Updated dist files.
This commit is contained in:
parent
6809c370c0
commit
7d34f73769
12
CHANGELOG.md
12
CHANGELOG.md
@ -3,6 +3,18 @@ Changelog
|
|||||||
|
|
||||||
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
|
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
|
||||||
|
|
||||||
|
ethers/v5.0.0-beta.175 (2020-02-27 19:53)
|
||||||
|
-----------------------------------------
|
||||||
|
|
||||||
|
- Fix address-less filter listening in Provider. ([#741](https://github.com/ethers-io/ethers.js/issues/741); [64dccb2](https://github.com/ethers-io/ethers.js/commit/64dccb275c68ebb40328350d4ab5be0f29b8a02e))
|
||||||
|
- Added sync version of wallet decryption. ([0ad94cd](https://github.com/ethers-io/ethers.js/commit/0ad94cdf8137259bedb38c0dc949b61570bcdac0), [6809c37](https://github.com/ethers-io/ethers.js/commit/6809c370c027aea148466c00d3ce09c6d0ee6ddc))
|
||||||
|
|
||||||
|
ethers/v5.0.0-beta.175 (2020-02-27 19:38)
|
||||||
|
-----------------------------------------
|
||||||
|
|
||||||
|
- Fix address-less filter listening in Provider. ([#741](https://github.com/ethers-io/ethers.js/issues/741); [64dccb2](https://github.com/ethers-io/ethers.js/commit/64dccb275c68ebb40328350d4ab5be0f29b8a02e))
|
||||||
|
- Added sync version of wallet decryption. ([0ad94cd](https://github.com/ethers-io/ethers.js/commit/0ad94cdf8137259bedb38c0dc949b61570bcdac0))
|
||||||
|
|
||||||
ethers/v5.0.0-beta.174 (2020-02-25 14:57)
|
ethers/v5.0.0-beta.174 (2020-02-25 14:57)
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
|
2
packages/asm/lib.esm/_version.d.ts
vendored
2
packages/asm/lib.esm/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "asm/5.0.0-beta.150";
|
export declare const version = "asm/5.0.0-beta.151";
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "asm/5.0.0-beta.150";
|
export const version = "asm/5.0.0-beta.151";
|
||||||
|
2
packages/asm/lib/_version.d.ts
vendored
2
packages/asm/lib/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "asm/5.0.0-beta.150";
|
export declare const version = "asm/5.0.0-beta.151";
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "asm/5.0.0-beta.150";
|
exports.version = "asm/5.0.0-beta.151";
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
"generate": "node ./generate.js",
|
"generate": "node ./generate.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0xcb545068ae8f11aa8ae48f849b1136553c08eebbaba814fa23ac29f6f8011e89",
|
"tarballHash": "0x365816acb3e61390e82f1aff465687c0216af2855d08ba1d46cbf147b1493b9b",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.150"
|
"version": "5.0.0-beta.151"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "asm/5.0.0-beta.150";
|
export const version = "asm/5.0.0-beta.151";
|
||||||
|
2
packages/ethers/dist/ethers-all.esm.min.js
vendored
2
packages/ethers/dist/ethers-all.esm.min.js
vendored
File diff suppressed because one or more lines are too long
2
packages/ethers/dist/ethers-all.umd.min.js
vendored
2
packages/ethers/dist/ethers-all.umd.min.js
vendored
File diff suppressed because one or more lines are too long
277
packages/ethers/dist/ethers.esm.js
vendored
277
packages/ethers/dist/ethers.esm.js
vendored
@ -13958,7 +13958,7 @@ var aesJs = createCommonjsModule(function (module, exports) {
|
|||||||
})(commonjsGlobal);
|
})(commonjsGlobal);
|
||||||
});
|
});
|
||||||
|
|
||||||
const version$f = "json-wallets/5.0.0-beta.136";
|
const version$f = "json-wallets/5.0.0-beta.137";
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
function looseArrayify(hexString) {
|
function looseArrayify(hexString) {
|
||||||
@ -14580,6 +14580,12 @@ var scrypt = createCommonjsModule(function (module, exports) {
|
|||||||
});
|
});
|
||||||
var scrypt_1 = scrypt.scrypt;
|
var scrypt_1 = scrypt.scrypt;
|
||||||
|
|
||||||
|
var scrypt$1 = /*#__PURE__*/Object.freeze({
|
||||||
|
'default': scrypt,
|
||||||
|
__moduleExports: scrypt,
|
||||||
|
scrypt: scrypt_1
|
||||||
|
});
|
||||||
|
|
||||||
var rng;
|
var rng;
|
||||||
|
|
||||||
if (commonjsGlobal.crypto && crypto.getRandomValues) {
|
if (commonjsGlobal.crypto && crypto.getRandomValues) {
|
||||||
@ -14814,130 +14820,137 @@ class KeystoreAccount extends Description {
|
|||||||
return !!(value && value._isKeystoreAccount);
|
return !!(value && value._isKeystoreAccount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function _decrypt(data, key, ciphertext) {
|
||||||
|
const cipher = searchPath(data, "crypto/cipher");
|
||||||
|
if (cipher === "aes-128-ctr") {
|
||||||
|
const iv = looseArrayify(searchPath(data, "crypto/cipherparams/iv"));
|
||||||
|
const counter = new aesJs.Counter(iv);
|
||||||
|
const aesCtr = new aesJs.ModeOfOperation.ctr(key, counter);
|
||||||
|
return arrayify(aesCtr.decrypt(ciphertext));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
function _getAccount(data, key) {
|
||||||
|
const ciphertext = looseArrayify(searchPath(data, "crypto/ciphertext"));
|
||||||
|
const computedMAC = hexlify(keccak256(concat([key.slice(16, 32), ciphertext]))).substring(2);
|
||||||
|
if (computedMAC !== searchPath(data, "crypto/mac").toLowerCase()) {
|
||||||
|
throw new Error("invalid password");
|
||||||
|
}
|
||||||
|
const privateKey = _decrypt(data, key.slice(0, 16), ciphertext);
|
||||||
|
if (!privateKey) {
|
||||||
|
logger$j.throwError("unsupported cipher", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||||
|
operation: "decrypt"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const mnemonicKey = key.slice(32, 64);
|
||||||
|
const address = computeAddress(privateKey);
|
||||||
|
if (data.address) {
|
||||||
|
let check = data.address.toLowerCase();
|
||||||
|
if (check.substring(0, 2) !== "0x") {
|
||||||
|
check = "0x" + check;
|
||||||
|
}
|
||||||
|
if (getAddress(check) !== address) {
|
||||||
|
throw new Error("address mismatch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const account = {
|
||||||
|
_isKeystoreAccount: true,
|
||||||
|
address: address,
|
||||||
|
privateKey: hexlify(privateKey)
|
||||||
|
};
|
||||||
|
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
||||||
|
if (searchPath(data, "x-ethers/version") === "0.1") {
|
||||||
|
const mnemonicCiphertext = looseArrayify(searchPath(data, "x-ethers/mnemonicCiphertext"));
|
||||||
|
const mnemonicIv = looseArrayify(searchPath(data, "x-ethers/mnemonicCounter"));
|
||||||
|
const mnemonicCounter = new aesJs.Counter(mnemonicIv);
|
||||||
|
const mnemonicAesCtr = new aesJs.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
|
||||||
|
const path = searchPath(data, "x-ethers/path") || defaultPath;
|
||||||
|
const locale = searchPath(data, "x-ethers/locale") || "en";
|
||||||
|
const entropy = arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext));
|
||||||
|
try {
|
||||||
|
const mnemonic = entropyToMnemonic(entropy, locale);
|
||||||
|
const node = HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
|
||||||
|
if (node.privateKey != account.privateKey) {
|
||||||
|
throw new Error("mnemonic mismatch");
|
||||||
|
}
|
||||||
|
account.mnemonic = node.mnemonic;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
// If we don't have the locale wordlist installed to
|
||||||
|
// read this mnemonic, just bail and don't set the
|
||||||
|
// mnemonic
|
||||||
|
if (error.code !== Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new KeystoreAccount(account);
|
||||||
|
}
|
||||||
|
function pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc) {
|
||||||
|
return arrayify(browser_1$1(passwordBytes, salt, count, dkLen, prfFunc));
|
||||||
|
}
|
||||||
|
function pbkdf2(passwordBytes, salt, count, dkLen, prfFunc) {
|
||||||
|
return Promise.resolve(pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc));
|
||||||
|
}
|
||||||
|
function _computeKdfKey(data, password, pbkdf2Func, scryptFunc, progressCallback) {
|
||||||
|
const passwordBytes = getPassword(password);
|
||||||
|
const kdf = searchPath(data, "crypto/kdf");
|
||||||
|
if (kdf && typeof (kdf) === "string") {
|
||||||
|
const throwError = function (name, value) {
|
||||||
|
return logger$j.throwArgumentError("invalid key-derivation function parameters", name, value);
|
||||||
|
};
|
||||||
|
if (kdf.toLowerCase() === "scrypt") {
|
||||||
|
const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt"));
|
||||||
|
const N = parseInt(searchPath(data, "crypto/kdfparams/n"));
|
||||||
|
const r = parseInt(searchPath(data, "crypto/kdfparams/r"));
|
||||||
|
const p = parseInt(searchPath(data, "crypto/kdfparams/p"));
|
||||||
|
// Check for all required parameters
|
||||||
|
if (!N || !r || !p) {
|
||||||
|
throwError("kdf", kdf);
|
||||||
|
}
|
||||||
|
// Make sure N is a power of 2
|
||||||
|
if ((N & (N - 1)) !== 0) {
|
||||||
|
throwError("N", N);
|
||||||
|
}
|
||||||
|
const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen"));
|
||||||
|
if (dkLen !== 32) {
|
||||||
|
throwError("dklen", dkLen);
|
||||||
|
}
|
||||||
|
return scryptFunc(passwordBytes, salt, N, r, p, 64, progressCallback);
|
||||||
|
}
|
||||||
|
else if (kdf.toLowerCase() === "pbkdf2") {
|
||||||
|
const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt"));
|
||||||
|
let prfFunc = null;
|
||||||
|
const prf = searchPath(data, "crypto/kdfparams/prf");
|
||||||
|
if (prf === "hmac-sha256") {
|
||||||
|
prfFunc = "sha256";
|
||||||
|
}
|
||||||
|
else if (prf === "hmac-sha512") {
|
||||||
|
prfFunc = "sha512";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throwError("prf", prf);
|
||||||
|
}
|
||||||
|
const count = parseInt(searchPath(data, "crypto/kdfparams/c"));
|
||||||
|
const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen"));
|
||||||
|
if (dkLen !== 32) {
|
||||||
|
throwError("dklen", dkLen);
|
||||||
|
}
|
||||||
|
return pbkdf2Func(passwordBytes, salt, count, dkLen, prfFunc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return logger$j.throwArgumentError("unsupported key-derivation function", "kdf", kdf);
|
||||||
|
}
|
||||||
|
function decryptSync(json, password) {
|
||||||
|
const data = JSON.parse(json);
|
||||||
|
const key = _computeKdfKey(data, password, pbkdf2Sync, undefined);
|
||||||
|
return _getAccount(data, key);
|
||||||
|
}
|
||||||
function decrypt$1(json, password, progressCallback) {
|
function decrypt$1(json, password, progressCallback) {
|
||||||
return __awaiter$1(this, void 0, void 0, function* () {
|
return __awaiter$1(this, void 0, void 0, function* () {
|
||||||
const data = JSON.parse(json);
|
const data = JSON.parse(json);
|
||||||
const passwordBytes = getPassword(password);
|
const key = yield _computeKdfKey(data, password, pbkdf2, scrypt_1, progressCallback);
|
||||||
const decrypt = function (key, ciphertext) {
|
return _getAccount(data, key);
|
||||||
const cipher = searchPath(data, "crypto/cipher");
|
|
||||||
if (cipher === "aes-128-ctr") {
|
|
||||||
const iv = looseArrayify(searchPath(data, "crypto/cipherparams/iv"));
|
|
||||||
const counter = new aesJs.Counter(iv);
|
|
||||||
const aesCtr = new aesJs.ModeOfOperation.ctr(key, counter);
|
|
||||||
return arrayify(aesCtr.decrypt(ciphertext));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
const computeMAC = function (derivedHalf, ciphertext) {
|
|
||||||
return keccak256(concat([derivedHalf, ciphertext]));
|
|
||||||
};
|
|
||||||
const getAccount = function (key) {
|
|
||||||
return __awaiter$1(this, void 0, void 0, function* () {
|
|
||||||
const ciphertext = looseArrayify(searchPath(data, "crypto/ciphertext"));
|
|
||||||
const computedMAC = hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2);
|
|
||||||
if (computedMAC !== searchPath(data, "crypto/mac").toLowerCase()) {
|
|
||||||
throw new Error("invalid password");
|
|
||||||
}
|
|
||||||
const privateKey = decrypt(key.slice(0, 16), ciphertext);
|
|
||||||
const mnemonicKey = key.slice(32, 64);
|
|
||||||
if (!privateKey) {
|
|
||||||
logger$j.throwError("unsupported cipher", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
||||||
operation: "decrypt"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const address = computeAddress(privateKey);
|
|
||||||
if (data.address) {
|
|
||||||
let check = data.address.toLowerCase();
|
|
||||||
if (check.substring(0, 2) !== "0x") {
|
|
||||||
check = "0x" + check;
|
|
||||||
}
|
|
||||||
if (getAddress(check) !== address) {
|
|
||||||
throw new Error("address mismatch");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const account = {
|
|
||||||
_isKeystoreAccount: true,
|
|
||||||
address: address,
|
|
||||||
privateKey: hexlify(privateKey)
|
|
||||||
};
|
|
||||||
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
|
||||||
if (searchPath(data, "x-ethers/version") === "0.1") {
|
|
||||||
const mnemonicCiphertext = looseArrayify(searchPath(data, "x-ethers/mnemonicCiphertext"));
|
|
||||||
const mnemonicIv = looseArrayify(searchPath(data, "x-ethers/mnemonicCounter"));
|
|
||||||
const mnemonicCounter = new aesJs.Counter(mnemonicIv);
|
|
||||||
const mnemonicAesCtr = new aesJs.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
|
|
||||||
const path = searchPath(data, "x-ethers/path") || defaultPath;
|
|
||||||
const locale = searchPath(data, "x-ethers/locale") || "en";
|
|
||||||
const entropy = arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext));
|
|
||||||
try {
|
|
||||||
const mnemonic = entropyToMnemonic(entropy, locale);
|
|
||||||
const node = HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
|
|
||||||
if (node.privateKey != account.privateKey) {
|
|
||||||
throw new Error("mnemonic mismatch");
|
|
||||||
}
|
|
||||||
account.mnemonic = node.mnemonic;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
// If we don't have the locale wordlist installed to
|
|
||||||
// read this mnemonic, just bail and don't set the
|
|
||||||
// mnemonic
|
|
||||||
if (error.code !== Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new KeystoreAccount(account);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const kdf = searchPath(data, "crypto/kdf");
|
|
||||||
if (kdf && typeof (kdf) === "string") {
|
|
||||||
const throwError = function (name, value) {
|
|
||||||
return logger$j.throwArgumentError("invalid key-derivation function parameters", name, value);
|
|
||||||
};
|
|
||||||
if (kdf.toLowerCase() === "scrypt") {
|
|
||||||
const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt"));
|
|
||||||
const N = parseInt(searchPath(data, "crypto/kdfparams/n"));
|
|
||||||
const r = parseInt(searchPath(data, "crypto/kdfparams/r"));
|
|
||||||
const p = parseInt(searchPath(data, "crypto/kdfparams/p"));
|
|
||||||
// Check for all required parameters
|
|
||||||
if (!N || !r || !p) {
|
|
||||||
throwError("kdf", kdf);
|
|
||||||
}
|
|
||||||
// Make sure N is a power of 2
|
|
||||||
if ((N & (N - 1)) !== 0) {
|
|
||||||
throwError("N", N);
|
|
||||||
}
|
|
||||||
const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen"));
|
|
||||||
if (dkLen !== 32) {
|
|
||||||
throwError("dklen", dkLen);
|
|
||||||
}
|
|
||||||
const key = yield scrypt_1(passwordBytes, salt, N, r, p, 64, progressCallback);
|
|
||||||
//key = arrayify(key);
|
|
||||||
return getAccount(key);
|
|
||||||
}
|
|
||||||
else if (kdf.toLowerCase() === "pbkdf2") {
|
|
||||||
const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt"));
|
|
||||||
let prfFunc = null;
|
|
||||||
const prf = searchPath(data, "crypto/kdfparams/prf");
|
|
||||||
if (prf === "hmac-sha256") {
|
|
||||||
prfFunc = "sha256";
|
|
||||||
}
|
|
||||||
else if (prf === "hmac-sha512") {
|
|
||||||
prfFunc = "sha512";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throwError("prf", prf);
|
|
||||||
}
|
|
||||||
const c = parseInt(searchPath(data, "crypto/kdfparams/c"));
|
|
||||||
const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen"));
|
|
||||||
if (dkLen !== 32) {
|
|
||||||
throwError("dklen", dkLen);
|
|
||||||
}
|
|
||||||
const key = arrayify(browser_1$1(passwordBytes, salt, c, dkLen, prfFunc));
|
|
||||||
return getAccount(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return logger$j.throwArgumentError("unsupported key-derivation function", "kdf", kdf);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function encrypt(account, password, options, progressCallback) {
|
function encrypt(account, password, options, progressCallback) {
|
||||||
@ -15107,8 +15120,17 @@ function decryptJsonWallet(json, password, progressCallback) {
|
|||||||
}
|
}
|
||||||
return Promise.reject(new Error("invalid JSON wallet"));
|
return Promise.reject(new Error("invalid JSON wallet"));
|
||||||
}
|
}
|
||||||
|
function decryptJsonWalletSync(json, password) {
|
||||||
|
if (isCrowdsaleWallet(json)) {
|
||||||
|
return decrypt(json, password);
|
||||||
|
}
|
||||||
|
if (isKeystoreWallet(json)) {
|
||||||
|
return decryptSync(json, password);
|
||||||
|
}
|
||||||
|
throw new Error("invalid JSON wallet");
|
||||||
|
}
|
||||||
|
|
||||||
const version$g = "wallet/5.0.0-beta.137";
|
const version$g = "wallet/5.0.0-beta.138";
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
const logger$k = new Logger(version$g);
|
const logger$k = new Logger(version$g);
|
||||||
@ -15222,6 +15244,9 @@ class Wallet extends Signer {
|
|||||||
return new Wallet(account);
|
return new Wallet(account);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
static fromEncryptedJsonSync(json, password) {
|
||||||
|
return new Wallet(decryptJsonWalletSync(json, password));
|
||||||
|
}
|
||||||
static fromMnemonic(mnemonic, path, wordlist) {
|
static fromMnemonic(mnemonic, path, wordlist) {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
path = defaultPath;
|
path = defaultPath;
|
||||||
@ -16248,7 +16273,7 @@ function poll(func, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const version$j = "providers/5.0.0-beta.154";
|
const version$j = "providers/5.0.0-beta.155";
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
const logger$n = new Logger(version$j);
|
const logger$n = new Logger(version$j);
|
||||||
@ -16871,7 +16896,7 @@ class BaseProvider extends Provider {
|
|||||||
toBlock: blockNumber,
|
toBlock: blockNumber,
|
||||||
topics: topics
|
topics: topics
|
||||||
};
|
};
|
||||||
if (!filter.address) {
|
if (!filter.address || filter.address === "*") {
|
||||||
delete filter.address;
|
delete filter.address;
|
||||||
}
|
}
|
||||||
const runner = this.getLogs(filter).then((logs) => {
|
const runner = this.getLogs(filter).then((logs) => {
|
||||||
@ -19345,7 +19370,7 @@ var utils$1 = /*#__PURE__*/Object.freeze({
|
|||||||
Indexed: Indexed
|
Indexed: Indexed
|
||||||
});
|
});
|
||||||
|
|
||||||
const version$l = "ethers/5.0.0-beta.174";
|
const version$l = "ethers/5.0.0-beta.175";
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
const errors = Logger.errors;
|
const errors = Logger.errors;
|
||||||
|
4
packages/ethers/dist/ethers.esm.min.js
vendored
4
packages/ethers/dist/ethers.esm.min.js
vendored
File diff suppressed because one or more lines are too long
302
packages/ethers/dist/ethers.umd.js
vendored
302
packages/ethers/dist/ethers.umd.js
vendored
@ -15078,7 +15078,7 @@
|
|||||||
var _version$y = createCommonjsModule(function (module, exports) {
|
var _version$y = createCommonjsModule(function (module, exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "json-wallets/5.0.0-beta.136";
|
exports.version = "json-wallets/5.0.0-beta.137";
|
||||||
});
|
});
|
||||||
|
|
||||||
var _version$z = unwrapExports(_version$y);
|
var _version$z = unwrapExports(_version$y);
|
||||||
@ -16077,139 +16077,144 @@
|
|||||||
return KeystoreAccount;
|
return KeystoreAccount;
|
||||||
}(lib$3.Description));
|
}(lib$3.Description));
|
||||||
exports.KeystoreAccount = KeystoreAccount;
|
exports.KeystoreAccount = KeystoreAccount;
|
||||||
|
function _decrypt(data, key, ciphertext) {
|
||||||
|
var cipher = utils$1.searchPath(data, "crypto/cipher");
|
||||||
|
if (cipher === "aes-128-ctr") {
|
||||||
|
var iv = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/cipherparams/iv"));
|
||||||
|
var counter = new aes_js_1.default.Counter(iv);
|
||||||
|
var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter);
|
||||||
|
return lib$1.arrayify(aesCtr.decrypt(ciphertext));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
function _getAccount(data, key) {
|
||||||
|
var ciphertext = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/ciphertext"));
|
||||||
|
var computedMAC = lib$1.hexlify(lib$4.keccak256(lib$1.concat([key.slice(16, 32), ciphertext]))).substring(2);
|
||||||
|
if (computedMAC !== utils$1.searchPath(data, "crypto/mac").toLowerCase()) {
|
||||||
|
throw new Error("invalid password");
|
||||||
|
}
|
||||||
|
var privateKey = _decrypt(data, key.slice(0, 16), ciphertext);
|
||||||
|
if (!privateKey) {
|
||||||
|
logger.throwError("unsupported cipher", lib.Logger.errors.UNSUPPORTED_OPERATION, {
|
||||||
|
operation: "decrypt"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var mnemonicKey = key.slice(32, 64);
|
||||||
|
var address = lib$g.computeAddress(privateKey);
|
||||||
|
if (data.address) {
|
||||||
|
var check = data.address.toLowerCase();
|
||||||
|
if (check.substring(0, 2) !== "0x") {
|
||||||
|
check = "0x" + check;
|
||||||
|
}
|
||||||
|
if (lib$6.getAddress(check) !== address) {
|
||||||
|
throw new Error("address mismatch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var account = {
|
||||||
|
_isKeystoreAccount: true,
|
||||||
|
address: address,
|
||||||
|
privateKey: lib$1.hexlify(privateKey)
|
||||||
|
};
|
||||||
|
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
||||||
|
if (utils$1.searchPath(data, "x-ethers/version") === "0.1") {
|
||||||
|
var mnemonicCiphertext = utils$1.looseArrayify(utils$1.searchPath(data, "x-ethers/mnemonicCiphertext"));
|
||||||
|
var mnemonicIv = utils$1.looseArrayify(utils$1.searchPath(data, "x-ethers/mnemonicCounter"));
|
||||||
|
var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv);
|
||||||
|
var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
|
||||||
|
var path = utils$1.searchPath(data, "x-ethers/path") || lib$h.defaultPath;
|
||||||
|
var locale = utils$1.searchPath(data, "x-ethers/locale") || "en";
|
||||||
|
var entropy = lib$1.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext));
|
||||||
|
try {
|
||||||
|
var mnemonic = lib$h.entropyToMnemonic(entropy, locale);
|
||||||
|
var node = lib$h.HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
|
||||||
|
if (node.privateKey != account.privateKey) {
|
||||||
|
throw new Error("mnemonic mismatch");
|
||||||
|
}
|
||||||
|
account.mnemonic = node.mnemonic;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
// If we don't have the locale wordlist installed to
|
||||||
|
// read this mnemonic, just bail and don't set the
|
||||||
|
// mnemonic
|
||||||
|
if (error.code !== lib.Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new KeystoreAccount(account);
|
||||||
|
}
|
||||||
|
function pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc) {
|
||||||
|
return lib$1.arrayify(browser$2.pbkdf2(passwordBytes, salt, count, dkLen, prfFunc));
|
||||||
|
}
|
||||||
|
function pbkdf2(passwordBytes, salt, count, dkLen, prfFunc) {
|
||||||
|
return Promise.resolve(pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc));
|
||||||
|
}
|
||||||
|
function _computeKdfKey(data, password, pbkdf2Func, scryptFunc, progressCallback) {
|
||||||
|
var passwordBytes = utils$1.getPassword(password);
|
||||||
|
var kdf = utils$1.searchPath(data, "crypto/kdf");
|
||||||
|
if (kdf && typeof (kdf) === "string") {
|
||||||
|
var throwError = function (name, value) {
|
||||||
|
return logger.throwArgumentError("invalid key-derivation function parameters", name, value);
|
||||||
|
};
|
||||||
|
if (kdf.toLowerCase() === "scrypt") {
|
||||||
|
var salt = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/kdfparams/salt"));
|
||||||
|
var N = parseInt(utils$1.searchPath(data, "crypto/kdfparams/n"));
|
||||||
|
var r = parseInt(utils$1.searchPath(data, "crypto/kdfparams/r"));
|
||||||
|
var p = parseInt(utils$1.searchPath(data, "crypto/kdfparams/p"));
|
||||||
|
// Check for all required parameters
|
||||||
|
if (!N || !r || !p) {
|
||||||
|
throwError("kdf", kdf);
|
||||||
|
}
|
||||||
|
// Make sure N is a power of 2
|
||||||
|
if ((N & (N - 1)) !== 0) {
|
||||||
|
throwError("N", N);
|
||||||
|
}
|
||||||
|
var dkLen = parseInt(utils$1.searchPath(data, "crypto/kdfparams/dklen"));
|
||||||
|
if (dkLen !== 32) {
|
||||||
|
throwError("dklen", dkLen);
|
||||||
|
}
|
||||||
|
return scryptFunc(passwordBytes, salt, N, r, p, 64, progressCallback);
|
||||||
|
}
|
||||||
|
else if (kdf.toLowerCase() === "pbkdf2") {
|
||||||
|
var salt = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/kdfparams/salt"));
|
||||||
|
var prfFunc = null;
|
||||||
|
var prf = utils$1.searchPath(data, "crypto/kdfparams/prf");
|
||||||
|
if (prf === "hmac-sha256") {
|
||||||
|
prfFunc = "sha256";
|
||||||
|
}
|
||||||
|
else if (prf === "hmac-sha512") {
|
||||||
|
prfFunc = "sha512";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throwError("prf", prf);
|
||||||
|
}
|
||||||
|
var count = parseInt(utils$1.searchPath(data, "crypto/kdfparams/c"));
|
||||||
|
var dkLen = parseInt(utils$1.searchPath(data, "crypto/kdfparams/dklen"));
|
||||||
|
if (dkLen !== 32) {
|
||||||
|
throwError("dklen", dkLen);
|
||||||
|
}
|
||||||
|
return pbkdf2Func(passwordBytes, salt, count, dkLen, prfFunc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return logger.throwArgumentError("unsupported key-derivation function", "kdf", kdf);
|
||||||
|
}
|
||||||
|
function decryptSync(json, password) {
|
||||||
|
var data = JSON.parse(json);
|
||||||
|
var key = _computeKdfKey(data, password, pbkdf2Sync, scrypt$1.syncScrypt);
|
||||||
|
return _getAccount(data, key);
|
||||||
|
}
|
||||||
|
exports.decryptSync = decryptSync;
|
||||||
function decrypt(json, password, progressCallback) {
|
function decrypt(json, password, progressCallback) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var data, passwordBytes, decrypt, computeMAC, getAccount, kdf, throwError, salt, N, r, p, dkLen, key, salt, prfFunc, prf, c, dkLen, key;
|
var data, key;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0:
|
case 0:
|
||||||
data = JSON.parse(json);
|
data = JSON.parse(json);
|
||||||
passwordBytes = utils$1.getPassword(password);
|
return [4 /*yield*/, _computeKdfKey(data, password, pbkdf2, scrypt$1.scrypt, progressCallback)];
|
||||||
decrypt = function (key, ciphertext) {
|
|
||||||
var cipher = utils$1.searchPath(data, "crypto/cipher");
|
|
||||||
if (cipher === "aes-128-ctr") {
|
|
||||||
var iv = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/cipherparams/iv"));
|
|
||||||
var counter = new aes_js_1.default.Counter(iv);
|
|
||||||
var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter);
|
|
||||||
return lib$1.arrayify(aesCtr.decrypt(ciphertext));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
computeMAC = function (derivedHalf, ciphertext) {
|
|
||||||
return lib$4.keccak256(lib$1.concat([derivedHalf, ciphertext]));
|
|
||||||
};
|
|
||||||
getAccount = function (key) {
|
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
|
||||||
var ciphertext, computedMAC, privateKey, mnemonicKey, address, check, account, mnemonicCiphertext, mnemonicIv, mnemonicCounter, mnemonicAesCtr, path, locale, entropy, mnemonic, node;
|
|
||||||
return __generator(this, function (_a) {
|
|
||||||
ciphertext = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/ciphertext"));
|
|
||||||
computedMAC = lib$1.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2);
|
|
||||||
if (computedMAC !== utils$1.searchPath(data, "crypto/mac").toLowerCase()) {
|
|
||||||
throw new Error("invalid password");
|
|
||||||
}
|
|
||||||
privateKey = decrypt(key.slice(0, 16), ciphertext);
|
|
||||||
mnemonicKey = key.slice(32, 64);
|
|
||||||
if (!privateKey) {
|
|
||||||
logger.throwError("unsupported cipher", lib.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
||||||
operation: "decrypt"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
address = lib$g.computeAddress(privateKey);
|
|
||||||
if (data.address) {
|
|
||||||
check = data.address.toLowerCase();
|
|
||||||
if (check.substring(0, 2) !== "0x") {
|
|
||||||
check = "0x" + check;
|
|
||||||
}
|
|
||||||
if (lib$6.getAddress(check) !== address) {
|
|
||||||
throw new Error("address mismatch");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
account = {
|
|
||||||
_isKeystoreAccount: true,
|
|
||||||
address: address,
|
|
||||||
privateKey: lib$1.hexlify(privateKey)
|
|
||||||
};
|
|
||||||
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
|
||||||
if (utils$1.searchPath(data, "x-ethers/version") === "0.1") {
|
|
||||||
mnemonicCiphertext = utils$1.looseArrayify(utils$1.searchPath(data, "x-ethers/mnemonicCiphertext"));
|
|
||||||
mnemonicIv = utils$1.looseArrayify(utils$1.searchPath(data, "x-ethers/mnemonicCounter"));
|
|
||||||
mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv);
|
|
||||||
mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
|
|
||||||
path = utils$1.searchPath(data, "x-ethers/path") || lib$h.defaultPath;
|
|
||||||
locale = utils$1.searchPath(data, "x-ethers/locale") || "en";
|
|
||||||
entropy = lib$1.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext));
|
|
||||||
try {
|
|
||||||
mnemonic = lib$h.entropyToMnemonic(entropy, locale);
|
|
||||||
node = lib$h.HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
|
|
||||||
if (node.privateKey != account.privateKey) {
|
|
||||||
throw new Error("mnemonic mismatch");
|
|
||||||
}
|
|
||||||
account.mnemonic = node.mnemonic;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
// If we don't have the locale wordlist installed to
|
|
||||||
// read this mnemonic, just bail and don't set the
|
|
||||||
// mnemonic
|
|
||||||
if (error.code !== lib.Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [2 /*return*/, new KeystoreAccount(account)];
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
kdf = utils$1.searchPath(data, "crypto/kdf");
|
|
||||||
if (!(kdf && typeof (kdf) === "string")) return [3 /*break*/, 3];
|
|
||||||
throwError = function (name, value) {
|
|
||||||
return logger.throwArgumentError("invalid key-derivation function parameters", name, value);
|
|
||||||
};
|
|
||||||
if (!(kdf.toLowerCase() === "scrypt")) return [3 /*break*/, 2];
|
|
||||||
salt = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/kdfparams/salt"));
|
|
||||||
N = parseInt(utils$1.searchPath(data, "crypto/kdfparams/n"));
|
|
||||||
r = parseInt(utils$1.searchPath(data, "crypto/kdfparams/r"));
|
|
||||||
p = parseInt(utils$1.searchPath(data, "crypto/kdfparams/p"));
|
|
||||||
// Check for all required parameters
|
|
||||||
if (!N || !r || !p) {
|
|
||||||
throwError("kdf", kdf);
|
|
||||||
}
|
|
||||||
// Make sure N is a power of 2
|
|
||||||
if ((N & (N - 1)) !== 0) {
|
|
||||||
throwError("N", N);
|
|
||||||
}
|
|
||||||
dkLen = parseInt(utils$1.searchPath(data, "crypto/kdfparams/dklen"));
|
|
||||||
if (dkLen !== 32) {
|
|
||||||
throwError("dklen", dkLen);
|
|
||||||
}
|
|
||||||
return [4 /*yield*/, scrypt$1.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback)];
|
|
||||||
case 1:
|
case 1:
|
||||||
key = _a.sent();
|
key = _a.sent();
|
||||||
//key = arrayify(key);
|
return [2 /*return*/, _getAccount(data, key)];
|
||||||
return [2 /*return*/, getAccount(key)];
|
|
||||||
case 2:
|
|
||||||
if (kdf.toLowerCase() === "pbkdf2") {
|
|
||||||
salt = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/kdfparams/salt"));
|
|
||||||
prfFunc = null;
|
|
||||||
prf = utils$1.searchPath(data, "crypto/kdfparams/prf");
|
|
||||||
if (prf === "hmac-sha256") {
|
|
||||||
prfFunc = "sha256";
|
|
||||||
}
|
|
||||||
else if (prf === "hmac-sha512") {
|
|
||||||
prfFunc = "sha512";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throwError("prf", prf);
|
|
||||||
}
|
|
||||||
c = parseInt(utils$1.searchPath(data, "crypto/kdfparams/c"));
|
|
||||||
dkLen = parseInt(utils$1.searchPath(data, "crypto/kdfparams/dklen"));
|
|
||||||
if (dkLen !== 32) {
|
|
||||||
throwError("dklen", dkLen);
|
|
||||||
}
|
|
||||||
key = lib$1.arrayify(browser$2.pbkdf2(passwordBytes, salt, c, dkLen, prfFunc));
|
|
||||||
return [2 /*return*/, getAccount(key)];
|
|
||||||
}
|
|
||||||
_a.label = 3;
|
|
||||||
case 3: return [2 /*return*/, logger.throwArgumentError("unsupported key-derivation function", "kdf", kdf)];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -16369,8 +16374,9 @@
|
|||||||
|
|
||||||
var keystore$1 = unwrapExports(keystore);
|
var keystore$1 = unwrapExports(keystore);
|
||||||
var keystore_1 = keystore.KeystoreAccount;
|
var keystore_1 = keystore.KeystoreAccount;
|
||||||
var keystore_2 = keystore.decrypt;
|
var keystore_2 = keystore.decryptSync;
|
||||||
var keystore_3 = keystore.encrypt;
|
var keystore_3 = keystore.decrypt;
|
||||||
|
var keystore_4 = keystore.encrypt;
|
||||||
|
|
||||||
var lib$i = createCommonjsModule(function (module, exports) {
|
var lib$i = createCommonjsModule(function (module, exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -16383,6 +16389,7 @@
|
|||||||
exports.isKeystoreWallet = inspect.isKeystoreWallet;
|
exports.isKeystoreWallet = inspect.isKeystoreWallet;
|
||||||
|
|
||||||
exports.decryptKeystore = keystore.decrypt;
|
exports.decryptKeystore = keystore.decrypt;
|
||||||
|
exports.decryptKeystoreSync = keystore.decryptSync;
|
||||||
exports.encryptKeystore = keystore.encrypt;
|
exports.encryptKeystore = keystore.encrypt;
|
||||||
function decryptJsonWallet(json, password, progressCallback) {
|
function decryptJsonWallet(json, password, progressCallback) {
|
||||||
if (inspect.isCrowdsaleWallet(json)) {
|
if (inspect.isCrowdsaleWallet(json)) {
|
||||||
@ -16401,6 +16408,16 @@
|
|||||||
return Promise.reject(new Error("invalid JSON wallet"));
|
return Promise.reject(new Error("invalid JSON wallet"));
|
||||||
}
|
}
|
||||||
exports.decryptJsonWallet = decryptJsonWallet;
|
exports.decryptJsonWallet = decryptJsonWallet;
|
||||||
|
function decryptJsonWalletSync(json, password) {
|
||||||
|
if (inspect.isCrowdsaleWallet(json)) {
|
||||||
|
return crowdsale.decrypt(json, password);
|
||||||
|
}
|
||||||
|
if (inspect.isKeystoreWallet(json)) {
|
||||||
|
return keystore.decryptSync(json, password);
|
||||||
|
}
|
||||||
|
throw new Error("invalid JSON wallet");
|
||||||
|
}
|
||||||
|
exports.decryptJsonWalletSync = decryptJsonWalletSync;
|
||||||
});
|
});
|
||||||
|
|
||||||
var index$i = unwrapExports(lib$i);
|
var index$i = unwrapExports(lib$i);
|
||||||
@ -16409,13 +16426,15 @@
|
|||||||
var lib_3$d = lib$i.isCrowdsaleWallet;
|
var lib_3$d = lib$i.isCrowdsaleWallet;
|
||||||
var lib_4$b = lib$i.isKeystoreWallet;
|
var lib_4$b = lib$i.isKeystoreWallet;
|
||||||
var lib_5$a = lib$i.decryptKeystore;
|
var lib_5$a = lib$i.decryptKeystore;
|
||||||
var lib_6$6 = lib$i.encryptKeystore;
|
var lib_6$6 = lib$i.decryptKeystoreSync;
|
||||||
var lib_7$5 = lib$i.decryptJsonWallet;
|
var lib_7$5 = lib$i.encryptKeystore;
|
||||||
|
var lib_8$4 = lib$i.decryptJsonWallet;
|
||||||
|
var lib_9$4 = lib$i.decryptJsonWalletSync;
|
||||||
|
|
||||||
var _version$A = createCommonjsModule(function (module, exports) {
|
var _version$A = createCommonjsModule(function (module, exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "wallet/5.0.0-beta.137";
|
exports.version = "wallet/5.0.0-beta.138";
|
||||||
});
|
});
|
||||||
|
|
||||||
var _version$B = unwrapExports(_version$A);
|
var _version$B = unwrapExports(_version$A);
|
||||||
@ -16579,6 +16598,9 @@
|
|||||||
return new Wallet(account);
|
return new Wallet(account);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Wallet.fromEncryptedJsonSync = function (json, password) {
|
||||||
|
return new Wallet(lib$i.decryptJsonWalletSync(json, password));
|
||||||
|
};
|
||||||
Wallet.fromMnemonic = function (mnemonic, path, wordlist) {
|
Wallet.fromMnemonic = function (mnemonic, path, wordlist) {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
path = lib$h.defaultPath;
|
path = lib$h.defaultPath;
|
||||||
@ -17697,7 +17719,7 @@
|
|||||||
var _version$G = createCommonjsModule(function (module, exports) {
|
var _version$G = createCommonjsModule(function (module, exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "providers/5.0.0-beta.154";
|
exports.version = "providers/5.0.0-beta.155";
|
||||||
});
|
});
|
||||||
|
|
||||||
var _version$H = unwrapExports(_version$G);
|
var _version$H = unwrapExports(_version$G);
|
||||||
@ -18419,7 +18441,7 @@
|
|||||||
toBlock: blockNumber,
|
toBlock: blockNumber,
|
||||||
topics: topics
|
topics: topics
|
||||||
};
|
};
|
||||||
if (!filter_1.address) {
|
if (!filter_1.address || filter_1.address === "*") {
|
||||||
delete filter_1.address;
|
delete filter_1.address;
|
||||||
}
|
}
|
||||||
var runner = _this.getLogs(filter_1).then(function (logs) {
|
var runner = _this.getLogs(filter_1).then(function (logs) {
|
||||||
@ -21449,8 +21471,8 @@
|
|||||||
var lib_5$b = lib$m.CloudflareProvider;
|
var lib_5$b = lib$m.CloudflareProvider;
|
||||||
var lib_6$7 = lib$m.EtherscanProvider;
|
var lib_6$7 = lib$m.EtherscanProvider;
|
||||||
var lib_7$6 = lib$m.FallbackProvider;
|
var lib_7$6 = lib$m.FallbackProvider;
|
||||||
var lib_8$4 = lib$m.IpcProvider;
|
var lib_8$5 = lib$m.IpcProvider;
|
||||||
var lib_9$4 = lib$m.InfuraProvider;
|
var lib_9$5 = lib$m.InfuraProvider;
|
||||||
var lib_10$3 = lib$m.JsonRpcProvider;
|
var lib_10$3 = lib$m.JsonRpcProvider;
|
||||||
var lib_11$2 = lib$m.JsonRpcSigner;
|
var lib_11$2 = lib$m.JsonRpcSigner;
|
||||||
var lib_12$2 = lib$m.NodesmithProvider;
|
var lib_12$2 = lib$m.NodesmithProvider;
|
||||||
@ -21862,7 +21884,7 @@
|
|||||||
var _version$K = createCommonjsModule(function (module, exports) {
|
var _version$K = createCommonjsModule(function (module, exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "ethers/5.0.0-beta.174";
|
exports.version = "ethers/5.0.0-beta.175";
|
||||||
});
|
});
|
||||||
|
|
||||||
var _version$L = unwrapExports(_version$K);
|
var _version$L = unwrapExports(_version$K);
|
||||||
@ -21979,8 +22001,8 @@
|
|||||||
var lib_5$d = lib$p.getDefaultProvider;
|
var lib_5$d = lib$p.getDefaultProvider;
|
||||||
var lib_6$8 = lib$p.providers;
|
var lib_6$8 = lib$p.providers;
|
||||||
var lib_7$7 = lib$p.Contract;
|
var lib_7$7 = lib$p.Contract;
|
||||||
var lib_8$5 = lib$p.ContractFactory;
|
var lib_8$6 = lib$p.ContractFactory;
|
||||||
var lib_9$5 = lib$p.BigNumber;
|
var lib_9$6 = lib$p.BigNumber;
|
||||||
var lib_10$4 = lib$p.FixedNumber;
|
var lib_10$4 = lib$p.FixedNumber;
|
||||||
var lib_11$3 = lib$p.constants;
|
var lib_11$3 = lib$p.constants;
|
||||||
var lib_12$3 = lib$p.errors;
|
var lib_12$3 = lib$p.errors;
|
||||||
@ -21990,9 +22012,9 @@
|
|||||||
var lib_16$1 = lib$p.version;
|
var lib_16$1 = lib$p.version;
|
||||||
var lib_17 = lib$p.Wordlist;
|
var lib_17 = lib$p.Wordlist;
|
||||||
|
|
||||||
exports.BigNumber = lib_9$5;
|
exports.BigNumber = lib_9$6;
|
||||||
exports.Contract = lib_7$7;
|
exports.Contract = lib_7$7;
|
||||||
exports.ContractFactory = lib_8$5;
|
exports.ContractFactory = lib_8$6;
|
||||||
exports.FixedNumber = lib_10$4;
|
exports.FixedNumber = lib_10$4;
|
||||||
exports.Signer = lib_2$m;
|
exports.Signer = lib_2$m;
|
||||||
exports.VoidSigner = lib_4$e;
|
exports.VoidSigner = lib_4$e;
|
||||||
|
4
packages/ethers/dist/ethers.umd.min.js
vendored
4
packages/ethers/dist/ethers.umd.min.js
vendored
File diff suppressed because one or more lines are too long
2
packages/ethers/lib.esm/_version.d.ts
vendored
2
packages/ethers/lib.esm/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "ethers/5.0.0-beta.174";
|
export declare const version = "ethers/5.0.0-beta.175";
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "ethers/5.0.0-beta.174";
|
export const version = "ethers/5.0.0-beta.175";
|
||||||
|
2
packages/ethers/lib/_version.d.ts
vendored
2
packages/ethers/lib/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "ethers/5.0.0-beta.174";
|
export declare const version = "ethers/5.0.0-beta.175";
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "ethers/5.0.0-beta.174";
|
exports.version = "ethers/5.0.0-beta.175";
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0x89962a1d50d4b8c82d9b9a90583f82f8c516d773ba897257ce30a9b849d035e0",
|
"tarballHash": "0x7ba56ea10adf6d45f1d98a1a6fb8c5b3b30410d264d4532cad263d1132baceb3",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.174"
|
"version": "5.0.0-beta.175"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "ethers/5.0.0-beta.174";
|
export const version = "ethers/5.0.0-beta.175";
|
||||||
|
2
packages/json-wallets/lib.esm/_version.d.ts
vendored
2
packages/json-wallets/lib.esm/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "json-wallets/5.0.0-beta.136";
|
export declare const version = "json-wallets/5.0.0-beta.137";
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "json-wallets/5.0.0-beta.136";
|
export const version = "json-wallets/5.0.0-beta.137";
|
||||||
|
5
packages/json-wallets/lib.esm/index.d.ts
vendored
5
packages/json-wallets/lib.esm/index.d.ts
vendored
@ -2,6 +2,7 @@ import { Bytes } from "@ethersproject/bytes";
|
|||||||
import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer";
|
import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer";
|
||||||
import { decrypt as decryptCrowdsale } from "./crowdsale";
|
import { decrypt as decryptCrowdsale } from "./crowdsale";
|
||||||
import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect";
|
import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect";
|
||||||
import { decrypt as decryptKeystore, encrypt as encryptKeystore, EncryptOptions, ProgressCallback } from "./keystore";
|
import { decrypt as decryptKeystore, decryptSync as decryptKeystoreSync, encrypt as encryptKeystore, EncryptOptions, ProgressCallback } from "./keystore";
|
||||||
declare function decryptJsonWallet(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<ExternallyOwnedAccount>;
|
declare function decryptJsonWallet(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<ExternallyOwnedAccount>;
|
||||||
export { decryptCrowdsale, decryptKeystore, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, ProgressCallback, EncryptOptions, };
|
declare function decryptJsonWalletSync(json: string, password: Bytes | string): ExternallyOwnedAccount;
|
||||||
|
export { decryptCrowdsale, decryptKeystore, decryptKeystoreSync, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, decryptJsonWalletSync, ProgressCallback, EncryptOptions, };
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import { decrypt as decryptCrowdsale } from "./crowdsale";
|
import { decrypt as decryptCrowdsale } from "./crowdsale";
|
||||||
import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect";
|
import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect";
|
||||||
import { decrypt as decryptKeystore, encrypt as encryptKeystore } from "./keystore";
|
import { decrypt as decryptKeystore, decryptSync as decryptKeystoreSync, encrypt as encryptKeystore } from "./keystore";
|
||||||
function decryptJsonWallet(json, password, progressCallback) {
|
function decryptJsonWallet(json, password, progressCallback) {
|
||||||
if (isCrowdsaleWallet(json)) {
|
if (isCrowdsaleWallet(json)) {
|
||||||
if (progressCallback) {
|
if (progressCallback) {
|
||||||
@ -18,4 +18,13 @@ function decryptJsonWallet(json, password, progressCallback) {
|
|||||||
}
|
}
|
||||||
return Promise.reject(new Error("invalid JSON wallet"));
|
return Promise.reject(new Error("invalid JSON wallet"));
|
||||||
}
|
}
|
||||||
export { decryptCrowdsale, decryptKeystore, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, };
|
function decryptJsonWalletSync(json, password) {
|
||||||
|
if (isCrowdsaleWallet(json)) {
|
||||||
|
return decryptCrowdsale(json, password);
|
||||||
|
}
|
||||||
|
if (isKeystoreWallet(json)) {
|
||||||
|
return decryptKeystoreSync(json, password);
|
||||||
|
}
|
||||||
|
throw new Error("invalid JSON wallet");
|
||||||
|
}
|
||||||
|
export { decryptCrowdsale, decryptKeystore, decryptKeystoreSync, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, decryptJsonWalletSync, };
|
||||||
|
1
packages/json-wallets/lib.esm/keystore.d.ts
vendored
1
packages/json-wallets/lib.esm/keystore.d.ts
vendored
@ -28,6 +28,7 @@ export declare type EncryptOptions = {
|
|||||||
p?: number;
|
p?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
export declare function decryptSync(json: string, password: Bytes | string): KeystoreAccount;
|
||||||
export declare function decrypt(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<KeystoreAccount>;
|
export declare function decrypt(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<KeystoreAccount>;
|
||||||
export declare function encrypt(account: ExternallyOwnedAccount, password: Bytes | string, options?: EncryptOptions, progressCallback?: ProgressCallback): Promise<string>;
|
export declare function encrypt(account: ExternallyOwnedAccount, password: Bytes | string, options?: EncryptOptions, progressCallback?: ProgressCallback): Promise<string>;
|
||||||
export {};
|
export {};
|
||||||
|
@ -15,7 +15,7 @@ import { getAddress } from "@ethersproject/address";
|
|||||||
import { arrayify, concat, hexlify } from "@ethersproject/bytes";
|
import { arrayify, concat, hexlify } from "@ethersproject/bytes";
|
||||||
import { defaultPath, entropyToMnemonic, HDNode, mnemonicToEntropy } from "@ethersproject/hdnode";
|
import { defaultPath, entropyToMnemonic, HDNode, mnemonicToEntropy } from "@ethersproject/hdnode";
|
||||||
import { keccak256 } from "@ethersproject/keccak256";
|
import { keccak256 } from "@ethersproject/keccak256";
|
||||||
import { pbkdf2 } from "@ethersproject/pbkdf2";
|
import { pbkdf2 as _pbkdf2 } from "@ethersproject/pbkdf2";
|
||||||
import { randomBytes } from "@ethersproject/random";
|
import { randomBytes } from "@ethersproject/random";
|
||||||
import { Description } from "@ethersproject/properties";
|
import { Description } from "@ethersproject/properties";
|
||||||
import { computeAddress } from "@ethersproject/transactions";
|
import { computeAddress } from "@ethersproject/transactions";
|
||||||
@ -32,130 +32,137 @@ export class KeystoreAccount extends Description {
|
|||||||
return !!(value && value._isKeystoreAccount);
|
return !!(value && value._isKeystoreAccount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function _decrypt(data, key, ciphertext) {
|
||||||
|
const cipher = searchPath(data, "crypto/cipher");
|
||||||
|
if (cipher === "aes-128-ctr") {
|
||||||
|
const iv = looseArrayify(searchPath(data, "crypto/cipherparams/iv"));
|
||||||
|
const counter = new aes.Counter(iv);
|
||||||
|
const aesCtr = new aes.ModeOfOperation.ctr(key, counter);
|
||||||
|
return arrayify(aesCtr.decrypt(ciphertext));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
function _getAccount(data, key) {
|
||||||
|
const ciphertext = looseArrayify(searchPath(data, "crypto/ciphertext"));
|
||||||
|
const computedMAC = hexlify(keccak256(concat([key.slice(16, 32), ciphertext]))).substring(2);
|
||||||
|
if (computedMAC !== searchPath(data, "crypto/mac").toLowerCase()) {
|
||||||
|
throw new Error("invalid password");
|
||||||
|
}
|
||||||
|
const privateKey = _decrypt(data, key.slice(0, 16), ciphertext);
|
||||||
|
if (!privateKey) {
|
||||||
|
logger.throwError("unsupported cipher", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||||
|
operation: "decrypt"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const mnemonicKey = key.slice(32, 64);
|
||||||
|
const address = computeAddress(privateKey);
|
||||||
|
if (data.address) {
|
||||||
|
let check = data.address.toLowerCase();
|
||||||
|
if (check.substring(0, 2) !== "0x") {
|
||||||
|
check = "0x" + check;
|
||||||
|
}
|
||||||
|
if (getAddress(check) !== address) {
|
||||||
|
throw new Error("address mismatch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const account = {
|
||||||
|
_isKeystoreAccount: true,
|
||||||
|
address: address,
|
||||||
|
privateKey: hexlify(privateKey)
|
||||||
|
};
|
||||||
|
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
||||||
|
if (searchPath(data, "x-ethers/version") === "0.1") {
|
||||||
|
const mnemonicCiphertext = looseArrayify(searchPath(data, "x-ethers/mnemonicCiphertext"));
|
||||||
|
const mnemonicIv = looseArrayify(searchPath(data, "x-ethers/mnemonicCounter"));
|
||||||
|
const mnemonicCounter = new aes.Counter(mnemonicIv);
|
||||||
|
const mnemonicAesCtr = new aes.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
|
||||||
|
const path = searchPath(data, "x-ethers/path") || defaultPath;
|
||||||
|
const locale = searchPath(data, "x-ethers/locale") || "en";
|
||||||
|
const entropy = arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext));
|
||||||
|
try {
|
||||||
|
const mnemonic = entropyToMnemonic(entropy, locale);
|
||||||
|
const node = HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
|
||||||
|
if (node.privateKey != account.privateKey) {
|
||||||
|
throw new Error("mnemonic mismatch");
|
||||||
|
}
|
||||||
|
account.mnemonic = node.mnemonic;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
// If we don't have the locale wordlist installed to
|
||||||
|
// read this mnemonic, just bail and don't set the
|
||||||
|
// mnemonic
|
||||||
|
if (error.code !== Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new KeystoreAccount(account);
|
||||||
|
}
|
||||||
|
function pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc) {
|
||||||
|
return arrayify(_pbkdf2(passwordBytes, salt, count, dkLen, prfFunc));
|
||||||
|
}
|
||||||
|
function pbkdf2(passwordBytes, salt, count, dkLen, prfFunc) {
|
||||||
|
return Promise.resolve(pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc));
|
||||||
|
}
|
||||||
|
function _computeKdfKey(data, password, pbkdf2Func, scryptFunc, progressCallback) {
|
||||||
|
const passwordBytes = getPassword(password);
|
||||||
|
const kdf = searchPath(data, "crypto/kdf");
|
||||||
|
if (kdf && typeof (kdf) === "string") {
|
||||||
|
const throwError = function (name, value) {
|
||||||
|
return logger.throwArgumentError("invalid key-derivation function parameters", name, value);
|
||||||
|
};
|
||||||
|
if (kdf.toLowerCase() === "scrypt") {
|
||||||
|
const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt"));
|
||||||
|
const N = parseInt(searchPath(data, "crypto/kdfparams/n"));
|
||||||
|
const r = parseInt(searchPath(data, "crypto/kdfparams/r"));
|
||||||
|
const p = parseInt(searchPath(data, "crypto/kdfparams/p"));
|
||||||
|
// Check for all required parameters
|
||||||
|
if (!N || !r || !p) {
|
||||||
|
throwError("kdf", kdf);
|
||||||
|
}
|
||||||
|
// Make sure N is a power of 2
|
||||||
|
if ((N & (N - 1)) !== 0) {
|
||||||
|
throwError("N", N);
|
||||||
|
}
|
||||||
|
const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen"));
|
||||||
|
if (dkLen !== 32) {
|
||||||
|
throwError("dklen", dkLen);
|
||||||
|
}
|
||||||
|
return scryptFunc(passwordBytes, salt, N, r, p, 64, progressCallback);
|
||||||
|
}
|
||||||
|
else if (kdf.toLowerCase() === "pbkdf2") {
|
||||||
|
const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt"));
|
||||||
|
let prfFunc = null;
|
||||||
|
const prf = searchPath(data, "crypto/kdfparams/prf");
|
||||||
|
if (prf === "hmac-sha256") {
|
||||||
|
prfFunc = "sha256";
|
||||||
|
}
|
||||||
|
else if (prf === "hmac-sha512") {
|
||||||
|
prfFunc = "sha512";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throwError("prf", prf);
|
||||||
|
}
|
||||||
|
const count = parseInt(searchPath(data, "crypto/kdfparams/c"));
|
||||||
|
const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen"));
|
||||||
|
if (dkLen !== 32) {
|
||||||
|
throwError("dklen", dkLen);
|
||||||
|
}
|
||||||
|
return pbkdf2Func(passwordBytes, salt, count, dkLen, prfFunc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return logger.throwArgumentError("unsupported key-derivation function", "kdf", kdf);
|
||||||
|
}
|
||||||
|
export function decryptSync(json, password) {
|
||||||
|
const data = JSON.parse(json);
|
||||||
|
const key = _computeKdfKey(data, password, pbkdf2Sync, scrypt.syncScrypt);
|
||||||
|
return _getAccount(data, key);
|
||||||
|
}
|
||||||
export function decrypt(json, password, progressCallback) {
|
export function decrypt(json, password, progressCallback) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const data = JSON.parse(json);
|
const data = JSON.parse(json);
|
||||||
const passwordBytes = getPassword(password);
|
const key = yield _computeKdfKey(data, password, pbkdf2, scrypt.scrypt, progressCallback);
|
||||||
const decrypt = function (key, ciphertext) {
|
return _getAccount(data, key);
|
||||||
const cipher = searchPath(data, "crypto/cipher");
|
|
||||||
if (cipher === "aes-128-ctr") {
|
|
||||||
const iv = looseArrayify(searchPath(data, "crypto/cipherparams/iv"));
|
|
||||||
const counter = new aes.Counter(iv);
|
|
||||||
const aesCtr = new aes.ModeOfOperation.ctr(key, counter);
|
|
||||||
return arrayify(aesCtr.decrypt(ciphertext));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
const computeMAC = function (derivedHalf, ciphertext) {
|
|
||||||
return keccak256(concat([derivedHalf, ciphertext]));
|
|
||||||
};
|
|
||||||
const getAccount = function (key) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const ciphertext = looseArrayify(searchPath(data, "crypto/ciphertext"));
|
|
||||||
const computedMAC = hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2);
|
|
||||||
if (computedMAC !== searchPath(data, "crypto/mac").toLowerCase()) {
|
|
||||||
throw new Error("invalid password");
|
|
||||||
}
|
|
||||||
const privateKey = decrypt(key.slice(0, 16), ciphertext);
|
|
||||||
const mnemonicKey = key.slice(32, 64);
|
|
||||||
if (!privateKey) {
|
|
||||||
logger.throwError("unsupported cipher", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
||||||
operation: "decrypt"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const address = computeAddress(privateKey);
|
|
||||||
if (data.address) {
|
|
||||||
let check = data.address.toLowerCase();
|
|
||||||
if (check.substring(0, 2) !== "0x") {
|
|
||||||
check = "0x" + check;
|
|
||||||
}
|
|
||||||
if (getAddress(check) !== address) {
|
|
||||||
throw new Error("address mismatch");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const account = {
|
|
||||||
_isKeystoreAccount: true,
|
|
||||||
address: address,
|
|
||||||
privateKey: hexlify(privateKey)
|
|
||||||
};
|
|
||||||
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
|
||||||
if (searchPath(data, "x-ethers/version") === "0.1") {
|
|
||||||
const mnemonicCiphertext = looseArrayify(searchPath(data, "x-ethers/mnemonicCiphertext"));
|
|
||||||
const mnemonicIv = looseArrayify(searchPath(data, "x-ethers/mnemonicCounter"));
|
|
||||||
const mnemonicCounter = new aes.Counter(mnemonicIv);
|
|
||||||
const mnemonicAesCtr = new aes.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
|
|
||||||
const path = searchPath(data, "x-ethers/path") || defaultPath;
|
|
||||||
const locale = searchPath(data, "x-ethers/locale") || "en";
|
|
||||||
const entropy = arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext));
|
|
||||||
try {
|
|
||||||
const mnemonic = entropyToMnemonic(entropy, locale);
|
|
||||||
const node = HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
|
|
||||||
if (node.privateKey != account.privateKey) {
|
|
||||||
throw new Error("mnemonic mismatch");
|
|
||||||
}
|
|
||||||
account.mnemonic = node.mnemonic;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
// If we don't have the locale wordlist installed to
|
|
||||||
// read this mnemonic, just bail and don't set the
|
|
||||||
// mnemonic
|
|
||||||
if (error.code !== Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new KeystoreAccount(account);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const kdf = searchPath(data, "crypto/kdf");
|
|
||||||
if (kdf && typeof (kdf) === "string") {
|
|
||||||
const throwError = function (name, value) {
|
|
||||||
return logger.throwArgumentError("invalid key-derivation function parameters", name, value);
|
|
||||||
};
|
|
||||||
if (kdf.toLowerCase() === "scrypt") {
|
|
||||||
const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt"));
|
|
||||||
const N = parseInt(searchPath(data, "crypto/kdfparams/n"));
|
|
||||||
const r = parseInt(searchPath(data, "crypto/kdfparams/r"));
|
|
||||||
const p = parseInt(searchPath(data, "crypto/kdfparams/p"));
|
|
||||||
// Check for all required parameters
|
|
||||||
if (!N || !r || !p) {
|
|
||||||
throwError("kdf", kdf);
|
|
||||||
}
|
|
||||||
// Make sure N is a power of 2
|
|
||||||
if ((N & (N - 1)) !== 0) {
|
|
||||||
throwError("N", N);
|
|
||||||
}
|
|
||||||
const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen"));
|
|
||||||
if (dkLen !== 32) {
|
|
||||||
throwError("dklen", dkLen);
|
|
||||||
}
|
|
||||||
const key = yield scrypt.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback);
|
|
||||||
//key = arrayify(key);
|
|
||||||
return getAccount(key);
|
|
||||||
}
|
|
||||||
else if (kdf.toLowerCase() === "pbkdf2") {
|
|
||||||
const salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt"));
|
|
||||||
let prfFunc = null;
|
|
||||||
const prf = searchPath(data, "crypto/kdfparams/prf");
|
|
||||||
if (prf === "hmac-sha256") {
|
|
||||||
prfFunc = "sha256";
|
|
||||||
}
|
|
||||||
else if (prf === "hmac-sha512") {
|
|
||||||
prfFunc = "sha512";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throwError("prf", prf);
|
|
||||||
}
|
|
||||||
const c = parseInt(searchPath(data, "crypto/kdfparams/c"));
|
|
||||||
const dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen"));
|
|
||||||
if (dkLen !== 32) {
|
|
||||||
throwError("dklen", dkLen);
|
|
||||||
}
|
|
||||||
const key = arrayify(pbkdf2(passwordBytes, salt, c, dkLen, prfFunc));
|
|
||||||
return getAccount(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return logger.throwArgumentError("unsupported key-derivation function", "kdf", kdf);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export function encrypt(account, password, options, progressCallback) {
|
export function encrypt(account, password, options, progressCallback) {
|
||||||
|
2
packages/json-wallets/lib/_version.d.ts
vendored
2
packages/json-wallets/lib/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "json-wallets/5.0.0-beta.136";
|
export declare const version = "json-wallets/5.0.0-beta.137";
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "json-wallets/5.0.0-beta.136";
|
exports.version = "json-wallets/5.0.0-beta.137";
|
||||||
|
5
packages/json-wallets/lib/index.d.ts
vendored
5
packages/json-wallets/lib/index.d.ts
vendored
@ -2,6 +2,7 @@ import { Bytes } from "@ethersproject/bytes";
|
|||||||
import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer";
|
import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer";
|
||||||
import { decrypt as decryptCrowdsale } from "./crowdsale";
|
import { decrypt as decryptCrowdsale } from "./crowdsale";
|
||||||
import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect";
|
import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect";
|
||||||
import { decrypt as decryptKeystore, encrypt as encryptKeystore, EncryptOptions, ProgressCallback } from "./keystore";
|
import { decrypt as decryptKeystore, decryptSync as decryptKeystoreSync, encrypt as encryptKeystore, EncryptOptions, ProgressCallback } from "./keystore";
|
||||||
declare function decryptJsonWallet(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<ExternallyOwnedAccount>;
|
declare function decryptJsonWallet(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<ExternallyOwnedAccount>;
|
||||||
export { decryptCrowdsale, decryptKeystore, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, ProgressCallback, EncryptOptions, };
|
declare function decryptJsonWalletSync(json: string, password: Bytes | string): ExternallyOwnedAccount;
|
||||||
|
export { decryptCrowdsale, decryptKeystore, decryptKeystoreSync, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, decryptJsonWalletSync, ProgressCallback, EncryptOptions, };
|
||||||
|
@ -8,6 +8,7 @@ exports.isCrowdsaleWallet = inspect_1.isCrowdsaleWallet;
|
|||||||
exports.isKeystoreWallet = inspect_1.isKeystoreWallet;
|
exports.isKeystoreWallet = inspect_1.isKeystoreWallet;
|
||||||
var keystore_1 = require("./keystore");
|
var keystore_1 = require("./keystore");
|
||||||
exports.decryptKeystore = keystore_1.decrypt;
|
exports.decryptKeystore = keystore_1.decrypt;
|
||||||
|
exports.decryptKeystoreSync = keystore_1.decryptSync;
|
||||||
exports.encryptKeystore = keystore_1.encrypt;
|
exports.encryptKeystore = keystore_1.encrypt;
|
||||||
function decryptJsonWallet(json, password, progressCallback) {
|
function decryptJsonWallet(json, password, progressCallback) {
|
||||||
if (inspect_1.isCrowdsaleWallet(json)) {
|
if (inspect_1.isCrowdsaleWallet(json)) {
|
||||||
@ -26,3 +27,13 @@ function decryptJsonWallet(json, password, progressCallback) {
|
|||||||
return Promise.reject(new Error("invalid JSON wallet"));
|
return Promise.reject(new Error("invalid JSON wallet"));
|
||||||
}
|
}
|
||||||
exports.decryptJsonWallet = decryptJsonWallet;
|
exports.decryptJsonWallet = decryptJsonWallet;
|
||||||
|
function decryptJsonWalletSync(json, password) {
|
||||||
|
if (inspect_1.isCrowdsaleWallet(json)) {
|
||||||
|
return crowdsale_1.decrypt(json, password);
|
||||||
|
}
|
||||||
|
if (inspect_1.isKeystoreWallet(json)) {
|
||||||
|
return keystore_1.decryptSync(json, password);
|
||||||
|
}
|
||||||
|
throw new Error("invalid JSON wallet");
|
||||||
|
}
|
||||||
|
exports.decryptJsonWalletSync = decryptJsonWalletSync;
|
||||||
|
1
packages/json-wallets/lib/keystore.d.ts
vendored
1
packages/json-wallets/lib/keystore.d.ts
vendored
@ -28,6 +28,7 @@ export declare type EncryptOptions = {
|
|||||||
p?: number;
|
p?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
export declare function decryptSync(json: string, password: Bytes | string): KeystoreAccount;
|
||||||
export declare function decrypt(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<KeystoreAccount>;
|
export declare function decrypt(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<KeystoreAccount>;
|
||||||
export declare function encrypt(account: ExternallyOwnedAccount, password: Bytes | string, options?: EncryptOptions, progressCallback?: ProgressCallback): Promise<string>;
|
export declare function encrypt(account: ExternallyOwnedAccount, password: Bytes | string, options?: EncryptOptions, progressCallback?: ProgressCallback): Promise<string>;
|
||||||
export {};
|
export {};
|
||||||
|
@ -89,139 +89,144 @@ var KeystoreAccount = /** @class */ (function (_super) {
|
|||||||
return KeystoreAccount;
|
return KeystoreAccount;
|
||||||
}(properties_1.Description));
|
}(properties_1.Description));
|
||||||
exports.KeystoreAccount = KeystoreAccount;
|
exports.KeystoreAccount = KeystoreAccount;
|
||||||
|
function _decrypt(data, key, ciphertext) {
|
||||||
|
var cipher = utils_1.searchPath(data, "crypto/cipher");
|
||||||
|
if (cipher === "aes-128-ctr") {
|
||||||
|
var iv = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/cipherparams/iv"));
|
||||||
|
var counter = new aes_js_1.default.Counter(iv);
|
||||||
|
var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter);
|
||||||
|
return bytes_1.arrayify(aesCtr.decrypt(ciphertext));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
function _getAccount(data, key) {
|
||||||
|
var ciphertext = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/ciphertext"));
|
||||||
|
var computedMAC = bytes_1.hexlify(keccak256_1.keccak256(bytes_1.concat([key.slice(16, 32), ciphertext]))).substring(2);
|
||||||
|
if (computedMAC !== utils_1.searchPath(data, "crypto/mac").toLowerCase()) {
|
||||||
|
throw new Error("invalid password");
|
||||||
|
}
|
||||||
|
var privateKey = _decrypt(data, key.slice(0, 16), ciphertext);
|
||||||
|
if (!privateKey) {
|
||||||
|
logger.throwError("unsupported cipher", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
||||||
|
operation: "decrypt"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var mnemonicKey = key.slice(32, 64);
|
||||||
|
var address = transactions_1.computeAddress(privateKey);
|
||||||
|
if (data.address) {
|
||||||
|
var check = data.address.toLowerCase();
|
||||||
|
if (check.substring(0, 2) !== "0x") {
|
||||||
|
check = "0x" + check;
|
||||||
|
}
|
||||||
|
if (address_1.getAddress(check) !== address) {
|
||||||
|
throw new Error("address mismatch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var account = {
|
||||||
|
_isKeystoreAccount: true,
|
||||||
|
address: address,
|
||||||
|
privateKey: bytes_1.hexlify(privateKey)
|
||||||
|
};
|
||||||
|
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
||||||
|
if (utils_1.searchPath(data, "x-ethers/version") === "0.1") {
|
||||||
|
var mnemonicCiphertext = utils_1.looseArrayify(utils_1.searchPath(data, "x-ethers/mnemonicCiphertext"));
|
||||||
|
var mnemonicIv = utils_1.looseArrayify(utils_1.searchPath(data, "x-ethers/mnemonicCounter"));
|
||||||
|
var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv);
|
||||||
|
var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
|
||||||
|
var path = utils_1.searchPath(data, "x-ethers/path") || hdnode_1.defaultPath;
|
||||||
|
var locale = utils_1.searchPath(data, "x-ethers/locale") || "en";
|
||||||
|
var entropy = bytes_1.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext));
|
||||||
|
try {
|
||||||
|
var mnemonic = hdnode_1.entropyToMnemonic(entropy, locale);
|
||||||
|
var node = hdnode_1.HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
|
||||||
|
if (node.privateKey != account.privateKey) {
|
||||||
|
throw new Error("mnemonic mismatch");
|
||||||
|
}
|
||||||
|
account.mnemonic = node.mnemonic;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
// If we don't have the locale wordlist installed to
|
||||||
|
// read this mnemonic, just bail and don't set the
|
||||||
|
// mnemonic
|
||||||
|
if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new KeystoreAccount(account);
|
||||||
|
}
|
||||||
|
function pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc) {
|
||||||
|
return bytes_1.arrayify(pbkdf2_1.pbkdf2(passwordBytes, salt, count, dkLen, prfFunc));
|
||||||
|
}
|
||||||
|
function pbkdf2(passwordBytes, salt, count, dkLen, prfFunc) {
|
||||||
|
return Promise.resolve(pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc));
|
||||||
|
}
|
||||||
|
function _computeKdfKey(data, password, pbkdf2Func, scryptFunc, progressCallback) {
|
||||||
|
var passwordBytes = utils_1.getPassword(password);
|
||||||
|
var kdf = utils_1.searchPath(data, "crypto/kdf");
|
||||||
|
if (kdf && typeof (kdf) === "string") {
|
||||||
|
var throwError = function (name, value) {
|
||||||
|
return logger.throwArgumentError("invalid key-derivation function parameters", name, value);
|
||||||
|
};
|
||||||
|
if (kdf.toLowerCase() === "scrypt") {
|
||||||
|
var salt = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/kdfparams/salt"));
|
||||||
|
var N = parseInt(utils_1.searchPath(data, "crypto/kdfparams/n"));
|
||||||
|
var r = parseInt(utils_1.searchPath(data, "crypto/kdfparams/r"));
|
||||||
|
var p = parseInt(utils_1.searchPath(data, "crypto/kdfparams/p"));
|
||||||
|
// Check for all required parameters
|
||||||
|
if (!N || !r || !p) {
|
||||||
|
throwError("kdf", kdf);
|
||||||
|
}
|
||||||
|
// Make sure N is a power of 2
|
||||||
|
if ((N & (N - 1)) !== 0) {
|
||||||
|
throwError("N", N);
|
||||||
|
}
|
||||||
|
var dkLen = parseInt(utils_1.searchPath(data, "crypto/kdfparams/dklen"));
|
||||||
|
if (dkLen !== 32) {
|
||||||
|
throwError("dklen", dkLen);
|
||||||
|
}
|
||||||
|
return scryptFunc(passwordBytes, salt, N, r, p, 64, progressCallback);
|
||||||
|
}
|
||||||
|
else if (kdf.toLowerCase() === "pbkdf2") {
|
||||||
|
var salt = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/kdfparams/salt"));
|
||||||
|
var prfFunc = null;
|
||||||
|
var prf = utils_1.searchPath(data, "crypto/kdfparams/prf");
|
||||||
|
if (prf === "hmac-sha256") {
|
||||||
|
prfFunc = "sha256";
|
||||||
|
}
|
||||||
|
else if (prf === "hmac-sha512") {
|
||||||
|
prfFunc = "sha512";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throwError("prf", prf);
|
||||||
|
}
|
||||||
|
var count = parseInt(utils_1.searchPath(data, "crypto/kdfparams/c"));
|
||||||
|
var dkLen = parseInt(utils_1.searchPath(data, "crypto/kdfparams/dklen"));
|
||||||
|
if (dkLen !== 32) {
|
||||||
|
throwError("dklen", dkLen);
|
||||||
|
}
|
||||||
|
return pbkdf2Func(passwordBytes, salt, count, dkLen, prfFunc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return logger.throwArgumentError("unsupported key-derivation function", "kdf", kdf);
|
||||||
|
}
|
||||||
|
function decryptSync(json, password) {
|
||||||
|
var data = JSON.parse(json);
|
||||||
|
var key = _computeKdfKey(data, password, pbkdf2Sync, scrypt.syncScrypt);
|
||||||
|
return _getAccount(data, key);
|
||||||
|
}
|
||||||
|
exports.decryptSync = decryptSync;
|
||||||
function decrypt(json, password, progressCallback) {
|
function decrypt(json, password, progressCallback) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var data, passwordBytes, decrypt, computeMAC, getAccount, kdf, throwError, salt, N, r, p, dkLen, key, salt, prfFunc, prf, c, dkLen, key;
|
var data, key;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0:
|
case 0:
|
||||||
data = JSON.parse(json);
|
data = JSON.parse(json);
|
||||||
passwordBytes = utils_1.getPassword(password);
|
return [4 /*yield*/, _computeKdfKey(data, password, pbkdf2, scrypt.scrypt, progressCallback)];
|
||||||
decrypt = function (key, ciphertext) {
|
|
||||||
var cipher = utils_1.searchPath(data, "crypto/cipher");
|
|
||||||
if (cipher === "aes-128-ctr") {
|
|
||||||
var iv = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/cipherparams/iv"));
|
|
||||||
var counter = new aes_js_1.default.Counter(iv);
|
|
||||||
var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter);
|
|
||||||
return bytes_1.arrayify(aesCtr.decrypt(ciphertext));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
computeMAC = function (derivedHalf, ciphertext) {
|
|
||||||
return keccak256_1.keccak256(bytes_1.concat([derivedHalf, ciphertext]));
|
|
||||||
};
|
|
||||||
getAccount = function (key) {
|
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
|
||||||
var ciphertext, computedMAC, privateKey, mnemonicKey, address, check, account, mnemonicCiphertext, mnemonicIv, mnemonicCounter, mnemonicAesCtr, path, locale, entropy, mnemonic, node;
|
|
||||||
return __generator(this, function (_a) {
|
|
||||||
ciphertext = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/ciphertext"));
|
|
||||||
computedMAC = bytes_1.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2);
|
|
||||||
if (computedMAC !== utils_1.searchPath(data, "crypto/mac").toLowerCase()) {
|
|
||||||
throw new Error("invalid password");
|
|
||||||
}
|
|
||||||
privateKey = decrypt(key.slice(0, 16), ciphertext);
|
|
||||||
mnemonicKey = key.slice(32, 64);
|
|
||||||
if (!privateKey) {
|
|
||||||
logger.throwError("unsupported cipher", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
||||||
operation: "decrypt"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
address = transactions_1.computeAddress(privateKey);
|
|
||||||
if (data.address) {
|
|
||||||
check = data.address.toLowerCase();
|
|
||||||
if (check.substring(0, 2) !== "0x") {
|
|
||||||
check = "0x" + check;
|
|
||||||
}
|
|
||||||
if (address_1.getAddress(check) !== address) {
|
|
||||||
throw new Error("address mismatch");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
account = {
|
|
||||||
_isKeystoreAccount: true,
|
|
||||||
address: address,
|
|
||||||
privateKey: bytes_1.hexlify(privateKey)
|
|
||||||
};
|
|
||||||
// Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
|
|
||||||
if (utils_1.searchPath(data, "x-ethers/version") === "0.1") {
|
|
||||||
mnemonicCiphertext = utils_1.looseArrayify(utils_1.searchPath(data, "x-ethers/mnemonicCiphertext"));
|
|
||||||
mnemonicIv = utils_1.looseArrayify(utils_1.searchPath(data, "x-ethers/mnemonicCounter"));
|
|
||||||
mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv);
|
|
||||||
mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
|
|
||||||
path = utils_1.searchPath(data, "x-ethers/path") || hdnode_1.defaultPath;
|
|
||||||
locale = utils_1.searchPath(data, "x-ethers/locale") || "en";
|
|
||||||
entropy = bytes_1.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext));
|
|
||||||
try {
|
|
||||||
mnemonic = hdnode_1.entropyToMnemonic(entropy, locale);
|
|
||||||
node = hdnode_1.HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
|
|
||||||
if (node.privateKey != account.privateKey) {
|
|
||||||
throw new Error("mnemonic mismatch");
|
|
||||||
}
|
|
||||||
account.mnemonic = node.mnemonic;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
// If we don't have the locale wordlist installed to
|
|
||||||
// read this mnemonic, just bail and don't set the
|
|
||||||
// mnemonic
|
|
||||||
if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [2 /*return*/, new KeystoreAccount(account)];
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
kdf = utils_1.searchPath(data, "crypto/kdf");
|
|
||||||
if (!(kdf && typeof (kdf) === "string")) return [3 /*break*/, 3];
|
|
||||||
throwError = function (name, value) {
|
|
||||||
return logger.throwArgumentError("invalid key-derivation function parameters", name, value);
|
|
||||||
};
|
|
||||||
if (!(kdf.toLowerCase() === "scrypt")) return [3 /*break*/, 2];
|
|
||||||
salt = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/kdfparams/salt"));
|
|
||||||
N = parseInt(utils_1.searchPath(data, "crypto/kdfparams/n"));
|
|
||||||
r = parseInt(utils_1.searchPath(data, "crypto/kdfparams/r"));
|
|
||||||
p = parseInt(utils_1.searchPath(data, "crypto/kdfparams/p"));
|
|
||||||
// Check for all required parameters
|
|
||||||
if (!N || !r || !p) {
|
|
||||||
throwError("kdf", kdf);
|
|
||||||
}
|
|
||||||
// Make sure N is a power of 2
|
|
||||||
if ((N & (N - 1)) !== 0) {
|
|
||||||
throwError("N", N);
|
|
||||||
}
|
|
||||||
dkLen = parseInt(utils_1.searchPath(data, "crypto/kdfparams/dklen"));
|
|
||||||
if (dkLen !== 32) {
|
|
||||||
throwError("dklen", dkLen);
|
|
||||||
}
|
|
||||||
return [4 /*yield*/, scrypt.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback)];
|
|
||||||
case 1:
|
case 1:
|
||||||
key = _a.sent();
|
key = _a.sent();
|
||||||
//key = arrayify(key);
|
return [2 /*return*/, _getAccount(data, key)];
|
||||||
return [2 /*return*/, getAccount(key)];
|
|
||||||
case 2:
|
|
||||||
if (kdf.toLowerCase() === "pbkdf2") {
|
|
||||||
salt = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/kdfparams/salt"));
|
|
||||||
prfFunc = null;
|
|
||||||
prf = utils_1.searchPath(data, "crypto/kdfparams/prf");
|
|
||||||
if (prf === "hmac-sha256") {
|
|
||||||
prfFunc = "sha256";
|
|
||||||
}
|
|
||||||
else if (prf === "hmac-sha512") {
|
|
||||||
prfFunc = "sha512";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throwError("prf", prf);
|
|
||||||
}
|
|
||||||
c = parseInt(utils_1.searchPath(data, "crypto/kdfparams/c"));
|
|
||||||
dkLen = parseInt(utils_1.searchPath(data, "crypto/kdfparams/dklen"));
|
|
||||||
if (dkLen !== 32) {
|
|
||||||
throwError("dklen", dkLen);
|
|
||||||
}
|
|
||||||
key = bytes_1.arrayify(pbkdf2_1.pbkdf2(passwordBytes, salt, c, dkLen, prfFunc));
|
|
||||||
return [2 /*return*/, getAccount(key)];
|
|
||||||
}
|
|
||||||
_a.label = 3;
|
|
||||||
case 3: return [2 /*return*/, logger.throwArgumentError("unsupported key-derivation function", "kdf", kdf)];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0x8090a7e2dad9b2fb916389e0c7796d9bde973caf1eb55600b6d817449905cd54",
|
"tarballHash": "0x444f5beaea128ad7f3894689177e2b70875b2ddd08fcae32a0dd09d499f6bf81",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.136"
|
"version": "5.0.0-beta.137"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "json-wallets/5.0.0-beta.136";
|
export const version = "json-wallets/5.0.0-beta.137";
|
||||||
|
2
packages/providers/lib.esm/_version.d.ts
vendored
2
packages/providers/lib.esm/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "providers/5.0.0-beta.154";
|
export declare const version = "providers/5.0.0-beta.155";
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "providers/5.0.0-beta.154";
|
export const version = "providers/5.0.0-beta.155";
|
||||||
|
@ -247,7 +247,7 @@ export class BaseProvider extends Provider {
|
|||||||
toBlock: blockNumber,
|
toBlock: blockNumber,
|
||||||
topics: topics
|
topics: topics
|
||||||
};
|
};
|
||||||
if (!filter.address) {
|
if (!filter.address || filter.address === "*") {
|
||||||
delete filter.address;
|
delete filter.address;
|
||||||
}
|
}
|
||||||
const runner = this.getLogs(filter).then((logs) => {
|
const runner = this.getLogs(filter).then((logs) => {
|
||||||
|
2
packages/providers/lib/_version.d.ts
vendored
2
packages/providers/lib/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "providers/5.0.0-beta.154";
|
export declare const version = "providers/5.0.0-beta.155";
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "providers/5.0.0-beta.154";
|
exports.version = "providers/5.0.0-beta.155";
|
||||||
|
@ -311,7 +311,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
|||||||
toBlock: blockNumber,
|
toBlock: blockNumber,
|
||||||
topics: topics
|
topics: topics
|
||||||
};
|
};
|
||||||
if (!filter_1.address) {
|
if (!filter_1.address || filter_1.address === "*") {
|
||||||
delete filter_1.address;
|
delete filter_1.address;
|
||||||
}
|
}
|
||||||
var runner = _this.getLogs(filter_1).then(function (logs) {
|
var runner = _this.getLogs(filter_1).then(function (logs) {
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0xde98df2ddcf9668138d796b06aa2266794a33fd3b41dd89c27e4cd31001d6f22",
|
"tarballHash": "0xc767c5ec2d6ff95465d7c3618d0acc436a5ca169469e63f2ca63d783da619895",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.154"
|
"version": "5.0.0-beta.155"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "providers/5.0.0-beta.154";
|
export const version = "providers/5.0.0-beta.155";
|
||||||
|
2
packages/wallet/lib.esm/_version.d.ts
vendored
2
packages/wallet/lib.esm/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "wallet/5.0.0-beta.137";
|
export declare const version = "wallet/5.0.0-beta.138";
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "wallet/5.0.0-beta.137";
|
export const version = "wallet/5.0.0-beta.138";
|
||||||
|
1
packages/wallet/lib.esm/index.d.ts
vendored
1
packages/wallet/lib.esm/index.d.ts
vendored
@ -24,6 +24,7 @@ export declare class Wallet extends Signer implements ExternallyOwnedAccount {
|
|||||||
*/
|
*/
|
||||||
static createRandom(options?: any): Wallet;
|
static createRandom(options?: any): Wallet;
|
||||||
static fromEncryptedJson(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<Wallet>;
|
static fromEncryptedJson(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<Wallet>;
|
||||||
|
static fromEncryptedJsonSync(json: string, password: Bytes | string): Wallet;
|
||||||
static fromMnemonic(mnemonic: string, path?: string, wordlist?: Wordlist): Wallet;
|
static fromMnemonic(mnemonic: string, path?: string, wordlist?: Wordlist): Wallet;
|
||||||
}
|
}
|
||||||
export declare function verifyMessage(message: Bytes | string, signature: SignatureLike): string;
|
export declare function verifyMessage(message: Bytes | string, signature: SignatureLike): string;
|
||||||
|
@ -9,7 +9,7 @@ import { keccak256 } from "@ethersproject/keccak256";
|
|||||||
import { defineReadOnly, resolveProperties } from "@ethersproject/properties";
|
import { defineReadOnly, resolveProperties } from "@ethersproject/properties";
|
||||||
import { randomBytes } from "@ethersproject/random";
|
import { randomBytes } from "@ethersproject/random";
|
||||||
import { SigningKey } from "@ethersproject/signing-key";
|
import { SigningKey } from "@ethersproject/signing-key";
|
||||||
import { decryptJsonWallet, encryptKeystore } from "@ethersproject/json-wallets";
|
import { decryptJsonWallet, decryptJsonWalletSync, encryptKeystore } from "@ethersproject/json-wallets";
|
||||||
import { computeAddress, recoverAddress, serialize } from "@ethersproject/transactions";
|
import { computeAddress, recoverAddress, serialize } from "@ethersproject/transactions";
|
||||||
import { Logger } from "@ethersproject/logger";
|
import { Logger } from "@ethersproject/logger";
|
||||||
import { version } from "./_version";
|
import { version } from "./_version";
|
||||||
@ -124,6 +124,9 @@ export class Wallet extends Signer {
|
|||||||
return new Wallet(account);
|
return new Wallet(account);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
static fromEncryptedJsonSync(json, password) {
|
||||||
|
return new Wallet(decryptJsonWalletSync(json, password));
|
||||||
|
}
|
||||||
static fromMnemonic(mnemonic, path, wordlist) {
|
static fromMnemonic(mnemonic, path, wordlist) {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
path = defaultPath;
|
path = defaultPath;
|
||||||
|
2
packages/wallet/lib/_version.d.ts
vendored
2
packages/wallet/lib/_version.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const version = "wallet/5.0.0-beta.137";
|
export declare const version = "wallet/5.0.0-beta.138";
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.version = "wallet/5.0.0-beta.137";
|
exports.version = "wallet/5.0.0-beta.138";
|
||||||
|
1
packages/wallet/lib/index.d.ts
vendored
1
packages/wallet/lib/index.d.ts
vendored
@ -24,6 +24,7 @@ export declare class Wallet extends Signer implements ExternallyOwnedAccount {
|
|||||||
*/
|
*/
|
||||||
static createRandom(options?: any): Wallet;
|
static createRandom(options?: any): Wallet;
|
||||||
static fromEncryptedJson(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<Wallet>;
|
static fromEncryptedJson(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise<Wallet>;
|
||||||
|
static fromEncryptedJsonSync(json: string, password: Bytes | string): Wallet;
|
||||||
static fromMnemonic(mnemonic: string, path?: string, wordlist?: Wordlist): Wallet;
|
static fromMnemonic(mnemonic: string, path?: string, wordlist?: Wordlist): Wallet;
|
||||||
}
|
}
|
||||||
export declare function verifyMessage(message: Bytes | string, signature: SignatureLike): string;
|
export declare function verifyMessage(message: Bytes | string, signature: SignatureLike): string;
|
||||||
|
@ -155,6 +155,9 @@ var Wallet = /** @class */ (function (_super) {
|
|||||||
return new Wallet(account);
|
return new Wallet(account);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Wallet.fromEncryptedJsonSync = function (json, password) {
|
||||||
|
return new Wallet(json_wallets_1.decryptJsonWalletSync(json, password));
|
||||||
|
};
|
||||||
Wallet.fromMnemonic = function (mnemonic, path, wordlist) {
|
Wallet.fromMnemonic = function (mnemonic, path, wordlist) {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
path = hdnode_1.defaultPath;
|
path = hdnode_1.defaultPath;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0xa098db4b7fc243e61ce11b86b973f97c3663315cfeabc820a4eda8d6b80dd6d8",
|
"tarballHash": "0x6c595b55e197ee5284306c696556b3e1af92fe0482eeee654276add82025b5c6",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.137"
|
"version": "5.0.0-beta.138"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = "wallet/5.0.0-beta.137";
|
export const version = "wallet/5.0.0-beta.138";
|
||||||
|
Loading…
Reference in New Issue
Block a user