Skip to content

Fully redact all occurrences of specified secrets in an object.

License

Notifications You must be signed in to change notification settings

MikeSmvl/full-redact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

full-redact

Fully redact all occurrences of specified secrets in an object.

CircleCI

Installation

npm i full-redact

Usage

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]',
//    }
//  }

Options

require('full-redact')({censor, secrets, inPlace}) => Function

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

censor

The replacement string that will be used when redacting a secret.

secrets

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.

inPlace

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.

License

MIT

About

Fully redact all occurrences of specified secrets in an object.

Resources

License

Stars

Watchers

Forks

Packages

No packages published