0.1.0 • Published 1 year ago

@vates/obfuscate v0.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@vates/obfuscate

Package Version License PackagePhobia Node compatibility

Install

Installation of the npm package:

npm install --save @vates/obfuscate

Usage

replace(value, replacement)

Recursively replace sensitive entries with a replacement value.

import { replace } from '@vates/obfuscate'

replace({ username: 'foo', password: 'bar' }, 'obfuscated')
// → { username: 'foo', password: 'obfuscated'}

obfuscate(value)

Recursively replace sensitive entries with a special tag.

import { obfuscate } from '@vates/obfuscate'

obfuscate({ username: 'foo', password: 'bar' })
// → {
//   username: 'foo',
//   password: 'obfuscated-q3oi6d9X8uenGvdLnHk2',
// }

merge(newValue, oldValue)

Replace entries obfuscated by obfuscate() in the new value by entries from the old one.

This is especially useful to give an obfuscated value to a client, let them modify it, and then merge modified and unmodified values.

import { obfuscate, merge } from '@vates/obfuscate'

const original = { username: 'foo', password: 'bar', token: 'baz' }

// compute an obfuscated value to send to a client
const obfuscated = obfuscate(original)

// let the client update any entries
obfuscated.token = 'qux'

// merge the updated value with the original one
merge(obfuscated, original)
// → { username: 'foo', password: 'bar', token: 'qux' }

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Vates SAS

0.1.0

1 year ago