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

Function mask

apps/ui/src/lib/logger/logger.utils.ts:10–32  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

8import type { ILogEvent, ILogLevel } from "./logger.types";
9
10function mask(value: unknown): unknown {
11 if (Array.isArray(value)) {
12 return value.map(mask);
13 }
14
15 if (!isRecord(value)) {
16 return value;
17 }
18
19 const out: Record<string, unknown> = {};
20
21 for (const [key, raw] of Object.entries(value)) {
22 if (PII_KEYS.includes(key)) {
23 out[key] = "[redacted]";
24 } else if (typeof raw === "object" && raw !== null) {
25 out[key] = mask(raw);
26 } else {
27 out[key] = raw;
28 }
29 }
30
31 return out;
32}
33
34export function emit(level: ILogLevel, payload: ILogEvent): void {
35 const maskedRaw = mask(payload);

Callers 1

emitFunction · 0.85

Calls 1

isRecordFunction · 0.90

Tested by

no test coverage detected