Skip to content

Commit d2dc5f0

Browse files
committed
[Fix] check parameters before the "no Promise" bailout
1 parent b2ad615 commit d2dc5f0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/async.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ module.exports = function (password, salt, iterations, keylen, digest, callback)
8888
digest = undefined;
8989
}
9090

91+
checkParameters(iterations, keylen);
92+
password = toBuffer(password, defaultEncoding, 'Password');
93+
salt = toBuffer(salt, defaultEncoding, 'Salt');
94+
if (typeof callback !== 'function') {
95+
throw new Error('No callback provided to pbkdf2');
96+
}
97+
9198
digest = digest || 'sha1';
9299
var algo = toBrowser[digest.toLowerCase()];
93100

@@ -105,13 +112,6 @@ module.exports = function (password, salt, iterations, keylen, digest, callback)
105112
return;
106113
}
107114

108-
checkParameters(iterations, keylen);
109-
password = toBuffer(password, defaultEncoding, 'Password');
110-
salt = toBuffer(salt, defaultEncoding, 'Salt');
111-
if (typeof callback !== 'function') {
112-
throw new Error('No callback provided to pbkdf2');
113-
}
114-
115115
resolvePromise(checkNative(algo).then(function (resp) {
116116
if (resp) {
117117
return browserPbkdf2(password, salt, iterations, keylen, algo);

0 commit comments

Comments
 (0)