@caict/bop-typescript-sdk 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -10
- package/README.md +7 -1
- package/base.tsconfig.json +14 -0
- package/dist/bop/bop-base/base.d.ts +24 -0
- package/dist/bop/bop-base/base.js +253 -0
- package/dist/bop/bop-base/base.js.map +1 -0
- package/dist/bop/bop-base/index.d.ts +18 -0
- package/dist/bop/bop-base/index.js +69 -0
- package/dist/bop/bop-base/index.js.map +1 -0
- package/dist/bop/bop-base/permit.d.ts +11 -0
- package/dist/bop/bop-base/permit.js +104 -0
- package/dist/bop/bop-base/permit.js.map +1 -0
- package/dist/bop/bop-base/test/base.test.d.ts +1 -0
- package/dist/bop/bop-base/test/base.test.js +772 -0
- package/dist/bop/bop-base/test/base.test.js.map +1 -0
- package/dist/bop/bop-base/test/index.test.d.ts +1 -0
- package/dist/bop/bop-base/test/index.test.js +89 -0
- package/dist/bop/bop-base/test/index.test.js.map +1 -0
- package/dist/bop/bop-base/test/permit.test.d.ts +1 -0
- package/dist/bop/bop-base/test/permit.test.js +140 -0
- package/dist/bop/bop-base/test/permit.test.js.map +1 -0
- package/dist/bop/bop-proto/bop-ws.d.ts +325 -0
- package/dist/bop/bop-proto/bop-ws.js +3599 -0
- package/dist/bop/bop-proto/bop-ws.js.map +1 -0
- package/dist/bop/bop-proto/bop.d.ts +903 -0
- package/dist/bop/bop-proto/bop.js +10421 -0
- package/dist/bop/bop-proto/bop.js.map +1 -0
- package/dist/bop/bop-ws/index.d.ts +43 -0
- package/dist/bop/bop-ws/index.js +265 -0
- package/dist/bop/bop-ws/index.js.map +1 -0
- package/dist/bop/bop-ws/sample/sample.d.ts +1 -0
- package/dist/bop/bop-ws/sample/sample.js +96 -0
- package/dist/bop/bop-ws/sample/sample.js.map +1 -0
- package/dist/bop/index.d.ts +5 -0
- package/dist/bop/index.js +37 -0
- package/dist/bop/index.js.map +1 -0
- package/dist/bop-sdk/index.d.ts +13 -0
- package/dist/bop-sdk/index.js +45 -0
- package/dist/bop-sdk/index.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-account.d.ts +8 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-account.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-account.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-chain.d.ts +5 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-chain.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-chain.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-contract.d.ts +6 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-contract.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-contract.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-ledger.d.ts +8 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-ledger.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-ledger.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-provider.d.ts +12 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-provider.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-provider.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-signer.d.ts +17 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-signer.js +109 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-signer.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-transaction.d.ts +17 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-transaction.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-transaction.js.map +1 -0
- package/dist/bop-sdk/interface/provider-ws.d.ts +5 -0
- package/dist/bop-sdk/interface/provider-ws.js +12 -0
- package/dist/bop-sdk/interface/provider-ws.js.map +1 -0
- package/dist/bop-sdk/interface/provider.d.ts +7 -0
- package/dist/bop-sdk/interface/provider.js +23 -0
- package/dist/bop-sdk/interface/provider.js.map +1 -0
- package/dist/bop-sdk/interface/service/3rd.d.ts +12 -0
- package/dist/bop-sdk/interface/service/3rd.js +49 -0
- package/dist/bop-sdk/interface/service/3rd.js.map +1 -0
- package/dist/bop-sdk/interface/service/account.d.ts +12 -0
- package/dist/bop-sdk/interface/service/account.js +98 -0
- package/dist/bop-sdk/interface/service/account.js.map +1 -0
- package/dist/bop-sdk/interface/service/chain.d.ts +9 -0
- package/dist/bop-sdk/interface/service/chain.js +55 -0
- package/dist/bop-sdk/interface/service/chain.js.map +1 -0
- package/dist/bop-sdk/interface/service/contract.d.ts +10 -0
- package/dist/bop-sdk/interface/service/contract.js +67 -0
- package/dist/bop-sdk/interface/service/contract.js.map +1 -0
- package/dist/bop-sdk/interface/service/helper.d.ts +20 -0
- package/dist/bop-sdk/interface/service/helper.js +383 -0
- package/dist/bop-sdk/interface/service/helper.js.map +1 -0
- package/dist/bop-sdk/interface/service/ledger.d.ts +12 -0
- package/dist/bop-sdk/interface/service/ledger.js +89 -0
- package/dist/bop-sdk/interface/service/ledger.js.map +1 -0
- package/dist/bop-sdk/interface/service/offline/check/index.js +138 -0
- package/dist/bop-sdk/interface/service/offline/common/constant.js +6 -0
- package/dist/bop-sdk/interface/service/offline/common/snowFlakeUtils.js +192 -0
- package/dist/bop-sdk/interface/service/offline/common/util.js +511 -0
- package/dist/bop-sdk/interface/service/offline/exception/customErrors.js +29 -0
- package/dist/bop-sdk/interface/service/offline/exception/errors.js +90 -0
- package/dist/bop-sdk/interface/service/offline/exception/index.js +5 -0
- package/dist/bop-sdk/interface/service/offline/operation/accountCreateOperation.js +28 -0
- package/dist/bop-sdk/interface/service/offline/operation/accountSetMetadataOperation.js +44 -0
- package/dist/bop-sdk/interface/service/offline/operation/accountSetPrivilegeOperation.js +49 -0
- package/dist/bop-sdk/interface/service/offline/operation/contractCreateOperation.js +43 -0
- package/dist/bop-sdk/interface/service/offline/operation/contractInvokeOperation.js +42 -0
- package/dist/bop-sdk/interface/service/offline/operation/contractInvokeRequestOperation.js +69 -0
- package/dist/bop-sdk/interface/service/offline/operation/gasSendOperation.js +29 -0
- package/dist/bop-sdk/interface/service/offline/operation/gasSendRequestOperation.js +61 -0
- package/dist/bop-sdk/interface/service/offline/operation/index.js +20 -0
- package/dist/bop-sdk/interface/service/offline/proto/chain_pb.js +12079 -0
- package/dist/bop-sdk/interface/service/offline/proto/common_pb.js +2867 -0
- package/dist/bop-sdk/interface/service/offline/transaction/index.js +988 -0
- package/dist/bop-sdk/interface/service/offline/transaction/operations.js +188 -0
- package/dist/bop-sdk/interface/service/offline/validate/account.js +152 -0
- package/dist/bop-sdk/interface/service/offline/validate/contract.js +101 -0
- package/dist/bop-sdk/interface/service/offline/validate/index.js +10 -0
- package/dist/bop-sdk/interface/service/offline/validate/transaction.js +51 -0
- package/dist/bop-sdk/interface/service/transaction.d.ts +21 -0
- package/dist/bop-sdk/interface/service/transaction.js +591 -0
- package/dist/bop-sdk/interface/service/transaction.js.map +1 -0
- package/dist/bop-sdk/interface/signer.d.ts +12 -0
- package/dist/bop-sdk/interface/signer.js +53 -0
- package/dist/bop-sdk/interface/signer.js.map +1 -0
- package/dist/bop-sdk/interface/test/3rd.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/3rd.test.js +1524 -0
- package/dist/bop-sdk/interface/test/3rd.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/account.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/account.test.js +225 -0
- package/dist/bop-sdk/interface/test/account.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/chain.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/chain.test.js +72 -0
- package/dist/bop-sdk/interface/test/chain.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/contract.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/contract.test.js +266 -0
- package/dist/bop-sdk/interface/test/contract.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/ledger.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/ledger.test.js +167 -0
- package/dist/bop-sdk/interface/test/ledger.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/provider.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/provider.test.js +295 -0
- package/dist/bop-sdk/interface/test/provider.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/signer.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/signer.test.js +87 -0
- package/dist/bop-sdk/interface/test/signer.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/transaction.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/transaction.test.js +663 -0
- package/dist/bop-sdk/interface/test/transaction.test.js.map +1 -0
- package/dist/bop-sdk/proto/bop-sdk-common.d.ts +225 -0
- package/dist/bop-sdk/proto/bop-sdk-common.js +831 -0
- package/dist/bop-sdk/proto/bop-sdk-common.js.map +1 -0
- package/dist/bop-sdk/proto/bop-sdk-interface.d.ts +623 -0
- package/dist/bop-sdk/proto/bop-sdk-interface.js +8623 -0
- package/dist/bop-sdk/proto/bop-sdk-interface.js.map +1 -0
- package/dist/bop-sdk/proto/bop-sdk-utils.d.ts +107 -0
- package/dist/bop-sdk/proto/bop-sdk-utils.js +1160 -0
- package/dist/bop-sdk/proto/bop-sdk-utils.js.map +1 -0
- package/dist/bop-sdk/utils/abi/abi-coder.d.ts +16 -0
- package/dist/bop-sdk/utils/abi/abi-coder.js +101 -0
- package/dist/bop-sdk/utils/abi/abi-coder.js.map +1 -0
- package/dist/bop-sdk/utils/abi/address.d.ts +8 -0
- package/dist/bop-sdk/utils/abi/address.js +116 -0
- package/dist/bop-sdk/utils/abi/address.js.map +1 -0
- package/dist/bop-sdk/utils/abi/bignumber.d.ts +39 -0
- package/dist/bop-sdk/utils/abi/bignumber.js +316 -0
- package/dist/bop-sdk/utils/abi/bignumber.js.map +1 -0
- package/dist/bop-sdk/utils/abi/bytes.d.ts +41 -0
- package/dist/bop-sdk/utils/abi/bytes.js +423 -0
- package/dist/bop-sdk/utils/abi/bytes.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/abstract-coder.d.ts +52 -0
- package/dist/bop-sdk/utils/abi/coders/abstract-coder.js +164 -0
- package/dist/bop-sdk/utils/abi/coders/abstract-coder.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/address.d.ts +7 -0
- package/dist/bop-sdk/utils/abi/coders/address.js +52 -0
- package/dist/bop-sdk/utils/abi/coders/address.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/anonymous.d.ts +8 -0
- package/dist/bop-sdk/utils/abi/coders/anonymous.js +22 -0
- package/dist/bop-sdk/utils/abi/coders/anonymous.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/array.d.ts +13 -0
- package/dist/bop-sdk/utils/abi/coders/array.js +220 -0
- package/dist/bop-sdk/utils/abi/coders/array.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/boolean.d.ts +7 -0
- package/dist/bop-sdk/utils/abi/coders/boolean.js +20 -0
- package/dist/bop-sdk/utils/abi/coders/boolean.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/bytes.d.ts +11 -0
- package/dist/bop-sdk/utils/abi/coders/bytes.js +33 -0
- package/dist/bop-sdk/utils/abi/coders/bytes.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/fixed-bytes.d.ts +9 -0
- package/dist/bop-sdk/utils/abi/coders/fixed-bytes.js +28 -0
- package/dist/bop-sdk/utils/abi/coders/fixed-bytes.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/null.d.ts +7 -0
- package/dist/bop-sdk/utils/abi/coders/null.js +24 -0
- package/dist/bop-sdk/utils/abi/coders/null.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/number.d.ts +10 -0
- package/dist/bop-sdk/utils/abi/coders/number.js +45 -0
- package/dist/bop-sdk/utils/abi/coders/number.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/string.d.ts +8 -0
- package/dist/bop-sdk/utils/abi/coders/string.js +21 -0
- package/dist/bop-sdk/utils/abi/coders/string.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/tuple.d.ts +10 -0
- package/dist/bop-sdk/utils/abi/coders/tuple.js +60 -0
- package/dist/bop-sdk/utils/abi/coders/tuple.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/addresses.d.ts +1 -0
- package/dist/bop-sdk/utils/abi/constants/addresses.js +5 -0
- package/dist/bop-sdk/utils/abi/constants/addresses.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/bignumbers.d.ts +10 -0
- package/dist/bop-sdk/utils/abi/constants/bignumbers.js +21 -0
- package/dist/bop-sdk/utils/abi/constants/bignumbers.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/hashes.d.ts +1 -0
- package/dist/bop-sdk/utils/abi/constants/hashes.js +5 -0
- package/dist/bop-sdk/utils/abi/constants/hashes.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/index.d.ts +4 -0
- package/dist/bop-sdk/utils/abi/constants/index.js +19 -0
- package/dist/bop-sdk/utils/abi/constants/index.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/strings.d.ts +1 -0
- package/dist/bop-sdk/utils/abi/constants/strings.js +6 -0
- package/dist/bop-sdk/utils/abi/constants/strings.js.map +1 -0
- package/dist/bop-sdk/utils/abi/fragments.d.ts +84 -0
- package/dist/bop-sdk/utils/abi/fragments.js +919 -0
- package/dist/bop-sdk/utils/abi/fragments.js.map +1 -0
- package/dist/bop-sdk/utils/abi/id.d.ts +1 -0
- package/dist/bop-sdk/utils/abi/id.js +10 -0
- package/dist/bop-sdk/utils/abi/id.js.map +1 -0
- package/dist/bop-sdk/utils/abi/index.d.ts +4 -0
- package/dist/bop-sdk/utils/abi/index.js +21 -0
- package/dist/bop-sdk/utils/abi/index.js.map +1 -0
- package/dist/bop-sdk/utils/abi/interface.d.ts +83 -0
- package/dist/bop-sdk/utils/abi/interface.js +663 -0
- package/dist/bop-sdk/utils/abi/interface.js.map +1 -0
- package/dist/bop-sdk/utils/abi/keccak256.d.ts +2 -0
- package/dist/bop-sdk/utils/abi/keccak256.js +13 -0
- package/dist/bop-sdk/utils/abi/keccak256.js.map +1 -0
- package/dist/bop-sdk/utils/abi/properties.d.ts +16 -0
- package/dist/bop-sdk/utils/abi/properties.js +141 -0
- package/dist/bop-sdk/utils/abi/properties.js.map +1 -0
- package/dist/bop-sdk/utils/abi/strings/bytes32.d.ts +3 -0
- package/dist/bop-sdk/utils/abi/strings/bytes32.js +36 -0
- package/dist/bop-sdk/utils/abi/strings/bytes32.js.map +1 -0
- package/dist/bop-sdk/utils/abi/strings/idna.d.ts +4 -0
- package/dist/bop-sdk/utils/abi/strings/idna.js +200 -0
- package/dist/bop-sdk/utils/abi/strings/idna.js.map +1 -0
- package/dist/bop-sdk/utils/abi/strings/index.d.ts +4 -0
- package/dist/bop-sdk/utils/abi/strings/index.js +17 -0
- package/dist/bop-sdk/utils/abi/strings/index.js.map +1 -0
- package/dist/bop-sdk/utils/abi/strings/utf8.d.ts +26 -0
- package/dist/bop-sdk/utils/abi/strings/utf8.js +265 -0
- package/dist/bop-sdk/utils/abi/strings/utf8.js.map +1 -0
- package/dist/bop-sdk/utils/encryption-address.d.ts +25 -0
- package/dist/bop-sdk/utils/encryption-address.js +426 -0
- package/dist/bop-sdk/utils/encryption-address.js.map +1 -0
- package/dist/bop-sdk/utils/encryption-crypto.d.ts +16 -0
- package/dist/bop-sdk/utils/encryption-crypto.js +406 -0
- package/dist/bop-sdk/utils/encryption-crypto.js.map +1 -0
- package/dist/bop-sdk/utils/encryption-mnemonics.d.ts +7 -0
- package/dist/bop-sdk/utils/encryption-mnemonics.js +129 -0
- package/dist/bop-sdk/utils/encryption-mnemonics.js.map +1 -0
- package/dist/bop-sdk/utils/index.d.ts +13 -0
- package/dist/bop-sdk/utils/index.js +22 -0
- package/dist/bop-sdk/utils/index.js.map +1 -0
- package/dist/bop-sdk/utils/logger.d.ts +52 -0
- package/dist/bop-sdk/utils/logger.js +377 -0
- package/dist/bop-sdk/utils/logger.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/package.json +92 -88
- package/src/bop/bop-base/test/base.test.ts +3 -1
- package/src/bop/bop-base/test/index.test.ts +3 -1
- package/src/bop/bop-base/test/permit.test.ts +3 -1
- package/src/bop-sdk/interface/test/3rd.test.ts +4 -1
- package/src/bop-sdk/interface/test/account.test.ts +4 -1
- package/src/bop-sdk/interface/test/chain.test.ts +3 -1
- package/src/bop-sdk/interface/test/contract.test.ts +4 -1
- package/src/bop-sdk/interface/test/ledger.test.ts +4 -1
- package/src/bop-sdk/interface/test/provider.test.ts +3 -1
- package/src/bop-sdk/interface/test/signer.test.ts +4 -1
- package/src/bop-sdk/interface/test/transaction.test.ts +4 -1
- package/tsconfig.json +24 -0
- package/NOTICE +0 -5
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toUtf8CodePoints = exports.toUtf8String = exports._toUtf8String = exports._toEscapedUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = exports.Utf8ErrorReason = exports.UnicodeNormalizationForm = void 0;
|
|
4
|
+
const bytes_1 = require("../bytes");
|
|
5
|
+
const logger_1 = require("../../logger");
|
|
6
|
+
const version = "utf8/5.7.0";
|
|
7
|
+
const logger = new logger_1.Logger(version);
|
|
8
|
+
///////////////////////////////
|
|
9
|
+
var UnicodeNormalizationForm;
|
|
10
|
+
(function (UnicodeNormalizationForm) {
|
|
11
|
+
UnicodeNormalizationForm["current"] = "";
|
|
12
|
+
UnicodeNormalizationForm["NFC"] = "NFC";
|
|
13
|
+
UnicodeNormalizationForm["NFD"] = "NFD";
|
|
14
|
+
UnicodeNormalizationForm["NFKC"] = "NFKC";
|
|
15
|
+
UnicodeNormalizationForm["NFKD"] = "NFKD";
|
|
16
|
+
})(UnicodeNormalizationForm = exports.UnicodeNormalizationForm || (exports.UnicodeNormalizationForm = {}));
|
|
17
|
+
var Utf8ErrorReason;
|
|
18
|
+
(function (Utf8ErrorReason) {
|
|
19
|
+
// A continuation byte was present where there was nothing to continue
|
|
20
|
+
// - offset = the index the codepoint began in
|
|
21
|
+
Utf8ErrorReason["UNEXPECTED_CONTINUE"] = "unexpected continuation byte";
|
|
22
|
+
// An invalid (non-continuation) byte to start a UTF-8 codepoint was found
|
|
23
|
+
// - offset = the index the codepoint began in
|
|
24
|
+
Utf8ErrorReason["BAD_PREFIX"] = "bad codepoint prefix";
|
|
25
|
+
// The string is too short to process the expected codepoint
|
|
26
|
+
// - offset = the index the codepoint began in
|
|
27
|
+
Utf8ErrorReason["OVERRUN"] = "string overrun";
|
|
28
|
+
// A missing continuation byte was expected but not found
|
|
29
|
+
// - offset = the index the continuation byte was expected at
|
|
30
|
+
Utf8ErrorReason["MISSING_CONTINUE"] = "missing continuation byte";
|
|
31
|
+
// The computed code point is outside the range for UTF-8
|
|
32
|
+
// - offset = start of this codepoint
|
|
33
|
+
// - badCodepoint = the computed codepoint; outside the UTF-8 range
|
|
34
|
+
Utf8ErrorReason["OUT_OF_RANGE"] = "out of UTF-8 range";
|
|
35
|
+
// UTF-8 strings may not contain UTF-16 surrogate pairs
|
|
36
|
+
// - offset = start of this codepoint
|
|
37
|
+
// - badCodepoint = the computed codepoint; inside the UTF-16 surrogate range
|
|
38
|
+
Utf8ErrorReason["UTF16_SURROGATE"] = "UTF-16 surrogate";
|
|
39
|
+
// The string is an overlong representation
|
|
40
|
+
// - offset = start of this codepoint
|
|
41
|
+
// - badCodepoint = the computed codepoint; already bounds checked
|
|
42
|
+
Utf8ErrorReason["OVERLONG"] = "overlong representation";
|
|
43
|
+
})(Utf8ErrorReason = exports.Utf8ErrorReason || (exports.Utf8ErrorReason = {}));
|
|
44
|
+
function errorFunc(reason, offset, bytes, output, badCodepoint) {
|
|
45
|
+
return logger.throwArgumentError(`invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes);
|
|
46
|
+
}
|
|
47
|
+
function ignoreFunc(reason, offset, bytes, output, badCodepoint) {
|
|
48
|
+
// If there is an invalid prefix (including stray continuation), skip any additional continuation bytes
|
|
49
|
+
if (reason === Utf8ErrorReason.BAD_PREFIX ||
|
|
50
|
+
reason === Utf8ErrorReason.UNEXPECTED_CONTINUE) {
|
|
51
|
+
let i = 0;
|
|
52
|
+
for (let o = offset + 1; o < bytes.length; o++) {
|
|
53
|
+
if (bytes[o] >> 6 !== 0x02) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
i++;
|
|
57
|
+
}
|
|
58
|
+
return i;
|
|
59
|
+
}
|
|
60
|
+
// This byte runs us past the end of the string, so just jump to the end
|
|
61
|
+
// (but the first byte was read already read and therefore skipped)
|
|
62
|
+
if (reason === Utf8ErrorReason.OVERRUN) {
|
|
63
|
+
return bytes.length - offset - 1;
|
|
64
|
+
}
|
|
65
|
+
// Nothing to skip
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
function replaceFunc(reason, offset, bytes, output, badCodepoint) {
|
|
69
|
+
// Overlong representations are otherwise "valid" code points; just non-deistingtished
|
|
70
|
+
if (reason === Utf8ErrorReason.OVERLONG) {
|
|
71
|
+
output.push(badCodepoint);
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
// Put the replacement character into the output
|
|
75
|
+
output.push(0xfffd);
|
|
76
|
+
// Otherwise, process as if ignoring errors
|
|
77
|
+
return ignoreFunc(reason, offset, bytes, output, badCodepoint);
|
|
78
|
+
}
|
|
79
|
+
// Common error handing strategies
|
|
80
|
+
exports.Utf8ErrorFuncs = Object.freeze({
|
|
81
|
+
error: errorFunc,
|
|
82
|
+
ignore: ignoreFunc,
|
|
83
|
+
replace: replaceFunc,
|
|
84
|
+
});
|
|
85
|
+
// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499
|
|
86
|
+
function getUtf8CodePoints(bytes, onError) {
|
|
87
|
+
if (onError == null) {
|
|
88
|
+
onError = exports.Utf8ErrorFuncs.error;
|
|
89
|
+
}
|
|
90
|
+
bytes = (0, bytes_1.arrayify)(bytes);
|
|
91
|
+
const result = [];
|
|
92
|
+
let i = 0;
|
|
93
|
+
// Invalid bytes are ignored
|
|
94
|
+
while (i < bytes.length) {
|
|
95
|
+
const c = bytes[i++];
|
|
96
|
+
// 0xxx xxxx
|
|
97
|
+
if (c >> 7 === 0) {
|
|
98
|
+
result.push(c);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
// Multibyte; how many bytes left for this character?
|
|
102
|
+
let extraLength = null;
|
|
103
|
+
let overlongMask = null;
|
|
104
|
+
// 110x xxxx 10xx xxxx
|
|
105
|
+
if ((c & 0xe0) === 0xc0) {
|
|
106
|
+
extraLength = 1;
|
|
107
|
+
overlongMask = 0x7f;
|
|
108
|
+
// 1110 xxxx 10xx xxxx 10xx xxxx
|
|
109
|
+
}
|
|
110
|
+
else if ((c & 0xf0) === 0xe0) {
|
|
111
|
+
extraLength = 2;
|
|
112
|
+
overlongMask = 0x7ff;
|
|
113
|
+
// 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
|
|
114
|
+
}
|
|
115
|
+
else if ((c & 0xf8) === 0xf0) {
|
|
116
|
+
extraLength = 3;
|
|
117
|
+
overlongMask = 0xffff;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
if ((c & 0xc0) === 0x80) {
|
|
121
|
+
i += onError(Utf8ErrorReason.UNEXPECTED_CONTINUE, i - 1, bytes, result);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
i += onError(Utf8ErrorReason.BAD_PREFIX, i - 1, bytes, result);
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
// Do we have enough bytes in our data?
|
|
129
|
+
if (i - 1 + extraLength >= bytes.length) {
|
|
130
|
+
i += onError(Utf8ErrorReason.OVERRUN, i - 1, bytes, result);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
// Remove the length prefix from the char
|
|
134
|
+
let res = c & ((1 << (8 - extraLength - 1)) - 1);
|
|
135
|
+
for (let j = 0; j < extraLength; j++) {
|
|
136
|
+
let nextChar = bytes[i];
|
|
137
|
+
// Invalid continuation byte
|
|
138
|
+
if ((nextChar & 0xc0) != 0x80) {
|
|
139
|
+
i += onError(Utf8ErrorReason.MISSING_CONTINUE, i, bytes, result);
|
|
140
|
+
res = null;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
res = (res << 6) | (nextChar & 0x3f);
|
|
144
|
+
i++;
|
|
145
|
+
}
|
|
146
|
+
// See above loop for invalid continuation byte
|
|
147
|
+
if (res === null) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
// Maximum code point
|
|
151
|
+
if (res > 0x10ffff) {
|
|
152
|
+
i += onError(Utf8ErrorReason.OUT_OF_RANGE, i - 1 - extraLength, bytes, result, res);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
// Reserved for UTF-16 surrogate halves
|
|
156
|
+
if (res >= 0xd800 && res <= 0xdfff) {
|
|
157
|
+
i += onError(Utf8ErrorReason.UTF16_SURROGATE, i - 1 - extraLength, bytes, result, res);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
// Check for overlong sequences (more bytes than needed)
|
|
161
|
+
if (res <= overlongMask) {
|
|
162
|
+
i += onError(Utf8ErrorReason.OVERLONG, i - 1 - extraLength, bytes, result, res);
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
result.push(res);
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
|
|
170
|
+
function toUtf8Bytes(str, form = UnicodeNormalizationForm.current) {
|
|
171
|
+
if (form != UnicodeNormalizationForm.current) {
|
|
172
|
+
logger.checkNormalize();
|
|
173
|
+
str = str.normalize(form);
|
|
174
|
+
}
|
|
175
|
+
let result = [];
|
|
176
|
+
for (let i = 0; i < str.length; i++) {
|
|
177
|
+
const c = str.charCodeAt(i);
|
|
178
|
+
if (c < 0x80) {
|
|
179
|
+
result.push(c);
|
|
180
|
+
}
|
|
181
|
+
else if (c < 0x800) {
|
|
182
|
+
result.push((c >> 6) | 0xc0);
|
|
183
|
+
result.push((c & 0x3f) | 0x80);
|
|
184
|
+
}
|
|
185
|
+
else if ((c & 0xfc00) == 0xd800) {
|
|
186
|
+
i++;
|
|
187
|
+
const c2 = str.charCodeAt(i);
|
|
188
|
+
if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) {
|
|
189
|
+
throw new Error("invalid utf-8 string");
|
|
190
|
+
}
|
|
191
|
+
// Surrogate Pair
|
|
192
|
+
const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);
|
|
193
|
+
result.push((pair >> 18) | 0xf0);
|
|
194
|
+
result.push(((pair >> 12) & 0x3f) | 0x80);
|
|
195
|
+
result.push(((pair >> 6) & 0x3f) | 0x80);
|
|
196
|
+
result.push((pair & 0x3f) | 0x80);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
result.push((c >> 12) | 0xe0);
|
|
200
|
+
result.push(((c >> 6) & 0x3f) | 0x80);
|
|
201
|
+
result.push((c & 0x3f) | 0x80);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return (0, bytes_1.arrayify)(result);
|
|
205
|
+
}
|
|
206
|
+
exports.toUtf8Bytes = toUtf8Bytes;
|
|
207
|
+
function escapeChar(value) {
|
|
208
|
+
const hex = "0000" + value.toString(16);
|
|
209
|
+
return "\\u" + hex.substring(hex.length - 4);
|
|
210
|
+
}
|
|
211
|
+
function _toEscapedUtf8String(bytes, onError) {
|
|
212
|
+
return ('"' +
|
|
213
|
+
getUtf8CodePoints(bytes, onError)
|
|
214
|
+
.map((codePoint) => {
|
|
215
|
+
if (codePoint < 256) {
|
|
216
|
+
switch (codePoint) {
|
|
217
|
+
case 8:
|
|
218
|
+
return "\\b";
|
|
219
|
+
case 9:
|
|
220
|
+
return "\\t";
|
|
221
|
+
case 10:
|
|
222
|
+
return "\\n";
|
|
223
|
+
case 13:
|
|
224
|
+
return "\\r";
|
|
225
|
+
case 34:
|
|
226
|
+
return '\\"';
|
|
227
|
+
case 92:
|
|
228
|
+
return "\\\\";
|
|
229
|
+
}
|
|
230
|
+
if (codePoint >= 32 && codePoint < 127) {
|
|
231
|
+
return String.fromCharCode(codePoint);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (codePoint <= 0xffff) {
|
|
235
|
+
return escapeChar(codePoint);
|
|
236
|
+
}
|
|
237
|
+
codePoint -= 0x10000;
|
|
238
|
+
return (escapeChar(((codePoint >> 10) & 0x3ff) + 0xd800) +
|
|
239
|
+
escapeChar((codePoint & 0x3ff) + 0xdc00));
|
|
240
|
+
})
|
|
241
|
+
.join("") +
|
|
242
|
+
'"');
|
|
243
|
+
}
|
|
244
|
+
exports._toEscapedUtf8String = _toEscapedUtf8String;
|
|
245
|
+
function _toUtf8String(codePoints) {
|
|
246
|
+
return codePoints
|
|
247
|
+
.map((codePoint) => {
|
|
248
|
+
if (codePoint <= 0xffff) {
|
|
249
|
+
return String.fromCharCode(codePoint);
|
|
250
|
+
}
|
|
251
|
+
codePoint -= 0x10000;
|
|
252
|
+
return String.fromCharCode(((codePoint >> 10) & 0x3ff) + 0xd800, (codePoint & 0x3ff) + 0xdc00);
|
|
253
|
+
})
|
|
254
|
+
.join("");
|
|
255
|
+
}
|
|
256
|
+
exports._toUtf8String = _toUtf8String;
|
|
257
|
+
function toUtf8String(bytes, onError) {
|
|
258
|
+
return _toUtf8String(getUtf8CodePoints(bytes, onError));
|
|
259
|
+
}
|
|
260
|
+
exports.toUtf8String = toUtf8String;
|
|
261
|
+
function toUtf8CodePoints(str, form = UnicodeNormalizationForm.current) {
|
|
262
|
+
return getUtf8CodePoints(toUtf8Bytes(str, form));
|
|
263
|
+
}
|
|
264
|
+
exports.toUtf8CodePoints = toUtf8CodePoints;
|
|
265
|
+
//# sourceMappingURL=utf8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utf8.js","sourceRoot":"","sources":["../../../../../src/bop-sdk/utils/abi/strings/utf8.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,oCAA+C;AAE/C,yCAAsC;AACtC,MAAM,OAAO,GAAG,YAAY,CAAC;AAC7B,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,OAAO,CAAC,CAAC;AAEnC,+BAA+B;AAE/B,IAAY,wBAMX;AAND,WAAY,wBAAwB;IAClC,wCAAY,CAAA;IACZ,uCAAW,CAAA;IACX,uCAAW,CAAA;IACX,yCAAa,CAAA;IACb,yCAAa,CAAA;AACf,CAAC,EANW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAMnC;AAED,IAAY,eA+BX;AA/BD,WAAY,eAAe;IACzB,sEAAsE;IACtE,8CAA8C;IAC9C,uEAAoD,CAAA;IAEpD,0EAA0E;IAC1E,8CAA8C;IAC9C,sDAAmC,CAAA;IAEnC,4DAA4D;IAC5D,8CAA8C;IAC9C,6CAA0B,CAAA;IAE1B,yDAAyD;IACzD,6DAA6D;IAC7D,iEAA8C,CAAA;IAE9C,yDAAyD;IACzD,2CAA2C;IAC3C,mEAAmE;IACnE,sDAAmC,CAAA;IAEnC,uDAAuD;IACvD,2CAA2C;IAC3C,6EAA6E;IAC7E,uDAAoC,CAAA;IAEpC,2CAA2C;IAC3C,2CAA2C;IAC3C,kEAAkE;IAClE,uDAAoC,CAAA;AACtC,CAAC,EA/BW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA+B1B;AAUD,SAAS,SAAS,CAChB,MAAuB,EACvB,MAAc,EACd,KAAwB,EACxB,MAAqB,EACrB,YAAqB;IAErB,OAAO,MAAM,CAAC,kBAAkB,CAC9B,+BAA+B,MAAM,KAAK,MAAM,EAAE,EAClD,OAAO,EACP,KAAK,CACN,CAAC;AACJ,CAAC;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AU;SACd,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QACjB,IAAI,SAAS,IAAI,MAAM,EAAE;YACvB,OAAO,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;SACvC;QACD,SAAS,IAAI,OAAO,CAAC;QACrB,OAAO,MAAM,CAAC,YAAY,CACxB,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,GAAG,MAAM,EACpC,CAAC,SAAS,GAAG,KAAK,CAAC,GAAG,MAAM,CAC7B,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAbD,sCAaC;AAED,SAAgB,YAAY,CAC1B,KAAgB,EAChB,OAAuB;IAEvB,OAAO,aAAa,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1D,CAAC;AALD,oCAKC;AAED,SAAgB,gBAAgB,CAC9B,GAAW,EACX,OAAiC,wBAAwB,CAAC,OAAO;IAEjE,OAAO,iBAAiB,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACnD,CAAC;AALD,4CAKC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CheckKeyResponse, GetAccountPublicKeyInfoResponse, GetBidAndKeyPairResponse, GetKeyResponse, KeyType } from "../proto/bop-sdk-utils";
|
|
2
|
+
export declare class EncryptionAddress {
|
|
3
|
+
constructor();
|
|
4
|
+
private rawKeyToHex;
|
|
5
|
+
private remove0xPrefix;
|
|
6
|
+
private isHexadecimalString;
|
|
7
|
+
private hexStringToNumberArray;
|
|
8
|
+
private startsWithDidBid;
|
|
9
|
+
private isValidChainCode;
|
|
10
|
+
getBidAndKeyPair(chainCode?: string): GetBidAndKeyPairResponse;
|
|
11
|
+
getBidAndKeyPairBySM2(chainCode?: string): GetBidAndKeyPairResponse;
|
|
12
|
+
privateKeyManager(type: KeyType, chainCode?: string): GetBidAndKeyPairResponse;
|
|
13
|
+
privateKeyManagerByKey(priKey: string): GetBidAndKeyPairResponse;
|
|
14
|
+
publicKeyManager(pubKey: string): GetAccountPublicKeyInfoResponse;
|
|
15
|
+
getEncPublicKey(priKey: string): GetKeyResponse;
|
|
16
|
+
getEncPublicKeyByRaw(type: KeyType, rawPublicKey: string): GetKeyResponse;
|
|
17
|
+
getEncPrivateKeyByRaw(type: KeyType, rawPrivateKey: string): GetKeyResponse;
|
|
18
|
+
parsePrivateKey(encPrivateKey: string): GetKeyResponse;
|
|
19
|
+
parsePublicKey(encPublicKey: string): GetKeyResponse;
|
|
20
|
+
publicToAddress(encPublicKey: string): GetKeyResponse;
|
|
21
|
+
isPrivateKey(encPrivateKey: string): CheckKeyResponse;
|
|
22
|
+
isPublicKey(encPublicKey: string): CheckKeyResponse;
|
|
23
|
+
encAddressToHex(encAddress: string): GetKeyResponse;
|
|
24
|
+
hexToEncAddress(hexAddress: string): GetKeyResponse;
|
|
25
|
+
}
|