Repository navigation
prototype(cli): patchy login end to end (#131) - #132
Closed
allisonmahmood wants to merge 11 commits into
Closed
allisonmahmood wants to merge 11 commits into
allisonmahmood wants to merge 11 commits into
Conversation
Throwaway prototype for the login-door ticket. Every /d/* page (and two door-only routes, /login/device and /sign-out) now sits behind route-scoped router middleware that hands the request to @clerk/backend's authenticateRequest, copies Clerk's headers back, redirects for the handshake, shows a script-free door page when signed out, and matches the Clerk user to a prototype_users row (migration 0090, just-in-time into acct_dev) before serving with private, no-store caching. ClerkSession.prototype.ts is the Effect service over the SDK; it builds without keys so the server boots and the door fails closed. It wraps globalThis.fetch to log every outbound call as [clerk-net], and the door logs one [door] line per request with the verdict, timings, network count and the Set-Cookie attributes Clerk returned (values redacted). The dev runner forwards every CLERK_* key from dev.env plus PROTOTYPE_DOOR_MODE. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…119 node scripts/prototype/login-door.mjs <patchUrl> walks the whole trip a person makes: the pasted link to the door page, the Account Portal sign-in with a +clerk_test address and code 424242, and back to the served patch, recording every main-frame hop with its status and Set-Cookie attributes, the cookie jar, and the [door]/[clerk-net] lines from dev.log. --wait N reloads after N seconds, --sign-out exercises the device page and the sign-out form, --print-jwt-key derives CLERK_JWT_KEY from the JWKS. Co-Authored-By: Claude Fable 5.1 <[email protected]>
… families (#119 experiment)
…edirects, in-memory router (#119) Seven offline tests over the login door prototype: a session signed by an RSA-2048 test keypair verifies through CLERK_JWT_KEY with no network and the door serves it; a hand-built fetch client on redirect: manual sees the SDK's handshake 307, its Location and the __clerk_redirect_count cookie; HttpRouter.toHttpEffect with HttpServerRequest.fromWeb drives the door in memory; HttpClient.withCookiesRef carries the loop-guard cookie across hand-driven hops until the SDK gives up; an expired session handshakes only a document GET and sign-out still expires every Clerk cookie while the BAPI revoke fails offline; and a pk_live_ key answers a cookie-less document GET with the door where a pk_test_ key handshakes. The fake instance, keypair, session signing, fetch guard and acct_dev seed live in @patchy/auth/testing so the other suites can be put behind the same door. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…uites green (#119) Pages.test.ts and the server's booted-whole test broke when the door went in front of /d/*: ClerkSession was not provided in one and the door failed closed with a 503 in the other. Both now take the offline instance's keys through their ConfigProvider, seed acct_dev for the door's just-in-time user row, and send a signed-in reader's cookies; a doored page is private, no-store, so the cache expectations follow. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…RL comment tells the truth (#119) Three corrections from the review round, so the branch reads as a true primary source for the real door: - `__clerk_handshake` and `__clerk_handshake_nonce` join what `/sign-out` expires, plain and suffixed. Nothing else clears them and the payload is a standing `__session` directive, so a browser that kept the cookie was signed in again on its next document GET. T8 now asserts the 303 expires the pair and the next GET is the door. - The comment over the Web `Request` claimed the SDK builds the handshake's `redirect_url` from the public URL. It does not: `deriveUrlFromHeaders` rebuilds the origin from `X-Forwarded-Host` / `Host` and `X-Forwarded-Proto`. The comment now says so, and says the real door has to pin those headers from `publicBaseUrl` too. - The door CSP gains `img-src data:` so the shared shell's grain is not blocked on door pages. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…what did not happen (#119) Copy only, from the review round. The device done page said the machine "was confirmed", but the POST only logs the choice and mints nothing. The outsider lede said the account "is not part of the company this patch is shared in", which is the wrong-company state; the page is the no-company one, whose product answer is create or join. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Throwaway, on top of the login-door prototype. Device login on the wire (POST /api/login/device, POST /api/login/device/token), a device-login table and service that mints the machine token on confirm, the confirm page behind the door in three copy variants (?v=a|b|c, and undoored at /prototype/login/device), its reverse states (deny, expired, answered, unknown, bare), the item-9 bounce back through the door, and patchy login in both shapes the research surfaced: Stripe's (block for a human, one JSON document plus --complete otherwise) and always-two-step (PATCHY_LOGIN_SHAPE=two-step). scripts/prototype/patchy-login.mjs drives the confirm page headlessly. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Owner
Author
|
Closed unmerged on purpose: a prototype, kept as the primary source for #131's decision. The branch stays. |
This was referenced Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prototype for #131, closed unmerged on purpose: the branch is the primary source for the device-login decision and the spec carries what was decided. Stacked on the login-door prototype (#127, also closed unmerged).
The question.
patchy loginprints a URL and a code that an agent relays to a human, then receives a machine token. An agent's shell tool waits for the process to exit, so a login that blocks never gets its URL in front of anyone. #130 narrowed the shapes to two; this builds both so the handoff, the confirm page and the reverse states could be felt rather than argued.What it builds. Two unauthenticated routes (
POST /api/login/device,POST /api/login/device/token), a device-login table and service that mints the machine token on confirm and hands it out exactly once on the poll, the confirm page behind the door in three copy variants (?v=a|b|c, undoored at/prototype/login/device), every reverse state (deny, expired, answered, unknown, bare, the #122 item 9 bounce), andpatchy loginin Stripe's shape and the always-two-step shape (PATCHY_LOGIN_SHAPE).scripts/prototype/patchy-login.mjsdrives the page headlessly.What it found is on #131: from the agent seat only the non-blocking shapes work, whatever the stream; the URL with the code survives the door and the portal in one click; deny, expiry, re-login and the stale-session bounce behave as #122 decided.
Made by Claude Fable 5.1 in Claude Code.