Repository navigation
fix(web): store a new browser key before registering it, and finish interrupted renewals (D-016) - #94
Merged
Merged
Conversation
|
Warning Review limit reachedNext included review available in 32 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (13)
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 |
…nterrupted renewals (D-016) Importing an identity or renewing its browser key now stages the new key in the vault and reads it back before the identity update is signed. A storage failure therefore stops before anything changes on chain. The staged record is committed as the main one only after the update lands. An interrupted renewal (the tab closed, or storing failed after registering) is finished on the next unlock or restored session, once Platform shows the staged key under its id. Unlock tries both records' own protections, so a renewal protected with another passphrase or passkey is never a dead end. A stage that Platform proves was never registered is dropped. A stage whose main record has changed since is kept as a conflict, rechecked inside the finishing transaction. Storage and encryption blobs carry across. A wallet sign-in with a pending renewal offers a choice: finish it (unlock) or continue with the wallet, which discards it; the key stays registered but unused. Settings → Keys lists a pending renewal with Finish and Discard. Also keys the spend ledger by kind to fix a same-millisecond overwrite. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…iscarded (D-016) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta
force-pushed
the
fix/web-key-store-first
branch
from
September 27, 2026 22:10
14444e9 to
d0a6384
Compare
PastaPastaPasta
added a commit
that referenced
this pull request
Sep 27, 2026
Resolve with #87 (per-facade retryable reads; pathElements added under system) and #94 (staged key persist in the renewal, D-016; the sheet remembers only a committed key). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Summary
Fixes D-016: a browser key import or renewal could lock the user out. Before this change, the identity update registering the new key was signed and broadcast before the key was stored. If storing failed (quota, private mode, a closed tab), the old key was already disabled on chain and the new one existed nowhere.
The key is now stored first, and the chain changes second:
registerLimitedKeytakes apersisthook. It is called with the new key before the update is signed.stageInVaultwrites avault-staged:record (carryingreplaces, the main keyId it will replace) and reads it back. A write the browser didn't keep throws, and nothing changes on chain. After the update lands,storeInVaultcommits the key as the main record and drops the stage.finishStagedRenewal→recoverStaged, which returns aRecoverResult:adopted: Platform shows the staged WIF under its keyId, whether live, expired or disabled. The staged key becomes the main record, and the storage and encryption blobs are re-sealed under it.discarded: another key holds that id, which proves the stage was never registered. The stage is dropped.pending: the key is not visible yet. The stage is kept.locked: the method used opens the current key but not the renewal. The session opens with a notice explaining how to finish the renewal.conflict: the main record changed since staging, for example after a newer sign-in. Nothing is overwritten. The check is repeated inside the finishing IndexedDB transaction via the newidbUpdate(…, alsoRead).PendingRenewalChoiceError, and the flow offers two options:lib/spend.ts): the spend ledger key now includes the event kind. This fixes a same-millisecond overwrite that madekey-spend.test.tsflaky.Tests
lib/auth/key-safety.test.ts(vault):lockedand then adopting;conflictresult;conflict;lib/auth/key-recovery.test.ts(controller):neverdropped, with the "discarded" message.tscandlintare clean, and 1921 tests pass (10 skipped).Review
code-review-validator ran three rounds on the vault and controller changes. Every round's blockers were fixed, and the last verdict was clear. Its two notes, the outcome-specific unlock message and the in-transaction conflict recheck, are included here.
Live
The companion write-refusal work (#91) was re-run live on the beta.5 devnet (moutai, master 98c04d4) and passed 6/6. This PR changes only local vault ordering and recovery; the on-chain update it signs is the same one as before.
🤖 Generated with Claude Code