import { SIGN_IN_LINK_MINUTES } from "@/lib/signin-link"; export type SignInEmail = { subject: string; text: string; html: string }; function escapeHtml(value: string): string { return value .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll('"', """) .replaceAll("'", "'"); } // Plain on purpose: one link, how long it lasts, and that it can be ignored. export function renderSignInEmail(url: string): SignInEmail { const subject = "Your SchemaTax sign-in link"; const validity = `This link works once and expires in ${SIGN_IN_LINK_MINUTES} minutes.`; const ignore = "If you didn't ask for this, you can ignore this email. Nobody can sign in without the link."; const text = [ "Use this link to sign in to SchemaTax:", url, validity, ignore, "SchemaTax", ].join("\n\n"); const p = "margin:0 0 16px;font-size:15px;line-height:1.6;color:#16202e"; const small = "margin:0 0 16px;font-size:13px;line-height:1.6;color:#4a5463"; const html = `
Use this button to sign in to SchemaTax:
${escapeHtml(validity)}
${escapeHtml(ignore)}
SchemaTax