docs: document wallet integrity boundaries

This commit is contained in:
2026-08-22 16:56:50 +02:00
parent 76d59d8d08
commit 72f387f6e5
2 changed files with 50 additions and 22 deletions
+18 -4
View File
@@ -22,8 +22,9 @@ lnurlcash-kit directly.
```
ops.ts / ops/ # flows: carve (exact-amount), mint, pay, receiveBearer,
# transfer (inter-mint); ops.ts is the façade
storage/ # encrypted bearers + activity log, settings, backup,
# nwcConnections, passkeySlots; storage.ts is the façade
storage/ # encrypted bearers + activity log, owner-bound NWC,
# passkey and trusted-mint records, settings, backup;
# storage.ts is the façade
keys.ts # BIP39, LUD-05 linking key derivation, password wrap
passkeys.ts + passkeyWrap.ts # WebAuthn PRF wrap (same linking key)
nostrBackup.ts + nostr/ # kind-30078 backup, NIP-44 self-encryption
@@ -38,8 +39,21 @@ test-utils.ts # mock mint harness used by *.test.ts
- Style: NO semicolons, 2-space indent, single quotes, `{braced}` imports
without inner spaces — deliberately different from the rest of the app
(eslint override); keep the tested core diffable against its lineage.
- Storage: localStorage keys `sattle_*`; strict shape validation on read,
malformed entries dropped; read-modify-write under `withStorageLock`.
- Storage: localStorage keys `sattle_*`; strict shape validation on read.
Credential, NWC, passkey, and trusted-mint records belong to the canonical
saved-key owner. Normal writes require that exact persisted owner; migration
of ownerless legacy records has its own proof-gated API.
- Concurrency: read-modify-write uses `withStorageLock` where Web Locks are
available, but lock handoff is not a localStorage visibility barrier. The
trusted-mint repository reconciles from a durable IndexedDB commit mirror
before one successful localStorage write and before resolving. Its fallback
is local execution only, with no cross-tab serialization guarantee. Storage
events are wakeups, so listeners re-read current storage instead of trusting
`event.newValue`, including on clears.
- Lifecycle: wallet transitions serialize create, restore, unlock, lock, and
forget. Activation completes proven-owner migration before exposing unlocked
state. Forget locks, drains NWC, clears runtime and owner-bound state, then
removes the saved key after biometric deletion succeeds.
- Network: kit calls only; injectable transport/options so tests never
touch the network. No WebSocket at import time (lazy `import()`).
- Every module header comment explains the WHY, including failure models.