Skip to content

Commit 9a72b95

Browse files
committed
refactor: update return types in 2FA processing functions for better type safety
1 parent 9897036 commit 9a72b95

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

apps/meteor/client/lib/2fa/process2faReturn.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ export async function process2faReturn({
9292
}
9393
}
9494

95-
export async function process2faAsyncReturn({
95+
export async function process2faAsyncReturn<TResult>({
9696
error,
9797
onCode,
9898
emailOrUsername,
9999
}: {
100100
error: unknown;
101-
onCode: (code: string, method: string) => unknown | Promise<unknown>;
101+
onCode: (code: string, method: string) => TResult | Promise<TResult>;
102102
emailOrUsername: string | null | undefined;
103-
}): Promise<unknown> {
103+
}): Promise<TResult> {
104104
// if the promise is rejected, we need to check if it's a 2fa error
105105
// if it's not a 2fa error, we reject the promise
106106
if (!(isTotpRequiredError(error) || isTotpInvalidError(error)) || !hasRequiredTwoFactorMethod(error)) {

apps/meteor/client/meteorOverrides/totpOnCall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const withSyncTOTP = (call: (name: string, ...args: any[]) => any) => {
4545
};
4646
};
4747

48-
const withAsyncTOTP = (callAsync: (name: string, ...args: any[]) => Promise<any>) => {
49-
return async function callAsyncWithTOTP(methodName: string, ...args: unknown[]): Promise<unknown> {
48+
const withAsyncTOTP = <TResult>(callAsync: (name: string, ...args: any[]) => Promise<TResult>) => {
49+
return async function callAsyncWithTOTP(methodName: string, ...args: unknown[]): Promise<TResult> {
5050
try {
5151
return await callAsync(methodName, ...args);
5252
} catch (error: unknown) {

0 commit comments

Comments
 (0)