π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Inline
Manav Rathibb2ddec16371
diff --git a/web/apps/photos/src/components/Sidebar/DebugSection.tsx b/web/apps/photos/src/components/Sidebar/DebugSection.tsxindex 28c65ca8e0..e336374030 100644--- a/web/apps/photos/src/components/Sidebar/DebugSection.tsx+++ b/web/apps/photos/src/components/Sidebar/DebugSection.tsx@@ -9,10 +9,6 @@ import { useContext, useEffect, useState } from "react";import { Trans } from "react-i18next";import { isInternalUser } from "utils/user";import { testUpload } from "../../../tests/upload.test";-import {- testZipFileReading,- testZipWithRootFileReadingTest,-} from "../../../tests/zip-file-reading.test";export default function DebugSection() {const appContext = useContext(AppContext);@@ -62,25 +58,11 @@ export default function DebugSection() {</Typography>)}{isInternalUser() && (- <>- <EnteMenuItem- variant="secondary"- onClick={testUpload}- label={"Test Upload"}- />-- <EnteMenuItem- variant="secondary"- onClick={testZipFileReading}- label="Test Zip file reading"- />-- <EnteMenuItem- variant="secondary"- onClick={testZipWithRootFileReadingTest}- label="Zip with Root file Test"- />- </>+ <EnteMenuItem+ variant="secondary"+ onClick={testUpload}+ label={"Test Upload"}+ />)}</>);diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.tsindex 9cd8cc0038..a9edfc7837 100644--- a/web/apps/photos/src/services/upload/uploadService.ts+++ b/web/apps/photos/src/services/upload/uploadService.ts@@ -71,6 +71,25 @@ const maximumChunksPerUploadPart = 5;* */const multipartPartSize = ENCRYPTION_CHUNK_SIZE * maximumChunksPerUploadPart;+interface DataStream {+ stream: ReadableStream<Uint8Array>;+ chunkCount: number;+}++function isDataStream(object: any): object is DataStream {+ return "stream" in object;+}++interface LocalFileAttributes<T extends string | Uint8Array | DataStream> {+ encryptedData: T;+ decryptionHeader: string;+}++interface EncryptionResult<T extends string | Uint8Array | DataStream> {+ file: LocalFileAttributes<T>;+ key: string;+}+/** Upload files to cloud storage */class UploadService {private uploadURLs: UploadURL[] = [];diff --git a/web/apps/photos/tests/zip-file-reading.test.ts b/web/apps/photos/tests/zip-file-reading.test.tsdeleted file mode 100644index e4fe6bbf3a..0000000000--- a/web/apps/photos/tests/zip-file-reading.test.ts+++ /dev/null@@ -1,112 +0,0 @@-import { getFileNameSize } from "@/next/file";-import { ENCRYPTION_CHUNK_SIZE } from "@ente/shared/crypto/constants";-import type { DataStream } from "@ente/shared/utils/data-stream";-import { PICKED_UPLOAD_TYPE } from "constants/upload";-import { getElectronFileStream, getFileStream } from "services/readerService";-import { getImportSuggestion } from "utils/upload";--// This was for used to verify that converting from the browser readable stream-// to the node readable stream correctly handles files that align on the 4 MB-// data boundary. This expects a zip file containing random files of various-// sizes starting from 1M to 20M.-export const testZipFileReading = async () => {- try {- const electron = globalThis.electron;- if (!electron) {- console.log("testZipFileReading Check is for desktop only");- return;- }- if (!process.env.NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH) {- throw Error(- "upload test failed NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH missing",- );- }- const files = await electron.getElectronFilesFromGoogleZip(- process.env.NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH,- );- if (!files?.length) {- throw Error(- `testZipFileReading Check failed β- No files selected`,- );- }- console.log("test zip file reading check started");- let i = 0;- for (const file of files) {- i++;- let filedata: DataStream;- if (file instanceof File) {- filedata = getFileStream(file, ENCRYPTION_CHUNK_SIZE);- } else {- filedata = await getElectronFileStream(- file,- ENCRYPTION_CHUNK_SIZE,- );- }- const streamReader = filedata.stream.getReader();- for (let i = 0; i < filedata.chunkCount; i++) {- const { done } = await streamReader.read();- if (done) {- throw Error(- `testZipFileReading Check failed β- ${getFileNameSize(- file,- )} less than expected chunks, expected: ${- filedata.chunkCount- }, got ${i - 1}`,- );- }- }- const { done } = await streamReader.read();-- if (!done) {- throw Error(- `testZipFileReading Check failed β- ${getFileNameSize(- file,- )} more than expected chunks, expected: ${- filedata.chunkCount- }`,- );- }- console.log(`${i}/${files.length} passed β `);- }- console.log("test zip file reading check passed β ");- } catch (e) {- console.log(e);- }-};--// This was used when fixing a bug around handling a zip file that has a photo-// at the root.-export const testZipWithRootFileReadingTest = async () => {- try {- const electron = globalThis.electron;- if (!electron) {- console.log("testZipFileReading Check is for desktop only");- return;- }- if (!process.env.NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH) {- throw Error(- "upload test failed NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH missing",- );- }- const files = await electron.getElectronFilesFromGoogleZip(- process.env.NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH,- );-- const importSuggestion = getImportSuggestion(- PICKED_UPLOAD_TYPE.ZIPS,- files.map((file) => file["path"]),- );- if (!importSuggestion.rootFolderName) {- throw Error(- `testZipWithRootFileReadingTest Check failed β- rootFolderName is missing`,- );- }- console.log("testZipWithRootFileReadingTest passed β ");- } catch (e) {- console.log(e);- }-};diff --git a/web/packages/shared/crypto/types.ts b/web/packages/shared/crypto/types.tsindex 47bfa8b2ce..e591820f08 100644--- a/web/packages/shared/crypto/types.ts+++ b/web/packages/shared/crypto/types.ts@@ -1,17 +1,3 @@-import type { DataStream } from "../utils/data-stream";--export interface LocalFileAttributes<- T extends string | Uint8Array | DataStream,-> {- encryptedData: T;- decryptionHeader: string;-}--export interface EncryptionResult<T extends string | Uint8Array | DataStream> {- file: LocalFileAttributes<T>;- key: string;-}-export interface B64EncryptionResult {encryptedData: string;key: string;diff --git a/web/packages/shared/utils/data-stream.ts b/web/packages/shared/utils/data-stream.tsdeleted file mode 100644index d072dfe7ec..0000000000--- a/web/packages/shared/utils/data-stream.ts+++ /dev/null@@ -1,8 +0,0 @@-export interface DataStream {- stream: ReadableStream<Uint8Array>;- chunkCount: number;-}--export function isDataStream(object: any): object is DataStream {- return "stream" in object;-}