This commit is contained in:
Manav Rathi
2024-08-05 10:34:01 +05:30
parent 0bff899713
commit 32a602725a
4 changed files with 9 additions and 10 deletions

View File

@@ -1119,7 +1119,7 @@ const encryptFile = async (
worker,
);
const { file: encryptedThumbnail } = await worker.encryptThumbnail(
const encryptedThumbnail = await worker.encryptThumbnail(
file.thumbnail,
fileKey,
);

View File

@@ -23,7 +23,7 @@ export const encryptFileMetadata = async (
metadata: Uint8Array,
keyB64: string,
) => {
const { file } = await libsodium.encryptChaChaOneShot(metadata, keyB64);
const file = await libsodium.encryptChaChaOneShot(metadata, keyB64);
return {
encryptedMetadataB64: await libsodium.toB64(file.encryptedData),
decryptionHeaderB64: file.decryptionHeader,

View File

@@ -49,8 +49,10 @@ export class DedicatedCryptoWorker {
async encryptMetadata(metadata: Object, key: string) {
const encodedMetadata = textEncoder.encode(JSON.stringify(metadata));
const { file: encryptedMetadata } =
await libsodium.encryptChaChaOneShot(encodedMetadata, key);
const encryptedMetadata = await libsodium.encryptChaChaOneShot(
encodedMetadata,
key,
);
const { encryptedData, ...other } = encryptedMetadata;
return {
file: {
@@ -69,7 +71,7 @@ export class DedicatedCryptoWorker {
const encodedEmbedding = textEncoder.encode(
JSON.stringify(Array.from(embedding)),
);
const { file: encryptEmbedding } = await libsodium.encryptChaChaOneShot(
const encryptEmbedding = await libsodium.encryptChaChaOneShot(
encodedEmbedding,
key,
);

View File

@@ -144,11 +144,8 @@ export async function encryptChaChaOneShot(data: Uint8Array, key: string) {
sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL,
);
return {
key: await toB64(uintkey),
file: {
encryptedData: pushResult,
decryptionHeader: await toB64(header),
},
encryptedData: pushResult,
decryptionHeader: await toB64(header),
};
}