From e6943e674705991d087efda19ceddb2c8403aee7 Mon Sep 17 00:00:00 2001 From: Kieran Date: Sun, 17 Mar 2024 19:11:21 +0000 Subject: [PATCH] chore: Update translations --- functions/.well-known/lnurlp/[handle].ts | 74 ++++++++++++------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/functions/.well-known/lnurlp/[handle].ts b/functions/.well-known/lnurlp/[handle].ts index 67a9cca..19d6bb8 100644 --- a/functions/.well-known/lnurlp/[handle].ts +++ b/functions/.well-known/lnurlp/[handle].ts @@ -1,48 +1,48 @@ -interface Env { } +interface Env {} interface NostrJson { - names: Record; - relays?: Record>; - nip46?: Record>; + names: Record; + relays?: Record>; + nip46?: Record>; } async function fetchNip05Pubkey(name: string, domain: string, timeout = 2_000): Promise { - if (!name || !domain) { - return undefined; - } - try { - const res = await fetch(`https://${domain}/.well-known/nostr.json?name=${encodeURIComponent(name)}`, { - signal: AbortSignal.timeout(timeout), - }); - const data: NostrJson = await res.json(); - const match = Object.keys(data.names).find(n => { - return n.toLowerCase() === name.toLowerCase(); - }); - return match ? data.names[match] : undefined; - } catch { - // ignored - } + if (!name || !domain) { return undefined; + } + try { + const res = await fetch(`https://${domain}/.well-known/nostr.json?name=${encodeURIComponent(name)}`, { + signal: AbortSignal.timeout(timeout), + }); + const data: NostrJson = await res.json(); + const match = Object.keys(data.names).find(n => { + return n.toLowerCase() === name.toLowerCase(); + }); + return match ? data.names[match] : undefined; + } catch { + // ignored + } + return undefined; } export const onRequest: PagesFunction = async context => { - const handle = context.params.handle as string | undefined; - let pubkey = handle; - if (handle && handle.length !== 64) { - const nip5 = await fetchNip05Pubkey(handle, "zap.stream"); - if (nip5) { - pubkey = nip5; - } + const handle = context.params.handle as string | undefined; + let pubkey = handle; + if (handle && handle.length !== 64) { + const nip5 = await fetchNip05Pubkey(handle, "zap.stream"); + if (nip5) { + pubkey = nip5; } + } - const response = await fetch(`https://api.zap.stream/.well-known/lnurlp/${pubkey}`); - const results = await response.text(); - const responseHeaders = Object.fromEntries(response.headers.entries()); - return new Response(results, { - headers: { - ...responseHeaders, - "access-control-allow-origin": "*", - "cache-control": "no-store" - } - }); -} \ No newline at end of file + const response = await fetch(`https://api.zap.stream/.well-known/lnurlp/${pubkey}`); + const results = await response.text(); + const responseHeaders = Object.fromEntries(response.headers.entries()); + return new Response(results, { + headers: { + ...responseHeaders, + "access-control-allow-origin": "*", + "cache-control": "no-store", + }, + }); +};