Skip to content

armgit / ente

Public Imported from GitHub
0

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

Del

Manav Rathi21febab897a6
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 05fcf39bd3..f5f5811ceb 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -32,7 +32,7 @@ import log from "ente-base/log";
import {
clearSessionStorage,
haveCredentialsInSession,
- masterKeyBytesFromSessionIfLoggedIn,
+ masterKeyB64FromSessionIfLoggedIn,
} from "ente-base/session";
import { FullScreenDropZone } from "ente-gallery/components/FullScreenDropZone";
import { type UploadTypeSelectorIntent } from "ente-gallery/components/Upload";
@@ -561,7 +561,7 @@ const Page: React.FC = () => {
showSessionExpiredDialog();
return;
}
- if (!(await masterKeyBytesFromSessionIfLoggedIn())) {
+ if (!(await masterKeyB64FromSessionIfLoggedIn())) {
clearSessionStorage();
router.push("/credentials");
return;
diff --git a/web/packages/base/session.ts b/web/packages/base/session.ts
index edb6c78137..6b6892f066 100644
--- a/web/packages/base/session.ts
+++ b/web/packages/base/session.ts
@@ -43,27 +43,11 @@ const SessionKeyData = z.object({
// };
/**
- * Return the user's decrypted master key bytes from session storage.
+ * Return the user's decrypted master key (as a base64 string) from session
+ * storage.
*
* Precondition: The user should be logged in.
*/
-export const masterKeyFromSession = async () => {
- const key = await masterKeyBytesFromSessionIfLoggedIn();
- if (key) {
- return key;
- } else {
- throw new Error(
- "The user's master key was not found in session storage. Likely they are not logged in.",
- );
- }
-};
-
-/**
- * Variant of {@link masterKeyFromSession} that returns the master key as a
- * base64 string.
- *
- * TODO(RE): Undup
- */
export const masterKeyB64FromSession = async () => {
const key = await masterKeyB64FromSessionIfLoggedIn();
if (key) {
@@ -86,26 +70,9 @@ export const masterKeyB64FromSession = async () => {
export const haveCredentialsInSession = () =>
!!sessionStorage.getItem("encryptionKey");
-/**
- * Return the decrypted user's master key (as bytes) from session storage if
- * they are logged in, otherwise return `undefined`.
- */
-export const masterKeyBytesFromSessionIfLoggedIn = async () => {
- // TODO: Same value as the deprecated getKey("encryptionKey")
- const value = sessionStorage.getItem("encryptionKey");
- if (!value) return undefined;
-
- const { encryptedData, key, nonce } = SessionKeyData.parse(
- JSON.parse(value),
- );
- return decryptBoxBytes({ encryptedData, nonce }, key);
-};
-
/**
* Return the decrypted user's master key (as a base64 string) from session
* storage if they are logged in, otherwise return `undefined`.
- *
- * TODO(RE): Undup.
*/
export const masterKeyB64FromSessionIfLoggedIn = async () => {
// TODO: Same value as the deprecated getKey("encryptionKey")