Manav Rathi 004dd3bd0c
Rearrange to make webpack happy
Something in the previous arrangement was causing webpack to not pack
worker/worker.ts as a web worker.
2024-08-10 20:28:17 +05:30

23 lines
772 B
TypeScript

import { sharedCryptoWorker } from "@/base/crypto";
import type { B64EncryptionResult } from "@/base/crypto/libsodium";
import { CustomError } from "@ente/shared/error";
import { getKey, SESSION_KEYS } from "@ente/shared/storage/sessionStorage";
export const getActualKey = async () => {
try {
const encryptionKeyAttributes: B64EncryptionResult = getKey(
SESSION_KEYS.ENCRYPTION_KEY,
);
const cryptoWorker = await sharedCryptoWorker();
const key = await cryptoWorker.decryptB64(
encryptionKeyAttributes.encryptedData,
encryptionKeyAttributes.nonce,
encryptionKeyAttributes.key,
);
return key;
} catch (e) {
throw new Error(CustomError.KEY_MISSING);
}
};