add: TOTP.now function

This commit is contained in:
lancegin
2017-06-30 11:14:15 +08:00
parent 67be5af566
commit be851891f5
2 changed files with 9 additions and 3 deletions
+7 -1
View File
@@ -4,6 +4,7 @@
*/
import { OTP } from './otp';
import { Util } from './util';
export class TOTP extends OTP {
/*
@@ -35,7 +36,12 @@ export class TOTP extends OTP {
* ```
*/
now() {
return "TOTP.now";
// get now time string
let now = Util.timecode(new Date(), this.interval);
// generate the one-time password
let digit = super.generate_otp(now);
return digit;
}
/*