0.1.0 • Published 5 years ago

evervault v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Version Downloads/week License

Installation

This is a Node.js module available through the npm registry. It can be installed using the npm or yarn command line tools.

npm install evervault --save

Getting Started

const evervault = require('evervault')('YOUR_API_KEY')

// Deploy an evervault cage from a Node.js function
evervault.cages.deploy(function () {
  // For example, calculate the distance between the two latitude/longitude pairs
  const location = params.location.split(",")
  const destination = params.destination.split(",")

  let radlat1 = Math.PI * parseFloat(location[0]) / 180
  let radlat2 = Math.PI * parseFloat(destination[0]) / 180

  let theta = parseFloat(location[1]) - parseFloat(destination[1])
  let radtheta = Math.PI * theta / 180

  let dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta)

  if (dist > 1) {
    dist = 1;
  }

  dist = Math.acos(dist);
  dist = dist * 180 / Math.PI;
  dist = dist * 60 * 1.1515 * 1.609344;

  send(JSON.stringify({
    distanceBetweenPoints: dist
  }))
}, function (err, cage) {
  console.log("Successfully deployed cage " + cage.name)
});

// List all of the cages that have been deployed on your account
evervault.cages.list(function (err, cages) {
  console.log(err, cages);
});

// Encrypt an object to be processed by preset evervault cages
evervault.data.encrypt(["mute-butterfly-4924", "noisy-rain-3981"], {
  message: "this will be encrypted using a key known only to the specified evervault cages",
  location: "53.349293,-6.247709",
  destination: "37.421533,-122.212311"
}, function (err, result) {
  // We now have an encrypted object which can be read by cages `mute-butterfly-4924` and `noisy-rain-3981`
  // Save it to your database, or send it straight to the cage to be processed.
});

Dependencies

  • aes-js: A pure JavaScript implementation of the AES block cipher and all common modes of operation.
  • node-webcrypto-ossl: A WebCrypto Polyfill for Node in TypeScript built on OpenSSL
  • request: Simplified HTTP request client.

License

MIT