@polkadot/util-keyring
Advanced tools
Comparing version 0.22.11 to 0.23.1
"use strict"; | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L6 | ||
const bs58 = require('bs58'); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
const assert = require('@polkadot/util/assert'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = decode; | ||
const bufferToU8a = require('@polkadot/util/buffer/toU8a'); | ||
var _bs = _interopRequireDefault(require("bs58")); | ||
const isHex = require('@polkadot/util/is/hex'); | ||
var _assert = _interopRequireDefault(require("@polkadot/util/assert")); | ||
const isU8a = require('@polkadot/util/is/u8a'); | ||
var _toU8a = _interopRequireDefault(require("@polkadot/util/buffer/toU8a")); | ||
const u8aToU8a = require('@polkadot/util/u8a/toU8a'); | ||
var _hex = _interopRequireDefault(require("@polkadot/util/is/hex")); | ||
const blake2b = require('@polkadot/util-crypto/blake2/asU8a'); | ||
var _u8a = _interopRequireDefault(require("@polkadot/util/is/u8a")); | ||
module.exports = function decode(encoded) { | ||
if (isU8a(encoded) || isHex(encoded)) { | ||
return u8aToU8a(encoded); | ||
var _toU8a2 = _interopRequireDefault(require("@polkadot/util/u8a/toU8a")); | ||
var _asU8a = _interopRequireDefault(require("@polkadot/util-crypto/blake2/asU8a")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L6 | ||
function decode(encoded) { | ||
if ((0, _u8a.default)(encoded) || (0, _hex.default)(encoded)) { | ||
return (0, _toU8a2.default)(encoded); | ||
} // flowlint-next-line unclear-type:off | ||
@@ -28,11 +35,11 @@ | ||
const str = encoded; | ||
const decoded = bufferToU8a(bs58.decode(str)); | ||
const decoded = (0, _toU8a.default)(_bs.default.decode(str)); | ||
const error = message => `Decoding ${str}: ${message}`; | ||
assert(decoded[0] === 42, error('Invalid decoded address prefix')); | ||
assert(decoded.length === 32 + 1 + 2, error('Invalid decoded address length')); | ||
const hash = blake2b(decoded.subarray(0, 33), 512); | ||
assert(decoded[33] === hash[0] && decoded[34] === hash[1], error(' Invalid decoded address checksum')); | ||
(0, _assert.default)(decoded[0] === 42, error('Invalid decoded address prefix')); | ||
(0, _assert.default)(decoded.length === 32 + 1 + 2, error('Invalid decoded address length')); | ||
const hash = (0, _asU8a.default)(decoded.subarray(0, 33), 512); | ||
(0, _assert.default)(decoded[33] === hash[0] && decoded[34] === hash[1], error(' Invalid decoded address checksum')); | ||
return decoded.slice(1, 33); | ||
}; | ||
} |
"use strict"; | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L34 | ||
const bs58 = require('bs58'); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
const assert = require('@polkadot/util/assert'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = encode; | ||
const u8aConcat = require('@polkadot/util/u8a/concat'); | ||
var _bs = _interopRequireDefault(require("bs58")); | ||
const u8aToBuffer = require('@polkadot/util/u8a/toBuffer'); | ||
var _assert = _interopRequireDefault(require("@polkadot/util/assert")); | ||
const u8aToU8a = require('@polkadot/util/u8a/toU8a'); | ||
var _concat = _interopRequireDefault(require("@polkadot/util/u8a/concat")); | ||
const blake2b = require('@polkadot/util-crypto/blake2/asU8a'); | ||
var _toBuffer = _interopRequireDefault(require("@polkadot/util/u8a/toBuffer")); | ||
var _toU8a = _interopRequireDefault(require("@polkadot/util/u8a/toU8a")); | ||
var _asU8a = _interopRequireDefault(require("@polkadot/util-crypto/blake2/asU8a")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L34 | ||
const PREFIX = new Uint8Array([42]); | ||
module.exports = function encode(_publicKey) { | ||
const publicKey = u8aToU8a(_publicKey); | ||
assert(publicKey.length === 32, `Expected a valid publicKey to convert`); | ||
const input = u8aConcat(PREFIX, publicKey); | ||
const hash = blake2b(input, 512); | ||
return bs58.encode(u8aToBuffer(u8aConcat(input, hash.subarray(0, 2)))); | ||
}; | ||
function encode(_publicKey) { | ||
const publicKey = (0, _toU8a.default)(_publicKey); | ||
(0, _assert.default)(publicKey.length === 32, `Expected a valid publicKey to convert`); | ||
const input = (0, _concat.default)(PREFIX, publicKey); | ||
const hash = (0, _asU8a.default)(input, 512); | ||
return _bs.default.encode((0, _toBuffer.default)((0, _concat.default)(input, hash.subarray(0, 2)))); | ||
} |
"use strict"; | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const decodeAddress = require('./decode'); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
const encodeAddress = require('./encode'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "decodeAddress", { | ||
enumerable: true, | ||
get: function get() { | ||
return _decode.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "encodeAddress", { | ||
enumerable: true, | ||
get: function get() { | ||
return _encode.default; | ||
} | ||
}); | ||
module.exports = { | ||
decodeAddress, | ||
encodeAddress | ||
}; | ||
var _decode = _interopRequireDefault(require("./decode")); | ||
var _encode = _interopRequireDefault(require("./encode")); |
37
index.js
"use strict"; | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const naclKeypairFromSeed = require('@polkadot/util-crypto/nacl/keypair/fromSeed'); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
const hexToU8a = require('@polkadot/util/hex/toU8a'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = keyring; | ||
const addressDecode = require('./address/decode'); | ||
var _fromSeed = _interopRequireDefault(require("@polkadot/util-crypto/nacl/keypair/fromSeed")); | ||
const createPair = require('./pair'); | ||
var _toU8a = _interopRequireDefault(require("@polkadot/util/hex/toU8a")); | ||
const createPairs = require('./pairs'); | ||
var _decode = _interopRequireDefault(require("./address/decode")); | ||
module.exports = function keyring() { | ||
const pairs = createPairs(); | ||
var _pair = _interopRequireDefault(require("./pair")); | ||
const addFromAddress = (address, meta, defaultEncoded) => pairs.add(createPair({ | ||
publicKey: addressDecode(address) | ||
var _pairs = _interopRequireDefault(require("./pairs")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
function keyring() { | ||
const pairs = (0, _pairs.default)(); | ||
const addFromAddress = (address, meta, defaultEncoded) => pairs.add((0, _pair.default)({ | ||
publicKey: (0, _decode.default)(address) | ||
}, meta, defaultEncoded)); | ||
@@ -29,4 +36,4 @@ | ||
meta | ||
}) => addFromAddress(address, meta, hexToU8a(encoded)), | ||
addFromSeed: (seed, meta) => pairs.add(createPair(naclKeypairFromSeed(seed), meta)), | ||
}) => addFromAddress(address, meta, (0, _toU8a.default)(encoded)), | ||
addFromSeed: (seed, meta) => pairs.add((0, _pair.default)((0, _fromSeed.default)(seed), meta)), | ||
getPair: address => pairs.get(address), | ||
@@ -40,2 +47,2 @@ getPairs: pairs.all, | ||
}; | ||
}; | ||
} |
{ | ||
"name": "@polkadot/util-keyring", | ||
"version": "0.22.11", | ||
"version": "0.23.1", | ||
"description": "Keyring management", | ||
@@ -39,6 +39,6 @@ "main": "index.js", | ||
"@babel/runtime": "^7.0.0-beta.47", | ||
"@polkadot/util": "^0.22.11", | ||
"@polkadot/util-crypto": "^0.22.11", | ||
"@polkadot/util": "^0.23.1", | ||
"@polkadot/util-crypto": "^0.23.1", | ||
"bs58": "^4.0.1" | ||
} | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = decode; | ||
require("core-js/modules/es6.regexp.to-string"); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const u8aConcat = require('@polkadot/util/u8a/concat'); | ||
var _concat = _interopRequireDefault(require("@polkadot/util/u8a/concat")); | ||
const u8aFixLength = require('@polkadot/util/u8a/fixLength'); | ||
var _fixLength = _interopRequireDefault(require("@polkadot/util/u8a/fixLength")); | ||
const u8aFromString = require('@polkadot/util/u8a/fromString'); | ||
var _fromString = _interopRequireDefault(require("@polkadot/util/u8a/fromString")); | ||
const assert = require('@polkadot/util/assert'); | ||
var _assert = _interopRequireDefault(require("@polkadot/util/assert")); | ||
const naclDecrypt = require('@polkadot/util-crypto/nacl/decrypt'); | ||
var _decrypt = _interopRequireDefault(require("@polkadot/util-crypto/nacl/decrypt")); | ||
const naclFromSeed = require('@polkadot/util-crypto/nacl/keypair/fromSeed'); | ||
var _fromSeed = _interopRequireDefault(require("@polkadot/util-crypto/nacl/keypair/fromSeed")); | ||
const _require = require('./defaults'), | ||
PKCS8_DIVIDER = _require.PKCS8_DIVIDER, | ||
PKCS8_HEADER = _require.PKCS8_HEADER; | ||
var _defaults = require("./defaults"); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const KEY_LENGTH = 32; | ||
const SEED_OFFSET = PKCS8_HEADER.length; | ||
const SEED_OFFSET = _defaults.PKCS8_HEADER.length; | ||
const DIV_OFFSET = SEED_OFFSET + KEY_LENGTH; | ||
const PUBLIC_OFFSET = SEED_OFFSET + KEY_LENGTH + PKCS8_DIVIDER.length; | ||
const PUBLIC_OFFSET = SEED_OFFSET + KEY_LENGTH + _defaults.PKCS8_DIVIDER.length; | ||
module.exports = function decode(passphrase, _encrypted) { | ||
assert(_encrypted, `No encrypted data available to decode`); // flowlint-next-line unclear-type:off | ||
function decode(passphrase, _encrypted) { | ||
(0, _assert.default)(_encrypted, `No encrypted data available to decode`); // flowlint-next-line unclear-type:off | ||
@@ -35,13 +40,13 @@ const encrypted = _encrypted; // flowlint-next-line sketchy-null-string:off | ||
const encoded = passphrase // flowlint-next-line unclear-type:off | ||
? naclDecrypt(encrypted.subarray(24), encrypted.subarray(0, 24), u8aFixLength(u8aFromString(passphrase), 256, true)) : encrypted; | ||
assert(encoded, `Unable to unencrypt using the supplied passphrase`); | ||
const header = encoded.subarray(0, PKCS8_HEADER.length); | ||
const divider = encoded.subarray(DIV_OFFSET, DIV_OFFSET + PKCS8_DIVIDER.length); | ||
assert(header.toString() === PKCS8_HEADER.toString(), 'Invalid Pkcs8 header found in body'); | ||
assert(divider.toString() === PKCS8_DIVIDER.toString(), 'Invalid Pkcs8 divider found in body'); | ||
? (0, _decrypt.default)(encrypted.subarray(24), encrypted.subarray(0, 24), (0, _fixLength.default)((0, _fromString.default)(passphrase), 256, true)) : encrypted; | ||
(0, _assert.default)(encoded, `Unable to unencrypt using the supplied passphrase`); | ||
const header = encoded.subarray(0, _defaults.PKCS8_HEADER.length); | ||
const divider = encoded.subarray(DIV_OFFSET, DIV_OFFSET + _defaults.PKCS8_DIVIDER.length); | ||
(0, _assert.default)(header.toString() === _defaults.PKCS8_HEADER.toString(), 'Invalid Pkcs8 header found in body'); | ||
(0, _assert.default)(divider.toString() === _defaults.PKCS8_DIVIDER.toString(), 'Invalid Pkcs8 divider found in body'); | ||
const publicKey = encoded.subarray(PUBLIC_OFFSET, PUBLIC_OFFSET + KEY_LENGTH); | ||
const seed = encoded.subarray(SEED_OFFSET, SEED_OFFSET + KEY_LENGTH); | ||
const secretKey = u8aConcat(seed, publicKey); | ||
const validate = naclFromSeed(seed); | ||
assert(validate.publicKey.toString() === publicKey.toString(), 'Pkcs8 decoded publicKeys are not matching'); | ||
const secretKey = (0, _concat.default)(seed, publicKey); | ||
const validate = (0, _fromSeed.default)(seed); | ||
(0, _assert.default)(validate.publicKey.toString() === publicKey.toString(), 'Pkcs8 decoded publicKeys are not matching'); | ||
return { | ||
@@ -51,2 +56,2 @@ publicKey, | ||
}; | ||
}; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.PKCS8_HEADER = exports.PKCS8_DIVIDER = void 0; | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
@@ -7,6 +11,4 @@ // This software may be modified and distributed under the terms | ||
const PKCS8_DIVIDER = new Uint8Array([161, 35, 3, 33, 0]); | ||
exports.PKCS8_DIVIDER = PKCS8_DIVIDER; | ||
const PKCS8_HEADER = new Uint8Array([48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]); | ||
module.exports = { | ||
PKCS8_DIVIDER, | ||
PKCS8_HEADER | ||
}; | ||
exports.PKCS8_HEADER = PKCS8_HEADER; |
"use strict"; | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const u8aConcat = require('@polkadot/util/u8a/concat'); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
const u8aFixLength = require('@polkadot/util/u8a/fixLength'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = encode; | ||
const u8aFromString = require('@polkadot/util/u8a/fromString'); | ||
var _concat = _interopRequireDefault(require("@polkadot/util/u8a/concat")); | ||
const naclEncrypt = require('@polkadot/util-crypto/nacl/encrypt'); | ||
var _fixLength = _interopRequireDefault(require("@polkadot/util/u8a/fixLength")); | ||
const _require = require('./defaults'), | ||
PKCS8_DIVIDER = _require.PKCS8_DIVIDER, | ||
PKCS8_HEADER = _require.PKCS8_HEADER; | ||
var _fromString = _interopRequireDefault(require("@polkadot/util/u8a/fromString")); | ||
module.exports = function encode(secretKey, passphrase) { | ||
const encoded = u8aConcat(PKCS8_HEADER, secretKey.subarray(0, 32), PKCS8_DIVIDER, secretKey.subarray(32, 64)); // flowlint-next-line sketchy-null-string:off | ||
var _encrypt = _interopRequireDefault(require("@polkadot/util-crypto/nacl/encrypt")); | ||
var _defaults = require("./defaults"); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
function encode(secretKey, passphrase) { | ||
const encoded = (0, _concat.default)(_defaults.PKCS8_HEADER, secretKey.subarray(0, 32), _defaults.PKCS8_DIVIDER, secretKey.subarray(32, 64)); // flowlint-next-line sketchy-null-string:off | ||
if (!passphrase) { | ||
@@ -25,7 +30,7 @@ return encoded; | ||
const _naclEncrypt = naclEncrypt(encoded, u8aFixLength(u8aFromString(passphrase), 256, true)), | ||
const _naclEncrypt = (0, _encrypt.default)(encoded, (0, _fixLength.default)((0, _fromString.default)(passphrase), 256, true)), | ||
encrypted = _naclEncrypt.encrypted, | ||
nonce = _naclEncrypt.nonce; | ||
return u8aConcat(nonce, encrypted); | ||
}; | ||
return (0, _concat.default)(nonce, encrypted); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = getMeta; | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
module.exports = function getMeta(state) { | ||
function getMeta(state) { | ||
return state.meta; | ||
}; | ||
} |
@@ -5,24 +5,29 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = pair; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const naclSign = require('@polkadot/util-crypto/nacl/sign'); | ||
var _sign = _interopRequireDefault(require("@polkadot/util-crypto/nacl/sign")); | ||
const naclVerify = require('@polkadot/util-crypto/nacl/verify'); | ||
var _verify = _interopRequireDefault(require("@polkadot/util-crypto/nacl/verify")); | ||
const encodeAddress = require('../address/encode'); | ||
var _encode = _interopRequireDefault(require("../address/encode")); | ||
const decode = require('./decode'); | ||
var _decode = _interopRequireDefault(require("./decode")); | ||
const encode = require('./encode'); | ||
var _encode2 = _interopRequireDefault(require("./encode")); | ||
const _getMeta = require('./getMeta'); | ||
var _getMeta2 = _interopRequireDefault(require("./getMeta")); | ||
const _setMeta = require('./setMeta'); | ||
var _setMeta2 = _interopRequireDefault(require("./setMeta")); | ||
const _toJson = require('./toJson'); | ||
var _toJson2 = _interopRequireDefault(require("./toJson")); | ||
module.exports = function pair({ | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
function pair({ | ||
publicKey: _publicKey, | ||
@@ -32,3 +37,3 @@ secretKey | ||
const state = { | ||
address: encodeAddress(_publicKey), | ||
address: (0, _encode.default)(_publicKey), | ||
meta: (0, _objectSpread2.default)({}, meta) | ||
@@ -39,16 +44,16 @@ }; | ||
decodePkcs8: (passphrase, encoded) => { | ||
const decoded = decode(passphrase, encoded || defaultEncoded); | ||
const decoded = (0, _decode.default)(passphrase, encoded || defaultEncoded); | ||
_publicKey = decoded.publicKey; | ||
secretKey = decoded.secretKey; | ||
state.address = encodeAddress(_publicKey); | ||
state.address = (0, _encode.default)(_publicKey); | ||
}, | ||
encodePkcs8: passphrase => encode(secretKey, passphrase), | ||
getMeta: () => _getMeta(state), | ||
encodePkcs8: passphrase => (0, _encode2.default)(secretKey, passphrase), | ||
getMeta: () => (0, _getMeta2.default)(state), | ||
hasSecretKey: () => !!(secretKey && secretKey.length !== 0), | ||
publicKey: () => _publicKey, | ||
setMeta: meta => _setMeta(state, meta), | ||
sign: message => naclSign(message, secretKey), | ||
toJson: passphrase => _toJson(state, encode(secretKey, passphrase), !!passphrase), | ||
verify: (message, signature) => naclVerify(message, signature, _publicKey) | ||
setMeta: meta => (0, _setMeta2.default)(state, meta), | ||
sign: message => (0, _sign.default)(message, secretKey), | ||
toJson: passphrase => (0, _toJson2.default)(state, (0, _encode2.default)(secretKey, passphrase), !!passphrase), | ||
verify: (message, signature) => (0, _verify.default)(message, signature, _publicKey) | ||
}; | ||
}; | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = everybody; | ||
var _encode = _interopRequireDefault(require("../address/encode")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const addressEncode = require('../address/encode'); | ||
const _publicKey = new Uint8Array(32); | ||
const _address = addressEncode(_publicKey); | ||
const _address = (0, _encode.default)(_publicKey); | ||
@@ -26,3 +33,3 @@ const meta = { | ||
module.exports = function everybody() { | ||
function everybody() { | ||
return { | ||
@@ -40,2 +47,2 @@ address: () => _address, | ||
}; | ||
}; | ||
} |
@@ -5,2 +5,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = setMeta; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
@@ -11,4 +16,4 @@ | ||
// of the ISC license. See the LICENSE file for details. | ||
module.exports = function setMeta(state, meta) { | ||
function setMeta(state, meta) { | ||
state.meta = (0, _objectSpread2.default)({}, state.meta, meta); | ||
}; | ||
} |
@@ -5,10 +5,15 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = toJson; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _toHex = _interopRequireDefault(require("@polkadot/util/u8a/toHex")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const u8aToHex = require('@polkadot/util/u8a/toHex'); | ||
module.exports = function toJson({ | ||
function toJson({ | ||
address, | ||
@@ -19,3 +24,3 @@ meta | ||
address, | ||
encoded: u8aToHex(encoded), | ||
encoded: (0, _toHex.default)(encoded), | ||
encoding: { | ||
@@ -28,2 +33,2 @@ content: 'pkcs8', | ||
}; | ||
}; | ||
} |
35
pairs.js
@@ -5,20 +5,25 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = pairs; | ||
var _values = _interopRequireDefault(require("@babel/runtime/core-js/object/values")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const assert = require('@polkadot/util/assert'); | ||
var _assert = _interopRequireDefault(require("@polkadot/util/assert")); | ||
const isHex = require('@polkadot/util/is/hex'); | ||
var _hex = _interopRequireDefault(require("@polkadot/util/is/hex")); | ||
const isU8a = require('@polkadot/util/is/u8a'); | ||
var _u8a = _interopRequireDefault(require("@polkadot/util/is/u8a")); | ||
const u8aToHex = require('@polkadot/util/u8a/toHex'); | ||
var _toHex = _interopRequireDefault(require("@polkadot/util/u8a/toHex")); | ||
const u8aToU8a = require('@polkadot/util/u8a/toU8a'); | ||
var _toU8a = _interopRequireDefault(require("@polkadot/util/u8a/toU8a")); | ||
const addressDecode = require('./address/decode'); | ||
var _decode = _interopRequireDefault(require("./address/decode")); | ||
module.exports = function pairs() { | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
function pairs() { | ||
const self = {}; | ||
@@ -33,5 +38,5 @@ return { | ||
get: address => { | ||
const pair = self[addressDecode(address)]; | ||
assert(pair, () => { | ||
const formatted = isU8a(address) || isHex(address) ? u8aToHex(u8aToU8a(address)) // flowlint-next-line unclear-type:off | ||
const pair = self[(0, _decode.default)(address)]; | ||
(0, _assert.default)(pair, () => { | ||
const formatted = (0, _u8a.default)(address) || (0, _hex.default)(address) ? (0, _toHex.default)((0, _toU8a.default)(address)) // flowlint-next-line unclear-type:off | ||
: address; | ||
@@ -43,5 +48,5 @@ return `Unable to retrieve keypair '${formatted}'`; | ||
remove: address => { | ||
delete self[addressDecode(address)]; | ||
delete self[(0, _decode.default)(address)]; | ||
} | ||
}; | ||
}; | ||
} |
@@ -5,2 +5,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = testKeyring; | ||
var _keys = _interopRequireDefault(require("@babel/runtime/core-js/object/keys")); | ||
@@ -10,13 +15,13 @@ | ||
var _toU8a = _interopRequireDefault(require("@polkadot/util/hex/toU8a")); | ||
var _fromString = _interopRequireDefault(require("@polkadot/util/u8a/fromString")); | ||
var _index = _interopRequireDefault(require("./index")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const hexToU8a = require('@polkadot/util/hex/toU8a'); | ||
const u8aFromString = require('@polkadot/util/u8a/fromString'); | ||
const createKeyring = require('./index'); | ||
function padSeed(seed) { | ||
return u8aFromString(seed.padEnd(32, ' ')); | ||
return (0, _fromString.default)(seed.padEnd(32, ' ')); | ||
} | ||
@@ -32,7 +37,7 @@ | ||
one: padSeed('12345678901234567890123456789012'), | ||
two: hexToU8a('0x9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60') | ||
two: (0, _toU8a.default)('0x9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60') | ||
}; | ||
module.exports = function testKeyring() { | ||
const keyring = createKeyring(); | ||
function testKeyring() { | ||
const keyring = (0, _index.default)(); | ||
(0, _keys.default)(SEEDS).forEach(name => { | ||
@@ -45,2 +50,2 @@ keyring.addFromSeed(SEEDS[name], { | ||
return keyring; | ||
}; | ||
} |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = testKeyringPairs; | ||
var _testing = _interopRequireDefault(require("./testing")); | ||
var _nobody = _interopRequireDefault(require("./pair/nobody")); | ||
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the ISC license. See the LICENSE file for details. | ||
const createKeyring = require('./testing'); | ||
const nobody = require('./pair/nobody')(); | ||
module.exports = function testKeyringPairs() { | ||
const keyring = createKeyring(); | ||
function testKeyringPairs() { | ||
const keyring = (0, _testing.default)(); | ||
const pairs = keyring.getPairs(); | ||
@@ -21,4 +28,4 @@ return pairs.reduce((result, pair) => { | ||
_keyring: keyring, | ||
nobody | ||
nobody: (0, _nobody.default)() | ||
}); | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
39465
404
+ Added@polkadot/util@0.23.2(transitive)
+ Added@polkadot/util-crypto@0.23.2(transitive)
- Removed@polkadot/util@0.22.11(transitive)
- Removed@polkadot/util-crypto@0.22.11(transitive)
Updated@polkadot/util@^0.23.1