Skip to content

vitorabner/iron-mask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A flexible way to mask sensitive data

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published