remove err
argument from functions
It was never used and is not really the node.js way to do things.
This commit is contained in:
parent
190d29070c
commit
4475c95ecb
@ -35,7 +35,7 @@ var base32 = require('thirty-two');
|
|||||||
* be user specific, and be incremented for each request.
|
* be user specific, and be incremented for each request.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports.checkHOTP = function(args, err, cb) {
|
module.exports.checkHOTP = function(args, cb) {
|
||||||
|
|
||||||
var hmac,
|
var hmac,
|
||||||
digest,
|
digest,
|
||||||
@ -103,7 +103,7 @@ module.exports.checkHOTP = function(args, err, cb) {
|
|||||||
* Default - 30
|
* Default - 30
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports.checkTOTP = function(args, err, cb) {
|
module.exports.checkTOTP = function(args, cb) {
|
||||||
|
|
||||||
var hmac,
|
var hmac,
|
||||||
digest,
|
digest,
|
||||||
@ -168,7 +168,7 @@ module.exports.checkTOTP = function(args, err, cb) {
|
|||||||
* be user specific, and be incremented for each request.
|
* be user specific, and be incremented for each request.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports.getHOTP = function(args, err, cb) {
|
module.exports.getHOTP = function(args, cb) {
|
||||||
|
|
||||||
var hmac,
|
var hmac,
|
||||||
digest,
|
digest,
|
||||||
@ -203,7 +203,7 @@ module.exports.getHOTP = function(args, err, cb) {
|
|||||||
* Default - 30
|
* Default - 30
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports.getTOTP = function(args, err, cb) {
|
module.exports.getTOTP = function(args, cb) {
|
||||||
var hmac,
|
var hmac,
|
||||||
digest,
|
digest,
|
||||||
offset, h, v, p = 6, b,
|
offset, h, v, p = 6, b,
|
||||||
|
48
test/notp.js
48
test/notp.js
@ -60,9 +60,6 @@ exports.testHOTP = function(beforeExit, assert) {
|
|||||||
args.C = 0;
|
args.C = 0;
|
||||||
args.P = 'WILLNOTPASS';
|
args.P = 'WILLNOTPASS';
|
||||||
notp.checkHOTP(args,
|
notp.checkHOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, false, 'Should not pass');
|
assert.eql(ret, false, 'Should not pass');
|
||||||
n++;
|
n++;
|
||||||
@ -74,9 +71,6 @@ exports.testHOTP = function(beforeExit, assert) {
|
|||||||
args.C = i;
|
args.C = i;
|
||||||
args.P = HOTP[i];
|
args.P = HOTP[i];
|
||||||
notp.checkHOTP(args,
|
notp.checkHOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, true, 'Should pass');
|
assert.eql(ret, true, 'Should pass');
|
||||||
assert.eql(w, 0, 'Should be in sync');
|
assert.eql(w, 0, 'Should be in sync');
|
||||||
@ -108,9 +102,6 @@ exports.testTOTP = function(beforeExit, assert) {
|
|||||||
args.T = 0;
|
args.T = 0;
|
||||||
args.P = 'WILLNOTPASS';
|
args.P = 'WILLNOTPASS';
|
||||||
notp.checkTOTP(args,
|
notp.checkTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, false, 'Should not pass');
|
assert.eql(ret, false, 'Should not pass');
|
||||||
n++;
|
n++;
|
||||||
@ -121,9 +112,6 @@ exports.testTOTP = function(beforeExit, assert) {
|
|||||||
args._t = 59*1000;
|
args._t = 59*1000;
|
||||||
args.P = '287082';
|
args.P = '287082';
|
||||||
notp.checkTOTP(args,
|
notp.checkTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, true, 'Should pass');
|
assert.eql(ret, true, 'Should pass');
|
||||||
assert.eql(w, 0, 'Should be in sync');
|
assert.eql(w, 0, 'Should be in sync');
|
||||||
@ -135,9 +123,6 @@ exports.testTOTP = function(beforeExit, assert) {
|
|||||||
args._t = 1234567890*1000;
|
args._t = 1234567890*1000;
|
||||||
args.P = '005924';
|
args.P = '005924';
|
||||||
notp.checkTOTP(args,
|
notp.checkTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, true, 'Should pass');
|
assert.eql(ret, true, 'Should pass');
|
||||||
assert.eql(w, 0, 'Should be in sync');
|
assert.eql(w, 0, 'Should be in sync');
|
||||||
@ -149,9 +134,6 @@ exports.testTOTP = function(beforeExit, assert) {
|
|||||||
args._t = 1111111109*1000;
|
args._t = 1111111109*1000;
|
||||||
args.P = '081804';
|
args.P = '081804';
|
||||||
notp.checkTOTP(args,
|
notp.checkTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, true, 'Should pass');
|
assert.eql(ret, true, 'Should pass');
|
||||||
assert.eql(w, 0, 'Should be in sync');
|
assert.eql(w, 0, 'Should be in sync');
|
||||||
@ -163,9 +145,6 @@ exports.testTOTP = function(beforeExit, assert) {
|
|||||||
args._t = 2000000000*1000;
|
args._t = 2000000000*1000;
|
||||||
args.P = '279037';
|
args.P = '279037';
|
||||||
notp.checkTOTP(args,
|
notp.checkTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, true, 'Should pass');
|
assert.eql(ret, true, 'Should pass');
|
||||||
assert.eql(w, 0, 'Should be in sync');
|
assert.eql(w, 0, 'Should be in sync');
|
||||||
@ -196,9 +175,6 @@ exports.testHOTPOutOfSync = function(beforeExit, assert) {
|
|||||||
// Check that the test should fail for W < 8
|
// Check that the test should fail for W < 8
|
||||||
args.W = 7;
|
args.W = 7;
|
||||||
notp.checkHOTP(args,
|
notp.checkHOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, false, 'Should not pass for value of W < 8');
|
assert.eql(ret, false, 'Should not pass for value of W < 8');
|
||||||
n++;
|
n++;
|
||||||
@ -208,9 +184,6 @@ exports.testHOTPOutOfSync = function(beforeExit, assert) {
|
|||||||
// Check that the test should pass for W >= 9
|
// Check that the test should pass for W >= 9
|
||||||
args.W = 8;
|
args.W = 8;
|
||||||
notp.checkHOTP(args,
|
notp.checkHOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, true, 'Should pass for value of W >= 9');
|
assert.eql(ret, true, 'Should pass for value of W >= 9');
|
||||||
n++;
|
n++;
|
||||||
@ -239,9 +212,6 @@ exports.testTOTPOutOfSync = function(beforeExit, assert) {
|
|||||||
// Check that the test should fail for W < 2
|
// Check that the test should fail for W < 2
|
||||||
args.W = 2;
|
args.W = 2;
|
||||||
notp.checkTOTP(args,
|
notp.checkTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, false, 'Should not pass for value of W < 3');
|
assert.eql(ret, false, 'Should not pass for value of W < 3');
|
||||||
n++;
|
n++;
|
||||||
@ -251,9 +221,6 @@ exports.testTOTPOutOfSync = function(beforeExit, assert) {
|
|||||||
// Check that the test should pass for W >= 3
|
// Check that the test should pass for W >= 3
|
||||||
args.W = 3;
|
args.W = 3;
|
||||||
notp.checkTOTP(args,
|
notp.checkTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, true, 'Should pass for value of W >= 3');
|
assert.eql(ret, true, 'Should pass for value of W >= 3');
|
||||||
n++;
|
n++;
|
||||||
@ -281,9 +248,6 @@ exports.testGetHOTP = function(beforeExit, assert) {
|
|||||||
for(i=0;i<HOTP.length;i++) {
|
for(i=0;i<HOTP.length;i++) {
|
||||||
args.C = i;
|
args.C = i;
|
||||||
notp.getHOTP(args,
|
notp.getHOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret) {
|
function(ret) {
|
||||||
assert.eql(ret, HOTP[i], 'HTOP value should be correct');
|
assert.eql(ret, HOTP[i], 'HTOP value should be correct');
|
||||||
n++;
|
n++;
|
||||||
@ -310,9 +274,6 @@ exports.testGetTOTP = function(beforeExit, assert) {
|
|||||||
// Check for test vector at 59s
|
// Check for test vector at 59s
|
||||||
args._t = 59*1000;
|
args._t = 59*1000;
|
||||||
notp.getTOTP(args,
|
notp.getTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, '287082', 'TOTP values should match');
|
assert.eql(ret, '287082', 'TOTP values should match');
|
||||||
n++;
|
n++;
|
||||||
@ -322,9 +283,6 @@ exports.testGetTOTP = function(beforeExit, assert) {
|
|||||||
// Check for test vector at 1234567890
|
// Check for test vector at 1234567890
|
||||||
args._t = 1234567890*1000;
|
args._t = 1234567890*1000;
|
||||||
notp.getTOTP(args,
|
notp.getTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, '005924', 'TOTP values should match');
|
assert.eql(ret, '005924', 'TOTP values should match');
|
||||||
n++;
|
n++;
|
||||||
@ -334,9 +292,6 @@ exports.testGetTOTP = function(beforeExit, assert) {
|
|||||||
// Check for test vector at 1111111109
|
// Check for test vector at 1111111109
|
||||||
args._t = 1111111109*1000;
|
args._t = 1111111109*1000;
|
||||||
notp.getTOTP(args,
|
notp.getTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, '081804', 'TOTP values should match');
|
assert.eql(ret, '081804', 'TOTP values should match');
|
||||||
n++;
|
n++;
|
||||||
@ -346,9 +301,6 @@ exports.testGetTOTP = function(beforeExit, assert) {
|
|||||||
// Check for test vector at 2000000000
|
// Check for test vector at 2000000000
|
||||||
args._t = 2000000000*1000;
|
args._t = 2000000000*1000;
|
||||||
notp.getTOTP(args,
|
notp.getTOTP(args,
|
||||||
function(err) {
|
|
||||||
assert.eql(true, false, err);
|
|
||||||
},
|
|
||||||
function(ret, w) {
|
function(ret, w) {
|
||||||
assert.eql(ret, '279037', 'TOTP values should match');
|
assert.eql(ret, '279037', 'TOTP values should match');
|
||||||
n++;
|
n++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user