Skip to content

#17 Front end relay client behind proveRevenue - #75

Merged
Nabil-Aufa merged 9 commits into
mainfrom
feat/17-relay-client
Oct 29, 2026
Merged

Nabil-Aufa merged 9 commits into
mainfrom
feat/17-relay-client

Conversation

@Lin1er

@Lin1er Lin1er commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Refs #17. This PR is stacked on #57 (#20, @Nabil-Aufa) and only touches the proveRevenue seam. Nabil, it's your branch, so merge it into #57 or cherry-pick it, whichever you prefer.

The relay itself is in #73. Its API is documented in docs/api.md → "The proof relay".

What changes

  • lib/reclaim/relay.ts:

    • Opens Google's popup via the Identity Services token client, requesting adsense.readonly only. It loads Google's script, not an npm package.
    • Calls POST /proofs with { borrower, accessToken }, then polls GET /proofs/:id every 5 s.
    • Returns AdvanceRequest, converting timestampS and epoch with BigInt().
  • proveRevenue:

    • Uses the relay when NEXT_PUBLIC_RELAY_URL and NEXT_PUBLIC_GOOGLE_CLIENT_ID are both set.
    • If only the relay URL is set, it fails with relayNotReady.
    • With no relay URL, it runs the same mock as before.
  • Stages keep their meaning:

    • waiting is while Google's popup is open;
    • reading lasts from the relay job until it ends.
    • Closing the popup, or allowing it without the AdSense box ticked, raises ReclaimCancelledError, which already shows as "You closed the AdSense window".
    • reopen opens a new popup; if an older popup closes, the session doesn't end.
    • abandon stops polling, and the session never settles.
  • Three new prove failures, each mapped from the relay's error code:

    • googleSignIn (token);
    • noAdsense (account);
    • relayFailed (busy, or a failure on our side).

    The copy follows the existing rules and the tests check it. Nabil: the wording and illustrations are yours, so change them freely.

  • .env.example, README and ARCHITECTURE §3 now cover NEXT_PUBLIC_GOOGLE_CLIENT_ID.

Needed to run it for real

  • A Google OAuth client of type "Web application". Its authorized JavaScript origins must be the front end's origins. While the consent screen is in testing, sign-in only works for the test users listed on it.
  • The AdSense Management API enabled in that Google Cloud project.
  • The relay deployed, with the front end's origin in CORS_ORIGINS.

