Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const decrypt = async (event) => {
try {
const { passphrase, keystoreV3 } = event.data;
const privateKey = await decryptPrivateKey(passphrase, keystoreV3);
// @ts-ignore
self.postMessage({ privateKey });
} catch (error) {
console.log(error);
// @ts-ignore
self.postMessage({ privateKey: undefined });
}
};
static async fromFile(file: string, passphrase: string): Promise {
try {
const keystore = JSON.parse(file);
const privateKey = await zcrypto.decryptPrivateKey(passphrase, keystore);
return new Account(privateKey);
} catch (err) {
throw new Error(`Could not decrypt keystore file.`);
}
}