π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Unnest
Manav Rathi4b616dcbe1c7
diff --git a/web/packages/accounts/components/PasswordStrength.tsx b/web/packages/accounts/components/PasswordStrength.tsxindex bbb6dcf347..d6cb14623a 100644--- a/web/packages/accounts/components/PasswordStrength.tsx+++ b/web/packages/accounts/components/PasswordStrength.tsx@@ -28,6 +28,7 @@ export const PasswordStrengthHint: React.FC<PasswordStrengthHintProps> = ({variant="small"sx={{mt: "8px",+ mx: "2px",alignSelf: "flex-start",whiteSpace: "pre",color: "var(--et-color)",diff --git a/web/packages/accounts/components/SignUpContents.tsx b/web/packages/accounts/components/SignUpContents.tsxindex 9390de0204..2b7e1c0912 100644--- a/web/packages/accounts/components/SignUpContents.tsx+++ b/web/packages/accounts/components/SignUpContents.tsx@@ -22,11 +22,13 @@ import {generateAndSaveInteractiveKeyAttributes,generateKeysAndAttributes,sendOTT,+ type GenerateKeysAndAttributesResult,} from "ente-accounts/services/user";import { isWeakPassword } from "ente-accounts/utils/password";import { LinkButton } from "ente-base/components/LinkButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { ShowHidePasswordInputAdornment } from "ente-base/components/mui/PasswordInputAdornment";+import { deriveKeyInsufficientMemoryErrorMessage } from "ente-base/crypto/types";import { isMuseumHTTPError } from "ente-base/http";import log from "ente-base/log";import { saveMasterKeyInSessionAndSafeStore } from "ente-base/session";@@ -89,17 +91,17 @@ export const SignUpContents: React.FC<SignUpContentsProps> = ({{ email, password, confirmPassword, referral },{ setFieldError },) => {+ if (password != confirmPassword) {+ setFieldError("confirm", t("password_mismatch_error"));+ return;+ }+try {- if (password != confirmPassword) {- setFieldError("confirm", t("password_mismatch_error"));- return;- }+ setLocalReferralSource(referral);+try {- setLocalReferralSource(referral);await sendOTT(email, "signup");- await setLSUser({ email });} catch (e) {- log.error("Signup failed", e);if (await isMuseumHTTPError(e,@@ -108,36 +110,50 @@ export const SignUpContents: React.FC<SignUpContentsProps> = ({)) {setFieldError("email", t("email_already_registered"));- } else {- setFieldError("email", t("generic_error"));+ return;}throw e;}- try {- const { masterKey, kek, keyAttributes } =- await generateKeysAndAttributes(password);-- const srpSetupAttributes = await generateSRPSetupAttributes(- await deriveSRPPassword(kek),- );- setData("originalKeyAttributes", keyAttributes);- setData("srpSetupAttributes", srpSetupAttributes);- await generateAndSaveInteractiveKeyAttributes(- password,- keyAttributes,- masterKey,- );+ await setLSUser({ email });- await saveMasterKeyInSessionAndSafeStore(masterKey);- setJustSignedUp(true);- void router.push("/verify");+ let gkResult: GenerateKeysAndAttributesResult;+ try {+ gkResult = await generateKeysAndAttributes(password);} catch (e) {- setFieldError("confirm", t("password_generation_failed"));+ if (+ e instanceof Error &&+ e.message == deriveKeyInsufficientMemoryErrorMessage+ ) {+ setFieldError(+ "confirmPassword",+ t("password_generation_failed"),+ );+ return;+ }throw e;}++ const { masterKey, kek, keyAttributes } = gkResult;++ const srpSetupAttributes = await generateSRPSetupAttributes(+ await deriveSRPPassword(kek),+ );++ setData("originalKeyAttributes", keyAttributes);+ setData("srpSetupAttributes", srpSetupAttributes);+ await generateAndSaveInteractiveKeyAttributes(+ password,+ keyAttributes,+ masterKey,+ );++ await saveMasterKeyInSessionAndSafeStore(masterKey);+ setJustSignedUp(true);+ void router.push("/verify");} catch (e) {- log.error("signup failed", e);+ log.error("Signup failed", e);+ setFieldError("confirmPassword", t("generic_error"));}},});diff --git a/web/packages/accounts/services/user.ts b/web/packages/accounts/services/user.tsindex e529c95f2b..ad75316b0d 100644--- a/web/packages/accounts/services/user.ts+++ b/web/packages/accounts/services/user.ts@@ -356,6 +356,12 @@ export const ensureSavedKeyAttributes = (): KeyAttributes =>export const saveKeyAttributes = (keyAttributes: KeyAttributes) =>localStorage.setItem("keyAttributes", JSON.stringify(keyAttributes));+export interface GenerateKeysAndAttributesResult {+ masterKey: string;+ kek: string;+ keyAttributes: KeyAttributes;+}+/*** Generate a new set of key attributes.*@@ -366,7 +372,7 @@ export const saveKeyAttributes = (keyAttributes: KeyAttributes) =>*/export async function generateKeysAndAttributes(password: string,-): Promise<{ masterKey: string; kek: string; keyAttributes: KeyAttributes }> {+): Promise<GenerateKeysAndAttributesResult> {const masterKey = await generateKey();const recoveryKey = await generateKey();const {