/** * Text rewriting for the secret history scrub (docs/secrets.md, "Removing * secrets from stored history"). Matching itself belongs to the scrub's * matcher; this module only applies its ranges to stored text and JSON. */ /** * What the scrub needs from a matcher (`@opengeni/core`'s * session-secret-redaction-matchers provides it). `marker` is the exact text written in * place of each match, `[redacted: ]`; it never contains a * value. `redact` returns the text with every match replaced by `marker` and * must leave markers already in the text untouched, so a second run changes * nothing. */ export type SecretRedactionMatcher = { readonly marker: string; redact(text: string): string; }; export type SecretRedactionTextResult = { text: string; matches: number; }; /** * True when `text` holds marker-shaped text. Such a value is refused: where * that part is a kept marker, the value could never be found. */ export declare function containsSecretRedactionMarker(text: string): boolean; /** * The marker written in place of a match: a label, never a value. Brackets, * quotes, backslashes, control characters and lone surrogates are dropped and * the label is cut at 300 code points, so the marker reads the same in plain * and JSON text and always passes the cell writer's marker shape check. */ export declare function secretRedactionMarker(label: string): string; /** * Apply every matcher in turn. Matches are counted by the markers each one * adds, so a matcher needs no counting interface of its own. */ export declare function redactSecretText(text: string, matchers: readonly SecretRedactionMatcher[]): SecretRedactionTextResult; /** A stored text column, decoded and re-encoded through its lossless codec version. */ export declare function redactStoredText(stored: string, codecVersion: number | null, matchers: readonly SecretRedactionMatcher[]): SecretRedactionTextResult; /** * Redact every string value of JSON text, leaving keys, numbers, structure * and untouched strings byte for byte. Keys are never rewritten: two keys * redacted to the same marker would collapse into one. Each string is decoded first, * so a match can never cross a JSON boundary and escaped forms are seen as the * text they stand for. Values written through the lossless codec (version 1) * are decoded and re-encoded around the rewrite. */ export declare function redactJsonText(json: string, codecVersion: number | null, matchers: readonly SecretRedactionMatcher[]): SecretRedactionTextResult; /** One top-level member of a JSON object text: its key and its value's span. */ export type JsonObjectMember = { key: string; start: number; end: number; }; /** * The top-level members of JSON object text, without parsing the values (a * row's numeric columns keep their exact digits). */ export declare function jsonObjectMembers(json: string): JsonObjectMember[]; /** Replace member value spans of JSON object text (spans must not overlap). */ export declare function replaceJsonMembers(json: string, replacements: readonly { member: JsonObjectMember; text: string; }[]): string; /** * Redact a database row written as JSON (`row_to_json`, as in the session * archive bundle). A column with a `_codec_version` of 1 is decoded * and re-encoded through the lossless codec; `textColumns` names the columns * stored as text rather than JSON, which use the text form of the codec. */ export declare function redactJsonRowText(json: string, textColumns: ReadonlySet, matchers: readonly SecretRedactionMatcher[]): SecretRedactionTextResult; /** * Redact a JSON value already in memory (a hydrated model-request snapshot). * Returns the same value when nothing matched. */ export declare function redactJsonValue(value: T, matchers: readonly SecretRedactionMatcher[]): { value: T; matches: number; };