Redact secrets in logs

This commit is contained in:
Chocobozzz
2026-07-10 11:26:40 +02:00
parent eef99811d6
commit 84c92a9f56
3 changed files with 14 additions and 4 deletions
+1
View File
@@ -1,2 +1,3 @@
export * from './chapters.js'
export * from './hash.js'
export * from './secret.js'
+9
View File
@@ -0,0 +1,9 @@
export function maskSecret (secret: string) {
if (!secret) return secret
if (typeof secret !== 'string') return '****'
if (secret.length <= 4) return '****'
if (secret.length <= 8) return secret.slice(0, 2) + '***'
return secret.slice(0, 4) + '****'
}