Something went wrong. Try again.
forked from tangled.org/core
Something went wrong. Try again.
1234567891011121314151617181920212223242526import type { Fetch } from "#lib/fetch.ts";
// best-effort batch lookup of verified signup emails against the internal// `/_internal/email-did` route. returns only the emails that resolved; a// transport or parse failure answers an empty map so hydration never throws.export const resolveEmailToDid = async ( fetchFn: Fetch, emails: string[]): Promise<Map<string, string>> => { if (emails.length === 0) return new Map(); const params = new URLSearchParams(); for (const email of emails) params.append("emails", email); try { const res = await fetchFn(`/_internal/email-did?${params}`); if (!res.ok) return new Map(); const map: Record<string, string | null> = await res.json(); const result = new Map<string, string>(); for (const [email, did] of Object.entries(map)) { if (did) result.set(email, did); } return result; } catch { return new Map(); }};