Non-functional tightening flagged in the slice-3 code review: - session.ts: document future multi-vault refactor (β+) so the module- scope singleton is explicitly "deliberately simple," not an oversight. - vault.ts: move findByHostname doc comment above the function; note α's intentionally-coarse hostname match (no www-stripping, no public-suffix matching) and that tighter matching is a β/γ concern. - index.ts: expand the passphrase scope-clearing comment to make the theatre explicit rather than leaving it looking like real defense. - index.ts: TODO(slice-4) marker on delete_item's non-atomic two-write path — consider manifest-first ordering or retry/rollback at router- split time. - index.ts: cross-reference comment on itemToManifestEntry pointing at the Rust-side ManifestEntry::from_item derivation it must mirror. No behavior change; build still compiles with 2 bundle-size warnings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
29 lines
950 B
TypeScript
29 lines
950 B
TypeScript
/// Single module-scope "current" SessionHandle.
|
||
///
|
||
/// α assumes one vault per extension install. The master key lives only
|
||
/// inside WASM linear memory (wrapped in Zeroizing<[u8;32]>); this module
|
||
/// just holds the opaque handle that names it.
|
||
///
|
||
/// Future multi-vault (β+) would replace `current` with
|
||
/// `Map<vaultId, SessionHandle>` and thread `vaultId` through every
|
||
/// handler. Deliberate α simplicity — not an oversight.
|
||
|
||
import type { SessionHandle } from '../../wasm/relicario_wasm';
|
||
|
||
let current: SessionHandle | null = null;
|
||
|
||
export function setCurrent(h: SessionHandle): void { current = h; }
|
||
|
||
export function getCurrent(): SessionHandle | null { return current; }
|
||
|
||
export function requireCurrent(): SessionHandle {
|
||
if (!current) throw new Error('vault_locked');
|
||
return current;
|
||
}
|
||
|
||
export function clearCurrent(): void {
|
||
if (!current) return;
|
||
try { current.free(); } catch { /* already freed */ }
|
||
current = null;
|
||
}
|