mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-11 11:34:26 +00:00
174dea8a29
* 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.
23 lines
721 B
TypeScript
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 });
|
|
};
|
|
});
|
|
}
|