(s: string)
| 24 | const REDACT_MIN_LENGTH = 16 |
| 25 | |
| 26 | export function redactSecrets(s: string): string { |
| 27 | return s.replace(SECRET_PATTERN, (_match, field: string, value: string) => { |
| 28 | if (value.length < REDACT_MIN_LENGTH) { |
| 29 | return `"${field}":"[REDACTED]"` |
| 30 | } |
| 31 | const redacted = `${value.slice(0, 8)}...${value.slice(-4)}` |
| 32 | return `"${field}":"${redacted}"` |
| 33 | }) |
| 34 | } |
| 35 | |
| 36 | /** Truncate a string for debug logging, collapsing newlines. */ |
| 37 | export function debugTruncate(s: string): string { |