* Generate a TOTP code from a secret key * @param secret Base32 encoded secret key * @returns TOTP code
(secret: string)
| 10 | * @returns TOTP code |
| 11 | */ |
| 12 | public static generateTOTP(secret: string): string { |
| 13 | const epoch = Math.floor(Date.now() / 1000) |
| 14 | const timeCounter = Math.floor(epoch / this.PERIOD) |
| 15 | return this.generateTOTPAtCounter(secret, timeCounter) |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Validate if a secret key is in valid Base32 format |
no test coverage detected