Browse Source

feat: two factor type

httpjamesm 1 year ago
parent
commit
cbdb4907cf
2 changed files with 16 additions and 2 deletions
  1. 12 2
      web/packages/accounts/api/user.ts
  2. 4 0
      web/packages/accounts/constants/twofactor.ts

+ 12 - 2
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 { getToken } from "@ente/shared/storage/localStorage/helpers";
 import { KeyAttributes } from "@ente/shared/user/types";
 import { KeyAttributes } from "@ente/shared/user/types";
 import { HttpStatusCode } from "axios";
 import { HttpStatusCode } from "axios";
+import { TwoFactorType } from "../constants/twofactor";
 
 
 const ENDPOINT = getEndpoint();
 const ENDPOINT = getEndpoint();
 
 
@@ -79,17 +80,26 @@ export const verifyTwoFactor = async (code: string, sessionID: string) => {
     return resp.data as UserVerificationResponse;
     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`, {
     const resp = await HTTPService.get(`${ENDPOINT}/users/two-factor/recover`, {
         sessionID,
         sessionID,
+        twoFactorType,
     });
     });
     return resp.data as TwoFactorRecoveryResponse;
     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`, {
     const resp = await HTTPService.post(`${ENDPOINT}/users/two-factor/remove`, {
         sessionID,
         sessionID,
         secret,
         secret,
+        twoFactorType,
     });
     });
     return resp.data as TwoFactorVerificationResponse;
     return resp.data as TwoFactorVerificationResponse;
 };
 };

+ 4 - 0
web/packages/accounts/constants/twofactor.ts

@@ -0,0 +1,4 @@
+export enum TwoFactorType {
+    PASSKEY = "passkey",
+    TOTP = "totp",
+}