From 52ef03555e00aef27c24cd9efb4c2ddd4f4dd8ff Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Tue, 19 Jan 2021 10:02:12 +0530 Subject: [PATCH] updated collectionService to handle keys in base64 format --- src/services/collectionService.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/services/collectionService.ts b/src/services/collectionService.ts index 378bf0084..238c3014a 100644 --- a/src/services/collectionService.ts +++ b/src/services/collectionService.ts @@ -65,9 +65,9 @@ const getCollectionKey = async (collection: collection, masterKey: string) => { masterKey ); decryptedKey = await worker.boxSealOpen( - await worker.fromB64(collection.encryptedKey), - await worker.fromB64(keyAttributes.publicKey), - await worker.fromB64(secretKey) + await collection.encryptedKey, + await keyAttributes.publicKey, + await secretKey ); } return { @@ -123,7 +123,7 @@ export const AddCollection = async (albumName: string, type: CollectionType) => const worker = await new CryptoWorker(); const encryptionKey = await getActualKey(); const token = getToken(); - const collectionKey: Uint8Array = await worker.generateMasterKey(); + const collectionKey: string = await worker.generateMasterKey(); const { encryptedData: encryptedKey, nonce: keyDecryptionNonce }: keyEncryptionResult = await worker.encryptToB64(collectionKey, encryptionKey); const newCollection: collection = { id: null, @@ -157,14 +157,13 @@ export const addToFavorites = async (file: file) => { } const addtoCollection = async (collection: collection, files: file[]) => { - console.log(collection, files); const params = new Object(); const worker = await new CryptoWorker(); const token = getToken(); params["collectionID"] = collection.id; const newFiles: file[] = await Promise.all(files.map(async file => { file.collectionID = Number(collection.id); - const newEncryptedKey: keyEncryptionResult = await worker.encryptToB64(await worker.fromB64(file.key), collection.key); + const newEncryptedKey: keyEncryptionResult = await worker.encryptToB64(file.key, collection.key); file.encryptedKey = newEncryptedKey.encryptedData; file.keyDecryptionNonce = newEncryptedKey.nonce; if (params["files"] == undefined) {