Repository navigation
feat(nostr): track which account owns a local key on shared phones - #727
Merged
Merged
Conversation
islandbitcoin
changed the base branch from
fix/nostr-npub-auto-relink
to
main
September 23, 2026 18:17
Rebased as one commit onto main after #720 merged; content unchanged from the previous branch head (ee94b11). Co-Authored-By: Claude Fable 5.1 <[email protected]>
islandbitcoin
force-pushed
the
feat/nostr-multi-account-keys
branch
from
September 23, 2026 18:20
ee94b11 to
56a0b10
Compare
…reign keys Review fixes for #727: - importNsec: a backend refusal (NPUB_NOT_AVAILABLE) is now an error, not a success. The form no longer shows "nsec imported successfully!" for a key the account cannot advertise. Parameters folded into an options object (max-params). Form-level test covers accepted/refused and asserts the owner stamp through the rendered form. - NostrKeyEnsurer: mismatch + foreign key uses a new keyForeignMismatchMessage that keeps the "differs from the one on your account" warning, so "Use this device" is not mistaken for merely borrowing another account's key. Added to all 23 locales. Dead `if (!accountId)` guard removed; doc comments rewrapped. - keyOwnerState: no account id -> "unknown", never "other" (the id comes from a cache-first query that can be unloaded). - Reconnect spec asserts the owner record after a successful relink (pins the accountId wiring in advanced-settings.tsx); stray blank lines in beforeEach removed. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Review fixes for #727: - importNsec now calls the backend first and only writes the keychain, clears the replaced key's owner record, and stamps the new owner once the key is accepted. A refusal (NPUB_NOT_AVAILABLE) is now a true no-op: the account's own nsec and its owner record survive, so on a shared phone B importing A's key no longer destroys B's key. - updateFlashBackend is typed Promise<boolean> with a fail-closed guard; the void-result-counts-as-registered test is removed with it. - Tests: refused case seeds a previous key + owner and asserts both are untouched (util and rendered form); a new test pins backend-before- keychain ordering. Co-Authored-By: Claude Fable 5.1 <[email protected]>
islandbitcoin
marked this pull request as ready for review
September 24, 2026 20:11
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.
Part of ENG-601 (multi-account support). Stacked on #720. Base is
fix/nostr-npub-auto-relink; retarget tomainonce #720 merges. Draft until then.Problem
The keychain entry holding the Nostr nsec survives logout (
use-logout.tsnever clears it). On a phone shared by two Flash accounts, account B starts with the key account A generated. #720 registers an unregistered local key silently, so B would claim A's key. The backend then refuses A (NPUB_NOT_AVAILABLE) and A's DMs go to a key B advertises.This is the first piece of multi-account support: two or more Flash accounts sharing one phone.
Change
app/nostr/key-owner.ts: records the owning account next to each local key, keyed on the npub.generateAndStoreKeyandsaveNewNostrKeystamp it. Deleting keys clears it.NostrKeyEnsurer:unregisteredwith a key owned by another account → asks once per (account, key) instead of registering.linked→ adopts ownership, so keys from before this record and imported nsecs get an owner.mismatchwith a foreign-owned key → names the other account, and a refusal never advises deleting that account's key.keyForeignMessage/keyForeignRelinkRefused, translated in all locales.Tests
__tests__/nostr/key-owner.spec.ts,__tests__/nostr/signer.spec.ts(owner stamp).nostr-key-ensurer.spec.tsx: foreign-key prompt, take over on confirm, decline remembered, per-key marker, refusal copy, once-per-account across logout/login, account payload without id.use-nostr-profile-relink.spec.ts: never registers a foreign key, owner stamp on fresh generation, delete clears owners.62 tests pass on this branch.
Out of scope, still open for full multi-account
giftwraps, rumors,lastSeen_*) are device-global and survive logout, so B can see A's decrypted history.🤖 Generated with Claude Code
https://claude.ai/code/session_014etuRoG7S3DxsAmWMP9jAX