diff --git a/src/hotp.js b/src/hotp.js index 86be771..3931da3 100644 --- a/src/hotp.js +++ b/src/hotp.js @@ -50,6 +50,10 @@ export class HOTP extends OTP { verify(otp, counter) { const otp_count = this.at(counter); + if (typeof(otp) === 'number') { + otp = otp.toString(); + } + if (otp === otp_count) { return true; } diff --git a/src/totp.js b/src/totp.js index d926314..d76ea7d 100644 --- a/src/totp.js +++ b/src/totp.js @@ -75,6 +75,10 @@ export class TOTP extends OTP { } otp_time = super.generate_otp(Util.timecode(time, this.interval)); + if (typeof(otp) === 'number') { + otp = otp.toString(); + } + if (otp === otp_time) { return true; }