UNPKG

syntropylog

Version:

An instance manager with observability for Node.js applications

23 lines (22 loc) 1.27 kB
/** * @file src/http/utils/redact.ts * @description Provides utility functions for redacting sensitive information * from objects and headers, crucial for secure logging. */ /** * Deeply clones and redacts sensitive fields from an object or array. * This function is designed to be safe and avoid modifying the original object. * @param {any} data - The object or array to redact. * @param {string[]} [sensitiveFields=[]] - An array of keys (strings) to be redacted, matched case-insensitively. * @param {number} [maxDepth=10] - The maximum recursion depth to prevent infinite loops. * @returns A new object or array with sensitive fields redacted. */ export declare function redactObject(data: any, sensitiveFields?: string[], maxDepth?: number): any; /** * Redacts sensitive headers from a headers object. * Header names are treated case-insensitively. * @param {Record<string, any>} headers - The headers object (e.g., from an HTTP request). * @param {string[]} [sensitiveHeaders=[]] - An array of header names to redact. * @returns A new headers object with sensitive values redacted. */ export declare function redactHeaders(headers: Record<string, any> | null | undefined, sensitiveHeaders?: string[]): Record<string, any> | null | undefined;