Skip to content

Commit

Permalink
refactor: don't require second argument on generate otp
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekacru committed Dec 10, 2024
1 parent 8ccf33b commit 56ed985
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/otp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}


Expand Down

0 comments on commit 56ed985

Please sign in to comment.