π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
type
Manav Rathi1ff6a53131d1
diff --git a/web/apps/accounts/src/pages/passkeys/flow/Recover.tsx b/web/apps/accounts/src/pages/passkeys/flow/Recover.tsxindex d0401606e6..6111109efb 100644--- a/web/apps/accounts/src/pages/passkeys/flow/Recover.tsx+++ b/web/apps/accounts/src/pages/passkeys/flow/Recover.tsx@@ -1,9 +1,8 @@-import { TwoFactorType } from "@ente/accounts/constants/twofactor";import Page_ from "@ente/accounts/pages/two-factor/recover";import { useAppContext } from "../../_app";const Page = () => (- <Page_ appContext={useAppContext()} twoFactorType={TwoFactorType.PASSKEY} />+ <Page_ appContext={useAppContext()} twoFactorType="passkey" />);export default Page;diff --git a/web/apps/accounts/src/pages/two-factor/recover.tsx b/web/apps/accounts/src/pages/two-factor/recover.tsxindex d3f40be49c..61414077e5 100644--- a/web/apps/accounts/src/pages/two-factor/recover.tsx+++ b/web/apps/accounts/src/pages/two-factor/recover.tsx@@ -1,6 +1,6 @@import Page_ from "@ente/accounts/pages/two-factor/recover";import { useAppContext } from "../_app";-const Page = () => <Page_ appContext={useAppContext()} />;+const Page = () => <Page_ appContext={useAppContext()} twoFactorType="totp" />;export default Page;diff --git a/web/apps/auth/src/pages/two-factor/recover.tsx b/web/apps/auth/src/pages/two-factor/recover.tsxindex d3f40be49c..61414077e5 100644--- a/web/apps/auth/src/pages/two-factor/recover.tsx+++ b/web/apps/auth/src/pages/two-factor/recover.tsx@@ -1,6 +1,6 @@import Page_ from "@ente/accounts/pages/two-factor/recover";import { useAppContext } from "../_app";-const Page = () => <Page_ appContext={useAppContext()} />;+const Page = () => <Page_ appContext={useAppContext()} twoFactorType="totp" />;export default Page;diff --git a/web/apps/photos/src/pages/two-factor/recover.tsx b/web/apps/photos/src/pages/two-factor/recover.tsxindex d3f40be49c..61414077e5 100644--- a/web/apps/photos/src/pages/two-factor/recover.tsx+++ b/web/apps/photos/src/pages/two-factor/recover.tsx@@ -1,6 +1,6 @@import Page_ from "@ente/accounts/pages/two-factor/recover";import { useAppContext } from "../_app";-const Page = () => <Page_ appContext={useAppContext()} />;+const Page = () => <Page_ appContext={useAppContext()} twoFactorType="totp" />;export default Page;diff --git a/web/packages/accounts/api/user.ts b/web/packages/accounts/api/user.tsindex 55d48b4d16..1060bb6ebb 100644--- a/web/packages/accounts/api/user.ts+++ b/web/packages/accounts/api/user.ts@@ -13,7 +13,6 @@ import { getEndpoint } from "@ente/shared/network/api";import { getToken } from "@ente/shared/storage/localStorage/helpers";import type { KeyAttributes } from "@ente/shared/user/types";import { HttpStatusCode } from "axios";-import { TwoFactorType } from "../constants/twofactor";const ENDPOINT = getEndpoint();@@ -73,9 +72,12 @@ export const verifyTwoFactor = async (code: string, sessionID: string) => {return resp.data as UserVerificationResponse;};+/** The type of the second factor we're trying to act on */+export type TwoFactorType = "totp" | "passkey";+export const recoverTwoFactor = async (sessionID: string,- twoFactorType: TwoFactorType = TwoFactorType.TOTP,+ twoFactorType: TwoFactorType,) => {const resp = await HTTPService.get(`${ENDPOINT}/users/two-factor/recover`, {sessionID,@@ -87,7 +89,7 @@ export const recoverTwoFactor = async (export const removeTwoFactor = async (sessionID: string,secret: string,- twoFactorType: TwoFactorType = TwoFactorType.TOTP,+ twoFactorType: TwoFactorType,) => {const resp = await HTTPService.post(`${ENDPOINT}/users/two-factor/remove`, {sessionID,diff --git a/web/packages/accounts/constants/twofactor.ts b/web/packages/accounts/constants/twofactor.tsdeleted file mode 100644index 92b10730d4..0000000000--- a/web/packages/accounts/constants/twofactor.ts+++ /dev/null@@ -1,4 +0,0 @@-export enum TwoFactorType {- PASSKEY = "passkey",- TOTP = "totp",-}diff --git a/web/packages/accounts/pages/two-factor/recover.tsx b/web/packages/accounts/pages/two-factor/recover.tsxindex 9b66d78aa3..5008e791b1 100644--- a/web/packages/accounts/pages/two-factor/recover.tsx+++ b/web/packages/accounts/pages/two-factor/recover.tsx@@ -1,9 +1,12 @@import log from "@/next/log";import type { BaseAppContextT } from "@/next/types/app";import { ensure } from "@/utils/ensure";-import { recoverTwoFactor, removeTwoFactor } from "@ente/accounts/api/user";+import {+ recoverTwoFactor,+ removeTwoFactor,+ type TwoFactorType,+} from "@ente/accounts/api/user";import { PAGES } from "@ente/accounts/constants/pages";-import { TwoFactorType } from "@ente/accounts/constants/twofactor";import { VerticallyCentered } from "@ente/shared/components/Container";import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";import FormPaper from "@ente/shared/components/Form/FormPaper";@@ -31,13 +34,10 @@ bip39.setDefaultWordlist("english");export interface RecoverPageProps {appContext: BaseAppContextT;- twoFactorType?: TwoFactorType;+ twoFactorType: TwoFactorType;}-const Page: React.FC<RecoverPageProps> = ({- appContext,- twoFactorType = TwoFactorType.TOTP,-}) => {+const Page: React.FC<RecoverPageProps> = ({ appContext, twoFactorType }) => {const { logout } = appContext;const [encryptedTwoFactorSecret, setEncryptedTwoFactorSecret] =