π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move
Manav Rathi2f6f1a4c6bfb
diff --git a/web/packages/accounts/api/srp.ts b/web/packages/accounts/api/srp.tsindex 7259e8c5ac..40be7b00e3 100644--- a/web/packages/accounts/api/srp.ts+++ b/web/packages/accounts/api/srp.ts@@ -3,18 +3,74 @@ import { apiURL } from "@/base/origins";import { ApiError, CustomError } from "@ente/shared/error";import HTTPService from "@ente/shared/network/HTTPService";import { HttpStatusCode } from "axios";-import type {- CompleteSRPSetupRequest,- CompleteSRPSetupResponse,- CreateSRPSessionResponse,- GetSRPAttributesResponse,- SRPAttributes,- SRPVerificationResponse,- SetupSRPRequest,- SetupSRPResponse,- UpdateSRPAndKeysRequest,- UpdateSRPAndKeysResponse,-} from "../types/srp";+import type { UpdatedKey, UserVerificationResponse } from "../types/user";++export interface SRPAttributes {+ srpUserID: string;+ srpSalt: string;+ memLimit: number;+ opsLimit: number;+ kekSalt: string;+ isEmailMFAEnabled: boolean;+}++export interface GetSRPAttributesResponse {+ attributes: SRPAttributes;+}++export interface SRPSetupAttributes {+ srpSalt: string;+ srpVerifier: string;+ srpUserID: string;+ loginSubKey: string;+}++export interface SetupSRPRequest {+ srpUserID: string;+ srpSalt: string;+ srpVerifier: string;+ srpA: string;+}++export interface SetupSRPResponse {+ setupID: string;+ srpB: string;+}++export interface CompleteSRPSetupRequest {+ setupID: string;+ srpM1: string;+}++export interface CompleteSRPSetupResponse {+ setupID: string;+ srpM2: string;+}++export interface CreateSRPSessionResponse {+ sessionID: string;+ srpB: string;+}++export interface SRPVerificationResponse extends UserVerificationResponse {+ srpM2: string;+}++export interface UpdateSRPAndKeysRequest {+ srpM1: string;+ setupID: string;+ updatedKeyAttr: UpdatedKey;+ /**+ * If true (default), then all existing sessions for the user will be+ * invalidated.+ */+ logOutOtherDevices?: boolean;+}++export interface UpdateSRPAndKeysResponse {+ srpM2: string;+ setupID: string;+}export const getSRPAttributes = async (email: string,diff --git a/web/packages/accounts/pages/credentials.tsx b/web/packages/accounts/pages/credentials.tsxindex 5287a7fbcf..a8e827ea4e 100644--- a/web/packages/accounts/pages/credentials.tsx+++ b/web/packages/accounts/pages/credentials.tsx@@ -39,6 +39,7 @@ import { Stack } from "@mui/material";import { t } from "i18next";import { useRouter } from "next/router";import { useCallback, useEffect, useState } from "react";+import type { SRPAttributes } from "../api/srp";import { getSRPAttributes } from "../api/srp";import {LoginFlowFormFooter,@@ -63,7 +64,6 @@ import {loginViaSRP,} from "../services/srp";import type { PageProps } from "../types/page";-import type { SRPAttributes } from "../types/srp";const Page: React.FC<PageProps> = ({ appContext }) => {const { logout, showNavBar, showMiniDialog } = appContext;diff --git a/web/packages/accounts/pages/verify.tsx b/web/packages/accounts/pages/verify.tsxindex f11e77f2f8..806b99125e 100644--- a/web/packages/accounts/pages/verify.tsx+++ b/web/packages/accounts/pages/verify.tsx@@ -29,6 +29,7 @@ import { t } from "i18next";import { useRouter } from "next/router";import { useEffect, useState } from "react";import { Trans } from "react-i18next";+import type { SRPAttributes, SRPSetupAttributes } from "../api/srp";import { getSRPAttributes } from "../api/srp";import { putAttributes, sendOtt, verifyOtt } from "../api/user";import {@@ -43,7 +44,6 @@ import {import { stashedRedirect, unstashRedirect } from "../services/redirect";import { configureSRP } from "../services/srp";import type { PageProps } from "../types/page";-import type { SRPAttributes, SRPSetupAttributes } from "../types/srp";const Page: React.FC<PageProps> = ({ appContext }) => {const { logout, showNavBar, showMiniDialog } = appContext;diff --git a/web/packages/accounts/services/session.ts b/web/packages/accounts/services/session.tsindex f8d63eeeb5..77389e6d02 100644--- a/web/packages/accounts/services/session.ts+++ b/web/packages/accounts/services/session.ts@@ -4,8 +4,8 @@ import { apiURL } from "@/base/origins";import { ensure } from "@/utils/ensure";import { getData, LS_KEYS } from "@ente/shared/storage/localStorage";import type { KeyAttributes } from "@ente/shared/user/types";+import type { SRPAttributes } from "../api/srp";import { getSRPAttributes } from "../api/srp";-import type { SRPAttributes } from "../types/srp";type SessionValidity =| { status: "invalid" }diff --git a/web/packages/accounts/services/srp.ts b/web/packages/accounts/services/srp.tsindex a1f8819753..9840332b38 100644--- a/web/packages/accounts/services/srp.ts+++ b/web/packages/accounts/services/srp.ts@@ -5,13 +5,13 @@ import { generateLoginSubKey } from "@ente/shared/crypto/helpers";import { getToken } from "@ente/shared/storage/localStorage/helpers";import { SRP, SrpClient } from "fast-srp-hap";import { v4 as uuidv4 } from "uuid";+import type { SRPAttributes, SRPSetupAttributes } from "../api/srp";import {completeSRPSetup,createSRPSession,startSRPSetup,verifySRPSession,} from "../api/srp";-import type { SRPAttributes, SRPSetupAttributes } from "../types/srp";import { convertBase64ToBuffer, convertBufferToBase64 } from "../utils";const SRP_PARAMS = SRP.params["4096"];diff --git a/web/packages/accounts/types/srp.ts b/web/packages/accounts/types/srp.tsdeleted file mode 100644index 6206e47300..0000000000--- a/web/packages/accounts/types/srp.ts+++ /dev/null@@ -1,68 +0,0 @@-import type { UpdatedKey, UserVerificationResponse } from "./user";--export interface SRPAttributes {- srpUserID: string;- srpSalt: string;- memLimit: number;- opsLimit: number;- kekSalt: string;- isEmailMFAEnabled: boolean;-}--export interface GetSRPAttributesResponse {- attributes: SRPAttributes;-}--export interface SRPSetupAttributes {- srpSalt: string;- srpVerifier: string;- srpUserID: string;- loginSubKey: string;-}--export interface SetupSRPRequest {- srpUserID: string;- srpSalt: string;- srpVerifier: string;- srpA: string;-}--export interface SetupSRPResponse {- setupID: string;- srpB: string;-}--export interface CompleteSRPSetupRequest {- setupID: string;- srpM1: string;-}--export interface CompleteSRPSetupResponse {- setupID: string;- srpM2: string;-}--export interface CreateSRPSessionResponse {- sessionID: string;- srpB: string;-}--export interface SRPVerificationResponse extends UserVerificationResponse {- srpM2: string;-}--export interface UpdateSRPAndKeysRequest {- srpM1: string;- setupID: string;- updatedKeyAttr: UpdatedKey;- /**- * If true (default), then all existing sessions for the user will be- * invalidated.- */- logOutOtherDevices?: boolean;-}--export interface UpdateSRPAndKeysResponse {- srpM2: string;- setupID: string;-}diff --git a/web/packages/accounts/utils/srp.ts b/web/packages/accounts/utils/srp.tsindex 3f9a9d6efc..25f8430886 100644--- a/web/packages/accounts/utils/srp.ts+++ b/web/packages/accounts/utils/srp.ts@@ -1,8 +1,8 @@import { sharedCryptoWorker } from "@/base/crypto";import { generateLoginSubKey } from "@ente/shared/crypto/helpers";import type { KeyAttributes } from "@ente/shared/user/types";+import type { SRPSetupAttributes } from "../api/srp";import { generateSRPSetupAttributes } from "../services/srp";-import type { SRPSetupAttributes } from "../types/srp";export async function generateKeyAndSRPAttributes(passphrase: string): Promise<{keyAttributes: KeyAttributes;diff --git a/web/packages/shared/components/VerifyMasterPasswordForm.tsx b/web/packages/shared/components/VerifyMasterPasswordForm.tsxindex 557847d45f..6a07025393 100644--- a/web/packages/shared/components/VerifyMasterPasswordForm.tsx+++ b/web/packages/shared/components/VerifyMasterPasswordForm.tsx@@ -1,4 +1,4 @@-import type { SRPAttributes } from "@/accounts/types/srp";+import type { SRPAttributes } from "@/accounts/api/srp";import { sharedCryptoWorker } from "@/base/crypto";import log from "@/base/log";import { Input, type ButtonProps } from "@mui/material";