forked from jeremyscalpello/node-2fa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
30 lines (23 loc) · 1.15 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var twoFactor = require('./index.js');
console.log("*******************************");
console.log("Generating New Secret");
var newSecret = twoFactor.generateSecret({name: 'My Awesome App', account: 'johndoe'});
console.log(newSecret);
console.log("*******************************");
console.log("Generating New Token With Secret " + newSecret.secret);
var newToken = twoFactor.generateToken(newSecret.secret);
console.log(newToken);
console.log("*******************************");
console.log("Verifying Valid Token");
console.log(twoFactor.verifyToken(newSecret.secret, newToken.token));
console.log("*******************************");
console.log("Verifying Valid Token - Window: 1");
console.log(twoFactor.verifyToken(newSecret.secret, newToken.token, 1));
console.log("*******************************");
console.log("Verifying Valid Token - Window: -3");
console.log(twoFactor.verifyToken(newSecret.secret, newToken.token, -3));
console.log("*******************************");
console.log("Verifying Invalid Token");
console.log(twoFactor.verifyToken(newSecret.secret, '11111'));
console.log("*******************************");
console.log("Done - Star Me On Github");