Skip to content

feat(web): App Connect v2 wallet sign-in on a vendored platform-auth core - #604

Merged
PastaPastaPasta merged 9 commits into
masterfrom
feat/app-connect-login
Oct 26, 2026
Merged

PastaPastaPasta merged 9 commits into
masterfrom
feat/app-connect-login

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

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.

  • Shared protocol code (vendored). lib/vendor/platform-auth/app-connect/ is copied by tools/vendor.mjs from feat: App Connect v2 protocol module and vendor sync tool platform-auth#5 at a627708. VENDORED.json records the commit and the file hashes. Forge owns this copy and may diverge; pnpm vendor:status reports drift. The vendored tests run in pnpm test.
  • Request, poll and verify (lib/auth/app-connect-v2.ts, app-connect-port.ts, connection-id.ts):
    • The request: one contractGroup(forge.group) auth binding using defaultLimits(chainNow). The appId is forge-core and the label is Dash Forge. There is no encryption binding, because no Forge contract allows wallet-issued encryption keys.
    • Renewal sends the identity hint and the same connection id. It does not use MODE, which wallets don't support yet.
    • Group trust comes from Forge's own assertGroupHolds.
    • Two identities answering is refused, as in v1.
    • Clocks: the verifier and the proposed expiry use chain time.
  • Sessions (controller.ts, vault.ts): a granted key goes through findWalletKey and then the existing adoptWalletKeys (origin: 'app-connect'). Vault, session resume, key watch, the devices list, and master-key renew, top-up and revoke are all reused unchanged.
  • Renewal handling.
    • A marker for the renewal in flight stops the renewing tab from signing itself out while the wallet swaps keys.
    • Replaced keys that the chain shows disabled are dropped from the stored extras.
    • walletSignInBlocker() asks for an unlock first, before a v2 code is shown over a locked vault that holds wallet keys.
  • Write errors: Platform key-limit and key-state codes are classified for App Connect sessions (renew in wallet, lock, or recheck).
  • UI.
    • Sign-in sheet: wallet-connect-flow.tsx shows 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 /connect nudges it.
    • Renewing: 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.
    • Wallet return: a static /connect/ return page relays the wallet's ac status to the waiting tab over BroadcastChannel. It is used only on the canonical https origin, never on IPFS builds.
  • Tests and docs.
    • The scripted wallet (wallet-sim.ts answerV2, e2e/wallet-responder-v2.ts) can now answer v2 requests. e2e/wallet-login-v2.spec.ts and lib/auth/app-connect-v2.live.test.ts are new, behind E2E_WRITE and FORGE_LIVE.
    • Docs: 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

  • The on-chain passkey vault. It comes in a follow-up stacked on this branch, together with the vaultEntry contract type.
  • The wallets' known-app list. Wallets show an unknown-app warning for Forge until Forge is listed.
  • Encryption keys from a v2 sign-in. Private repos still use the existing Settings route.

Test plan

  • pnpm typecheck && pnpm lint && pnpm lint:copy && pnpm test (after merging master): 9488 passed, 38 skipped
  • pnpm build, and out/connect/index.html exists
  • Playwright (chromium, E2E_DEVNET=sakura): the four /connect/ return-page tests pass
  • v2 read-only e2e (r1, r2): skipped locally because the sakura DAPI nodes were unreachable from the dev machine
  • Live: FORGE_LIVE=1 NEXT_PUBLIC_NETWORK=devnet NEXT_PUBLIC_DEVNET_NAME=sakura pnpm exec vitest run lib/auth/app-connect-v2.live.test.ts and E2E_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.
  • Opus code reviews of the core and the UI. The renewal and locked-vault issues they found are fixed, with tests.

🤖 Generated with Claude Code

PastaPastaPasta and others added 7 commits October 24, 2026 21:31
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>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff81d36b-7daa-4f69-9f48-d9fb31f6da9e
Commits

Reviewing files that changed from the base of the PR and between 1172b13 and fb67d9d.

Files selected for processing: 72
  • .gitleaks.toml
  • CHANGELOG.md
  • docs/design/ux-dx-spec.md
  • docs/design/wallet-login.md
  • forge-web/.eslintrc.json
  • forge-web/app/connect/page.tsx
  • forge-web/components/auth/connect-return.test.tsx
  • forge-web/components/auth/connect-return.tsx
  • forge-web/components/auth/wallet-connect-flow.test.tsx
  • forge-web/components/auth/wallet-connect-flow.tsx
  • forge-web/components/keys-panel.tsx
  • forge-web/components/login-modal.test.tsx
  • forge-web/components/login-modal.tsx
  • forge-web/components/low-funds-banner.test.tsx
  • forge-web/components/low-funds-banner.tsx
  • forge-web/components/repo/bulk-actions.tsx
  • forge-web/components/top-up-sheet.test.tsx
  • forge-web/components/top-up-sheet.tsx
  • forge-web/contexts/auth-context.tsx
  • forge-web/e2e/wallet-login-v2.spec.ts
  • forge-web/e2e/wallet-login.spec.ts
  • forge-web/e2e/wallet-responder-v2.ts
  • forge-web/e2e/wallet-responder.mjs
  • forge-web/hooks/use-ui-store.ts
  • forge-web/hooks/use-write-guard.test.tsx
  • forge-web/hooks/use-write-guard.ts
  • forge-web/lib/auth/app-connect-port.test.ts
  • forge-web/lib/auth/app-connect-port.ts
  • forge-web/lib/auth/app-connect-session.test.ts
  • forge-web/lib/auth/app-connect-v2.live.test.ts
  • forge-web/lib/auth/app-connect-v2.test.ts
  • forge-web/lib/auth/app-connect-v2.ts
  • forge-web/lib/auth/connect-callback.test.ts
  • forge-web/lib/auth/connect-callback.ts
  • forge-web/lib/auth/connection-id.test.ts
  • forge-web/lib/auth/connection-id.ts
  • forge-web/lib/auth/controller.ts
  • forge-web/lib/auth/vault.ts
  • forge-web/lib/auth/wallet-protocol.test.ts
  • forge-web/lib/auth/wallet-responder-v2.test.ts
  • forge-web/lib/auth/wallet-sim.ts
  • forge-web/lib/page-title.ts
  • forge-web/lib/sdk/facade.ts
  • forge-web/lib/short-url.ts
  • forge-web/lib/vendor/platform-auth/VENDORED.json
  • forge-web/lib/vendor/platform-auth/app-connect/crypto.test.ts
  • forge-web/lib/vendor/platform-auth/app-connect/crypto.ts
  • forge-web/lib/vendor/platform-auth/app-connect/errors.test.ts
  • forge-web/lib/vendor/platform-auth/app-connect/errors.ts
  • forge-web/lib/vendor/platform-auth/app-connect/group.ts
  • forge-web/lib/vendor/platform-auth/app-connect/index.ts
  • forge-web/lib/vendor/platform-auth/app-connect/poller.test.ts
  • forge-web/lib/vendor/platform-auth/app-connect/poller.ts
  • forge-web/lib/vendor/platform-auth/app-connect/primitives.test.ts
  • forge-web/lib/vendor/platform-auth/app-connect/primitives.ts
  • forge-web/lib/vendor/platform-auth/app-connect/request.test.ts
  • forge-web/lib/vendor/platform-auth/app-connect/request.ts
  • forge-web/lib/vendor/platform-auth/app-connect/session.test.ts
  • forge-web/lib/vendor/platform-auth/app-connect/session.ts
  • forge-web/lib/vendor/platform-auth/app-connect/test-helpers.ts
  • forge-web/lib/vendor/platform-auth/app-connect/types.ts
  • forge-web/lib/vendor/platform-auth/app-connect/vectors.json
  • forge-web/lib/vendor/platform-auth/app-connect/vectors.test.ts
  • forge-web/lib/vendor/platform-auth/app-connect/verify.test.ts
  • forge-web/lib/vendor/platform-auth/app-connect/verify.ts
  • forge-web/lib/view/funds.test.ts
  • forge-web/lib/view/funds.ts
  • forge-web/lib/view/write-errors.test.ts
  • forge-web/lib/view/write-errors.ts
  • forge-web/package.json
  • forge-web/scripts/copy-lint.mjs
  • forge-web/scripts/copy-lint.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The change adds App Connect v2 wallet sign-in and renewal to Forge. It includes request and grant handling, wallet-origin session management, callback-based phone linking, renewal prompts, write-error handling, and supporting tests and documentation.

Changes: App Connect v2 wallet authentication

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: Normal

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
Loading
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: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive 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 skippe… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: adding App Connect v2 wallet sign-in to forge-web using vendored platform-auth code.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed 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 re…
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.

❤️ Share

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>
PastaPastaPasta added a commit that referenced this pull request Oct 26, 2026
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>
@PastaPastaPasta
PastaPastaPasta merged commit 037fd8a into master Oct 26, 2026
22 checks passed
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.

1 participant