π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update
Manav Rathi738088e8a5d7
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 7d73991222..34d82c9f34 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -51,9 +51,12 @@ import { sortFiles } from "ente-gallery/utils/file";import type { Collection } from "ente-media/collection";import { type EnteFile } from "ente-media/file";import {+ removePublicCollectionAccessTokenJWT,savedLastPublicCollectionReferralCode,+ savedPublicCollectionAccessTokenJWT,savedPublicCollectionByKey,savedPublicCollectionFiles,+ savePublicCollectionAccessTokenJWT,} from "ente-new/albums/services/public-albums-fdb";import { verifyPublicAlbumPassword } from "ente-new/albums/services/public-collection";import {@@ -69,12 +72,10 @@ import { useRouter } from "next/router";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { type FileWithPath } from "react-dropzone";import {- getLocalPublicCollectionPassword,getPublicCollection,getPublicCollectionUID,removePublicCollectionWithFiles,removePublicFiles,- savePublicCollectionPassword,syncPublicFiles,} from "services/publicCollectionService";import { uploadManager } from "services/upload-manager";@@ -230,13 +231,12 @@ export default function PublicCollectionGallery() {const isPasswordProtected =localCollection?.publicURLs?.[0]?.passwordEnabled;setIsPasswordProtected(isPasswordProtected);- const collectionUID = getPublicCollectionUID(accessToken);const localFiles =await savedPublicCollectionFiles(accessToken);const localPublicFiles = sortFiles(localFiles, sortAsc);setPublicFiles(localPublicFiles);accessTokenJWT =- await getLocalPublicCollectionPassword(collectionUID);+ await savedPublicCollectionAccessTokenJWT(accessToken);}credentials.current = { accessToken, accessTokenJWT };downloadManager.setPublicAlbumsCredentials(credentials.current);@@ -316,7 +316,7 @@ export default function PublicCollectionGallery() {if (!isPasswordProtected && credentials.current.accessTokenJWT) {credentials.current.accessTokenJWT = undefined;downloadManager.setPublicAlbumsCredentials(credentials.current);- savePublicCollectionPassword(collectionUID, null);+ removePublicCollectionAccessTokenJWT(collectionUID);}if (@@ -395,7 +395,10 @@ export default function PublicCollectionGallery() {const collectionUID = getPublicCollectionUID(credentials.current.accessToken,);- await savePublicCollectionPassword(collectionUID, accessTokenJWT);+ await savePublicCollectionAccessTokenJWT(+ collectionUID,+ accessTokenJWT,+ );} catch (e) {log.error("Failed to verifyLinkPassword", e);if (isHTTP401Error(e)) {diff --git a/web/apps/photos/src/services/publicCollectionService.ts b/web/apps/photos/src/services/publicCollectionService.tsindex c9b8765c97..e51653efd0 100644--- a/web/apps/photos/src/services/publicCollectionService.ts+++ b/web/apps/photos/src/services/publicCollectionService.ts@@ -9,6 +9,7 @@ import type {import type { EnteFile, RemoteEnteFile } from "ente-media/file";import { decryptRemoteFile } from "ente-media/file";import {+ removePublicCollectionAccessTokenJWT,removePublicCollectionByKey,removePublicCollectionFiles,removePublicCollectionLastSyncTime,@@ -21,40 +22,16 @@ import {} from "ente-new/albums/services/public-albums-fdb";import { CustomError, parseSharingErrorCodes } from "ente-shared/error";import HTTPService from "ente-shared/network/HTTPService";-import localForage from "ente-shared/storage/localForage";// Fix this once we can trust the types.// eslint-disable-next-line @typescript-eslint/no-unnecessary-template-expressionexport const getPublicCollectionUID = (token: string) => `${token}`;-const getPublicCollectionPasswordKey = (collectionUID: string) =>- `public-${collectionUID}-passkey`;-export interface LocalSavedPublicCollectionFiles {collectionUID: string;files: EnteFile[];}-export const getLocalPublicCollectionPassword = async (- collectionUID: string,-): Promise<string> => {- return (- (await localForage.getItem<string>(- getPublicCollectionPasswordKey(collectionUID),- )) || ""- );-};--export const savePublicCollectionPassword = async (- collectionUID: string,- passToken: string,-): Promise<string> => {- return await localForage.setItem<string>(- getPublicCollectionPasswordKey(collectionUID),- passToken,- );-};-export const syncPublicFiles = async (token: string,passwordToken: string,@@ -266,7 +243,7 @@ export const removePublicCollectionWithFiles = async (};export const removePublicFiles = async (collectionUID: string) => {- await localForage.removeItem(getPublicCollectionPasswordKey(collectionUID));+ await removePublicCollectionAccessTokenJWT(collectionUID);await removePublicCollectionLastSyncTime(collectionUID);await removePublicCollectionFiles(collectionUID);};diff --git a/web/packages/new/albums/services/public-albums-fdb.ts b/web/packages/new/albums/services/public-albums-fdb.tsindex 4464f76be4..5a20984e1b 100644--- a/web/packages/new/albums/services/public-albums-fdb.ts+++ b/web/packages/new/albums/services/public-albums-fdb.ts@@ -19,7 +19,7 @@ import { z } from "zod/v4";** Use {@link savePublicCollections} to update the database.*/-export const savedPublicCollections = async (): Promise<Collection[]> =>+const savedPublicCollections = async (): Promise<Collection[]> =>// TODO://// See: [Note: strict mode migration]@@ -35,7 +35,7 @@ export const savedPublicCollections = async (): Promise<Collection[]> =>** This is the setter corresponding to {@link savedPublicCollections}.*/-export const savePublicCollections = (collections: Collection[]) =>+const savePublicCollections = (collections: Collection[]) =>localForage.setItem("public-collections", collections);/**@@ -233,24 +233,27 @@ export const removePublicCollectionLastSyncTime = async (};/**- * Return the password JWT, if any, present in our local database for the given- * public collection (as identified by its {@link accessToken}).+ * Return the access token JWT, if any, present in our local database for the+ * given public collection (as identified by its {@link accessToken}).*- * Use {@link savedPublicCollectionPasswordJWT} to save the value, and- * {@link removePublicCollectionPasswordJWT} to remove it.+ * Use {@link savePublicCollectionAccessTokenJWT} to save the value, and+ * {@link removePublicCollectionAccessTokenJWT} to remove it.*/-export const savedPublicCollectionPasswordJWT = async (accessToken: string) =>+export const savedPublicCollectionAccessTokenJWT = async (+ accessToken: string,+) =>LocalString.parse(await localForage.getItem(`public-${accessToken}-passkey`),);/**- * Update the password JWT in our local database for the given public+ * Update the access token JWT in our local database for the given public* collection (as identified by its {@link accessToken}).*- * This is the setter corresponding to {@link savedPublicCollectionPasswordJWT}.+ * This is the setter corresponding to+ * {@link savedPublicCollectionAccessTokenJWT}.*/-export const savePublicCollectionPasswordJWT = async (+export const savePublicCollectionAccessTokenJWT = async (accessToken: string,passwordJWT: string,) => {@@ -258,12 +261,10 @@ export const savePublicCollectionPasswordJWT = async (};/**- * Remove the password JWT in our local database for the given public+ * Remove the access token JWT in our local database for the given public* collection (as identified by its {@link accessToken}).- *- * This is the setter corresponding to {@link savedPublicCollectionPasswordJWT}.*/-export const removePublicCollectionPasswordJWT = async (+export const removePublicCollectionAccessTokenJWT = async (accessToken: string,) => {await localForage.removeItem(`public-${accessToken}-passkey`);