import type { GlobalStore } from "./state/globalStore.js"; export declare const REDACTED = "[REDACTED]"; /** * One thing a statelog event must not carry. A rule gets a value from the * event, before any `toJSON` ran on it, and the object that holds the value. * It returns the text to log in the value's place, or undefined to leave the * value to the next rule. */ export type ScrubRule = (raw: unknown, parent: unknown) => string | undefined; type Replacer = (this: unknown, key: string, value: unknown) => unknown; /** * Build a `JSON.stringify` replacer that runs each rule in order and logs the * first replacement. When no rule fires, `fallback` decides (by default the * value is kept). * * A replacer, not a deep copy, so the rules run inside the one stringify that * serializes the event, and Date, URL, and other `toJSON` values serialize as * they normally would. JSON.stringify applies `toJSON` before it calls the * replacer, so `value` may already be converted. `this[key]` still holds the * original, and that is what the rules see, since a redact tag is set on the * original. At the root key "", `this[""]` is `value`. * * Cycles are left to JSON.stringify, which throws on them: a cyclic body could * never have been serialized in the first place. */ export declare function makeScrubReplacer(rules: readonly ScrubRule[], fallback?: Replacer): Replacer; /** * Swap a value marked `redact` for its marker, and scrub a redacted string * that was interpolated into a larger one, since that larger string is a new * value with no tag of its own. When `globals` holds no tags at all, the rule * never fires and costs nothing per value. */ export declare function redactRule(globals: GlobalStore): ScrubRule; /** A string this long or shorter is logged as it is, even when it is base64. */ export declare const BINARY_OMIT_MIN_LENGTH = 4096; /** * Replace picture bytes, and any other binary data sent as base64, with a * marker such as `[image/png: 6000 bytes omitted]`. A string matches when it * is longer than `BINARY_OMIT_MIN_LENGTH` and is either a `data:` URI with * `;base64,`, or all base64 or base64url characters with both upper- and * lowercase letters among them. Prose and JSON never match, since they contain * spaces or punctuation outside that alphabet. Hex, long numbers, and * one-letter filler never match either: base64 of real binary data always * mixes the two cases. * * The mime type comes from the `data:` URI's header, or else from a string * `mimeType` beside the value. Agency's attachment shape keeps it there: * `{ kind: "base64", base64, mimeType }`. With neither, the marker says * `base64`. */ export declare const omitBinaryRule: ScrubRule; /** The rules every statelog event goes through, in order: the redact tag * first, so a redacted picture shows its redaction marker, then binary data. */ export declare function statelogScrubRules(globals: GlobalStore | undefined): ScrubRule[]; /** The fields every statelog line has. The rules apply to `data` alone. */ export type StatelogEnvelope = { format_version: number; trace_id: string; project_id: string; span_id: string | null; parent_span_id: string | null; data: Record; }; /** * Serialize an event in one `JSON.stringify`. The scrub rules see only `data`, * so a pathological redaction, such as a tag on the number 1, can never blank * an envelope field such as `format_version`. */ export declare function stringifyStatelogEvent(envelope: StatelogEnvelope, rules: readonly ScrubRule[]): string; export {};