diff --git a/web/packages/accounts/api/user.ts b/web/packages/accounts/api/user.ts index def8fa8c4a6d2cf283e268ea3daad54ede8b0127..ff4f7032678afb0e212749f0c713ce60505bde06 100644 --- a/web/packages/accounts/api/user.ts +++ b/web/packages/accounts/api/user.ts @@ -15,6 +15,7 @@ import { logError } from "@ente/shared/sentry"; import { getToken } from "@ente/shared/storage/localStorage/helpers"; import { KeyAttributes } from "@ente/shared/user/types"; import { HttpStatusCode } from "axios"; +import { TwoFactorType } from "../constants/twofactor"; const ENDPOINT = getEndpoint(); @@ -79,17 +80,26 @@ export const verifyTwoFactor = async (code: string, sessionID: string) => { return resp.data as UserVerificationResponse; }; -export const recoverTwoFactor = async (sessionID: string) => { +export const recoverTwoFactor = async ( + sessionID: string, + twoFactorType: TwoFactorType, +) => { const resp = await HTTPService.get(`${ENDPOINT}/users/two-factor/recover`, { sessionID, + twoFactorType, }); return resp.data as TwoFactorRecoveryResponse; }; -export const removeTwoFactor = async (sessionID: string, secret: string) => { +export const removeTwoFactor = async ( + sessionID: string, + secret: string, + twoFactorType: TwoFactorType, +) => { const resp = await HTTPService.post(`${ENDPOINT}/users/two-factor/remove`, { sessionID, secret, + twoFactorType, }); return resp.data as TwoFactorVerificationResponse; }; diff --git a/web/packages/accounts/constants/twofactor.ts b/web/packages/accounts/constants/twofactor.ts new file mode 100644 index 0000000000000000000000000000000000000000..92b10730d42a7f432f000f17d0df4181e33b8b32 --- /dev/null +++ b/web/packages/accounts/constants/twofactor.ts @@ -0,0 +1,4 @@ +export enum TwoFactorType { + PASSKEY = "passkey", + TOTP = "totp", +}