Skip to content

Commit

Permalink
Add TOTP verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Nov 7, 2017
1 parent 36fe56d commit 5ebe6b7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/algorithms/totp.js
Expand Up @@ -8,12 +8,22 @@ function TotpAlgorithm() {
TotpAlgorithm.prototype.generate = function(cb) {
console.log('GENERATE TOTP');

var secret = speakeasy.generateSecret();
var secret = speakeasy.generateSecret({ otpauth_url: false });
console.log(secret);

var otpauthURL = speakeasy.otpauthURL( {
secret: secret.ascii,
issuer: 'Foo',
label: 'test-at-test'
})

return cb(null, { secret: secret.ascii, barcodeURL: otpauthURL });
}

TotpAlgorithm.prototype.verify = function() {

TotpAlgorithm.prototype.verify = function(authnr, otp, cb) {
var opts = { secret: authnr.secret, token: otp };
var verified = speakeasy.totp.verify(opts);
return cb(null, verified);
}


Expand Down

0 comments on commit 5ebe6b7

Please sign in to comment.