hide-secrets
v2.0.0
Published
for when you want to log objects, but hide certain restricted fields, e.g., passwords.
Downloads
14,478
Readme
hide-secrets
var hide = require('hide-secrets')
var obj = {
innerObject: {
password: 'abc123',
email: '[email protected]',
token: 'my-secret-token'
},
auth: '' // empty strings are left empty.
}
console.log(hide(obj))
outputs
{
innerObject: {
password: '[SECRET]',
email: '[email protected]',
token: '[SECRET]'
},
auth: ''
}
Currently the following fields are obfuscated by default:
password
, pass
, token
, auth
, secret
, passphrase
.
If you want to override this list of obfuscated terms, simply:
create your own list of terms:
const badWords = [ 'super-secret-1', 'double-secret-probation' ]
pass this as configuration to hide-secrets:
console.log(hide(obj, {badWords}))
Any keys within obj that are contained within the badWords
array will be hidden.
License
ISC