Unnest
This commit is contained in:
@@ -1119,7 +1119,7 @@ const encryptFile = async (
|
||||
worker,
|
||||
);
|
||||
|
||||
const { file: encryptedThumbnail } = await worker.encryptThumbnail(
|
||||
const encryptedThumbnail = await worker.encryptThumbnail(
|
||||
file.thumbnail,
|
||||
fileKey,
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user