forked from Kieran/snort
fix: capture exception when verifying nip05
This commit is contained in:
parent
547b90e2b4
commit
ae4657feda
@ -14,12 +14,16 @@ async function fetchNip05Pubkey(name: string, domain: string) {
|
|||||||
if (!name || !domain) {
|
if (!name || !domain) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const res = await fetch(`https://${domain}/.well-known/nostr.json?name=${encodeURIComponent(name)}`);
|
const res = await fetch(`https://${domain}/.well-known/nostr.json?name=${encodeURIComponent(name)}`);
|
||||||
const data: NostrJson = await res.json();
|
const data: NostrJson = await res.json();
|
||||||
const match = Object.keys(data.names).find(n => {
|
const match = Object.keys(data.names).find(n => {
|
||||||
return n.toLowerCase() === name.toLowerCase();
|
return n.toLowerCase() === name.toLowerCase();
|
||||||
});
|
});
|
||||||
return match ? data.names[match] : undefined;
|
return match ? data.names[match] : undefined;
|
||||||
|
} catch (error) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERIFICATION_CACHE_TIME = 24 * 60 * 60 * 1000
|
const VERIFICATION_CACHE_TIME = 24 * 60 * 60 * 1000
|
||||||
|
Loading…
Reference in New Issue
Block a user