From 83ad00a39863bb6a61e15977202fe2feea2ca696 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 23:07:02 -0700 Subject: 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 --- src/nostr.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'src/nostr.js') 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']; -- cgit v1.2.3