// 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: typeof globalThis.fetch, emails: string[] ): Promise> => { 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 = await res.json(); const result = new Map(); for (const [email, did] of Object.entries(map)) { if (did) result.set(email, did); } return result; } catch { return new Map(); } };