Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Update types

Manav Rathi08c3b172d974
diff --git a/web/packages/base/crypto/ente-impl.ts b/web/packages/base/crypto/ente-impl.ts
index 6e3115795b..ebd6055b5c 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_2 } from "./types";
+import type { BytesOrB64, EncryptedBlob } from "./types";
export const _encryptBoxB64 = libsodium.encryptBoxB64;
@@ -45,7 +45,7 @@ export const _decryptBlobB64 = libsodium.decryptBlobB64;
export const _decryptThumbnail = _decryptBlob;
export const _decryptMetadataJSON_New = async (
- blob: EncryptedBlob_2,
+ blob: EncryptedBlob,
key: BytesOrB64,
) =>
JSON.parse(
diff --git a/web/packages/base/crypto/ente.ts b/web/packages/base/crypto/ente.ts
index 7585f961bd..476e589505 100644
--- a/web/packages/base/crypto/ente.ts
+++ b/web/packages/base/crypto/ente.ts
@@ -51,7 +51,7 @@ import { sharedCryptoWorker } from ".";
import { assertionFailed } from "../assert";
import { inWorker } from "../env";
import * as ei from "./ente-impl";
-import type { BytesOrB64, EncryptedBlob_2, EncryptedBox2 } from "./types";
+import type { BytesOrB64, EncryptedBlob, EncryptedBox } from "./types";
/**
* Some of these functions have not yet been needed on the main thread, and for
@@ -161,7 +161,7 @@ export const encryptMetadataJSON = async (r: {
/**
* Decrypt a box encrypted using {@link encryptBoxB64}.
*/
-export const decryptBox = (box: EncryptedBox2, key: BytesOrB64) =>
+export const decryptBox = (box: EncryptedBox, key: BytesOrB64) =>
inWorker()
? ei._decryptBox(box, key)
: sharedCryptoWorker().then((w) => w.decryptBox(box, key));
@@ -169,7 +169,7 @@ export const decryptBox = (box: EncryptedBox2, key: BytesOrB64) =>
/**
* Variant of {@link decryptBox} that returns the result as a base64 string.
*/
-export const decryptBoxB64 = (box: EncryptedBox2, key: BytesOrB64) =>
+export const decryptBoxB64 = (box: EncryptedBox, key: BytesOrB64) =>
inWorker()
? ei._decryptBoxB64(box, key)
: sharedCryptoWorker().then((w) => w.decryptBoxB64(box, key));
@@ -178,13 +178,13 @@ export const decryptBoxB64 = (box: EncryptedBox2, key: BytesOrB64) =>
* Decrypt a blob encrypted using either {@link encryptBlob} or
* {@link encryptBlobB64}.
*/
-export const decryptBlob = (blob: EncryptedBlob_2, key: BytesOrB64) =>
+export const decryptBlob = (blob: EncryptedBlob, key: BytesOrB64) =>
assertInWorker(ei._decryptBlob(blob, key));
/**
* A variant of {@link decryptBlob} that returns the result as a base64 string.
*/
-export const decryptBlobB64 = (blob: EncryptedBlob_2, key: BytesOrB64) =>
+export const decryptBlobB64 = (blob: EncryptedBlob, key: BytesOrB64) =>
inWorker()
? ei._decryptBlobB64(blob, key)
: sharedCryptoWorker().then((w) => w.decryptBlobB64(blob, key));
@@ -192,7 +192,7 @@ export const decryptBlobB64 = (blob: EncryptedBlob_2, key: BytesOrB64) =>
/**
* Decrypt the thumbnail encrypted using {@link encryptThumbnail}.
*/
-export const decryptThumbnail = (blob: EncryptedBlob_2, key: BytesOrB64) =>
+export const decryptThumbnail = (blob: EncryptedBlob, key: BytesOrB64) =>
assertInWorker(ei._decryptThumbnail(blob, key));
/**
@@ -202,7 +202,7 @@ export const decryptThumbnail = (blob: EncryptedBlob_2, key: BytesOrB64) =>
* JSON type, we need to return it as an `unknown`.
*/
export const decryptMetadataJSON_New = (
- blob: EncryptedBlob_2,
+ blob: EncryptedBlob,
key: BytesOrB64,
) =>
inWorker()
diff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.ts
index 5a1376fa79..29546d567f 100644
--- a/web/packages/base/crypto/libsodium.ts
+++ b/web/packages/base/crypto/libsodium.ts
@@ -13,10 +13,10 @@ import { CustomError } from "@ente/shared/error";
import sodium, { type StateAddress } from "libsodium-wrappers";
import type {
BytesOrB64,
- EncryptedBlob_2,
- EncryptedBlobB64_2,
- EncryptedBlobBytes_2,
- EncryptedBox2,
+ EncryptedBlob,
+ EncryptedBlobB64,
+ EncryptedBlobBytes,
+ EncryptedBox,
EncryptedBoxB64,
} from "./types";
@@ -258,7 +258,7 @@ export const encryptBoxB64 = async (
export const encryptBlob = async (
data: BytesOrB64,
key: BytesOrB64,
-): Promise<EncryptedBlobBytes_2> => {
+): Promise<EncryptedBlobBytes> => {
await sodium.ready;
const uintkey = await bytes(key);
@@ -285,7 +285,7 @@ export const encryptBlob = async (
export const encryptBlobB64 = async (
data: BytesOrB64,
key: BytesOrB64,
-): Promise<EncryptedBlobB64_2> => {
+): Promise<EncryptedBlobB64> => {
const { encryptedData, decryptionHeader } = await encryptBlob(data, key);
return {
encryptedData: await toB64(encryptedData),
@@ -371,7 +371,7 @@ export async function encryptFileChunk(
* Decrypt the result of {@link encryptBoxB64}.
*/
export const decryptBox2 = async (
- { encryptedData, nonce }: EncryptedBox2,
+ { encryptedData, nonce }: EncryptedBox,
key: BytesOrB64,
): Promise<Uint8Array> => {
await sodium.ready;
@@ -386,7 +386,7 @@ export const decryptBox2 = async (
* Variant of {@link decryptBox} that returns the data as a base64 string.
*/
export const decryptBoxB64 = (
- box: EncryptedBox2,
+ box: EncryptedBox,
key: BytesOrB64,
): Promise<string> => decryptBox2(box, key).then(toB64);
@@ -394,7 +394,7 @@ export const decryptBoxB64 = (
* Decrypt the result of {@link encryptBlob} or {@link encryptBlobB64}.
*/
export const decryptBlob2 = async (
- { encryptedData, decryptionHeader }: EncryptedBlob_2,
+ { encryptedData, decryptionHeader }: EncryptedBlob,
key: BytesOrB64,
): Promise<Uint8Array> => {
await sodium.ready;
@@ -414,7 +414,7 @@ export const decryptBlob2 = async (
* A variant of {@link decryptBlob2} that returns the result as a base64 string.
*/
export const decryptBlobB64 = (
- blob: EncryptedBlob_2,
+ blob: EncryptedBlob,
key: BytesOrB64,
): Promise<string> => decryptBlob2(blob, key).then(toB64);
diff --git a/web/packages/base/crypto/types.ts b/web/packages/base/crypto/types.ts
index d4c972e8c6..a70c5b3aa9 100644
--- a/web/packages/base/crypto/types.ts
+++ b/web/packages/base/crypto/types.ts
@@ -13,7 +13,7 @@ export type BytesOrB64 = Uint8Array | string;
*
* See: [Note: 3 forms of encryption (Box | Blob | Stream)].
*/
-export interface EncryptedBox2 {
+export interface EncryptedBox {
/**
* The data to decrypt.
*/
@@ -49,11 +49,11 @@ export interface EncryptedBoxB64 {
*
* See: [Note: 3 forms of encryption (Box | Blob | Stream)].
*
- * This type is a combination of {@link EncryptedBlobBytes_2} and
- * {@link EncryptedBlobB64_2} which allows the decryption routines to accept
+ * This type is a combination of {@link EncryptedBlobBytes} and
+ * {@link EncryptedBlobB64} which allows the decryption routines to accept
* either the bytes or the base64 variants produced by the encryption routines.
*/
-export interface EncryptedBlob_2 {
+export interface EncryptedBlob {
/**
* The encrypted data.
*/
@@ -69,10 +69,10 @@ export interface EncryptedBlob_2 {
}
/**
- * A variant of {@link EncryptedBlob_2} that has the encrypted data and header
+ * A variant of {@link EncryptedBlob} that has the encrypted data and header
* as bytes ({@link Uint8Array}s).
*/
-export interface EncryptedBlobBytes_2 {
+export interface EncryptedBlobBytes {
/**
* The encrypted data.
*/
@@ -88,10 +88,10 @@ export interface EncryptedBlobBytes_2 {
}
/**
- * A variant of {@link EncryptedBlob_2} that has the encrypted data and header
+ * A variant of {@link EncryptedBlob} that has the encrypted data and header
* as base64 strings.
*/
-export interface EncryptedBlobB64_2 {
+export interface EncryptedBlobB64 {
/**
* The encrypted data as a base64 string.
*/