speakeasy
speakeasy copied to clipboard
Increase token expiration time
var token = speakeasy.totp({ secret: secret.base32, encoding: 'base32', time:300 });
console.log(token);
var verified = speakeasy.totp.verify({
secret: secret.base32,
encoding: 'base32',
token: token
});
console.log(verified);
Always returns false value
The time option overrides the TOTP expiry algorithm. The token you generated is valid at 00:05 on 1 January 1970.
On Apr 16, 2017, at 11:17 PM, Shamoncushbu [email protected] wrote:
var token = speakeasy.totp({ secret: secret.base32, encoding: 'base32', time:300 });
console.log(token); var verified = speakeasy.totp.verify({ secret: secret.base32, encoding: 'base32', token: token }); console.log(verified);Always returns false value
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/speakeasyjs/speakeasy/issues/85, or mute the thread https://github.com/notifications/unsubscribe-auth/AAm4b_RYJX3L6lFPXQjQAC5lBQlHzMEEks5rwwPzgaJpZM4M-591.
@mikepb so whats the correct way of using time based tokens
If a custom time token is created, you need to pass the same time value to verify/verifyDelta method.
var token = speakeasy.totp({ secret: secret.base32, encoding: 'base32', time:300 });
var verified = speakeasy.totp.verify({ secret: secret.base32, encoding: 'base32', token: token, time: 300 }); console.log(verified);
The console log statement will return verified in this case. The totp.verify example with custom time value is not provided in documentation. It should be updated to avoid future confusion.
so what's the expiry time then? 30 seconds? or how do i increase the expiry time?
so what's the expiry time then? 30 seconds? or how do i increase the expiry time?
@mikepb Could you answer this?
I added a time to mine but the token stays the same no matter what, is this suppose to happen? When I take out the time it changes the token but quite frequently, I feel like the documentation didn't explain this well.
var token = speakeasy.totp({ secret: secret, encoding: 'base32', time: 120, }); return token; console.log(token); }