iron-mask
v1.0.2
Published
A flexible way to mask sensitive data
Downloads
44,636
Readme
A flexible way to mask sensitive data
Install
$ npm install --save iron-mask
Usage
const ironMask = require('iron-mask')
const mask = ironMask.create({
password: {
paths: ['password', 'creditCard.password'],
pattern: /\w.*/g,
replacer: '*'
},
cvv: {
paths: ['creditCard.cvv'],
pattern: /[0-9]{3}/,
replacer: cvv => `${cvv.substring(0,1)}**`
},
name: {
paths: ['name'],
pattern: 'Vitor Abner',
replacer: 'Batman'
}
})
const bankAccount = {
password: '123456789',
creditCard: {
password: '987654321',
cvv: '123'
},
name: 'Vitor Abner'
}
const maskedBankAccount = mask(bankAccount)
// Output:
//
// maskedBankAccount = {
// password: '*',
// creditCard: {
// password: '*',
// cvv: 1**
// },
// name: 'Batman'
// }
License
MIT © Vitor Abner