Skip to content

@graphty/graphty-element / logging / redactSecrets

Function: redactSecrets() ​

redactSecrets(text, secrets?): string

Defined in: graphty-element/src/logging/redactSecrets.ts:32

Removes credentials from a piece of text before it leaves the page: an error message, a stack, a URL, a log line. Every exact secrets value is removed first, then anything shaped like a key, so a key the caller knows is caught whatever its shape.

Parameters ​

text ​

string

the text to clean.

secrets? ​

readonly (string | undefined)[] = []

values known to be secret, such as the configured API key.

Returns ​

string

the text with each secret replaced by [redacted].

Example ​

typescript
redactSecrets("401: bad key sk-ant-api03-abcdefgh"); // "401: bad key [redacted]"