π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update
Manav Rathi028a5cf82741
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex d85900880d..36788d936e 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -52,6 +52,7 @@ import type { Collection } from "ente-media/collection";import { type EnteFile } from "ente-media/file";import {removePublicCollectionAccessTokenJWT,+ removePublicCollectionByKey,savedLastPublicCollectionReferralCode,savedPublicCollectionAccessTokenJWT,savedPublicCollectionByKey,@@ -61,6 +62,7 @@ import {import {pullCollection,pullPublicCollectionFiles,+ removePublicCollectionFileData,verifyPublicAlbumPassword,} from "ente-new/albums/services/public-collection";import {@@ -75,11 +77,6 @@ import { t } from "i18next";import { useRouter } from "next/router";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { type FileWithPath } from "react-dropzone";-import {- getPublicCollectionUID,- removePublicCollectionWithFiles,- removePublicFiles,-} from "services/publicCollectionService";import { uploadManager } from "services/upload-manager";import {SelectedState,@@ -208,6 +205,10 @@ export default function PublicCollectionGallery() {{ shallow: true },);}+ /**+ * Determine credentials, read the locally cached state, then start+ * pulling the latest from remote.+ */const main = async () => {let redirectingToWebsite = false;try {@@ -300,35 +301,30 @@ export default function PublicCollectionGallery() {* both our local database and component state.*/const publicAlbumsRemotePull = useCallback(async () => {- const collectionUID = getPublicCollectionUID(- credentials.current.accessToken,- );+ const accessToken = credentials.current.accessToken;try {showLoadingBar();setLoading(true);const { collection, referralCode: userReferralCode } =- await pullCollection(- credentials.current.accessToken,- collectionKey.current,- );+ await pullCollection(accessToken, collectionKey.current);referralCode.current = userReferralCode;setPublicCollection(collection);const isPasswordProtected =- collection?.publicURLs?.[0]?.passwordEnabled;+ !!collection.publicURLs[0]?.passwordEnabled;setIsPasswordProtected(isPasswordProtected);setErrorMessage(null);- // Remove the locally saved outdated password token if the sharer- // has disabled password protection on the link.+ // Remove the locally cached accessTokenJWT if the sharer has+ // disabled password protection on the link.if (!isPasswordProtected && credentials.current.accessTokenJWT) {credentials.current.accessTokenJWT = undefined;downloadManager.setPublicAlbumsCredentials(credentials.current);- removePublicCollectionAccessTokenJWT(collectionUID);+ removePublicCollectionAccessTokenJWT(accessToken);}if (isPasswordProtected && !credentials.current.accessTokenJWT) {- await removePublicFiles(collectionUID);+ await removePublicCollectionFileData(accessToken);} else {try {await pullPublicCollectionFiles(@@ -371,12 +367,9 @@ export default function PublicCollectionGallery() {? t("link_request_limit_exceeded"): t("link_expired_message"),);- // share has been disabled- // local cache should be cleared- removePublicCollectionWithFiles(- collectionUID,- collectionKey.current,- );+ // Sharing has been disabled. Clear out local cache.+ await removePublicCollectionFileData(accessToken);+ await removePublicCollectionByKey(collectionKey.current);setPublicCollection(undefined);setPublicFiles(undefined);} else {@@ -399,18 +392,16 @@ export default function PublicCollectionGallery() {setFieldError,) => {try {+ const accessToken = credentials.current.accessToken;const accessTokenJWT = await verifyPublicAlbumPassword(publicCollection.publicURLs[0]!,password,- credentials.current.accessToken,+ accessToken,);credentials.current.accessTokenJWT = accessTokenJWT;downloadManager.setPublicAlbumsCredentials(credentials.current);- const collectionUID = getPublicCollectionUID(- credentials.current.accessToken,- );await savePublicCollectionAccessTokenJWT(- collectionUID,+ accessToken,accessTokenJWT,);} catch (e) {diff --git a/web/apps/photos/src/services/publicCollectionService.ts b/web/apps/photos/src/services/publicCollectionService.tsdeleted file mode 100644index 6ee913d032..0000000000--- a/web/apps/photos/src/services/publicCollectionService.ts+++ /dev/null@@ -1,24 +0,0 @@-import {- removePublicCollectionAccessTokenJWT,- removePublicCollectionByKey,- removePublicCollectionFiles,- removePublicCollectionLastSyncTime,-} from "ente-new/albums/services/public-albums-fdb";--// Fix this once we can trust the types.-// eslint-disable-next-line @typescript-eslint/no-unnecessary-template-expression-export const getPublicCollectionUID = (token: string) => `${token}`;--export const removePublicCollectionWithFiles = async (- collectionUID: string,- collectionKey: string,-) => {- await removePublicCollectionByKey(collectionKey);- await removePublicFiles(collectionUID);-};--export const removePublicFiles = async (collectionUID: string) => {- await removePublicCollectionAccessTokenJWT(collectionUID);- await removePublicCollectionLastSyncTime(collectionUID);- await removePublicCollectionFiles(collectionUID);-};diff --git a/web/packages/new/albums/services/public-collection.ts b/web/packages/new/albums/services/public-collection.tsindex f6cf9ccfc2..5000f364b0 100644--- a/web/packages/new/albums/services/public-collection.ts+++ b/web/packages/new/albums/services/public-collection.ts@@ -18,6 +18,9 @@ import {} from "ente-media/file";import { z } from "zod/v4";import {+ removePublicCollectionAccessTokenJWT,+ removePublicCollectionFiles,+ removePublicCollectionLastSyncTime,savedPublicCollectionFiles,savedPublicCollectionLastSyncTime,saveLastPublicCollectionReferralCode,@@ -233,3 +236,17 @@ const getPublicCollectionDiff = async (ensureOk(res);return FileDiffResponse.parse(await res.json());};++/**+ * Remove the files, sync time and accessTokenJWT associated with the given+ * collection (identified by its {@link accessToken}).+ *+ * This function modifies local state.+ */+export const removePublicCollectionFileData = async (accessToken: string) => {+ await Promise.all([+ removePublicCollectionAccessTokenJWT(accessToken),+ removePublicCollectionLastSyncTime(accessToken),+ removePublicCollectionFiles(accessToken),+ ]);+};