MyCrypto/common/libs/web-workers/generateKeystore.ts
William O'Beirne 174dea8a29 MEW-01-004 - Stronger Keystores (#981)
* Add better password checking, confirm password, feedback, and up the minimum to 12.

* Move wallet generation off to a web worker, and bump up the n value to 8192. Refactor workers a wee bit.

* tscheck cleanup

* Make keystore password a form. Replace text with spinner on load.

* Center align again.

* Hard code n factor of test wallet, fix some misspelled type definitions for IV3Wallet.
2018-02-02 00:01:30 -06:00

23 lines
721 B
TypeScript

import { IV3Wallet } from 'ethereumjs-wallet';
import { N_FACTOR } from 'config';
import Worker from 'worker-loader!./workers/generateKeystore.worker.ts';
interface KeystorePayload {
filename: string;
keystore: IV3Wallet;
privateKey: string;
}
export default function generateKeystore(password: string): Promise<KeystorePayload> {
return new Promise(resolve => {
const worker = new Worker();
worker.postMessage({ password, N_FACTOR });
worker.onmessage = (ev: MessageEvent) => {
const filename: string = ev.data.filename;
const privateKey: string = ev.data.privateKey;
const keystore: IV3Wallet = ev.data.keystore;
resolve({ keystore, filename, privateKey });
};
});
}