π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Propogate
Manav Rathi12fbde45b35d
diff --git a/web/apps/photos/src/components/PhotoList/index.tsx b/web/apps/photos/src/components/PhotoList/index.tsxindex a6dfaa3a5a..f6a3aeee1f 100644--- a/web/apps/photos/src/components/PhotoList/index.tsx+++ b/web/apps/photos/src/components/PhotoList/index.tsx@@ -325,7 +325,7 @@ export function PhotoList({timeStampList.push(getEmptyListItem());}timeStampList.push(getVacuumItem(timeStampList));- if (publicCollectionGalleryContext.accessedThroughSharedURL) {+ if (publicCollectionGalleryContext.credentials) {if (publicCollectionGalleryContext.photoListFooter) {timeStampList.push(getPhotoListFooter(@@ -396,7 +396,7 @@ export function PhotoList({if (hasFooter) {return timeStampList;}- if (publicCollectionGalleryContext.accessedThroughSharedURL) {+ if (publicCollectionGalleryContext.credentials) {if (publicCollectionGalleryContext.photoListFooter) {return [...timeStampList,@@ -413,7 +413,7 @@ export function PhotoList({}});}, [- publicCollectionGalleryContext.accessedThroughSharedURL,+ publicCollectionGalleryContext.credentials,showAppDownloadBanner,publicCollectionGalleryContext.photoListFooter,]);@@ -521,7 +521,7 @@ export function PhotoList({const getVacuumItem = (timeStampList) => {let footerHeight;- if (publicCollectionGalleryContext.accessedThroughSharedURL) {+ if (publicCollectionGalleryContext.credentials) {footerHeight = publicCollectionGalleryContext.referralCode? ALBUM_FOOTER_HEIGHT_WITH_REFERRAL: ALBUM_FOOTER_HEIGHT;diff --git a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsxindex df4a4ab0a1..f140a3b05c 100644--- a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx+++ b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx@@ -213,7 +213,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({title={t("location")}caption={!mapEnabled ||- publicCollectionGalleryContext.accessedThroughSharedURL ? (+ publicCollectionGalleryContext.credentials ? (<Linkhref={openStreetMapLink(location)}target="_blank"@@ -245,7 +245,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({/>}/>- {!publicCollectionGalleryContext.accessedThroughSharedURL && (+ {!publicCollectionGalleryContext.credentials && (<MapBoxlocation={location}mapEnabled={mapEnabled}diff --git a/web/apps/photos/src/components/PhotoViewer/index.tsx b/web/apps/photos/src/components/PhotoViewer/index.tsxindex 1c324a0ab6..86dbf0195c 100644--- a/web/apps/photos/src/components/PhotoViewer/index.tsx+++ b/web/apps/photos/src/components/PhotoViewer/index.tsx@@ -345,7 +345,7 @@ function PhotoViewer(props: PhotoViewerProps) {function updateIsOwnFile(file: EnteFile) {const isOwnFile =- !publicCollectionGalleryContext.accessedThroughSharedURL &&+ !publicCollectionGalleryContext.credentials &&galleryContext.user?.id === file.ownerID;setIsOwnFile(isOwnFile);}diff --git a/web/apps/photos/src/components/Upload/UploadTypeSelector.tsx b/web/apps/photos/src/components/Upload/UploadTypeSelector.tsxindex 6f9cbfef1d..953455ec47 100644--- a/web/apps/photos/src/components/Upload/UploadTypeSelector.tsx+++ b/web/apps/photos/src/components/Upload/UploadTypeSelector.tsx@@ -62,7 +62,7 @@ export const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({if (open &&directlyShowUploadFiles &&- publicCollectionGalleryContext.accessedThroughSharedURL+ publicCollectionGalleryContext.credentials) {uploadFiles();onClose();diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsxindex 505fd992ae..1c3c17e108 100644--- a/web/apps/photos/src/components/Upload/Uploader.tsx+++ b/web/apps/photos/src/components/Upload/Uploader.tsx@@ -249,7 +249,7 @@ export default function Uploader({setUploadProgressView,},onUploadFile,- publicCollectionGalleryContext,+ publicCollectionGalleryContext.credentials,);if (uploadManager.isUploadRunning()) {@@ -288,11 +288,7 @@ export default function Uploader({setDesktopZipItems(zipItems);});}- }, [- publicCollectionGalleryContext.accessedThroughSharedURL,- publicCollectionGalleryContext.token,- publicCollectionGalleryContext.passwordToken,- ]);+ }, [publicCollectionGalleryContext.credentials]);// Handle selected files when user selects files for upload through the open// file / open folder selection dialog, or drag-and-drops them.@@ -417,10 +413,10 @@ export default function Uploader({props.setLoading(false);(async () => {- if (publicCollectionGalleryContext.accessedThroughSharedURL) {+ if (publicCollectionGalleryContext.credentials) {const uploaderName = await getPublicCollectionUploaderName(getPublicCollectionUID(- publicCollectionGalleryContext.token,+ publicCollectionGalleryContext.credentials.accessToken,),);uploaderNameRef.current = uploaderName;@@ -727,7 +723,7 @@ export default function Uploader({if (!skipSave) {savePublicCollectionUploaderName(getPublicCollectionUID(- publicCollectionGalleryContext.token,+ publicCollectionGalleryContext.credentials.accessToken,),uploaderName,);diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 5ed99e9478..7c3acdb66a 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -461,7 +461,7 @@ export default function PublicCollectionGallery() {<ActivityIndicator /></VerticallyCentered>);- } else if (!publicFiles) {+ } else if (!publicFiles || !credentials.current) {return <VerticallyCentered>{t("NOT_FOUND")}</VerticallyCentered>;} else if (errorMessage) {return <VerticallyCentered>{errorMessage}</VerticallyCentered>;@@ -484,17 +484,16 @@ export default function PublicCollectionGallery() {);}+ // TODO: memo this (after the dependencies are traceable).+ const context = {+ credentials: credentials.current,+ referralCode: referralCode.current,+ photoListHeader,+ photoListFooter,+ };+return (- <PublicCollectionGalleryContext.Provider- value={{- token: credentials.current.accessToken,- referralCode: referralCode.current,- passwordToken: credentials.current.accessTokenJWT,- accessedThroughSharedURL: true,- photoListHeader,- photoListFooter,- }}- >+ <PublicCollectionGalleryContext.Provider value={context}><FullScreenDropZone {...{ getDragAndDropRootProps }}><UploadSelectorInputs{...{diff --git a/web/apps/photos/src/services/upload/upload-service.ts b/web/apps/photos/src/services/upload/upload-service.tsindex 7bf38ee3fc..6b0e020243 100644--- a/web/apps/photos/src/services/upload/upload-service.ts+++ b/web/apps/photos/src/services/upload/upload-service.ts@@ -3,6 +3,7 @@ import type { BytesOrB64 } from "@/base/crypto/types";import { type CryptoWorker } from "@/base/crypto/worker";import { ensureElectron } from "@/base/electron";import { basename, nameAndExtension } from "@/base/file-name";+import type { PublicAlbumsCredentials } from "@/base/http";import log from "@/base/log";import { CustomErrorMessage } from "@/base/types/ipc";import { extractVideoMetadata } from "@/gallery/services/ffmpeg";@@ -42,10 +43,7 @@ import { mergeUint8Arrays } from "@/utils/array";import { ensureInteger, ensureNumber } from "@/utils/ensure";import { CustomError, handleUploadError } from "@ente/shared/error";import { addToCollection } from "services/collectionService";-import {- PublicUploadProps,- type LivePhotoAssets,-} from "services/upload/uploadManager";+import { type LivePhotoAssets } from "services/upload/uploadManager";import * as convert from "xml-js";import { tryParseEpochMicrosecondsFromFileName } from "./date";import publicUploadHttpClient from "./publicUploadHttpClient";@@ -110,17 +108,17 @@ const multipartChunksPerPart = 5;class UploadService {private uploadURLs: UploadURL[] = [];private pendingUploadCount: number = 0;- private publicUploadProps: PublicUploadProps = undefined;+ private publicAlbumsCredentials: PublicAlbumsCredentials | undefined;private activeUploadURLRefill: Promise<void> | undefined;- init(publicUploadProps: PublicUploadProps) {- this.publicUploadProps = publicUploadProps;+ init(publicAlbumsCredentials: PublicAlbumsCredentials | undefined) {+ this.publicAlbumsCredentials = publicAlbumsCredentials;}logout() {this.uploadURLs = [];this.pendingUploadCount = 0;- this.publicUploadProps = undefined;+ this.publicAlbumsCredentials = undefined;this.activeUploadURLRefill = undefined;}@@ -153,11 +151,12 @@ class UploadService {}async uploadFile(uploadFile: UploadFile) {- if (this.publicUploadProps.accessedThroughSharedURL) {+ if (this.publicAlbumsCredentials) {return publicUploadHttpClient.uploadFile(uploadFile,- this.publicUploadProps.token,- this.publicUploadProps.passwordToken,+ // TODO: publicAlbumsCredentials+ this.publicAlbumsCredentials.accessToken,+ this.publicAlbumsCredentials.accessTokenJWT,);} else {return UploadHttpClient.uploadFile(uploadFile);@@ -188,16 +187,10 @@ class UploadService {private async _refillUploadURLs() {let urls: UploadURL[];- if (this.publicUploadProps.accessedThroughSharedURL) {- if (!this.publicUploadProps.token) {- throw Error(CustomError.TOKEN_MISSING);- }+ if (this.publicAlbumsCredentials) {urls = await publicUploadHttpClient.fetchUploadURLs(this.pendingUploadCount,- {- accessToken: this.publicUploadProps.token,- accessTokenJWT: this.publicUploadProps.passwordToken,- },+ this.publicAlbumsCredentials,);} else {urls = await UploadHttpClient.fetchUploadURLs(@@ -208,11 +201,12 @@ class UploadService {}async fetchMultipartUploadURLs(count: number) {- if (this.publicUploadProps.accessedThroughSharedURL) {+ if (this.publicAlbumsCredentials) {+ // TODO: publicAlbumsCredentialsreturn await publicUploadHttpClient.fetchMultipartUploadURLs(count,- this.publicUploadProps.token,- this.publicUploadProps.passwordToken,+ this.publicAlbumsCredentials.accessToken,+ this.publicAlbumsCredentials.accessTokenJWT,);} else {return await UploadHttpClient.fetchMultipartUploadURLs(count);diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.tsindex f49925210e..474a4645f2 100644--- a/web/apps/photos/src/services/upload/uploadManager.ts+++ b/web/apps/photos/src/services/upload/uploadManager.ts@@ -2,6 +2,7 @@ import { isDesktop } from "@/base/app";import { createComlinkCryptoWorker } from "@/base/crypto";import { type CryptoWorker } from "@/base/crypto/worker";import { lowercaseExtension, nameAndExtension } from "@/base/file-name";+import type { PublicAlbumsCredentials } from "@/base/http";import log from "@/base/log";import type { Electron } from "@/base/types/ipc";import { ComlinkWorker } from "@/base/worker/comlink-worker";@@ -96,12 +97,6 @@ export interface LivePhotoAssets {video: UploadItem;}-export interface PublicUploadProps {- token: string;- passwordToken: string;- accessedThroughSharedURL: boolean;-}-interface UploadCancelStatus {value: boolean;}@@ -325,7 +320,7 @@ class UploadManager {private onUploadFile: (file: EnteFile) => void;private collections: Map<number, Collection>;private uploadInProgress: boolean;- private publicUploadProps: PublicUploadProps;+ private publicAlbumsCredentials: PublicAlbumsCredentials | undefined;private uploaderName: string;private uiService: UIService;@@ -336,12 +331,12 @@ class UploadManager {public async init(progressUpdater: ProgressUpdater,onUploadFile: (file: EnteFile) => void,- publicCollectProps: PublicUploadProps,+ publicAlbumsCredentials: PublicAlbumsCredentials | undefined,) {this.uiService.init(progressUpdater);- UploadService.init(publicCollectProps);+ UploadService.init(publicAlbumsCredentials);this.onUploadFile = onUploadFile;- this.publicUploadProps = publicCollectProps;+ this.publicAlbumsCredentials = publicAlbumsCredentials;}logout() {@@ -497,9 +492,11 @@ class UploadManager {};private async updateExistingFilesAndCollections(collections: Collection[]) {- if (this.publicUploadProps.accessedThroughSharedURL) {+ if (this.publicAlbumsCredentials) {this.existingFiles = await getLocalPublicFiles(- getPublicCollectionUID(this.publicUploadProps.token),+ getPublicCollectionUID(+ this.publicAlbumsCredentials.accessToken,+ ),);} else {this.existingFiles = getUserOwnedFiles(await getLocalFiles());diff --git a/web/apps/photos/src/utils/publicCollectionGallery/index.ts b/web/apps/photos/src/utils/publicCollectionGallery/index.tsindex c0e4cc9ff6..d5334d7f3f 100644--- a/web/apps/photos/src/utils/publicCollectionGallery/index.ts+++ b/web/apps/photos/src/utils/publicCollectionGallery/index.ts@@ -1,21 +1,23 @@+import type { PublicAlbumsCredentials } from "@/base/http";import { TimeStampListItem } from "components/PhotoList";import { createContext } from "react";export interface PublicCollectionGalleryContextType {- token: string;- passwordToken: string;+ /**+ * The {@link PublicAlbumsCredentials} to use. These are guaranteed to be+ * set if we are in the context of the public albums app, and will be+ * undefined when we're in the default photos app context.+ */+ credentials: PublicAlbumsCredentials | undefined;referralCode: string | null;- accessedThroughSharedURL: boolean;photoListHeader: TimeStampListItem;photoListFooter: TimeStampListItem;}export const PublicCollectionGalleryContext =createContext<PublicCollectionGalleryContextType>({- token: null,- passwordToken: null,+ credentials: undefined,referralCode: null,- accessedThroughSharedURL: false,photoListHeader: null,photoListFooter: null,});