aboutsummaryrefslogtreecommitdiffstats
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
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]>
-rw-r--r--src/marmot-client.js26
-rw-r--r--tools/marmot-chat-test.js10
2 files changed, 35 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
diff --git a/tools/marmot-chat-test.js b/tools/marmot-chat-test.js
index 1078bec..18f63b3 100644
--- a/tools/marmot-chat-test.js
+++ b/tools/marmot-chat-test.js
@@ -135,6 +135,16 @@ try {
const chk = wn(['keys', 'check', me]);
check('wn can use it', !chk.error && JSON.stringify(chk).includes('true'), JSON.stringify(chk).slice(0, 200));
+ if (SITE) {
+ // White Noise only invites an account whose relay lists it can find on ITS relays
+ const dir = 'wss://relay.eu.whitenoise.chat';
+ const found = await until(async () => {
+ const evs = await new Promise((res) => { const ws = new WebSocket(dir), out = []; ws.onopen = () => ws.send(JSON.stringify(['REQ', 'q', { kinds: [10002, 10050], authors: [me] }])); ws.onmessage = (m) => { const d = JSON.parse(m.data); if (d[0] === 'EVENT') out.push(d[2].kind); else { ws.close(); res(out); } }; ws.onerror = () => res(out); setTimeout(() => res(out), 4000); });
+ return evs.includes(10002) && evs.includes(10050);
+ }, 40000);
+ check('its relay lists are on the White Noise directory relays', !!found);
+ }
+
console.log('\n[a White Noise group invites us]');
const made = wn(['groups', 'create', 'Trail crew', me], alice);
check('wn groups create', !made.error, JSON.stringify(made.error || ''));