π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Inline
Manav Rathia9e0aa13ff95
diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.tsindex b18e0c4781..c50407eb94 100644--- a/web/apps/photos/src/services/upload/uploadService.ts+++ b/web/apps/photos/src/services/upload/uploadService.ts@@ -16,9 +16,9 @@ import { basename } from "@/next/file";import log from "@/next/log";import { CustomErrorMessage } from "@/next/types/ipc";import { ensure } from "@/utils/ensure";-import { ENCRYPTION_CHUNK_SIZE } from "@ente/shared/crypto/internal/libsodium";import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";-import type { B64EncryptionResult } from "@ente/shared/crypto/types";+import type { B64EncryptionResult } from "@ente/shared/crypto/internal/libsodium";+import { ENCRYPTION_CHUNK_SIZE } from "@ente/shared/crypto/internal/libsodium";import { CustomError, handleUploadError } from "@ente/shared/error";import type { Remote } from "comlink";import {diff --git a/web/packages/accounts/api/user.ts b/web/packages/accounts/api/user.tsindex 131ae73ef7..9269fe2e17 100644--- a/web/packages/accounts/api/user.ts+++ b/web/packages/accounts/api/user.ts@@ -7,7 +7,7 @@ import type {TwoFactorVerificationResponse,UserVerificationResponse,} from "@ente/accounts/types/user";-import type { B64EncryptionResult } from "@ente/shared/crypto/types";+import type { B64EncryptionResult } from "@ente/shared/crypto/internal/libsodium";import { ApiError, CustomError } from "@ente/shared/error";import HTTPService from "@ente/shared/network/HTTPService";import { getToken } from "@ente/shared/storage/localStorage/helpers";diff --git a/web/packages/accounts/pages/credentials.tsx b/web/packages/accounts/pages/credentials.tsxindex 60a2611e7e..39e1c5135a 100644--- a/web/packages/accounts/pages/credentials.tsx+++ b/web/packages/accounts/pages/credentials.tsx@@ -20,7 +20,7 @@ import {generateLoginSubKey,saveKeyInSessionStore,} from "@ente/shared/crypto/helpers";-import type { B64EncryptionResult } from "@ente/shared/crypto/types";+import type { B64EncryptionResult } from "@ente/shared/crypto/internal/libsodium";import { CustomError } from "@ente/shared/error";import InMemoryStore, { MS_KEYS } from "@ente/shared/storage/InMemoryStore";import {diff --git a/web/packages/accounts/pages/two-factor/recover.tsx b/web/packages/accounts/pages/two-factor/recover.tsxindex 22608c607f..e52f90c633 100644--- a/web/packages/accounts/pages/two-factor/recover.tsx+++ b/web/packages/accounts/pages/two-factor/recover.tsx@@ -18,7 +18,7 @@ import SingleInputForm, {} from "@ente/shared/components/SingleInputForm";import { SUPPORT_EMAIL } from "@ente/shared/constants/urls";import ComlinkCryptoWorker from "@ente/shared/crypto";-import type { B64EncryptionResult } from "@ente/shared/crypto/types";+import type { B64EncryptionResult } from "@ente/shared/crypto/internal/libsodium";import { ApiError } from "@ente/shared/error";import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";import { Link } from "@mui/material";diff --git a/web/packages/shared/crypto/internal/libsodium.ts b/web/packages/shared/crypto/internal/libsodium.tsindex 4337a0fb12..aa02772e52 100644--- a/web/packages/shared/crypto/internal/libsodium.ts+++ b/web/packages/shared/crypto/internal/libsodium.ts@@ -9,7 +9,6 @@import { mergeUint8Arrays } from "@/utils/array";import { CustomError } from "@ente/shared/error";import sodium, { type StateAddress } from "libsodium-wrappers";-import type { B64EncryptionResult } from "../types";export async function fromB64(input: string) {await sodium.ready;@@ -275,6 +274,13 @@ export async function encryptFileChunk(return pushResult;}++export interface B64EncryptionResult {+ encryptedData: string;+ key: string;+ nonce: string;+}+export async function encryptToB64(data: string, key: string) {await sodium.ready;const encrypted = await encrypt(await fromB64(data), await fromB64(key));diff --git a/web/packages/shared/crypto/types.ts b/web/packages/shared/crypto/types.tsdeleted file mode 100644index e591820f08..0000000000--- a/web/packages/shared/crypto/types.ts+++ /dev/null@@ -1,5 +0,0 @@-export interface B64EncryptionResult {- encryptedData: string;- key: string;- nonce: string;-}diff --git a/web/packages/shared/user/index.ts b/web/packages/shared/user/index.tsindex ba80411f6a..f66a62b4f6 100644--- a/web/packages/shared/user/index.ts+++ b/web/packages/shared/user/index.ts@@ -1,5 +1,5 @@import ComlinkCryptoWorker from "@ente/shared/crypto";-import type { B64EncryptionResult } from "@ente/shared/crypto/types";+import type { B64EncryptionResult } from "@ente/shared/crypto/internal/libsodium";import { CustomError } from "@ente/shared/error";import { getKey, SESSION_KEYS } from "@ente/shared/storage/sessionStorage";