Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove dep

Manav Rathi06656c1d883e
diff --git a/web/docs/storage.md b/web/docs/storage.md
index c5077bcd5a..761e4a2079 100644
--- a/web/docs/storage.md
+++ b/web/docs/storage.md
@@ -17,10 +17,12 @@ The data in local storage is tied to the Document's origin (scheme + host).
Some things that get stored here are:
-- Details about the logged in user, in particular their user id and a auth token
- we can use to make API calls on their behalf.
+- Details about the logged in user (See: [Note: Accounts DB]).
-- Various user preferences
+- Some user preferences (export settings, collection sort order).
+
+> Local storage is not accessible to web workers, so if any non main-thread
+> context needs access to the data, it should be stored in IndexedDB.
## IndexedDB
@@ -43,6 +45,13 @@ For more details, see:
- https://github.com/jakearchibald/idb
- https://github.com/localForage/localForage
+Some things that get stored here are:
+
+- The collection and file data (See: [Files DB]). Note that the file contents
+ themselves are not stored, only the "EnteFile" object that describes a file.
+
+- Various key value pairs (See: [Note: KV DB]).
+
## OPFS
OPFS is used for caching entire files when we're running under Electron (the Web
diff --git a/web/packages/accounts/pages/signup.tsx b/web/packages/accounts/pages/signup.tsx
index aa8604464c..20aaeb55ed 100644
--- a/web/packages/accounts/pages/signup.tsx
+++ b/web/packages/accounts/pages/signup.tsx
@@ -1,8 +1,8 @@
import { AccountsPageContents } from "ente-accounts/components/layouts/centered-paper";
import { SignUpContents } from "ente-accounts/components/SignUpContents";
+import { getData } from "ente-accounts/services/accounts-db";
import { LoadingIndicator } from "ente-base/components/loaders";
import { customAPIHost } from "ente-base/origins";
-import { getData } from "ente-shared//storage/localStorage";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
diff --git a/web/packages/base/kv.ts b/web/packages/base/kv.ts
index df90aca537..3a05e6ffb1 100644
--- a/web/packages/base/kv.ts
+++ b/web/packages/base/kv.ts
@@ -4,6 +4,8 @@ import log from "./log";
/**
* Key value store schema.
*
+ * [Note: KV DB]
+ *
* The use IndexedDB to store arbitrary key-value pairs. The functional
* motivation is to allow these to also be accessed from web workers (local
* storage is limited to the main thread).
diff --git a/web/packages/base/session.ts b/web/packages/base/session.ts
index 1569c1e9f0..0adc3003ed 100644
--- a/web/packages/base/session.ts
+++ b/web/packages/base/session.ts
@@ -1,7 +1,5 @@
-import { getToken } from "ente-accounts/services/accounts-db";
import { z } from "zod/v4";
import { decryptBox, encryptBox, generateKey } from "./crypto";
-import { isDevBuild } from "./env";
import log from "./log";
import { getAuthToken } from "./token";
@@ -157,22 +155,11 @@ export const updateSessionFromElectronSafeStorageIfNeeded = async () => {
};
/**
- * Return true if we both have the user's master key in session storage, and
- * their auth token in KV DB.
+ * Return true if we both have a usable user's master key in session storage,
+ * and their auth token in KV DB.
*/
-export const haveAuthenticatedSession = async () => {
- if (!(await masterKeyFromSession())) return false;
- const lsToken = getToken();
- const kvToken = await getAuthToken();
- // TODO: To avoid changing old behaviour, this currently relies on the token
- // from local storage. Both should be the same though, so it throws an error
- // on dev build (tag: Migration).
- if (isDevBuild) {
- if (lsToken != kvToken)
- throw new Error("Local storage and indexed DB mismatch");
- }
- return !!lsToken;
-};
+export const haveAuthenticatedSession = async () =>
+ (await masterKeyFromSession()) && !!(await getAuthToken());
/**
* Save the user's encypted key encryption key ("key") in session store