diff options
| author | Adam Soltys <[email protected]> | 2026-08-01 23:07:02 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-01 23:07:02 -0700 |
| commit | 83ad00a39863bb6a61e15977202fe2feea2ca696 (patch) | |
| tree | 251325b582093cdcaf08ba52981ee9905e018e9c /src/nostr.js | |
| parent | 88d93de66b9ba713c5cc1a8fc5b1528ea1d74fb8 (diff) | |
| download | coinosv3-83ad00a39863bb6a61e15977202fe2feea2ca696.tar.gz coinosv3-83ad00a39863bb6a61e15977202fe2feea2ca696.zip | |
Drop npub-locked gifts; collapse Nostr login behind a button
Gifts are plain bearer links again: the recipient-npub field, the
one-time claim code, the DM delivery, the /lg/ claim route and the
NIP-07 in-place decrypt are all gone, along with the crypto that only
they used. Unclaimed gifts remain reclaimable by the sender, so nothing
can be stranded by the removal.
The unlock screen shows a single 'Sign in with Nostr' button that
reveals the login options when tapped, instead of the full card
competing with create/import.
Co-Authored-By: Claude Fable 5 <[email protected]>
Diffstat (limited to 'src/nostr.js')
| -rw-r--r-- | src/nostr.js | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/src/nostr.js b/src/nostr.js index 0992122..3d0ea2f 100644 --- a/src/nostr.js +++ b/src/nostr.js @@ -58,8 +58,6 @@ export async function publishOn(relays, evt) { } catch { return false; } } -// --- locking a gift to a recipient's Nostr key --------------------------- -// An npub or 64-hex nostr pubkey → hex, or null if it isn't one. // NIP-47 wallet services sign with their own per-connection key and must // speak whichever encryption the client asked for, so export both schemes. export { nip04, nip44 }; @@ -71,26 +69,9 @@ export function parseNostrPubkey(input) { try { const d = nip19decode(s); if (d.type === 'npub') return d.data; } catch {} return null; } +// An npub or 64-hex nostr pubkey → hex, or null if it isn't one. export function npubOf(pkHex) { try { return npubEncode(pkHex); } catch { return null; } } -// Encrypt a gift payload two ways: (1) under a fresh one-time code, delivered to -// the recipient out-of-band via a nostr DM — the manual path; and (2) to the -// recipient's nostr pubkey via an ephemeral key, so a NIP-07 browser extension -// can decrypt it in-place with no code. Both decrypt to the same payload. -export function encryptGiftPayload(plaintext, recipientPkHex) { - const codeKey = randomBytes(32); - const ephSk = generateSecretKey(); - return { - code: base64urlnopad.encode(codeKey), - ctCode: nip44.encrypt(plaintext, codeKey), - eph: getPublicKey(ephSk), - ctKey: nip44.encrypt(plaintext, nip44.getConversationKey(ephSk, recipientPkHex)), - }; -} -export function decryptWithCode(code, ct) { - return nip44.decrypt(ct, base64urlnopad.decode((code || '').trim())); -} - // Profiles live across the network, so look them up on popular relays (broader // than the sync relays). export const PROFILE_RELAYS = ['wss://relay.damus.io', 'wss://nos.lol', 'wss://relay.primal.net', 'wss://relay.coinos.io']; |
