UNPKG

lever-ui-logger

Version:

Zero-dependency logging library with optional EventBus integration. Built-in PII redaction, multiple transports, and comprehensive logging capabilities.

86 lines 3.05 kB
/** * Built-in redaction patterns for common PII types */ export interface BuiltInRedactionPattern { /** Pattern name for debugging and configuration */ name: string; /** Regular expression to match PII */ pattern: RegExp; /** Replacement text (can include capture groups) */ replacement: string; /** Description of what this pattern detects */ description: string; /** Whether this pattern is enabled by default */ defaultEnabled: boolean; /** Performance category for priority ordering */ priority: 'high' | 'medium' | 'low'; } /** * Built-in PII detection patterns * Ordered by detection priority (high performance patterns first) */ export declare const BUILT_IN_PATTERNS: readonly BuiltInRedactionPattern[]; /** * Field names that commonly contain PII * These trigger redaction regardless of content */ export declare const PII_FIELD_NAMES: readonly string[]; /** * Creates a case-insensitive field name matcher. * Uses exact matches and common patterns to avoid false positives. * * @param fieldName - The field name to check for PII indicators * @returns True if the field name indicates it may contain PII * * @example * ```typescript * isPIIFieldName('password'); // true * isPIIFieldName('userId'); // true * isPIIFieldName('userPassword'); // true (camelCase) * isPIIFieldName('user_email'); // true (underscore) * isPIIFieldName('auth-token'); // true (hyphen) * isPIIFieldName('message'); // false * isPIIFieldName('timestamp'); // false * ``` */ export declare function isPIIFieldName(fieldName: string): boolean; /** * Gets enabled patterns based on configuration. * * @param enabledPatterns - Specific patterns to enable (overrides defaults) * @param disabledPatterns - Specific patterns to disable * @returns Array of enabled redaction patterns * * @example * ```typescript * // Get all default enabled patterns * const defaultPatterns = getEnabledPatterns(); * * // Only enable specific patterns * const emailOnly = getEnabledPatterns(['email']); * * // Enable defaults except IP addresses * const noIPs = getEnabledPatterns(undefined, ['ipv4', 'ipv6']); * ``` */ export declare function getEnabledPatterns(enabledPatterns?: string[], disabledPatterns?: string[]): BuiltInRedactionPattern[]; /** * Sorts patterns by priority for optimal performance. * High priority patterns are processed first for better performance. * * @param patterns - Array of redaction patterns to sort * @returns Sorted array with high priority patterns first * * @example * ```typescript * const unsorted = [ * { name: 'low-pattern', priority: 'low', ... }, * { name: 'high-pattern', priority: 'high', ... }, * { name: 'medium-pattern', priority: 'medium', ... } * ]; * const sorted = sortPatternsByPriority(unsorted); * // Result: [high-pattern, medium-pattern, low-pattern] * ``` */ export declare function sortPatternsByPriority(patterns: BuiltInRedactionPattern[]): BuiltInRedactionPattern[]; //# sourceMappingURL=redaction-patterns.d.ts.map