@airgap/coinlib-core 0.13.45-beta.2 → 0.13.45-beta.3
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 +30 -83
- package/actions/Action.js.map +1 -1
- package/actions/LinkedAction.js +18 -82
- package/actions/LinkedAction.js.map +1 -1
- package/actions/RepeatableAction.js +20 -83
- package/actions/RepeatableAction.js.map +1 -1
- package/actions/SimpleAction.js +12 -74
- package/actions/SimpleAction.js.map +1 -1
- package/actions/StateMachine.js +16 -17
- package/actions/StateMachine.js.map +1 -1
- package/data/KeyPair.d.ts +0 -1
- package/data/Lazy.js +15 -64
- package/data/Lazy.js.map +1 -1
- package/data/RPCBody.js +3 -6
- 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 +88 -130
- 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 +57 -61
- 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 +1 -2
- 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 +8 -10
- 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 +22 -28
- 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 +9 -10
- 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 +10 -11
- 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 +7 -8
- 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 +61 -63
- 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 +61 -63
- 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 +2 -3
- 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 +47 -76
- 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 +46 -61
- 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 +61 -106
- 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 +95 -100
- 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 +46 -75
- 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 +45 -70
- 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 +58 -63
- 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 +30 -33
- 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 +18 -20
- 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 +5 -12
- 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 +75 -76
- 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 +115 -178
- 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 +6 -9
- 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 +78 -83
- 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 +27 -36
- 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 +25 -26
- 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 +14 -230
- package/dependencies/src/cosmjs/index.js +373 -480
- package/dependencies/src/cosmjs/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/index.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/index.js +15 -19
- 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 +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js +37 -28
- 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 +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js +38 -30
- 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 +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/utils.js +33 -24
- package/dependencies/src/eciesjs-0.3.9/src/utils.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js +42 -34
- 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 +6 -10
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js.map +1 -1
- package/errors/coinlib-error.js +16 -37
- package/errors/coinlib-error.js.map +1 -1
- package/errors/index.d.ts +2 -2
- package/errors/index.js +89 -148
- 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 +7 -54
- package/protocols/BlockExplorerProtocol.js.map +1 -1
- package/protocols/CryptoClient.js +19 -78
- package/protocols/CryptoClient.js.map +1 -1
- package/protocols/Ed25519CryptoClient.js +30 -98
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinSubProtocol.js +1 -1
- package/protocols/ICoinSubProtocol.js.map +1 -1
- package/protocols/NonExtendedProtocol.js +26 -29
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/Secp256k1CryptoClient.js +9 -73
- package/protocols/Secp256k1CryptoClient.js.map +1 -1
- package/protocols/Sr25519CryptoClient.js +12 -76
- package/protocols/Sr25519CryptoClient.js.map +1 -1
- package/utils/AES.js +81 -132
- package/utils/AES.js.map +1 -1
- package/utils/ErrorWithData.js +5 -23
- package/utils/ErrorWithData.js.map +1 -1
- package/utils/Network.js +1 -1
- package/utils/Network.js.map +1 -1
- package/utils/ProtocolBlockExplorer.js +3 -4
- package/utils/ProtocolBlockExplorer.js.map +1 -1
- package/utils/ProtocolNetwork.js +11 -16
- package/utils/ProtocolNetwork.js.map +1 -1
- package/utils/ProtocolSymbols.d.ts +1 -1
- package/utils/ProtocolSymbols.js +6 -6
- package/utils/ProtocolSymbols.js.map +1 -1
- package/utils/array.js +14 -15
- package/utils/array.js.map +1 -1
- package/utils/assert.js +8 -12
- package/utils/assert.js.map +1 -1
- package/utils/base64Check.d.ts +0 -1
- package/utils/base64Check.js +15 -15
- package/utils/base64Check.js.map +1 -1
- package/utils/blake2b.js +11 -14
- package/utils/blake2b.js.map +1 -1
- package/utils/buffer.d.ts +0 -1
- package/utils/buffer.js +1 -1
- package/utils/buffer.js.map +1 -1
- package/utils/cache.js +38 -87
- package/utils/cache.js.map +1 -1
- package/utils/error.js +2 -3
- package/utils/error.js.map +1 -1
- package/utils/hex.d.ts +1 -2
- package/utils/hex.js +31 -38
- package/utils/hex.js.map +1 -1
- package/utils/interfaces.js +3 -4
- package/utils/interfaces.js.map +1 -1
- package/utils/object.js +5 -7
- package/utils/object.js.map +1 -1
- package/utils/padStart.js +1 -2
- package/utils/padStart.js.map +1 -1
- package/utils/remote-data/HttpRemoteData.js +24 -107
- package/utils/remote-data/HttpRemoteData.js.map +1 -1
- package/utils/remote-data/IpfsRemoteData.js +32 -116
- package/utils/remote-data/IpfsRemoteData.js.map +1 -1
- package/utils/remote-data/RemoteData.d.ts +0 -1
- package/utils/remote-data/RemoteData.js +3 -4
- package/utils/remote-data/RemoteData.js.map +1 -1
- package/utils/remote-data/RemoteDataFactory.d.ts +2 -2
- package/utils/remote-data/RemoteDataFactory.js +13 -20
- package/utils/remote-data/RemoteDataFactory.js.map +1 -1
- package/utils/remote-data/Sha256RemoteData.d.ts +0 -1
- package/utils/remote-data/Sha256RemoteData.js +44 -117
- package/utils/remote-data/Sha256RemoteData.js.map +1 -1
- package/utils/string.js +8 -9
- package/utils/string.js.map +1 -1
- package/utils/type.js +3 -4
- package/utils/type.js.map +1 -1
- package/utils/xxhash.d.ts +0 -1
- package/utils/xxhash.js +9 -11
- package/utils/xxhash.js.map +1 -1
- package/wallet/AirGapCoinWallet.js +64 -183
- package/wallet/AirGapCoinWallet.js.map +1 -1
- package/wallet/AirGapMarketWallet.js +88 -201
- package/wallet/AirGapMarketWallet.js.map +1 -1
- package/wallet/AirGapNFTWallet.js +48 -165
- package/wallet/AirGapNFTWallet.js.map +1 -1
- package/wallet/AirGapWallet.js +58 -145
- package/wallet/AirGapWallet.js.map +1 -1
|
@@ -2,14 +2,18 @@
|
|
|
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.
|
|
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;
|
|
6
10
|
/**
|
|
7
11
|
* Package int provides helper functions for integerss.
|
|
8
12
|
*/
|
|
9
13
|
// Shim using 16-bit pieces.
|
|
10
14
|
function imulShim(a, b) {
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
const ah = (a >>> 16) & 0xffff, al = a & 0xffff;
|
|
16
|
+
const bh = (b >>> 16) & 0xffff, bl = b & 0xffff;
|
|
13
17
|
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0);
|
|
14
18
|
}
|
|
15
19
|
/** 32-bit integer multiplication. */
|
|
@@ -19,22 +23,18 @@ exports.mul = Math.imul || imulShim;
|
|
|
19
23
|
function add(a, b) {
|
|
20
24
|
return (a + b) | 0;
|
|
21
25
|
}
|
|
22
|
-
exports.add = add;
|
|
23
26
|
/** 32-bit integer subtraction. */
|
|
24
27
|
function sub(a, b) {
|
|
25
28
|
return (a - b) | 0;
|
|
26
29
|
}
|
|
27
|
-
exports.sub = sub;
|
|
28
30
|
/** 32-bit integer left rotation */
|
|
29
31
|
function rotl(x, n) {
|
|
30
32
|
return x << n | x >>> (32 - n);
|
|
31
33
|
}
|
|
32
|
-
exports.rotl = rotl;
|
|
33
34
|
/** 32-bit integer left rotation */
|
|
34
35
|
function rotr(x, n) {
|
|
35
36
|
return x << (32 - n) | x >>> n;
|
|
36
37
|
}
|
|
37
|
-
exports.rotr = rotr;
|
|
38
38
|
function isIntegerShim(n) {
|
|
39
39
|
return typeof n === "number" && isFinite(n) && Math.floor(n) === n;
|
|
40
40
|
}
|
|
@@ -56,8 +56,6 @@ exports.MAX_SAFE_INTEGER = 9007199254740991;
|
|
|
56
56
|
*
|
|
57
57
|
* In ES2015, Number.isSafeInteger.
|
|
58
58
|
*/
|
|
59
|
-
|
|
60
|
-
return (0, exports.isInteger)(n) && (n >= -exports.MAX_SAFE_INTEGER && n <= exports.MAX_SAFE_INTEGER);
|
|
61
|
-
};
|
|
59
|
+
const isSafeInteger = (n) => (0, exports.isInteger)(n) && (n >= -exports.MAX_SAFE_INTEGER && n <= exports.MAX_SAFE_INTEGER);
|
|
62
60
|
exports.isSafeInteger = isSafeInteger;
|
|
63
61
|
//# 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;;;AAkB7C,kBAEC;AAGD,kBAEC;AAGD,oBAEC;AAGD,oBAEC;AAjCD;;GAEG;AAEH,4BAA4B;AAC5B,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IAClC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;IAChD,MAAM,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;AAED,oCAAoC;AACpC,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS;IACpC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;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;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;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,MAAM,aAAa,GAAG,CAAC,CAAS,EAAW,EAAE,CAChD,IAAA,iBAAS,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,wBAAgB,IAAI,CAAC,IAAI,wBAAgB,CAAC,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.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
exports.defaultRandomSource = void 0;
|
|
6
|
+
exports.randomBytes = randomBytes;
|
|
7
|
+
exports.randomUint32 = randomUint32;
|
|
8
|
+
exports.randomString = randomString;
|
|
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");
|
|
9
13
|
exports.defaultRandomSource = new system_1.SystemRandomSource();
|
|
10
|
-
function randomBytes(length, prng) {
|
|
11
|
-
if (prng === void 0) { prng = exports.defaultRandomSource; }
|
|
14
|
+
function randomBytes(length, prng = exports.defaultRandomSource) {
|
|
12
15
|
return prng.randomBytes(length);
|
|
13
16
|
}
|
|
14
|
-
exports.randomBytes = randomBytes;
|
|
15
17
|
/**
|
|
16
18
|
* Returns a uniformly random unsigned 32-bit integer.
|
|
17
19
|
*/
|
|
18
|
-
function randomUint32(prng) {
|
|
19
|
-
if (prng === void 0) { prng = exports.defaultRandomSource; }
|
|
20
|
+
function randomUint32(prng = exports.defaultRandomSource) {
|
|
20
21
|
// Generate 4-byte random buffer.
|
|
21
|
-
|
|
22
|
+
const buf = randomBytes(4, prng);
|
|
22
23
|
// Convert bytes from buffer into a 32-bit integer.
|
|
23
24
|
// It's not important which byte order to use, since
|
|
24
25
|
// the result is random.
|
|
25
|
-
|
|
26
|
+
const result = (0, binary_1.readUint32LE)(buf);
|
|
26
27
|
// Clean the buffer.
|
|
27
28
|
(0, wipe_1.wipe)(buf);
|
|
28
29
|
return result;
|
|
29
30
|
}
|
|
30
|
-
exports.randomUint32 = randomUint32;
|
|
31
31
|
/** 62 alphanumeric characters for default charset of randomString() */
|
|
32
|
-
|
|
32
|
+
const ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
33
33
|
/**
|
|
34
34
|
* Returns a uniform random string of the given length
|
|
35
35
|
* with characters from the given charset.
|
|
@@ -39,22 +39,20 @@ var ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx
|
|
|
39
39
|
* Default charset generates case-sensitive alphanumeric
|
|
40
40
|
* strings (0-9, A-Z, a-z).
|
|
41
41
|
*/
|
|
42
|
-
function randomString(length, charset, prng) {
|
|
43
|
-
if (charset === void 0) { charset = ALPHANUMERIC; }
|
|
44
|
-
if (prng === void 0) { prng = exports.defaultRandomSource; }
|
|
42
|
+
function randomString(length, charset = ALPHANUMERIC, prng = exports.defaultRandomSource) {
|
|
45
43
|
if (charset.length < 2) {
|
|
46
44
|
throw new Error("randomString charset is too short");
|
|
47
45
|
}
|
|
48
46
|
if (charset.length > 256) {
|
|
49
47
|
throw new Error("randomString charset is too long");
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
let out = '';
|
|
50
|
+
const charsLen = charset.length;
|
|
51
|
+
const maxByte = 256 - (256 % charsLen);
|
|
54
52
|
while (length > 0) {
|
|
55
|
-
|
|
56
|
-
for (
|
|
57
|
-
|
|
53
|
+
const buf = randomBytes(Math.ceil(length * 256 / maxByte), prng);
|
|
54
|
+
for (let i = 0; i < buf.length && length > 0; i++) {
|
|
55
|
+
const randomByte = buf[i];
|
|
58
56
|
if (randomByte < maxByte) {
|
|
59
57
|
out += charset.charAt(randomByte % charsLen);
|
|
60
58
|
length--;
|
|
@@ -64,7 +62,6 @@ function randomString(length, charset, prng) {
|
|
|
64
62
|
}
|
|
65
63
|
return out;
|
|
66
64
|
}
|
|
67
|
-
exports.randomString = randomString;
|
|
68
65
|
/**
|
|
69
66
|
* Returns uniform random string containing at least the given
|
|
70
67
|
* number of bits of entropy.
|
|
@@ -77,11 +74,8 @@ exports.randomString = randomString;
|
|
|
77
74
|
* Default charset generates case-sensitive alphanumeric
|
|
78
75
|
* strings (0-9, A-Z, a-z).
|
|
79
76
|
*/
|
|
80
|
-
function randomStringForEntropy(bits, charset, prng) {
|
|
81
|
-
|
|
82
|
-
if (prng === void 0) { prng = exports.defaultRandomSource; }
|
|
83
|
-
var length = Math.ceil(bits / (Math.log(charset.length) / Math.LN2));
|
|
77
|
+
function randomStringForEntropy(bits, charset = ALPHANUMERIC, prng = exports.defaultRandomSource) {
|
|
78
|
+
const length = Math.ceil(bits / (Math.log(charset.length) / Math.LN2));
|
|
84
79
|
return randomString(length, charset, prng);
|
|
85
80
|
}
|
|
86
|
-
exports.randomStringForEntropy = randomStringForEntropy;
|
|
87
81
|
//# 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;;;AAgB7C,kCAEC;AAKD,oCAaC;AAcD,oCA0BC;AAcD,wDAOC;AAzFD,4CAAqD;AACrD,uFAA0F;AAC1F,+EAA4E;AAI/D,QAAA,mBAAmB,GAAG,IAAI,2BAAkB,EAAE,CAAC;AAE5D,SAAgB,WAAW,CAAC,MAAc,EAAE,OAAqB,2BAAmB;IAChF,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,OAAqB,2BAAmB;IACjE,iCAAiC;IACjC,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAEjC,mDAAmD;IACnD,oDAAoD;IACpD,wBAAwB;IACxB,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,GAAG,CAAC,CAAC;IAEjC,oBAAoB;IACpB,IAAA,WAAI,EAAC,GAAG,CAAC,CAAC;IAEV,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,uEAAuE;AACvE,MAAM,YAAY,GAAG,gEAAgE,CAAC;AAEtF;;;;;;;;GAQG;AACH,SAAgB,YAAY,CACxB,MAAc,EACd,OAAO,GAAG,YAAY,EACtB,OAAqB,2BAAmB;IAExC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAChC,MAAM,OAAO,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC;IACvC,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC;QAChB,MAAM,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,CAAC;YAChD,MAAM,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,UAAU,GAAG,OAAO,EAAE,CAAC;gBACvB,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;gBAC7C,MAAM,EAAE,CAAC;YACb,CAAC;QACL,CAAC;QACD,IAAA,WAAI,EAAC,GAAG,CAAC,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,sBAAsB,CAClC,IAAY,EACZ,OAAO,GAAG,YAAY,EACtB,OAAqB,2BAAmB;IAExC,MAAM,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"}
|
|
@@ -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
|
+
const QUOTA = 65536;
|
|
7
|
+
class BrowserRandomSource {
|
|
8
|
+
constructor() {
|
|
9
9
|
this.isAvailable = false;
|
|
10
10
|
this.isInstantiated = false;
|
|
11
|
-
|
|
11
|
+
const browserCrypto = typeof self !== 'undefined'
|
|
12
12
|
? (self.crypto || self.msCrypto) // IE11 has msCrypto
|
|
13
13
|
: null;
|
|
14
14
|
if (browserCrypto && browserCrypto.getRandomValues !== undefined) {
|
|
@@ -17,17 +17,16 @@ var BrowserRandomSource = /** @class */ (function () {
|
|
|
17
17
|
this.isInstantiated = true;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
randomBytes(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
|
+
const out = new Uint8Array(length);
|
|
25
|
+
for (let 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
|
-
|
|
31
|
-
}());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
32
31
|
exports.BrowserRandomSource = BrowserRandomSource;
|
|
33
32
|
//# 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,MAAM,KAAK,GAAG,KAAK,CAAC;AAEpB,MAAa,mBAAmB;IAM5B;QALA,gBAAW,GAAG,KAAK,CAAC;QACpB,mBAAc,GAAG,KAAK,CAAC;QAKnB,MAAM,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,CAAC;YAC/D,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC;YAC7B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC/B,CAAC;IACL,CAAC;IAED,WAAW,CAAC,MAAc;QACtB,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvE,CAAC;QACD,MAAM,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,CAAC;YACzC,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;QACvF,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AA5BD,kDA4BC"}
|
|
@@ -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
|
+
const wipe_1 = require("../../../../../@stablelib/wipe-1.0.1/packages/wipe/wipe");
|
|
7
|
+
class NodeRandomSource {
|
|
8
|
+
constructor() {
|
|
9
9
|
this.isAvailable = false;
|
|
10
10
|
this.isInstantiated = false;
|
|
11
11
|
if (typeof require !== "undefined") {
|
|
12
|
-
|
|
12
|
+
const nodeCrypto = require("crypto");
|
|
13
13
|
if (nodeCrypto && nodeCrypto.randomBytes) {
|
|
14
14
|
this._crypto = nodeCrypto;
|
|
15
15
|
this.isAvailable = true;
|
|
@@ -17,27 +17,26 @@ var NodeRandomSource = /** @class */ (function () {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
randomBytes(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
|
+
let 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
|
+
const out = new Uint8Array(length);
|
|
32
32
|
// Copy bytes from buffer to output.
|
|
33
|
-
for (
|
|
33
|
+
for (let 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
|
-
|
|
41
|
-
}());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
42
41
|
exports.NodeRandomSource = NodeRandomSource;
|
|
43
42
|
//# 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,kFAA+E;AAI/E,MAAa,gBAAgB;IAMzB;QALA,gBAAW,GAAG,KAAK,CAAC;QACpB,mBAAc,GAAG,KAAK,CAAC;QAKnB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACjC,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,UAAU,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;gBACvC,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;gBAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;gBACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;IAED,WAAW,CAAC,MAAc;QACtB,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvE,CAAC;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,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACxE,CAAC;QAED,yBAAyB;QACzB,MAAM,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,CAAC;YAClC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;QAED,WAAW;QACX,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC;QAEb,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AA3CD,4CA2CC"}
|
|
@@ -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
|
+
const browser_1 = require("./browser");
|
|
7
|
+
const node_1 = require("./node");
|
|
8
|
+
class SystemRandomSource {
|
|
9
|
+
constructor() {
|
|
10
10
|
this.isAvailable = false;
|
|
11
11
|
this.name = "";
|
|
12
12
|
// Try browser.
|
|
@@ -25,13 +25,12 @@ var SystemRandomSource = /** @class */ (function () {
|
|
|
25
25
|
}
|
|
26
26
|
// No sources, we're out of options.
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
randomBytes(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
|
-
|
|
35
|
-
}());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
36
35
|
exports.SystemRandomSource = SystemRandomSource;
|
|
37
36
|
//# 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,uCAAgD;AAChD,iCAA0C;AAE1C,MAAa,kBAAkB;IAK3B;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,CAAC;YAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACtB,OAAO;QACX,CAAC;QAED,kCAAkC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,uBAAgB,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;YACnB,OAAO;QACX,CAAC;QAED,oCAAoC;IACxC,CAAC;IAED,WAAW,CAAC,MAAc;QACtB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;CACJ;AA/BD,gDA+BC"}
|
|
@@ -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<ArrayBuffer>;
|
|
16
|
+
protected _stateLo: Int32Array<ArrayBuffer>;
|
|
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
|
|
66
|
+
export type SavedState = {
|
|
67
67
|
stateHi: Int32Array;
|
|
68
68
|
stateLo: Int32Array;
|
|
69
69
|
buffer: Uint8Array | undefined;
|
|
@@ -2,16 +2,17 @@
|
|
|
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.
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
exports.SHA512 = exports.BLOCK_SIZE = exports.DIGEST_LENGTH = void 0;
|
|
6
|
+
exports.hash = hash;
|
|
7
|
+
const binary_1 = require("../../../../@stablelib/binary-1.0.1/packages/binary/binary");
|
|
8
|
+
const wipe_1 = require("../../../../@stablelib/wipe-1.0.1/packages/wipe/wipe");
|
|
8
9
|
exports.DIGEST_LENGTH = 64;
|
|
9
10
|
exports.BLOCK_SIZE = 128;
|
|
10
11
|
/**
|
|
11
12
|
* SHA-2-512 cryptographic hash algorithm.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
class SHA512 {
|
|
15
|
+
constructor() {
|
|
15
16
|
/** Length of hash output */
|
|
16
17
|
this.digestLength = exports.DIGEST_LENGTH;
|
|
17
18
|
/** Block size */
|
|
@@ -27,7 +28,7 @@ var SHA512 = /** @class */ (function () {
|
|
|
27
28
|
this._finished = false; // indicates whether the hash was finalized
|
|
28
29
|
this.reset();
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
_initState() {
|
|
31
32
|
this._stateHi[0] = 0x6a09e667;
|
|
32
33
|
this._stateHi[1] = 0xbb67ae85;
|
|
33
34
|
this._stateHi[2] = 0x3c6ef372;
|
|
@@ -44,39 +45,38 @@ var SHA512 = /** @class */ (function () {
|
|
|
44
45
|
this._stateLo[5] = 0x2b3e6c1f;
|
|
45
46
|
this._stateLo[6] = 0xfb41bd6b;
|
|
46
47
|
this._stateLo[7] = 0x137e2179;
|
|
47
|
-
}
|
|
48
|
+
}
|
|
48
49
|
/**
|
|
49
50
|
* Resets hash state making it possible
|
|
50
51
|
* to re-use this instance to hash other data.
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
+
reset() {
|
|
53
54
|
this._initState();
|
|
54
55
|
this._bufferLength = 0;
|
|
55
56
|
this._bytesHashed = 0;
|
|
56
57
|
this._finished = false;
|
|
57
58
|
return this;
|
|
58
|
-
}
|
|
59
|
+
}
|
|
59
60
|
/**
|
|
60
61
|
* Cleans internal buffers and resets hash state.
|
|
61
62
|
*/
|
|
62
|
-
|
|
63
|
+
clean() {
|
|
63
64
|
(0, wipe_1.wipe)(this._buffer);
|
|
64
65
|
(0, wipe_1.wipe)(this._tempHi);
|
|
65
66
|
(0, wipe_1.wipe)(this._tempLo);
|
|
66
67
|
this.reset();
|
|
67
|
-
}
|
|
68
|
+
}
|
|
68
69
|
/**
|
|
69
70
|
* Updates hash state with the given data.
|
|
70
71
|
*
|
|
71
72
|
* Throws error when trying to update already finalized hash:
|
|
72
73
|
* instance must be reset to update it again.
|
|
73
74
|
*/
|
|
74
|
-
|
|
75
|
-
if (dataLength === void 0) { dataLength = data.length; }
|
|
75
|
+
update(data, 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
|
+
let 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 @@ var SHA512 = /** @class */ (function () {
|
|
|
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
|
-
|
|
105
|
+
finish(out) {
|
|
106
106
|
if (!this._finished) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const bytesHashed = this._bytesHashed;
|
|
108
|
+
const left = this._bufferLength;
|
|
109
|
+
const bitLenHi = (bytesHashed / 0x20000000) | 0;
|
|
110
|
+
const bitLenLo = bytesHashed << 3;
|
|
111
|
+
const padLength = (bytesHashed % 128 < 112) ? 128 : 256;
|
|
112
112
|
this._buffer[left] = 0x80;
|
|
113
|
-
for (
|
|
113
|
+
for (let 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 @@ var SHA512 = /** @class */ (function () {
|
|
|
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 (let 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
|
-
|
|
131
|
-
|
|
130
|
+
digest() {
|
|
131
|
+
const 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
|
-
|
|
140
|
+
saveState() {
|
|
141
141
|
if (this._finished) {
|
|
142
142
|
throw new Error("SHA256: cannot save finished state");
|
|
143
143
|
}
|
|
@@ -148,12 +148,12 @@ var SHA512 = /** @class */ (function () {
|
|
|
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
|
-
|
|
156
|
+
restoreState(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 @@ var SHA512 = /** @class */ (function () {
|
|
|
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
|
-
|
|
170
|
+
cleanSavedState(savedState) {
|
|
171
171
|
(0, wipe_1.wipe)(savedState.stateHi);
|
|
172
172
|
(0, wipe_1.wipe)(savedState.stateLo);
|
|
173
173
|
if (savedState.buffer) {
|
|
@@ -175,12 +175,11 @@ var SHA512 = /** @class */ (function () {
|
|
|
175
175
|
}
|
|
176
176
|
savedState.bufferLength = 0;
|
|
177
177
|
savedState.bytesHashed = 0;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
}());
|
|
178
|
+
}
|
|
179
|
+
}
|
|
181
180
|
exports.SHA512 = SHA512;
|
|
182
181
|
// Constants
|
|
183
|
-
|
|
182
|
+
const K = new Int32Array([
|
|
184
183
|
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
|
|
185
184
|
0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
|
|
186
185
|
0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
|
|
@@ -223,33 +222,33 @@ var K = new Int32Array([
|
|
|
223
222
|
0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
|
|
224
223
|
]);
|
|
225
224
|
function hashBlocks(wh, wl, hh, hl, m, pos, len) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
225
|
+
let 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];
|
|
226
|
+
let h, l;
|
|
227
|
+
let th, tl;
|
|
228
|
+
let a, b, c, d;
|
|
230
229
|
while (len >= 128) {
|
|
231
|
-
for (
|
|
232
|
-
|
|
230
|
+
for (let i = 0; i < 16; i++) {
|
|
231
|
+
const j = 8 * i + pos;
|
|
233
232
|
wh[i] = (0, binary_1.readUint32BE)(m, j);
|
|
234
233
|
wl[i] = (0, binary_1.readUint32BE)(m, j + 4);
|
|
235
234
|
}
|
|
236
|
-
for (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
235
|
+
for (let i = 0; i < 80; i++) {
|
|
236
|
+
let bh0 = ah0;
|
|
237
|
+
let bh1 = ah1;
|
|
238
|
+
let bh2 = ah2;
|
|
239
|
+
let bh3 = ah3;
|
|
240
|
+
let bh4 = ah4;
|
|
241
|
+
let bh5 = ah5;
|
|
242
|
+
let bh6 = ah6;
|
|
243
|
+
let bh7 = ah7;
|
|
244
|
+
let bl0 = al0;
|
|
245
|
+
let bl1 = al1;
|
|
246
|
+
let bl2 = al2;
|
|
247
|
+
let bl3 = al3;
|
|
248
|
+
let bl4 = al4;
|
|
249
|
+
let bl5 = al5;
|
|
250
|
+
let bl6 = al6;
|
|
251
|
+
let bl7 = al7;
|
|
253
252
|
// add
|
|
254
253
|
h = ah7;
|
|
255
254
|
l = al7;
|
|
@@ -355,7 +354,7 @@ function hashBlocks(wh, wl, hh, hl, m, pos, len) {
|
|
|
355
354
|
al7 = bl6;
|
|
356
355
|
al0 = bl7;
|
|
357
356
|
if (i % 16 === 15) {
|
|
358
|
-
for (
|
|
357
|
+
for (let j = 0; j < 16; j++) {
|
|
359
358
|
// add
|
|
360
359
|
h = wh[j];
|
|
361
360
|
l = wl[j];
|
|
@@ -542,11 +541,10 @@ function hashBlocks(wh, wl, hh, hl, m, pos, len) {
|
|
|
542
541
|
return pos;
|
|
543
542
|
}
|
|
544
543
|
function hash(data) {
|
|
545
|
-
|
|
544
|
+
const h = new SHA512();
|
|
546
545
|
h.update(data);
|
|
547
|
-
|
|
546
|
+
const digest = h.digest();
|
|
548
547
|
h.clean();
|
|
549
548
|
return digest;
|
|
550
549
|
}
|
|
551
|
-
exports.hash = hash;
|
|
552
550
|
//# sourceMappingURL=sha512.js.map
|