This commit is contained in:
Manav Rathi 2024-08-17 21:33:15 +05:30
parent 9ae5006a4a
commit 0240b37032
No known key found for this signature in database
3 changed files with 11 additions and 35 deletions

View File

@ -1,11 +1,6 @@
/** Careful when adding add other imports! */
import * as libsodium from "./libsodium";
import type {
BytesOrB64,
DecryptBlobB64,
EncryptedBlob_2,
EncryptJSON,
} from "./types";
import type { BytesOrB64, EncryptedBlob_2, EncryptJSON } from "./types";
export const _encryptBoxB64 = libsodium.encryptBoxB64;
@ -55,7 +50,11 @@ export const _decryptMetadataJSON_New = async (
new TextDecoder().decode(await _decryptBlob(blob, key)),
) as unknown;
export const _decryptMetadataJSON = async (r: DecryptBlobB64) =>
export const _decryptMetadataJSON = async (r: {
encryptedDataB64: string;
decryptionHeaderB64: string;
keyB64: string;
}) =>
_decryptMetadataJSON_New(
{
encryptedData: r.encryptedDataB64,

View File

@ -53,7 +53,6 @@ import { inWorker } from "../env";
import * as ei from "./ente-impl";
import type {
BytesOrB64,
DecryptBlobB64,
EncryptedBlob_2,
EncryptedBox2,
EncryptJSON,
@ -202,7 +201,11 @@ export const decryptMetadataJSON_New = (
/**
* Deprecated, retains the old API.
*/
export const decryptMetadataJSON = (r: DecryptBlobB64) =>
export const decryptMetadataJSON = (r: {
encryptedDataB64: string;
decryptionHeaderB64: string;
keyB64: string;
}) =>
inWorker()
? ei._decryptMetadataJSON(r)
: sharedCryptoWorker().then((w) => w.decryptMetadataJSON(r));

View File

@ -4,7 +4,6 @@
*/
export type BytesOrB64 = Uint8Array | string;
/**
* Deprecated.
*
@ -125,28 +124,3 @@ export interface EncryptedBlobB64_2 {
*/
decryptionHeader: string;
}
/**
* Deprecated.
*
* A variant of {@link DecryptBlobBytes} with the encrypted Blob's data as a
* base64 encoded string.
*/
export interface DecryptBlobB64 {
/**
* A base64 string containing the data to decrypt.
*/
encryptedDataB64: string;
/**
* A base64 string containing the decryption header that was produced during
* encryption.
*
* The header contains a random nonce and other libsodium metadata. It does
* not need to be kept secret.
*/
decryptionHeaderB64: string;
/**
* A base64 string containing the encryption key.
*/
keyB64: string;
}