diff --git a/..env.swp b/..env.swp new file mode 100644 index 00000000..2ab13425 Binary files /dev/null and b/..env.swp differ diff --git a/src/utils/lookup.ts b/src/utils/lookup.ts index ce42e2f2..90b30c2b 100644 --- a/src/utils/lookup.ts +++ b/src/utils/lookup.ts @@ -1,8 +1,9 @@ -import { NIP05, NostrEvent } from '@nostrify/nostrify'; +import { NIP05, NostrEvent, NSchema as n } from '@nostrify/nostrify'; import { getAuthor } from '@/queries.ts'; import { bech32ToPubkey } from '@/utils.ts'; import { nip05Cache } from '@/utils/nip05.ts'; +import { Stickynotes } from '@soapbox/stickynotes'; /** Resolve a bech32 or NIP-05 identifier to an account. */ export async function lookupAccount( @@ -18,14 +19,19 @@ export async function lookupAccount( /** Resolve a bech32 or NIP-05 identifier to a pubkey. */ export async function lookupPubkey(value: string, signal?: AbortSignal): Promise { + const console = new Stickynotes('ditto:lookup'); + + if (n.bech32().safeParse(value).success) { + return bech32ToPubkey(value); + } + if (NIP05.regex().test(value)) { try { const { pubkey } = await nip05Cache.fetch(value, { signal }); return pubkey; - } catch { + } catch (e) { + console.debug(e); return; } } - - return bech32ToPubkey(value); }