From d45be3ee68ab6e8207fe428334df5e5e15201f87 Mon Sep 17 00:00:00 2001 From: Lisoveliy Date: Thu, 24 Jul 2025 17:42:48 +0300 Subject: [PATCH] fix: provided hashType into getOTP --- lib/totp-quickjs/OTPGenerator.js | 4 ++-- lib/totp-quickjs/index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/totp-quickjs/OTPGenerator.js b/lib/totp-quickjs/OTPGenerator.js index 7e161d0..044c006 100644 --- a/lib/totp-quickjs/OTPGenerator.js +++ b/lib/totp-quickjs/OTPGenerator.js @@ -54,6 +54,6 @@ export function getTOTP( timeOffset = 0, hashType = "SHA-1", ) { - const unixTime = Math.round((time / 1000 + timeOffset) / fetchTime); - return getHOTP(BigInt(unixTime), secret, digits); + const unixTime = Math.round((time / 1000n + timeOffset) / fetchTime); + return getHOTP(BigInt(unixTime), secret, digits, hashType); } diff --git a/lib/totp-quickjs/index.js b/lib/totp-quickjs/index.js index d77715f..2d6c6e5 100644 --- a/lib/totp-quickjs/index.js +++ b/lib/totp-quickjs/index.js @@ -48,12 +48,12 @@ export class TOTP { */ getOTP(time = Date.now()) { const unixTime = (time / 1000 + this.timeOffset) / this.fetchTime; - const otp = getHOTP(Math.floor(unixTime), this.secret, this.digits); + const otp = getHOTP(Math.floor(unixTime), this.secret, this.digits, this.hashType); const expireTime = time + (this.fetchTime - ((time / 1000 + this.timeOffset) % this.fetchTime)) * - 1000; + 1000; const createdTime = time - ((time / 1000 + this.timeOffset) % this.fetchTime) * 1000;