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

24 lines
657 B
TypeScript

import { IFullWallet, fromPrivateKey } from 'ethereumjs-wallet';
import { toBuffer } from 'ethereumjs-util';
import Worker from 'worker-loader!./workers/fromV3.worker.ts';
export default function fromV3(
keystore: string,
password: string,
nonStrict: boolean
): Promise<IFullWallet> {
return new Promise((resolve, reject) => {
const worker = new Worker();
worker.postMessage({ keystore, password, nonStrict });
worker.onmessage = (ev: MessageEvent) => {
const data = ev.data;
try {
const wallet = fromPrivateKey(toBuffer(data));
resolve(wallet);
} catch (e) {
reject(e);
}
};
});
}