π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Interim type
Manav Rathifac2b340453c
diff --git a/web/apps/photos/src/services/upload/upload-service.ts b/web/apps/photos/src/services/upload/upload-service.tsindex b9fcbae6a5..7b0ae0a28e 100644--- a/web/apps/photos/src/services/upload/upload-service.ts+++ b/web/apps/photos/src/services/upload/upload-service.ts@@ -1359,14 +1359,10 @@ const encryptFile = async (worker,);- const {- encryptedData: thumbEncryptedData,- decryptionHeader: thumbDecryptionHeader,- } = await worker.encryptThumbnail(file.thumbnail, fileKey);- const encryptedThumbnail = {- encryptedData: thumbEncryptedData,- decryptionHeader: thumbDecryptionHeader,- };+ const encryptedThumbnail = await worker.encryptThumbnail(+ file.thumbnail,+ fileKey,+ );const encryptedMetadata = await worker.encryptMetadataJSON({jsonValue: file.metadata,diff --git a/web/packages/base/crypto/ente-impl.ts b/web/packages/base/crypto/ente-impl.tsindex 72e31e5b87..f2279077a9 100644--- a/web/packages/base/crypto/ente-impl.ts+++ b/web/packages/base/crypto/ente-impl.ts@@ -1,6 +1,6 @@/** Careful when adding add other imports! */import * as libsodium from "./libsodium";-import type { BytesOrB64, EncryptedBlob } from "./types";+import type { BytesOrB64, EncryptedBlob, EncryptedFile } from "./types";export const _encryptBoxB64 = libsodium.encryptBoxB64;@@ -8,7 +8,10 @@ export const _encryptBlob = libsodium.encryptBlob;export const _encryptBlobB64 = libsodium.encryptBlobB64;-export const _encryptThumbnail = async (data: BytesOrB64, key: BytesOrB64) => {+export const _encryptThumbnail = async (+ data: BytesOrB64,+ key: BytesOrB64,+): Promise<EncryptedFile> => {const { encryptedData, decryptionHeader } = await _encryptBlob(data, key);return {encryptedData,diff --git a/web/packages/base/crypto/types.ts b/web/packages/base/crypto/types.tsindex 11cb1ed65e..d79a32f85e 100644--- a/web/packages/base/crypto/types.ts+++ b/web/packages/base/crypto/types.ts@@ -105,3 +105,27 @@ export interface EncryptedBlobB64 {*/decryptionHeader: string;}++/**+ * An intermediate between {@link EncryptedBlobBytes} and+ * {@link EncryptedBlobB64} that has the encrypted as bytes+ * ({@link Uint8Array}s), but the {@link decryptionHeader} as a base64 string.+ *+ * Such a format is handy for encrypting files, since it can then directly be+ * used (the file's encrypted bytes get uploaded separately, whilst the base64+ * decryption header becomes part of the corresponding {@link EnteFile}).+ */+export interface EncryptedFile {+ /**+ * The encrypted data.+ */+ encryptedData: Uint8Array;+ /**+ * A base64 string containing the decryption header.+ *+ * While the exact contents of the header are libsodium's internal details,+ * it effectively contains a random nonce generated by libsodium. It does+ * not need to be secret, but it is required to decrypt the data.+ */+ decryptionHeader: string;+}