Comparing version 1.0.1 to 1.0.2
@@ -42,3 +42,3 @@ 'use strict'; | ||
if (!cb) { | ||
return promises.promise(genSalt, this, arguments); | ||
return promises.promise(genSalt, this, [rounds, ignore]); | ||
} | ||
@@ -110,3 +110,3 @@ | ||
if (!cb) { | ||
return promises.promise(hash, this, arguments); | ||
return promises.promise(hash, this, [data, salt]); | ||
} | ||
@@ -157,11 +157,11 @@ | ||
module.exports.compare = function compare(data, hash, cb) { | ||
if (data == null || hash == null) { | ||
if (typeof data === 'function') { | ||
return process.nextTick(function() { | ||
cb(new Error('data and hash arguments required')); | ||
data(new Error('data and hash arguments required')); | ||
}); | ||
} | ||
if (typeof data !== 'string' || typeof hash !== 'string') { | ||
if (typeof hash === 'function') { | ||
return process.nextTick(function() { | ||
cb(new Error('data and hash must be strings')); | ||
hash(new Error('data and hash arguments required')); | ||
}); | ||
@@ -177,5 +177,17 @@ } | ||
if (!cb) { | ||
return promises.promise(compare, this, arguments); | ||
return promises.promise(compare, this, [data, hash]); | ||
} | ||
if (data == null || hash == null) { | ||
return process.nextTick(function() { | ||
cb(new Error('data and hash arguments required')); | ||
}); | ||
} | ||
if (typeof data !== 'string' || typeof hash !== 'string') { | ||
return process.nextTick(function() { | ||
cb(new Error('data and hash must be strings')); | ||
}); | ||
} | ||
return bindings.compare(data, hash, cb); | ||
@@ -182,0 +194,0 @@ }; |
@@ -0,1 +1,5 @@ | ||
# 1.0.2 (2016-12-31) | ||
* Fix `compare` promise rejection with invalid arguments | ||
# 1.0.1 (2016-12-07) | ||
@@ -2,0 +6,0 @@ |
@@ -14,3 +14,3 @@ { | ||
"main": "./bcrypt", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "Nick Campbell (https://github.com/ncb000gt)", | ||
@@ -34,4 +34,4 @@ "engines": { | ||
"bindings": "1.2.1", | ||
"nan": "2.3.5", | ||
"node-pre-gyp": "0.6.30" | ||
"nan": "2.5.0", | ||
"node-pre-gyp": "0.6.32" | ||
}, | ||
@@ -55,3 +55,4 @@ "devDependencies": { | ||
"Sean McArthur <sean.monstar@gmail.com> (https://github.com/seanmonstar)", | ||
"Fanie Oosthuysen <fanie.oosthuysen@gmail.com> (https://github.com/weareu)" | ||
"Fanie Oosthuysen <fanie.oosthuysen@gmail.com> (https://github.com/weareu)", | ||
"Amitosh Swain Mahapatra <amitosh.swain@gmail.com> (https://github.com/Agathver)" | ||
], | ||
@@ -58,0 +59,0 @@ "binary": { |
@@ -255,2 +255,3 @@ # node.bcrypt.js | ||
* [Fanie Oosthuysen][weareu] - Windows Support | ||
* [Amitosh Swain Mahapatra][agathver] - ES6 Promise Support | ||
@@ -281,1 +282,2 @@ ## License | ||
[weareu]:https://github.com/weareu | ||
[agathver]:https://github.com/Agathver |
@@ -148,3 +148,15 @@ var bcrypt = require('../bcrypt'); | ||
}); | ||
}, | ||
test_compare_no_params: function(assert) { | ||
bcrypt.compare(function(err, hash) { | ||
assert.ok(err, 'Should be an error. No params.'); | ||
assert.done(); | ||
}); | ||
}, | ||
test_hash_compare_one_param: function(assert) { | ||
bcrypt.compare('password', function(err, hash) { | ||
assert.ok(err, 'Should be an Error. No hash.'); | ||
assert.done(); | ||
}); | ||
} | ||
}; |
@@ -17,2 +17,6 @@ var bcrypt = require('../bcrypt'); | ||
}, | ||
test_salt_returns_promise_on_null_callback: function(assert) { | ||
assert.ok(typeof bcrypt.genSalt(13, null, null).then === 'function', "Should return a promise"); | ||
assert.done(); | ||
}, | ||
test_salt_length: function(assert) { | ||
@@ -46,2 +50,6 @@ assert.expect(2); | ||
}, | ||
test_hash_returns_promise_on_null_callback: function(assert) { | ||
assert.ok(typeof bcrypt.hash('password', 10, null).then === 'function', "Should return a promise"); | ||
assert.done(); | ||
}, | ||
test_hash: function(assert) { | ||
@@ -144,2 +152,6 @@ assert.expect(1); | ||
}, | ||
test_hash_compare_returns_promise_on_null_callback: function(assert) { | ||
assert.ok(typeof bcrypt.compare('password', 'something', null).then === 'function', "Should return a promise"); | ||
assert.done(); | ||
}, | ||
test_hash_compare: function(assert) { | ||
@@ -189,4 +201,24 @@ assert.expect(3); | ||
}); | ||
}, | ||
test_hash_compare_no_params: function(assert) { | ||
assert.expect(1); | ||
bcrypt.compare().then(function() { | ||
fail(assert, 'Should not resolve'); | ||
}).catch(function(err) { | ||
assert.equal(err.message, 'data and hash arguments required', 'Promise should be rejected when no parameters are supplied'); | ||
}).then(function() { | ||
assert.done(); | ||
}); | ||
}, | ||
test_hash_compare_one_param: function(assert) { | ||
assert.expect(1); | ||
bcrypt.compare('password').then(function() { | ||
fail(assert, 'Should not resolve'); | ||
}).catch(function(err) { | ||
assert.equal(err.message, 'data and hash arguments required', 'Promise should be rejected when no parameters are supplied'); | ||
}).then(function() { | ||
assert.done(); | ||
}); | ||
} | ||
}; | ||
} | ||
} |
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
98259
833
282
+ Addednan@2.5.0(transitive)
+ Addednode-pre-gyp@0.6.32(transitive)
+ Addedtar-pack@3.3.0(transitive)
- Removednan@2.3.5(transitive)
- Removednode-pre-gyp@0.6.30(transitive)
- Removedtar-pack@3.1.4(transitive)
Updatednan@2.5.0
Updatednode-pre-gyp@0.6.32