@airgap/coinlib-core 0.13.45-beta.3 → 0.13.45-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/Action.js +83 -30
- package/actions/Action.js.map +1 -1
- package/actions/LinkedAction.js +82 -18
- package/actions/LinkedAction.js.map +1 -1
- package/actions/RepeatableAction.js +83 -20
- package/actions/RepeatableAction.js.map +1 -1
- package/actions/SimpleAction.js +74 -12
- package/actions/SimpleAction.js.map +1 -1
- package/actions/StateMachine.js +17 -16
- package/actions/StateMachine.js.map +1 -1
- package/data/KeyPair.d.ts +1 -0
- package/data/Lazy.js +64 -15
- package/data/Lazy.js.map +1 -1
- package/data/RPCBody.js +6 -3
- package/data/RPCBody.js.map +1 -1
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.d.ts +12 -12
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js +130 -88
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js.map +1 -1
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.d.ts +3 -3
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js +61 -57
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js.map +1 -1
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js +96 -96
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js.map +1 -1
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js +2 -1
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js.map +1 -1
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js +10 -8
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js +28 -22
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js +10 -9
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js +11 -10
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js +8 -7
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js.map +1 -1
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.d.ts +3 -3
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js +63 -61
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js.map +1 -1
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.d.ts +4 -4
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js +63 -61
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js.map +1 -1
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.d.ts +1 -1
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js +3 -2
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js +111 -111
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js +15 -15
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js +76 -47
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js +61 -46
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js +106 -61
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/interface.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.d.ts +6 -6
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js +100 -95
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js +33 -33
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js +9 -9
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js +75 -46
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js +70 -45
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js +41 -41
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js +4 -4
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.d.ts +2 -2
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js +63 -58
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js +33 -30
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js +20 -18
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js +12 -5
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js +13 -13
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.d.ts +78 -78
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js +2 -2
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.d.ts +45 -45
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js +76 -75
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js +178 -115
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.d.ts +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js +9 -6
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js +83 -78
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js +36 -27
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.d.ts +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js +26 -25
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js.map +1 -1
- package/dependencies/src/cosmjs/index.d.ts +230 -14
- package/dependencies/src/cosmjs/index.js +480 -373
- package/dependencies/src/cosmjs/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/index.d.ts +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/index.js +19 -15
- package/dependencies/src/eciesjs-0.3.9/src/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.d.ts +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js +28 -37
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.d.ts +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js +30 -38
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/utils.d.ts +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/utils.js +24 -33
- package/dependencies/src/eciesjs-0.3.9/src/utils.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js +34 -42
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js +10 -6
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js.map +1 -1
- package/errors/coinlib-error.d.ts +2 -1
- package/errors/coinlib-error.js +38 -16
- package/errors/coinlib-error.js.map +1 -1
- package/errors/index.d.ts +2 -2
- package/errors/index.js +148 -89
- package/errors/index.js.map +1 -1
- package/index.js +19 -19
- package/index.js.map +1 -1
- package/interfaces/IAirGapSignedTransaction.d.ts +1 -1
- package/interfaces/IAirGapTransaction.js +3 -3
- package/interfaces/IAirGapTransaction.js.map +1 -1
- package/networks.js +9 -9
- package/networks.js.map +1 -1
- package/package.json +1 -1
- package/protocols/BlockExplorerProtocol.js +54 -7
- package/protocols/BlockExplorerProtocol.js.map +1 -1
- package/protocols/CryptoClient.js +78 -19
- package/protocols/CryptoClient.js.map +1 -1
- package/protocols/Ed25519CryptoClient.js +98 -30
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinSubProtocol.js +1 -1
- package/protocols/ICoinSubProtocol.js.map +1 -1
- package/protocols/NonExtendedProtocol.js +29 -26
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/Secp256k1CryptoClient.js +73 -9
- package/protocols/Secp256k1CryptoClient.js.map +1 -1
- package/protocols/Sr25519CryptoClient.js +76 -12
- package/protocols/Sr25519CryptoClient.js.map +1 -1
- package/utils/AES.js +132 -81
- package/utils/AES.js.map +1 -1
- package/utils/ErrorWithData.js +23 -5
- package/utils/ErrorWithData.js.map +1 -1
- package/utils/Network.js +1 -1
- package/utils/Network.js.map +1 -1
- package/utils/ProtocolBlockExplorer.js +4 -3
- package/utils/ProtocolBlockExplorer.js.map +1 -1
- package/utils/ProtocolNetwork.js +16 -11
- package/utils/ProtocolNetwork.js.map +1 -1
- package/utils/ProtocolSymbols.d.ts +3 -1
- package/utils/ProtocolSymbols.js +8 -6
- package/utils/ProtocolSymbols.js.map +1 -1
- package/utils/array.js +15 -14
- package/utils/array.js.map +1 -1
- package/utils/assert.js +12 -8
- package/utils/assert.js.map +1 -1
- package/utils/base64Check.d.ts +1 -0
- package/utils/base64Check.js +15 -15
- package/utils/base64Check.js.map +1 -1
- package/utils/blake2b.js +14 -11
- package/utils/blake2b.js.map +1 -1
- package/utils/buffer.d.ts +1 -0
- package/utils/buffer.js +1 -1
- package/utils/buffer.js.map +1 -1
- package/utils/cache.js +87 -38
- package/utils/cache.js.map +1 -1
- package/utils/error.js +3 -2
- package/utils/error.js.map +1 -1
- package/utils/hex.d.ts +2 -1
- package/utils/hex.js +38 -31
- package/utils/hex.js.map +1 -1
- package/utils/interfaces.js +4 -3
- package/utils/interfaces.js.map +1 -1
- package/utils/object.js +7 -5
- package/utils/object.js.map +1 -1
- package/utils/padStart.js +2 -1
- package/utils/padStart.js.map +1 -1
- package/utils/remote-data/HttpRemoteData.js +107 -24
- package/utils/remote-data/HttpRemoteData.js.map +1 -1
- package/utils/remote-data/IpfsRemoteData.js +116 -32
- package/utils/remote-data/IpfsRemoteData.js.map +1 -1
- package/utils/remote-data/RemoteData.d.ts +1 -0
- package/utils/remote-data/RemoteData.js +4 -3
- package/utils/remote-data/RemoteData.js.map +1 -1
- package/utils/remote-data/RemoteDataFactory.d.ts +2 -2
- package/utils/remote-data/RemoteDataFactory.js +20 -13
- package/utils/remote-data/RemoteDataFactory.js.map +1 -1
- package/utils/remote-data/Sha256RemoteData.d.ts +1 -0
- package/utils/remote-data/Sha256RemoteData.js +117 -44
- package/utils/remote-data/Sha256RemoteData.js.map +1 -1
- package/utils/string.js +9 -8
- package/utils/string.js.map +1 -1
- package/utils/type.js +4 -3
- package/utils/type.js.map +1 -1
- package/utils/xxhash.d.ts +1 -0
- package/utils/xxhash.js +11 -9
- package/utils/xxhash.js.map +1 -1
- package/wallet/AirGapCoinWallet.js +183 -64
- package/wallet/AirGapCoinWallet.js.map +1 -1
- package/wallet/AirGapMarketWallet.js +201 -88
- package/wallet/AirGapMarketWallet.js.map +1 -1
- package/wallet/AirGapNFTWallet.js +165 -48
- package/wallet/AirGapNFTWallet.js.map +1 -1
- package/wallet/AirGapWallet.js +145 -58
- package/wallet/AirGapWallet.js.map +1 -1
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
// Copyright (C) 2016 Dmitry Chestnykh
|
|
3
3
|
// MIT License. See LICENSE file for details.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.isSafeInteger = exports.MAX_SAFE_INTEGER = exports.isInteger = exports.mul = void 0;
|
|
6
|
-
exports.add = add;
|
|
7
|
-
exports.sub = sub;
|
|
8
|
-
exports.rotl = rotl;
|
|
9
|
-
exports.rotr = rotr;
|
|
5
|
+
exports.isSafeInteger = exports.MAX_SAFE_INTEGER = exports.isInteger = exports.rotr = exports.rotl = exports.sub = exports.add = exports.mul = void 0;
|
|
10
6
|
/**
|
|
11
7
|
* Package int provides helper functions for integerss.
|
|
12
8
|
*/
|
|
13
9
|
// Shim using 16-bit pieces.
|
|
14
10
|
function imulShim(a, b) {
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
var ah = (a >>> 16) & 0xffff, al = a & 0xffff;
|
|
12
|
+
var bh = (b >>> 16) & 0xffff, bl = b & 0xffff;
|
|
17
13
|
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0);
|
|
18
14
|
}
|
|
19
15
|
/** 32-bit integer multiplication. */
|
|
@@ -23,18 +19,22 @@ exports.mul = Math.imul || imulShim;
|
|
|
23
19
|
function add(a, b) {
|
|
24
20
|
return (a + b) | 0;
|
|
25
21
|
}
|
|
22
|
+
exports.add = add;
|
|
26
23
|
/** 32-bit integer subtraction. */
|
|
27
24
|
function sub(a, b) {
|
|
28
25
|
return (a - b) | 0;
|
|
29
26
|
}
|
|
27
|
+
exports.sub = sub;
|
|
30
28
|
/** 32-bit integer left rotation */
|
|
31
29
|
function rotl(x, n) {
|
|
32
30
|
return x << n | x >>> (32 - n);
|
|
33
31
|
}
|
|
32
|
+
exports.rotl = rotl;
|
|
34
33
|
/** 32-bit integer left rotation */
|
|
35
34
|
function rotr(x, n) {
|
|
36
35
|
return x << (32 - n) | x >>> n;
|
|
37
36
|
}
|
|
37
|
+
exports.rotr = rotr;
|
|
38
38
|
function isIntegerShim(n) {
|
|
39
39
|
return typeof n === "number" && isFinite(n) && Math.floor(n) === n;
|
|
40
40
|
}
|
|
@@ -56,6 +56,8 @@ exports.MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
56
56
|
*
|
|
57
57
|
* In ES2015, Number.isSafeInteger.
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
var isSafeInteger = function (n) {
|
|
60
|
+
return (0, exports.isInteger)(n) && (n >= -exports.MAX_SAFE_INTEGER && n <= exports.MAX_SAFE_INTEGER);
|
|
61
|
+
};
|
|
60
62
|
exports.isSafeInteger = isSafeInteger;
|
|
61
63
|
//# sourceMappingURL=int.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int.js","sourceRoot":"","sources":["../../../../../../../src/dependencies/src/@stablelib/int-1.0.1/packages/int/int.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;
|
|
1
|
+
{"version":3,"file":"int.js","sourceRoot":"","sources":["../../../../../../../src/dependencies/src/@stablelib/int-1.0.1/packages/int/int.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;AAE7C;;GAEG;AAEH,4BAA4B;AAC5B,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IAClC,IAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IAChD,IAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IAChD,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,sCAAsC;AACtC,6DAA6D;AAChD,QAAA,GAAG,GAAI,IAAgD,CAAC,IAAI,IAAI,QAAQ,CAAC;AAEtF,gCAAgC;AAChC,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS;IACpC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAFD,kBAEC;AAED,oCAAoC;AACpC,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS;IACpC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAFD,kBAEC;AAED,mCAAmC;AACnC,SAAgB,IAAI,CAAC,CAAS,EAAE,CAAS;IACrC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC;AAFD,oBAEC;AAED,mCAAmC;AACnC,SAAgB,IAAI,CAAC,CAAS,EAAE,CAAS;IACrC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAFD,oBAEC;AAED,SAAS,aAAa,CAAC,CAAS;IAC5B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACU,QAAA,SAAS,GAAI,MAA6C,CAAC,SAAS,IAAI,aAAa,CAAC;AAEnG;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD;;;;;GAKG;AACI,IAAM,aAAa,GAAG,UAAC,CAAS;IACnC,OAAA,IAAA,iBAAS,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,wBAAgB,IAAI,CAAC,IAAI,wBAAgB,CAAC;AAAjE,CAAiE,CAAC;AADzD,QAAA,aAAa,iBAC4C"}
|
|
@@ -2,34 +2,34 @@
|
|
|
2
2
|
// Copyright (C) 2016 Dmitry Chestnykh
|
|
3
3
|
// MIT License. See LICENSE file for details.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.defaultRandomSource = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.randomStringForEntropy = randomStringForEntropy;
|
|
10
|
-
const system_1 = require("./source/system");
|
|
11
|
-
const binary_1 = require("../../../../@stablelib/binary-1.0.1/packages/binary/binary");
|
|
12
|
-
const wipe_1 = require("../../../../@stablelib/wipe-1.0.1/packages/wipe/wipe");
|
|
5
|
+
exports.randomStringForEntropy = exports.randomString = exports.randomUint32 = exports.randomBytes = exports.defaultRandomSource = void 0;
|
|
6
|
+
var system_1 = require("./source/system");
|
|
7
|
+
var binary_1 = require("../../../../@stablelib/binary-1.0.1/packages/binary/binary");
|
|
8
|
+
var wipe_1 = require("../../../../@stablelib/wipe-1.0.1/packages/wipe/wipe");
|
|
13
9
|
exports.defaultRandomSource = new system_1.SystemRandomSource();
|
|
14
|
-
function randomBytes(length, prng
|
|
10
|
+
function randomBytes(length, prng) {
|
|
11
|
+
if (prng === void 0) { prng = exports.defaultRandomSource; }
|
|
15
12
|
return prng.randomBytes(length);
|
|
16
13
|
}
|
|
14
|
+
exports.randomBytes = randomBytes;
|
|
17
15
|
/**
|
|
18
16
|
* Returns a uniformly random unsigned 32-bit integer.
|
|
19
17
|
*/
|
|
20
|
-
function randomUint32(prng
|
|
18
|
+
function randomUint32(prng) {
|
|
19
|
+
if (prng === void 0) { prng = exports.defaultRandomSource; }
|
|
21
20
|
// Generate 4-byte random buffer.
|
|
22
|
-
|
|
21
|
+
var buf = randomBytes(4, prng);
|
|
23
22
|
// Convert bytes from buffer into a 32-bit integer.
|
|
24
23
|
// It's not important which byte order to use, since
|
|
25
24
|
// the result is random.
|
|
26
|
-
|
|
25
|
+
var result = (0, binary_1.readUint32LE)(buf);
|
|
27
26
|
// Clean the buffer.
|
|
28
27
|
(0, wipe_1.wipe)(buf);
|
|
29
28
|
return result;
|
|
30
29
|
}
|
|
30
|
+
exports.randomUint32 = randomUint32;
|
|
31
31
|
/** 62 alphanumeric characters for default charset of randomString() */
|
|
32
|
-
|
|
32
|
+
var ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
33
33
|
/**
|
|
34
34
|
* Returns a uniform random string of the given length
|
|
35
35
|
* with characters from the given charset.
|
|
@@ -39,20 +39,22 @@ const ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv
|
|
|
39
39
|
* Default charset generates case-sensitive alphanumeric
|
|
40
40
|
* strings (0-9, A-Z, a-z).
|
|
41
41
|
*/
|
|
42
|
-
function randomString(length, charset
|
|
42
|
+
function randomString(length, charset, prng) {
|
|
43
|
+
if (charset === void 0) { charset = ALPHANUMERIC; }
|
|
44
|
+
if (prng === void 0) { prng = exports.defaultRandomSource; }
|
|
43
45
|
if (charset.length < 2) {
|
|
44
46
|
throw new Error("randomString charset is too short");
|
|
45
47
|
}
|
|
46
48
|
if (charset.length > 256) {
|
|
47
49
|
throw new Error("randomString charset is too long");
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
var out = '';
|
|
52
|
+
var charsLen = charset.length;
|
|
53
|
+
var maxByte = 256 - (256 % charsLen);
|
|
52
54
|
while (length > 0) {
|
|
53
|
-
|
|
54
|
-
for (
|
|
55
|
-
|
|
55
|
+
var buf = randomBytes(Math.ceil(length * 256 / maxByte), prng);
|
|
56
|
+
for (var i = 0; i < buf.length && length > 0; i++) {
|
|
57
|
+
var randomByte = buf[i];
|
|
56
58
|
if (randomByte < maxByte) {
|
|
57
59
|
out += charset.charAt(randomByte % charsLen);
|
|
58
60
|
length--;
|
|
@@ -62,6 +64,7 @@ function randomString(length, charset = ALPHANUMERIC, prng = exports.defaultRand
|
|
|
62
64
|
}
|
|
63
65
|
return out;
|
|
64
66
|
}
|
|
67
|
+
exports.randomString = randomString;
|
|
65
68
|
/**
|
|
66
69
|
* Returns uniform random string containing at least the given
|
|
67
70
|
* number of bits of entropy.
|
|
@@ -74,8 +77,11 @@ function randomString(length, charset = ALPHANUMERIC, prng = exports.defaultRand
|
|
|
74
77
|
* Default charset generates case-sensitive alphanumeric
|
|
75
78
|
* strings (0-9, A-Z, a-z).
|
|
76
79
|
*/
|
|
77
|
-
function randomStringForEntropy(bits, charset
|
|
78
|
-
|
|
80
|
+
function randomStringForEntropy(bits, charset, prng) {
|
|
81
|
+
if (charset === void 0) { charset = ALPHANUMERIC; }
|
|
82
|
+
if (prng === void 0) { prng = exports.defaultRandomSource; }
|
|
83
|
+
var length = Math.ceil(bits / (Math.log(charset.length) / Math.LN2));
|
|
79
84
|
return randomString(length, charset, prng);
|
|
80
85
|
}
|
|
86
|
+
exports.randomStringForEntropy = randomStringForEntropy;
|
|
81
87
|
//# sourceMappingURL=random.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../../../../../src/dependencies/src/@stablelib/random-1.0.2/packages/random/random.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../../../../../src/dependencies/src/@stablelib/random-1.0.2/packages/random/random.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;AAQ7C,0CAAqD;AACrD,qFAA0F;AAC1F,6EAA4E;AAI/D,QAAA,mBAAmB,GAAG,IAAI,2BAAkB,EAAE,CAAC;AAE5D,SAAgB,WAAW,CAAC,MAAc,EAAE,IAAwC;IAAxC,qBAAA,EAAA,OAAqB,2BAAmB;IAChF,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAFD,kCAEC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAwC;IAAxC,qBAAA,EAAA,OAAqB,2BAAmB;IACjE,iCAAiC;IACjC,IAAM,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAEjC,mDAAmD;IACnD,oDAAoD;IACpD,wBAAwB;IACxB,IAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,GAAG,CAAC,CAAC;IAEjC,oBAAoB;IACpB,IAAA,WAAI,EAAC,GAAG,CAAC,CAAC;IAEV,OAAO,MAAM,CAAC;AAClB,CAAC;AAbD,oCAaC;AAED,uEAAuE;AACvE,IAAM,YAAY,GAAG,gEAAgE,CAAC;AAEtF;;;;;;;;GAQG;AACH,SAAgB,YAAY,CACxB,MAAc,EACd,OAAsB,EACtB,IAAwC;IADxC,wBAAA,EAAA,sBAAsB;IACtB,qBAAA,EAAA,OAAqB,2BAAmB;IAExC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACxD;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;KACvD;IACD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAChC,IAAM,OAAO,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC;IACvC,OAAO,MAAM,GAAG,CAAC,EAAE;QACf,IAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;QACjE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC/C,IAAM,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,UAAU,GAAG,OAAO,EAAE;gBACtB,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;gBAC7C,MAAM,EAAE,CAAC;aACZ;SACJ;QACD,IAAA,WAAI,EAAC,GAAG,CAAC,CAAC;KACb;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AA1BD,oCA0BC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,sBAAsB,CAClC,IAAY,EACZ,OAAsB,EACtB,IAAwC;IADxC,wBAAA,EAAA,sBAAsB;IACtB,qBAAA,EAAA,OAAqB,2BAAmB;IAExC,IAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACvE,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC;AAPD,wDAOC"}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// MIT License. See LICENSE file for details.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.BrowserRandomSource = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var QUOTA = 65536;
|
|
7
|
+
var BrowserRandomSource = /** @class */ (function () {
|
|
8
|
+
function BrowserRandomSource() {
|
|
9
9
|
this.isAvailable = false;
|
|
10
10
|
this.isInstantiated = false;
|
|
11
|
-
|
|
11
|
+
var browserCrypto = typeof self !== 'undefined'
|
|
12
12
|
? (self.crypto || self.msCrypto) // IE11 has msCrypto
|
|
13
13
|
: null;
|
|
14
14
|
if (browserCrypto && browserCrypto.getRandomValues !== undefined) {
|
|
@@ -17,16 +17,17 @@ class BrowserRandomSource {
|
|
|
17
17
|
this.isInstantiated = true;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
randomBytes(length) {
|
|
20
|
+
BrowserRandomSource.prototype.randomBytes = function (length) {
|
|
21
21
|
if (!this.isAvailable || !this._crypto) {
|
|
22
22
|
throw new Error("Browser random byte generator is not available.");
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
for (
|
|
24
|
+
var out = new Uint8Array(length);
|
|
25
|
+
for (var i = 0; i < out.length; i += QUOTA) {
|
|
26
26
|
this._crypto.getRandomValues(out.subarray(i, i + Math.min(out.length - i, QUOTA)));
|
|
27
27
|
}
|
|
28
28
|
return out;
|
|
29
|
-
}
|
|
30
|
-
|
|
29
|
+
};
|
|
30
|
+
return BrowserRandomSource;
|
|
31
|
+
}());
|
|
31
32
|
exports.BrowserRandomSource = BrowserRandomSource;
|
|
32
33
|
//# sourceMappingURL=browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../../../../../../src/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;AAI7C,
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../../../../../../src/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;AAI7C,IAAM,KAAK,GAAG,KAAK,CAAC;AAEpB;IAMI;QALA,gBAAW,GAAG,KAAK,CAAC;QACpB,mBAAc,GAAG,KAAK,CAAC;QAKnB,IAAM,aAAa,GAAG,OAAO,IAAI,KAAK,WAAW;YAC7C,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,IAAK,IAA2B,CAAC,QAAQ,CAAC,CAAC,oBAAoB;YAC7E,CAAC,CAAC,IAAI,CAAC;QAEX,IAAI,aAAa,IAAI,aAAa,CAAC,eAAe,KAAK,SAAS,EAAE;YAC9D,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC;YAC7B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;SAC9B;IACL,CAAC;IAED,yCAAW,GAAX,UAAY,MAAc;QACtB,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACtE;QACD,IAAM,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,KAAK,EAAE;YACxC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;SACtF;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IACL,0BAAC;AAAD,CAAC,AA5BD,IA4BC;AA5BY,kDAAmB"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
// MIT License. See LICENSE file for details.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.NodeRandomSource = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var wipe_1 = require("../../../../../@stablelib/wipe-1.0.1/packages/wipe/wipe");
|
|
7
|
+
var NodeRandomSource = /** @class */ (function () {
|
|
8
|
+
function NodeRandomSource() {
|
|
9
9
|
this.isAvailable = false;
|
|
10
10
|
this.isInstantiated = false;
|
|
11
11
|
if (typeof require !== "undefined") {
|
|
12
|
-
|
|
12
|
+
var nodeCrypto = require("crypto");
|
|
13
13
|
if (nodeCrypto && nodeCrypto.randomBytes) {
|
|
14
14
|
this._crypto = nodeCrypto;
|
|
15
15
|
this.isAvailable = true;
|
|
@@ -17,26 +17,27 @@ class NodeRandomSource {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
randomBytes(length) {
|
|
20
|
+
NodeRandomSource.prototype.randomBytes = function (length) {
|
|
21
21
|
if (!this.isAvailable || !this._crypto) {
|
|
22
22
|
throw new Error("Node.js random byte generator is not available.");
|
|
23
23
|
}
|
|
24
24
|
// Get random bytes (result is Buffer).
|
|
25
|
-
|
|
25
|
+
var buffer = this._crypto.randomBytes(length);
|
|
26
26
|
// Make sure we got the length that we requested.
|
|
27
27
|
if (buffer.length !== length) {
|
|
28
28
|
throw new Error("NodeRandomSource: got fewer bytes than requested");
|
|
29
29
|
}
|
|
30
30
|
// Allocate output array.
|
|
31
|
-
|
|
31
|
+
var out = new Uint8Array(length);
|
|
32
32
|
// Copy bytes from buffer to output.
|
|
33
|
-
for (
|
|
33
|
+
for (var i = 0; i < out.length; i++) {
|
|
34
34
|
out[i] = buffer[i];
|
|
35
35
|
}
|
|
36
36
|
// Cleanup.
|
|
37
37
|
(0, wipe_1.wipe)(buffer);
|
|
38
38
|
return out;
|
|
39
|
-
}
|
|
40
|
-
|
|
39
|
+
};
|
|
40
|
+
return NodeRandomSource;
|
|
41
|
+
}());
|
|
41
42
|
exports.NodeRandomSource = NodeRandomSource;
|
|
42
43
|
//# sourceMappingURL=node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../../../../../../src/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;AAG7C,
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../../../../../../src/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;AAG7C,gFAA+E;AAI/E;IAMI;QALA,gBAAW,GAAG,KAAK,CAAC;QACpB,mBAAc,GAAG,KAAK,CAAC;QAKnB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YAChC,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,UAAU,IAAI,UAAU,CAAC,WAAW,EAAE;gBACtC,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;gBAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;gBACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;aAC9B;SACJ;IACL,CAAC;IAED,sCAAW,GAAX,UAAY,MAAc;QACtB,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACtE;QAED,uCAAuC;QACvC,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE9C,iDAAiD;QACjD,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QAED,yBAAyB;QACzB,IAAM,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QAEnC,oCAAoC;QACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACjC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;SACtB;QAED,WAAW;QACX,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC;QAEb,OAAO,GAAG,CAAC;IACf,CAAC;IACL,uBAAC;AAAD,CAAC,AA3CD,IA2CC;AA3CY,4CAAgB"}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// MIT License. See LICENSE file for details.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.SystemRandomSource = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
var browser_1 = require("./browser");
|
|
7
|
+
var node_1 = require("./node");
|
|
8
|
+
var SystemRandomSource = /** @class */ (function () {
|
|
9
|
+
function SystemRandomSource() {
|
|
10
10
|
this.isAvailable = false;
|
|
11
11
|
this.name = "";
|
|
12
12
|
// Try browser.
|
|
@@ -25,12 +25,13 @@ class SystemRandomSource {
|
|
|
25
25
|
}
|
|
26
26
|
// No sources, we're out of options.
|
|
27
27
|
}
|
|
28
|
-
randomBytes(length) {
|
|
28
|
+
SystemRandomSource.prototype.randomBytes = function (length) {
|
|
29
29
|
if (!this.isAvailable) {
|
|
30
30
|
throw new Error("System random byte generator is not available.");
|
|
31
31
|
}
|
|
32
32
|
return this._source.randomBytes(length);
|
|
33
|
-
}
|
|
34
|
-
|
|
33
|
+
};
|
|
34
|
+
return SystemRandomSource;
|
|
35
|
+
}());
|
|
35
36
|
exports.SystemRandomSource = SystemRandomSource;
|
|
36
37
|
//# sourceMappingURL=system.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../../../../../../../src/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;AAG7C,
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../../../../../../../src/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,6CAA6C;;;AAG7C,qCAAgD;AAChD,+BAA0C;AAE1C;IAKI;QAJA,gBAAW,GAAG,KAAK,CAAC;QACpB,SAAI,GAAG,EAAE,CAAC;QAIN,eAAe;QACf,IAAI,CAAC,OAAO,GAAG,IAAI,6BAAmB,EAAE,CAAC;QACzC,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACtB,OAAO;SACV;QAED,kCAAkC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,uBAAgB,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;YACnB,OAAO;SACV;QAED,oCAAoC;IACxC,CAAC;IAED,wCAAW,GAAX,UAAY,MAAc;QACtB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACrE;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IACL,yBAAC;AAAD,CAAC,AA/BD,IA+BC;AA/BY,gDAAkB"}
|
|
@@ -12,8 +12,8 @@ export declare class SHA512 implements SerializableHash {
|
|
|
12
12
|
readonly digestLength: number;
|
|
13
13
|
/** Block size */
|
|
14
14
|
readonly blockSize: number;
|
|
15
|
-
protected _stateHi: Int32Array
|
|
16
|
-
protected _stateLo: Int32Array
|
|
15
|
+
protected _stateHi: Int32Array;
|
|
16
|
+
protected _stateLo: Int32Array;
|
|
17
17
|
private _tempHi;
|
|
18
18
|
private _tempLo;
|
|
19
19
|
private _buffer;
|
|
@@ -63,7 +63,7 @@ export declare class SHA512 implements SerializableHash {
|
|
|
63
63
|
*/
|
|
64
64
|
cleanSavedState(savedState: SavedState): void;
|
|
65
65
|
}
|
|
66
|
-
export type SavedState = {
|
|
66
|
+
export declare type SavedState = {
|
|
67
67
|
stateHi: Int32Array;
|
|
68
68
|
stateLo: Int32Array;
|
|
69
69
|
buffer: Uint8Array | undefined;
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
// Copyright (C) 2016 Dmitry Chestnykh
|
|
3
3
|
// MIT License. See LICENSE file for details.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.SHA512 = exports.BLOCK_SIZE = exports.DIGEST_LENGTH = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const wipe_1 = require("../../../../@stablelib/wipe-1.0.1/packages/wipe/wipe");
|
|
5
|
+
exports.hash = exports.SHA512 = exports.BLOCK_SIZE = exports.DIGEST_LENGTH = void 0;
|
|
6
|
+
var binary_1 = require("../../../../@stablelib/binary-1.0.1/packages/binary/binary");
|
|
7
|
+
var wipe_1 = require("../../../../@stablelib/wipe-1.0.1/packages/wipe/wipe");
|
|
9
8
|
exports.DIGEST_LENGTH = 64;
|
|
10
9
|
exports.BLOCK_SIZE = 128;
|
|
11
10
|
/**
|
|
12
11
|
* SHA-2-512 cryptographic hash algorithm.
|
|
13
12
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var SHA512 = /** @class */ (function () {
|
|
14
|
+
function SHA512() {
|
|
16
15
|
/** Length of hash output */
|
|
17
16
|
this.digestLength = exports.DIGEST_LENGTH;
|
|
18
17
|
/** Block size */
|
|
@@ -28,7 +27,7 @@ class SHA512 {
|
|
|
28
27
|
this._finished = false; // indicates whether the hash was finalized
|
|
29
28
|
this.reset();
|
|
30
29
|
}
|
|
31
|
-
_initState() {
|
|
30
|
+
SHA512.prototype._initState = function () {
|
|
32
31
|
this._stateHi[0] = 0x6a09e667;
|
|
33
32
|
this._stateHi[1] = 0xbb67ae85;
|
|
34
33
|
this._stateHi[2] = 0x3c6ef372;
|
|
@@ -45,38 +44,39 @@ class SHA512 {
|
|
|
45
44
|
this._stateLo[5] = 0x2b3e6c1f;
|
|
46
45
|
this._stateLo[6] = 0xfb41bd6b;
|
|
47
46
|
this._stateLo[7] = 0x137e2179;
|
|
48
|
-
}
|
|
47
|
+
};
|
|
49
48
|
/**
|
|
50
49
|
* Resets hash state making it possible
|
|
51
50
|
* to re-use this instance to hash other data.
|
|
52
51
|
*/
|
|
53
|
-
reset() {
|
|
52
|
+
SHA512.prototype.reset = function () {
|
|
54
53
|
this._initState();
|
|
55
54
|
this._bufferLength = 0;
|
|
56
55
|
this._bytesHashed = 0;
|
|
57
56
|
this._finished = false;
|
|
58
57
|
return this;
|
|
59
|
-
}
|
|
58
|
+
};
|
|
60
59
|
/**
|
|
61
60
|
* Cleans internal buffers and resets hash state.
|
|
62
61
|
*/
|
|
63
|
-
clean() {
|
|
62
|
+
SHA512.prototype.clean = function () {
|
|
64
63
|
(0, wipe_1.wipe)(this._buffer);
|
|
65
64
|
(0, wipe_1.wipe)(this._tempHi);
|
|
66
65
|
(0, wipe_1.wipe)(this._tempLo);
|
|
67
66
|
this.reset();
|
|
68
|
-
}
|
|
67
|
+
};
|
|
69
68
|
/**
|
|
70
69
|
* Updates hash state with the given data.
|
|
71
70
|
*
|
|
72
71
|
* Throws error when trying to update already finalized hash:
|
|
73
72
|
* instance must be reset to update it again.
|
|
74
73
|
*/
|
|
75
|
-
update(data, dataLength
|
|
74
|
+
SHA512.prototype.update = function (data, dataLength) {
|
|
75
|
+
if (dataLength === void 0) { dataLength = data.length; }
|
|
76
76
|
if (this._finished) {
|
|
77
77
|
throw new Error("SHA512: can't update because hash was finished.");
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
var dataPos = 0;
|
|
80
80
|
this._bytesHashed += dataLength;
|
|
81
81
|
if (this._bufferLength > 0) {
|
|
82
82
|
while (this._bufferLength < exports.BLOCK_SIZE && dataLength > 0) {
|
|
@@ -97,20 +97,20 @@ class SHA512 {
|
|
|
97
97
|
dataLength--;
|
|
98
98
|
}
|
|
99
99
|
return this;
|
|
100
|
-
}
|
|
100
|
+
};
|
|
101
101
|
/**
|
|
102
102
|
* Finalizes hash state and puts hash into out.
|
|
103
103
|
* If hash was already finalized, puts the same value.
|
|
104
104
|
*/
|
|
105
|
-
finish(out) {
|
|
105
|
+
SHA512.prototype.finish = function (out) {
|
|
106
106
|
if (!this._finished) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
var bytesHashed = this._bytesHashed;
|
|
108
|
+
var left = this._bufferLength;
|
|
109
|
+
var bitLenHi = (bytesHashed / 0x20000000) | 0;
|
|
110
|
+
var bitLenLo = bytesHashed << 3;
|
|
111
|
+
var padLength = (bytesHashed % 128 < 112) ? 128 : 256;
|
|
112
112
|
this._buffer[left] = 0x80;
|
|
113
|
-
for (
|
|
113
|
+
for (var i = left + 1; i < padLength - 8; i++) {
|
|
114
114
|
this._buffer[i] = 0;
|
|
115
115
|
}
|
|
116
116
|
(0, binary_1.writeUint32BE)(bitLenHi, this._buffer, padLength - 8);
|
|
@@ -118,26 +118,26 @@ class SHA512 {
|
|
|
118
118
|
hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, padLength);
|
|
119
119
|
this._finished = true;
|
|
120
120
|
}
|
|
121
|
-
for (
|
|
121
|
+
for (var i = 0; i < this.digestLength / 8; i++) {
|
|
122
122
|
(0, binary_1.writeUint32BE)(this._stateHi[i], out, i * 8);
|
|
123
123
|
(0, binary_1.writeUint32BE)(this._stateLo[i], out, i * 8 + 4);
|
|
124
124
|
}
|
|
125
125
|
return this;
|
|
126
|
-
}
|
|
126
|
+
};
|
|
127
127
|
/**
|
|
128
128
|
* Returns the final hash digest.
|
|
129
129
|
*/
|
|
130
|
-
digest() {
|
|
131
|
-
|
|
130
|
+
SHA512.prototype.digest = function () {
|
|
131
|
+
var out = new Uint8Array(this.digestLength);
|
|
132
132
|
this.finish(out);
|
|
133
133
|
return out;
|
|
134
|
-
}
|
|
134
|
+
};
|
|
135
135
|
/**
|
|
136
136
|
* Function useful for HMAC/PBKDF2 optimization. Returns hash state to be
|
|
137
137
|
* used with restoreState(). Only chain value is saved, not buffers or
|
|
138
138
|
* other state variables.
|
|
139
139
|
*/
|
|
140
|
-
saveState() {
|
|
140
|
+
SHA512.prototype.saveState = function () {
|
|
141
141
|
if (this._finished) {
|
|
142
142
|
throw new Error("SHA256: cannot save finished state");
|
|
143
143
|
}
|
|
@@ -148,12 +148,12 @@ class SHA512 {
|
|
|
148
148
|
bufferLength: this._bufferLength,
|
|
149
149
|
bytesHashed: this._bytesHashed
|
|
150
150
|
};
|
|
151
|
-
}
|
|
151
|
+
};
|
|
152
152
|
/**
|
|
153
153
|
* Function useful for HMAC/PBKDF2 optimization. Restores state saved by
|
|
154
154
|
* saveState() and sets bytesHashed to the given value.
|
|
155
155
|
*/
|
|
156
|
-
restoreState(savedState) {
|
|
156
|
+
SHA512.prototype.restoreState = function (savedState) {
|
|
157
157
|
this._stateHi.set(savedState.stateHi);
|
|
158
158
|
this._stateLo.set(savedState.stateLo);
|
|
159
159
|
this._bufferLength = savedState.bufferLength;
|
|
@@ -163,11 +163,11 @@ class SHA512 {
|
|
|
163
163
|
this._bytesHashed = savedState.bytesHashed;
|
|
164
164
|
this._finished = false;
|
|
165
165
|
return this;
|
|
166
|
-
}
|
|
166
|
+
};
|
|
167
167
|
/**
|
|
168
168
|
* Cleans state returned by saveState().
|
|
169
169
|
*/
|
|
170
|
-
cleanSavedState(savedState) {
|
|
170
|
+
SHA512.prototype.cleanSavedState = function (savedState) {
|
|
171
171
|
(0, wipe_1.wipe)(savedState.stateHi);
|
|
172
172
|
(0, wipe_1.wipe)(savedState.stateLo);
|
|
173
173
|
if (savedState.buffer) {
|
|
@@ -175,11 +175,12 @@ class SHA512 {
|
|
|
175
175
|
}
|
|
176
176
|
savedState.bufferLength = 0;
|
|
177
177
|
savedState.bytesHashed = 0;
|
|
178
|
-
}
|
|
179
|
-
|
|
178
|
+
};
|
|
179
|
+
return SHA512;
|
|
180
|
+
}());
|
|
180
181
|
exports.SHA512 = SHA512;
|
|
181
182
|
// Constants
|
|
182
|
-
|
|
183
|
+
var K = new Int32Array([
|
|
183
184
|
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
|
|
184
185
|
0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
|
|
185
186
|
0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
|
|
@@ -222,33 +223,33 @@ const K = new Int32Array([
|
|
|
222
223
|
0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
|
|
223
224
|
]);
|
|
224
225
|
function hashBlocks(wh, wl, hh, hl, m, pos, len) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7];
|
|
227
|
+
var h, l;
|
|
228
|
+
var th, tl;
|
|
229
|
+
var a, b, c, d;
|
|
229
230
|
while (len >= 128) {
|
|
230
|
-
for (
|
|
231
|
-
|
|
231
|
+
for (var i = 0; i < 16; i++) {
|
|
232
|
+
var j = 8 * i + pos;
|
|
232
233
|
wh[i] = (0, binary_1.readUint32BE)(m, j);
|
|
233
234
|
wl[i] = (0, binary_1.readUint32BE)(m, j + 4);
|
|
234
235
|
}
|
|
235
|
-
for (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
236
|
+
for (var i = 0; i < 80; i++) {
|
|
237
|
+
var bh0 = ah0;
|
|
238
|
+
var bh1 = ah1;
|
|
239
|
+
var bh2 = ah2;
|
|
240
|
+
var bh3 = ah3;
|
|
241
|
+
var bh4 = ah4;
|
|
242
|
+
var bh5 = ah5;
|
|
243
|
+
var bh6 = ah6;
|
|
244
|
+
var bh7 = ah7;
|
|
245
|
+
var bl0 = al0;
|
|
246
|
+
var bl1 = al1;
|
|
247
|
+
var bl2 = al2;
|
|
248
|
+
var bl3 = al3;
|
|
249
|
+
var bl4 = al4;
|
|
250
|
+
var bl5 = al5;
|
|
251
|
+
var bl6 = al6;
|
|
252
|
+
var bl7 = al7;
|
|
252
253
|
// add
|
|
253
254
|
h = ah7;
|
|
254
255
|
l = al7;
|
|
@@ -354,7 +355,7 @@ function hashBlocks(wh, wl, hh, hl, m, pos, len) {
|
|
|
354
355
|
al7 = bl6;
|
|
355
356
|
al0 = bl7;
|
|
356
357
|
if (i % 16 === 15) {
|
|
357
|
-
for (
|
|
358
|
+
for (var j = 0; j < 16; j++) {
|
|
358
359
|
// add
|
|
359
360
|
h = wh[j];
|
|
360
361
|
l = wl[j];
|
|
@@ -541,10 +542,11 @@ function hashBlocks(wh, wl, hh, hl, m, pos, len) {
|
|
|
541
542
|
return pos;
|
|
542
543
|
}
|
|
543
544
|
function hash(data) {
|
|
544
|
-
|
|
545
|
+
var h = new SHA512();
|
|
545
546
|
h.update(data);
|
|
546
|
-
|
|
547
|
+
var digest = h.digest();
|
|
547
548
|
h.clean();
|
|
548
549
|
return digest;
|
|
549
550
|
}
|
|
551
|
+
exports.hash = hash;
|
|
550
552
|
//# sourceMappingURL=sha512.js.map
|