secrets-masker v1.0.3
secrets-masker
Deep and recursive maskin of sensitive information. Configurable masks, patterns, and partial masking.
Installation
npm install secrets-masker --saveUsage
const masker = require('redact-secrets')({
mask: "XX-",
partialMask: 3
})
var obj = {
password: 'somepass',
l1: {
id: 1,
token: 'some-secret-stuff'
card: '1234 1234 1234 1234',
ssn: '123-34-3322'
}
}
obj = masker.map(obj);obj is now
{
password: 'somepass',
l1: {
id: 1,
token: 'XX-uff'
card: 'XX-234',
ssn: 'XX-322'
}
}API
masker = Masker(config)
const Masker = require("secrets-masker");
const masker = Masker(...);Config
partialMask: number
returns the last n character/digit of the orig value. If 0, no partial masking is done. Defaults to undefined (none).
Example:
input: "12345"
partialMask: 2
mask: "XX"
output: "XX-45"mask: string
Replaces the masked/redacted string or part of string (depends on partialMask)
Example:
input: "12345"
partialMask: 2
mask: "XX"
output: "XX-45"useDefault: boolean
If true (default), uses the default REGEX and patterns for keys and values. Otherwise, no.
Example:
{
...,
useDefault: false
}values: Array< RegExp | string >
Appends to default (if useDefault is true) array of RegExp to use for matching values. If useDefault is not true, this is the only array used.
keys: Array< RegExp | string >
Appends to default (if useDefault is true) array of RegExp to use for matching keys. If useDefault is not true, this is the only array used.
mask.map(obj)
Returns a clone of the given obj with its secret values masked. Original object is untouched
mask.forEach(obj)
Redacts the secret values of the obj in-place.
License
MIT