MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / redactValue

Function redactValue

src/utils/redact.ts:8–18  ·  view source on GitHub ↗
(key: string, value: unknown)

Source from the content-addressed store, hash-verified

6const SENSITIVE_KEY_PATTERN = /(api[_-]?key|token|password|passwd|secret|authorization|auth(?!or)|access[_-]?key|private[_-]?key|client[_-]?secret|bearer|x[_-]api[_-]key|session[_-]?id)/i;
7
8export function redactValue(key: string, value: unknown): unknown {
9 if (SENSITIVE_KEY_PATTERN.test(key)) {
10 if (typeof value === 'string' && value.length > 0) {
11 // Keep first 2 chars so the user knows something is set, redact the rest
12 const visible = value.slice(0, 2);
13 return `${visible}***[redacted ${value.length} chars]`;
14 }
15 return '[redacted]';
16 }
17 return value;
18}
19
20export function redactObject<T extends Record<string, unknown>>(obj: T): Record<string, unknown> {
21 const out: Record<string, unknown> = {};

Callers 3

redactObjectFunction · 0.85
summarizeArgsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected