Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Move

Manav Rathif8093a65a694
diff --git a/web/packages/accounts/pages/change-password.tsx b/web/packages/accounts/pages/change-password.tsx
index d7219860b9..b09b5a5e23 100644
--- a/web/packages/accounts/pages/change-password.tsx
+++ b/web/packages/accounts/pages/change-password.tsx
@@ -16,12 +16,12 @@ import {
getSRPAttributes,
startSRPSetup,
updateSRPAndKeys,
+ type UpdatedKeyAttr,
} from "ente-accounts/services/srp";
import {
ensureSavedKeyAttributes,
localUser,
type LocalUser,
- type UpdatedKey,
} from "ente-accounts/services/user";
import { generateAndSaveIntermediateKeyAttributes } from "ente-accounts/utils/helpers";
import { LinkButton } from "ente-base/components/LinkButton";
@@ -38,7 +38,7 @@ import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
/**
- * A page that allows a logged-in user to change their password.
+ * A page that allows a user to reset or change their password.
*/
const Page: React.FC = () => {
const [user, setUser] = useState<LocalUser>();
@@ -85,7 +85,7 @@ const PageContents: React.FC<PageContentsProps> = ({ user }) => {
}
const { encryptedData: encryptedKey, nonce: keyDecryptionNonce } =
await cryptoWorker.encryptBox(masterKey, kek.key);
- const updatedKey: UpdatedKey = {
+ const updatedKeyAttr: UpdatedKeyAttr = {
encryptedKey,
keyDecryptionNonce,
kekSalt: kek.salt,
@@ -117,11 +117,7 @@ const PageContents: React.FC<PageContentsProps> = ({ user }) => {
const srpM1 = convertBufferToBase64(srpClient.computeM1());
- await updateSRPAndKeys(token, {
- setupID,
- srpM1,
- updatedKeyAttr: updatedKey,
- });
+ await updateSRPAndKeys(token, { setupID, srpM1, updatedKeyAttr });
// Update the SRP attributes that are stored locally.
const srpAttributes = await getSRPAttributes(user.email);
@@ -129,10 +125,9 @@ const PageContents: React.FC<PageContentsProps> = ({ user }) => {
setData("srpAttributes", srpAttributes);
}
- const updatedKeyAttributes = Object.assign(keyAttributes, updatedKey);
await generateAndSaveIntermediateKeyAttributes(
passphrase,
- updatedKeyAttributes,
+ { ...keyAttributes, ...updatedKeyAttr },
masterKey,
);
diff --git a/web/packages/accounts/services/srp.ts b/web/packages/accounts/services/srp.ts
index 9fcaee31f9..7c1eea4f81 100644
--- a/web/packages/accounts/services/srp.ts
+++ b/web/packages/accounts/services/srp.ts
@@ -9,7 +9,7 @@ import HTTPService from "ente-shared/network/HTTPService";
import { getToken } from "ente-shared/storage/localStorage/helpers";
import { SRP, SrpClient } from "fast-srp-hap";
import { v4 as uuidv4 } from "uuid";
-import type { UpdatedKey, UserVerificationResponse } from "./user";
+import type { UserVerificationResponse } from "./user";
/**
* Derive a "password" (which is really an arbitrary binary value, not human
@@ -54,7 +54,7 @@ interface SetupSRPRequest {
srpA: string;
}
- interface SetupSRPResponse {
+interface SetupSRPResponse {
setupID: string;
srpB: string;
}
@@ -78,10 +78,18 @@ export interface SRPVerificationResponse extends UserVerificationResponse {
srpM2: string;
}
+export interface UpdatedKeyAttr {
+ kekSalt: string;
+ encryptedKey: string;
+ keyDecryptionNonce: string;
+ memLimit: number;
+ opsLimit: number;
+}
+
export interface UpdateSRPAndKeysRequest {
srpM1: string;
setupID: string;
- updatedKeyAttr: UpdatedKey;
+ updatedKeyAttr: UpdatedKeyAttr;
/**
* If true (default), then all existing sessions for the user will be
* invalidated.
diff --git a/web/packages/accounts/services/user.ts b/web/packages/accounts/services/user.ts
index ff68030618..fce307ea32 100644
--- a/web/packages/accounts/services/user.ts
+++ b/web/packages/accounts/services/user.ts
@@ -486,14 +486,6 @@ export const remoteLogoutIfNeeded = async () => {
ensureOk(res);
};
-export interface UpdatedKey {
- kekSalt: string;
- encryptedKey: string;
- keyDecryptionNonce: string;
- memLimit: number;
- opsLimit: number;
-}
-
/**
* Change the email associated with the user's account on remote.
*