is-secret
Version:
A distributed maintained collection of patterns that indicate that something probably is secret
68 lines (46 loc) • 1.67 kB
Markdown
A distributed maintained collection of patterns that indicate that
something probably is secret.
This is useful if you want to filter sensitive values in a data set.
This module uses a very simple algorithm that will not catch everthing.
Use at your own risk.
[](https://www.npmjs.com/package/is-secret)
[](https://travis-ci.org/watson/is-secret)
[](https://github.com/feross/standard)
```
npm install is-secret --save
```
```js
var isSecret = require('is-secret')
var data = {
username: 'watson',
password: 'f8bY2fg8',
card: '1234 1234 1234 1234' // credit card number
}
Object.keys(data).forEach(function (key) {
if (isSecret.key(key) ||
isSecret.value(data[key])) data[key] = '********'
})
console.log(data)
// {
// username: 'watson',
// password: '********',
// card: '********'
// }
```
_If you need functionality similar to what is shown in this example, I
suggest you take a look at the
[](https://github.com/watson/redact-secrets) module._
Validates the given `string` against a list of key names known to
typically indicate secret data.
Returns `true` if the `string` is considered secret. Otherwise `false`.
Validates the given `string` against a list of patterns that indicates
secret data.
Returns `true` if the `string` is considered secret. Otherwise `false`.
[](LICENSE)