Fully redact all occurrences of specified secrets in an object.
npm i full-redact
const fullRedact = require('full-redact');
let redact = fullRedact({ secrets: ['password', 'apiKey'] });
let obj = {
username: 'mike',
password: '123',
config: {
apiKey: '123abc',
},
};
console.log(redact(obj));
// {
// username: 'mike',
// password: '[REDACTED]',
// config: {
// apiKey: '[REDACTED]',
// }
// }
Returns a function that can be used to redact secrets in an object.
Options | Type | Default | Required |
---|---|---|---|
censor | string | [REDACTED] | false |
secrets | array<string> | n/a | true |
inPlace | boolean | false | false |
The replacement string that will be used when redacting a secret.
The array of strings that represent the secrets to be redacted. Any occurrence of these secrets will have it's value inside the object replaced by the censor.
When inPlace is true, it will update (redact) the object directly (in-place) instead of returning a copy of the object that has been redacted.
MIT