π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Swap
Manav Rathi44bdb016a8ab
diff --git a/web/packages/base/crypto/ente-impl.ts b/web/packages/base/crypto/ente-impl.tsindex 2b65831fb9..1c6e07e962 100644--- a/web/packages/base/crypto/ente-impl.ts+++ b/web/packages/base/crypto/ente-impl.ts@@ -20,11 +20,11 @@ export const _encryptAssociatedData = libsodium.encryptBlob;export const _encryptThumbnail = _encryptAssociatedData;-export const _encryptAssociatedB64Data = (r: EncryptBytes) =>+export const _encryptAssociatedDataB64 = (r: EncryptBytes) =>_encryptAssociatedData(r).then(EncryptedBlobBytesToB64);export const _encryptMetadataJSON = ({ jsonValue, keyB64 }: EncryptJSON) =>- _encryptAssociatedB64Data({+ _encryptAssociatedDataB64({data: new TextEncoder().encode(JSON.stringify(jsonValue)),keyB64,});@@ -33,7 +33,7 @@ export const _decryptAssociatedData = libsodium.decryptBlob;export const _decryptThumbnail = _decryptAssociatedData;-export const _decryptAssociatedB64Data = async ({+export const _decryptAssociatedDataB64 = async ({encryptedDataB64,decryptionHeaderB64,keyB64,@@ -46,5 +46,5 @@ export const _decryptAssociatedB64Data = async ({export const _decryptMetadataJSON = async (r: DecryptBlobB64) =>JSON.parse(- new TextDecoder().decode(await _decryptAssociatedB64Data(r)),+ new TextDecoder().decode(await _decryptAssociatedDataB64(r)),) as unknown;diff --git a/web/packages/base/crypto/ente.ts b/web/packages/base/crypto/ente.tsindex 18035ed85f..8fe3aaad08 100644--- a/web/packages/base/crypto/ente.ts+++ b/web/packages/base/crypto/ente.ts@@ -96,10 +96,10 @@ export const encryptThumbnail = (r: EncryptBytes) =>* A variant of {@link encryptAssociatedData} that returns the encrypted data as* a base64 string instead of returning its bytes.*- * Use {@link decryptAssociatedB64Data} to decrypt the result.+ * Use {@link decryptAssociatedDataB64} to decrypt the result.*/-export const encryptAssociatedB64Data = (r: EncryptBytes) =>- assertInWorker(ei._encryptAssociatedB64Data(r));+export const encryptAssociatedDataB64 = (r: EncryptBytes) =>+ assertInWorker(ei._encryptAssociatedDataB64(r));/*** Encrypt the JSON metadata associated with an Ente object (file, collection or@@ -144,12 +144,12 @@ export const decryptThumbnail = (r: DecryptBlobBytes) =>* A variant of {@link decryptAssociatedData} that expects the encrypted data as* a base64 encoded string.*- * This is the sibling of {@link decryptAssociatedB64Data}.+ * This is the sibling of {@link encryptAssociatedDataB64}.*/-export const decryptAssociatedB64Data = (r: DecryptBlobB64) =>+export const decryptAssociatedDataB64 = (r: DecryptBlobB64) =>inWorker()- ? ei._decryptAssociatedB64Data(r)- : sharedCryptoWorker().then((w) => w.decryptAssociatedB64Data(r));+ ? ei._decryptAssociatedDataB64(r)+ : sharedCryptoWorker().then((w) => w.decryptAssociatedDataB64(r));/*** Decrypt the metadata JSON associated with an Ente object.*diff --git a/web/packages/base/crypto/worker.ts b/web/packages/base/crypto/worker.tsindex c4a1dc1b62..c6aae70a2b 100644--- a/web/packages/base/crypto/worker.ts+++ b/web/packages/base/crypto/worker.ts@@ -15,7 +15,7 @@ export class CryptoWorker {encryptThumbnail = ei._encryptThumbnail;encryptMetadataJSON = ei._encryptMetadataJSON;decryptThumbnail = ei._decryptThumbnail;- decryptAssociatedB64Data = ei._decryptAssociatedB64Data;+ decryptAssociatedDataB64 = ei._decryptAssociatedDataB64;decryptMetadataJSON = ei._decryptMetadataJSON;// TODO: -- AUDIT BELOW --diff --git a/web/packages/new/photos/services/file-data.ts b/web/packages/new/photos/services/file-data.tsindex 8fd35da830..0b3f1ef0b8 100644--- a/web/packages/new/photos/services/file-data.ts+++ b/web/packages/new/photos/services/file-data.ts@@ -1,4 +1,4 @@-import { encryptAssociatedB64Data } from "@/base/crypto/ente";+import { encryptAssociatedDataB64 } from "@/base/crypto/ente";import { authenticatedRequestHeaders, ensureOk } from "@/base/http";import { apiURL } from "@/base/origins";import type { EnteFile } from "@/new/photos/types/file";@@ -95,7 +95,7 @@ export const putFileData = async (data: Uint8Array,) => {const { encryptedDataB64, decryptionHeaderB64 } =- await encryptAssociatedB64Data({ data: data, keyB64: enteFile.key });+ await encryptAssociatedDataB64({ data: data, keyB64: enteFile.key });const res = await fetch(await apiURL("/files/data"), {method: "PUT",diff --git a/web/packages/new/photos/services/ml/ml-data.ts b/web/packages/new/photos/services/ml/ml-data.tsindex 2d99f215d5..4c82ef426f 100644--- a/web/packages/new/photos/services/ml/ml-data.ts+++ b/web/packages/new/photos/services/ml/ml-data.ts@@ -1,4 +1,4 @@-import { decryptAssociatedB64Data } from "@/base/crypto/ente";+import { decryptAssociatedDataB64 } from "@/base/crypto/ente";import log from "@/base/log";import type { EnteFile } from "@/new/photos/types/file";import { nullToUndefined } from "@/utils/transform";@@ -172,7 +172,7 @@ export const fetchMLData = async (}try {- const decryptedBytes = await decryptAssociatedB64Data({+ const decryptedBytes = await decryptAssociatedDataB64({encryptedDataB64: remoteFileData.encryptedData,decryptionHeaderB64: remoteFileData.decryptionHeader,keyB64: file.key,diff --git a/web/packages/new/photos/services/user-entity.ts b/web/packages/new/photos/services/user-entity.tsindex ee3e5edd8c..67f92c77a8 100644--- a/web/packages/new/photos/services/user-entity.ts+++ b/web/packages/new/photos/services/user-entity.ts@@ -1,5 +1,5 @@import { sharedCryptoWorker } from "@/base/crypto";-import { decryptAssociatedB64Data } from "@/base/crypto/ente";+import { decryptAssociatedDataB64 } from "@/base/crypto/ente";import { authenticatedRequestHeaders, ensureOk, HTTPError } from "@/base/http";import { getKV, getKVN, setKV } from "@/base/kv";import { apiURL } from "@/base/origins";@@ -150,7 +150,7 @@ export const userEntityDiff = async (});const decrypt = (encryptedDataB64: string, decryptionHeaderB64: string) =>- decryptAssociatedB64Data({+ decryptAssociatedDataB64({encryptedDataB64,decryptionHeaderB64,keyB64: entityKeyB64,