used boxSeal to encypt collection key for sharing

This commit is contained in:
Abhinav-grd 2021-04-28 14:21:26 +05:30
parent e039aeb4ba
commit 43ebfbf116

View file

@ -102,7 +102,10 @@ const getCollections = async (
);
const promises: Promise<Collection>[] = resp.data.collections.map(
async (collection: Collection) => {
let collectionWithSecrets = { ...collection, key: null };
if (collection.isDeleted) {
return collection;
}
let collectionWithSecrets = collection;
try {
collectionWithSecrets = await getCollectionWithSecrets(
collection,
@ -118,10 +121,7 @@ const getCollections = async (
}
}
);
const collections = (await Promise.all(promises)).filter(
(collection) => collection.key !== null
);
return collections;
return await Promise.all(promises);
} catch (e) {
console.error('getCollections failed- ', e);
ErrorHandler(e);
@ -432,7 +432,7 @@ export const shareCollection = async (
const token = getToken();
const publicKey: string = await getPublicKey(withUserEmail);
const encryptedKey: B64EncryptionResult = await worker.encryptToB64(
const encryptedKey: B64EncryptionResult = await worker.boxSeal(
collection.key,
publicKey
);