Skip to content

Commit

Permalink
Use interface instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin Mors committed Nov 19, 2024
1 parent 5b1db81 commit 7e0913c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/modules/crypto/otpauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ const parseOtpauth = (uri: string): Otpauth => {
};
};

export const generateOtpFromUri = (uri: string): { token: string; remainingTime: number | null } => {
export interface GenerateOtpOutput {
token: string;
remainingTime: number | null;
}

export const generateOtpFromUri = (uri: string): GenerateOtpOutput => {
const otpauth = parseOtpauth(uri);

authenticator.resetOptions();
Expand All @@ -68,7 +73,7 @@ export const generateOtpFromUri = (uri: string): { token: string; remainingTime:
}
};

export const generateOtpFromSecret = (secret: string): { token: string; remainingTime: number | null } => {
export const generateOtpFromSecret = (secret: string): GenerateOtpOutput => {
authenticator.resetOptions();
return { token: authenticator.generate(secret), remainingTime: authenticator.timeRemaining() };
};

0 comments on commit 7e0913c

Please sign in to comment.