redact-secrets
Deeply iterate over an object and redact secret values by replacing them with a predefined string
Last updated 8 years ago by watson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install redact-secrets 
SYNC missed versions from official npm registry.

redact-secrets

Deeply iterate over an object and redact secret values by replacing them with a predefined string.

Build status js-standard-style

Installation

npm install redact-secrets --save

Usage

var redact = require('redact-secrets')('[REDACTED]')

var obj = {
  username: 'watson',
  password: 'hhGu38gf',
  extra: {
    id: 1,
    token: 'some-secret-stuff'
    card: '1234 1234 1234 1234'
  }
}

console.log(redact.map(obj))
// {
//   username: 'watson',
//   password: '[REDACTED]',
//   extra: {
//     id: 1,
//     token: '[REDACTED]'
//     card: '[REDACTED]'
//   }
// }

API

redact = Redact(string)

This module exposes a init function which takes a single argument: The string used as a replacement variable for values that are redacted.

The init function returns an object holding two functions: map and forEach.

redact.map(obj)

Returns a clone of the given obj with its secret values redacted.

redact.forEach(obj)

Redacts the secret values of the obj in-place.

License

MIT

Current Tags

  • 1.0.0                                ...           latest (8 years ago)

1 Versions

  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE