diff options
| -rw-r--r-- | routes/nostr.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/routes/nostr.ts b/routes/nostr.ts index 4a7ce069..3b28076a 100644 --- a/routes/nostr.ts +++ b/routes/nostr.ts @@ -348,7 +348,21 @@ export default { } = req; let names = {}; if (name) { - names = { [name]: (await getUser(name, fields)).pubkey }; + // v3 registrar first: a claimed name's NIP-05 belongs to its wallet key. + // Legacy accounts answer as before when the registrar doesn't know it. + try { + const r = await fetch( + `${process.env.NAMES_URL || "https://names.coinos.io"}/.well-known/nostr.json?name=${encodeURIComponent(name)}`, + { signal: AbortSignal.timeout(3000) }, + ); + if (r.ok) { + const j = await r.json(); + if (j?.names?.[name]) return res.send({ names: { [name]: j.names[name] } }); + } + } catch {} + const u = await getUser(name, fields); + if (!u) return res.send({ names: {} }); // unknown name: empty per NIP-05, not a 500 + names = { [name]: u.pubkey }; } else { const records = await db.sMembers("nip5"); for (const s of records) { |
