mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
nip05: add debugging output
This commit is contained in:
parent
7ed34a0906
commit
d2a4862a2a
1 changed files with 16 additions and 4 deletions
|
|
@ -18,14 +18,26 @@ async function lookup(value: string, opts: LookupOpts = {}): Promise<string | nu
|
|||
|
||||
const [_, name = '_', domain] = match;
|
||||
|
||||
const handleAbort = () => {
|
||||
console.log(`NIP-05 lookup aborted for @${name}@${domain}`);
|
||||
};
|
||||
|
||||
const signal = AbortSignal.timeout(timeout);
|
||||
signal.addEventListener('abort', handleAbort);
|
||||
|
||||
try {
|
||||
const res = await fetch(`https://${domain}/.well-known/nostr.json?name=${name}`, {
|
||||
signal: AbortSignal.timeout(timeout),
|
||||
});
|
||||
const url = `https://${domain}/.well-known/nostr.json?name=${name}`;
|
||||
console.log(`Fetching ${url}`);
|
||||
|
||||
const res = await fetch(url, { signal });
|
||||
signal.removeEventListener('abort', handleAbort);
|
||||
console.log(`NIP-05: successfully fetched @${name}@${domain}}`);
|
||||
|
||||
const { names } = nostrJsonSchema.parse(await res.json());
|
||||
const pubkey = names[name] || null;
|
||||
console.log(`NIP-05: @${name}@${domain} is ${pubkey}`);
|
||||
|
||||
return names[name] || null;
|
||||
return pubkey;
|
||||
} catch (_e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue