hide-secrets
Version:
for when you want to log objects, but hide certain restricted fields, e.g., passwords.
70 lines (52 loc) • 1.6 kB
Markdown
[![Build Status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![NPM version][npm-image]][npm-url]
[![js-standard-style][standard-image]][standard-url]
```js
var hide = require('hide-secrets')
var obj = {
innerObject: {
password: 'abc123',
email: 'ben@npmjs.com',
token: 'my-secret-token'
},
auth: '' // empty strings are left empty.
}
console.log(hide(obj))
```
outputs
```
{
innerObject: {
password: '[SECRET]',
email: 'ben@npmjs.com',
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:
1. create your own list of terms:
```js
const badWords = [
'super-secret-1', 'double-secret-probation'
]
```
1. pass this as configuration to hide-secrets:
```js
console.log(hide(obj, {badWords}))
```
Any keys within obj that are contained within the `badWords` array will be hidden.
ISC
[]: https://travis-ci.org/bcoe/hide-secrets
[]: https://img.shields.io/travis/bcoe/hide-secrets.svg
[]: https://coveralls.io/github/bcoe/hide-secrets
[]: https://img.shields.io/coveralls/bcoe/hide-secrets.svg
[]: https://npmjs.org/package/hide-secrets
[]: https://img.shields.io/npm/v/hide-secrets.svg
[]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[]: https://github.com/feross/standard