From 164718bcd4ff4e56247859dc108b2fe10907603f Mon Sep 17 00:00:00 2001 From: Gin Date: Tue, 6 Nov 2018 11:24:51 +0800 Subject: [PATCH] fix: type check error --- src/hotp.js | 4 ++++ src/totp.js | 4 ++++ 2 files changed, 8 insertions(+) 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; }