Initial commit: Nosterm client (terminal-style Nostr chat SPA)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { getDb, type StoredIdentityRecord } from '../database';
|
||||
|
||||
const PRIMARY = 'primary';
|
||||
|
||||
/**
|
||||
* storage for a remembered device identity. keeps ONLY the nip-49 ncryptsec
|
||||
* (passphrase-encrypted secret key) — never a plaintext key. the mvp remembers
|
||||
* a single identity under a fixed key.
|
||||
*/
|
||||
export const identityRepository = {
|
||||
async get(): Promise<StoredIdentityRecord | undefined> {
|
||||
return getDb().identities.get(PRIMARY);
|
||||
},
|
||||
|
||||
async save(pubkey: string, ncryptsec: string): Promise<void> {
|
||||
await getDb().identities.put({
|
||||
key: PRIMARY,
|
||||
pubkey,
|
||||
ncryptsec,
|
||||
savedAt: Date.now()
|
||||
});
|
||||
},
|
||||
|
||||
async clear(): Promise<void> {
|
||||
await getDb().identities.delete(PRIMARY);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user