π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
numered lists too
Manav Rathi4e7d76472248
diff --git a/web/apps/accounts/src/services/passkey.ts b/web/apps/accounts/src/services/passkey.tsindex fa6eae5f1a..88d6054da0 100644--- a/web/apps/accounts/src/services/passkey.ts+++ b/web/apps/accounts/src/services/passkey.ts@@ -184,14 +184,14 @@ const beginPasskeyRegistration = async (token: string) => {//// So we do the conversion here.//- // 1. To avoid inventing an intermediary type and the boilerplate that'd- // come with it, we do a force typecast the options in the response to- // one that has `PublicKeyCredentialCreationOptions`.+ // 1. To avoid inventing an intermediary type and the boilerplate that'd+ // come with it, we do a force typecast the options in the response to+ // one that has `PublicKeyCredentialCreationOptions`.//- // 2. Convert the two binary data fields that are expected to be in the- // response from URLEncodedBase64 strings to Uint8Arrays. There is a- // third possibility, excludedCredentials[].id, but that we don't- // currently use.+ // 2. Convert the two binary data fields that are expected to be in the+ // response from URLEncodedBase64 strings to Uint8Arrays. There is a+ // third possibility, excludedCredentials[].id, but that we don't+ // currently use.//// The web.dev guide calls this out too://diff --git a/web/packages/accounts/services/session.ts b/web/packages/accounts/services/session.tsindex 7d2ffb18b6..97c88c16f7 100644--- a/web/packages/accounts/services/session.ts+++ b/web/packages/accounts/services/session.ts@@ -49,10 +49,10 @@ type SessionValidity =** The `/session-validity` API call tells us:*- * 1. Whether or not the session has been invalidated (by the user choosing to- * log out from all devices elsewhere).+ * 1. Whether or not the session has been invalidated (by the user choosing to+ * log out from all devices elsewhere).*- * 2. What are their latest key attributes.+ * 2. What are their latest key attributes.** If the session has been invalidated, we log them out here too.*diff --git a/web/packages/base/crypto/index.ts b/web/packages/base/crypto/index.tsindex 471d8e4540..dffe099447 100644--- a/web/packages/base/crypto/index.ts+++ b/web/packages/base/crypto/index.ts@@ -8,9 +8,9 @@** [Note: Crypto code hierarchy]*- * 1. @/base/crypto (Crypto API for our code)- * 2. @/base/crypto/libsodium (Lower level wrappers over libsodium)- * 3. libsodium-wrappers (JavaScript bindings to libsodium)+ * 1. @/base/crypto (Crypto API for our code)+ * 2. @/base/crypto/libsodium (Lower level wrappers over libsodium)+ * 3. libsodium-wrappers (JavaScript bindings to libsodium)** Our cryptography primitives are provided by libsodium, specifically, its* JavaScript bindings ("libsodium-wrappers"). This is the lowest layer. Notediff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.tsindex dcbd2f4803..9fb5363991 100644--- a/web/packages/base/crypto/libsodium.ts+++ b/web/packages/base/crypto/libsodium.ts@@ -169,19 +169,19 @@ export const generateBlobOrStreamKey = async () => {** libsodium provides two "high level" encryption patterns:*- * 1. Authenticated encryption ("secretbox")- * https://doc.libsodium.org/secret-key_cryptography/secretbox+ * 1. Authenticated encryption ("secretbox")+ * https://doc.libsodium.org/secret-key_cryptography/secretbox*- * 2. Encrypted streams and file encryption ("secretstream")- * https://doc.libsodium.org/secret-key_cryptography/secretstream+ * 2. Encrypted streams and file encryption ("secretstream")+ * https://doc.libsodium.org/secret-key_cryptography/secretstream** In terms of the underlying algorithm, they are essentially the same.*- * 1. The secretbox APIs use XSalsa20 with Poly1305 (where XSalsa20 is the- * stream cipher used for encryption, which Poly1305 is the MAC used for- * authentication).+ * 1. The secretbox APIs use XSalsa20 with Poly1305 (where XSalsa20 is the+ * stream cipher used for encryption, which Poly1305 is the MAC used for+ * authentication).*- * 2. The secretstream APIs use XChaCha20 with Poly1305.+ * 2. The secretstream APIs use XChaCha20 with Poly1305.** XSalsa20 is a minor variant (predecessor in fact) of XChaCha20. I am not* aware why libsodium uses both the variants, but they seem to have similar@@ -189,12 +189,12 @@ export const generateBlobOrStreamKey = async () => {** These two sets of APIs map functionally map to two different use cases.*- * 1. If there is a single independent bit of data to encrypt, the secretbox- * APIs fit the bill.+ * 1. If there is a single independent bit of data to encrypt, the secretbox+ * APIs fit the bill.*- * 2. If there is a set of related data to encrypt, e.g. the contents of a file- * where the file is too big to fit into a single message, then the- * secretstream APIs are more appropriate.+ * 2. If there is a set of related data to encrypt, e.g. the contents of a file+ * where the file is too big to fit into a single message, then the+ * secretstream APIs are more appropriate.** However, in our code we have evolved two different use cases for the 2nd* option. The data to encrypt might be smaller than our streaming encryption@@ -206,15 +206,15 @@ export const generateBlobOrStreamKey = async () => {** Thus, we have three scenarios:*- * 1. Box: Using secretbox APIs to encrypt some independent blob of data.+ * 1. Box: Using secretbox APIs to encrypt some independent blob of data.*- * 2. Blob: Using secretstream APIs without chunking. This is used to encrypt- * data associated to an Ente object (file, collection, entity, etc), when- * the data is small-ish (less than a few MBs).+ * 2. Blob: Using secretstream APIs without chunking. This is used to encrypt+ * data associated to an Ente object (file, collection, entity, etc), when+ * the data is small-ish (less than a few MBs).*- * 3. Stream/Chunks: Using secretstream APIs for encrypting chunks. This is- * used to encrypt the actual content of the files associated with an- * EnteFile object. This itself happens in two ways:+ * 3. Stream/Chunks: Using secretstream APIs for encrypting chunks. This is used+ * to encrypt the actual content of the files associated with an EnteFile+ * object. This itself happens in two ways:** 3a. One shot mode - where we do break the data into chunks, but a single* function processes all the chunks in one go.@@ -228,22 +228,22 @@ export const generateBlobOrStreamKey = async () => {* underlying algorithm differ, but also the terminology that libsodium use for* the nonce.*- * 1. When using the secretbox APIs, the nonce is called the "nonce", and needs- * to be provided by us (the caller).+ * 1. When using the secretbox APIs, the nonce is called the "nonce", and needs+ * to be provided by us (the caller).*- * 2. When using the secretstream APIs, the nonce is internally generated by- * libsodium and provided by libsodium to us (the caller) as a "header".+ * 2. When using the secretstream APIs, the nonce is internally generated by+ * libsodium and provided by libsodium to us (the caller) as a "header".** However, even for case 1, the functions we expose from libsodium.ts generate* the nonce for the caller. So for higher level functions, the difference* between Box and Blob encryption is:*- * 1. Box uses secretbox APIs (Salsa), Blob uses secretstream APIs (ChaCha).+ * 1. Box uses secretbox APIs (Salsa), Blob uses secretstream APIs (ChaCha).*- * 2. Blob should generally be used for data associated with an Ente object,- * and Box for the other cases.+ * 2. Blob should generally be used for data associated with an Ente object, and+ * Box for the other cases.*- * 3. Box returns a "nonce", while Blob returns a "header".+ * 3. Box returns a "nonce", while Blob returns a "header".** The difference between case 2 and 3 (Blob vs Stream) is that while both use* the same algorithms, in case of Blob the entire data is encrypted / decrypteddiff --git a/web/packages/base/kv.ts b/web/packages/base/kv.tsindex 4d572d4530..45cf3afece 100644--- a/web/packages/base/kv.ts+++ b/web/packages/base/kv.ts@@ -62,10 +62,10 @@ interface KVDBSchema extends DBSchema {* promise to the database. To ensure that all connections get torn down* correctly, we need to perform the following logout sequence:*- * 1. Terminate all the workers which might have one of the instances in- * memory. This closes their connections.+ * 1. Terminate all the workers which might have one of the instances in memory.+ * This closes their connections.*- * 2. Delete the database on the main thread.+ * 2. Delete the database on the main thread.*/let _kvDB: ReturnType<typeof openKVDB> | undefined;diff --git a/web/packages/gallery/utils/convert.ts b/web/packages/gallery/utils/convert.tsindex 5c5b865c9e..f950039b02 100644--- a/web/packages/gallery/utils/convert.ts+++ b/web/packages/gallery/utils/convert.ts@@ -29,21 +29,21 @@ let _isNativeJPEGConversionAvailable = true;** The logic used by this function is:*- * 1. Try to detect the MIME type of the file from its contents and/or name.+ * 1. Try to detect the MIME type of the file from its contents and/or name.*- * 2. If this detected type is one of the types that we know that the browser- * likely cannot render, continue. Otherwise return the imageBlob that was- * passed in (after setting its MIME type).+ * 2. If this detected type is one of the types that we know that the browser+ * likely cannot render, continue. Otherwise return the imageBlob that was+ * passed in (after setting its MIME type).*- * 3. If we're running in our desktop app and this MIME type is something our- * desktop app can natively convert to a JPEG (using ffmpeg), do that and- * return the resultant JPEG blob.+ * 3. If we're running in our desktop app and this MIME type is something our+ * desktop app can natively convert to a JPEG (using ffmpeg), do that and+ * return the resultant JPEG blob.*- * 4. If this is an HEIC file, use our (WASM) HEIC converter and return the- * resultant JPEG blob.+ * 4. If this is an HEIC file, use our (WASM) HEIC converter and return the+ * resultant JPEG blob.*- * 5. Otherwise return the original (with the MIME type if we were able to- * deduce one).+ * 5. Otherwise return the original (with the MIME type if we were able to+ * deduce one).** In will catch all errors and return the original in those cases.*/diff --git a/web/packages/media/file-metadata.ts b/web/packages/media/file-metadata.tsindex f84abbb4ce..75bc8bf6c0 100644--- a/web/packages/media/file-metadata.ts+++ b/web/packages/media/file-metadata.ts@@ -732,10 +732,10 @@ export const parseMetadataDate = (//// In its full generality, this is non-trivial. The approach we take is://- // 1. Rely on the browser to be able to partial ISO 8601 string. This- // relies on non-standard behaviour but works in practice seemingly.+ // 1. Rely on the browser to be able to partial ISO 8601 string. This relies+ // on non-standard behaviour but works in practice seemingly.//- // 2. Get an ISO 8601 representation of it. This is standard.+ // 2. Get an ISO 8601 representation of it. This is standard.//// A thing to watch out for is that browsers treat date only and date time// strings differently when the offset is not present (as would be for us).diff --git a/web/packages/new/photos/services/remote-store.ts b/web/packages/new/photos/services/remote-store.tsindex f34053b504..a53da0e99a 100644--- a/web/packages/new/photos/services/remote-store.ts+++ b/web/packages/new/photos/services/remote-store.ts@@ -14,11 +14,11 @@ import { z } from "zod";** There are two APIs to get the current state from remote:*- * 1. GET /remote-store/feature-flags fetches the combined state (nb: even- * though the name of the endpoint has the word feature-flags, it also- * includes user preferences).+ * 1. GET /remote-store/feature-flags fetches the combined state (nb: even+ * though the name of the endpoint has the word feature-flags, it also+ * includes user preferences).*- * 2. GET /remote-store fetches individual values.+ * 2. GET /remote-store fetches individual values.** Usually 1 is what we use, since it gets us everything in a single go, and* which we can also easily cache in local storage by saving the entire responsediff --git a/web/packages/new/photos/services/settings.ts b/web/packages/new/photos/services/settings.tsindex deaec985b8..c93a4e5513 100644--- a/web/packages/new/photos/services/settings.ts+++ b/web/packages/new/photos/services/settings.ts@@ -20,21 +20,21 @@ import { fetchFeatureFlags, updateRemoteFlag } from "./remote-store";** At a high level, this is how the app manages remote flags:*- * 1. On app start, the initial are read from local storage in- * {@link initSettings}.+ * 1. On app start, the initial are read from local storage in+ * {@link initSettings}.*- * 2. During the remote sync, remote flags are fetched and saved in local- * storage, and the in-memory state updated to reflect the latest values- * ({@link syncSettings}).+ * 2. During the remote sync, remote flags are fetched and saved in local+ * storage, and the in-memory state updated to reflect the latest values+ * ({@link syncSettings}).*- * 3. Updating a value also cause an unconditional fetch and update- * ({@link syncSettings}).+ * 3. Updating a value also cause an unconditional fetch and update+ * ({@link syncSettings}).*- * 4. The individual getter functions for the flags (e.g.- * {@link isInternalUser}) return the in-memory values, and so are suitable- * for frequent use during UI rendering.+ * 4. The individual getter functions for the flags (e.g.+ * {@link isInternalUser}) return the in-memory values, and so are suitable+ * for frequent use during UI rendering.*- * 5. Everything gets reset to the default state on {@link logoutSettings}.+ * 5. Everything gets reset to the default state on {@link logoutSettings}.*/export interface Settings {/**diff --git a/web/packages/new/photos/services/user-entity/index.ts b/web/packages/new/photos/services/user-entity/index.tsindex 803a177e66..cca744c21c 100644--- a/web/packages/new/photos/services/user-entity/index.ts+++ b/web/packages/new/photos/services/user-entity/index.ts@@ -222,16 +222,16 @@ export const updateOrCreateUserEntities = async (* Return the entity key that can be used to decrypt the encrypted contents of* user entities of the given {@link type}.*- * 1. See if we have the encrypted entity key present locally. If so, return- * the entity key by decrypting it using with the user's master key.+ * 1. See if we have the encrypted entity key present locally. If so, return the+ * entity key by decrypting it using with the user's master key.*- * 2. Otherwise fetch the encrypted entity key for that type from remote. If we- * get one, obtain the entity key by decrypt the encrypted one using the- * user's master key, save it locally for future use, and return it.+ * 2. Otherwise fetch the encrypted entity key for that type from remote. If we+ * get one, obtain the entity key by decrypt the encrypted one using the+ * user's master key, save it locally for future use, and return it.*- * 3. Otherwise generate a new entity key, encrypt it using the user's master- * key, putting the encrypted one to remote and also saving it locally, and- * return it.+ * 3. Otherwise generate a new entity key, encrypt it using the user's master+ * key, putting the encrypted one to remote and also saving it locally, and+ * return it.** See also, [Note: User entity keys].*/