mirror of
https://github.com/LanceGin/jsotp.git
synced 2026-05-24 00:00:05 +08:00
add: TOTP.now function
This commit is contained in:
+7
-1
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user