import { randomUUID } from "node:crypto"; import { parseSecretReference } from "@opengeni/contracts"; import { fromPostgresLosslessJson, fromPostgresLosslessText, LOSSLESS_CONTENT_CODEC_VERSION, toPostgresLosslessJson, toPostgresLosslessText, } from "./lossless-json"; /** * 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 }; /** * Marker-shaped text, `[redacted: