Shrink the unlocked-session key footprint - #129
Conversation
|
@claude review |
|
Claude finished @dmnyc's task in 5m 25s —— View job Review: Shrink the unlocked-session key footprint
Solid, well-motivated change. The decrypt-on-demand rework ( The step-up state machine is where I found problems. It stores one 1. Two open panels invalidate each other's step-up forever (medium)
With auto-lock "never" and panels A and B both open:
The two panels ping-pong indefinitely; neither can stay past the step-up screen. It fails closed (no security hole), but the wallet is effectively unusable with two windows open. Storing a map of 2. Step-up prompt fires immediately after re-onboarding (medium)
Reset → create/restore a wallet → the panel's next Clearing the pending flag in 3. The step-up screen is a dead end once the throttle hard-locks (medium)
Two things would close it: render the throttle countdown/blocked state proactively like 4. Unhandled rejection on
|
…ed step-up screen
|
Review feedback addressed in 5da84dd:
On the notes: the advisory-not-enforced nature is a fair read — worth stating in the PR body, done here: the step-up gates the panel UI only; |
Fixes #108 (M-5 + L-11).
Three reductions to what lives in memory while the wallet is unlocked:
unlock()and SW-wakeensureLoaded()used to decrypt every wallet's mnemonic at once into a warm cache for the whole session. Now only the derived key is recovered;getMnemonic()is async and decrypts a wallet's seed the first time that wallet actually signs, caching it until lock. A plaintext seed exists in service-worker memory one at a time, only for wallets in use — never all of them for hours.storage.session(same lifetime as the session key it guards — dies at browser exit, survives SW eviction so an open panel isn't re-prompted) and a new panel session getsneedsStepUpingetState, rendering a password re-verify screen before the wallet UI. Verified passwords via the newwallet/stepUp(shares the unlock throttle — same password oracle as unlock/reveal),wallet/unlock, moving off "never", lock, and reset all clear the pending prompt. Background signing still requires its own per-action step-up, unchanged.storage.session.setAccessLevel({ accessLevel: "TRUSTED_CONTEXTS" })is now called explicitly at SW startup (the default, and the only level this design tolerates) so a future widening to trusted-and-untrusted contexts is a deliberate, visible edit rather than drift. Firefox has nosetAccessLevel; itsstorage.sessionis extension-only by construction.Verified:
pnpm typecheck,pnpm test(325 passing), Chrome and Firefox production builds.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note (from review): the step-up is advisory at the UI layer — the SW returns
needsStepUpbut doesn't refuse wallet operations from a panel that owes one. Signing paths (wallet/send,wallet/swap) already demand the password when auto-lock is 0; the residual surface is reads and non-signing ops from extension contexts.