quantumcoin 6.14.2 → 6.14.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/CHANGELOG.md +442 -442
- package/FUNDING.json +10 -10
- package/LICENSE.md +21 -21
- package/README.md +132 -142
- package/SECURITY.md +34 -34
- package/dist/README.md +22 -22
- package/dist/quantumcoin.js +1127 -1324
- package/dist/quantumcoin.js.map +1 -1
- package/dist/quantumcoin.min.js +1 -1
- package/dist/quantumcoin.umd.js +1128 -1327
- package/dist/quantumcoin.umd.js.map +1 -1
- package/dist/quantumcoin.umd.min.js +1 -1
- package/dist/wordlists-extra.js +1 -1
- package/dist/wordlists-extra.js.map +1 -1
- package/dist/wordlists-extra.min.js +1 -1
- package/lib.commonjs/README.md +16 -16
- package/lib.commonjs/_version.js +1 -1
- package/lib.commonjs/crypto/signature.d.ts +3 -76
- package/lib.commonjs/crypto/signature.d.ts.map +1 -1
- package/lib.commonjs/crypto/signature.js +15 -199
- package/lib.commonjs/crypto/signature.js.map +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts.map +1 -1
- package/lib.commonjs/crypto/signing-key.js +19 -10
- package/lib.commonjs/crypto/signing-key.js.map +1 -1
- package/lib.commonjs/package.json +12 -12
- package/lib.commonjs/providers/provider-jsonrpc.d.ts +0 -1
- package/lib.commonjs/providers/provider-jsonrpc.d.ts.map +1 -1
- package/lib.commonjs/providers/provider-jsonrpc.js +0 -1
- package/lib.commonjs/providers/provider-jsonrpc.js.map +1 -1
- package/lib.commonjs/quantumcoin.d.ts +2 -0
- package/lib.commonjs/quantumcoin.d.ts.map +1 -1
- package/lib.commonjs/quantumcoin.js +11 -5
- package/lib.commonjs/quantumcoin.js.map +1 -1
- package/lib.commonjs/transaction/address.d.ts.map +1 -1
- package/lib.commonjs/transaction/address.js +8 -3
- package/lib.commonjs/transaction/address.js.map +1 -1
- package/lib.commonjs/transaction/transaction.d.ts.map +1 -1
- package/lib.commonjs/transaction/transaction.js +7 -40
- package/lib.commonjs/transaction/transaction.js.map +1 -1
- package/lib.commonjs/wallet/json-keystore.d.ts.map +1 -1
- package/lib.commonjs/wallet/json-keystore.js +7 -7
- package/lib.commonjs/wallet/json-keystore.js.map +1 -1
- package/lib.commonjs/wallet/wallet.d.ts.map +1 -1
- package/lib.commonjs/wallet/wallet.js +2 -2
- package/lib.commonjs/wallet/wallet.js.map +1 -1
- package/lib.esm/README.md +16 -16
- package/lib.esm/_version.js +1 -1
- package/lib.esm/crypto/signature.d.ts +3 -76
- package/lib.esm/crypto/signature.d.ts.map +1 -1
- package/lib.esm/crypto/signature.js +16 -202
- package/lib.esm/crypto/signature.js.map +1 -1
- package/lib.esm/crypto/signing-key.d.ts +1 -1
- package/lib.esm/crypto/signing-key.d.ts.map +1 -1
- package/lib.esm/crypto/signing-key.js +20 -9
- package/lib.esm/crypto/signing-key.js.map +1 -1
- package/lib.esm/package.json +12 -12
- package/lib.esm/providers/provider-jsonrpc.d.ts +0 -1
- package/lib.esm/providers/provider-jsonrpc.d.ts.map +1 -1
- package/lib.esm/providers/provider-jsonrpc.js +0 -1
- package/lib.esm/providers/provider-jsonrpc.js.map +1 -1
- package/lib.esm/quantumcoin.d.ts +2 -0
- package/lib.esm/quantumcoin.d.ts.map +1 -1
- package/lib.esm/quantumcoin.js +6 -0
- package/lib.esm/quantumcoin.js.map +1 -1
- package/lib.esm/transaction/address.d.ts.map +1 -1
- package/lib.esm/transaction/address.js +8 -2
- package/lib.esm/transaction/address.js.map +1 -1
- package/lib.esm/transaction/transaction.d.ts.map +1 -1
- package/lib.esm/transaction/transaction.js +7 -40
- package/lib.esm/transaction/transaction.js.map +1 -1
- package/lib.esm/wallet/json-keystore.d.ts.map +1 -1
- package/lib.esm/wallet/json-keystore.js +11 -5
- package/lib.esm/wallet/json-keystore.js.map +1 -1
- package/lib.esm/wallet/wallet.d.ts.map +1 -1
- package/lib.esm/wallet/wallet.js +3 -1
- package/lib.esm/wallet/wallet.js.map +1 -1
- package/package.json +6 -5
- package/rollup.config.mjs +50 -50
- package/src.ts/_version.ts +1 -1
- package/src.ts/abi/abi-coder.ts +237 -237
- package/src.ts/abi/bytes32.ts +45 -45
- package/src.ts/abi/coders/abstract-coder.ts +541 -541
- package/src.ts/abi/coders/address.ts +36 -36
- package/src.ts/abi/coders/anonymous.ts +29 -29
- package/src.ts/abi/coders/array.ts +199 -199
- package/src.ts/abi/coders/boolean.ts +27 -27
- package/src.ts/abi/coders/bytes.ts +43 -43
- package/src.ts/abi/coders/fixed-bytes.ts +37 -37
- package/src.ts/abi/coders/null.ts +28 -28
- package/src.ts/abi/coders/number.ts +63 -63
- package/src.ts/abi/coders/string.ts +29 -29
- package/src.ts/abi/coders/tuple.ts +69 -69
- package/src.ts/abi/fragments.ts +1617 -1617
- package/src.ts/abi/index.ts +41 -41
- package/src.ts/abi/interface.ts +1271 -1271
- package/src.ts/abi/typed.ts +796 -796
- package/src.ts/address/address.ts +148 -148
- package/src.ts/address/checks.ts +123 -123
- package/src.ts/address/contract-address.ts +80 -80
- package/src.ts/address/index.ts +57 -57
- package/src.ts/constants/addresses.ts +8 -8
- package/src.ts/constants/hashes.ts +7 -7
- package/src.ts/constants/index.ts +16 -16
- package/src.ts/constants/numbers.ts +35 -35
- package/src.ts/constants/strings.ts +16 -16
- package/src.ts/contract/contract.ts +1120 -1120
- package/src.ts/contract/factory.ts +143 -143
- package/src.ts/contract/index.ts +31 -31
- package/src.ts/contract/types.ts +236 -236
- package/src.ts/contract/wrappers.ts +225 -225
- package/src.ts/crypto/crypto-browser.ts +64 -64
- package/src.ts/crypto/crypto.ts +4 -4
- package/src.ts/crypto/hmac.ts +51 -51
- package/src.ts/crypto/index.ts +59 -59
- package/src.ts/crypto/keccak.ts +54 -54
- package/src.ts/crypto/pbkdf2.ts +55 -55
- package/src.ts/crypto/random.ts +36 -36
- package/src.ts/crypto/ripemd160.ts +43 -43
- package/src.ts/crypto/scrypt.ts +114 -114
- package/src.ts/crypto/sha2.ts +78 -78
- package/src.ts/crypto/signature.ts +145 -349
- package/src.ts/crypto/signing-key.ts +126 -118
- package/src.ts/hash/authorization.ts +38 -38
- package/src.ts/hash/id.ts +17 -17
- package/src.ts/hash/index.ts +18 -18
- package/src.ts/hash/message.ts +51 -51
- package/src.ts/hash/namehash.ts +101 -101
- package/src.ts/hash/solidity.ts +117 -117
- package/src.ts/hash/typed-data.ts +658 -658
- package/src.ts/index.ts +12 -12
- package/src.ts/providers/abstract-provider.ts +1761 -1761
- package/src.ts/providers/abstract-signer.ts +314 -314
- package/src.ts/providers/community.ts +49 -49
- package/src.ts/providers/contracts.ts +42 -42
- package/src.ts/providers/default-provider.ts +96 -96
- package/src.ts/providers/ens-resolver.ts +606 -606
- package/src.ts/providers/format.ts +320 -320
- package/src.ts/providers/formatting.ts +418 -418
- package/src.ts/providers/index.ts +125 -125
- package/src.ts/providers/network.ts +327 -327
- package/src.ts/providers/pagination.ts +8 -8
- package/src.ts/providers/plugin-fallback.ts +35 -35
- package/src.ts/providers/plugins-network.ts +281 -281
- package/src.ts/providers/provider-browser.ts +334 -334
- package/src.ts/providers/provider-fallback.ts +801 -801
- package/src.ts/providers/provider-ipcsocket-browser.ts +3 -3
- package/src.ts/providers/provider-ipcsocket.ts +81 -81
- package/src.ts/providers/provider-jsonrpc.ts +1334 -1335
- package/src.ts/providers/provider-socket.ts +352 -352
- package/src.ts/providers/provider-websocket.ts +103 -103
- package/src.ts/providers/provider.ts +2136 -2136
- package/src.ts/providers/signer-noncemanager.ts +98 -98
- package/src.ts/providers/signer.ts +166 -166
- package/src.ts/providers/subscriber-connection.ts +74 -74
- package/src.ts/providers/subscriber-filterid.ts +199 -199
- package/src.ts/providers/subscriber-polling.ts +321 -321
- package/src.ts/providers/ws-browser.ts +11 -11
- package/src.ts/providers/ws.ts +3 -3
- package/src.ts/quantumcoin.ts +219 -211
- package/src.ts/thirdparty.d.ts +16 -16
- package/src.ts/transaction/accesslist.ts +43 -43
- package/src.ts/transaction/address.ts +35 -31
- package/src.ts/transaction/authorization.ts +14 -14
- package/src.ts/transaction/index.ts +51 -51
- package/src.ts/transaction/transaction.ts +1349 -1379
- package/src.ts/utils/base58.ts +73 -73
- package/src.ts/utils/base64-browser.ts +25 -25
- package/src.ts/utils/base64.ts +56 -56
- package/src.ts/utils/data.ts +199 -199
- package/src.ts/utils/errors.ts +793 -793
- package/src.ts/utils/events.ts +105 -105
- package/src.ts/utils/fetch.ts +970 -970
- package/src.ts/utils/fixednumber.ts +643 -643
- package/src.ts/utils/geturl-browser.ts +81 -81
- package/src.ts/utils/geturl.ts +134 -134
- package/src.ts/utils/index.ts +95 -95
- package/src.ts/utils/maths.ts +240 -240
- package/src.ts/utils/properties.ts +60 -60
- package/src.ts/utils/rlp-decode.ts +104 -104
- package/src.ts/utils/rlp-encode.ts +64 -64
- package/src.ts/utils/rlp.ts +20 -20
- package/src.ts/utils/units.ts +91 -91
- package/src.ts/utils/utf8.ts +325 -325
- package/src.ts/utils/uuid.ts +36 -36
- package/src.ts/wallet/base-wallet.ts +160 -160
- package/src.ts/wallet/index.ts +32 -32
- package/src.ts/wallet/json-keystore.ts +108 -106
- package/src.ts/wallet/utils.ts +147 -147
- package/src.ts/wallet/wallet.ts +138 -139
- package/src.ts/wordlists/bit-reader.ts +35 -35
- package/src.ts/wordlists/decode-owl.ts +58 -58
- package/src.ts/wordlists/decode-owla.ts +33 -33
- package/src.ts/wordlists/generation/encode-latin.ts +370 -370
- package/src.ts/wordlists/index.ts +26 -26
- package/src.ts/wordlists/lang-cz.ts +33 -33
- package/src.ts/wordlists/lang-en.ts +33 -33
- package/src.ts/wordlists/lang-es.ts +35 -35
- package/src.ts/wordlists/lang-fr.ts +34 -34
- package/src.ts/wordlists/lang-it.ts +33 -33
- package/src.ts/wordlists/lang-ja.ts +181 -181
- package/src.ts/wordlists/lang-ko.ts +104 -104
- package/src.ts/wordlists/lang-pt.ts +34 -34
- package/src.ts/wordlists/lang-zh.ts +112 -112
- package/src.ts/wordlists/wordlist-owl.ts +77 -77
- package/src.ts/wordlists/wordlist-owla.ts +41 -41
- package/src.ts/wordlists/wordlist.ts +59 -59
- package/src.ts/wordlists/wordlists-browser.ts +8 -8
- package/src.ts/wordlists/wordlists-extra.ts +9 -9
- package/src.ts/wordlists/wordlists.ts +38 -38
- package/dist/quantumcoin.min.js'.gz' +0 -0
- package/dist/quantumcoin.umd.min.js'.gz' +0 -0
- package/dist/wordlists-extra.min.js'.gz' +0 -0
- package/lib.commonjs/providers/provider-alchemy.d.ts +0 -50
- package/lib.commonjs/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-alchemy.js +0 -151
- package/lib.commonjs/providers/provider-alchemy.js.map +0 -1
- package/lib.commonjs/providers/provider-ankr.d.ts +0 -61
- package/lib.commonjs/providers/provider-ankr.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-ankr.js +0 -137
- package/lib.commonjs/providers/provider-ankr.js.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.d.ts +0 -59
- package/lib.commonjs/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.js +0 -145
- package/lib.commonjs/providers/provider-blockscout.js.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.d.ts +0 -46
- package/lib.commonjs/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.js +0 -102
- package/lib.commonjs/providers/provider-chainstack.js.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.d.ts +0 -14
- package/lib.commonjs/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.js +0 -26
- package/lib.commonjs/providers/provider-cloudflare.js.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.d.ts +0 -147
- package/lib.commonjs/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.js +0 -587
- package/lib.commonjs/providers/provider-etherscan.js.map +0 -1
- package/lib.commonjs/providers/provider-infura.d.ts +0 -101
- package/lib.commonjs/providers/provider-infura.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-infura.js +0 -206
- package/lib.commonjs/providers/provider-infura.js.map +0 -1
- package/lib.commonjs/providers/provider-pocket.d.ts +0 -54
- package/lib.commonjs/providers/provider-pocket.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-pocket.js +0 -109
- package/lib.commonjs/providers/provider-pocket.js.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.d.ts +0 -59
- package/lib.commonjs/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.js +0 -163
- package/lib.commonjs/providers/provider-quicknode.js.map +0 -1
- package/lib.commonjs/wallet/hdwallet.d.ts +0 -248
- package/lib.commonjs/wallet/hdwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/hdwallet.js +0 -505
- package/lib.commonjs/wallet/hdwallet.js.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.d.ts +0 -27
- package/lib.commonjs/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.js +0 -60
- package/lib.commonjs/wallet/json-crowdsale.js.map +0 -1
- package/lib.commonjs/wallet/mnemonic.d.ts +0 -65
- package/lib.commonjs/wallet/mnemonic.d.ts.map +0 -1
- package/lib.commonjs/wallet/mnemonic.js +0 -169
- package/lib.commonjs/wallet/mnemonic.js.map +0 -1
- package/lib.commonjs/wallet/seedwallet.d.ts +0 -4
- package/lib.commonjs/wallet/seedwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/seedwallet.js +0 -8
- package/lib.commonjs/wallet/seedwallet.js.map +0 -1
- package/lib.esm/providers/provider-alchemy.d.ts +0 -50
- package/lib.esm/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.esm/providers/provider-alchemy.js +0 -147
- package/lib.esm/providers/provider-alchemy.js.map +0 -1
- package/lib.esm/providers/provider-ankr.d.ts +0 -61
- package/lib.esm/providers/provider-ankr.d.ts.map +0 -1
- package/lib.esm/providers/provider-ankr.js +0 -133
- package/lib.esm/providers/provider-ankr.js.map +0 -1
- package/lib.esm/providers/provider-blockscout.d.ts +0 -59
- package/lib.esm/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.esm/providers/provider-blockscout.js +0 -141
- package/lib.esm/providers/provider-blockscout.js.map +0 -1
- package/lib.esm/providers/provider-chainstack.d.ts +0 -46
- package/lib.esm/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.esm/providers/provider-chainstack.js +0 -98
- package/lib.esm/providers/provider-chainstack.js.map +0 -1
- package/lib.esm/providers/provider-cloudflare.d.ts +0 -14
- package/lib.esm/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.esm/providers/provider-cloudflare.js +0 -22
- package/lib.esm/providers/provider-cloudflare.js.map +0 -1
- package/lib.esm/providers/provider-etherscan.d.ts +0 -147
- package/lib.esm/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.esm/providers/provider-etherscan.js +0 -584
- package/lib.esm/providers/provider-etherscan.js.map +0 -1
- package/lib.esm/providers/provider-infura.d.ts +0 -101
- package/lib.esm/providers/provider-infura.d.ts.map +0 -1
- package/lib.esm/providers/provider-infura.js +0 -201
- package/lib.esm/providers/provider-infura.js.map +0 -1
- package/lib.esm/providers/provider-pocket.d.ts +0 -54
- package/lib.esm/providers/provider-pocket.d.ts.map +0 -1
- package/lib.esm/providers/provider-pocket.js +0 -105
- package/lib.esm/providers/provider-pocket.js.map +0 -1
- package/lib.esm/providers/provider-quicknode.d.ts +0 -59
- package/lib.esm/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.esm/providers/provider-quicknode.js +0 -159
- package/lib.esm/providers/provider-quicknode.js.map +0 -1
- package/lib.esm/wallet/hdwallet.d.ts +0 -248
- package/lib.esm/wallet/hdwallet.d.ts.map +0 -1
- package/lib.esm/wallet/hdwallet.js +0 -498
- package/lib.esm/wallet/hdwallet.js.map +0 -1
- package/lib.esm/wallet/json-crowdsale.d.ts +0 -27
- package/lib.esm/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.esm/wallet/json-crowdsale.js +0 -55
- package/lib.esm/wallet/json-crowdsale.js.map +0 -1
- package/lib.esm/wallet/mnemonic.d.ts +0 -65
- package/lib.esm/wallet/mnemonic.d.ts.map +0 -1
- package/lib.esm/wallet/mnemonic.js +0 -165
- package/lib.esm/wallet/mnemonic.js.map +0 -1
- package/lib.esm/wallet/seedwallet.d.ts +0 -4
- package/lib.esm/wallet/seedwallet.d.ts.map +0 -1
- package/lib.esm/wallet/seedwallet.js +0 -4
- package/lib.esm/wallet/seedwallet.js.map +0 -1
package/dist/quantumcoin.umd.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !== 'undefined' ? window: typeof global !== 'undefined' ? global: typeof self !== 'undefined' ? self: {});
|
|
2
2
|
(function (global, factory) {
|
|
3
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
5
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ethers = {}));
|
|
6
|
-
})(this, (function (exports) { 'use strict';
|
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('quantum-coin-js-sdk'), require('quantum-coin-pqc-js-sdk')) :
|
|
4
|
+
typeof define === 'function' && define.amd ? define(['exports', 'quantum-coin-js-sdk', 'quantum-coin-pqc-js-sdk'], factory) :
|
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ethers = {}, global.quantumCoinJsSdk, global.quantumCoinPqcJsSdk));
|
|
6
|
+
})(this, (function (exports, quantumCoinJsSdk, quantumCoinPqcJsSdk) { 'use strict';
|
|
7
7
|
|
|
8
8
|
/* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
|
|
9
9
|
/**
|
|
10
10
|
* The current version of Ethers.
|
|
11
11
|
*/
|
|
12
|
-
const version = "6.14.
|
|
12
|
+
const version = "6.14.3";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Property helper functions.
|
|
@@ -461,7 +461,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
461
461
|
*
|
|
462
462
|
* @_subsection: api/utils:Math Helpers [about-maths]
|
|
463
463
|
*/
|
|
464
|
-
const BN_0$
|
|
464
|
+
const BN_0$9 = BigInt(0);
|
|
465
465
|
const BN_1$4 = BigInt(1);
|
|
466
466
|
//const BN_Max256 = (BN_1 << BigInt(256)) - BN_1;
|
|
467
467
|
// IEEE 754 support 53-bits of mantissa
|
|
@@ -475,7 +475,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
475
475
|
function fromTwos(_value, _width) {
|
|
476
476
|
const value = getUint(_value, "value");
|
|
477
477
|
const width = BigInt(getNumber(_width, "width"));
|
|
478
|
-
assert((value >> width) === BN_0$
|
|
478
|
+
assert((value >> width) === BN_0$9, "overflow", "NUMERIC_FAULT", {
|
|
479
479
|
operation: "fromTwos", fault: "overflow", value: _value
|
|
480
480
|
});
|
|
481
481
|
// Top bit set; treat as a negative value
|
|
@@ -495,7 +495,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
495
495
|
let value = getBigInt(_value, "value");
|
|
496
496
|
const width = BigInt(getNumber(_width, "width"));
|
|
497
497
|
const limit = (BN_1$4 << (width - BN_1$4));
|
|
498
|
-
if (value < BN_0$
|
|
498
|
+
if (value < BN_0$9) {
|
|
499
499
|
value = -value;
|
|
500
500
|
assert(value <= limit, "too low", "NUMERIC_FAULT", {
|
|
501
501
|
operation: "toTwos", fault: "overflow", value: _value
|
|
@@ -551,7 +551,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
551
551
|
*/
|
|
552
552
|
function getUint(value, name) {
|
|
553
553
|
const result = getBigInt(value, name);
|
|
554
|
-
assert(result >= BN_0$
|
|
554
|
+
assert(result >= BN_0$9, "unsigned value cannot be negative", "NUMERIC_FAULT", {
|
|
555
555
|
fault: "overflow", operation: "getUint", value
|
|
556
556
|
});
|
|
557
557
|
return result;
|
|
@@ -637,7 +637,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
637
637
|
*/
|
|
638
638
|
function toBeArray(_value) {
|
|
639
639
|
const value = getUint(_value, "value");
|
|
640
|
-
if (value === BN_0$
|
|
640
|
+
if (value === BN_0$9) {
|
|
641
641
|
return new Uint8Array([]);
|
|
642
642
|
}
|
|
643
643
|
let hex = value.toString(16);
|
|
@@ -695,7 +695,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
695
695
|
assertArgument(result != null, `invalid base58 value`, "letter", letter);
|
|
696
696
|
return result;
|
|
697
697
|
}
|
|
698
|
-
const BN_0$
|
|
698
|
+
const BN_0$8 = BigInt(0);
|
|
699
699
|
const BN_58 = BigInt(58);
|
|
700
700
|
/**
|
|
701
701
|
* Encode %%value%% as a Base58-encoded string.
|
|
@@ -721,7 +721,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
721
721
|
* Decode the Base58-encoded %%value%%.
|
|
722
722
|
*/
|
|
723
723
|
function decodeBase58(value) {
|
|
724
|
-
let result = BN_0$
|
|
724
|
+
let result = BN_0$8;
|
|
725
725
|
for (let i = 0; i < value.length; i++) {
|
|
726
726
|
result *= BN_58;
|
|
727
727
|
result += getAlpha(value[i]);
|
|
@@ -1915,7 +1915,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
1915
1915
|
* @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math]
|
|
1916
1916
|
*/
|
|
1917
1917
|
const BN_N1 = BigInt(-1);
|
|
1918
|
-
const BN_0$
|
|
1918
|
+
const BN_0$7 = BigInt(0);
|
|
1919
1919
|
const BN_1$3 = BigInt(1);
|
|
1920
1920
|
const BN_5 = BigInt(5);
|
|
1921
1921
|
const _guard$3 = {};
|
|
@@ -1939,7 +1939,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
1939
1939
|
assert(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
|
|
1940
1940
|
operation: safeOp, fault: "overflow", value: val
|
|
1941
1941
|
});
|
|
1942
|
-
if (val > BN_0$
|
|
1942
|
+
if (val > BN_0$7) {
|
|
1943
1943
|
val = fromTwos(mask(val, width), width);
|
|
1944
1944
|
}
|
|
1945
1945
|
else {
|
|
@@ -1997,7 +1997,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
1997
1997
|
}
|
|
1998
1998
|
function toString(val, decimals) {
|
|
1999
1999
|
let negative = "";
|
|
2000
|
-
if (val < BN_0$
|
|
2000
|
+
if (val < BN_0$7) {
|
|
2001
2001
|
negative = "-";
|
|
2002
2002
|
val *= BN_N1;
|
|
2003
2003
|
}
|
|
@@ -2188,13 +2188,13 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
2188
2188
|
mulSignal(other) {
|
|
2189
2189
|
this.#checkFormat(other);
|
|
2190
2190
|
const value = this.#val * other.#val;
|
|
2191
|
-
assert((value % this.#tens) === BN_0$
|
|
2191
|
+
assert((value % this.#tens) === BN_0$7, "precision lost during signalling mul", "NUMERIC_FAULT", {
|
|
2192
2192
|
operation: "mulSignal", fault: "underflow", value: this
|
|
2193
2193
|
});
|
|
2194
2194
|
return this.#checkValue(value / this.#tens, "mulSignal");
|
|
2195
2195
|
}
|
|
2196
2196
|
#div(o, safeOp) {
|
|
2197
|
-
assert(o.#val !== BN_0$
|
|
2197
|
+
assert(o.#val !== BN_0$7, "division by zero", "NUMERIC_FAULT", {
|
|
2198
2198
|
operation: "div", fault: "divide-by-zero", value: this
|
|
2199
2199
|
});
|
|
2200
2200
|
this.#checkFormat(o);
|
|
@@ -2218,12 +2218,12 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
2218
2218
|
* (precision loss) occurs.
|
|
2219
2219
|
*/
|
|
2220
2220
|
divSignal(other) {
|
|
2221
|
-
assert(other.#val !== BN_0$
|
|
2221
|
+
assert(other.#val !== BN_0$7, "division by zero", "NUMERIC_FAULT", {
|
|
2222
2222
|
operation: "div", fault: "divide-by-zero", value: this
|
|
2223
2223
|
});
|
|
2224
2224
|
this.#checkFormat(other);
|
|
2225
2225
|
const value = (this.#val * this.#tens);
|
|
2226
|
-
assert((value % other.#val) === BN_0$
|
|
2226
|
+
assert((value % other.#val) === BN_0$7, "precision lost during signalling div", "NUMERIC_FAULT", {
|
|
2227
2227
|
operation: "divSignal", fault: "underflow", value: this
|
|
2228
2228
|
});
|
|
2229
2229
|
return this.#checkValue(value / other.#val, "divSignal");
|
|
@@ -2282,7 +2282,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
2282
2282
|
*/
|
|
2283
2283
|
floor() {
|
|
2284
2284
|
let val = this.#val;
|
|
2285
|
-
if (this.#val < BN_0$
|
|
2285
|
+
if (this.#val < BN_0$7) {
|
|
2286
2286
|
val -= this.#tens - BN_1$3;
|
|
2287
2287
|
}
|
|
2288
2288
|
val = (this.#val / this.#tens) * this.#tens;
|
|
@@ -2296,7 +2296,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
2296
2296
|
*/
|
|
2297
2297
|
ceiling() {
|
|
2298
2298
|
let val = this.#val;
|
|
2299
|
-
if (this.#val > BN_0$
|
|
2299
|
+
if (this.#val > BN_0$7) {
|
|
2300
2300
|
val += this.#tens - BN_1$3;
|
|
2301
2301
|
}
|
|
2302
2302
|
val = (this.#val / this.#tens) * this.#tens;
|
|
@@ -2325,11 +2325,11 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
2325
2325
|
/**
|
|
2326
2326
|
* Returns true if %%this%% is equal to ``0``.
|
|
2327
2327
|
*/
|
|
2328
|
-
isZero() { return (this.#val === BN_0$
|
|
2328
|
+
isZero() { return (this.#val === BN_0$7); }
|
|
2329
2329
|
/**
|
|
2330
2330
|
* Returns true if %%this%% is less than ``0``.
|
|
2331
2331
|
*/
|
|
2332
|
-
isNegative() { return (this.#val < BN_0$
|
|
2332
|
+
isNegative() { return (this.#val < BN_0$7); }
|
|
2333
2333
|
/**
|
|
2334
2334
|
* Returns the string representation of %%this%%.
|
|
2335
2335
|
*/
|
|
@@ -2366,7 +2366,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
2366
2366
|
const delta = decimals - format.decimals;
|
|
2367
2367
|
if (delta > 0) {
|
|
2368
2368
|
const tens = getTens(delta);
|
|
2369
|
-
assert((value % tens) === BN_0$
|
|
2369
|
+
assert((value % tens) === BN_0$7, "value loses precision for format", "NUMERIC_FAULT", {
|
|
2370
2370
|
operation: "fromValue", fault: "underflow", value: _value
|
|
2371
2371
|
});
|
|
2372
2372
|
value /= tens;
|
|
@@ -4779,11 +4779,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
4779
4779
|
const MessagePrefix = "\x19Ethereum Signed Message:\n";
|
|
4780
4780
|
|
|
4781
4781
|
// Constants
|
|
4782
|
-
const BN_0$7 = BigInt(0);
|
|
4783
|
-
//const BN_1 = BigInt(1);
|
|
4784
|
-
const BN_2$3 = BigInt(2);
|
|
4785
|
-
const BN_28$1 = BigInt(28);
|
|
4786
|
-
const BN_35$1 = BigInt(35);
|
|
4787
4782
|
const _guard$1 = {};
|
|
4788
4783
|
/*
|
|
4789
4784
|
function toUint256(value: BigNumberish): string {
|
|
@@ -4799,7 +4794,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
4799
4794
|
#r;
|
|
4800
4795
|
#s;
|
|
4801
4796
|
#v;
|
|
4802
|
-
#networkV;
|
|
4803
4797
|
/**
|
|
4804
4798
|
* The ``r`` value for a signature.
|
|
4805
4799
|
*
|
|
@@ -4820,67 +4814,22 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
4820
4814
|
}
|
|
4821
4815
|
/**
|
|
4822
4816
|
* The ``v`` value for a signature.
|
|
4823
|
-
*
|
|
4824
|
-
* Since a given ``x`` value for ``r`` has two possible values for
|
|
4825
|
-
* its correspondin ``y``, the ``v`` indicates which of the two ``y``
|
|
4826
|
-
* values to use.
|
|
4827
|
-
*
|
|
4828
|
-
* It is normalized to the values ``28`` or ``28`` for legacy
|
|
4829
|
-
* purposes.
|
|
4830
4817
|
*/
|
|
4831
4818
|
get v() { return this.#v; }
|
|
4832
4819
|
set v(value) {
|
|
4833
4820
|
const v = getNumber(value, "value");
|
|
4834
|
-
assertArgument(v ===
|
|
4821
|
+
assertArgument(v === 1, "invalid v", "v", value);
|
|
4835
4822
|
this.#v = v;
|
|
4836
4823
|
}
|
|
4837
|
-
/**
|
|
4838
|
-
* The EIP-155 ``v`` for legacy transactions. For non-legacy
|
|
4839
|
-
* transactions, this value is ``null``.
|
|
4840
|
-
*/
|
|
4841
|
-
get networkV() { return this.#networkV; }
|
|
4842
|
-
/**
|
|
4843
|
-
* The chain ID for EIP-155 legacy transactions. For non-legacy
|
|
4844
|
-
* transactions, this value is ``null``.
|
|
4845
|
-
*/
|
|
4846
|
-
get legacyChainId() {
|
|
4847
|
-
const v = this.networkV;
|
|
4848
|
-
if (v == null) {
|
|
4849
|
-
return null;
|
|
4850
|
-
}
|
|
4851
|
-
return Signature.getChainId(v);
|
|
4852
|
-
}
|
|
4853
|
-
/**
|
|
4854
|
-
* The ``yParity`` for the signature.
|
|
4855
|
-
*
|
|
4856
|
-
* See ``v`` for more details on how this value is used.
|
|
4857
|
-
*/
|
|
4858
|
-
get yParity() {
|
|
4859
|
-
return (this.v === 28) ? 0 : 1;
|
|
4860
|
-
}
|
|
4861
|
-
/**
|
|
4862
|
-
* The [[link-eip-2098]] compact representation of the ``yParity``
|
|
4863
|
-
* and ``s`` compacted into a single ``bytes32``.
|
|
4864
|
-
*/
|
|
4865
|
-
get yParityAndS() {
|
|
4866
|
-
// The EIP-2098 compact representation
|
|
4867
|
-
const yParityAndS = getBytes(this.s);
|
|
4868
|
-
if (this.yParity) {
|
|
4869
|
-
yParityAndS[0] |= 0x80;
|
|
4870
|
-
}
|
|
4871
|
-
return hexlify(yParityAndS);
|
|
4872
|
-
}
|
|
4873
|
-
/**
|
|
4874
|
-
* The [[link-eip-2098]] compact representation.
|
|
4875
|
-
*/
|
|
4876
|
-
get compactSerialized() {
|
|
4877
|
-
return concat([this.r, this.yParityAndS]);
|
|
4878
|
-
}
|
|
4879
4824
|
/**
|
|
4880
4825
|
* The serialized representation.
|
|
4881
4826
|
*/
|
|
4882
4827
|
get serialized() {
|
|
4883
|
-
return
|
|
4828
|
+
return JSON.stringify({
|
|
4829
|
+
r: this.r,
|
|
4830
|
+
s: this.s,
|
|
4831
|
+
v: this.v
|
|
4832
|
+
});
|
|
4884
4833
|
}
|
|
4885
4834
|
/**
|
|
4886
4835
|
* @private
|
|
@@ -4890,94 +4839,26 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
4890
4839
|
this.#r = r;
|
|
4891
4840
|
this.#s = s;
|
|
4892
4841
|
this.#v = v;
|
|
4893
|
-
this.#networkV = null;
|
|
4894
4842
|
}
|
|
4895
4843
|
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
4896
|
-
return `Signature { r: "${this.r}", s: "${this.s}"
|
|
4844
|
+
return `Signature { r: "${this.r}", s: "${this.s}" }`;
|
|
4897
4845
|
}
|
|
4898
4846
|
/**
|
|
4899
4847
|
* Returns a new identical [[Signature]].
|
|
4900
4848
|
*/
|
|
4901
4849
|
clone() {
|
|
4902
4850
|
const clone = new Signature(_guard$1, this.r, this.s, this.v);
|
|
4903
|
-
if (this.networkV) {
|
|
4904
|
-
clone.#networkV = this.networkV;
|
|
4905
|
-
}
|
|
4906
4851
|
return clone;
|
|
4907
4852
|
}
|
|
4908
4853
|
/**
|
|
4909
4854
|
* Returns a representation that is compatible with ``JSON.stringify``.
|
|
4910
4855
|
*/
|
|
4911
4856
|
toJSON() {
|
|
4912
|
-
const networkV = this.networkV;
|
|
4913
4857
|
return {
|
|
4914
4858
|
_type: "signature",
|
|
4915
|
-
networkV: ((networkV != null) ? networkV.toString() : null),
|
|
4916
4859
|
r: this.r, s: this.s, v: this.v,
|
|
4917
4860
|
};
|
|
4918
4861
|
}
|
|
4919
|
-
/**
|
|
4920
|
-
* Compute the chain ID from the ``v`` in a legacy EIP-155 transactions.
|
|
4921
|
-
*
|
|
4922
|
-
* @example:
|
|
4923
|
-
* Signature.getChainId(45)
|
|
4924
|
-
* //_result:
|
|
4925
|
-
*
|
|
4926
|
-
* Signature.getChainId(46)
|
|
4927
|
-
* //_result:
|
|
4928
|
-
*/
|
|
4929
|
-
static getChainId(v) {
|
|
4930
|
-
const bv = getBigInt(v, "v");
|
|
4931
|
-
// The v is not an EIP-155 v, so it is the unspecified chain ID
|
|
4932
|
-
if ((bv == BN_28$1) || (bv == BN_28$1)) {
|
|
4933
|
-
return BN_0$7;
|
|
4934
|
-
}
|
|
4935
|
-
// Bad value for an EIP-155 v
|
|
4936
|
-
assertArgument(bv >= BN_35$1, "invalid EIP-155 v", "v", v);
|
|
4937
|
-
return (bv - BN_35$1) / BN_2$3;
|
|
4938
|
-
}
|
|
4939
|
-
/**
|
|
4940
|
-
* Compute the ``v`` for a chain ID for a legacy EIP-155 transactions.
|
|
4941
|
-
*
|
|
4942
|
-
* Legacy transactions which use [[link-eip-155]] hijack the ``v``
|
|
4943
|
-
* property to include the chain ID.
|
|
4944
|
-
*
|
|
4945
|
-
* @example:
|
|
4946
|
-
*
|
|
4947
|
-
* Signature.getChainIdV(5, 28)
|
|
4948
|
-
* //_result:
|
|
4949
|
-
*
|
|
4950
|
-
*/
|
|
4951
|
-
static getChainIdV(chainId, v) {
|
|
4952
|
-
return (getBigInt(chainId) * BN_2$3) + BigInt(35 + v - 28);
|
|
4953
|
-
}
|
|
4954
|
-
/**
|
|
4955
|
-
* Compute the normalized legacy transaction ``v`` from a ``yParirty``,
|
|
4956
|
-
* a legacy transaction ``v`` or a legacy [[link-eip-155]] transaction.
|
|
4957
|
-
*
|
|
4958
|
-
* @example:
|
|
4959
|
-
* // The values 0 and 1 imply v is actually yParity
|
|
4960
|
-
* Signature.getNormalizedV(0)
|
|
4961
|
-
* //_result:
|
|
4962
|
-
*
|
|
4963
|
-
* // Legacy EIP-155 transaction (i.e. >= 35)
|
|
4964
|
-
* Signature.getNormalizedV(46)
|
|
4965
|
-
* //_result:
|
|
4966
|
-
*
|
|
4967
|
-
* // Invalid values throw
|
|
4968
|
-
* Signature.getNormalizedV(5)
|
|
4969
|
-
* //_error:
|
|
4970
|
-
*/
|
|
4971
|
-
/*static getNormalizedV(v: BigNumberish): 28 {
|
|
4972
|
-
const bv = getBigInt(v);
|
|
4973
|
-
|
|
4974
|
-
if (bv === BN_1 || bv === BN_28) { return 28; }
|
|
4975
|
-
|
|
4976
|
-
assertArgument(bv >= BN_35, "invalid v", "v", v);
|
|
4977
|
-
|
|
4978
|
-
// Otherwise, EIP-155 v means odd is 28 and even is 28
|
|
4979
|
-
return (bv & BN_1) ? 28: 28;
|
|
4980
|
-
}*/
|
|
4981
4862
|
/**
|
|
4982
4863
|
* Creates a new [[Signature]].
|
|
4983
4864
|
*
|
|
@@ -4991,85 +4872,20 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
4991
4872
|
assertArgument(check, message, "signature", sig);
|
|
4992
4873
|
}
|
|
4993
4874
|
if (sig == null) {
|
|
4994
|
-
return new Signature(_guard$1, ZeroHash, ZeroHash,
|
|
4875
|
+
return new Signature(_guard$1, ZeroHash, ZeroHash, 1);
|
|
4995
4876
|
}
|
|
4996
4877
|
if (typeof (sig) === "string") {
|
|
4997
|
-
|
|
4998
|
-
if (bytes.length === 64) {
|
|
4999
|
-
const r = hexlify(bytes.slice(0, 32));
|
|
5000
|
-
const s = bytes.slice(32, 64);
|
|
5001
|
-
const v = (s[0] & 0x80) ? 28: 28;
|
|
5002
|
-
s[0] &= 0x7f;
|
|
5003
|
-
return new Signature(_guard, r, hexlify(s), v);
|
|
5004
|
-
}
|
|
5005
|
-
|
|
5006
|
-
if (bytes.length === 65) {
|
|
5007
|
-
const r = hexlify(bytes.slice(0, 32));
|
|
5008
|
-
const s = bytes.slice(32, 64);
|
|
5009
|
-
assertError((s[0] & 0x80) === 0, "non-canonical s");
|
|
5010
|
-
const v = Signature.getNormalizedV(bytes[64]);
|
|
5011
|
-
return new Signature(_guard, r, hexlify(s), v);
|
|
5012
|
-
}*/
|
|
5013
|
-
assertError(false, "invalid raw signature length");
|
|
4878
|
+
assertError(false, "invalid raw signature");
|
|
5014
4879
|
}
|
|
5015
4880
|
if (sig instanceof Signature) {
|
|
5016
4881
|
return sig.clone();
|
|
5017
4882
|
}
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
const
|
|
5021
|
-
assertError(
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
// Get s; by any means necessary (we check consistency below)
|
|
5025
|
-
const s = (function(s?: string, yParityAndS?: string) {
|
|
5026
|
-
if (s != null) { return toUint256(s); }
|
|
5027
|
-
|
|
5028
|
-
if (yParityAndS != null) {
|
|
5029
|
-
assertError(isHexString(yParityAndS, 32), "invalid yParityAndS");
|
|
5030
|
-
const bytes = getBytes(yParityAndS);
|
|
5031
|
-
bytes[0] &= 0x7f;
|
|
5032
|
-
return hexlify(bytes);
|
|
5033
|
-
}
|
|
5034
|
-
|
|
5035
|
-
assertError(false, "missing s");
|
|
5036
|
-
})(sig.s, sig.yParityAndS);
|
|
5037
|
-
assertError((getBytes(s)[0] & 0x80) == 0, "non-canonical s");
|
|
5038
|
-
|
|
5039
|
-
// Get v; by any means necessary (we check consistency below)
|
|
5040
|
-
const { networkV, v } = (function(_v?: BigNumberish, yParityAndS?: string, yParity?: Numeric): { networkV?: bigint, v: 28 | 28 } {
|
|
5041
|
-
if (_v != null) {
|
|
5042
|
-
const v = getBigInt(_v);
|
|
5043
|
-
return {
|
|
5044
|
-
networkV: ((v >= BN_35) ? v: undefined),
|
|
5045
|
-
v: Signature.getNormalizedV(v)
|
|
5046
|
-
};
|
|
5047
|
-
}
|
|
5048
|
-
|
|
5049
|
-
if (yParityAndS != null) {
|
|
5050
|
-
assertError(isHexString(yParityAndS, 32), "invalid yParityAndS");
|
|
5051
|
-
return { v: ((getBytes(yParityAndS)[0] & 0x80) ? 28: 28) };
|
|
5052
|
-
}
|
|
5053
|
-
|
|
5054
|
-
if (yParity != null) {
|
|
5055
|
-
switch (getNumber(yParity, "sig.yParity")) {
|
|
5056
|
-
case 0: return { v: 28 };
|
|
5057
|
-
case 1: return { v: 28 };
|
|
5058
|
-
}
|
|
5059
|
-
assertError(false, "invalid yParity");
|
|
5060
|
-
}
|
|
5061
|
-
|
|
5062
|
-
assertError(false, "missing v");
|
|
5063
|
-
})(sig.v, sig.yParityAndS, sig.yParity);
|
|
5064
|
-
|
|
5065
|
-
const result = new Signature(_guard, r, s, v);
|
|
5066
|
-
if (networkV) { result.#networkV = networkV; }
|
|
5067
|
-
|
|
5068
|
-
// If multiple of v, yParity, yParityAndS we given, check they match
|
|
5069
|
-
assertError(sig.yParity == null || getNumber(sig.yParity, "sig.yParity") === result.yParity, "yParity mismatch");
|
|
5070
|
-
assertError(sig.yParityAndS == null || sig.yParityAndS === result.yParityAndS, "yParityAndS mismatch");
|
|
5071
|
-
|
|
5072
|
-
return result;*/
|
|
4883
|
+
assertError(sig.r != null, "missing r");
|
|
4884
|
+
assertError(sig.s != null, "missing s");
|
|
4885
|
+
const _v = sig.v;
|
|
4886
|
+
assertError(_v != null, "missing v");
|
|
4887
|
+
assertArgument(_v === 1, "invalid v", "v", sig.v);
|
|
4888
|
+
return new Signature(_guard$1, sig.r, sig.s, 1);
|
|
5073
4889
|
}
|
|
5074
4890
|
}
|
|
5075
4891
|
|
|
@@ -5080,7 +4896,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
5080
4896
|
*/
|
|
5081
4897
|
const CRYPTO_MESSAGE_LENGTH = 32;
|
|
5082
4898
|
const CRYPTO_SECRETKEY_BYTES = 64 + 2560 + 1312 + 128;
|
|
5083
|
-
|
|
4899
|
+
const CRYPTO_PUBLICKEY_BYTES = 32 + 1312 + 64;
|
|
5084
4900
|
/**
|
|
5085
4901
|
* A **SigningKey** provides high-level access to cryptography operations and key management.
|
|
5086
4902
|
*/
|
|
@@ -5107,9 +4923,10 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
5107
4923
|
*/
|
|
5108
4924
|
sign(digest) {
|
|
5109
4925
|
assertArgument(dataLength(digest) === CRYPTO_MESSAGE_LENGTH, "invalid digest length", "digest", digest);
|
|
5110
|
-
const sig =
|
|
4926
|
+
const sig = quantumCoinPqcJsSdk.cryptoSign(getBytesCopy(digest), getBytesCopy(this.#privateKey));
|
|
5111
4927
|
const pubBytes = getBytes(this.publicKey);
|
|
5112
|
-
|
|
4928
|
+
let combinedSig = quantumCoinJsSdk.combinePublicKeySignature(pubBytes, sig);
|
|
4929
|
+
combinedSig = "0x" + combinedSig;
|
|
5113
4930
|
return Signature.from({
|
|
5114
4931
|
r: this.publicKey,
|
|
5115
4932
|
s: combinedSig,
|
|
@@ -5117,7 +4934,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
5117
4934
|
});
|
|
5118
4935
|
}
|
|
5119
4936
|
/**
|
|
5120
|
-
* Compute the public key for a private %%key%%.
|
|
4937
|
+
* Compute the public key for a private %%key%%. If a publicKey is passed, it is returned as is. for backward compatibility.
|
|
5121
4938
|
*
|
|
5122
4939
|
*
|
|
5123
4940
|
* @example:
|
|
@@ -5128,9 +4945,17 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
5128
4945
|
* //_result:
|
|
5129
4946
|
*/
|
|
5130
4947
|
static computePublicKey(key) {
|
|
5131
|
-
|
|
5132
|
-
let
|
|
5133
|
-
|
|
4948
|
+
let keyBytes = getBytes(key, "key");
|
|
4949
|
+
let pubKey;
|
|
4950
|
+
if (keyBytes.length == CRYPTO_SECRETKEY_BYTES) {
|
|
4951
|
+
pubKey = quantumCoinJsSdk.publicKeyFromPrivateKey(keyBytes);
|
|
4952
|
+
assertArgument(pubKey !== null && pubKey !== undefined, "invalid key", "key", "[REDACTED]");
|
|
4953
|
+
pubKey = '0x' + pubKey;
|
|
4954
|
+
}
|
|
4955
|
+
else if (keyBytes.length == CRYPTO_PUBLICKEY_BYTES) {
|
|
4956
|
+
pubKey = keyBytes;
|
|
4957
|
+
}
|
|
4958
|
+
assertArgument(pubKey !== null && pubKey !== undefined, "invalid key", "key", "[REDACTED]");
|
|
5134
4959
|
return pubKey;
|
|
5135
4960
|
}
|
|
5136
4961
|
/**
|
|
@@ -5156,7 +4981,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
5156
4981
|
const sig = Signature.from(signature);
|
|
5157
4982
|
let sigBytes = getBytes(sig.s);
|
|
5158
4983
|
let digestBytes = digest;
|
|
5159
|
-
let publicKey =
|
|
4984
|
+
let publicKey = quantumCoinJsSdk.publicKeyFromSignature(digestBytes, sigBytes);
|
|
5160
4985
|
return publicKey;
|
|
5161
4986
|
}
|
|
5162
4987
|
}
|
|
@@ -6560,13 +6385,18 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6560
6385
|
function computeAddress(key) {
|
|
6561
6386
|
let pubkey;
|
|
6562
6387
|
if (typeof (key) === "string") {
|
|
6563
|
-
|
|
6388
|
+
if (key.startsWith("0x")) {
|
|
6389
|
+
pubkey = SigningKey.computePublicKey(key);
|
|
6390
|
+
}
|
|
6391
|
+
else {
|
|
6392
|
+
pubkey = SigningKey.computePublicKey("0x" + key);
|
|
6393
|
+
}
|
|
6564
6394
|
}
|
|
6565
6395
|
else {
|
|
6566
6396
|
pubkey = key.publicKey;
|
|
6567
6397
|
}
|
|
6568
6398
|
let pubKeyBytes = getBytes(pubkey);
|
|
6569
|
-
return
|
|
6399
|
+
return quantumCoinJsSdk.addressFromPublicKey(pubKeyBytes);
|
|
6570
6400
|
}
|
|
6571
6401
|
/**
|
|
6572
6402
|
* Returns the recovered address for the private key that was
|
|
@@ -6663,9 +6493,9 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6663
6493
|
nonce: handleUint(auth[2], "nonce"),
|
|
6664
6494
|
chainId: handleUint(auth[0], "chainId"),
|
|
6665
6495
|
signature: Signature.from({
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6496
|
+
r: auth[4],
|
|
6497
|
+
s: auth[5],
|
|
6498
|
+
v: 1
|
|
6669
6499
|
})
|
|
6670
6500
|
});
|
|
6671
6501
|
}
|
|
@@ -6704,7 +6534,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6704
6534
|
formatNumber(a.chainId, "chainId"),
|
|
6705
6535
|
a.address,
|
|
6706
6536
|
formatNumber(a.nonce, "nonce"),
|
|
6707
|
-
formatNumber(a.signature.yParity, "yParity"),
|
|
6708
6537
|
a.signature.r,
|
|
6709
6538
|
a.signature.s
|
|
6710
6539
|
];
|
|
@@ -6772,17 +6601,8 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6772
6601
|
if (tx.chainId != BN_0$4) {
|
|
6773
6602
|
// A chainId was provided; if non-zero we'll use EIP-155
|
|
6774
6603
|
chainId = getBigInt(tx.chainId, "tx.chainId");
|
|
6775
|
-
// We have a chainId in the tx and an EIP-155 v in the signature,
|
|
6776
|
-
// make sure they agree with each other
|
|
6777
|
-
assertArgument(!sig || sig.networkV == null || sig.legacyChainId === chainId, "tx.chainId/sig.v mismatch", "sig", sig);
|
|
6778
|
-
}
|
|
6779
|
-
else if (tx.signature) {
|
|
6780
|
-
// No explicit chainId, but EIP-155 have a derived implicit chainId
|
|
6781
|
-
const legacy = tx.signature.legacyChainId;
|
|
6782
|
-
if (legacy != null) {
|
|
6783
|
-
chainId = legacy;
|
|
6784
|
-
}
|
|
6785
6604
|
}
|
|
6605
|
+
else if (tx.signature) ;
|
|
6786
6606
|
// Requesting an unsigned transaction
|
|
6787
6607
|
if (!sig) {
|
|
6788
6608
|
// We have an EIP-155 transaction (chainId was specified and non-zero)
|
|
@@ -6793,17 +6613,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6793
6613
|
}
|
|
6794
6614
|
return encodeRlp(fields);
|
|
6795
6615
|
}
|
|
6796
|
-
|
|
6797
|
-
// match but that logic could break existing code, so schedule
|
|
6798
|
-
// this for the next major bump.
|
|
6799
|
-
// Compute the EIP-155 v
|
|
6800
|
-
let v = BigInt(27 + sig.yParity);
|
|
6801
|
-
if (chainId !== BN_0$4) {
|
|
6802
|
-
v = Signature.getChainIdV(chainId, sig.v);
|
|
6803
|
-
}
|
|
6804
|
-
else if (BigInt(sig.v) !== v) {
|
|
6805
|
-
assertArgument(false, "tx.chainId/sig.v mismatch", "sig", sig);
|
|
6806
|
-
}
|
|
6616
|
+
let v = sig.v;
|
|
6807
6617
|
// Add the signature
|
|
6808
6618
|
fields.push(toBeArray(v));
|
|
6809
6619
|
fields.push(toBeArray(sig.r));
|
|
@@ -6811,19 +6621,9 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6811
6621
|
return encodeRlp(fields);
|
|
6812
6622
|
}
|
|
6813
6623
|
function _parseEipSignature(tx, fields) {
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
if (yParity !== 0 && yParity !== 1) {
|
|
6818
|
-
throw new Error("bad yParity");
|
|
6819
|
-
}
|
|
6820
|
-
}
|
|
6821
|
-
catch (error) {
|
|
6822
|
-
assertArgument(false, "invalid yParity", "yParity", fields[0]);
|
|
6823
|
-
}
|
|
6824
|
-
const r = zeroPadValue(fields[1], 32);
|
|
6825
|
-
const s = zeroPadValue(fields[2], 32);
|
|
6826
|
-
const signature = Signature.from({ r, s, yParity });
|
|
6624
|
+
const r = fields[1];
|
|
6625
|
+
const s = fields[2];
|
|
6626
|
+
const signature = Signature.from({ r, s });
|
|
6827
6627
|
tx.signature = signature;
|
|
6828
6628
|
}
|
|
6829
6629
|
function _parseEip1559(data) {
|
|
@@ -6863,7 +6663,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6863
6663
|
formatAccessList(tx.accessList || [])
|
|
6864
6664
|
];
|
|
6865
6665
|
if (sig) {
|
|
6866
|
-
fields.push(formatNumber(sig.yParity, "yParity"));
|
|
6867
6666
|
fields.push(toBeArray(sig.r));
|
|
6868
6667
|
fields.push(toBeArray(sig.s));
|
|
6869
6668
|
}
|
|
@@ -6903,7 +6702,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6903
6702
|
formatAccessList(tx.accessList || [])
|
|
6904
6703
|
];
|
|
6905
6704
|
if (sig) {
|
|
6906
|
-
fields.push(formatNumber(sig.yParity, "recoveryParam"));
|
|
6907
6705
|
fields.push(toBeArray(sig.r));
|
|
6908
6706
|
fields.push(toBeArray(sig.s));
|
|
6909
6707
|
}
|
|
@@ -6981,7 +6779,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
6981
6779
|
formatHashes(tx.blobVersionedHashes || [], "blobVersionedHashes")
|
|
6982
6780
|
];
|
|
6983
6781
|
if (sig) {
|
|
6984
|
-
fields.push(formatNumber(sig.yParity, "yParity"));
|
|
6985
6782
|
fields.push(toBeArray(sig.r));
|
|
6986
6783
|
fields.push(toBeArray(sig.s));
|
|
6987
6784
|
// We have blobs; return the network wrapped format
|
|
@@ -7037,7 +6834,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
7037
6834
|
formatAuthorizationList(tx.authorizationList || [])
|
|
7038
6835
|
];
|
|
7039
6836
|
if (sig) {
|
|
7040
|
-
fields.push(formatNumber(sig.yParity, "yParity"));
|
|
7041
6837
|
fields.push(toBeArray(sig.r));
|
|
7042
6838
|
fields.push(toBeArray(sig.s));
|
|
7043
6839
|
}
|
|
@@ -7758,276 +7554,276 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
7758
7554
|
const FENCED = new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]);
|
|
7759
7555
|
const NSM_MAX = 4;
|
|
7760
7556
|
|
|
7761
|
-
function decode_arithmetic(bytes) {
|
|
7762
|
-
let pos = 0;
|
|
7763
|
-
function u16() { return (bytes[pos++] << 8) | bytes[pos++]; }
|
|
7764
|
-
|
|
7765
|
-
// decode the frequency table
|
|
7766
|
-
let symbol_count = u16();
|
|
7767
|
-
let total = 1;
|
|
7768
|
-
let acc = [0, 1]; // first symbol has frequency 1
|
|
7769
|
-
for (let i = 1; i < symbol_count; i++) {
|
|
7770
|
-
acc.push(total += u16());
|
|
7771
|
-
}
|
|
7772
|
-
|
|
7773
|
-
// skip the sized-payload that the last 3 symbols index into
|
|
7774
|
-
let skip = u16();
|
|
7775
|
-
let pos_payload = pos;
|
|
7776
|
-
pos += skip;
|
|
7777
|
-
|
|
7778
|
-
let read_width = 0;
|
|
7779
|
-
let read_buffer = 0;
|
|
7780
|
-
function read_bit() {
|
|
7781
|
-
if (read_width == 0) {
|
|
7782
|
-
// this will read beyond end of buffer
|
|
7783
|
-
// but (undefined|0) => zero pad
|
|
7784
|
-
read_buffer = (read_buffer << 8) | bytes[pos++];
|
|
7785
|
-
read_width = 8;
|
|
7786
|
-
}
|
|
7787
|
-
return (read_buffer >> --read_width) & 1;
|
|
7788
|
-
}
|
|
7789
|
-
|
|
7790
|
-
const N = 31;
|
|
7791
|
-
const FULL = 2**N;
|
|
7792
|
-
const HALF = FULL >>> 1;
|
|
7793
|
-
const QRTR = HALF >> 1;
|
|
7794
|
-
const MASK = FULL - 1;
|
|
7795
|
-
|
|
7796
|
-
// fill register
|
|
7797
|
-
let register = 0;
|
|
7798
|
-
for (let i = 0; i < N; i++) register = (register << 1) | read_bit();
|
|
7799
|
-
|
|
7800
|
-
let symbols = [];
|
|
7801
|
-
let low = 0;
|
|
7802
|
-
let range = FULL; // treat like a float
|
|
7803
|
-
while (true) {
|
|
7804
|
-
let value = Math.floor((((register - low + 1) * total) - 1) / range);
|
|
7805
|
-
let start = 0;
|
|
7806
|
-
let end = symbol_count;
|
|
7807
|
-
while (end - start > 1) { // binary search
|
|
7808
|
-
let mid = (start + end) >>> 1;
|
|
7809
|
-
if (value < acc[mid]) {
|
|
7810
|
-
end = mid;
|
|
7811
|
-
} else {
|
|
7812
|
-
start = mid;
|
|
7813
|
-
}
|
|
7814
|
-
}
|
|
7815
|
-
if (start == 0) break; // first symbol is end mark
|
|
7816
|
-
symbols.push(start);
|
|
7817
|
-
let a = low + Math.floor(range * acc[start] / total);
|
|
7818
|
-
let b = low + Math.floor(range * acc[start+1] / total) - 1;
|
|
7819
|
-
while (((a ^ b) & HALF) == 0) {
|
|
7820
|
-
register = (register << 1) & MASK | read_bit();
|
|
7821
|
-
a = (a << 1) & MASK;
|
|
7822
|
-
b = (b << 1) & MASK | 1;
|
|
7823
|
-
}
|
|
7824
|
-
while (a & ~b & QRTR) {
|
|
7825
|
-
register = (register & HALF) | ((register << 1) & (MASK >>> 1)) | read_bit();
|
|
7826
|
-
a = (a << 1) ^ HALF;
|
|
7827
|
-
b = ((b ^ HALF) << 1) | HALF | 1;
|
|
7828
|
-
}
|
|
7829
|
-
low = a;
|
|
7830
|
-
range = 1 + b - a;
|
|
7831
|
-
}
|
|
7832
|
-
let offset = symbol_count - 4;
|
|
7833
|
-
return symbols.map(x => { // index into payload
|
|
7834
|
-
switch (x - offset) {
|
|
7835
|
-
case 3: return offset + 0x10100 + ((bytes[pos_payload++] << 16) | (bytes[pos_payload++] << 8) | bytes[pos_payload++]);
|
|
7836
|
-
case 2: return offset + 0x100 + ((bytes[pos_payload++] << 8) | bytes[pos_payload++]);
|
|
7837
|
-
case 1: return offset + bytes[pos_payload++];
|
|
7838
|
-
default: return x - 1;
|
|
7839
|
-
}
|
|
7840
|
-
});
|
|
7841
|
-
}
|
|
7842
|
-
|
|
7843
|
-
// returns an iterator which returns the next symbol
|
|
7844
|
-
function read_payload(v) {
|
|
7845
|
-
let pos = 0;
|
|
7846
|
-
return () => v[pos++];
|
|
7847
|
-
}
|
|
7848
|
-
function read_compressed_payload(s) {
|
|
7849
|
-
return read_payload(decode_arithmetic(unsafe_atob(s)));
|
|
7557
|
+
function decode_arithmetic(bytes) {
|
|
7558
|
+
let pos = 0;
|
|
7559
|
+
function u16() { return (bytes[pos++] << 8) | bytes[pos++]; }
|
|
7560
|
+
|
|
7561
|
+
// decode the frequency table
|
|
7562
|
+
let symbol_count = u16();
|
|
7563
|
+
let total = 1;
|
|
7564
|
+
let acc = [0, 1]; // first symbol has frequency 1
|
|
7565
|
+
for (let i = 1; i < symbol_count; i++) {
|
|
7566
|
+
acc.push(total += u16());
|
|
7567
|
+
}
|
|
7568
|
+
|
|
7569
|
+
// skip the sized-payload that the last 3 symbols index into
|
|
7570
|
+
let skip = u16();
|
|
7571
|
+
let pos_payload = pos;
|
|
7572
|
+
pos += skip;
|
|
7573
|
+
|
|
7574
|
+
let read_width = 0;
|
|
7575
|
+
let read_buffer = 0;
|
|
7576
|
+
function read_bit() {
|
|
7577
|
+
if (read_width == 0) {
|
|
7578
|
+
// this will read beyond end of buffer
|
|
7579
|
+
// but (undefined|0) => zero pad
|
|
7580
|
+
read_buffer = (read_buffer << 8) | bytes[pos++];
|
|
7581
|
+
read_width = 8;
|
|
7582
|
+
}
|
|
7583
|
+
return (read_buffer >> --read_width) & 1;
|
|
7584
|
+
}
|
|
7585
|
+
|
|
7586
|
+
const N = 31;
|
|
7587
|
+
const FULL = 2**N;
|
|
7588
|
+
const HALF = FULL >>> 1;
|
|
7589
|
+
const QRTR = HALF >> 1;
|
|
7590
|
+
const MASK = FULL - 1;
|
|
7591
|
+
|
|
7592
|
+
// fill register
|
|
7593
|
+
let register = 0;
|
|
7594
|
+
for (let i = 0; i < N; i++) register = (register << 1) | read_bit();
|
|
7595
|
+
|
|
7596
|
+
let symbols = [];
|
|
7597
|
+
let low = 0;
|
|
7598
|
+
let range = FULL; // treat like a float
|
|
7599
|
+
while (true) {
|
|
7600
|
+
let value = Math.floor((((register - low + 1) * total) - 1) / range);
|
|
7601
|
+
let start = 0;
|
|
7602
|
+
let end = symbol_count;
|
|
7603
|
+
while (end - start > 1) { // binary search
|
|
7604
|
+
let mid = (start + end) >>> 1;
|
|
7605
|
+
if (value < acc[mid]) {
|
|
7606
|
+
end = mid;
|
|
7607
|
+
} else {
|
|
7608
|
+
start = mid;
|
|
7609
|
+
}
|
|
7610
|
+
}
|
|
7611
|
+
if (start == 0) break; // first symbol is end mark
|
|
7612
|
+
symbols.push(start);
|
|
7613
|
+
let a = low + Math.floor(range * acc[start] / total);
|
|
7614
|
+
let b = low + Math.floor(range * acc[start+1] / total) - 1;
|
|
7615
|
+
while (((a ^ b) & HALF) == 0) {
|
|
7616
|
+
register = (register << 1) & MASK | read_bit();
|
|
7617
|
+
a = (a << 1) & MASK;
|
|
7618
|
+
b = (b << 1) & MASK | 1;
|
|
7619
|
+
}
|
|
7620
|
+
while (a & ~b & QRTR) {
|
|
7621
|
+
register = (register & HALF) | ((register << 1) & (MASK >>> 1)) | read_bit();
|
|
7622
|
+
a = (a << 1) ^ HALF;
|
|
7623
|
+
b = ((b ^ HALF) << 1) | HALF | 1;
|
|
7624
|
+
}
|
|
7625
|
+
low = a;
|
|
7626
|
+
range = 1 + b - a;
|
|
7627
|
+
}
|
|
7628
|
+
let offset = symbol_count - 4;
|
|
7629
|
+
return symbols.map(x => { // index into payload
|
|
7630
|
+
switch (x - offset) {
|
|
7631
|
+
case 3: return offset + 0x10100 + ((bytes[pos_payload++] << 16) | (bytes[pos_payload++] << 8) | bytes[pos_payload++]);
|
|
7632
|
+
case 2: return offset + 0x100 + ((bytes[pos_payload++] << 8) | bytes[pos_payload++]);
|
|
7633
|
+
case 1: return offset + bytes[pos_payload++];
|
|
7634
|
+
default: return x - 1;
|
|
7635
|
+
}
|
|
7636
|
+
});
|
|
7637
|
+
}
|
|
7638
|
+
|
|
7639
|
+
// returns an iterator which returns the next symbol
|
|
7640
|
+
function read_payload(v) {
|
|
7641
|
+
let pos = 0;
|
|
7642
|
+
return () => v[pos++];
|
|
7643
|
+
}
|
|
7644
|
+
function read_compressed_payload(s) {
|
|
7645
|
+
return read_payload(decode_arithmetic(unsafe_atob(s)));
|
|
7646
|
+
}
|
|
7647
|
+
|
|
7648
|
+
// unsafe in the sense:
|
|
7649
|
+
// expected well-formed Base64 w/o padding
|
|
7650
|
+
// 20220922: added for https://github.com/adraffy/ens-normalize.js/issues/4
|
|
7651
|
+
function unsafe_atob(s) {
|
|
7652
|
+
let lookup = [];
|
|
7653
|
+
[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'].forEach((c, i) => lookup[c.charCodeAt(0)] = i);
|
|
7654
|
+
let n = s.length;
|
|
7655
|
+
let ret = new Uint8Array((6 * n) >> 3);
|
|
7656
|
+
for (let i = 0, pos = 0, width = 0, carry = 0; i < n; i++) {
|
|
7657
|
+
carry = (carry << 6) | lookup[s.charCodeAt(i)];
|
|
7658
|
+
width += 6;
|
|
7659
|
+
if (width >= 8) {
|
|
7660
|
+
ret[pos++] = (carry >> (width -= 8));
|
|
7661
|
+
}
|
|
7662
|
+
}
|
|
7663
|
+
return ret;
|
|
7664
|
+
}
|
|
7665
|
+
|
|
7666
|
+
// eg. [0,1,2,3...] => [0,-1,1,-2,...]
|
|
7667
|
+
function signed(i) {
|
|
7668
|
+
return (i & 1) ? (~i >> 1) : (i >> 1);
|
|
7669
|
+
}
|
|
7670
|
+
|
|
7671
|
+
function read_deltas(n, next) {
|
|
7672
|
+
let v = Array(n);
|
|
7673
|
+
for (let i = 0, x = 0; i < n; i++) v[i] = x += signed(next());
|
|
7674
|
+
return v;
|
|
7675
|
+
}
|
|
7676
|
+
|
|
7677
|
+
// [123][5] => [0 3] [1 1] [0 0]
|
|
7678
|
+
function read_sorted(next, prev = 0) {
|
|
7679
|
+
let ret = [];
|
|
7680
|
+
while (true) {
|
|
7681
|
+
let x = next();
|
|
7682
|
+
let n = next();
|
|
7683
|
+
if (!n) break;
|
|
7684
|
+
prev += x;
|
|
7685
|
+
for (let i = 0; i < n; i++) {
|
|
7686
|
+
ret.push(prev + i);
|
|
7687
|
+
}
|
|
7688
|
+
prev += n + 1;
|
|
7689
|
+
}
|
|
7690
|
+
return ret;
|
|
7691
|
+
}
|
|
7692
|
+
|
|
7693
|
+
function read_sorted_arrays(next) {
|
|
7694
|
+
return read_array_while(() => {
|
|
7695
|
+
let v = read_sorted(next);
|
|
7696
|
+
if (v.length) return v;
|
|
7697
|
+
});
|
|
7698
|
+
}
|
|
7699
|
+
|
|
7700
|
+
// returns map of x => ys
|
|
7701
|
+
function read_mapped(next) {
|
|
7702
|
+
let ret = [];
|
|
7703
|
+
while (true) {
|
|
7704
|
+
let w = next();
|
|
7705
|
+
if (w == 0) break;
|
|
7706
|
+
ret.push(read_linear_table(w, next));
|
|
7707
|
+
}
|
|
7708
|
+
while (true) {
|
|
7709
|
+
let w = next() - 1;
|
|
7710
|
+
if (w < 0) break;
|
|
7711
|
+
ret.push(read_replacement_table(w, next));
|
|
7712
|
+
}
|
|
7713
|
+
return ret.flat();
|
|
7714
|
+
}
|
|
7715
|
+
|
|
7716
|
+
// read until next is falsy
|
|
7717
|
+
// return array of read values
|
|
7718
|
+
function read_array_while(next) {
|
|
7719
|
+
let v = [];
|
|
7720
|
+
while (true) {
|
|
7721
|
+
let x = next(v.length);
|
|
7722
|
+
if (!x) break;
|
|
7723
|
+
v.push(x);
|
|
7724
|
+
}
|
|
7725
|
+
return v;
|
|
7726
|
+
}
|
|
7727
|
+
|
|
7728
|
+
// read w columns of length n
|
|
7729
|
+
// return as n rows of length w
|
|
7730
|
+
function read_transposed(n, w, next) {
|
|
7731
|
+
let m = Array(n).fill().map(() => []);
|
|
7732
|
+
for (let i = 0; i < w; i++) {
|
|
7733
|
+
read_deltas(n, next).forEach((x, j) => m[j].push(x));
|
|
7734
|
+
}
|
|
7735
|
+
return m;
|
|
7736
|
+
}
|
|
7737
|
+
|
|
7738
|
+
// returns [[x, ys], [x+dx, ys+dy], [x+2*dx, ys+2*dy], ...]
|
|
7739
|
+
// where dx/dy = steps, n = run size, w = length of y
|
|
7740
|
+
function read_linear_table(w, next) {
|
|
7741
|
+
let dx = 1 + next();
|
|
7742
|
+
let dy = next();
|
|
7743
|
+
let vN = read_array_while(next);
|
|
7744
|
+
let m = read_transposed(vN.length, 1+w, next);
|
|
7745
|
+
return m.flatMap((v, i) => {
|
|
7746
|
+
let [x, ...ys] = v;
|
|
7747
|
+
return Array(vN[i]).fill().map((_, j) => {
|
|
7748
|
+
let j_dy = j * dy;
|
|
7749
|
+
return [x + j * dx, ys.map(y => y + j_dy)];
|
|
7750
|
+
});
|
|
7751
|
+
});
|
|
7752
|
+
}
|
|
7753
|
+
|
|
7754
|
+
// return [[x, ys...], ...]
|
|
7755
|
+
// where w = length of y
|
|
7756
|
+
function read_replacement_table(w, next) {
|
|
7757
|
+
let n = 1 + next();
|
|
7758
|
+
let m = read_transposed(n, 1+w, next);
|
|
7759
|
+
return m.map(v => [v[0], v.slice(1)]);
|
|
7760
|
+
}
|
|
7761
|
+
|
|
7762
|
+
|
|
7763
|
+
function read_trie(next) {
|
|
7764
|
+
let ret = [];
|
|
7765
|
+
let sorted = read_sorted(next);
|
|
7766
|
+
expand(decode([]), []);
|
|
7767
|
+
return ret; // not sorted
|
|
7768
|
+
function decode(Q) { // characters that lead into this node
|
|
7769
|
+
let S = next(); // state: valid, save, check
|
|
7770
|
+
let B = read_array_while(() => { // buckets leading to new nodes
|
|
7771
|
+
let cps = read_sorted(next).map(i => sorted[i]);
|
|
7772
|
+
if (cps.length) return decode(cps);
|
|
7773
|
+
});
|
|
7774
|
+
return {S, B, Q};
|
|
7775
|
+
}
|
|
7776
|
+
function expand({S, B}, cps, saved) {
|
|
7777
|
+
if (S & 4 && saved === cps[cps.length-1]) return;
|
|
7778
|
+
if (S & 2) saved = cps[cps.length-1];
|
|
7779
|
+
if (S & 1) ret.push(cps);
|
|
7780
|
+
for (let br of B) {
|
|
7781
|
+
for (let cp of br.Q) {
|
|
7782
|
+
expand(br, [...cps, cp], saved);
|
|
7783
|
+
}
|
|
7784
|
+
}
|
|
7785
|
+
}
|
|
7850
7786
|
}
|
|
7851
7787
|
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
return
|
|
7873
|
-
}
|
|
7874
|
-
|
|
7875
|
-
function
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
return
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
}
|
|
7892
|
-
prev += n + 1;
|
|
7893
|
-
}
|
|
7894
|
-
return ret;
|
|
7895
|
-
}
|
|
7896
|
-
|
|
7897
|
-
function read_sorted_arrays(next) {
|
|
7898
|
-
return read_array_while(() => {
|
|
7899
|
-
let v = read_sorted(next);
|
|
7900
|
-
if (v.length) return v;
|
|
7901
|
-
});
|
|
7902
|
-
}
|
|
7903
|
-
|
|
7904
|
-
// returns map of x => ys
|
|
7905
|
-
function read_mapped(next) {
|
|
7906
|
-
let ret = [];
|
|
7907
|
-
while (true) {
|
|
7908
|
-
let w = next();
|
|
7909
|
-
if (w == 0) break;
|
|
7910
|
-
ret.push(read_linear_table(w, next));
|
|
7911
|
-
}
|
|
7912
|
-
while (true) {
|
|
7913
|
-
let w = next() - 1;
|
|
7914
|
-
if (w < 0) break;
|
|
7915
|
-
ret.push(read_replacement_table(w, next));
|
|
7916
|
-
}
|
|
7917
|
-
return ret.flat();
|
|
7918
|
-
}
|
|
7919
|
-
|
|
7920
|
-
// read until next is falsy
|
|
7921
|
-
// return array of read values
|
|
7922
|
-
function read_array_while(next) {
|
|
7923
|
-
let v = [];
|
|
7924
|
-
while (true) {
|
|
7925
|
-
let x = next(v.length);
|
|
7926
|
-
if (!x) break;
|
|
7927
|
-
v.push(x);
|
|
7928
|
-
}
|
|
7929
|
-
return v;
|
|
7930
|
-
}
|
|
7931
|
-
|
|
7932
|
-
// read w columns of length n
|
|
7933
|
-
// return as n rows of length w
|
|
7934
|
-
function read_transposed(n, w, next) {
|
|
7935
|
-
let m = Array(n).fill().map(() => []);
|
|
7936
|
-
for (let i = 0; i < w; i++) {
|
|
7937
|
-
read_deltas(n, next).forEach((x, j) => m[j].push(x));
|
|
7938
|
-
}
|
|
7939
|
-
return m;
|
|
7940
|
-
}
|
|
7941
|
-
|
|
7942
|
-
// returns [[x, ys], [x+dx, ys+dy], [x+2*dx, ys+2*dy], ...]
|
|
7943
|
-
// where dx/dy = steps, n = run size, w = length of y
|
|
7944
|
-
function read_linear_table(w, next) {
|
|
7945
|
-
let dx = 1 + next();
|
|
7946
|
-
let dy = next();
|
|
7947
|
-
let vN = read_array_while(next);
|
|
7948
|
-
let m = read_transposed(vN.length, 1+w, next);
|
|
7949
|
-
return m.flatMap((v, i) => {
|
|
7950
|
-
let [x, ...ys] = v;
|
|
7951
|
-
return Array(vN[i]).fill().map((_, j) => {
|
|
7952
|
-
let j_dy = j * dy;
|
|
7953
|
-
return [x + j * dx, ys.map(y => y + j_dy)];
|
|
7954
|
-
});
|
|
7955
|
-
});
|
|
7956
|
-
}
|
|
7957
|
-
|
|
7958
|
-
// return [[x, ys...], ...]
|
|
7959
|
-
// where w = length of y
|
|
7960
|
-
function read_replacement_table(w, next) {
|
|
7961
|
-
let n = 1 + next();
|
|
7962
|
-
let m = read_transposed(n, 1+w, next);
|
|
7963
|
-
return m.map(v => [v[0], v.slice(1)]);
|
|
7964
|
-
}
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
function read_trie(next) {
|
|
7968
|
-
let ret = [];
|
|
7969
|
-
let sorted = read_sorted(next);
|
|
7970
|
-
expand(decode([]), []);
|
|
7971
|
-
return ret; // not sorted
|
|
7972
|
-
function decode(Q) { // characters that lead into this node
|
|
7973
|
-
let S = next(); // state: valid, save, check
|
|
7974
|
-
let B = read_array_while(() => { // buckets leading to new nodes
|
|
7975
|
-
let cps = read_sorted(next).map(i => sorted[i]);
|
|
7976
|
-
if (cps.length) return decode(cps);
|
|
7977
|
-
});
|
|
7978
|
-
return {S, B, Q};
|
|
7979
|
-
}
|
|
7980
|
-
function expand({S, B}, cps, saved) {
|
|
7981
|
-
if (S & 4 && saved === cps[cps.length-1]) return;
|
|
7982
|
-
if (S & 2) saved = cps[cps.length-1];
|
|
7983
|
-
if (S & 1) ret.push(cps);
|
|
7984
|
-
for (let br of B) {
|
|
7985
|
-
for (let cp of br.Q) {
|
|
7986
|
-
expand(br, [...cps, cp], saved);
|
|
7987
|
-
}
|
|
7988
|
-
}
|
|
7989
|
-
}
|
|
7990
|
-
}
|
|
7991
|
-
|
|
7992
|
-
function hex_cp(cp) {
|
|
7993
|
-
return cp.toString(16).toUpperCase().padStart(2, '0');
|
|
7994
|
-
}
|
|
7995
|
-
|
|
7996
|
-
function quote_cp(cp) {
|
|
7997
|
-
return `{${hex_cp(cp)}}`; // raffy convention: like "\u{X}" w/o the "\u"
|
|
7998
|
-
}
|
|
7999
|
-
|
|
8000
|
-
/*
|
|
8001
|
-
export function explode_cp(s) {
|
|
8002
|
-
return [...s].map(c => c.codePointAt(0));
|
|
8003
|
-
}
|
|
8004
|
-
*/
|
|
8005
|
-
function explode_cp(s) { // this is about 2x faster
|
|
8006
|
-
let cps = [];
|
|
8007
|
-
for (let pos = 0, len = s.length; pos < len; ) {
|
|
8008
|
-
let cp = s.codePointAt(pos);
|
|
8009
|
-
pos += cp < 0x10000 ? 1 : 2;
|
|
8010
|
-
cps.push(cp);
|
|
8011
|
-
}
|
|
8012
|
-
return cps;
|
|
8013
|
-
}
|
|
8014
|
-
|
|
8015
|
-
function str_from_cps(cps) {
|
|
8016
|
-
const chunk = 4096;
|
|
8017
|
-
let len = cps.length;
|
|
8018
|
-
if (len < chunk) return String.fromCodePoint(...cps);
|
|
8019
|
-
let buf = [];
|
|
8020
|
-
for (let i = 0; i < len; ) {
|
|
8021
|
-
buf.push(String.fromCodePoint(...cps.slice(i, i += chunk)));
|
|
8022
|
-
}
|
|
8023
|
-
return buf.join('');
|
|
8024
|
-
}
|
|
8025
|
-
|
|
8026
|
-
function compare_arrays(a, b) {
|
|
8027
|
-
let n = a.length;
|
|
8028
|
-
let c = n - b.length;
|
|
8029
|
-
for (let i = 0; c == 0 && i < n; i++) c = a[i] - b[i];
|
|
8030
|
-
return c;
|
|
7788
|
+
function hex_cp(cp) {
|
|
7789
|
+
return cp.toString(16).toUpperCase().padStart(2, '0');
|
|
7790
|
+
}
|
|
7791
|
+
|
|
7792
|
+
function quote_cp(cp) {
|
|
7793
|
+
return `{${hex_cp(cp)}}`; // raffy convention: like "\u{X}" w/o the "\u"
|
|
7794
|
+
}
|
|
7795
|
+
|
|
7796
|
+
/*
|
|
7797
|
+
export function explode_cp(s) {
|
|
7798
|
+
return [...s].map(c => c.codePointAt(0));
|
|
7799
|
+
}
|
|
7800
|
+
*/
|
|
7801
|
+
function explode_cp(s) { // this is about 2x faster
|
|
7802
|
+
let cps = [];
|
|
7803
|
+
for (let pos = 0, len = s.length; pos < len; ) {
|
|
7804
|
+
let cp = s.codePointAt(pos);
|
|
7805
|
+
pos += cp < 0x10000 ? 1 : 2;
|
|
7806
|
+
cps.push(cp);
|
|
7807
|
+
}
|
|
7808
|
+
return cps;
|
|
7809
|
+
}
|
|
7810
|
+
|
|
7811
|
+
function str_from_cps(cps) {
|
|
7812
|
+
const chunk = 4096;
|
|
7813
|
+
let len = cps.length;
|
|
7814
|
+
if (len < chunk) return String.fromCodePoint(...cps);
|
|
7815
|
+
let buf = [];
|
|
7816
|
+
for (let i = 0; i < len; ) {
|
|
7817
|
+
buf.push(String.fromCodePoint(...cps.slice(i, i += chunk)));
|
|
7818
|
+
}
|
|
7819
|
+
return buf.join('');
|
|
7820
|
+
}
|
|
7821
|
+
|
|
7822
|
+
function compare_arrays(a, b) {
|
|
7823
|
+
let n = a.length;
|
|
7824
|
+
let c = n - b.length;
|
|
7825
|
+
for (let i = 0; c == 0 && i < n; i++) c = a[i] - b[i];
|
|
7826
|
+
return c;
|
|
8031
7827
|
}
|
|
8032
7828
|
|
|
8033
7829
|
// created 2023-09-25T01:01:55.148Z
|
|
@@ -8037,786 +7833,786 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
8037
7833
|
// SHA-256: a974b6f8541fc29d919bc85118af0a44015851fab5343f8679cb31be2bdb209e
|
|
8038
7834
|
var COMPRESSED = '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';
|
|
8039
7835
|
|
|
8040
|
-
// https://unicode.org/reports/tr15/
|
|
8041
|
-
// for reference implementation
|
|
8042
|
-
// see: /derive/nf.js
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
// algorithmic hangul
|
|
8046
|
-
// https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf (page 144)
|
|
8047
|
-
const S0 = 0xAC00;
|
|
8048
|
-
const L0 = 0x1100;
|
|
8049
|
-
const V0 = 0x1161;
|
|
8050
|
-
const T0 = 0x11A7;
|
|
8051
|
-
const L_COUNT = 19;
|
|
8052
|
-
const V_COUNT = 21;
|
|
8053
|
-
const T_COUNT = 28;
|
|
8054
|
-
const N_COUNT = V_COUNT * T_COUNT;
|
|
8055
|
-
const S_COUNT = L_COUNT * N_COUNT;
|
|
8056
|
-
const S1 = S0 + S_COUNT;
|
|
8057
|
-
const L1 = L0 + L_COUNT;
|
|
8058
|
-
const V1 = V0 + V_COUNT;
|
|
8059
|
-
const T1 = T0 + T_COUNT;
|
|
8060
|
-
|
|
8061
|
-
function unpack_cc(packed) {
|
|
8062
|
-
return (packed >> 24) & 0xFF;
|
|
8063
|
-
}
|
|
8064
|
-
function unpack_cp(packed) {
|
|
8065
|
-
return packed & 0xFFFFFF;
|
|
8066
|
-
}
|
|
8067
|
-
|
|
8068
|
-
let SHIFTED_RANK, EXCLUSIONS, DECOMP, RECOMP;
|
|
8069
|
-
|
|
8070
|
-
function init$1() {
|
|
8071
|
-
//console.time('nf');
|
|
8072
|
-
let r = read_compressed_payload(COMPRESSED);
|
|
8073
|
-
SHIFTED_RANK = new Map(read_sorted_arrays(r).flatMap((v, i) => v.map(x => [x, (i+1) << 24]))); // pre-shifted
|
|
8074
|
-
EXCLUSIONS = new Set(read_sorted(r));
|
|
8075
|
-
DECOMP = new Map();
|
|
8076
|
-
RECOMP = new Map();
|
|
8077
|
-
for (let [cp, cps] of read_mapped(r)) {
|
|
8078
|
-
if (!EXCLUSIONS.has(cp) && cps.length == 2) {
|
|
8079
|
-
let [a, b] = cps;
|
|
8080
|
-
let bucket = RECOMP.get(a);
|
|
8081
|
-
if (!bucket) {
|
|
8082
|
-
bucket = new Map();
|
|
8083
|
-
RECOMP.set(a, bucket);
|
|
8084
|
-
}
|
|
8085
|
-
bucket.set(b, cp);
|
|
8086
|
-
}
|
|
8087
|
-
DECOMP.set(cp, cps.reverse()); // stored reversed
|
|
8088
|
-
}
|
|
8089
|
-
//console.timeEnd('nf');
|
|
8090
|
-
// 20230905: 11ms
|
|
8091
|
-
}
|
|
8092
|
-
|
|
8093
|
-
function is_hangul(cp) {
|
|
8094
|
-
return cp >= S0 && cp < S1;
|
|
8095
|
-
}
|
|
8096
|
-
|
|
8097
|
-
function compose_pair(a, b) {
|
|
8098
|
-
if (a >= L0 && a < L1 && b >= V0 && b < V1) {
|
|
8099
|
-
return S0 + (a - L0) * N_COUNT + (b - V0) * T_COUNT;
|
|
8100
|
-
} else if (is_hangul(a) && b > T0 && b < T1 && (a - S0) % T_COUNT == 0) {
|
|
8101
|
-
return a + (b - T0);
|
|
8102
|
-
} else {
|
|
8103
|
-
let recomp = RECOMP.get(a);
|
|
8104
|
-
if (recomp) {
|
|
8105
|
-
recomp = recomp.get(b);
|
|
8106
|
-
if (recomp) {
|
|
8107
|
-
return recomp;
|
|
8108
|
-
}
|
|
8109
|
-
}
|
|
8110
|
-
return -1;
|
|
8111
|
-
}
|
|
7836
|
+
// https://unicode.org/reports/tr15/
|
|
7837
|
+
// for reference implementation
|
|
7838
|
+
// see: /derive/nf.js
|
|
7839
|
+
|
|
7840
|
+
|
|
7841
|
+
// algorithmic hangul
|
|
7842
|
+
// https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf (page 144)
|
|
7843
|
+
const S0 = 0xAC00;
|
|
7844
|
+
const L0 = 0x1100;
|
|
7845
|
+
const V0 = 0x1161;
|
|
7846
|
+
const T0 = 0x11A7;
|
|
7847
|
+
const L_COUNT = 19;
|
|
7848
|
+
const V_COUNT = 21;
|
|
7849
|
+
const T_COUNT = 28;
|
|
7850
|
+
const N_COUNT = V_COUNT * T_COUNT;
|
|
7851
|
+
const S_COUNT = L_COUNT * N_COUNT;
|
|
7852
|
+
const S1 = S0 + S_COUNT;
|
|
7853
|
+
const L1 = L0 + L_COUNT;
|
|
7854
|
+
const V1 = V0 + V_COUNT;
|
|
7855
|
+
const T1 = T0 + T_COUNT;
|
|
7856
|
+
|
|
7857
|
+
function unpack_cc(packed) {
|
|
7858
|
+
return (packed >> 24) & 0xFF;
|
|
7859
|
+
}
|
|
7860
|
+
function unpack_cp(packed) {
|
|
7861
|
+
return packed & 0xFFFFFF;
|
|
7862
|
+
}
|
|
7863
|
+
|
|
7864
|
+
let SHIFTED_RANK, EXCLUSIONS, DECOMP, RECOMP;
|
|
7865
|
+
|
|
7866
|
+
function init$1() {
|
|
7867
|
+
//console.time('nf');
|
|
7868
|
+
let r = read_compressed_payload(COMPRESSED);
|
|
7869
|
+
SHIFTED_RANK = new Map(read_sorted_arrays(r).flatMap((v, i) => v.map(x => [x, (i+1) << 24]))); // pre-shifted
|
|
7870
|
+
EXCLUSIONS = new Set(read_sorted(r));
|
|
7871
|
+
DECOMP = new Map();
|
|
7872
|
+
RECOMP = new Map();
|
|
7873
|
+
for (let [cp, cps] of read_mapped(r)) {
|
|
7874
|
+
if (!EXCLUSIONS.has(cp) && cps.length == 2) {
|
|
7875
|
+
let [a, b] = cps;
|
|
7876
|
+
let bucket = RECOMP.get(a);
|
|
7877
|
+
if (!bucket) {
|
|
7878
|
+
bucket = new Map();
|
|
7879
|
+
RECOMP.set(a, bucket);
|
|
7880
|
+
}
|
|
7881
|
+
bucket.set(b, cp);
|
|
7882
|
+
}
|
|
7883
|
+
DECOMP.set(cp, cps.reverse()); // stored reversed
|
|
7884
|
+
}
|
|
7885
|
+
//console.timeEnd('nf');
|
|
7886
|
+
// 20230905: 11ms
|
|
7887
|
+
}
|
|
7888
|
+
|
|
7889
|
+
function is_hangul(cp) {
|
|
7890
|
+
return cp >= S0 && cp < S1;
|
|
7891
|
+
}
|
|
7892
|
+
|
|
7893
|
+
function compose_pair(a, b) {
|
|
7894
|
+
if (a >= L0 && a < L1 && b >= V0 && b < V1) {
|
|
7895
|
+
return S0 + (a - L0) * N_COUNT + (b - V0) * T_COUNT;
|
|
7896
|
+
} else if (is_hangul(a) && b > T0 && b < T1 && (a - S0) % T_COUNT == 0) {
|
|
7897
|
+
return a + (b - T0);
|
|
7898
|
+
} else {
|
|
7899
|
+
let recomp = RECOMP.get(a);
|
|
7900
|
+
if (recomp) {
|
|
7901
|
+
recomp = recomp.get(b);
|
|
7902
|
+
if (recomp) {
|
|
7903
|
+
return recomp;
|
|
7904
|
+
}
|
|
7905
|
+
}
|
|
7906
|
+
return -1;
|
|
7907
|
+
}
|
|
7908
|
+
}
|
|
7909
|
+
|
|
7910
|
+
function decomposed(cps) {
|
|
7911
|
+
if (!SHIFTED_RANK) init$1();
|
|
7912
|
+
let ret = [];
|
|
7913
|
+
let buf = [];
|
|
7914
|
+
let check_order = false;
|
|
7915
|
+
function add(cp) {
|
|
7916
|
+
let cc = SHIFTED_RANK.get(cp);
|
|
7917
|
+
if (cc) {
|
|
7918
|
+
check_order = true;
|
|
7919
|
+
cp |= cc;
|
|
7920
|
+
}
|
|
7921
|
+
ret.push(cp);
|
|
7922
|
+
}
|
|
7923
|
+
for (let cp of cps) {
|
|
7924
|
+
while (true) {
|
|
7925
|
+
if (cp < 0x80) {
|
|
7926
|
+
ret.push(cp);
|
|
7927
|
+
} else if (is_hangul(cp)) {
|
|
7928
|
+
let s_index = cp - S0;
|
|
7929
|
+
let l_index = s_index / N_COUNT | 0;
|
|
7930
|
+
let v_index = (s_index % N_COUNT) / T_COUNT | 0;
|
|
7931
|
+
let t_index = s_index % T_COUNT;
|
|
7932
|
+
add(L0 + l_index);
|
|
7933
|
+
add(V0 + v_index);
|
|
7934
|
+
if (t_index > 0) add(T0 + t_index);
|
|
7935
|
+
} else {
|
|
7936
|
+
let mapped = DECOMP.get(cp);
|
|
7937
|
+
if (mapped) {
|
|
7938
|
+
buf.push(...mapped);
|
|
7939
|
+
} else {
|
|
7940
|
+
add(cp);
|
|
7941
|
+
}
|
|
7942
|
+
}
|
|
7943
|
+
if (!buf.length) break;
|
|
7944
|
+
cp = buf.pop();
|
|
7945
|
+
}
|
|
7946
|
+
}
|
|
7947
|
+
if (check_order && ret.length > 1) {
|
|
7948
|
+
let prev_cc = unpack_cc(ret[0]);
|
|
7949
|
+
for (let i = 1; i < ret.length; i++) {
|
|
7950
|
+
let cc = unpack_cc(ret[i]);
|
|
7951
|
+
if (cc == 0 || prev_cc <= cc) {
|
|
7952
|
+
prev_cc = cc;
|
|
7953
|
+
continue;
|
|
7954
|
+
}
|
|
7955
|
+
let j = i-1;
|
|
7956
|
+
while (true) {
|
|
7957
|
+
let tmp = ret[j+1];
|
|
7958
|
+
ret[j+1] = ret[j];
|
|
7959
|
+
ret[j] = tmp;
|
|
7960
|
+
if (!j) break;
|
|
7961
|
+
prev_cc = unpack_cc(ret[--j]);
|
|
7962
|
+
if (prev_cc <= cc) break;
|
|
7963
|
+
}
|
|
7964
|
+
prev_cc = unpack_cc(ret[i]);
|
|
7965
|
+
}
|
|
7966
|
+
}
|
|
7967
|
+
return ret;
|
|
7968
|
+
}
|
|
7969
|
+
|
|
7970
|
+
function composed_from_decomposed(v) {
|
|
7971
|
+
let ret = [];
|
|
7972
|
+
let stack = [];
|
|
7973
|
+
let prev_cp = -1;
|
|
7974
|
+
let prev_cc = 0;
|
|
7975
|
+
for (let packed of v) {
|
|
7976
|
+
let cc = unpack_cc(packed);
|
|
7977
|
+
let cp = unpack_cp(packed);
|
|
7978
|
+
if (prev_cp == -1) {
|
|
7979
|
+
if (cc == 0) {
|
|
7980
|
+
prev_cp = cp;
|
|
7981
|
+
} else {
|
|
7982
|
+
ret.push(cp);
|
|
7983
|
+
}
|
|
7984
|
+
} else if (prev_cc > 0 && prev_cc >= cc) {
|
|
7985
|
+
if (cc == 0) {
|
|
7986
|
+
ret.push(prev_cp, ...stack);
|
|
7987
|
+
stack.length = 0;
|
|
7988
|
+
prev_cp = cp;
|
|
7989
|
+
} else {
|
|
7990
|
+
stack.push(cp);
|
|
7991
|
+
}
|
|
7992
|
+
prev_cc = cc;
|
|
7993
|
+
} else {
|
|
7994
|
+
let composed = compose_pair(prev_cp, cp);
|
|
7995
|
+
if (composed >= 0) {
|
|
7996
|
+
prev_cp = composed;
|
|
7997
|
+
} else if (prev_cc == 0 && cc == 0) {
|
|
7998
|
+
ret.push(prev_cp);
|
|
7999
|
+
prev_cp = cp;
|
|
8000
|
+
} else {
|
|
8001
|
+
stack.push(cp);
|
|
8002
|
+
prev_cc = cc;
|
|
8003
|
+
}
|
|
8004
|
+
}
|
|
8005
|
+
}
|
|
8006
|
+
if (prev_cp >= 0) {
|
|
8007
|
+
ret.push(prev_cp, ...stack);
|
|
8008
|
+
}
|
|
8009
|
+
return ret;
|
|
8010
|
+
}
|
|
8011
|
+
|
|
8012
|
+
// note: cps can be iterable
|
|
8013
|
+
function nfd(cps) {
|
|
8014
|
+
return decomposed(cps).map(unpack_cp);
|
|
8015
|
+
}
|
|
8016
|
+
function nfc(cps) {
|
|
8017
|
+
return composed_from_decomposed(decomposed(cps));
|
|
8112
8018
|
}
|
|
8113
8019
|
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
}
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
//
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
if (
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
function
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
let
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
//
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
if (
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
let cp = cps[i++];
|
|
8711
|
-
let seqs = cm_whitelist && M.get(cp);
|
|
8712
|
-
if (seqs) {
|
|
8713
|
-
// list of codepoints that can follow
|
|
8714
|
-
// if this exists, this will always be 1+
|
|
8715
|
-
let j = i;
|
|
8716
|
-
while (j < e && CM.has(cps[j])) j++;
|
|
8717
|
-
let cms = cps.slice(i, j);
|
|
8718
|
-
let match = seqs.find(seq => !compare_arrays(seq, cms));
|
|
8719
|
-
if (!match) throw new Error(`disallowed combining mark sequence: "${safe_str_from_cps([cp, ...cms])}"`);
|
|
8720
|
-
i = j;
|
|
8721
|
-
} else if (!V.has(cp)) {
|
|
8722
|
-
// https://www.unicode.org/reports/tr39/#mixed_script_confusables
|
|
8723
|
-
let quoted = quoted_cp(cp);
|
|
8724
|
-
for (let cp of cps) {
|
|
8725
|
-
let u = UNIQUE.get(cp);
|
|
8726
|
-
if (u && u !== g) {
|
|
8727
|
-
// if both scripts are restricted this error is confusing
|
|
8728
|
-
// because we don't differentiate RestrictedA from RestrictedB
|
|
8729
|
-
if (!u.R) quoted = `${quoted} is ${u.N}`;
|
|
8730
|
-
break;
|
|
8731
|
-
}
|
|
8732
|
-
}
|
|
8733
|
-
throw new Error(`disallowed ${g.N} character: ${quoted}`);
|
|
8734
|
-
//throw new Error(`disallowed character: ${quoted} (expected ${g.N})`);
|
|
8735
|
-
//throw new Error(`${g.N} does not allow: ${quoted}`);
|
|
8736
|
-
}
|
|
8737
|
-
}
|
|
8738
|
-
if (!cm_whitelist) {
|
|
8739
|
-
let decomposed = nfd(cps);
|
|
8740
|
-
for (let i = 1, e = decomposed.length; i < e; i++) { // we know it can't be cm leading
|
|
8741
|
-
if (CM.has(decomposed[i])) {
|
|
8742
|
-
let j = i + 1;
|
|
8743
|
-
while (j < e && CM.has(decomposed[j])) j++;
|
|
8744
|
-
if (j - i > M) {
|
|
8745
|
-
throw new Error(`too many combining marks: "${str_from_cps(decomposed.slice(i-1, j))}" (${j-i}/${M})`);
|
|
8746
|
-
}
|
|
8747
|
-
i = j;
|
|
8748
|
-
}
|
|
8749
|
-
}
|
|
8750
|
-
}
|
|
8751
|
-
*/
|
|
8752
|
-
}
|
|
8753
|
-
|
|
8754
|
-
// given a list of codepoints
|
|
8755
|
-
// returns a list of lists, where emoji are a fully-qualified (as Array subclass)
|
|
8756
|
-
// eg. explode_cp("abc💩d") => [[61, 62, 63], Emoji[1F4A9, FE0F], [64]]
|
|
8757
|
-
// 20230818: rename for 'process' name collision h/t Javarome
|
|
8758
|
-
// https://github.com/adraffy/ens-normalize.js/issues/23
|
|
8759
|
-
function tokens_from_str(input, nf, ef) {
|
|
8760
|
-
let ret = [];
|
|
8761
|
-
let chars = [];
|
|
8762
|
-
input = input.slice().reverse(); // flip so we can pop
|
|
8763
|
-
while (input.length) {
|
|
8764
|
-
let emoji = consume_emoji_reversed(input);
|
|
8765
|
-
if (emoji) {
|
|
8766
|
-
if (chars.length) {
|
|
8767
|
-
ret.push(nf(chars));
|
|
8768
|
-
chars = [];
|
|
8769
|
-
}
|
|
8770
|
-
ret.push(ef(emoji));
|
|
8771
|
-
} else {
|
|
8772
|
-
let cp = input.pop();
|
|
8773
|
-
if (VALID.has(cp)) {
|
|
8774
|
-
chars.push(cp);
|
|
8775
|
-
} else {
|
|
8776
|
-
let cps = MAPPED.get(cp);
|
|
8777
|
-
if (cps) {
|
|
8778
|
-
chars.push(...cps); // less than 10 elements
|
|
8779
|
-
} else if (!IGNORED.has(cp)) {
|
|
8780
|
-
// 20230912: unicode 15.1 changed the order of processing such that
|
|
8781
|
-
// disallowed parts are only rejected after NFC
|
|
8782
|
-
// https://unicode.org/reports/tr46/#Validity_Criteria
|
|
8783
|
-
// this doesn't impact normalization as of today
|
|
8784
|
-
// technically, this error can be removed as the group logic will apply similar logic
|
|
8785
|
-
// however the error type might be less clear
|
|
8786
|
-
throw error_disallowed(cp);
|
|
8787
|
-
}
|
|
8788
|
-
}
|
|
8789
|
-
}
|
|
8790
|
-
}
|
|
8791
|
-
if (chars.length) {
|
|
8792
|
-
ret.push(nf(chars));
|
|
8793
|
-
}
|
|
8794
|
-
return ret;
|
|
8795
|
-
}
|
|
8796
|
-
|
|
8797
|
-
function filter_fe0f(cps) {
|
|
8798
|
-
return cps.filter(cp => cp != FE0F);
|
|
8799
|
-
}
|
|
8800
|
-
|
|
8801
|
-
// given array of codepoints
|
|
8802
|
-
// returns the longest valid emoji sequence (or undefined if no match)
|
|
8803
|
-
// *MUTATES* the supplied array
|
|
8804
|
-
// disallows interleaved ignored characters
|
|
8805
|
-
// fills (optional) eaten array with matched codepoints
|
|
8806
|
-
function consume_emoji_reversed(cps, eaten) {
|
|
8807
|
-
let node = EMOJI_ROOT;
|
|
8808
|
-
let emoji;
|
|
8809
|
-
let pos = cps.length;
|
|
8810
|
-
while (pos) {
|
|
8811
|
-
node = node.get(cps[--pos]);
|
|
8812
|
-
if (!node) break;
|
|
8813
|
-
let {V} = node;
|
|
8814
|
-
if (V) { // this is a valid emoji (so far)
|
|
8815
|
-
emoji = V;
|
|
8816
|
-
cps.length = pos; // truncate
|
|
8817
|
-
}
|
|
8818
|
-
}
|
|
8819
|
-
return emoji;
|
|
8020
|
+
const HYPHEN = 0x2D;
|
|
8021
|
+
const STOP_CH = '.';
|
|
8022
|
+
const FE0F = 0xFE0F;
|
|
8023
|
+
const UNIQUE_PH = 1;
|
|
8024
|
+
|
|
8025
|
+
// 20230913: replace [...v] with Array_from(v) to avoid large spreads
|
|
8026
|
+
const Array_from = x => Array.from(x); // Array.from.bind(Array);
|
|
8027
|
+
|
|
8028
|
+
function group_has_cp(g, cp) {
|
|
8029
|
+
// 20230913: keep primary and secondary distinct instead of creating valid union
|
|
8030
|
+
return g.P.has(cp) || g.Q.has(cp);
|
|
8031
|
+
}
|
|
8032
|
+
|
|
8033
|
+
class Emoji extends Array {
|
|
8034
|
+
get is_emoji() { return true; } // free tagging system
|
|
8035
|
+
}
|
|
8036
|
+
|
|
8037
|
+
let MAPPED, IGNORED, CM, NSM, ESCAPE, GROUPS, WHOLE_VALID, WHOLE_MAP, VALID, EMOJI_LIST, EMOJI_ROOT;
|
|
8038
|
+
|
|
8039
|
+
function init() {
|
|
8040
|
+
if (MAPPED) return;
|
|
8041
|
+
|
|
8042
|
+
let r = read_compressed_payload(COMPRESSED$1);
|
|
8043
|
+
const read_sorted_array = () => read_sorted(r);
|
|
8044
|
+
const read_sorted_set = () => new Set(read_sorted_array());
|
|
8045
|
+
const set_add_many = (set, v) => v.forEach(x => set.add(x));
|
|
8046
|
+
|
|
8047
|
+
MAPPED = new Map(read_mapped(r));
|
|
8048
|
+
IGNORED = read_sorted_set(); // ignored characters are not valid, so just read raw codepoints
|
|
8049
|
+
|
|
8050
|
+
/*
|
|
8051
|
+
// direct include from payload is smaller than the decompression code
|
|
8052
|
+
const FENCED = new Map(read_array_while(() => {
|
|
8053
|
+
let cp = r();
|
|
8054
|
+
if (cp) return [cp, read_str(r())];
|
|
8055
|
+
}));
|
|
8056
|
+
*/
|
|
8057
|
+
// 20230217: we still need all CM for proper error formatting
|
|
8058
|
+
// but norm only needs NSM subset that are potentially-valid
|
|
8059
|
+
CM = read_sorted_array();
|
|
8060
|
+
NSM = new Set(read_sorted_array().map(i => CM[i]));
|
|
8061
|
+
CM = new Set(CM);
|
|
8062
|
+
|
|
8063
|
+
ESCAPE = read_sorted_set(); // characters that should not be printed
|
|
8064
|
+
read_sorted_set(); // only needed to illustrate ens_tokenize() transformations
|
|
8065
|
+
|
|
8066
|
+
let chunks = read_sorted_arrays(r);
|
|
8067
|
+
let unrestricted = r();
|
|
8068
|
+
//const read_chunked = () => new Set(read_sorted_array().flatMap(i => chunks[i]).concat(read_sorted_array()));
|
|
8069
|
+
const read_chunked = () => {
|
|
8070
|
+
// 20230921: build set in parts, 2x faster
|
|
8071
|
+
let set = new Set();
|
|
8072
|
+
read_sorted_array().forEach(i => set_add_many(set, chunks[i]));
|
|
8073
|
+
set_add_many(set, read_sorted_array());
|
|
8074
|
+
return set;
|
|
8075
|
+
};
|
|
8076
|
+
GROUPS = read_array_while(i => {
|
|
8077
|
+
// minifier property mangling seems unsafe
|
|
8078
|
+
// so these are manually renamed to single chars
|
|
8079
|
+
let N = read_array_while(r).map(x => x+0x60);
|
|
8080
|
+
if (N.length) {
|
|
8081
|
+
let R = i >= unrestricted; // unrestricted then restricted
|
|
8082
|
+
N[0] -= 32; // capitalize
|
|
8083
|
+
N = str_from_cps(N);
|
|
8084
|
+
if (R) N=`Restricted[${N}]`;
|
|
8085
|
+
let P = read_chunked(); // primary
|
|
8086
|
+
let Q = read_chunked(); // secondary
|
|
8087
|
+
let M = !r(); // not-whitelisted, check for NSM
|
|
8088
|
+
// *** this code currently isn't needed ***
|
|
8089
|
+
/*
|
|
8090
|
+
let V = [...P, ...Q].sort((a, b) => a-b); // derive: sorted valid
|
|
8091
|
+
let M = r()-1; // number of combining mark
|
|
8092
|
+
if (M < 0) { // whitelisted
|
|
8093
|
+
M = new Map(read_array_while(() => {
|
|
8094
|
+
let i = r();
|
|
8095
|
+
if (i) return [V[i-1], read_array_while(() => {
|
|
8096
|
+
let v = read_array_while(r);
|
|
8097
|
+
if (v.length) return v.map(x => x-1);
|
|
8098
|
+
})];
|
|
8099
|
+
}));
|
|
8100
|
+
}*/
|
|
8101
|
+
return {N, P, Q, M, R};
|
|
8102
|
+
}
|
|
8103
|
+
});
|
|
8104
|
+
|
|
8105
|
+
// decode compressed wholes
|
|
8106
|
+
WHOLE_VALID = read_sorted_set();
|
|
8107
|
+
WHOLE_MAP = new Map();
|
|
8108
|
+
let wholes = read_sorted_array().concat(Array_from(WHOLE_VALID)).sort((a, b) => a-b); // must be sorted
|
|
8109
|
+
wholes.forEach((cp, i) => {
|
|
8110
|
+
let d = r();
|
|
8111
|
+
let w = wholes[i] = d ? wholes[i-d] : {V: [], M: new Map()};
|
|
8112
|
+
w.V.push(cp); // add to member set
|
|
8113
|
+
if (!WHOLE_VALID.has(cp)) {
|
|
8114
|
+
WHOLE_MAP.set(cp, w); // register with whole map
|
|
8115
|
+
}
|
|
8116
|
+
});
|
|
8117
|
+
|
|
8118
|
+
// compute confusable-extent complements
|
|
8119
|
+
// usage: WHOLE_MAP.get(cp).M.get(cp) = complement set
|
|
8120
|
+
for (let {V, M} of new Set(WHOLE_MAP.values())) {
|
|
8121
|
+
// connect all groups that have each whole character
|
|
8122
|
+
let recs = [];
|
|
8123
|
+
for (let cp of V) {
|
|
8124
|
+
let gs = GROUPS.filter(g => group_has_cp(g, cp));
|
|
8125
|
+
let rec = recs.find(({G}) => gs.some(g => G.has(g)));
|
|
8126
|
+
if (!rec) {
|
|
8127
|
+
rec = {G: new Set(), V: []};
|
|
8128
|
+
recs.push(rec);
|
|
8129
|
+
}
|
|
8130
|
+
rec.V.push(cp);
|
|
8131
|
+
set_add_many(rec.G, gs);
|
|
8132
|
+
}
|
|
8133
|
+
// per character cache groups which are not a member of the extent
|
|
8134
|
+
let union = recs.flatMap(x => Array_from(x.G)); // all of the groups used by this whole
|
|
8135
|
+
for (let {G, V} of recs) {
|
|
8136
|
+
let complement = new Set(union.filter(g => !G.has(g))); // groups not covered by the extent
|
|
8137
|
+
for (let cp of V) {
|
|
8138
|
+
M.set(cp, complement); // this is the same reference
|
|
8139
|
+
}
|
|
8140
|
+
}
|
|
8141
|
+
}
|
|
8142
|
+
|
|
8143
|
+
// compute valid set
|
|
8144
|
+
// 20230924: VALID was union but can be re-used
|
|
8145
|
+
VALID = new Set(); // exists in 1+ groups
|
|
8146
|
+
let multi = new Set(); // exists in 2+ groups
|
|
8147
|
+
const add_to_union = cp => VALID.has(cp) ? multi.add(cp) : VALID.add(cp);
|
|
8148
|
+
for (let g of GROUPS) {
|
|
8149
|
+
for (let cp of g.P) add_to_union(cp);
|
|
8150
|
+
for (let cp of g.Q) add_to_union(cp);
|
|
8151
|
+
}
|
|
8152
|
+
// dual purpose WHOLE_MAP: return placeholder if unique non-confusable
|
|
8153
|
+
for (let cp of VALID) {
|
|
8154
|
+
if (!WHOLE_MAP.has(cp) && !multi.has(cp)) {
|
|
8155
|
+
WHOLE_MAP.set(cp, UNIQUE_PH);
|
|
8156
|
+
}
|
|
8157
|
+
}
|
|
8158
|
+
// add all decomposed parts
|
|
8159
|
+
// see derive: "Valid is Closed (via Brute-force)"
|
|
8160
|
+
set_add_many(VALID, nfd(VALID));
|
|
8161
|
+
|
|
8162
|
+
// decode emoji
|
|
8163
|
+
// 20230719: emoji are now fully-expanded to avoid quirk logic
|
|
8164
|
+
EMOJI_LIST = read_trie(r).map(v => Emoji.from(v)).sort(compare_arrays);
|
|
8165
|
+
EMOJI_ROOT = new Map(); // this has approx 7K nodes (2+ per emoji)
|
|
8166
|
+
for (let cps of EMOJI_LIST) {
|
|
8167
|
+
// 20230719: change to *slightly* stricter algorithm which disallows
|
|
8168
|
+
// insertion of misplaced FE0F in emoji sequences (matching ENSIP-15)
|
|
8169
|
+
// example: beautified [A B] (eg. flag emoji)
|
|
8170
|
+
// before: allow: [A FE0F B], error: [A FE0F FE0F B]
|
|
8171
|
+
// after: error: both
|
|
8172
|
+
// note: this code now matches ENSNormalize.{cs,java} logic
|
|
8173
|
+
let prev = [EMOJI_ROOT];
|
|
8174
|
+
for (let cp of cps) {
|
|
8175
|
+
let next = prev.map(node => {
|
|
8176
|
+
let child = node.get(cp);
|
|
8177
|
+
if (!child) {
|
|
8178
|
+
// should this be object?
|
|
8179
|
+
// (most have 1-2 items, few have many)
|
|
8180
|
+
// 20230719: no, v8 default map is 4?
|
|
8181
|
+
child = new Map();
|
|
8182
|
+
node.set(cp, child);
|
|
8183
|
+
}
|
|
8184
|
+
return child;
|
|
8185
|
+
});
|
|
8186
|
+
if (cp === FE0F) {
|
|
8187
|
+
prev.push(...next); // less than 20 elements
|
|
8188
|
+
} else {
|
|
8189
|
+
prev = next;
|
|
8190
|
+
}
|
|
8191
|
+
}
|
|
8192
|
+
for (let x of prev) {
|
|
8193
|
+
x.V = cps;
|
|
8194
|
+
}
|
|
8195
|
+
}
|
|
8196
|
+
}
|
|
8197
|
+
|
|
8198
|
+
// if escaped: {HEX}
|
|
8199
|
+
// else: "x" {HEX}
|
|
8200
|
+
function quoted_cp(cp) {
|
|
8201
|
+
return (should_escape(cp) ? '' : `${bidi_qq(safe_str_from_cps([cp]))} `) + quote_cp(cp);
|
|
8202
|
+
}
|
|
8203
|
+
|
|
8204
|
+
// 20230211: some messages can be mixed-directional and result in spillover
|
|
8205
|
+
// use 200E after a quoted string to force the remainder of a string from
|
|
8206
|
+
// acquring the direction of the quote
|
|
8207
|
+
// https://www.w3.org/International/questions/qa-bidi-unicode-controls#exceptions
|
|
8208
|
+
function bidi_qq(s) {
|
|
8209
|
+
return `"${s}"\u200E`; // strong LTR
|
|
8210
|
+
}
|
|
8211
|
+
|
|
8212
|
+
function check_label_extension(cps) {
|
|
8213
|
+
if (cps.length >= 4 && cps[2] == HYPHEN && cps[3] == HYPHEN) {
|
|
8214
|
+
throw new Error(`invalid label extension: "${str_from_cps(cps.slice(0, 4))}"`); // this can only be ascii so cant be bidi
|
|
8215
|
+
}
|
|
8216
|
+
}
|
|
8217
|
+
function check_leading_underscore(cps) {
|
|
8218
|
+
const UNDERSCORE = 0x5F;
|
|
8219
|
+
for (let i = cps.lastIndexOf(UNDERSCORE); i > 0; ) {
|
|
8220
|
+
if (cps[--i] !== UNDERSCORE) {
|
|
8221
|
+
throw new Error('underscore allowed only at start');
|
|
8222
|
+
}
|
|
8223
|
+
}
|
|
8224
|
+
}
|
|
8225
|
+
// check that a fenced cp is not leading, trailing, or touching another fenced cp
|
|
8226
|
+
function check_fenced(cps) {
|
|
8227
|
+
let cp = cps[0];
|
|
8228
|
+
let prev = FENCED.get(cp);
|
|
8229
|
+
if (prev) throw error_placement(`leading ${prev}`);
|
|
8230
|
+
let n = cps.length;
|
|
8231
|
+
let last = -1; // prevents trailing from throwing
|
|
8232
|
+
for (let i = 1; i < n; i++) {
|
|
8233
|
+
cp = cps[i];
|
|
8234
|
+
let match = FENCED.get(cp);
|
|
8235
|
+
if (match) {
|
|
8236
|
+
// since cps[0] isn't fenced, cps[1] cannot throw
|
|
8237
|
+
if (last == i) throw error_placement(`${prev} + ${match}`);
|
|
8238
|
+
last = i + 1;
|
|
8239
|
+
prev = match;
|
|
8240
|
+
}
|
|
8241
|
+
}
|
|
8242
|
+
if (last == n) throw error_placement(`trailing ${prev}`);
|
|
8243
|
+
}
|
|
8244
|
+
|
|
8245
|
+
// create a safe to print string
|
|
8246
|
+
// invisibles are escaped
|
|
8247
|
+
// leading cm uses placeholder
|
|
8248
|
+
// if cps exceed max, middle truncate with ellipsis
|
|
8249
|
+
// quoter(cp) => string, eg. 3000 => "{3000}"
|
|
8250
|
+
// note: in html, you'd call this function then replace [<>&] with entities
|
|
8251
|
+
function safe_str_from_cps(cps, max = Infinity, quoter = quote_cp) {
|
|
8252
|
+
//if (Number.isInteger(cps)) cps = [cps];
|
|
8253
|
+
//if (!Array.isArray(cps)) throw new TypeError(`expected codepoints`);
|
|
8254
|
+
let buf = [];
|
|
8255
|
+
if (is_combining_mark(cps[0])) buf.push('◌');
|
|
8256
|
+
if (cps.length > max) {
|
|
8257
|
+
max >>= 1;
|
|
8258
|
+
cps = [...cps.slice(0, max), 0x2026, ...cps.slice(-max)];
|
|
8259
|
+
}
|
|
8260
|
+
let prev = 0;
|
|
8261
|
+
let n = cps.length;
|
|
8262
|
+
for (let i = 0; i < n; i++) {
|
|
8263
|
+
let cp = cps[i];
|
|
8264
|
+
if (should_escape(cp)) {
|
|
8265
|
+
buf.push(str_from_cps(cps.slice(prev, i)));
|
|
8266
|
+
buf.push(quoter(cp));
|
|
8267
|
+
prev = i + 1;
|
|
8268
|
+
}
|
|
8269
|
+
}
|
|
8270
|
+
buf.push(str_from_cps(cps.slice(prev, n)));
|
|
8271
|
+
return buf.join('');
|
|
8272
|
+
}
|
|
8273
|
+
|
|
8274
|
+
// note: set(s) cannot be exposed because they can be modified
|
|
8275
|
+
// note: Object.freeze() doesn't work
|
|
8276
|
+
function is_combining_mark(cp) {
|
|
8277
|
+
init();
|
|
8278
|
+
return CM.has(cp);
|
|
8279
|
+
}
|
|
8280
|
+
function should_escape(cp) {
|
|
8281
|
+
init();
|
|
8282
|
+
return ESCAPE.has(cp);
|
|
8283
|
+
}
|
|
8284
|
+
|
|
8285
|
+
function ens_normalize(name) {
|
|
8286
|
+
return flatten(split(name, nfc, filter_fe0f));
|
|
8287
|
+
}
|
|
8288
|
+
|
|
8289
|
+
function split(name, nf, ef) {
|
|
8290
|
+
if (!name) return []; // 20230719: empty name allowance
|
|
8291
|
+
init();
|
|
8292
|
+
let offset = 0;
|
|
8293
|
+
// https://unicode.org/reports/tr46/#Validity_Criteria
|
|
8294
|
+
// 4.) "The label must not contain a U+002E ( . ) FULL STOP."
|
|
8295
|
+
return name.split(STOP_CH).map(label => {
|
|
8296
|
+
let input = explode_cp(label);
|
|
8297
|
+
let info = {
|
|
8298
|
+
input,
|
|
8299
|
+
offset, // codepoint, not substring!
|
|
8300
|
+
};
|
|
8301
|
+
offset += input.length + 1; // + stop
|
|
8302
|
+
try {
|
|
8303
|
+
// 1.) "The label must be in Unicode Normalization Form NFC"
|
|
8304
|
+
let tokens = info.tokens = tokens_from_str(input, nf, ef);
|
|
8305
|
+
let token_count = tokens.length;
|
|
8306
|
+
let type;
|
|
8307
|
+
if (!token_count) { // the label was effectively empty (could of had ignored characters)
|
|
8308
|
+
//norm = [];
|
|
8309
|
+
//type = 'None'; // use this instead of next match, "ASCII"
|
|
8310
|
+
// 20230120: change to strict
|
|
8311
|
+
// https://discuss.ens.domains/t/ens-name-normalization-2nd/14564/59
|
|
8312
|
+
throw new Error(`empty label`);
|
|
8313
|
+
}
|
|
8314
|
+
let norm = info.output = tokens.flat();
|
|
8315
|
+
check_leading_underscore(norm);
|
|
8316
|
+
let emoji = info.emoji = token_count > 1 || tokens[0].is_emoji; // same as: tokens.some(x => x.is_emoji);
|
|
8317
|
+
if (!emoji && norm.every(cp => cp < 0x80)) { // special case for ascii
|
|
8318
|
+
// 20230123: matches matches WHATWG, see note 3.3
|
|
8319
|
+
check_label_extension(norm); // only needed for ascii
|
|
8320
|
+
// cant have fenced
|
|
8321
|
+
// cant have cm
|
|
8322
|
+
// cant have wholes
|
|
8323
|
+
// see derive: "Fastpath ASCII"
|
|
8324
|
+
type = 'ASCII';
|
|
8325
|
+
} else {
|
|
8326
|
+
let chars = tokens.flatMap(x => x.is_emoji ? [] : x); // all of the nfc tokens concat together
|
|
8327
|
+
if (!chars.length) { // theres no text, just emoji
|
|
8328
|
+
type = 'Emoji';
|
|
8329
|
+
} else {
|
|
8330
|
+
// 5.) "The label must not begin with a combining mark, that is: General_Category=Mark."
|
|
8331
|
+
if (CM.has(norm[0])) throw error_placement('leading combining mark');
|
|
8332
|
+
for (let i = 1; i < token_count; i++) { // we've already checked the first token
|
|
8333
|
+
let cps = tokens[i];
|
|
8334
|
+
if (!cps.is_emoji && CM.has(cps[0])) { // every text token has emoji neighbors, eg. EtEEEtEt...
|
|
8335
|
+
// bidi_qq() not needed since emoji is LTR and cps is a CM
|
|
8336
|
+
throw error_placement(`emoji + combining mark: "${str_from_cps(tokens[i-1])} + ${safe_str_from_cps([cps[0]])}"`);
|
|
8337
|
+
}
|
|
8338
|
+
}
|
|
8339
|
+
check_fenced(norm);
|
|
8340
|
+
let unique = Array_from(new Set(chars));
|
|
8341
|
+
let [g] = determine_group(unique); // take the first match
|
|
8342
|
+
// see derive: "Matching Groups have Same CM Style"
|
|
8343
|
+
// alternative: could form a hybrid type: Latin/Japanese/...
|
|
8344
|
+
check_group(g, chars); // need text in order
|
|
8345
|
+
check_whole(g, unique); // only need unique text (order would be required for multiple-char confusables)
|
|
8346
|
+
type = g.N;
|
|
8347
|
+
// 20230121: consider exposing restricted flag
|
|
8348
|
+
// it's simpler to just check for 'Restricted'
|
|
8349
|
+
// or even better: type.endsWith(']')
|
|
8350
|
+
//if (g.R) info.restricted = true;
|
|
8351
|
+
}
|
|
8352
|
+
}
|
|
8353
|
+
info.type = type;
|
|
8354
|
+
} catch (err) {
|
|
8355
|
+
info.error = err; // use full error object
|
|
8356
|
+
}
|
|
8357
|
+
return info;
|
|
8358
|
+
});
|
|
8359
|
+
}
|
|
8360
|
+
|
|
8361
|
+
function check_whole(group, unique) {
|
|
8362
|
+
let maker;
|
|
8363
|
+
let shared = [];
|
|
8364
|
+
for (let cp of unique) {
|
|
8365
|
+
let whole = WHOLE_MAP.get(cp);
|
|
8366
|
+
if (whole === UNIQUE_PH) return; // unique, non-confusable
|
|
8367
|
+
if (whole) {
|
|
8368
|
+
let set = whole.M.get(cp); // groups which have a character that look-like this character
|
|
8369
|
+
maker = maker ? maker.filter(g => set.has(g)) : Array_from(set);
|
|
8370
|
+
if (!maker.length) return; // confusable intersection is empty
|
|
8371
|
+
} else {
|
|
8372
|
+
shared.push(cp);
|
|
8373
|
+
}
|
|
8374
|
+
}
|
|
8375
|
+
if (maker) {
|
|
8376
|
+
// we have 1+ confusable
|
|
8377
|
+
// check if any of the remaining groups
|
|
8378
|
+
// contain the shared characters too
|
|
8379
|
+
for (let g of maker) {
|
|
8380
|
+
if (shared.every(cp => group_has_cp(g, cp))) {
|
|
8381
|
+
throw new Error(`whole-script confusable: ${group.N}/${g.N}`);
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
}
|
|
8385
|
+
}
|
|
8386
|
+
|
|
8387
|
+
// assumption: unique.size > 0
|
|
8388
|
+
// returns list of matching groups
|
|
8389
|
+
function determine_group(unique) {
|
|
8390
|
+
let groups = GROUPS;
|
|
8391
|
+
for (let cp of unique) {
|
|
8392
|
+
// note: we need to dodge CM that are whitelisted
|
|
8393
|
+
// but that code isn't currently necessary
|
|
8394
|
+
let gs = groups.filter(g => group_has_cp(g, cp));
|
|
8395
|
+
if (!gs.length) {
|
|
8396
|
+
if (!GROUPS.some(g => group_has_cp(g, cp))) {
|
|
8397
|
+
// the character was composed of valid parts
|
|
8398
|
+
// but it's NFC form is invalid
|
|
8399
|
+
// 20230716: change to more exact statement, see: ENSNormalize.{cs,java}
|
|
8400
|
+
// note: this doesn't have to be a composition
|
|
8401
|
+
// 20230720: change to full check
|
|
8402
|
+
throw error_disallowed(cp); // this should be rare
|
|
8403
|
+
} else {
|
|
8404
|
+
// there is no group that contains all these characters
|
|
8405
|
+
// throw using the highest priority group that matched
|
|
8406
|
+
// https://www.unicode.org/reports/tr39/#mixed_script_confusables
|
|
8407
|
+
throw error_group_member(groups[0], cp);
|
|
8408
|
+
}
|
|
8409
|
+
}
|
|
8410
|
+
groups = gs;
|
|
8411
|
+
if (gs.length == 1) break; // there is only one group left
|
|
8412
|
+
}
|
|
8413
|
+
// there are at least 1 group(s) with all of these characters
|
|
8414
|
+
return groups;
|
|
8415
|
+
}
|
|
8416
|
+
|
|
8417
|
+
// throw on first error
|
|
8418
|
+
function flatten(split) {
|
|
8419
|
+
return split.map(({input, error, output}) => {
|
|
8420
|
+
if (error) {
|
|
8421
|
+
// don't print label again if just a single label
|
|
8422
|
+
let msg = error.message;
|
|
8423
|
+
// bidi_qq() only necessary if msg is digits
|
|
8424
|
+
throw new Error(split.length == 1 ? msg : `Invalid label ${bidi_qq(safe_str_from_cps(input, 63))}: ${msg}`);
|
|
8425
|
+
}
|
|
8426
|
+
return str_from_cps(output);
|
|
8427
|
+
}).join(STOP_CH);
|
|
8428
|
+
}
|
|
8429
|
+
|
|
8430
|
+
function error_disallowed(cp) {
|
|
8431
|
+
// TODO: add cp to error?
|
|
8432
|
+
return new Error(`disallowed character: ${quoted_cp(cp)}`);
|
|
8433
|
+
}
|
|
8434
|
+
function error_group_member(g, cp) {
|
|
8435
|
+
let quoted = quoted_cp(cp);
|
|
8436
|
+
let gg = GROUPS.find(g => g.P.has(cp)); // only check primary
|
|
8437
|
+
if (gg) {
|
|
8438
|
+
quoted = `${gg.N} ${quoted}`;
|
|
8439
|
+
}
|
|
8440
|
+
return new Error(`illegal mixture: ${g.N} + ${quoted}`);
|
|
8441
|
+
}
|
|
8442
|
+
function error_placement(where) {
|
|
8443
|
+
return new Error(`illegal placement: ${where}`);
|
|
8444
|
+
}
|
|
8445
|
+
|
|
8446
|
+
// assumption: cps.length > 0
|
|
8447
|
+
// assumption: cps[0] isn't a CM
|
|
8448
|
+
// assumption: the previous character isn't an emoji
|
|
8449
|
+
function check_group(g, cps) {
|
|
8450
|
+
for (let cp of cps) {
|
|
8451
|
+
if (!group_has_cp(g, cp)) {
|
|
8452
|
+
// for whitelisted scripts, this will throw illegal mixture on invalid cm, eg. "e{300}{300}"
|
|
8453
|
+
// at the moment, it's unnecessary to introduce an extra error type
|
|
8454
|
+
// until there exists a whitelisted multi-character
|
|
8455
|
+
// eg. if (M < 0 && is_combining_mark(cp)) { ... }
|
|
8456
|
+
// there are 3 cases:
|
|
8457
|
+
// 1. illegal cm for wrong group => mixture error
|
|
8458
|
+
// 2. illegal cm for same group => cm error
|
|
8459
|
+
// requires set of whitelist cm per group:
|
|
8460
|
+
// eg. new Set([...g.P, ...g.Q].flatMap(nfc).filter(cp => CM.has(cp)))
|
|
8461
|
+
// 3. wrong group => mixture error
|
|
8462
|
+
throw error_group_member(g, cp);
|
|
8463
|
+
}
|
|
8464
|
+
}
|
|
8465
|
+
//if (M >= 0) { // we have a known fixed cm count
|
|
8466
|
+
if (g.M) { // we need to check for NSM
|
|
8467
|
+
let decomposed = nfd(cps);
|
|
8468
|
+
for (let i = 1, e = decomposed.length; i < e; i++) { // see: assumption
|
|
8469
|
+
// 20230210: bugfix: using cps instead of decomposed h/t Carbon225
|
|
8470
|
+
/*
|
|
8471
|
+
if (CM.has(decomposed[i])) {
|
|
8472
|
+
let j = i + 1;
|
|
8473
|
+
while (j < e && CM.has(decomposed[j])) j++;
|
|
8474
|
+
if (j - i > M) {
|
|
8475
|
+
throw new Error(`too many combining marks: ${g.N} ${bidi_qq(str_from_cps(decomposed.slice(i-1, j)))} (${j-i}/${M})`);
|
|
8476
|
+
}
|
|
8477
|
+
i = j;
|
|
8478
|
+
}
|
|
8479
|
+
*/
|
|
8480
|
+
// 20230217: switch to NSM counting
|
|
8481
|
+
// https://www.unicode.org/reports/tr39/#Optional_Detection
|
|
8482
|
+
if (NSM.has(decomposed[i])) {
|
|
8483
|
+
let j = i + 1;
|
|
8484
|
+
for (let cp; j < e && NSM.has(cp = decomposed[j]); j++) {
|
|
8485
|
+
// a. Forbid sequences of the same nonspacing mark.
|
|
8486
|
+
for (let k = i; k < j; k++) { // O(n^2) but n < 100
|
|
8487
|
+
if (decomposed[k] == cp) {
|
|
8488
|
+
throw new Error(`duplicate non-spacing marks: ${quoted_cp(cp)}`);
|
|
8489
|
+
}
|
|
8490
|
+
}
|
|
8491
|
+
}
|
|
8492
|
+
// parse to end so we have full nsm count
|
|
8493
|
+
// b. Forbid sequences of more than 4 nonspacing marks (gc=Mn or gc=Me).
|
|
8494
|
+
if (j - i > NSM_MAX) {
|
|
8495
|
+
// note: this slice starts with a base char or spacing-mark cm
|
|
8496
|
+
throw new Error(`excessive non-spacing marks: ${bidi_qq(safe_str_from_cps(decomposed.slice(i-1, j)))} (${j-i}/${NSM_MAX})`);
|
|
8497
|
+
}
|
|
8498
|
+
i = j;
|
|
8499
|
+
}
|
|
8500
|
+
}
|
|
8501
|
+
}
|
|
8502
|
+
// *** this code currently isn't needed ***
|
|
8503
|
+
/*
|
|
8504
|
+
let cm_whitelist = M instanceof Map;
|
|
8505
|
+
for (let i = 0, e = cps.length; i < e; ) {
|
|
8506
|
+
let cp = cps[i++];
|
|
8507
|
+
let seqs = cm_whitelist && M.get(cp);
|
|
8508
|
+
if (seqs) {
|
|
8509
|
+
// list of codepoints that can follow
|
|
8510
|
+
// if this exists, this will always be 1+
|
|
8511
|
+
let j = i;
|
|
8512
|
+
while (j < e && CM.has(cps[j])) j++;
|
|
8513
|
+
let cms = cps.slice(i, j);
|
|
8514
|
+
let match = seqs.find(seq => !compare_arrays(seq, cms));
|
|
8515
|
+
if (!match) throw new Error(`disallowed combining mark sequence: "${safe_str_from_cps([cp, ...cms])}"`);
|
|
8516
|
+
i = j;
|
|
8517
|
+
} else if (!V.has(cp)) {
|
|
8518
|
+
// https://www.unicode.org/reports/tr39/#mixed_script_confusables
|
|
8519
|
+
let quoted = quoted_cp(cp);
|
|
8520
|
+
for (let cp of cps) {
|
|
8521
|
+
let u = UNIQUE.get(cp);
|
|
8522
|
+
if (u && u !== g) {
|
|
8523
|
+
// if both scripts are restricted this error is confusing
|
|
8524
|
+
// because we don't differentiate RestrictedA from RestrictedB
|
|
8525
|
+
if (!u.R) quoted = `${quoted} is ${u.N}`;
|
|
8526
|
+
break;
|
|
8527
|
+
}
|
|
8528
|
+
}
|
|
8529
|
+
throw new Error(`disallowed ${g.N} character: ${quoted}`);
|
|
8530
|
+
//throw new Error(`disallowed character: ${quoted} (expected ${g.N})`);
|
|
8531
|
+
//throw new Error(`${g.N} does not allow: ${quoted}`);
|
|
8532
|
+
}
|
|
8533
|
+
}
|
|
8534
|
+
if (!cm_whitelist) {
|
|
8535
|
+
let decomposed = nfd(cps);
|
|
8536
|
+
for (let i = 1, e = decomposed.length; i < e; i++) { // we know it can't be cm leading
|
|
8537
|
+
if (CM.has(decomposed[i])) {
|
|
8538
|
+
let j = i + 1;
|
|
8539
|
+
while (j < e && CM.has(decomposed[j])) j++;
|
|
8540
|
+
if (j - i > M) {
|
|
8541
|
+
throw new Error(`too many combining marks: "${str_from_cps(decomposed.slice(i-1, j))}" (${j-i}/${M})`);
|
|
8542
|
+
}
|
|
8543
|
+
i = j;
|
|
8544
|
+
}
|
|
8545
|
+
}
|
|
8546
|
+
}
|
|
8547
|
+
*/
|
|
8548
|
+
}
|
|
8549
|
+
|
|
8550
|
+
// given a list of codepoints
|
|
8551
|
+
// returns a list of lists, where emoji are a fully-qualified (as Array subclass)
|
|
8552
|
+
// eg. explode_cp("abc💩d") => [[61, 62, 63], Emoji[1F4A9, FE0F], [64]]
|
|
8553
|
+
// 20230818: rename for 'process' name collision h/t Javarome
|
|
8554
|
+
// https://github.com/adraffy/ens-normalize.js/issues/23
|
|
8555
|
+
function tokens_from_str(input, nf, ef) {
|
|
8556
|
+
let ret = [];
|
|
8557
|
+
let chars = [];
|
|
8558
|
+
input = input.slice().reverse(); // flip so we can pop
|
|
8559
|
+
while (input.length) {
|
|
8560
|
+
let emoji = consume_emoji_reversed(input);
|
|
8561
|
+
if (emoji) {
|
|
8562
|
+
if (chars.length) {
|
|
8563
|
+
ret.push(nf(chars));
|
|
8564
|
+
chars = [];
|
|
8565
|
+
}
|
|
8566
|
+
ret.push(ef(emoji));
|
|
8567
|
+
} else {
|
|
8568
|
+
let cp = input.pop();
|
|
8569
|
+
if (VALID.has(cp)) {
|
|
8570
|
+
chars.push(cp);
|
|
8571
|
+
} else {
|
|
8572
|
+
let cps = MAPPED.get(cp);
|
|
8573
|
+
if (cps) {
|
|
8574
|
+
chars.push(...cps); // less than 10 elements
|
|
8575
|
+
} else if (!IGNORED.has(cp)) {
|
|
8576
|
+
// 20230912: unicode 15.1 changed the order of processing such that
|
|
8577
|
+
// disallowed parts are only rejected after NFC
|
|
8578
|
+
// https://unicode.org/reports/tr46/#Validity_Criteria
|
|
8579
|
+
// this doesn't impact normalization as of today
|
|
8580
|
+
// technically, this error can be removed as the group logic will apply similar logic
|
|
8581
|
+
// however the error type might be less clear
|
|
8582
|
+
throw error_disallowed(cp);
|
|
8583
|
+
}
|
|
8584
|
+
}
|
|
8585
|
+
}
|
|
8586
|
+
}
|
|
8587
|
+
if (chars.length) {
|
|
8588
|
+
ret.push(nf(chars));
|
|
8589
|
+
}
|
|
8590
|
+
return ret;
|
|
8591
|
+
}
|
|
8592
|
+
|
|
8593
|
+
function filter_fe0f(cps) {
|
|
8594
|
+
return cps.filter(cp => cp != FE0F);
|
|
8595
|
+
}
|
|
8596
|
+
|
|
8597
|
+
// given array of codepoints
|
|
8598
|
+
// returns the longest valid emoji sequence (or undefined if no match)
|
|
8599
|
+
// *MUTATES* the supplied array
|
|
8600
|
+
// disallows interleaved ignored characters
|
|
8601
|
+
// fills (optional) eaten array with matched codepoints
|
|
8602
|
+
function consume_emoji_reversed(cps, eaten) {
|
|
8603
|
+
let node = EMOJI_ROOT;
|
|
8604
|
+
let emoji;
|
|
8605
|
+
let pos = cps.length;
|
|
8606
|
+
while (pos) {
|
|
8607
|
+
node = node.get(cps[--pos]);
|
|
8608
|
+
if (!node) break;
|
|
8609
|
+
let {V} = node;
|
|
8610
|
+
if (V) { // this is a valid emoji (so far)
|
|
8611
|
+
emoji = V;
|
|
8612
|
+
cps.length = pos; // truncate
|
|
8613
|
+
}
|
|
8614
|
+
}
|
|
8615
|
+
return emoji;
|
|
8820
8616
|
}
|
|
8821
8617
|
|
|
8822
8618
|
const Zeros = new Uint8Array(32);
|
|
@@ -19235,7 +19031,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
19235
19031
|
address: a.address,
|
|
19236
19032
|
nonce: toQuantity(a.nonce),
|
|
19237
19033
|
chainId: toQuantity(a.chainId),
|
|
19238
|
-
yParity: toQuantity(a.signature.yParity),
|
|
19239
19034
|
r: toQuantity(a.signature.r),
|
|
19240
19035
|
s: toQuantity(a.signature.s),
|
|
19241
19036
|
};
|
|
@@ -20550,7 +20345,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
20550
20345
|
else {
|
|
20551
20346
|
pass = toUtf8String(_password);
|
|
20552
20347
|
}
|
|
20553
|
-
let wal =
|
|
20348
|
+
let wal = quantumCoinJsSdk.deserializeEncryptedWallet(json, pass);
|
|
20554
20349
|
let privKey = wal.privateKey;
|
|
20555
20350
|
let ks = {
|
|
20556
20351
|
address: wal.address,
|
|
@@ -20570,13 +20365,13 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
20570
20365
|
const signingKey = new SigningKey(account.privateKey);
|
|
20571
20366
|
const privateKey = getBytes(signingKey.privateKey);
|
|
20572
20367
|
const publicKey = getBytes(signingKey.publicKey);
|
|
20573
|
-
const wal = new
|
|
20368
|
+
const wal = new quantumCoinJsSdk.Wallet(account.address, privateKey, publicKey);
|
|
20574
20369
|
if (typeof password === 'string') {
|
|
20575
|
-
return
|
|
20370
|
+
return quantumCoinJsSdk.serializeEncryptedWallet(wal, password);
|
|
20576
20371
|
}
|
|
20577
20372
|
else {
|
|
20578
20373
|
let passPhrase = toUtf8String(password);
|
|
20579
|
-
return
|
|
20374
|
+
return quantumCoinJsSdk.serializeEncryptedWallet(wal, passPhrase);
|
|
20580
20375
|
}
|
|
20581
20376
|
}
|
|
20582
20377
|
|
|
@@ -20672,7 +20467,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
20672
20467
|
* If there is no crytographic random source, this will throw.
|
|
20673
20468
|
*/
|
|
20674
20469
|
static createRandom(provider) {
|
|
20675
|
-
let wal =
|
|
20470
|
+
let wal = quantumCoinJsSdk.newWallet();
|
|
20676
20471
|
let privKey = wal.privateKey;
|
|
20677
20472
|
return new Wallet(hexlify(privKey));
|
|
20678
20473
|
}
|
|
@@ -20962,6 +20757,10 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
20962
20757
|
|
|
20963
20758
|
/////////////////////////////
|
|
20964
20759
|
//
|
|
20760
|
+
async function initQuantum() {
|
|
20761
|
+
let clientConfigVal = new quantumCoinJsSdk.Config("https://sdk.readrelay.quantumcoinapi.com", "https://sdk.writerelay.quantumcoinapi.com", 123123, "", ""); //Mainnet
|
|
20762
|
+
return await quantumCoinJsSdk.initialize(clientConfigVal);
|
|
20763
|
+
}
|
|
20965
20764
|
// dummy change; to pick-up ws security issue changes
|
|
20966
20765
|
|
|
20967
20766
|
var quantumcoin = /*#__PURE__*/Object.freeze({
|
|
@@ -21090,6 +20889,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
21090
20889
|
hashMessage: hashMessage,
|
|
21091
20890
|
hexlify: hexlify,
|
|
21092
20891
|
id: id,
|
|
20892
|
+
initQuantum: initQuantum,
|
|
21093
20893
|
isAddress: isAddress,
|
|
21094
20894
|
isAddressable: isAddressable,
|
|
21095
20895
|
isBytesLike: isBytesLike,
|
|
@@ -21264,6 +21064,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
|
|
|
21264
21064
|
exports.hashMessage = hashMessage;
|
|
21265
21065
|
exports.hexlify = hexlify;
|
|
21266
21066
|
exports.id = id;
|
|
21067
|
+
exports.initQuantum = initQuantum;
|
|
21267
21068
|
exports.isAddress = isAddress;
|
|
21268
21069
|
exports.isAddressable = isAddressable;
|
|
21269
21070
|
exports.isBytesLike = isBytesLike;
|