From 5a16f87c3ba44c9c5231b37cf626db06b63ce351 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 2 Aug 2026 22:03:50 -0700 Subject: Sync just works: NIP-65 relays, no card; gift-locking leftovers gone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Device sync card and toggle are gone — sync is always on, riding the user's own NIP-65 (kind 10002) write relays: the login npub's first, else the wallet key's, coinos relay as the fallback and always included. A fresh wallet identity with no NIP-65 publishes one (default relay) so other clients can find its events. The npub-locked-gift remnants go with it: the per-wallet nostr address card that pitched gift-locking, the how-it-works sentence, the dead NostrSync.sendDM/sendNostrDM path, and the orphaned claim-code field. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01Wvj4aoeMZwA7VUGdJP9Swi --- src/nostr.js | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'src/nostr.js') diff --git a/src/nostr.js b/src/nostr.js index 1a4a0c5..c644ef5 100644 --- a/src/nostr.js +++ b/src/nostr.js @@ -12,7 +12,6 @@ import * as nip06 from 'nostr-tools/nip06'; import * as nip44 from 'nostr-tools/nip44'; import * as nip04 from 'nostr-tools/nip04'; -import { wrapEvent as nip17WrapEvent } from 'nostr-tools/nip17'; import { getPublicKey, finalizeEvent, generateSecretKey } from 'nostr-tools/pure'; import { decode as nip19decode, npubEncode } from 'nostr-tools/nip19'; import { SimplePool } from 'nostr-tools/pool'; @@ -164,10 +163,9 @@ export function getSyncConfig() { if (raw) { const c = JSON.parse(raw); const relays = Array.isArray(c.relays) ? c.relays : []; - return { - enabled: c.enabled !== false, - relays: relays.length ? relays : DEFAULT_SYNC_RELAYS, - }; + // Always on — the toggle is gone; relays follow the user's NIP-65 + // (adoptSyncRelays in the sync feature), coinos relay as the default. + return { enabled: true, relays: relays.length ? relays : DEFAULT_SYNC_RELAYS }; } } catch {} return { enabled: true, relays: DEFAULT_SYNC_RELAYS }; // default: on, coinos relay @@ -223,23 +221,6 @@ export class NostrSync { return results.some((r) => r.status === 'fulfilled'); } - // Deliver an encrypted DM (a locked gift's claim code) as a NIP-17 gift wrap - // (kind 1059) — the modern standard every current client supports. Goes to the - // recipient's published inbox relays (NIP-17/65) plus a broad fallback. Returns - // true if ≥1 relay accepted it. - async sendDM(recipientPkHex, text, relays = null) { - if (!this.sk) return false; - let evt; - try { evt = nip17WrapEvent(this.sk, { publicKey: recipientPkHex }, text); } catch { return false; } - let targets = relays; - if (!targets) { - const inbox = await fetchInboxRelays(recipientPkHex); - targets = [...new Set([...inbox, ...PROFILE_RELAYS])].slice(0, 8); // recipient's inbox + safety net - } - const res = await Promise.allSettled(pool.publish(targets, evt)); - return res.some((x) => x.status === 'fulfilled'); - } - // Publish an arbitrary event (finalized here with our key) to the relays. // Used by features that speak their own event kinds (e.g. ark zaps). async publishEvent(partial) { -- cgit v1.2.3