MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / maskEmailForLogging

Function maskEmailForLogging

apps/api/src/lib/email/email.utils.ts:49–71  ·  view source on GitHub ↗
(email: string)

Source from the content-addressed store, hash-verified

47 * "" -> "***"
48 */
49export const maskEmailForLogging = (email: string): string => {
50 if (email === "") {
51 return "***";
52 }
53
54 const atIndex = email.indexOf("@");
55
56 if (atIndex === -1) {
57 return "***";
58 }
59
60 const localPart = email.slice(0, atIndex);
61 const domain = email.slice(atIndex + 1);
62
63 if (localPart.length <= 2) {
64 return `***@${domain}`;
65 }
66
67 const first = localPart[0] ?? "";
68 const last = localPart[localPart.length - 1] ?? "";
69
70 return `${first}***${last}@${domain}`;
71};
72
73/**
74 * Boundary validator for outbound email payloads. Throws an `ApiError`

Callers 15

constructorMethod · 0.90
processJobMethod · 0.90
sendTemplateNowFunction · 0.90
recordMethod · 0.90
isSuppressedMethod · 0.90
clearMethod · 0.90
sendMethod · 0.90
sendMethod · 0.90
sendMethod · 0.90
sendMethod · 0.90
sendMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected