diff --git a/install.js b/install.js index 58cdc066..7d64638f 100644 --- a/install.js +++ b/install.js @@ -10,6 +10,7 @@ var https = require('https'); var fs = require('fs'); var path = require('path'); var exec = require('child_process').exec; +var spawn = require('child_process').spawn; var os = require('os'); var libFiles = [ @@ -270,8 +271,8 @@ function doDownloads(next) { }); } -function run(cmdLine, expectedExitCode, next) { - var child = exec(cmdLine); +function run(cmdLine, args, expectedExitCode, next) { + var child = spawn(cmdLine, { shell: true }); if (typeof expectedExitCode === 'undefined') { expectedExitCode = 0; @@ -340,9 +341,9 @@ function isPreInstallMode() { // Start if (os.platform() !== 'win32') { if (isPreInstallMode()) { - run('make libsodium'); + run('make', ['libsodium']); } else { - run('make nodesodium'); + run('make', ['nodesodium']); } } else { checkMSVSVersion(); @@ -357,7 +358,7 @@ if (os.platform() !== 'win32') { }); } else { console.log('Install Mode'); - run('node-gyp rebuild', 0, function() { + run('node-gyp', ['rebuild'], 0, function() { console.log('Copy lib files to Release folder'); files = libFiles.slice(0); // clone array copyFiles(files, function() { @@ -366,4 +367,4 @@ if (os.platform() !== 'win32') { }); }); } -} \ No newline at end of file +} diff --git a/lib/box.js b/lib/box.js index aa2c8245..25e49801 100644 --- a/lib/box.js +++ b/lib/box.js @@ -15,8 +15,8 @@ var assert = require('assert'); /** * Public-key authenticated encryption: Box * - * @param {String|Buffer|Array} secretKey sender's private key. * @param {String|Buffer|Array} publicKey recipient's public key. + * @param {String|Buffer|Array} secretKey sender's private key. * @param {Boolean} easy Use regular or easy mode. Defaults to regular * * @see Keys @@ -144,17 +144,17 @@ module.exports = function Box(publicKey, secretKey, easy) { * @param {Buffer|String|Array} nonce the nonce used to encrypt * @param {String} [encoding] the encoding to used in cipherText, nonce, plainText */ - self.decrypt = function (cipherBox, encoding) { + self.decrypt = function (cipherText, nonce, encoding) { encoding = String(encoding || self.defaultEncoding); - assert(typeof cipherBox == 'object' && cipherBox.hasOwnProperty('cipherText') && cipherBox.hasOwnProperty('nonce'), 'cipherBox is an object with properties `cipherText` and `nonce`.'); - assert(cipherBox.cipherText instanceof Buffer, 'cipherBox should have a cipherText property that is a buffer') ; + assert(cipherText instanceof Buffer, 'cipherText property that is a buffer') ; + assert(nonce instanceof Buffer, 'nonce property that is a buffer') ; - var nonce = new Nonce(cipherBox.nonce); + //var nonce = new Nonce(cipherBox.nonce); nonce.get() var plainText = (self.easy ? binding.crypto_box_open_easy : binding.crypto_box_open)( - cipherBox.cipherText, - nonce.get(), + cipherText, + nonce, self.boxKey.getPublicKey().get(), self.boxKey.getSecretKey().get() ); @@ -170,4 +170,3 @@ module.exports = function Box(publicKey, secretKey, easy) { self.close = self.encrypt; self.open = self.decrypt; }; - diff --git a/package.json b/package.json index ed08ea5c..da034406 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "main": "index.js", "description": "Lib Sodium port for node.js", "dependencies": { - "nan": "^2.2.1" + "nan": "2.2.1" }, "devDependencies": { "mdextract": "^1.0.0",