/** * Shared server-side rules for recognising credentials. * * Both the config inspector and the SQL-binding writer need to answer "does * this look like a secret?", and they used to answer it differently — config * values were redacted against a real word list while query bindings were only * truncated by length. One list, used by both, so the same secret cannot be * masked in one view and printed in full in another. */ /** * Names that identify a credential — applies to env vars, config keys, and SQL * identifiers alike. */ export declare const SECRET_NAME_PATTERNS: RegExp[]; /** * Names that matter for env vars and config keys but NOT for SQL identifiers. * * An `email` env var is usually an SMTP account; an `email` *column* is ordinary * application data, and redacting every binding of every query that touches it * would make the query pane useless for debugging auth. Same for the service * URLs, which are env-shaped names rather than column names. */ export declare const CONFIG_ONLY_NAME_PATTERNS: RegExp[]; /** Whether a name identifies a credential. */ export declare function isSecretName(name: string): boolean; /** Whether a name is sensitive in a config/env context (credentials plus contact/service names). */ export declare function isSensitiveConfigName(name: string): boolean; /** * Whether a SQL statement mentions a credential-shaped identifier. * * Tokenised first: the name patterns above use `_`/`.`/`-` boundaries, so * running them across raw SQL would miss `password` sitting between spaces. * * Positional bindings cannot be mapped back to specific columns reliably, so a * hit means every binding for that statement is redacted. Coarse on purpose — * over-redacting one statement's parameters beats storing a password. */ export declare function sqlMentionsSecret(sql: string): boolean; export declare function looksLikeCredentialValue(value: string): boolean; /** * Redact and truncate SQL bindings before persistence. * * Two independent rules, because neither catches everything on its own: * * 1. **By statement.** If the SQL mentions a credential-shaped identifier * (`password`, `remember_token`, `otp`, ...), every binding for that * statement is redacted. Positional bindings cannot be mapped back to * columns reliably, so this is all-or-nothing per statement — coarse, but * it is the only thing that catches a short secret like a 6-digit OTP. * 2. **By value shape.** Hashes, JWTs, provider key prefixes, long hex * digests, and URLs with embedded credentials are redacted wherever they * appear, regardless of the statement. * * Anything that survives both is truncated at {@link MAX_BINDING_LEN} so an * oversized payload cannot bloat the row. * * Ordinary parameters — ids, flags, emails, timestamps — still pass through, so * the query pane stays useful for debugging. */ export declare function sanitizeBindings(bindings: unknown, sqlText?: string): unknown; /** * Redact a structured record (a pino log entry, an event payload) with the * same key/shape rules as bindings but WITHOUT length truncation — log data * carries stack traces and payload context that must stay whole. */ export declare function sanitizeRecordValues(record: unknown): unknown; /** * Redact credential-bearing query parameters from a URL before it is stored. * * Request URLs are persisted with their query strings (useful for debugging * pagination and filters), but a `?token=…` password-reset link or a * `?signature=…` signed URL must not land in SQLite in the clear. Parameters * are redacted by name (see {@link isSecretName}) or when the value itself * looks like a credential; everything else passes through untouched. */ export declare function sanitizeUrlQuery(url: string): string;