@keetanetwork/keetanet-client 0.14.0 → 0.14.2
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/client/builder.d.ts +8 -3
- package/client/index-browser.d.ts +1 -1
- package/client/index-browser.js +1805 -1716
- package/client/index.d.ts +1 -1
- package/client/index.js +217 -148
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/KeetaNetSDK.Client.html +4 -4
- package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.LedgerStorageTransactionBase.html +8 -0
- package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Stats.html +10 -4
- package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +10 -0
- package/docs/classes/KeetaNetSDK.Referenced.UserClientBuilder.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.UserClient.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BuilderBlockOptions.html +3 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +2 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageTransactionBaseOptions.html +6 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
- package/docs/interfaces/{KeetaNetSDK.PublishOptions.html → KeetaNetSDK.Referenced.PublishOptions.html} +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_asn1.html +1 -1
- package/docs/modules/KeetaNetSDK.html +2 -2
- package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.SchemaMap.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes-1.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.LedgerErrorCodes.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1CheckUtilities.html +1 -0
- package/lib/error/certificate.d.ts +1 -1
- package/lib/error/ledger.d.ts +1 -1
- package/lib/ledger/db_dynamodb.d.ts +5 -9
- package/lib/ledger/db_postgres.d.ts +11 -3
- package/lib/ledger/db_spanner.d.ts +5 -12
- package/lib/ledger/db_spanner_helper.d.ts +1 -1
- package/lib/ledger/db_sqlite.d.ts +11 -3
- package/lib/ledger/index.d.ts +11 -2
- package/lib/stats.d.ts +22 -3
- package/lib/utils/asn1.d.ts +18 -1
- package/lib/utils/static-types.d.ts +11 -0
- package/package.json +1 -1
- package/version.d.ts +1 -1
- package/benchmarking/test.d.ts +0 -4
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageTransactionBase.html +0 -6
package/client/index.js
CHANGED
|
@@ -64809,37 +64809,18 @@ function ExportBlockOperations(operations) {
|
|
|
64809
64809
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
64810
64810
|
return container;
|
|
64811
64811
|
}
|
|
64812
|
-
function assertExplicitContextValueLike(input) {
|
|
64813
|
-
if (typeof input !== 'object' || input === null) {
|
|
64814
|
-
throw (new Error(`Found entry which is not a context ${String(input)}`));
|
|
64815
|
-
}
|
|
64816
|
-
if (!('type' in input) || input.type !== 'context') {
|
|
64817
|
-
throw (new Error(`Found entry which is not a context ${String(input)}`));
|
|
64818
|
-
}
|
|
64819
|
-
if (!('kind' in input) || input.kind !== 'explicit') {
|
|
64820
|
-
throw (new Error(`Found entry which is not an explicit context ${String(input)}`));
|
|
64821
|
-
}
|
|
64822
|
-
if (!('value' in input)) {
|
|
64823
|
-
throw (new Error(`Found entry which is not a numeric explicit context ${String(input)}`));
|
|
64824
|
-
}
|
|
64825
|
-
const typeInput = input.value;
|
|
64826
|
-
if (typeof typeInput !== 'number') {
|
|
64827
|
-
throw (new Error(`Found entry which is not a numeric explicit context ${String(input)}`));
|
|
64828
|
-
}
|
|
64829
|
-
if (!('contains' in input)) {
|
|
64830
|
-
throw (new Error(`Found entry which which lacks contains ${JSON.stringify(input)}`));
|
|
64831
|
-
}
|
|
64832
|
-
if (!Array.isArray(input.contains)) {
|
|
64833
|
-
throw (new Error(`Found entry which is not a Sequence ${input.contains}`));
|
|
64834
|
-
}
|
|
64835
|
-
}
|
|
64836
64812
|
function ImportOperationsASN1(input, network) {
|
|
64837
64813
|
const retval = [];
|
|
64838
64814
|
for (const entryWrapper of input) {
|
|
64839
64815
|
const operation = {};
|
|
64840
|
-
|
|
64816
|
+
if (!asn1_1.ASN1CheckUtilities.isASN1ContextTag(entryWrapper, 'explicit')) {
|
|
64817
|
+
throw (new Error('Invalid createArgs type for CREATE_IDENTIFIER operation'));
|
|
64818
|
+
}
|
|
64841
64819
|
const type = assertOperationType(entryWrapper.value);
|
|
64842
64820
|
const entry = entryWrapper.contains;
|
|
64821
|
+
if (!Array.isArray(entry)) {
|
|
64822
|
+
throw (new Error(`Found entry which is not a Sequence ${typeof entry}`));
|
|
64823
|
+
}
|
|
64843
64824
|
const typeStr = operationTypeToString(type);
|
|
64844
64825
|
const operationSchema = BlockOperationASN1SchemaBase[typeStr];
|
|
64845
64826
|
if (!operationSchema) {
|
|
@@ -64871,16 +64852,24 @@ function ImportOperationsASN1(input, network) {
|
|
|
64871
64852
|
keyValueOut = newKeyValue;
|
|
64872
64853
|
}
|
|
64873
64854
|
else if (key === 'createArguments' && typeStr === 'CREATE_IDENTIFIER') {
|
|
64874
|
-
|
|
64855
|
+
if (!asn1_1.ASN1CheckUtilities.isASN1ContextTag(keyValueIn, 'explicit')) {
|
|
64856
|
+
throw (new Error('Invalid createArgs type for CREATE_IDENTIFIER operation'));
|
|
64857
|
+
}
|
|
64875
64858
|
if (keyValueIn.value !== account_1.AccountKeyAlgorithm.MULTISIG) {
|
|
64876
64859
|
throw (new Error('unrecognized type for multisig create arguments'));
|
|
64877
64860
|
}
|
|
64878
|
-
if (keyValueIn.contains.length !== 2
|
|
64861
|
+
if (!Array.isArray(keyValueIn.contains) || keyValueIn.contains.length !== 2) {
|
|
64862
|
+
throw (new Error('Invalid createArgs container'));
|
|
64863
|
+
}
|
|
64864
|
+
if (!Array.isArray(keyValueIn.contains[0])) {
|
|
64879
64865
|
throw (new Error('Invalid createArgs container'));
|
|
64880
64866
|
}
|
|
64881
64867
|
keyValueOut = {
|
|
64882
64868
|
type: keyValueIn.value,
|
|
64883
64869
|
signers: keyValueIn.contains[0].map(function (value) {
|
|
64870
|
+
if (!Buffer.isBuffer(value)) {
|
|
64871
|
+
throw (new Error(`Invalid signer value, expected Buffer, got ${typeof value}`));
|
|
64872
|
+
}
|
|
64884
64873
|
return (account_1.default.fromPublicKeyAndType(value));
|
|
64885
64874
|
}),
|
|
64886
64875
|
quorum: keyValueIn.contains[1]
|
|
@@ -65039,7 +65028,17 @@ const BlockErrorCodes = [
|
|
|
65039
65028
|
'DUPLICATE_INCLUDED',
|
|
65040
65029
|
'ORPHAN_FOUND',
|
|
65041
65030
|
'CYCLE_FOUND',
|
|
65042
|
-
'SECONDARY_GRAPH'
|
|
65031
|
+
'SECONDARY_GRAPH',
|
|
65032
|
+
'MISSING_FIELD',
|
|
65033
|
+
'SIGNATURE_ALGORITHM_MISMATCH',
|
|
65034
|
+
'SELF_SIGNED_VALIDATION_FAILED',
|
|
65035
|
+
'CHAIN_VERIFICATION_FAILED',
|
|
65036
|
+
'DUPLICATE_EXTENSION',
|
|
65037
|
+
'EXTENSION_NOT_PROCESSED',
|
|
65038
|
+
'INVALID_SIGNATURE_ALGORITHM',
|
|
65039
|
+
'INVALID_GRAPH_COUNT',
|
|
65040
|
+
'MOMENT_INVALID',
|
|
65041
|
+
'INVALID_VERSION'
|
|
65043
65042
|
];
|
|
65044
65043
|
class KeetaNetCertificateError extends _1.KeetaNetError {
|
|
65045
65044
|
constructor(code, message) {
|
|
@@ -65131,6 +65130,7 @@ const _1 = __webpack_require__(5390);
|
|
|
65131
65130
|
const helper_1 = __webpack_require__(3208);
|
|
65132
65131
|
const LedgerErrorType = 'LEDGER';
|
|
65133
65132
|
const LedgerErrorCodes = [
|
|
65133
|
+
'BLOCK_ALREADY_EXISTS',
|
|
65134
65134
|
'TRANSACTION_ABORTED',
|
|
65135
65135
|
'INVALID_CHAIN',
|
|
65136
65136
|
'INVALID_NETWORK',
|
|
@@ -66109,6 +66109,16 @@ class LedgerStorageBase {
|
|
|
66109
66109
|
})));
|
|
66110
66110
|
}
|
|
66111
66111
|
async preAdjust(input, mayDefer = true, transaction) {
|
|
66112
|
+
const allBlockHeightsToFetch = input.blocks.map(block => {
|
|
66113
|
+
return ({ blockHash: block.hash, account: block.account });
|
|
66114
|
+
});
|
|
66115
|
+
const allBlockHeights = await this.getBlockHeights(transaction, allBlockHeightsToFetch);
|
|
66116
|
+
// Check if any blocks already exist on the ledger that would cause this staple to fail and exit early
|
|
66117
|
+
for (const [blockHash, blockHeight] of Object.entries(allBlockHeights)) {
|
|
66118
|
+
if (blockHeight !== null) {
|
|
66119
|
+
throw (new ledger_1.default('LEDGER_BLOCK_ALREADY_EXISTS', `Block Already Exists: ${blockHash.toString()}`));
|
|
66120
|
+
}
|
|
66121
|
+
}
|
|
66112
66122
|
const seenBlockHashes = new block_1.BlockHash.Set();
|
|
66113
66123
|
const blockHeights = {};
|
|
66114
66124
|
const toFetch = [];
|
|
@@ -67180,7 +67190,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
67180
67190
|
};
|
|
67181
67191
|
var _LedgerAtomicInterface_instances, _LedgerAtomicInterface_network, _LedgerAtomicInterface_subnet, _LedgerAtomicInterface_kind, _LedgerAtomicInterface_privateKey, _LedgerAtomicInterface_computeFeeFromBlocks, _LedgerAtomicInterface_storage, _LedgerAtomicInterface_ledger, _LedgerAtomicInterface_cache, _LedgerAtomicInterface_transaction, _LedgerAtomicInterface_assertTransaction, _LedgerAtomicInterface_validateVotingWeight, _LedgerAtomicInterface_listAccountInfo, _LedgerAtomicInterface_checkSingleAccountPermissions, _LedgerAtomicInterface_checkPermissionRequirements, _LedgerAtomicInterface_validateLedgerOutcome, _LedgerAtomicInterface_validateBlocksForVote, _LedgerAtomicInterface_voteOrQuoteWithFees, _Ledger_storage, _Ledger_config;
|
|
67182
67192
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
67183
|
-
exports.Ledger = exports.LedgerKind = void 0;
|
|
67193
|
+
exports.Ledger = exports.LedgerStorageTransactionBase = exports.LedgerKind = void 0;
|
|
67184
67194
|
const vote_1 = __webpack_require__(1130);
|
|
67185
67195
|
const block_1 = __webpack_require__(6158);
|
|
67186
67196
|
const account_1 = __importDefault(__webpack_require__(9415));
|
|
@@ -67193,6 +67203,7 @@ const conversion_1 = __webpack_require__(2360);
|
|
|
67193
67203
|
const cache_1 = __importDefault(__webpack_require__(5834));
|
|
67194
67204
|
const timing_1 = __webpack_require__(2895);
|
|
67195
67205
|
const operations_1 = __webpack_require__(2778);
|
|
67206
|
+
const stats_1 = __webpack_require__(2127);
|
|
67196
67207
|
/**
|
|
67197
67208
|
* Kind of ledger
|
|
67198
67209
|
*/
|
|
@@ -67201,6 +67212,16 @@ var LedgerKind;
|
|
|
67201
67212
|
LedgerKind[LedgerKind["REPRESENTATIVE"] = 0] = "REPRESENTATIVE";
|
|
67202
67213
|
LedgerKind[LedgerKind["ACCOUNT"] = 1] = "ACCOUNT";
|
|
67203
67214
|
})(LedgerKind || (exports.LedgerKind = LedgerKind = {}));
|
|
67215
|
+
class LedgerStorageTransactionBase {
|
|
67216
|
+
constructor(options) {
|
|
67217
|
+
this.node = options.node;
|
|
67218
|
+
this.moment = options.moment ?? new Date();
|
|
67219
|
+
this.identifier = options.identifier;
|
|
67220
|
+
this.readOnly = options.readOnly ?? true;
|
|
67221
|
+
this.statsPending = new stats_1.StatsPending();
|
|
67222
|
+
}
|
|
67223
|
+
}
|
|
67224
|
+
exports.LedgerStorageTransactionBase = LedgerStorageTransactionBase;
|
|
67204
67225
|
/**
|
|
67205
67226
|
* Atomic transactional interface to a storage backend
|
|
67206
67227
|
*/
|
|
@@ -67242,6 +67263,7 @@ class LedgerAtomicInterface {
|
|
|
67242
67263
|
const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
67243
67264
|
__classPrivateFieldSet(this, _LedgerAtomicInterface_transaction, null, "f");
|
|
67244
67265
|
await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").commitTransaction(transaction);
|
|
67266
|
+
__classPrivateFieldGet(this, _LedgerAtomicInterface_ledger, "f").node?.stats.merge(transaction.statsPending);
|
|
67245
67267
|
}
|
|
67246
67268
|
async abort() {
|
|
67247
67269
|
const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
@@ -67484,12 +67506,9 @@ class LedgerAtomicInterface {
|
|
|
67484
67506
|
/**
|
|
67485
67507
|
* Add all the block hashes to the node checksum
|
|
67486
67508
|
*/
|
|
67487
|
-
const
|
|
67488
|
-
|
|
67489
|
-
|
|
67490
|
-
for (const block of staple.blocks) {
|
|
67491
|
-
ourNode.stats.xor('ledgerChecksum', block.hash);
|
|
67492
|
-
}
|
|
67509
|
+
for (const staple of voteStaples) {
|
|
67510
|
+
for (const block of staple.blocks) {
|
|
67511
|
+
transaction.statsPending.xor('ledgerChecksum', block.hash);
|
|
67493
67512
|
}
|
|
67494
67513
|
}
|
|
67495
67514
|
postambleTiming?.end();
|
|
@@ -68253,13 +68272,7 @@ class Ledger {
|
|
|
68253
68272
|
return (await this.run(identifier, code, true));
|
|
68254
68273
|
}
|
|
68255
68274
|
async beginTransaction(identifier, readOnly = false) {
|
|
68256
|
-
const
|
|
68257
|
-
node: this.node,
|
|
68258
|
-
moment: new Date(),
|
|
68259
|
-
identifier,
|
|
68260
|
-
readOnly
|
|
68261
|
-
};
|
|
68262
|
-
const transaction = await __classPrivateFieldGet(this, _Ledger_storage, "f").beginTransaction(transactionBase);
|
|
68275
|
+
const transaction = await __classPrivateFieldGet(this, _Ledger_storage, "f").beginTransaction({ node: this.node, moment: new Date(), identifier, readOnly });
|
|
68263
68276
|
return (new LedgerAtomicInterface(transaction, __classPrivateFieldGet(this, _Ledger_storage, "f"), __classPrivateFieldGet(this, _Ledger_config, "f"), this));
|
|
68264
68277
|
}
|
|
68265
68278
|
async vote(...args) {
|
|
@@ -68383,7 +68396,7 @@ class Ledger {
|
|
|
68383
68396
|
}));
|
|
68384
68397
|
}
|
|
68385
68398
|
async getFee(...args) {
|
|
68386
|
-
return (await this.
|
|
68399
|
+
return (await this.runReadOnly('db-getFee', async function (transaction) {
|
|
68387
68400
|
return (await transaction.getFee(...args));
|
|
68388
68401
|
}));
|
|
68389
68402
|
}
|
|
@@ -68934,7 +68947,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
68934
68947
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
68935
68948
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68936
68949
|
};
|
|
68937
|
-
var _P2PHttpConnection_switch, _P2PWebSocket_underlyingSocket, _P2PWebSocket_socket, _P2PWebSocket_switch, _P2PSwitch_instances, _P2PSwitch_connectedPeersCleanup, _P2PSwitch_connectedPeersRemote, _P2PSwitch_connectedPeersLocal, _P2PSwitch_localNode, _P2PSwitch_manualPeersCheckIntervals, _P2PSwitch_asyncSends, _P2PSwitch_messageFilterCache, _P2PSwitch_connectedPeerConnection, _P2PSwitch_connectedPeers, _P2PSwitch_updateLastSeenPeer, _P2PSwitch_peersCacheSet, _P2PSwitch_peersCached, _P2PSwitch_relayActiveState, _P2PSwitch_performPeerCleanup, _P2PSwitch_getLocalPeerInfo, _P2PSwitch_emitOutgoingGreeting, _P2PSwitch_localNodeKeyOrNull, _P2PSwitch_handleIncomingGreeting, _P2PSwitch_updateConnTimeout, _P2PSwitch_connectToPeer, _P2PSwitch_passesFilter;
|
|
68950
|
+
var _P2PHttpConnection_switch, _P2PWebSocket_underlyingSocket, _P2PWebSocket_socket, _P2PWebSocket_switch, _P2PSwitch_instances, _P2PSwitch_connectedPeersCleanup, _P2PSwitch_connectedPeersRemote, _P2PSwitch_connectedPeersLocal, _P2PSwitch_localNode, _P2PSwitch_manualPeersCheckIntervals, _P2PSwitch_asyncSends, _P2PSwitch_messageFilterCache, _P2PSwitch_cachedLocalPeerInfo, _P2PSwitch_cachedLocalPeerSerialized, _P2PSwitch_connectedPeerConnection, _P2PSwitch_connectedPeers, _P2PSwitch_updateLastSeenPeer, _P2PSwitch_peersCacheSet, _P2PSwitch_peersCached, _P2PSwitch_relayActiveState, _P2PSwitch_performPeerCleanup, _P2PSwitch_getLocalPeerInfo, _P2PSwitch_emitOutgoingGreeting, _P2PSwitch_localNodeKeyOrNull, _P2PSwitch_handleIncomingGreeting, _P2PSwitch_updateConnTimeout, _P2PSwitch_connectToPeer, _P2PSwitch_passesFilter;
|
|
68938
68951
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
68939
68952
|
exports.Testing = exports.P2PSwitch = exports.P2PWebSocket = exports.P2PHttpConnection = void 0;
|
|
68940
68953
|
exports.generateP2PPeerSigned = generateP2PPeerSigned;
|
|
@@ -69628,6 +69641,8 @@ class P2PSwitch {
|
|
|
69628
69641
|
_P2PSwitch_manualPeersCheckIntervals.set(this, void 0);
|
|
69629
69642
|
_P2PSwitch_asyncSends.set(this, []);
|
|
69630
69643
|
_P2PSwitch_messageFilterCache.set(this, {});
|
|
69644
|
+
_P2PSwitch_cachedLocalPeerInfo.set(this, undefined);
|
|
69645
|
+
_P2PSwitch_cachedLocalPeerSerialized.set(this, undefined);
|
|
69631
69646
|
/**
|
|
69632
69647
|
* Write a debug or error message to the connected node.
|
|
69633
69648
|
*
|
|
@@ -69935,11 +69950,14 @@ class P2PSwitch {
|
|
|
69935
69950
|
return (await __classPrivateFieldGet(this, _P2PSwitch_instances, "m", _P2PSwitch_getLocalPeerInfo).call(this));
|
|
69936
69951
|
}
|
|
69937
69952
|
async getOutgoingGreetingInfo() {
|
|
69938
|
-
|
|
69939
|
-
|
|
69940
|
-
|
|
69953
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_cachedLocalPeerSerialized, "f") === undefined) {
|
|
69954
|
+
const greetingInfo = await __classPrivateFieldGet(this, _P2PSwitch_instances, "m", _P2PSwitch_getLocalPeerInfo).call(this);
|
|
69955
|
+
if (greetingInfo === null) {
|
|
69956
|
+
throw (new Error('Invalid NodeKind for emitting outgoing greeting'));
|
|
69957
|
+
}
|
|
69958
|
+
__classPrivateFieldSet(this, _P2PSwitch_cachedLocalPeerSerialized, P2PPeerToJSO(greetingInfo), "f");
|
|
69941
69959
|
}
|
|
69942
|
-
return (
|
|
69960
|
+
return (__classPrivateFieldGet(this, _P2PSwitch_cachedLocalPeerSerialized, "f"));
|
|
69943
69961
|
}
|
|
69944
69962
|
/**
|
|
69945
69963
|
* Receive a message from a connection
|
|
@@ -70467,7 +70485,7 @@ class P2PSwitch {
|
|
|
70467
70485
|
}
|
|
70468
70486
|
}
|
|
70469
70487
|
exports.P2PSwitch = P2PSwitch;
|
|
70470
|
-
_P2PSwitch_connectedPeersCleanup = new WeakMap(), _P2PSwitch_connectedPeersRemote = new WeakMap(), _P2PSwitch_connectedPeersLocal = new WeakMap(), _P2PSwitch_localNode = new WeakMap(), _P2PSwitch_manualPeersCheckIntervals = new WeakMap(), _P2PSwitch_asyncSends = new WeakMap(), _P2PSwitch_messageFilterCache = new WeakMap(), _P2PSwitch_peersCacheSet = new WeakMap(), _P2PSwitch_instances = new WeakSet(), _P2PSwitch_connectedPeerConnection =
|
|
70488
|
+
_P2PSwitch_connectedPeersCleanup = new WeakMap(), _P2PSwitch_connectedPeersRemote = new WeakMap(), _P2PSwitch_connectedPeersLocal = new WeakMap(), _P2PSwitch_localNode = new WeakMap(), _P2PSwitch_manualPeersCheckIntervals = new WeakMap(), _P2PSwitch_asyncSends = new WeakMap(), _P2PSwitch_messageFilterCache = new WeakMap(), _P2PSwitch_cachedLocalPeerInfo = new WeakMap(), _P2PSwitch_cachedLocalPeerSerialized = new WeakMap(), _P2PSwitch_peersCacheSet = new WeakMap(), _P2PSwitch_instances = new WeakSet(), _P2PSwitch_connectedPeerConnection =
|
|
70471
70489
|
/**
|
|
70472
70490
|
* Get the connection for a given peer or PeerID
|
|
70473
70491
|
*/
|
|
@@ -70608,47 +70626,50 @@ async function _P2PSwitch_relayActiveState(conn) {
|
|
|
70608
70626
|
*/
|
|
70609
70627
|
/** XXX:TODO */
|
|
70610
70628
|
}, _P2PSwitch_getLocalPeerInfo = async function _P2PSwitch_getLocalPeerInfo() {
|
|
70611
|
-
|
|
70612
|
-
|
|
70613
|
-
|
|
70614
|
-
|
|
70615
|
-
|
|
70616
|
-
id: 'unused'
|
|
70617
|
-
};
|
|
70618
|
-
break;
|
|
70619
|
-
case node_1.NodeKind.REPRESENTATIVE:
|
|
70620
|
-
{
|
|
70621
|
-
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints === undefined) {
|
|
70622
|
-
throw (new Error('internal error: Our endpoints are not defined'));
|
|
70623
|
-
}
|
|
70624
|
-
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.p2p === undefined) {
|
|
70625
|
-
throw (new Error('internal error: Our endpoint (p2p) is not defined'));
|
|
70626
|
-
}
|
|
70627
|
-
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.api === undefined) {
|
|
70628
|
-
throw (new Error('internal error: Our endpoint (api) is not defined'));
|
|
70629
|
-
}
|
|
70630
|
-
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.ledgerPrivateKey === undefined) {
|
|
70631
|
-
throw (new Error('internal error: Our ledger key is not defined'));
|
|
70632
|
-
}
|
|
70633
|
-
const greetingInfoSigned = await generateP2PPeerSigned({
|
|
70629
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_cachedLocalPeerInfo, "f") === undefined) {
|
|
70630
|
+
let greetingInfo;
|
|
70631
|
+
switch (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.kind) {
|
|
70632
|
+
case node_1.NodeKind.PARTICIPANT:
|
|
70633
|
+
greetingInfo = {
|
|
70634
70634
|
kind: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.kind,
|
|
70635
|
-
|
|
70636
|
-
|
|
70637
|
-
p2p: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.p2p,
|
|
70638
|
-
api: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.api
|
|
70639
|
-
},
|
|
70640
|
-
preferUpdates: this.config.useHTTPRepublish ? 'http' : 'websocket'
|
|
70641
|
-
});
|
|
70642
|
-
if (greetingInfoSigned === null) {
|
|
70643
|
-
throw (new Error('internal error: Could not generate signature'));
|
|
70644
|
-
}
|
|
70645
|
-
greetingInfo = greetingInfoSigned;
|
|
70635
|
+
id: 'unused'
|
|
70636
|
+
};
|
|
70646
70637
|
break;
|
|
70647
|
-
|
|
70648
|
-
|
|
70649
|
-
|
|
70638
|
+
case node_1.NodeKind.REPRESENTATIVE:
|
|
70639
|
+
{
|
|
70640
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints === undefined) {
|
|
70641
|
+
throw (new Error('internal error: Our endpoints are not defined'));
|
|
70642
|
+
}
|
|
70643
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.p2p === undefined) {
|
|
70644
|
+
throw (new Error('internal error: Our endpoint (p2p) is not defined'));
|
|
70645
|
+
}
|
|
70646
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.api === undefined) {
|
|
70647
|
+
throw (new Error('internal error: Our endpoint (api) is not defined'));
|
|
70648
|
+
}
|
|
70649
|
+
if (__classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.ledgerPrivateKey === undefined) {
|
|
70650
|
+
throw (new Error('internal error: Our ledger key is not defined'));
|
|
70651
|
+
}
|
|
70652
|
+
const greetingInfoSigned = await generateP2PPeerSigned({
|
|
70653
|
+
kind: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.kind,
|
|
70654
|
+
key: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.ledgerPrivateKey,
|
|
70655
|
+
endpoints: {
|
|
70656
|
+
p2p: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.p2p,
|
|
70657
|
+
api: __classPrivateFieldGet(this, _P2PSwitch_localNode, "f").config.endpoints.api
|
|
70658
|
+
},
|
|
70659
|
+
preferUpdates: this.config.useHTTPRepublish ? 'http' : 'websocket'
|
|
70660
|
+
});
|
|
70661
|
+
if (greetingInfoSigned === null) {
|
|
70662
|
+
throw (new Error('internal error: Could not generate signature'));
|
|
70663
|
+
}
|
|
70664
|
+
greetingInfo = greetingInfoSigned;
|
|
70665
|
+
break;
|
|
70666
|
+
}
|
|
70667
|
+
default:
|
|
70668
|
+
return (null);
|
|
70669
|
+
}
|
|
70670
|
+
__classPrivateFieldSet(this, _P2PSwitch_cachedLocalPeerInfo, greetingInfo, "f");
|
|
70650
70671
|
}
|
|
70651
|
-
return (
|
|
70672
|
+
return (__classPrivateFieldGet(this, _P2PSwitch_cachedLocalPeerInfo, "f"));
|
|
70652
70673
|
}, _P2PSwitch_emitOutgoingGreeting = async function _P2PSwitch_emitOutgoingGreeting(to) {
|
|
70653
70674
|
const messageID = uuid.v4();
|
|
70654
70675
|
const greeting = await this.getOutgoingGreetingInfo();
|
|
@@ -71372,9 +71393,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
71372
71393
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
71373
71394
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
71374
71395
|
};
|
|
71375
|
-
var
|
|
71396
|
+
var _a, _Stats_syncPromise, _Stats_kv, _Stats_assertDurationBreakdowns, _Stats_getDurationRange;
|
|
71376
71397
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
71377
|
-
exports.Stats = void 0;
|
|
71398
|
+
exports.Stats = exports.StatsPending = void 0;
|
|
71378
71399
|
const kv_memory_1 = __importDefault(__webpack_require__(1557));
|
|
71379
71400
|
const buffer_1 = __webpack_require__(3310);
|
|
71380
71401
|
const hash_1 = __webpack_require__(7908);
|
|
@@ -71404,11 +71425,57 @@ const durationRanges = {
|
|
|
71404
71425
|
'100000ms': [10001, 100000],
|
|
71405
71426
|
'ExtraLong': [100000, Number.MAX_SAFE_INTEGER]
|
|
71406
71427
|
};
|
|
71407
|
-
class
|
|
71428
|
+
class StatsPending {
|
|
71429
|
+
constructor() {
|
|
71430
|
+
this.localDBIncr = {};
|
|
71431
|
+
this.localDBXOR = {};
|
|
71432
|
+
}
|
|
71433
|
+
consume() {
|
|
71434
|
+
const incrChanges = this.localDBIncr;
|
|
71435
|
+
this.localDBIncr = {};
|
|
71436
|
+
const xorChanges = this.localDBXOR;
|
|
71437
|
+
this.localDBXOR = {};
|
|
71438
|
+
return ({ incrChanges, xorChanges });
|
|
71439
|
+
}
|
|
71440
|
+
compoundKey(arena, key) {
|
|
71441
|
+
const compoundKey = [arena, key].join('|');
|
|
71442
|
+
return (compoundKey);
|
|
71443
|
+
}
|
|
71444
|
+
incrCompoundKey(compoundKey, change) {
|
|
71445
|
+
if (this.localDBIncr[compoundKey] === undefined) {
|
|
71446
|
+
this.localDBIncr[compoundKey] = 0;
|
|
71447
|
+
}
|
|
71448
|
+
this.localDBIncr[compoundKey] += change;
|
|
71449
|
+
}
|
|
71450
|
+
incr(arena, key, change = 1) {
|
|
71451
|
+
const compoundKey = this.compoundKey(arena, key);
|
|
71452
|
+
this.incrCompoundKey(compoundKey, change);
|
|
71453
|
+
}
|
|
71454
|
+
xor(key, change) {
|
|
71455
|
+
const changeValue = typeof change === 'bigint' ? change : change.toBigInt();
|
|
71456
|
+
const existingValue = this.localDBXOR[key];
|
|
71457
|
+
if (existingValue === undefined) {
|
|
71458
|
+
this.localDBXOR[key] = changeValue;
|
|
71459
|
+
return;
|
|
71460
|
+
}
|
|
71461
|
+
this.localDBXOR[key] ^= changeValue;
|
|
71462
|
+
}
|
|
71463
|
+
merge(pending) {
|
|
71464
|
+
const { incrChanges, xorChanges } = pending.consume();
|
|
71465
|
+
// Merge incr changes
|
|
71466
|
+
for (const [key, value] of Object.entries(incrChanges)) {
|
|
71467
|
+
this.incrCompoundKey(key, value);
|
|
71468
|
+
}
|
|
71469
|
+
// Merge xor changes
|
|
71470
|
+
for (const [key, value] of Object.entries(xorChanges)) {
|
|
71471
|
+
this.xor(key, value);
|
|
71472
|
+
}
|
|
71473
|
+
}
|
|
71474
|
+
}
|
|
71475
|
+
exports.StatsPending = StatsPending;
|
|
71476
|
+
class Stats extends StatsPending {
|
|
71408
71477
|
constructor(config) {
|
|
71409
|
-
|
|
71410
|
-
_Stats_localDBIncr.set(this, {});
|
|
71411
|
-
_Stats_localDBXOR.set(this, {});
|
|
71478
|
+
super();
|
|
71412
71479
|
_Stats_syncPromise.set(this, void 0);
|
|
71413
71480
|
_Stats_kv.set(this, void 0);
|
|
71414
71481
|
let kv = config.kv;
|
|
@@ -71451,22 +71518,6 @@ class Stats {
|
|
|
71451
71518
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
71452
71519
|
return ret;
|
|
71453
71520
|
}
|
|
71454
|
-
incr(arena, key, change = 1) {
|
|
71455
|
-
const compoundKey = __classPrivateFieldGet(this, _Stats_instances, "m", _Stats_compoundKey).call(this, arena, key);
|
|
71456
|
-
if (__classPrivateFieldGet(this, _Stats_localDBIncr, "f")[compoundKey] === undefined) {
|
|
71457
|
-
__classPrivateFieldGet(this, _Stats_localDBIncr, "f")[compoundKey] = 0;
|
|
71458
|
-
}
|
|
71459
|
-
__classPrivateFieldGet(this, _Stats_localDBIncr, "f")[compoundKey] += change;
|
|
71460
|
-
}
|
|
71461
|
-
xor(key, change) {
|
|
71462
|
-
const changeValue = change.toBigInt();
|
|
71463
|
-
const existingValue = __classPrivateFieldGet(this, _Stats_localDBXOR, "f")[key];
|
|
71464
|
-
if (existingValue === undefined) {
|
|
71465
|
-
__classPrivateFieldGet(this, _Stats_localDBXOR, "f")[key] = changeValue;
|
|
71466
|
-
return;
|
|
71467
|
-
}
|
|
71468
|
-
__classPrivateFieldGet(this, _Stats_localDBXOR, "f")[key] ^= changeValue;
|
|
71469
|
-
}
|
|
71470
71521
|
async getXor(key) {
|
|
71471
71522
|
await __classPrivateFieldGet(this, _Stats_syncPromise, "f");
|
|
71472
71523
|
const bufferKey = `@buffer:${key}`;
|
|
@@ -71476,8 +71527,8 @@ class Stats {
|
|
|
71476
71527
|
base = BigInt(`0x${baseString}`);
|
|
71477
71528
|
}
|
|
71478
71529
|
let local = 0n;
|
|
71479
|
-
if (
|
|
71480
|
-
local =
|
|
71530
|
+
if (this.localDBXOR[key] !== undefined) {
|
|
71531
|
+
local = this.localDBXOR[key];
|
|
71481
71532
|
}
|
|
71482
71533
|
const computed = base ^ local;
|
|
71483
71534
|
const retval = new buffer_1.BufferStorage(computed, XOR_BUFFER_SIZE);
|
|
@@ -71503,7 +71554,7 @@ class Stats {
|
|
|
71503
71554
|
}
|
|
71504
71555
|
async get(arena, key) {
|
|
71505
71556
|
await __classPrivateFieldGet(this, _Stats_syncPromise, "f");
|
|
71506
|
-
const compoundKey =
|
|
71557
|
+
const compoundKey = this.compoundKey(arena, key);
|
|
71507
71558
|
let base = await __classPrivateFieldGet(this, _Stats_kv, "f").get('stats', compoundKey);
|
|
71508
71559
|
if (base === undefined) {
|
|
71509
71560
|
base = 0;
|
|
@@ -71515,8 +71566,8 @@ class Stats {
|
|
|
71515
71566
|
throw (new Error('internal error: corrupt data in stats table'));
|
|
71516
71567
|
}
|
|
71517
71568
|
let local = 0;
|
|
71518
|
-
if (
|
|
71519
|
-
local =
|
|
71569
|
+
if (this.localDBIncr[compoundKey] !== undefined) {
|
|
71570
|
+
local = this.localDBIncr[compoundKey];
|
|
71520
71571
|
}
|
|
71521
71572
|
return (base + local);
|
|
71522
71573
|
}
|
|
@@ -71544,20 +71595,17 @@ class Stats {
|
|
|
71544
71595
|
return (retval);
|
|
71545
71596
|
}
|
|
71546
71597
|
async sync() {
|
|
71547
|
-
const
|
|
71548
|
-
const localDBXOR = Object.entries(__classPrivateFieldGet(this, _Stats_localDBXOR, "f"));
|
|
71549
|
-
__classPrivateFieldSet(this, _Stats_localDBIncr, {}, "f");
|
|
71550
|
-
__classPrivateFieldSet(this, _Stats_localDBXOR, {}, "f");
|
|
71598
|
+
const { incrChanges, xorChanges } = this.consume();
|
|
71551
71599
|
await __classPrivateFieldGet(this, _Stats_syncPromise, "f");
|
|
71552
71600
|
__classPrivateFieldSet(this, _Stats_syncPromise, (async () => {
|
|
71553
71601
|
const updatePromises = [];
|
|
71554
|
-
for (const [key, value] of
|
|
71602
|
+
for (const [key, value] of Object.entries(incrChanges)) {
|
|
71555
71603
|
if (value === undefined) {
|
|
71556
71604
|
continue;
|
|
71557
71605
|
}
|
|
71558
71606
|
updatePromises.push(__classPrivateFieldGet(this, _Stats_kv, "f").incr('stats', key, value));
|
|
71559
71607
|
}
|
|
71560
|
-
for (const [key, value] of
|
|
71608
|
+
for (const [key, value] of Object.entries(xorChanges)) {
|
|
71561
71609
|
if (value === undefined) {
|
|
71562
71610
|
continue;
|
|
71563
71611
|
}
|
|
@@ -71572,10 +71620,7 @@ class Stats {
|
|
|
71572
71620
|
}
|
|
71573
71621
|
}
|
|
71574
71622
|
exports.Stats = Stats;
|
|
71575
|
-
_a = Stats,
|
|
71576
|
-
const compoundKey = [arena, key].join('|');
|
|
71577
|
-
return (compoundKey);
|
|
71578
|
-
}, _Stats_assertDurationBreakdowns = function _Stats_assertDurationBreakdowns(durations) {
|
|
71623
|
+
_a = Stats, _Stats_syncPromise = new WeakMap(), _Stats_kv = new WeakMap(), _Stats_assertDurationBreakdowns = function _Stats_assertDurationBreakdowns(durations) {
|
|
71579
71624
|
for (const duration of durations) {
|
|
71580
71625
|
this.assertDurationBreakdown(duration);
|
|
71581
71626
|
}
|
|
@@ -71637,7 +71682,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
71637
71682
|
};
|
|
71638
71683
|
var _ValidateASN1_schema, _BufferStorageASN1_data;
|
|
71639
71684
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
71640
|
-
exports._Testing = exports.ASN1BigIntToBuffer = exports.ASN1IntegerToBigInt = exports.JStoASN1 = exports.ASN1toJS = exports.BufferStorageASN1 = exports.ValidateASN1 = exports.asn1 = void 0;
|
|
71685
|
+
exports._Testing = exports.ASN1BigIntToBuffer = exports.ASN1IntegerToBigInt = exports.JStoASN1 = exports.ASN1toJS = exports.BufferStorageASN1 = exports.ValidateASN1 = exports.ASN1CheckUtilities = exports.asn1 = void 0;
|
|
71641
71686
|
exports.isASN1Object = isASN1Object;
|
|
71642
71687
|
exports.isValidSequenceSchema = isValidSequenceSchema;
|
|
71643
71688
|
const asn1js = __importStar(__webpack_require__(7813));
|
|
@@ -71768,7 +71813,16 @@ function isASN1Set(input) {
|
|
|
71768
71813
|
}
|
|
71769
71814
|
return (true);
|
|
71770
71815
|
}
|
|
71771
|
-
function
|
|
71816
|
+
function isASN1ContextTagKind(input) {
|
|
71817
|
+
if (typeof input !== 'string') {
|
|
71818
|
+
return (false);
|
|
71819
|
+
}
|
|
71820
|
+
if (!(['explicit', 'implicit'].includes(input))) {
|
|
71821
|
+
return (false);
|
|
71822
|
+
}
|
|
71823
|
+
return (true);
|
|
71824
|
+
}
|
|
71825
|
+
function isASN1ContextTag(input, tagKind) {
|
|
71772
71826
|
if (!isASN1Object(input)) {
|
|
71773
71827
|
return (false);
|
|
71774
71828
|
}
|
|
@@ -71781,6 +71835,12 @@ function isASN1ContextTag(input) {
|
|
|
71781
71835
|
if (!('contains' in input) || input.contains === undefined) {
|
|
71782
71836
|
return (false);
|
|
71783
71837
|
}
|
|
71838
|
+
if (!('kind' in input) || !isASN1ContextTagKind(input.kind)) {
|
|
71839
|
+
return (false);
|
|
71840
|
+
}
|
|
71841
|
+
if (tagKind !== undefined && input.kind !== tagKind) {
|
|
71842
|
+
return (false);
|
|
71843
|
+
}
|
|
71784
71844
|
return (true);
|
|
71785
71845
|
}
|
|
71786
71846
|
function isASN1BitString(input) {
|
|
@@ -71837,6 +71897,15 @@ function isStringValidForKind(input, kind) {
|
|
|
71837
71897
|
}
|
|
71838
71898
|
return (false);
|
|
71839
71899
|
}
|
|
71900
|
+
exports.ASN1CheckUtilities = {
|
|
71901
|
+
isASN1Object,
|
|
71902
|
+
isASN1OID,
|
|
71903
|
+
isASN1String,
|
|
71904
|
+
isASN1Set,
|
|
71905
|
+
isASN1ContextTag,
|
|
71906
|
+
isASN1BitString,
|
|
71907
|
+
isASN1Date
|
|
71908
|
+
};
|
|
71840
71909
|
/**
|
|
71841
71910
|
* Checks if an ASN.1 sequence is valid based on a provided validation schema.
|
|
71842
71911
|
*/
|
|
@@ -73318,7 +73387,7 @@ class CertificateBuilder {
|
|
|
73318
73387
|
case 'sha3-256':
|
|
73319
73388
|
return (hashLib.name);
|
|
73320
73389
|
default:
|
|
73321
|
-
throw (new Error(`Unsupported hash algorithm "${hashLib.name}"`));
|
|
73390
|
+
throw (new Error(`internal error: Unsupported hash algorithm "${hashLib.name}"`));
|
|
73322
73391
|
}
|
|
73323
73392
|
}
|
|
73324
73393
|
const hashName = params.hashParams?.defaults?.[purpose] ?? defaultHashName;
|
|
@@ -73337,7 +73406,7 @@ class CertificateBuilder {
|
|
|
73337
73406
|
const hashName = this.hashName(params, purpose);
|
|
73338
73407
|
const hashFunction = params.hashParams.functions?.[hashName];
|
|
73339
73408
|
if (hashFunction === undefined) {
|
|
73340
|
-
throw (new Error(`Hash function "${hashName}" not found for purpose "${purpose}"`));
|
|
73409
|
+
throw (new Error(`internal error: Hash function "${hashName}" not found for purpose "${purpose}"`));
|
|
73341
73410
|
}
|
|
73342
73411
|
return (hashFunction(...data));
|
|
73343
73412
|
}
|
|
@@ -73461,28 +73530,28 @@ class CertificateBuilder {
|
|
|
73461
73530
|
/* Validate that required parameters are set */
|
|
73462
73531
|
const issuer = finalParams.issuer;
|
|
73463
73532
|
if (issuer === undefined) {
|
|
73464
|
-
throw (new
|
|
73533
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"issuer" not set'));
|
|
73465
73534
|
}
|
|
73466
73535
|
const subjectPublicKey = finalParams.subjectPublicKey;
|
|
73467
73536
|
if (subjectPublicKey === undefined) {
|
|
73468
|
-
throw (new
|
|
73537
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"subject" not set'));
|
|
73469
73538
|
}
|
|
73470
73539
|
const validFrom = finalParams.validFrom;
|
|
73471
73540
|
if (validFrom === undefined) {
|
|
73472
|
-
throw (new
|
|
73541
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"validFrom" not set'));
|
|
73473
73542
|
}
|
|
73474
73543
|
const validTo = finalParams.validTo;
|
|
73475
73544
|
if (validTo === undefined) {
|
|
73476
|
-
throw (new
|
|
73545
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"validTo" not set'));
|
|
73477
73546
|
}
|
|
73478
73547
|
const serial = finalParams.serial;
|
|
73479
73548
|
if (serial === undefined) {
|
|
73480
|
-
throw (new
|
|
73549
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"serialNumber" not set'));
|
|
73481
73550
|
}
|
|
73482
73551
|
const hashLib = finalParams.hashLib;
|
|
73483
73552
|
const hashParams = finalParams.hashParams;
|
|
73484
73553
|
if (hashParams === undefined) {
|
|
73485
|
-
throw (new
|
|
73554
|
+
throw (new certificate_1.default('CERTIFICATE_MISSING_FIELD', '"hashParams" not set'));
|
|
73486
73555
|
}
|
|
73487
73556
|
return ({
|
|
73488
73557
|
...finalParams,
|
|
@@ -73796,7 +73865,7 @@ class Certificate {
|
|
|
73796
73865
|
const tbsCertificate = parts[0];
|
|
73797
73866
|
const [version, serialNumber, signatureAlgorithmSigned, issuer, [notBefore, notAfter], subject, subjectPublicKey, extensions] = tbsCertificate;
|
|
73798
73867
|
if (version.contains !== 2n) {
|
|
73799
|
-
throw (new
|
|
73868
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_VERSION', 'Only X509v3 certificates are supported'));
|
|
73800
73869
|
}
|
|
73801
73870
|
const signatureAlgorithm = parts[1];
|
|
73802
73871
|
/**
|
|
@@ -73836,7 +73905,7 @@ class Certificate {
|
|
|
73836
73905
|
const signatureAlgorithmSignedBuffer = new ASN1.BufferStorageASN1(signatureAlgorithmSigned).getDERBuffer();
|
|
73837
73906
|
const signatureAlgorithmBuffer = new ASN1.BufferStorageASN1(signatureAlgorithm).getDERBuffer();
|
|
73838
73907
|
if (!signatureAlgorithmSignedBuffer.equals(signatureAlgorithmBuffer)) {
|
|
73839
|
-
throw (new
|
|
73908
|
+
throw (new certificate_1.default('CERTIFICATE_SIGNATURE_ALGORITHM_MISMATCH', 'Signature algorithm mismatch between signature and certificate'));
|
|
73840
73909
|
}
|
|
73841
73910
|
/*
|
|
73842
73911
|
* Process the extensions base extensions, which can be critical for
|
|
@@ -73866,7 +73935,7 @@ class Certificate {
|
|
|
73866
73935
|
}
|
|
73867
73936
|
});
|
|
73868
73937
|
if (!found) {
|
|
73869
|
-
throw (new
|
|
73938
|
+
throw (new certificate_1.default('CERTIFICATE_SELF_SIGNED_VALIDATION_FAILED', 'Self-signed certificate is not a root CA in the Root CA store'));
|
|
73870
73939
|
}
|
|
73871
73940
|
this.chain = [this];
|
|
73872
73941
|
}
|
|
@@ -73875,7 +73944,7 @@ class Certificate {
|
|
|
73875
73944
|
this.chain = [this];
|
|
73876
73945
|
}
|
|
73877
73946
|
if (!this.verify(this)) {
|
|
73878
|
-
throw (new
|
|
73947
|
+
throw (new certificate_1.default('CERTIFICATE_SELF_SIGNED_VALIDATION_FAILED', 'Self-signed certificate signature verification failed'));
|
|
73879
73948
|
}
|
|
73880
73949
|
}
|
|
73881
73950
|
else {
|
|
@@ -73885,7 +73954,7 @@ class Certificate {
|
|
|
73885
73954
|
if (options?.store !== undefined) {
|
|
73886
73955
|
const chain = this.verifyChain(options.store);
|
|
73887
73956
|
if (chain === null || chain.length === 0) {
|
|
73888
|
-
throw (new
|
|
73957
|
+
throw (new certificate_1.default('CERTIFICATE_CHAIN_VERIFICATION_FAILED', 'Certificate chain verification failed'));
|
|
73889
73958
|
}
|
|
73890
73959
|
this.chain = chain;
|
|
73891
73960
|
}
|
|
@@ -73950,7 +74019,7 @@ class Certificate {
|
|
|
73950
74019
|
compatibleKeyTypes = [account_1.default.AccountKeyAlgorithm.ED25519];
|
|
73951
74020
|
break;
|
|
73952
74021
|
default:
|
|
73953
|
-
throw (new
|
|
74022
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_SIGNATURE_ALGORITHM', `Unsupported signature algorithm ${signatureAlgorithm}`));
|
|
73954
74023
|
}
|
|
73955
74024
|
let hashAlgorithm;
|
|
73956
74025
|
switch (signatureAlgorithm) {
|
|
@@ -73964,7 +74033,7 @@ class Certificate {
|
|
|
73964
74033
|
hashAlgorithm = null;
|
|
73965
74034
|
break;
|
|
73966
74035
|
default:
|
|
73967
|
-
throw (new
|
|
74036
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_SIGNATURE_ALGORITHM', `Unsupported signature algorithm ${signatureAlgorithm}`));
|
|
73968
74037
|
}
|
|
73969
74038
|
let accountIsCompatible = false;
|
|
73970
74039
|
for (const checkCompatibleKeyType of compatibleKeyTypes) {
|
|
@@ -73974,7 +74043,7 @@ class Certificate {
|
|
|
73974
74043
|
}
|
|
73975
74044
|
}
|
|
73976
74045
|
if (!accountIsCompatible) {
|
|
73977
|
-
throw (new
|
|
74046
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_SIGNATURE_ALGORITHM', `Account does not have a compatible key type for signature algorithm ${signatureAlgorithm}`));
|
|
73978
74047
|
}
|
|
73979
74048
|
let dataToVerify;
|
|
73980
74049
|
if (hashAlgorithm !== null) {
|
|
@@ -74001,7 +74070,7 @@ class Certificate {
|
|
|
74001
74070
|
return (true);
|
|
74002
74071
|
}
|
|
74003
74072
|
if (certificates.size > 10) {
|
|
74004
|
-
throw (new
|
|
74073
|
+
throw (new certificate_1.default('CERTIFICATE_INVALID_GRAPH_COUNT', 'Cannot currently handle more than 10 certificates in a graph'));
|
|
74005
74074
|
}
|
|
74006
74075
|
const issuersFrom = [];
|
|
74007
74076
|
const issuersTo = [];
|
|
@@ -74114,7 +74183,7 @@ class Certificate {
|
|
|
74114
74183
|
assertValid(moment) {
|
|
74115
74184
|
const valid = this.checkValid(moment, true);
|
|
74116
74185
|
if (!valid.valid) {
|
|
74117
|
-
throw (new
|
|
74186
|
+
throw (new certificate_1.default('CERTIFICATE_MOMENT_INVALID', `Certificate is not valid: ${valid.reason}`));
|
|
74118
74187
|
}
|
|
74119
74188
|
}
|
|
74120
74189
|
checkIssued(issuer, reason) {
|
|
@@ -74179,7 +74248,7 @@ class Certificate {
|
|
|
74179
74248
|
}
|
|
74180
74249
|
assertConstructed() {
|
|
74181
74250
|
if (!__classPrivateFieldGet(this, _Certificate_finalizeConstructionCalled, "f")) {
|
|
74182
|
-
throw (new Error('finalizeConstruction not called'));
|
|
74251
|
+
throw (new Error('internal error: finalizeConstruction not called'));
|
|
74183
74252
|
}
|
|
74184
74253
|
}
|
|
74185
74254
|
/**
|
|
@@ -74310,7 +74379,7 @@ _Certificate_raw = new WeakMap(), _Certificate_hash = new WeakMap(), _Certificat
|
|
|
74310
74379
|
for (const extension of extensions) {
|
|
74311
74380
|
const id = extension[0].oid;
|
|
74312
74381
|
if (seenExtensions.has(id)) {
|
|
74313
|
-
throw (new
|
|
74382
|
+
throw (new certificate_1.default('CERTIFICATE_DUPLICATE_EXTENSION', `Duplicate extension ${id}`));
|
|
74314
74383
|
}
|
|
74315
74384
|
seenExtensions.add(id);
|
|
74316
74385
|
}
|
|
@@ -74365,7 +74434,7 @@ _Certificate_raw = new WeakMap(), _Certificate_hash = new WeakMap(), _Certificat
|
|
|
74365
74434
|
[id] = extension;
|
|
74366
74435
|
}
|
|
74367
74436
|
if (critical && !__classPrivateFieldGet(this, _Certificate_extensionsProcessed, "f").has(id.oid)) {
|
|
74368
|
-
throw (new
|
|
74437
|
+
throw (new certificate_1.default('CERTIFICATE_EXTENSION_NOT_PROCESSED', `Critical extension ${id.oid} not processed`));
|
|
74369
74438
|
}
|
|
74370
74439
|
}
|
|
74371
74440
|
}, _Certificate_checkValid = function _Certificate_checkValid(moment) {
|
|
@@ -77346,7 +77415,7 @@ exports.Testing = { findRDN, blockHashesFromVote, feeFromVote };
|
|
|
77346
77415
|
|
|
77347
77416
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
77348
77417
|
exports.version = void 0;
|
|
77349
|
-
exports.version = '0.14.
|
|
77418
|
+
exports.version = '0.14.2+g68f40cc8d6fed6135fa06451bd1fb0691868e25f';
|
|
77350
77419
|
exports["default"] = exports.version;
|
|
77351
77420
|
|
|
77352
77421
|
|