Verified

  • vitest: 137 pass, including six new relay-client tests:
    • the happy path;
    • closing the popup;
    • a failed job keeps its code;
    • busy answers 409/503;
    • reopen waits on the newest popup;
    • abandon.
  • Lint and typecheck are clean.
  • Not yet run in a real browser against a real Google account. That needs the OAuth client above and a READY AdSense account (FEASIBILITY GATE: one real AdSense revenue proof verified on testnet #5).

@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
forepay-vue5 Ready Ready Preview Oct 25, 2026 9:21am UTC
1 Skipped Deployment
Project Deployment Actions Updated
forepay Skipped Skipped Oct 25, 2026 9:21am UTC

@Lexirieru

Copy link
Copy Markdown
Collaborator

Retargeted to main and rebased — I force-pushed feat/17-relay-client, so git fetch && git reset --hard origin/feat/17-relay-client before you touch it again.

This was based on feat/20-prove-and-accept, which is now merged (#57). One commit was unique to this PR; it replays cleanly onto main, and the diff is +417/-22 across 13 files, unchanged from what the PR showed.

Green and mergeable now. Not reviewing it yet — same as #73, I would rather read it properly than approve it on momentum. It also touches fe/src/modules/advance/failures.ts, which @Nabil-Aufa changed in #57 and is changing again in #71, so it is worth landing #71 first to avoid a third round of conflicts in the same file.

Two things from the contract side that bear on this PR:

@Nabil-Aufa Nabil-Aufa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lin1er, thanks. The seam is the right size, the mock path is untouched, and the scope check on the token (adsense.readonly actually granted) is a good catch. I read the diff against docs/api.md on #73 and against the screens around proveRevenue. These are what I found, with the most important first.

Must fix before merge

  1. The waiting copy says "This takes a few seconds". Advance.tsx:388 shows "Reading your revenue: This takes a few seconds. Keep this page open." With the relay, that stage lasts about ten minutes plus the queue. A creator who believes "a few seconds" leaves, and loses the proof (see 2). This needs words that set the wait honestly. That copy is mine; I will write it unless you want to.

  2. Leaving or reloading during the ten minutes loses the proof, and coming back fails.

    • abandon() only stops polling. The job keeps running on the relay, and the job id lives only in memory.
    • The tab bar is right there, so a creator who comes back to /advance starts a new POST /proofs. That gets 409 ("already in progress"), which shows "We could not finish your proof", while their proof finishes unseen. Jobs are kept for an hour (docs/api.md), so the result is still there to be had.
    • Proposal: keep { borrower, jobId } in sessionStorage, as modules/advance/pending.ts already does for a sent advance. On return, poll that job instead of signing in again. On #73, a 409 could also return the running job's id, so a tab that lost its storage can pick the job up.
  3. A relay that does not answer is reported as Stellar. fetch failing on POST /proofs or a poll throws a TypeError. sorted() in failures.ts maps that to unreachable, "We could not reach Stellar", which is wrong and sends the creator to check the wrong thing.

    • Map transport failures from relay.ts to a RelayError (internal, or a new unreachable code), so they reach relayFailed.
    • The Google script failing to load (loadGis) needs the same. Today "Google sign-in failed to load" falls through to unexpected.

Should fix

  1. The popup can be blocked the first time. requestAccessToken() runs after await loadGis(). When the script is not cached, the popup opens outside the click's user activation, and browsers may block it.

    • Load the script when 2a mounts, so the press opens the popup at once.
    • Also handle error_callback with type: "popup_failed_to_open" on its own: today it reads as "You closed the AdSense window", but the creator closed nothing.
  2. 409, 503 busy and 503 "relay not configured" all become relayFailed, "Try again in a few minutes".

    • 409 is this wallet's own running job; with 2 it becomes a resume, not an error.
    • 503 with "relay": false is our misconfiguration and should read like relayNotReady, not "try again".
  3. The 30-minute give-up (timeoutMs) ends as relayFailed while the job may still finish within the relay's hour. With 2 in place, keep polling the stored job instead of starting over.

  4. No e2e for the relay path. The unit tests are good. The three new panels and the popup stage are not covered in Playwright, though. A routed /proofs and a stubbed window.google.accounts.oauth2 would cover them like tests/e2e/rpc.ts covers Stellar.

Copy and design (mine to finish, noted so they are not lost)

  • The waiting panel says "Log in to AdSense in the new window". It is now Google's sign-in, so it should say something like "Sign in with Google in the new window".
  • The three new failure panels all use the session-cancelled illustration and "Prove my revenue" + "Back". noAdsense probably wants its own words about which Google account to use; "Nothing was saved" is vague next to our "Nothing was charged" rule.
  • The board: the three panels and the long wait need adding to the design. @AncungAulia

Happy to take 1, 4 (the preload) and the copy myself on top of this PR if you prefer. 2 and 3 are in relay.ts, so tell me whether you want them or I do them.

These came from a review pass without a separate verification step (I read the code, I did not run it against a live relay), so please treat them as candidates and check each one.

🤖 Generated with Claude Code

@Lin1er

Lin1er commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@Nabil-Aufa thanks, all seven check out against the code. Split as you proposed:

  • Mine, in relay.ts / failures.ts and on #17 Proof relay: POST /proofs, bound to the borrower inside the signed claim #73: 2 (resume a stored job; 409 returns the running job's id), 3 (relay and Google-script transport failures become RelayError, not Stellar), 5 (409 resumes; 503 with "relay": false reads like relayNotReady), 6 (keep polling the stored job instead of giving up at 30 minutes), and popup_failed_to_open as its own code from 4.
  • Yours: 1 (the waiting copy), 4's preload when 2a mounts, the panel copy, and 7 (e2e) once the seam settles, unless you want me to take 7 too.

On the wait: proving is about a minute on the relay host (docs/deployments.md), not ten, but with a queue it can still be several, so the copy should not promise seconds.

I will push to this branch and say so here. Agreed on landing #71 first for failures.ts; I will rebase onto it.

Lin1er added a commit that referenced this pull request Oct 20, 2026
The front end has to tell "your proof is still running" from "the relay is
full" from "the relay is not set up here", and the status alone cannot: 503
means two of them. Each refusal now says which in `code`.

409 deliberately does not return the running job's id. A borrower's address is
public, and the id is what reads their revenue, so the front end keeps the id
it was given with the 202 (review on #75).
Lin1er added a commit that referenced this pull request Oct 20, 2026
Review on #75:

- The job id is kept in sessionStorage. Coming back to /advance, or
  reloading, while the relay proves waits on the same job without a second
  sign-in, instead of a new POST the relay refuses as already running.
  A kept job the relay no longer has (restart, or past its hour) starts a
  fresh proof. The id is cleared once the job ends, not when the screen is
  left.
- A relay that does not answer is RelayError unreachable, not "We could not
  reach Stellar". Google's script failing to load is googleUnavailable.
- error_callback popup_failed_to_open is popupBlocked: the creator closed
  nothing.
- 409 is running, 503 is busy or unconfigured, read from the relay's new
  `code` (#73), the status as fallback. unconfigured reads like
  relayNotReady, not "try again".
- No 30-minute give-up: polling runs to the hour after which the claim is
  too old and the relay has forgotten the job.
- preloadSignIn() is exported for 2a to call on mount (the preload in 4).

The copy for the four new panels is a first pass for Nabil to replace.
@Lin1er

Lin1er commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@Nabil-Aufa pushed 2, 3, 5, 6 and the popup_failed_to_open half of 4 to this branch. 176 FE tests pass, and lint and typecheck are clean.

  • 2, resume. The job id lives in sessionStorage (forepay.proof.job, the id and the borrower only). relayProveRevenue polls a kept job before it signs in. Advance mounts into it the same way it mounts into a pending advance (proofRunning(address)). A kept job the relay no longer has (it restarted, or the hour passed) gets a 404, and the session falls through to a fresh sign-in. The id is cleared when the job ends, not when the screen is left.
  • 409 does not return the running job's id. I decided against that half of the proposal on #17 Proof relay: POST /proofs, bound to the borrower inside the signed claim #73. A borrower's address is public, and the id is what reads their revenue, so anyone could read anyone's figure while it proves. A tab that lost its storage gets proofRunning ("Your proof is already being made… try again in a few minutes"). By then the job has ended, and the next press starts a new one.
  • 3. Transport failures to the relay are RelayError("unreachable") → relayUnreachable. loadGis failing is googleUnavailable. Neither is reported as Stellar anymore.
  • 5. The relay now sends code with every refusal (#17 Proof relay: POST /proofs, bound to the borrower inside the signed claim #73, live): running (409), busy (503 queue), unconfigured (503). unconfigured maps to relayNotReady.
  • 6. The 30-minute give-up is gone. It polls up to an hour, which is when the claim is too old anyway and the relay forgets the job.
  • 4. preloadSignIn() is exported from @/lib/reclaim for 2a to call on mount. I left the call to you with the rest of 2a.

The copy for the four new kinds (proofRunning, relayUnreachable, googleUnavailable, popupBlocked) is a first pass in lib/errors.ts, and they share the relayFailed panel. Replace any of it freely.

Lexirieru pushed a commit that referenced this pull request Oct 20, 2026
…d claim (#73)

* feat(#17): proof relay, POST /proofs and GET /proofs/:id

The relay takes the borrower's G… and a Google access token with
adsense.readonly, proves the trailing AdSense revenue with zkFetch, and
returns request_advance's arguments. The G… goes into contextAddress before
the attestor signs, so the binding is inside the signed claim (#9).

Proving takes about ten minutes of CPU with snarkjs, so the request answers
202 with a job id and the front end polls. One proof runs at a time; one job
per borrower; a short queue. Jobs live in memory and the token only in the
running job's closure: never stored, logged or returned, and scrubbed from
errors.

The pre-flight checks (account, READY, response shape) move from the
prove:adsense CLI to adsense/account.ts and relay/prove.ts, so the CLI and
the relay run the same code. Failures carry a code that says whose move it
is: token, account, provider, prove, audit.

The browser flow and the API are in docs/api.md.

* docs(#17): the API and the relay, public at api-forepay.jameshub.fun

Deployed from feat/17-proof-relay with #74 merged in. /config reports the
recorded addresses and relay: true; /ready answers. A smoke proof made on
the host was signed by the production attestor in 54 s and passes
verify_proof in simulation, with the one-byte flip refused as #5.

* docs(#17): proving takes about a minute on the relay host, not ten

* feat(#17): relay errors carry a code: running, busy, unconfigured

The front end has to tell "your proof is still running" from "the relay is
full" from "the relay is not set up here", and the status alone cannot: 503
means two of them. Each refusal now says which in `code`.

409 deliberately does not return the running job's id. A borrower's address is
public, and the id is what reads their revenue, so the front end keeps the id
it was given with the 202 (review on #75).

* fix(#17): refuse an access token too short to be Google's

Scrubbing a one-character token out of a failure message cut that
character out of every word ("e[redacted]pired"), seen live on the relay.
Google's tokens run to hundreds of characters; under 16 is a 400.
@Lexirieru

Copy link
Copy Markdown
Collaborator

@Nabil-Aufa — one item in your review should be dropped rather than implemented, and it is worth saying before @Lin1er builds it.

Item 2's second half would leak creators' revenue

"On #73, a 409 could also return the running job's id, so a tab that lost its storage can pick the job up."

The job id is a bearer capability: whoever holds it can GET /proofs/:id and read that creator's AdSense revenue to the cent. The borrower's G… is the opposite of a secret — it is on the ledger, in every transaction they have signed, and in the URL of their own explorer page.

If the 409 returned the id, anyone who knows a creator's address could POST /proofs with it and a junk token, get back the id of the creator's running job, and poll it until the revenue figure comes out. James's comment at app.ts:198 already says exactly this, and he was right to leave it out:

No job id here: a borrower's address is public, and the id is what reads their revenue.

The rest of item 2 is right, and is the whole fix

The sessionStorage {borrower, jobId} resume solves the case that actually happens — navigate away, come back — and it needs nothing from the relay. Keep that.

For a tab that genuinely lost its storage (hard reload, crash, another device) there is no safe recovery without proving control of the wallet, which means signing a challenge the relay verifies. That is a real feature and not a 30-day one. So the honest behaviour is prove again, with copy that says so — much better than today's "We could not finish your proof", which is what you correctly flagged.

And one thing neither of us caught: a resumed job can hand you a dead proof

The relay keeps a finished job readable for an hour, and the contract refuses a proof older than an hour, measured from the attestor's timestampS — set near the end of proving. So a tab that resumes at minute 50 gets stage: "done" with a complete AdvanceRequest whose proof has minutes left, the creator approves a wallet signature, and the last step of the flow fails with #12 ProofStale.

Nothing is charged — simulation refuses it before submission — but it is the worst place in the flow to fail, and your resume is what makes it likely.

I asked James to put the deadline in the job view:

/** Unix seconds after which the contract will refuse this proof as stale. */
expiresAt?: number;   // Number(request.timestampS) + 3600

With that, 2a can say "this proof has expired, prove again" before asking for a signature. Please check for it when you wire the resume; if it is not there yet, Number(request.timestampS) + 3600 is the same number computed in the front end.

Everything else in your review reads right to me, and item 1 is the most important thing on this PR: "This takes a few seconds" for a ten-minute wait is what causes the data loss in item 2.

proveRevenue now uses the #17 relay when NEXT_PUBLIC_RELAY_URL and
NEXT_PUBLIC_GOOGLE_CLIENT_ID are set. The creator signs in with Google's
own popup (Identity Services token client, adsense.readonly only), the
token and the wallet's G… go once to POST /proofs, and the job is polled
until it answers with request_advance's arguments. No Reclaim SDK runs in
the browser.

Stages keep their meaning: waiting while Google's popup is open, reading
from the relay job until it ends. Closing the popup, or allowing without
the AdSense scope, is ReclaimCancelledError, as closing the window was.
Reopening waits on the newest popup. An abandoned session stops polling
and never settles.

Relay failures carry the relay's code. Three new prove failures say whose
move it is: googleSignIn (sign in again), noAdsense, relayFailed. The mock
is unchanged while NEXT_PUBLIC_RELAY_URL is empty.
Review on #75:

- The job id is kept in sessionStorage. Coming back to /advance, or
  reloading, while the relay proves waits on the same job without a second
  sign-in, instead of a new POST the relay refuses as already running.
  A kept job the relay no longer has (restart, or past its hour) starts a
  fresh proof. The id is cleared once the job ends, not when the screen is
  left.
- A relay that does not answer is RelayError unreachable, not "We could not
  reach Stellar". Google's script failing to load is googleUnavailable.
- error_callback popup_failed_to_open is popupBlocked: the creator closed
  nothing.
- 409 is running, 503 is busy or unconfigured, read from the relay's new
  `code` (#73), the status as fallback. unconfigured reads like
  relayNotReady, not "try again".
- No 30-minute give-up: polling runs to the hour after which the claim is
  too old and the relay has forgotten the job.
- preloadSignIn() is exported for 2a to call on mount (the preload in 4).

The copy for the four new panels is a first pass for Nabil to replace.
@Lin1er
Lin1er force-pushed the feat/17-relay-client branch from 8176b6f to bb65d2e Compare October 23, 2026 03:24
@Lin1er

Lin1er commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main after #71 landed. One conflict, in Advance.tsx's mount effect: #71 renamed resume to pickUp. Resolved by keeping both, a pending advance first, then a proof still running. 187 FE tests pass locally, and lint and typecheck are clean. @Nabil-Aufa ready for your re-review. The two remaining items from your list (the waiting copy, and calling preloadSignIn() when 2a mounts) are yours, as agreed.

@Nabil-Aufa Nabil-Aufa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lin1er, thanks for the rebase and the fixes. I re-read bb65d2e against my first review and docs/api.md, and ran it: lint and typecheck clean, 187 unit tests and 206 Playwright tests pass here.

Fixed as asked: relay failures are the relay's (polls included), popup_failed_to_open has its own panel, 409 / 503 read the relay's code, the 30-minute give-up is gone, and a proof that finishes while the creator is away is found on return. A poll that fails on the network keeps the id, so the next press resumes. Good.

Must fix

  1. A kept job the relay no longer has opens Google's popup outside any press. When follow(kept) gets 404 (the relay restarted, or the creator is back more than an hour after the job ended), prove() clears the id and calls signIn() straight away.
    • From the mount effect (proofRunning(address) → prove()), that is a popup with no click at all.
    • From a press, it opens after an await, outside the click's user activation.
    • Either way the browser blocks it, and the creator reads "Your browser blocked the Google window", which is not what happened. I confirmed the call with a throwaway test: kept id, relay answering 404, and signIn runs once with no press.
    • Proposal: on 404, clear the id and end the session back at 2a (a new error kind, or a quiet return to the start), so the next press opens the popup inside its click.

Small

  1. proofRunning copy promises a pick-up that cannot happen. "Try again in a few minutes to pick it up": the 409 deliberately carries no id (docs/api.md), so a tab that lost it can only start a new proof once the old one ends. That copy is mine; I will rewrite it with the other panels.
  2. One slot for every wallet. JOB_KEY holds one { borrower, id }, so proving with a second wallet in the same tab overwrites the first one's id. Rare; fine to leave, worth a comment.

As agreed, I am taking the waiting copy, preloadSignIn() on 2a, the panel copy, the stale-proof check before signing and the e2e. Since you are away until tomorrow, I can also do 1 on this branch as a separate commit, unless you would rather keep it.

🤖 Generated with Claude Code

Nabil-Aufa and others added 5 commits October 25, 2026 15:21
…in outside a press

When the relay answers 404 for the job id this tab kept (it restarted, or the hour
passed), the session used to clear it and call signIn() straight away. From the mount
effect that opens Google's popup with no press at all, and from a press it opens after
an await. The browser blocks it, and the creator read "Your browser blocked the Google
window", which is not what happened.

Now the session ends as RelayError("gone"), shown as "Your earlier proof has ended"
with Prove my revenue, so the next sign-in opens inside a click.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the popup

Also on a failure panel, whose Prove my revenue starts the same sign-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… relay's panels

- Waiting: "Sign in with Google in the new window", naming the account and the AdSense box
  to tick. 2a says "Sign in with Google" too.
- Reading: about a minute, longer behind a queue; other pages are safe, a closed tab means
  proving again. It no longer promises a few seconds.
- noAdsense names the Google account as the thing to change.
- proofRunning no longer promises to pick the job up: a 409 carries no id, so it says to
  wait for it to end and prove again.
- busy has its own panel, "Forepay is busy right now", instead of relayFailed.
- "Nothing was saved" becomes "Nothing was charged", the rule the other panels follow.
- "You closed the Google window", since the window is Google's now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second e2e build has NEXT_PUBLIC_RELAY_URL and a Google client id set (the relay-desktop
and relay-mobile projects). Google's sign-in is a stub on window.google, which relay.ts
uses when it is already there, and the spec answers /proofs as docs/api.md describes.

Covered: the offer after a real-shaped job, noAdsense, the Google window closed and
blocked, a full queue, a 409 from a tab that lost its job, leaving and coming back to the
same job with one sign-in and one POST, and a kept job the relay no longer has, which must
not open Google's window until the creator presses.

Jobs are polled every 200 ms under NEXT_PUBLIC_E2E, as the mock shortens its delays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lashes 2a

From the strict review of the four commits before this one:
- proofGone: "Your earlier proof is gone", worded for both causes (the relay restarted, or
  an hour passed); the proof did not necessarily finish. Proof-expired illustration.
- noAdsense covers all of the relay's `account` cases: none, several, or not approved.
- popupBlocked and googleUnavailable: "Nothing was read or charged", like relayBusy. The
  cancelled panel keeps the board's "Nothing was read or saved"; the previous commit's body
  overstated how far that rule went.
- The relay panels pair "Prove again" with "Back" in a row, as the board's pairs do;
  "Prove my revenue" did not fit half the row.
- Back on /advance with a kept job, "Reading your revenue" shows from the first render, as
  a pending advance does, so 2a's button never flashes.
- Comments: why accept has no clock check on the proof (simulation refuses with 12 before
  the wallet is asked), the reading copy describes the relay, and JOB_KEY holds one wallet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nabil-Aufa and others added 2 commits October 25, 2026 15:47
…me, and make the relay build optional

- Unit: a poll that fails on the network keeps the id, and the next press reaches gone with
  no sign-in. The relay kinds' "Nothing was charged" claims are asserted.
- e2e: token and prove failures with Prove again, a relay that does not answer, Google's
  script loading on 2a before any press, the script failing to load, and no flash of 2a's
  button when coming back to a running proof.
- PW_RELAY=0 leaves out the relay dev server and its projects, for quicker single-spec runs.
  README and .env.example say what the second build and NEXT_PUBLIC_E2E now do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s every account case

From the strict re-review:
- A failure that keeps the job id (a poll that failed on the network) left "Back" on a
  "Reading your revenue" spinner with nothing running: the start screen shows it for a kept
  job, and toStart() never started the session. toStart() now waits on the kept job, as it
  does on a pending advance. Two e2e: Back after a failed poll reaches the offer with one
  sign-in and one POST; Back after a gone job returns to 2a.
- noAdsense: "We could not use your AdSense account", true for none, several, or not
  approved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Nabil-Aufa

Copy link
Copy Markdown
Collaborator

@Lin1er, since you are away I took the must-fix from my last review as agreed, plus my own part, as commits on top of bb65d2e. Nothing of yours was rewritten. If you would rather do the 404 fix your way, drop d4ec16b: the commits after it do not depend on how it is done, only on the gone code.

What changed

Commit What
d4ec16b The must-fix. A kept job the relay answers 404 for ends as RelayError("gone"), shown as "Your earlier proof is gone" with Prove again. signIn() is never called outside a press.
c428e18 preloadSignIn() while 2a or a failure panel is shown.
10cd4bf Copy for the Google sign-in, the minute-long wait and the relay panels. busy gets its own panel.
e5d6303 e2e for the relay path: a second dev server with the relay and a client id set, Google stubbed on window.google, /proofs answered by the spec.
9914ec0, ec245af, 2fdfa59 Fixes from a strict review (three rounds, PASS), described below.

Fixes found in review:

  • Coming back to /advance with a kept job shows "Reading your revenue" from the first render, so 2a's button never flashes.
  • "Back" with a kept job waits on it, instead of a spinner with nothing running.
  • Every relay panel pairs "Prove again" with "Back".

The stale-proof check: not added, on purpose

I said I would add a clock check before signing. It is not needed:

  • requestAdvance simulates before it asks the wallet;
  • the contract refuses a proof over an hour old with 12, which shows as "This proof expired";
  • so no signature is asked for a stale proof.

The e2e "a proof that expires while the offer is open is named at accept" covers it. A comment in Advance.accept says so.

One behaviour worth knowing

While the relay is down and a job id is kept, "Back" shows "We could not reach Forepay" again. The creator reaches 2a once the relay answers (the job is done or gone) or the tab is closed. Nothing can be proved without the relay meanwhile.

For the board (@AncungAulia)

Changed on purpose. These replace strings on "Prove and accept / States and interactions", because the window is Google's now and the relay takes about a minute:

Where Board Now
2a body "Log in to AdSense in a secure window. We read your revenue for the last three months and nothing else." "Sign in with Google in a secure window. We read your AdSense revenue for the last three months and nothing else."
Waiting "Log in to AdSense in the new window" / "We only read your revenue for the last three months. Your password never reaches us." "Sign in with Google in the new window" / "Pick the Google account that owns your AdSense, and allow Forepay to see your AdSense reports. We only read your revenue for the last three months."
Reading "This takes a few seconds. Keep this page open." "This takes about a minute, longer when others are proving too. You can use other pages meanwhile. Closing this tab means proving again."
Cancelled title "You closed the AdSense window" "You closed the Google window" (body unchanged)

New panels, not on the board yet. Each has "Prove again" and "Back":

Panel Title / body
noAdsense "We could not use your AdSense account" / "We could not find one approved AdSense account on this Google account. Sign in with the account that owns your AdSense, then try again. Nothing was charged."
googleSignIn "Google did not let us read AdSense" / "Sign in again and allow Forepay to see your AdSense reports. Nothing was charged."
relayBusy "Forepay is busy right now" / "Many creators are proving at once. Nothing was read or charged. Try again in a few minutes."
proofRunning "Your proof is already being made" / "A proof for this wallet started earlier, in a tab that no longer has it. Wait a few minutes for it to end, then prove again. Nothing was charged."
proofGone "Your earlier proof is gone" / "We no longer have the proof you started earlier. Prove your revenue again, it takes about a minute. Nothing was charged." (proof-expired illustration)
relayFailed "We could not finish your proof" / "Nothing was charged. Try again in a few minutes."
relayUnreachable "We could not reach Forepay" / "Nothing was charged. Check your connection, then try again."
googleUnavailable "Google sign-in did not load" / "Nothing was read or charged. Check your connection, then try again."
popupBlocked "Your browser blocked the Google window" / "Allow pop-ups for Forepay, then try again. Nothing was read or charged."

All but proofGone use the session-cancelled illustration for now.

The board draws "Prove again" + "Back" stacked. The code puts the pair in one row from 768 up, under section 08's rule, as the code-12 and code-14 panels already do. Tell me if the board should win.

Checked

  • Lint and typecheck are clean.
  • 189 unit tests pass.
  • Playwright: 238 pass, 22 skipped. That includes 32 relay runs, desktop and mobile.
  • PW_RELAY=0 leaves the relay build out, for quicker single-spec runs.
  • A strict review against the pen file, Playwright and real Chrome passed on the third round.

Still mine after merge: the env in Vercel (@AncungAulia) and the app.forepay.xyz OAuth origin (@Lin1er), then the full-flow screenshots for #22.

🤖 Generated with Claude Code

@Lin1er

Lin1er commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator Author

@Nabil-Aufa thanks for taking these. I read d4ec16b to 2fdfa59 and keep all of them, including your 404 fix: throwing gone instead of signing in is the right call, and it is the smaller change. The one-slot comment on JOB_KEY covers item 3.

Checked here on 2fdfa59: 189 unit tests pass and typecheck is clean; CI is green on the same commit.

Agreed on leaving out the clock check: simulation refuses a stale proof before the wallet is asked, and the e2e pins it.

The app.forepay.xyz origin is on the OAuth client since 2026-10-23 (noted on #86), so nothing of mine is left on this PR. @Lexirieru it is ready for your review and merge.

Lexirieru pushed a commit that referenced this pull request Oct 25, 2026
app.forepay.xyz serves fe/ from main on testnet. The record says how it
was checked, by the rendered page in Chrome and headless Chromium, and
that the API now answers the deployed origin.

The screenshots are all of the live app. None of the offer, signing or
repayment is included: on this deployment proving runs on the mock,
which the contract refuses, until the relay client (#75) and a real
proof (#77) land. Deliverable 2 stays Partial for that reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lexirieru pushed a commit that referenced this pull request Oct 25, 2026
app.forepay.xyz serves fe/ from main on testnet. The record says how it
was checked, by the rendered page in Chrome and headless Chromium, and
that the API now answers the deployed origin.

The screenshots are all of the live app. None of the offer, signing or
repayment is included: on this deployment proving runs on the mock,
which the contract refuses, until the relay client (#75) and a real
proof (#77) land. Deliverable 2 stays Partial for that reason.

Co-authored-by: Nabil-Aufa <181296848+Nabil-Aufa@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@Lin1er

Lin1er commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator Author

@Nabil-Aufa your review from 2026-10-23 is still Changes requested, although every item in it is fixed, by your own commits d4ec16b…2fdfa59 (accepted in my comment above). Could you re-review and approve, or dismiss it, so the PR's state matches where it actually is?

@Lexirieru the branch is MERGEABLE / CLEAN at 2fdfa59, and CI is green (Rust, TypeScript, Python). It is ready for your merge once that review is cleared.

@Nabil-Aufa Nabil-Aufa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every item from my reviews of 2026-10-20 and 2026-10-23 is fixed, in d4ec16b…2fdfa59, and @Lin1er has accepted those commits above. Checked again on 2fdfa59: the head is unchanged since the strict review passed, CI is green (Rust, TypeScript, Python, Vercel), and it merges into current main with no conflicts. Approving. @Lexirieru, it is ready for your merge.

🤖 Generated with Claude Code

@Nabil-Aufa

Copy link
Copy Markdown
Collaborator

Merging under the working agreement's two-day clause: approved on 2026-10-26 at 2fdfa59, CI green, and no overlap with main since (this PR touches fe/ only; main has not touched fe/). @Lexirieru, for the record.

Without NEXT_PUBLIC_RELAY_URL on Vercel the live app keeps the mock, so nothing changes for the live site until the env is set. Squash merged without deleting feat/17-relay-client, so #104 retargets to main instead of closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants