iron-mask

1.0.2 • Public • Published

Build Status Coverage Status

IronMask Logo

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

Readme

Keywords

none

Package Sidebar

Install

npm i iron-mask

Weekly Downloads

4,739

Version

1.0.2

License

MIT

Last publish

Collaborators

  • vitorabner