Type alias CorjRedactPolicyInput

CorjRedactPolicyInput: {
    keys?: readonly (string | RegExp)[];
    paths?: readonly (string | RegExp)[];
    patterns?: readonly RegExp[];
    replacement?: string;
    transform?: CorjRedactTransform | null;
}

A redaction policy as it is passed in; every part is optional. keys and paths skip reads, so an excluded getter never runs; patterns and transform rewrite text wherever the report emits it. To remove a secret's text from message, stack and as_string alike, use patterns.

Type declaration

  • Optional keys?: readonly (string | RegExp)[]

    Property names never read from the caught object. A string matches exactly.

  • Optional paths?: readonly (string | RegExp)[]

    JSONPaths never read, e.g. "$.cause.config.headers". A string matches exactly.

  • Optional patterns?: readonly RegExp[]

    Applied with String.prototype.replace to every string the report emits.

  • Optional replacement?: string

    What an excluded value and a pattern match become. Defaults to CORJ_REDACTED_MARKER.

  • Optional transform?: CorjRedactTransform | null

    Runs after the above on every value the report emits.

Example

const redact: CorjRedactPolicyInput = {
keys: ['password', /^authorization$/i],
paths: ['$.cause.config.headers'],
patterns: [/sk-live-[A-Za-z0-9]+/g], // the g flag is required
transform: (value, { sourceProperty }) => (sourceProperty === 'url' ? '[url]' : value),
};