From 56ed9851fb5780d1e0b3ac7de1e511c125b0e75c Mon Sep 17 00:00:00 2001 From: Bereket Engida Date: Tue, 10 Dec 2024 19:11:17 +0300 Subject: [PATCH] refactor: don't require second argument on generate otp --- src/otp.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/otp.ts b/src/otp.ts index d9d3eb3..a5fe062 100644 --- a/src/otp.ts +++ b/src/otp.ts @@ -39,17 +39,17 @@ export async function generateHOTP( export async function generateTOTP( secret: string, - { - period = defaultPeriod, - digits = defaultDigits, - }: { + options?: { period?: number; digits?: number; - }, + hash?: SHAFamily; + } ) { + const digits = options?.digits ?? defaultDigits; + const period = options?.period ?? defaultPeriod; const milliseconds = period * 1000; const counter = Math.floor(Date.now() / milliseconds); - return await generateHOTP(secret, { counter, digits }); + return await generateHOTP(secret, { counter, digits, hash: options?.hash }); }