0.1.0 • Published 9 years ago

voltrevo-privacy v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

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