Repository navigation
feat(web): App Connect v2 wallet sign-in on a vendored platform-auth core - #604
Conversation
Copy platform-auth's App Connect v2 module (src/app-connect at a627708, feat/app-connect-module) into forge-web/lib/vendor/platform-auth with platform-auth's tools/vendor.mjs; VENDORED.json records the commit and a hash per file. The module's only externals are @noble/hashes and @noble/secp256k1, which Forge already depends on, and it is clean under Forge's noUncheckedIndexedAccess. Its tests run in pnpm test. - copy-lint skips lib/vendor: those strings are upstream developer errors, and editing them would only add drift. - eslint limits imports of the vendored test-helpers (fixed-seed vector requests) to tests and lib/auth/wallet-sim.ts. - pnpm vendor:status reports drift against a platform-auth checkout (PLATFORM_AUTH_DIR, default ../../platform-auth). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add Forge's App Connect v2 sign-in core beside the v1 flow, which is unchanged (a v1 wallet refuses a v=2 request, so they never share a QR). - app-connect-port: the vendored verifier's and poller's ports over the SDK (proved identity reads, remaining budgets, contract keys, answers in the App Connect contract sorted by owner bytes) and the chain clock. A key whose type, data or bounds cannot be read is dropped, never treated as unbound. - app-connect-v2: one request for a HIGH key bound to the dash-forge group with Forge's default limits from chain time (app forge-core, label "Dash Forge", connection id, CREATED_AT from this device's clock, no encryption binding, no MODE; a renewal adds IDENTITY_HINT). The QR carries no callback, the deep link may. awaitV2Grant pages every answer, verifies each against chain time, refuses when two identities answered (counting every answer that opens), settles like v1, then checks the key again with findWalletKey and wipes the granted and ephemeral keys. - connection-id: the per-network connection id (kept across logout and forget) and the renewal-in-flight mark, both in localStorage. - wallet-sim: answerV2, a v2 wallet on the vendored parser and sealing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- vault: a stored key's origin is 'dg' or 'app-connect' (VaultInfo
fromAppConnect, storedOrigin); a master-key renewal clears it.
- controller: AuthSession.origin (from the stored record, validated in a
kept hint); adoptWalletKeys({ origin: 'app-connect' }) stores it, drops
held keys the chain shows disabled, refuses to overwrite a key another
tab stored meanwhile, and ends the renewal mark. An App Connect key
starts no write within APP_CONNECT_SIGNING_EXPIRY_MARGIN_MS of expiry.
walletRenewalRequest/endWalletRenewal renew in the wallet with the same
connection id; while the mark names a key, a tab that finds it disabled
neither locks nor drops its unlock. walletSignInBlocker says when a
locked vault must be unlocked before a v2 sign-in; recheckSession
re-verifies the keys.
- write-errors: for App Connect sessions, a disabled or removed key reads
as revoked by the wallet and a write outside the key's bounds asks for a
recheck (classifyAppConnectError).
- funds: renewFix and fundsNotice(state, origin) route renewal of an App
Connect key to the wallet, at the same thresholds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wallet tile now shows an App Connect v2 request first where the chain supports it: one approval for a key that works on every Forge contract, with a budget and an expiry, so no guided grants follow. A link switches to the older code (v1, unchanged) for wallets without v2, and back. - wallet-connect-flow: v2 login with the group and locked-key checks before the code, confirm step with the granted limits and group notice, poll on focus and visibility and on the return page's nudge, and mode="renew": protection is chosen before the code shows, the new key is stored even if the sheet is closing (held for a decision or unlock when it cannot be stored yet), and the renewal mark ends on every way out but a stored key. - /connect/ (static) and lib/auth/connect-callback: the phone link's `cb` (https, canonical origin, never on IPFS builds), `r`/`ac` parsing, and the BroadcastChannel nudge and ack between the return page and the tab that shows the code. A wallet-reported decline reaches that tab. - Wallet-granted keys are renewed in the wallet from the low-funds banner, the top-up sheet and Settings, with the identity file as the other way; the write guard passes the session origin to writeFailure and re-checks the session on a write refused as outside the key's bounds. - The wallet tile comes first where v2 is on offer; WalletSupportNote and the sheet copy follow. `connect` is a reserved short-URL segment. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- e2e/wallet-responder-v2.ts: a scripted wallet that follows the profile's wallet rules (freshness, one HIGH contractGroup binding of the Forge group with a budget and expiry, no encryption binding), adds one group-bound key and disables the previous grant for the same connection id in one master-signed update, then publishes the sealed loginKeyResponse. It reuses `connect()` of wallet-responder.mjs, now exported. Its request checks are unit tested (lib/auth/wallet-responder-v2.test.ts). - e2e/wallet-login-v2.spec.ts: read-only checks (wallet tile first, the v2 request and its terms, the older code and back, the phone link, the /connect/ return page) that skip themselves when no devnet node is reachable, and a live scenario behind E2E_WRITE=1 (login, a star with no grant sheet, renewal in the wallet, the old key disabled). - lib/auth/app-connect-v2.live.test.ts: the same on a controller, gated by FORGE_LIVE=1. - e2e/wallet-login.spec.ts takes "Show the older code" first on a devnet, where the v2 request now comes first. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
wallet-login.md gets a v2 section (the request, availability and group trust, verification, the session, the write-error table, renewal, the callback, what is not done) and a compatibility row for v2 wallets and the scripted responder, with the live tests marked as not yet run. ux-dx-spec 2.2 describes tile 1 as v2-first with the older code behind a link, and 2.3 the renewal in the wallet. CHANGELOG notes it under Unreleased. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Follow-up to the App Connect v2 sheet after review: - A wallet renewal stores through the sheet's shared `finish` with the protection chosen before the code showed. A key that cannot be stored yet (an unfinished renewal on this device, a locked vault) stays on screen with a retry; closing the sheet ends the renewal mark unless a store is running, in which case that attempt ends it if it fails. - A failed or restarted v2 request goes off screen at once, and the older code stays reachable when the group read keeps failing. The older code no longer re-reads the group. - `ac=constructor` and other inherited names are not statuses. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Protocol and payload contracts forge-web/lib/vendor/platform-auth/app-connect/*, forge-web/lib/vendor/platform-auth/VENDORED.json |
Adds v2 request encoding and URI handling, payload cryptography, shared types, and test vectors. |
Grant verification and key selection forge-web/lib/vendor/platform-auth/app-connect/* |
Adds response polling, grant verification, group-trust checks, error classification, and signing-key selection. |
Forge request and chain integration forge-web/lib/auth/app-connect-v2.ts, forge-web/lib/auth/app-connect-port.ts, forge-web/lib/auth/connection-id.ts, forge-web/lib/auth/wallet-sim.ts, forge-web/lib/sdk/facade.ts |
Adds Forge request creation and polling, SDK-backed chain reads, connection IDs, renewal markers, and wallet simulation support. |
Wallet-origin session and renewal lifecycle forge-web/lib/auth/controller.ts, forge-web/lib/auth/vault.ts, forge-web/contexts/auth-context.tsx |
Stores App Connect key origin, coordinates renewal, checks signing expiry, and rechecks vault sessions against chain state. |
Sign-in, callbacks, and wallet renewal flow forge-web/components/auth/*, forge-web/components/login-modal.tsx, forge-web/app/connect/page.tsx, forge-web/lib/auth/connect-callback.ts |
Adds v2-first sign-in with a v1 switch, callback handling for phone returns, grant confirmation, and a wallet renewal view. |
Renewal prompts and write-failure handling forge-web/components/keys-panel.tsx, forge-web/components/low-funds-banner.tsx, forge-web/components/top-up-sheet.tsx, forge-web/lib/view/*, forge-web/hooks/use-write-guard.ts, forge-web/components/repo/bulk-actions.tsx |
Routes App Connect renewal notices to the granting wallet and classifies wallet-key write failures with session context. |
End-to-end coverage and supporting updates forge-web/e2e/*, forge-web/scripts/*, forge-web/package.json, forge-web/.eslintrc.json, docs/design/*, CHANGELOG.md, .gitleaks.toml |
Adds scripted-wallet and browser coverage, updates design and changelog text, and adjusts vendoring and lint support. |
Priority:
Estimated code review effort: 4 (Complex) | ~60 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant User
participant ForgeBrowser
participant Wallet
participant ForgeChain
User->>ForgeBrowser: Start wallet sign-in
ForgeBrowser->>ForgeBrowser: Build and display App Connect v2 request
Wallet->>ForgeChain: Publish encrypted approval response
ForgeBrowser->>ForgeChain: Poll for response and verify granted key
ForgeBrowser->>User: Show identity and granted limits
User->>ForgeBrowser: Confirm identity
ForgeBrowser->>ForgeBrowser: Store wallet-origin session
Merge Risk: 
Minimal · up to fb67d
-
This change adds App Connect v2 wallet sign-in and renewal while keeping the v1 flow available. No concrete merge-blocking problem was found. The live wallet and e2e paths were not run because the sakura nodes were unreachable, so they remain untested end to end.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 inconclusive Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description clearly explains the change, scope, implementation, testing, documentation updates, and known test limitations. It uses different headings from the template and does not include the requested screenshot section or explicitly check every template checkbox, but it is substantially complete.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 62.04% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 108 functions across 50 files. (22 skipped: 8 unsupported, 14 over the file limit.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 2
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in master (testnet registration, Platform SDK rc.8, zod 4) via #604. Testnet registered forge-meta without vaultEntry, so passkey_vault joins testnet's 'since' in NETWORK_REGISTRATIONS (build.py --check reproduces the registered bytes again), and the vault deployment notes now say testnet needs the same forge-meta update as sakura. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Adds App Connect v2 wallet sign-in to forge-web. One wallet approval grants a key that is bound to the Forge contract group (HIGH, with a budget and an expiry), so a v2 sign-in no longer needs per-contract guided grants. v1 stays available.
lib/vendor/platform-auth/app-connect/is copied bytools/vendor.mjsfrom feat: App Connect v2 protocol module and vendor sync tool platform-auth#5 ata627708.VENDORED.jsonrecords the commit and the file hashes. Forge owns this copy and may diverge;pnpm vendor:statusreports drift. The vendored tests run inpnpm test.lib/auth/app-connect-v2.ts,app-connect-port.ts,connection-id.ts):contractGroup(forge.group)auth binding usingdefaultLimits(chainNow). TheappIdis forge-core and the label isDash Forge. There is no encryption binding, because no Forge contract allows wallet-issued encryption keys.MODE, which wallets don't support yet.assertGroupHolds.controller.ts,vault.ts): a granted key goes throughfindWalletKeyand then the existingadoptWalletKeys(origin: 'app-connect'). Vault, session resume, key watch, the devices list, and master-key renew, top-up and revoke are all reused unchanged.walletSignInBlocker()asks for an unlock first, before a v2 code is shown over a locked vault that holds wallet keys.wallet-connect-flow.tsxshows v2 first where it is available, with a "Show the older code" link to the unchanged v1 flow. The sheet re-checks for an answer on focus, on visibility change, and when/connectnudges it.mode="renew"handles renewal. The low-funds banner, top-up sheet and keys panel point wallet-granted keys at "Renew in your wallet", with the identity file as the second option./connect/return page relays the wallet'sacstatus to the waiting tab over BroadcastChannel. It is used only on the canonical https origin, never on IPFS builds.wallet-sim.tsanswerV2,e2e/wallet-responder-v2.ts) can now answer v2 requests.e2e/wallet-login-v2.spec.tsandlib/auth/app-connect-v2.live.test.tsare new, behindE2E_WRITEandFORGE_LIVE.docs/design/wallet-login.md,ux-dx-spec.md§2.2–2.3 and CHANGELOG are updated.v2 is only offered where Forge v2 is deployed and the chain runs protocol 14 or later. Today that means devnet sakura.
Not in this PR
vaultEntrycontract type.Test plan
pnpm typecheck && pnpm lint && pnpm lint:copy && pnpm test(after merging master): 9488 passed, 38 skippedpnpm build, andout/connect/index.htmlexistsE2E_DEVNET=sakura): the four/connect/return-page tests passFORGE_LIVE=1 NEXT_PUBLIC_NETWORK=devnet NEXT_PUBLIC_DEVNET_NAME=sakura pnpm exec vitest run lib/auth/app-connect-v2.live.test.tsandE2E_DEVNET=sakura E2E_WRITE=1 pnpm exec playwright test wallet-login-v2.spec.ts. Both need reachable sakura nodes and a funded RELAY identity (about 0.2 DASH). Not run yet.🤖 Generated with Claude Code