sanitise-object

2.0.1 • Public • Published

sanitise-object

Build Status Dependency Status

Recursively deletes properties from an object that match a list of keywords. Useful for removing user secrets from an object before logging it.

Install

Warning: Node.js 6 or higher is required.

npm install --save sanitise-object

Usage

const sanitiseObject = require('sanitise-object')
const input = {
  username: 'batou',
  password: 'major',
  friend: {
    name: 'tachikoma',
    apikey: 'thinktank'
  }
}
const keywords = ['password', 'key']
 
sanitiseObject(input, keywords)
// {
//   username: 'batou',
//   friend: {
//     name: 'tachikoma'
//   }
// }

API

sanitiseObject(input, [keywords])

Returns a clone of the input object with matching properties removed.

input

Type: object

keywords

Type: array
Default: ['password', 'secret', 'key', 'token']

List of keywords to match against. Properties are removed if a keyword appears anywhere in it's name. Matching is case insensitive.

License

sanitise-object is released under the ISC license.

Copyright © 2017, Roland Warmerdam.

Readme

Keywords

none

Package Sidebar

Install

npm i sanitise-object

Weekly Downloads

0

Version

2.0.1

License

ISC

Last publish

Collaborators

  • rowno