MCPcopy Create free account
hub / github.com/cortexkit/magic-context / sanitizeConfigValue

Function sanitizeConfigValue

packages/plugin/src/shared/redaction.ts:246–264  ·  view source on GitHub ↗
(value: unknown, keyPath: string[] = [])

Source from the content-addressed store, hash-verified

244}
245
246export function sanitizeConfigValue(value: unknown, keyPath: string[] = []): unknown {
247 const key = keyPath.at(-1) ?? "";
248 if (key && isSecretKey(key)) {
249 return `<REDACTED:${redactionTypeForKey(key)}>`;
250 }
251 if (typeof value === "string") return sanitizeDiagnosticText(value);
252 if (Array.isArray(value)) {
253 return value.map((entry, index) => sanitizeConfigValue(entry, [...keyPath, String(index)]));
254 }
255 if (value && typeof value === "object") {
256 return Object.fromEntries(
257 Object.entries(value).map(([entryKey, entry]) => [
258 entryKey,
259 sanitizeConfigValue(entry, [...keyPath, entryKey]),
260 ]),
261 );
262 }
263 return value;
264}

Callers 4

sanitizeValueFunction · 0.90
bundleIssueReportFunction · 0.90
redaction.test.tsFile · 0.90

Calls 3

isSecretKeyFunction · 0.85
redactionTypeForKeyFunction · 0.85
sanitizeDiagnosticTextFunction · 0.85

Tested by

no test coverage detected