/** * RedactEngine — DLP Compliance Engine (Zero-Leak PII Protection) * * Compiles object paths into V8-optimized redaction functions using * `fast-redact` (the Pino logger serialization engine). Masks sensitive * fields structurally before data leaves the framework. * * Architecture: * ┌──────────────────────────────────────────────────┐ * │ Boot / .redactPII() call │ * │ │ * │ ['*.ssn', 'credit_card.number'] │ * │ │ │ * │ ▼ │ * │ fast-redact({ paths, censor, serialize: false })│ * │ │ │ * │ ▼ │ * │ Compiled RedactFn (V8-optimized) │ * │ Applied in Presenter.make() on wireData │ * └──────────────────────────────────────────────────┘ * * Properties: * - Compiles paths into V8-optimized functions at config time * - Zero overhead on hot path (pre-compiled redaction) * - Wildcards supported: `'*.ssn'`, `'patients[*].diagnosis'` * - Custom censor: string or function `(value) => maskedValue` * - Zero-risk fallback: if `fast-redact` is not installed, logs warning * and passes data through unmodified * * @module * @internal */ /** * Configuration for PII redaction. * * @example * ```typescript * const config: RedactConfig = { * paths: ['*.ssn', 'credit_card.number', 'patients[*].diagnosis'], * censor: '[REDACTED]', * }; * ``` */ export interface RedactConfig { /** * Array of object paths to redact, using `fast-redact` syntax. * * Supports: * - Dot notation: `'user.ssn'` * - Bracket notation: `'user["ssn"]'` * - Wildcards: `'*.ssn'`, `'patients[*].diagnosis'` * - Array indices: `'items[0].secret'` * * @see https://github.com/davidmarkclements/fast-redact#paths--array */ readonly paths: readonly string[]; /** * Replacement value for redacted fields. * * - **String**: Static replacement (default: `'[REDACTED]'`) * - **Function**: Dynamic censor `(originalValue) => maskedValue` * (e.g. `(v) => '***' + String(v).slice(-4)`) * * @default '[REDACTED]' */ readonly censor?: string | ((value: unknown) => string); } /** * A compiled redaction function. * * Applies PII masking to an object. Uses `structuredClone` internally * to preserve the original data for UI blocks and rules * (Late Guillotine pattern). */ export type RedactFn = (data: unknown) => unknown; /** * Compile a redaction config into a V8-optimized redaction function. * * The compiled function uses `structuredClone` to avoid mutating the * original data (required for Late Guillotine: UI blocks and rules * need the full unmasked data). * * @param config - Redaction configuration (paths + optional censor) * @returns A compiled `RedactFn`, or `undefined` if `fast-redact` is unavailable * * @example * ```typescript * const redact = compileRedactor({ * paths: ['*.ssn', 'credit_card.number'], * censor: '[REDACTED]', * }); * * if (redact) { * const safe = redact(sensitiveData); * // safe.ssn === '[REDACTED]' * } * ``` */ export declare function compileRedactor(config: RedactConfig): RedactFn | undefined; /** * Pre-load the `fast-redact` module. * * Called during `initFusion()` boot sequence alongside other * optional dependencies. Not required — the engine degrades * gracefully if `fast-redact` is not installed. * * @returns `true` if `fast-redact` is available */ export declare function initRedactEngine(): Promise; //# sourceMappingURL=RedactEngine.d.ts.map