π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fwd
Manav Rathi2884c0aedfc0
diff --git a/web/packages/base/crypto/index.ts b/web/packages/base/crypto/index.tsindex d267670a71..615ee362ac 100644--- a/web/packages/base/crypto/index.ts+++ b/web/packages/base/crypto/index.ts@@ -46,6 +46,7 @@* of going through this file.*/import { ComlinkWorker } from "@/base/worker/comlink-worker";+import { type StateAddress } from "libsodium-wrappers-sumo";import { assertionFailed } from "../assert";import { inWorker } from "../env";import * as ei from "./ente-impl";@@ -163,6 +164,43 @@ export const encryptThumbnail = (data: BytesOrB64, key: BytesOrB64) =>? ei._encryptThumbnail(data, key): sharedCryptoWorker().then((w) => w.encryptThumbnail(data, key));+/**+ * Encrypt the given data using chunked streaming encryption, but process all+ * the chunks in one go.+ *+ * For more details, see {@link encryptStreamBytes} in `libsodium.ts`.+ */+export const encryptStreamBytes = async (data: Uint8Array, key: BytesOrB64) =>+ inWorker()+ ? ei._encryptStreamBytes(data, key)+ : sharedCryptoWorker().then((w) => w.encryptStreamBytes(data, key));++/**+ * Prepare for chunked streaming encryption using {@link encryptStreamChunk}.+ *+ * For more details, see {@link initChunkEncryption} in `libsodium.ts`.+ */+export const initChunkEncryption = async (key: BytesOrB64) =>+ inWorker()+ ? ei._initChunkEncryption(key)+ : sharedCryptoWorker().then((w) => w.initChunkEncryption(key));++/**+ * Encrypt a chunk as part of a chunked streaming encryption.+ *+ * For more details, see {@link encryptStreamChunk} in `libsodium.ts`.+ */+export const encryptStreamChunk = async (+ data: Uint8Array,+ pushState: StateAddress,+ isFinalChunk: boolean,+) =>+ inWorker()+ ? ei._encryptStreamChunk(data, pushState, isFinalChunk)+ : sharedCryptoWorker().then((w) =>+ w.encryptStreamChunk(data, pushState, isFinalChunk),+ );+/*** Encrypt the JSON metadata associated with an Ente object (file, collection or* entity) using the object's key.