Comparing version 0.3.2 to 0.3.3
@@ -82,4 +82,8 @@ 'use strict'; | ||
cipher.write(text, options.from); | ||
cipher.end(); | ||
try { | ||
cipher.write(text, options.from); | ||
cipher.end(); | ||
} catch (ex) { | ||
return callback(ex); | ||
} | ||
}; | ||
@@ -111,4 +115,11 @@ | ||
const key = new NodeRSA(privateKey); | ||
const decryptedText = key.decrypt(text, 'utf8'); | ||
let decryptedText; | ||
try { | ||
decryptedText = key.decrypt(text, 'utf8'); | ||
} catch (ex) { | ||
return callback(ex); | ||
} | ||
callback(null, decryptedText); | ||
@@ -115,0 +126,0 @@ }); |
{ | ||
"name": "crypto2", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "crypto2 is a convenience wrapper around Node.js' crypto module.", | ||
@@ -19,3 +19,3 @@ "contributors": [ | ||
], | ||
"main": "lib/crypto2.js", | ||
"main": "dist/crypto2.js", | ||
"dependencies": { | ||
@@ -25,5 +25,5 @@ "node-rsa": "0.4.2" | ||
"devDependencies": { | ||
"assertthat": "0.8.2", | ||
"roboter": "0.13.15", | ||
"roboter-server": "0.13.15" | ||
"assertthat": "0.11.0", | ||
"roboter": "0.15.4", | ||
"roboter-server": "0.15.4" | ||
}, | ||
@@ -30,0 +30,0 @@ "repository": { |
@@ -9,5 +9,51 @@ 'use strict'; | ||
task('universal/analyze', { | ||
src: [ '**/*.js', '!node_modules/**/*.js', '!coverage/**/*.js' ] | ||
src: [ '**/*.js', '!node_modules/**/*.js', '!coverage/**/*.js', '!dist/**/*.js' ] | ||
}); | ||
task('universal/release', { | ||
createDistribution: true | ||
}); | ||
task('universal/license', { | ||
compatible: [ | ||
// Individual licenses | ||
'Apache-2.0', 'Apache-2.0*', | ||
'BSD-2-Clause', 'BSD-3-Clause', | ||
'ISC', | ||
'MIT', 'MIT*', 'MIT/X11', | ||
'MIT Licensed. http://www.opensource.org/licenses/mit-license.php', | ||
'Public Domain', | ||
'Unlicense', | ||
// Combined licenses | ||
'(Apache-2.0 OR MPL-1.1)', | ||
'BSD-3-Clause OR MIT', | ||
'(MIT AND CC-BY-3.0)', | ||
'(WTFPL OR MIT)' | ||
], | ||
ignore: { | ||
// BSD-3-Clause, see https://github.com/deoxxa/duplexer2/blob/0.0.2/LICENSE.md | ||
duplexer2: '0.0.2', | ||
// BSD-3-Clause, see https://github.com/estools/esquery/blob/v1.0.0/license.txt | ||
esquery: '1.0.0', | ||
// MIT, see https://github.com/mklabs/node-fileset/blob/v0.2.1/LICENSE-MIT | ||
fileset: '0.2.1', | ||
// MIT, https://github.com/tarruda/has/blob/1.0.1/package.json | ||
has: '1.0.1', | ||
// BSD-2-Clause, see https://github.com/facebook/regenerator/blob/30d34536b9e3f7a2873b04a16ec66fec9c8246f6/LICENSE | ||
'regenerator-transform': '0.10.1', | ||
// BSD-2-Clause, see https://github.com/jviereck/regjsparser/blob/0.1.5/LICENSE.BSD | ||
regjsparser: '0.1.5', | ||
// MIT, see https://github.com/eugeneware/unique-stream/blob/v1.0.0/LICENSE | ||
'unique-stream': '1.0.0' | ||
} | ||
}); | ||
}). | ||
start(); |
@@ -102,2 +102,9 @@ 'use strict'; | ||
}); | ||
test('throws an error when an invalid string is given.', done => { | ||
crypto2.decrypt.aes256cbc('this-is-not-encrypted', 'secret', err => { | ||
assert.that(err.message).is.equalTo('Bad input string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -122,2 +129,12 @@ | ||
}); | ||
test('throws an error when an invalid string is given.', done => { | ||
crypto2.readPrivateKey('./test/units/privateKey.pem', (errReadPrivateKey, privateKey) => { | ||
assert.that(errReadPrivateKey).is.null(); | ||
crypto2.decrypt.rsa('this-is-not-encrypted', privateKey, errDecrypt => { | ||
assert.that(errDecrypt.message).is.equalTo('Error during decryption (probably incorrect key). Original error: Error: Incorrect data or key'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -124,0 +141,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34968
635
9
2