export function maskEmail(value: string | null | undefined): string | null { if (!value) return null; const at = value.indexOf("@"); if (at <= 0) return value; const local = value.slice(0, at); const domain = value.slice(at + 1); if (!domain) return value; if (local.length === 1) return `*@${domain}`; if (local.length === 2) return `${local[0]}*@${domain}`; return `${local[0]}***${local[local.length - 1]}@${domain}`; } export function maskAccountId(value: string | null | undefined): string | null { if (!value) return null; const id = value.trim(); if (!id) return null; // Short IDs would disclose the entire identifier via the suffix; use a non-identifying placeholder. if (id.length <= 4) return "account-…"; return `account-…${id.slice(-4)}`; }