/** * Stage-0 secret redaction (spec docs/specs/2026-07-02-encryption-and-secret-redaction.md * §4.2/§4.3, SEC-3..6/SEC-9). * * Single entry point: `redactText(input, opts)`. Invoked at the ingest choke * point (POST /ingest/transcript, before the `transcripts` INSERT) and on the * `/remember` manual-write path (spec OQ-2: yes). Downstream pipeline stages * inherit already-redacted text — there is no second redaction pass. * * Placeholder format: `[REDACTED::]` where hash8 = first 8 hex * chars of SHA-256(secret value). Same secret -> same placeholder (dedup-safe * across a transcript); the raw value is NEVER stored or logged (SEC-5). * * Detection order (never redact inside an already-inserted placeholder): * 1. PEM private-key blocks (multiline, whole block) * 2. Vendor/pattern detectors (AWS, GitHub, Azure, GCP, Slack, generic * key=value, JWT, connection-string userinfo) + config custom patterns * 3. Shannon-entropy detector + numeric-secret digit-run heuristic * (FEAT-468 — catches unlabeled digit-only secrets, which sit below * any Shannon-entropy threshold by construction; see entropy.ts) over * whatever text remains */ import type { Config } from '../config/config.js'; export interface RedactionEvent { type: string; hash8: string; /** Offset of the redacted span within the text snapshot at detection time. */ offset: number; } export interface RedactOptions { /** Shannon-entropy threshold in bits/char. Default 4.0. */ entropyThreshold?: number; /** Additional regex sources (as strings) from config, type 'custom'. */ customPatterns?: string[]; } export interface RedactResult { text: string; events: RedactionEvent[]; } /** * Redact secrets from `input`. Pure function — no I/O, no DB writes (callers * aggregate `events` into `redaction_log` themselves). */ export declare function redactText(input: string, opts?: RedactOptions): RedactResult; /** * Choke-point helper for route handlers: applies config (enabled flag, * entropy threshold, custom patterns) and is a no-op passthrough when * `security.redaction.enabled` is false (SEC-9). */ export declare function redactIfEnabled(input: string, config: Config): RedactResult;