voltrevo-privacy

0.1.0 • Public • Published

voltrevo-privacy NPM version Build Status Dependency Status

Controls access to objects by securely wrapping and unwrapping them

Install

$ npm install --save voltrevo-privacy

Usage

'use strict';
 
var Privacy = require('voltrevo-privacy');
var someOtherLib = require('some-other-lib');
 
var privacy = Privacy(); // Create instance.
 
var SECRET = {};
 
someOtherLib.add(
  // It is impossible for someOtherLib to get SECRET.
  privacy.wrap(SECRET)
);
 
someOtherLib.later(function(stuff) {
  // The only way to get SECRET back is using privacy.unwrap. Even though
  // someOtherLib clearly had stuff, and it is impossible for someOtherLib to
  // get SECRET, as long as stuff is the thing we gave someOtherLib earlier,
  // this will work:
  assert(privacy.unwrap(stuff) === SECRET);
});

License

MIT © Andrew Morris

Package Sidebar

Install

npm i voltrevo-privacy

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • voltrevo