π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move
Manav Rathid7b6c771e87c
diff --git a/web/packages/accounts/pages/verify.tsx b/web/packages/accounts/pages/verify.tsxindex b59ff22c50..66933f36db 100644--- a/web/packages/accounts/pages/verify.tsx+++ b/web/packages/accounts/pages/verify.tsx@@ -196,7 +196,7 @@ const Page: React.FC = () => {return (<VerifyingPasskeyemail={email}- passkeySessionID={passkeyVerificationData?.passkeySessionID}+ passkeySessionID={passkeyVerificationData.passkeySessionID}onRetry={() =>openPasskeyVerificationURL(passkeyVerificationData)}diff --git a/web/packages/accounts/services/accounts-db.ts b/web/packages/accounts/services/accounts-db.tsindex f9731952bf..f02f4e2678 100644--- a/web/packages/accounts/services/accounts-db.ts+++ b/web/packages/accounts/services/accounts-db.ts@@ -1,5 +1,6 @@import { getKVS, removeKV, setKV } from "ente-base/kv";import log from "ente-base/log";+import { RemoteKeyAttributes, type KeyAttributes } from "./user";export type LocalStorageKey =| "user"@@ -126,6 +127,27 @@ export const isLocalStorageAndIndexedDBMismatch = async () => {);};+/**+ * Return the user's {@link KeyAttributes} if they are present in local storage.+ *+ * The key attributes are stored in the browser's localStorage. Thus, this+ * function only works from the main thread, not from web workers (local storage+ * is not accessible to web workers).+ */+export const savedKeyAttributes = (): KeyAttributes | undefined => {+ const jsonString = localStorage.getItem("keyAttributes");+ if (!jsonString) return undefined;+ return RemoteKeyAttributes.parse(JSON.parse(jsonString));+};++/**+ * Save the user's {@link KeyAttributes} in local storage.+ *+ * Use {@link savedKeyAttributes} to retrieve them.+ */+export const saveKeyAttributes = (keyAttributes: KeyAttributes) =>+ localStorage.setItem("keyAttributes", JSON.stringify(keyAttributes));+export const getToken = (): string => {const token = getData("user")?.token;return token;diff --git a/web/packages/accounts/services/recovery-key.ts b/web/packages/accounts/services/recovery-key.tsindex daf11e1507..3d2a8be28b 100644--- a/web/packages/accounts/services/recovery-key.ts+++ b/web/packages/accounts/services/recovery-key.ts@@ -8,7 +8,8 @@ import {toHex,} from "ente-base/crypto";import { ensureMasterKeyFromSession } from "ente-base/session";-import { putUserRecoveryKeyAttributes, saveKeyAttributes } from "./user";+import { saveKeyAttributes } from "./accounts-db";+import { putUserRecoveryKeyAttributes } from "./user";// Mobile client library only supports English.bip39.setDefaultWordlist("english");diff --git a/web/packages/accounts/services/user.ts b/web/packages/accounts/services/user.tsindex e8da5559ee..c34a178d07 100644--- a/web/packages/accounts/services/user.ts+++ b/web/packages/accounts/services/user.ts@@ -1,4 +1,9 @@-import { getData, setLSUser } from "ente-accounts/services/accounts-db";+import {+ getData,+ savedKeyAttributes,+ saveKeyAttributes,+ setLSUser,+} from "ente-accounts/services/accounts-db";import {generateSRPSetupAttributes,getSRPAttributes,@@ -350,19 +355,6 @@ export const RemoteKeyAttributes = z.object({recoveryKeyDecryptionNonce: z.string().nullish().transform(nullToUndefined),});-/**- * Return the user's {@link KeyAttributes} if they are present in local storage.- *- * The key attributes are stored in the browser's localStorage. Thus, this- * function only works from the main thread, not from web workers (local storage- * is not accessible to web workers).- */-export const savedKeyAttributes = (): KeyAttributes | undefined => {- const jsonString = localStorage.getItem("keyAttributes");- if (!jsonString) return undefined;- return RemoteKeyAttributes.parse(JSON.parse(jsonString));-};-/*** A variant of {@link savedKeyAttributes} that throws if keyAttributes are not* present in local storage.@@ -370,14 +362,6 @@ export const savedKeyAttributes = (): KeyAttributes | undefined => {export const ensureSavedKeyAttributes = (): KeyAttributes =>ensureExpectedLoggedInValue(savedKeyAttributes());-/**- * Save the user's {@link KeyAttributes} in local storage.- *- * Use {@link savedKeyAttributes} to retrieve them.- */-export const saveKeyAttributes = (keyAttributes: KeyAttributes) =>- localStorage.setItem("keyAttributes", JSON.stringify(keyAttributes));-export interface GenerateKeysAndAttributesResult {masterKey: string;kek: string;