Two- / Multi- Factor Authenication (2FA / MFA / OTP) for node.js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

24 lines
657 B

'use strict';
var authenticator = require('./authenticator');
var formattedKey = authenticator.generateKey();
console.log(formattedKey);
// "acqo ua72 d3yf a4e5 uorx ztkh j2xl 3wiz"
var formattedToken = authenticator.generateToken(formattedKey);
console.log(formattedToken);
// "957 124"
var result = authenticator.verifyToken(formattedKey, formattedToken);
console.log(result);
// { delta: 0 }
result = authenticator.verifyToken(formattedKey, '000-000');
console.log(result);
// null
// result will allways be one of
// (failure) null
// (success) { delta: -1 }, { delta: 0 }, or { delta: 1 }
// delta lets you know which way time drift is occurring