voltrevo-privacy
v0.1.0
Published
Controls access to objects by securely wrapping and unwrapping them
Downloads
10
Maintainers
Readme
voltrevo-privacy
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