From ce93c2fb70860455d3d12dc01945537b41a365c9 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 a4fb9e0..b812d1e 100644 --- a/lib/totp-quickjs/OTPGenerator.js +++ b/lib/totp-quickjs/OTPGenerator.js @@ -58,6 +58,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;