aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-02 22:37:13 -0700
committerAdam Soltys <[email protected]>2026-10-02 22:37:13 -0700
commit78f8e047f2e94e6065f6041c481387c7e6e20eec (patch)
tree67db6b67de5002d86cffc9f74d6e1c0fdd678eb4 /src
parente67666de3c4e2f745c38dfe04ff18e178c17b67c (diff)
downloadcoinosv3-78f8e047f2e94e6065f6041c481387c7e6e20eec.tar.gz
coinosv3-78f8e047f2e94e6065f6041c481387c7e6e20eec.zip
White Noise can find a coinos account: relay lists go to its directory relays
The Android app said a coinos user "isn't on White Noise yet" although their KeyPackage was published: MDK will not invite an account whose kind 10002 and 10050 lists it cannot find, and it looks on relay.eu/us.whitenoise.chat and purplepag.es, where coinos never wrote. The client now passes the account's already-signed lists along to those relays (no signer needed, nothing rewritten), weekly and until both exist. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/marmot-client.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/marmot-client.js b/src/marmot-client.js
index 1fef568..c8878a2 100644
--- a/src/marmot-client.js
+++ b/src/marmot-client.js
@@ -18,6 +18,11 @@ import { dlog } from './debug.js';
// White Noise (MDK's RETIRED_RELAY_HOSTS) never dials those.
export const GROUP_RELAYS = ['wss://relay.coinos.io', 'wss://nos.lol', 'wss://relay.primal.net'];
+// Where White Noise looks people up. It will not invite an account whose
+// relay lists (kinds 10002 and 10050) it cannot find, and it looks on its own
+// relays and the purplepag.es index — not on ours.
+const DIRECTORY_RELAYS = ['wss://relay.eu.whitenoise.chat', 'wss://relay.us.whitenoise.chat', 'wss://purplepag.es'];
+
const DAY = 86400;
const KP_REFRESH = 30 * DAY; // republish well inside the 84-day lifetime
const REACH_TTL = 10 * 60_000;
@@ -83,7 +88,11 @@ export function marmotClient({ scope, pubkey, identity, on, relays = GROUP_RELAY
// KeyPackage where our NIP-65 write relays say to look. Silent unless
// `interactive`; returns whether we are reachable.
function ready(opts = {}) {
- if (!kpBusy) kpBusy = ensure(opts).catch((e) => { dlog('marmot: keypackage', e); return false; }).finally(() => { kpBusy = null; });
+ if (!kpBusy) kpBusy = ensure(opts).catch((e) => { dlog('marmot: keypackage', e); return false; }).finally(() => {
+ kpBusy = null;
+ // a little later: a brand-new wallet is still publishing its lists
+ if (dev && now() - (dev.announced || 0) > 7 * DAY) setTimeout(announce, 8000);
+ });
return kpBusy;
}
async function ensure(opts) {
@@ -96,6 +105,21 @@ export function marmotClient({ scope, pubkey, identity, on, relays = GROUP_RELAY
return publishKeyPackage(s);
}
+ // Put the account's relay lists where White Noise will find them. These
+ // are the events the account already signed, passed along unchanged — so
+ // no signer is asked, and a login npub's lists stay exactly as its other
+ // clients wrote them. Redone weekly, and until both lists exist.
+ async function announce() {
+ if (stopped || !dev) return;
+ try {
+ const evs = await queryOn(PROFILE_RELAYS, { kinds: [10002, 10050], authors: [pubkey] }, 3500);
+ const newest = (kind) => evs.filter((e) => e.kind === kind).sort((a, b) => b.created_at - a.created_at)[0];
+ const lists = [newest(10002), newest(10050)];
+ for (const ev of lists) if (ev) await publishOn(DIRECTORY_RELAYS, ev);
+ if (lists.every(Boolean)) { dev.announced = now(); await saveDev(); }
+ } catch (e) { dlog('marmot: announce', e); }
+ }
+
async function publishKeyPackage(s) {
const kp = M.newKeyPackage(dev);
// the private half is on disk before the public half is findable