π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix cyclic dep
Manav Rathi999cc91f6cf9
diff --git a/web/packages/accounts/services/srp.ts b/web/packages/accounts/services/srp.tsindex 295682a944..8618957f89 100644--- a/web/packages/accounts/services/srp.ts+++ b/web/packages/accounts/services/srp.ts@@ -13,7 +13,7 @@ import { SRP, SrpClient } from "fast-srp-hap";import { v4 as uuidv4 } from "uuid";import { z } from "zod/v4";import {- RemoteEmailOrSRPVerificationResponse,+ RemoteSRPVerificationResponse,type EmailOrSRPVerificationResponse,} from "./user";@@ -644,16 +644,7 @@ interface VerifySRPSessionRequest {srpM1: string;}-const SRPVerificationResponse = z.object({- ...RemoteEmailOrSRPVerificationResponse.shape,- /**- * The SRP M2 (evidence message), the proof that the server has the- * verifier.- */- srpM2: z.string(),-});--type SRPVerificationResponse = z.infer<typeof SRPVerificationResponse>;+type SRPVerificationResponse = z.infer<typeof RemoteSRPVerificationResponse>;const verifySRPSession = async (verifySRPSessionRequest: VerifySRPSessionRequest,@@ -667,5 +658,5 @@ const verifySRPSession = async (throw new Error(srpVerificationUnauthorizedErrorMessage);}ensureOk(res);- return SRPVerificationResponse.parse(await res.json());+ return RemoteSRPVerificationResponse.parse(await res.json());};diff --git a/web/packages/accounts/services/user.ts b/web/packages/accounts/services/user.tsindex 5a3855416b..af24bb0093 100644--- a/web/packages/accounts/services/user.ts+++ b/web/packages/accounts/services/user.ts@@ -603,7 +603,7 @@ export interface EmailOrSRPVerificationResponse {** See: [Note: Duplicated Zod schema and TypeScript type]*/-export const RemoteEmailOrSRPVerificationResponse = z.object({+const RemoteEmailOrSRPVerificationResponse = z.object({id: z.number(),keyAttributes: RemoteKeyAttributes.nullish().transform(nullToUndefined),encryptedToken: z.string().nullish().transform(nullToUndefined),@@ -614,6 +614,23 @@ export const RemoteEmailOrSRPVerificationResponse = z.object({twoFactorSessionIDV2: z.string().nullish().transform(nullToUndefined),});+/**+ * A specialization of {@link RemoteEmailOrSRPVerificationResponse} for SRP+ * verification, which results in the {@link srpM2} field in addition to the+ * other ones.+ *+ * The declaration conceptually belongs to `srp.ts`, but is here to avoid cyclic+ * dependencies.+ */+export const RemoteSRPVerificationResponse = z.object({+ ...RemoteEmailOrSRPVerificationResponse.shape,+ /**+ * The SRP M2 (evidence message), the proof that the server has the+ * verifier.+ */+ srpM2: z.string(),+});+/*** Verify user's access to the given {@link email} by comparing the OTT that* remote previously sent to that email.