@keetanetwork/keetanet-client 0.14.5 → 0.14.7

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.
Files changed (185) hide show
  1. package/README.md +1 -1
  2. package/api/index.d.ts +7 -0
  3. package/api/node.d.ts +8 -0
  4. package/client/client_common_tests.d.ts +8 -0
  5. package/client/index-browser.d.ts +17 -3
  6. package/client/index-browser.js +1011 -138
  7. package/client/index.d.ts +17 -3
  8. package/client/index.js +2266 -155
  9. package/config/index.d.ts +3 -0
  10. package/docs/GETTING-STARTED.md +3 -3
  11. package/docs/assets/hierarchy.js +1 -1
  12. package/docs/assets/navigation.js +1 -1
  13. package/docs/assets/search.js +1 -1
  14. package/docs/classes/KeetaNetSDK.Client.html +8 -4
  15. package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
  16. package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
  17. package/docs/classes/KeetaNetSDK.Referenced.Block.html +3 -2
  18. package/docs/classes/KeetaNetSDK.Referenced.BlockBuilder.html +2 -1
  19. package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +2 -2
  20. package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
  21. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
  22. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
  23. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
  24. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
  25. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
  26. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
  27. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
  28. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  29. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  30. package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
  31. package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
  32. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
  33. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
  34. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
  35. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
  36. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
  37. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
  38. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
  39. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
  40. package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
  41. package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
  42. package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
  43. package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
  44. package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
  45. package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
  46. package/docs/classes/KeetaNetSDK.Referenced.IdempotentKey.html +17 -0
  47. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
  48. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
  49. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +4 -4
  50. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +1 -1
  51. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +1 -1
  52. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerIdempotentKeyError.html +12 -0
  53. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +1 -1
  54. package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
  55. package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
  56. package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +4 -2
  57. package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +3 -1
  58. package/docs/classes/KeetaNetSDK.Referenced.Log.html +40 -0
  59. package/docs/classes/KeetaNetSDK.Referenced.LogTargetConsole.html +5 -0
  60. package/docs/classes/KeetaNetSDK.Referenced.Node.html +1 -1
  61. package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
  62. package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
  63. package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
  64. package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
  65. package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
  66. package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
  67. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +2 -2
  68. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +1 -1
  69. package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
  70. package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +1 -1
  71. package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
  72. package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +1 -1
  73. package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
  74. package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +2 -2
  75. package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
  76. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
  77. package/docs/classes/KeetaNetSDK.UserClient.html +9 -5
  78. package/docs/documents/GETTING-STARTED.html +3 -3
  79. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_helper.validateBase64ToBuffer.html +1 -0
  80. package/docs/hierarchy.html +1 -1
  81. package/docs/index.html +1 -1
  82. package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
  83. package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
  84. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
  85. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
  86. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
  87. package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
  88. package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +3 -2
  89. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
  90. package/docs/interfaces/KeetaNetSDK.Referenced.BaseTokenInfo.html +3 -2
  91. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
  92. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
  93. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
  94. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +1 -1
  95. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
  96. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
  97. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
  98. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
  99. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
  100. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  101. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  102. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +3 -2
  103. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1JSON.html +3 -2
  104. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1UnsignedCanonical.html +3 -2
  105. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +3 -2
  106. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2JSON.html +3 -2
  107. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2UnsignedCanonical.html +3 -2
  108. package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
  109. package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
  110. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
  111. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
  112. package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +3 -2
  113. package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
  114. package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
  115. package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
  116. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerConfig.html +2 -2
  117. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +4 -2
  118. package/docs/interfaces/KeetaNetSDK.Referenced.LogTarget.html +4 -0
  119. package/docs/interfaces/KeetaNetSDK.Referenced.Logger.html +6 -0
  120. package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
  121. package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
  122. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
  123. package/docs/interfaces/KeetaNetSDK.Referenced.NodeConfig.html +4 -2
  124. package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
  125. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
  126. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
  127. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
  128. package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
  129. package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
  130. package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
  131. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
  132. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
  133. package/docs/interfaces/KeetaNetSDK.Referenced.VoteStapleJSON.html +2 -2
  134. package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
  135. package/docs/interfaces/KeetaNetSDK.Referenced.src_config.ValidationConfig.html +3 -2
  136. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
  137. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
  138. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
  139. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
  140. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
  141. package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
  142. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_helper.html +1 -1
  143. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_initial.html +1 -1
  144. package/docs/types/KeetaNetSDK.Referenced.AccountInfoResponse.html +3 -2
  145. package/docs/types/KeetaNetSDK.Referenced.IdempotentKeyString.html +1 -0
  146. package/docs/types/KeetaNetSDK.Referenced.LedgerIdempotentKeyErrorCode.html +1 -0
  147. package/docs/types/KeetaNetSDK.Referenced.LogCurrentRequest.html +2 -0
  148. package/docs/types/KeetaNetSDK.Referenced.LogEntry.html +6 -0
  149. package/docs/types/KeetaNetSDK.Referenced.LogLevel.html +1 -0
  150. package/docs/types/KeetaNetSDK.Referenced.LogOptions.html +4 -0
  151. package/docs/types/KeetaNetSDK.Referenced.LogTargetConsoleConfig.html +4 -0
  152. package/docs/types/KeetaNetSDK.Referenced.LogTargetID.html +1 -0
  153. package/docs/types/KeetaNetSDK.Referenced.LogTargetLevel.html +1 -0
  154. package/docs/types/KeetaNetSDK.Referenced.src_config.NetworkConfig.html +1 -1
  155. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_initial.BaseNetworkInfo.html +1 -0
  156. package/docs/variables/KeetaNetSDK.Referenced.FullLedgerIdempotentKeyErrorCodes.html +1 -0
  157. package/docs/variables/KeetaNetSDK.Referenced.allFullErrorCodes.html +1 -1
  158. package/docs/variables/KeetaNetSDK.lib.html +2 -2
  159. package/lib/block/index.d.ts +38 -24
  160. package/lib/error/block.d.ts +2 -2
  161. package/lib/error/index.d.ts +5 -4
  162. package/lib/error/ledger.d.ts +30 -2
  163. package/lib/index.d.ts +2 -0
  164. package/lib/kv/kv_redis.d.ts +3 -2
  165. package/lib/ledger/db_dynamodb.d.ts +2 -1
  166. package/lib/ledger/db_postgres.d.ts +2 -1
  167. package/lib/ledger/db_spanner.d.ts +2 -1
  168. package/lib/ledger/db_spanner_helper.d.ts +18 -2
  169. package/lib/ledger/db_sqlite.d.ts +3 -2
  170. package/lib/ledger/index.d.ts +27 -1
  171. package/lib/log/common.d.ts +39 -0
  172. package/lib/log/helper.generated.d.ts +9 -0
  173. package/lib/log/index.d.ts +102 -0
  174. package/lib/log/target_console.d.ts +14 -0
  175. package/lib/log/target_gcp.d.ts +20 -0
  176. package/lib/log/target_gcp.js +469 -0
  177. package/lib/node/index.d.ts +6 -4
  178. package/lib/utils/helper.d.ts +1 -1
  179. package/lib/utils/initial.d.ts +5 -0
  180. package/lib/vote.d.ts +1 -0
  181. package/npm-shrinkwrap.json +1145 -29
  182. package/package.json +3 -2
  183. package/version.d.ts +1 -1
  184. package/benchmarking/test.d.ts +0 -4
  185. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_helper.internalLogger.html +0 -1
@@ -92151,6 +92151,59 @@ module.exports = function typedarrayToBuffer (arr) {
92151
92151
  }
92152
92152
 
92153
92153
 
92154
+ /***/ }),
92155
+
92156
+ /***/ 8659:
92157
+ /***/ ((__unused_webpack_module, exports) => {
92158
+
92159
+ "use strict";
92160
+
92161
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
92162
+ exports.TypeGuardError = void 0;
92163
+ class TypeGuardError extends Error {
92164
+ constructor(props) {
92165
+ // MESSAGE CONSTRUCTION
92166
+ super(props.message ||
92167
+ `Error on ${props.method}(): invalid type${props.path ? ` on ${props.path}` : ""}, expect to be ${props.expected}`);
92168
+ // INHERITANCE POLYFILL
92169
+ const proto = new.target.prototype;
92170
+ if (Object.setPrototypeOf)
92171
+ Object.setPrototypeOf(this, proto);
92172
+ else
92173
+ this.__proto__ = proto;
92174
+ // ASSIGN MEMBERS
92175
+ this.method = props.method;
92176
+ this.path = props.path;
92177
+ this.expected = props.expected;
92178
+ this.value = props.value;
92179
+ }
92180
+ }
92181
+ exports.TypeGuardError = TypeGuardError;
92182
+ //# sourceMappingURL=TypeGuardError.js.map
92183
+
92184
+ /***/ }),
92185
+
92186
+ /***/ 7422:
92187
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
92188
+
92189
+ "use strict";
92190
+ var __webpack_unused_export__;
92191
+
92192
+ __webpack_unused_export__ = ({ value: true });
92193
+ exports.v = void 0;
92194
+ const TypeGuardError_1 = __webpack_require__(8659);
92195
+ const _assertGuard = (exceptionable, props, factory) => {
92196
+ if (exceptionable === true) {
92197
+ if (factory)
92198
+ throw factory(props);
92199
+ else
92200
+ throw new TypeGuardError_1.TypeGuardError(props);
92201
+ }
92202
+ return false;
92203
+ };
92204
+ exports.v = _assertGuard;
92205
+ //# sourceMappingURL=_assertGuard.js.map
92206
+
92154
92207
  /***/ }),
92155
92208
 
92156
92209
  /***/ 4643:
@@ -101182,7 +101235,6 @@ __webpack_require__.d(client_helper_namespaceObject, {
101182
101235
  crypto: () => (client_helper_crypto),
101183
101236
  debugPrintableObject: () => (client_debugPrintableObject),
101184
101237
  env: () => (client_env),
101185
- internalLogger: () => (client_internalLogger),
101186
101238
  isBuffer: () => (client_isBuffer),
101187
101239
  isIntegerOrBigInt: () => (client_isIntegerOrBigInt),
101188
101240
  nonNullable: () => (client_nonNullable),
@@ -101191,6 +101243,7 @@ __webpack_require__.d(client_helper_namespaceObject, {
101191
101243
  randomInt: () => (client_randomInt),
101192
101244
  randomString: () => (client_randomString),
101193
101245
  setGenerator: () => (client_setGenerator),
101246
+ validateBase64ToBuffer: () => (client_validateBase64ToBuffer),
101194
101247
  waitTicks: () => (client_waitTicks)
101195
101248
  });
101196
101249
 
@@ -105388,9 +105441,9 @@ function client_v4(options, buf, offset) {
105388
105441
  /* harmony default export */ const client_esm_browser_v4 = (client_v4);
105389
105442
 
105390
105443
  ;// ./src/lib/utils/helper.ts
105391
- /* provided dependency */ var client_process = __webpack_require__(5606);
105392
105444
  /* provided dependency */ var src_client_Buffer = __webpack_require__(8287)["Buffer"];
105393
- var client_process$env$KEETANET, client_process$env$KEETANET2, client_ref, client_global$AsyncDisposab;
105445
+ /* provided dependency */ var client_process = __webpack_require__(5606);
105446
+ var client_ref, client_global$AsyncDisposab;
105394
105447
  function src_client_classPrivateFieldSet(s, a, r) { return s.set(src_client_assertClassBrand(s, a), r), r; }
105395
105448
  function src_client_classPrivateMethodInitSpec(e, a) { src_client_checkPrivateRedeclaration(e, a), a.add(e); }
105396
105449
  function src_client_defineProperty_0(e, r, t) { return (r = src_client_toPropertyKey_0(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -105404,13 +105457,17 @@ function src_client_assertClassBrand(e, t, n) { if ("function" == typeof e ? e =
105404
105457
 
105405
105458
 
105406
105459
 
105407
- const client_loggingLevels = ['debug', 'error'];
105408
- const client_configuredLoggingLevel = (client_process$env$KEETANET = client_process.env['KEETANET_DEBUG']) === null || client_process$env$KEETANET === void 0 ? void 0 : client_process$env$KEETANET.toLowerCase();
105409
- const client_configuredLoggingFilter = new RegExp((client_process$env$KEETANET2 = client_process.env['KEETANET_DEBUG_FILTER']) !== null && client_process$env$KEETANET2 !== void 0 ? client_process$env$KEETANET2 : '', 'i');
105410
105460
  const client_helper_randomBytes = client_crypto_default().randomBytes.bind((client_crypto_default()));
105411
105461
  const client_helper_randomUUID = (client_crypto_default()).randomUUID ? client_crypto_default().randomUUID.bind((client_crypto_default())) : function () {
105412
105462
  return client_esm_browser_v4();
105413
105463
  };
105464
+ function client_validateBase64ToBuffer(input) {
105465
+ const buffer = src_client_Buffer.from(input, 'base64');
105466
+ if (input !== buffer.toString('base64')) {
105467
+ throw new Error('Could Not Decode base64 String');
105468
+ }
105469
+ return buffer;
105470
+ }
105414
105471
  function client_bufferToArrayBuffer(input) {
105415
105472
  const out = new ArrayBuffer(input.length);
105416
105473
  const view = new Uint8Array(out);
@@ -105634,48 +105691,6 @@ function client_convertToJSON(_ignore_key, item) {
105634
105691
  }
105635
105692
  return item;
105636
105693
  }
105637
- function client_internalLogger(nodeAlias, level, from) {
105638
- /**
105639
- * Disable logging unless specified
105640
- */
105641
- if (client_configuredLoggingLevel === undefined) {
105642
- return;
105643
- }
105644
-
105645
- /**
105646
- * Only log matching sources
105647
- */
105648
- if (!client_configuredLoggingFilter.test(from)) {
105649
- return;
105650
- }
105651
- const configuredLoggingLevelValue = client_loggingLevels.indexOf(client_configuredLoggingLevel);
105652
- const levelValue = client_loggingLevels.indexOf(level);
105653
- /**
105654
- * Do not log anything if desired log level is higher than logged message
105655
- */
105656
- if (configuredLoggingLevelValue > levelValue) {
105657
- return;
105658
- }
105659
- if (nodeAlias === undefined) {
105660
- nodeAlias = '<unnamed node>';
105661
- }
105662
- let logger;
105663
- switch (level) {
105664
- case 'debug':
105665
- logger = console.debug;
105666
- break;
105667
- case 'error':
105668
- logger = console.error;
105669
- break;
105670
- }
105671
- if (logger === undefined) {
105672
- return;
105673
- }
105674
- for (var _len = arguments.length, message = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
105675
- message[_key - 3] = arguments[_key];
105676
- }
105677
- logger(`[${nodeAlias}/${from.toUpperCase()}]`, ...message);
105678
- }
105679
105694
  function client_objectToBuffer(input) {
105680
105695
  const stringified = JSON.stringify(input, client_convertToJSON);
105681
105696
  return src_client_Buffer.from(stringified);
@@ -114359,6 +114374,9 @@ const client_baseValidationConfig = {
114359
114374
  regex: /^[-_A-Za-z0-9+/= ]+$/,
114360
114375
  canBeEmpty: true
114361
114376
  }
114377
+ },
114378
+ idempotentKey: {
114379
+ maxByteLength: 32
114362
114380
  }
114363
114381
  };
114364
114382
  function client_getNetworkAlias(networkOrID) {
@@ -115205,7 +115223,7 @@ function client_block_toPrimitive(t, r) { if ("object" != typeof t || !t) return
115205
115223
 
115206
115224
 
115207
115225
  const client_BlockErrorType = 'BLOCK';
115208
- const client_BlockErrorCodes = ['INVALID_TYPE', 'INVALID_VERSION', 'NO_MULTIPLE_SET_REP', 'IDENTIFIER_NEED_DEFAULT_PERMISSIONS', 'CANNOT_SEND_NON_TOKEN', 'TOKEN_RECEIVE_DIFFERS', 'ONLY_TOKEN_OP', 'ONLY_IDENTIFIER_OP', 'NO_TOKEN_OP', 'NO_IDENTIFIER_OP', 'INVALID_SIGNER', 'INVALID_PURPOSE_VALIDATION', 'INVALID_MULTISIG_QUORUM', 'INVALID_MULTISIG_SIGNER_DEPTH', 'INVALID_MULTISIG_SIGNER_COUNT', 'INVALID_MULTISIG_SIGNER_DUPLICATE', 'INVALID_CREATE_IDENTIFIER_ARGS', 'NO_MULTISIG_OP', 'IDENTIFIER_INVALID', 'GENERAL_FIELD_INVALID', 'PERMISSIONS_INVALID_DEFAULT', 'PERMISSIONS_INVALID_ENTITY', 'PERMISSIONS_INVALID_PRINCIPAL', 'PERMISSIONS_INVALID_TARGET', 'INVALID_ACCOUNT_TYPE', 'NO_ADMIN_ON_TARGET', 'PREVIOUS_SELF', 'NO_DELEGATE_ADMIN', 'NO_MODIFY_PERMISSION_DUPE', 'CANNOT_FORWARD_TO_SELF', 'EXACT_TRUE_WHEN_FORWARDING', 'CERTIFICATE_SUBJECT_MISMATCH', 'NO_DUPLICATE_CERTIFICATE_OPERATION', 'INTERMEDIATE_CERTIFICATES_ONLY_ADD', 'INVALID_CERTIFICATE_VALUE', 'EXTERNAL_TOO_LONG', 'EXTERNAL_INVALID', 'EXTERNAL_MISSING', 'SUPPLY_INVALID'];
115226
+ const client_BlockErrorCodes = ['INVALID_TYPE', 'INVALID_VERSION', 'NO_MULTIPLE_SET_REP', 'IDENTIFIER_NEED_DEFAULT_PERMISSIONS', 'CANNOT_SEND_NON_TOKEN', 'TOKEN_RECEIVE_DIFFERS', 'ONLY_TOKEN_OP', 'ONLY_IDENTIFIER_OP', 'NO_TOKEN_OP', 'NO_IDENTIFIER_OP', 'INVALID_SIGNER', 'INVALID_PURPOSE_VALIDATION', 'INVALID_MULTISIG_QUORUM', 'INVALID_MULTISIG_SIGNER_DEPTH', 'INVALID_MULTISIG_SIGNER_COUNT', 'INVALID_MULTISIG_SIGNER_DUPLICATE', 'INVALID_CREATE_IDENTIFIER_ARGS', 'NO_MULTISIG_OP', 'IDENTIFIER_INVALID', 'GENERAL_FIELD_INVALID', 'PERMISSIONS_INVALID_DEFAULT', 'PERMISSIONS_INVALID_ENTITY', 'PERMISSIONS_INVALID_PRINCIPAL', 'PERMISSIONS_INVALID_TARGET', 'INVALID_ACCOUNT_TYPE', 'NO_ADMIN_ON_TARGET', 'PREVIOUS_SELF', 'NO_DELEGATE_ADMIN', 'NO_MODIFY_PERMISSION_DUPE', 'CANNOT_FORWARD_TO_SELF', 'EXACT_TRUE_WHEN_FORWARDING', 'CERTIFICATE_SUBJECT_MISMATCH', 'NO_DUPLICATE_CERTIFICATE_OPERATION', 'INTERMEDIATE_CERTIFICATES_ONLY_ADD', 'INVALID_CERTIFICATE_VALUE', 'EXTERNAL_TOO_LONG', 'EXTERNAL_INVALID', 'EXTERNAL_MISSING', 'SUPPLY_INVALID', 'INVALID_IDEMPOTENT_FORMAT', 'INVALID_IDEMPOTENT_LENGTH'];
115209
115227
  const client_FullBlockErrorCodes = client_BlockErrorCodes.map(code => `${client_BlockErrorType}_${code}`);
115210
115228
  class src_client_KeetaNetBlockError extends src_client_KeetaNetErrorBase {
115211
115229
  constructor(code, message) {
@@ -116719,7 +116737,8 @@ client_utils_certificate_defineProperty(src_client_Certificate, "Hash", src_clie
116719
116737
  */
116720
116738
  client_utils_certificate_defineProperty(src_client_Certificate, "certificateObjectTypeID", '8d05dca5-5f42-4dc9-8bf9-f534c6570994:CERTIFICATE');
116721
116739
  ;// ./src/lib/error/ledger.ts
116722
- var client_KeetaNetLedgerError, client_KeetaNetLedgerVoteError;
116740
+ /* provided dependency */ var client_ledger_Buffer = __webpack_require__(8287)["Buffer"];
116741
+ var client_KeetaNetLedgerError, client_KeetaNetLedgerVoteError, client_KeetaNetLedgerIdempotentKeyError;
116723
116742
  function client_ledger_defineProperty(e, r, t) { return (r = client_ledger_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
116724
116743
  function client_ledger_toPropertyKey(t) { var i = client_ledger_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
116725
116744
  function client_ledger_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -116732,11 +116751,14 @@ const client_LedgerBaseErrorCodes = ['BLOCK_ALREADY_EXISTS', 'TRANSACTION_ABORTE
116732
116751
 
116733
116752
  // Errors that can trigger rep sync
116734
116753
  const client_LedgerVoteErrorCodes = ['NOT_SUCCESSOR', 'NOT_OPENING'];
116735
- const client_FullLedgerErrorCodes = [...client_LedgerBaseErrorCodes, ...client_LedgerVoteErrorCodes].map(code => `${client_LedgerErrorType}_${code}`);
116754
+ const client_LedgerIdempotentKeyErrorCodes = ['IDEMPOTENT_KEY_EXISTS'];
116755
+ const client_FullLedgerErrorCodes = [...client_LedgerBaseErrorCodes, ...client_LedgerVoteErrorCodes, ...client_LedgerIdempotentKeyErrorCodes].map(code => `${client_LedgerErrorType}_${code}`);
116736
116756
  const client_FullLedgerBaseErrorCode = client_LedgerBaseErrorCodes.map(code => `${client_LedgerErrorType}_${code}`);
116737
116757
  const client_FullLedgerVoteErrorCodes = client_LedgerVoteErrorCodes.map(code => `${client_LedgerErrorType}_${code}`);
116758
+ const client_FullLedgerIdempotentKeyErrorCodes = client_LedgerIdempotentKeyErrorCodes.map(code => `${client_LedgerErrorType}_${code}`);
116738
116759
  const client_ledgerBaseErrorCodeSet = new Set(client_FullLedgerBaseErrorCode);
116739
116760
  const client_ledgerVoteErrorCodeSet = new Set(client_FullLedgerVoteErrorCodes);
116761
+ const client_ledgerIdempotentKeyErrorCodeSet = new Set(client_FullLedgerIdempotentKeyErrorCodes);
116740
116762
  class client_ledger_KeetaNetLedgerError extends src_client_KeetaNetErrorBase {
116741
116763
  static assertValidLedgerErrorCode(code) {
116742
116764
  return client_ledgerBaseErrorCodeSet.has(code);
@@ -116781,6 +116803,58 @@ class src_client_KeetaNetLedgerVoteError extends src_client_KeetaNetErrorBase {
116781
116803
  }
116782
116804
  client_KeetaNetLedgerVoteError = src_client_KeetaNetLedgerVoteError;
116783
116805
  client_ledger_defineProperty(src_client_KeetaNetLedgerVoteError, "isInstance", client_checkableGenerator(client_KeetaNetLedgerVoteError));
116806
+ class src_client_KeetaNetLedgerIdempotentKeyError extends src_client_KeetaNetErrorBase {
116807
+ static assertValidLedgerErrorCode(code) {
116808
+ return client_ledgerIdempotentKeyErrorCodeSet.has(code);
116809
+ }
116810
+ constructor(code, blockhash, existingBlockhash, account, idempotentKey) {
116811
+ let messageIdempotentKey = '<unknown>';
116812
+ if (idempotentKey) {
116813
+ messageIdempotentKey = client_ledger_Buffer.from(idempotentKey).toString('base64');
116814
+ }
116815
+ let messageAccount = '<unknown>';
116816
+ if (account) {
116817
+ messageAccount = account.publicKeyString.get();
116818
+ }
116819
+ const message = `Idempotent key (${messageIdempotentKey}) for account (${messageAccount}) already exists for blockhash ${existingBlockhash.toString()}`;
116820
+ super(code, message, {
116821
+ type: client_LedgerErrorType,
116822
+ codes: client_LedgerIdempotentKeyErrorCodes
116823
+ });
116824
+ client_ledger_defineProperty(this, "type", client_LedgerErrorType);
116825
+ client_ledger_defineProperty(this, "shouldRetry", false);
116826
+ this.blockhash = blockhash;
116827
+ this.existingBlockhash = existingBlockhash;
116828
+ if (account) {
116829
+ this.account = account;
116830
+ }
116831
+ if (idempotentKey) {
116832
+ if (client_ledger_Buffer.isBuffer(idempotentKey)) {
116833
+ this.idempotentKey = client_bufferToArrayBuffer(idempotentKey);
116834
+ } else {
116835
+ this.idempotentKey = idempotentKey;
116836
+ }
116837
+ }
116838
+ }
116839
+ toJSON() {
116840
+ const jsonOptional = {};
116841
+ if (this.account) {
116842
+ jsonOptional.account = this.account.publicKeyString.get();
116843
+ }
116844
+ if (this.idempotentKey) {
116845
+ jsonOptional.idempotentKey = client_ledger_Buffer.from(this.idempotentKey).toString('base64');
116846
+ }
116847
+ const json = {
116848
+ ...super.toJSON(),
116849
+ ...jsonOptional,
116850
+ blockhash: this.blockhash.toString(),
116851
+ existingBlockhash: this.existingBlockhash.toString()
116852
+ };
116853
+ return json;
116854
+ }
116855
+ }
116856
+ client_KeetaNetLedgerIdempotentKeyError = src_client_KeetaNetLedgerIdempotentKeyError;
116857
+ client_ledger_defineProperty(src_client_KeetaNetLedgerIdempotentKeyError, "isInstance", client_checkableGenerator(client_KeetaNetLedgerIdempotentKeyError));
116784
116858
  ;// ./src/lib/ledger/common.ts
116785
116859
  function client_common_classPrivateMethodInitSpec(e, a) { client_common_checkPrivateRedeclaration(e, a), a.add(e); }
116786
116860
  function client_common_checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
@@ -117499,11 +117573,11 @@ class client_LedgerStorageBase {
117499
117573
  }
117500
117574
  }
117501
117575
  function client_log() {
117502
- if (this.config !== null) {
117503
- if (this.config.log !== undefined) {
117504
- this.config.log(...arguments);
117505
- }
117576
+ var _this$config;
117577
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
117578
+ args[_key] = arguments[_key];
117506
117579
  }
117580
+ (_this$config = this.config) === null || _this$config === void 0 || (_this$config = _this$config.log) === null || _this$config === void 0 || _this$config.debug('ledger', ...args);
117507
117581
  }
117508
117582
  function client_assertLedgerStorage(value) {
117509
117583
  if (value === 'main' || value === 'side') {
@@ -118904,6 +118978,7 @@ function client_lib_block_toPrimitive(t, r) { if ("object" != typeof t || !t) re
118904
118978
 
118905
118979
 
118906
118980
 
118981
+
118907
118982
  const client_NO_PREVIOUS = '9bd05fa2-8e59-42a2-8153-26d8e8c10143:NO_PREVIOUS';
118908
118983
  let client_BlockPurpose = /*#__PURE__*/function (BlockPurpose) {
118909
118984
  BlockPurpose[BlockPurpose["GENERIC"] = 0] = "GENERIC";
@@ -118990,6 +119065,9 @@ client_lib_block_defineProperty(client_block_BlockHash, "Set", client_setGenerat
118990
119065
  /**
118991
119066
  * Subnet ID
118992
119067
  */
119068
+ /**
119069
+ * Idempotent Key
119070
+ */
118993
119071
  /**
118994
119072
  * Block signature
118995
119073
  */
@@ -119008,6 +119086,8 @@ client_lib_block_defineProperty(client_block_BlockHash, "Set", client_setGenerat
119008
119086
  /** @internal */
119009
119087
  const client_BlockV1ASN1Schema = [0n, client_BufferStorageASN1.Validate.IsInteger, {
119010
119088
  choice: [client_BufferStorageASN1.Validate.IsInteger, client_BufferStorageASN1.Validate.IsNull]
119089
+ }, {
119090
+ optional: client_BufferStorageASN1.Validate.IsOctetString
119011
119091
  }, {
119012
119092
  type: 'date',
119013
119093
  kind: 'general'
@@ -119094,6 +119174,8 @@ const client_BlockV2ASN1Schema = {
119094
119174
  value: 1,
119095
119175
  contains: [client_BufferStorageASN1.Validate.IsInteger, {
119096
119176
  optional: client_BufferStorageASN1.Validate.IsInteger
119177
+ }, {
119178
+ optional: client_BufferStorageASN1.Validate.IsOctetString
119097
119179
  }, {
119098
119180
  type: 'date',
119099
119181
  kind: 'general'
@@ -119162,6 +119244,28 @@ function client_ignore_static_checks() {
119162
119244
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
119163
119245
  const _ignore_check_blockasn1v2_reverse_2 = _ignore_check_blockasn1v2_reverse_1;
119164
119246
  }
119247
+ function client_parseBlockIdempotent(input, network) {
119248
+ let output;
119249
+ if (client_block_Buffer.isBuffer(input)) {
119250
+ output = input;
119251
+ } else {
119252
+ try {
119253
+ output = client_validateBase64ToBuffer(input);
119254
+ } catch (base64Error) {
119255
+ throw new src_client_KeetaNetBlockError('BLOCK_INVALID_IDEMPOTENT_FORMAT', 'Could not parse base64 Block idempotent');
119256
+ }
119257
+ }
119258
+ if (output === undefined) {
119259
+ throw new src_client_KeetaNetBlockError('BLOCK_INVALID_IDEMPOTENT_FORMAT', 'Could not parse Block idempotent');
119260
+ }
119261
+ if (network !== undefined) {
119262
+ const idempotentValidationConfig = client_getValidation(network).idempotentKey;
119263
+ if (output.length > idempotentValidationConfig.maxByteLength) {
119264
+ throw new src_client_KeetaNetBlockError('BLOCK_INVALID_IDEMPOTENT_LENGTH', `Block idempotent key is length ${output.length}, but maxByteLength is ${idempotentValidationConfig.maxByteLength}`);
119265
+ }
119266
+ }
119267
+ return output;
119268
+ }
119165
119269
  function client_MapV1InputValues(input) {
119166
119270
  var _Account$toAccount, _output$account;
119167
119271
  const output = {};
@@ -119169,6 +119273,28 @@ function client_MapV1InputValues(input) {
119169
119273
  throw new Error('MapInputValues should not be called with version != 1');
119170
119274
  }
119171
119275
  output.version = input.version;
119276
+
119277
+ /*
119278
+ * Import network
119279
+ */
119280
+ if (input.network !== undefined) {
119281
+ if (typeof input.network === 'bigint') {
119282
+ output.network = input.network;
119283
+ } else {
119284
+ output.network = BigInt(input.network);
119285
+ }
119286
+ }
119287
+
119288
+ /*
119289
+ * Import idempotent key
119290
+ */
119291
+ if (input.idempotent !== undefined) {
119292
+ output.idempotent = client_parseBlockIdempotent(input.idempotent, output.network);
119293
+ }
119294
+
119295
+ /*
119296
+ * Import date
119297
+ */
119172
119298
  if (input.date !== undefined) {
119173
119299
  output.date = new Date(input.date);
119174
119300
  }
@@ -119200,17 +119326,6 @@ function client_MapV1InputValues(input) {
119200
119326
  }
119201
119327
  }
119202
119328
 
119203
- /*
119204
- * Import network
119205
- */
119206
- if (input.network !== undefined) {
119207
- if (typeof input.network === 'bigint') {
119208
- output.network = input.network;
119209
- } else {
119210
- output.network = BigInt(input.network);
119211
- }
119212
- }
119213
-
119214
119329
  /*
119215
119330
  * Import Subnet
119216
119331
  */
@@ -119241,6 +119356,24 @@ function client_MapV2InputValues(input) {
119241
119356
  }
119242
119357
  output.version = input.version;
119243
119358
  output.purpose = input.purpose;
119359
+
119360
+ /*
119361
+ * Import network
119362
+ */
119363
+ if (input.network !== undefined) {
119364
+ output.network = BigInt(input.network);
119365
+ }
119366
+
119367
+ /*
119368
+ * Import idempotent key
119369
+ */
119370
+ if (input.idempotent !== undefined) {
119371
+ output.idempotent = client_parseBlockIdempotent(input.idempotent, output.network);
119372
+ }
119373
+
119374
+ /*
119375
+ * Import date
119376
+ */
119244
119377
  if (input.date !== undefined) {
119245
119378
  output.date = new Date(input.date);
119246
119379
  }
@@ -119265,13 +119398,6 @@ function client_MapV2InputValues(input) {
119265
119398
  }
119266
119399
  }
119267
119400
 
119268
- /*
119269
- * Import network
119270
- */
119271
- if (input.network !== undefined) {
119272
- output.network = BigInt(input.network);
119273
- }
119274
-
119275
119401
  /*
119276
119402
  * Import Subnet
119277
119403
  */
@@ -119389,7 +119515,7 @@ class src_client_Block {
119389
119515
  if (client_util.types.isArrayBuffer(input)) {
119390
119516
  const data = new client_BufferStorageASN1(input, client_BlockASN1Schema).getASN1();
119391
119517
  if (Array.isArray(data)) {
119392
- var _data$;
119518
+ var _data$, _data$2;
119393
119519
  if (data[0] !== 0n) {
119394
119520
  throw new Error('Invalid block version without context tag');
119395
119521
  }
@@ -119397,10 +119523,11 @@ class src_client_Block {
119397
119523
  this.purpose = client_BlockPurpose.GENERIC;
119398
119524
  this.network = data[1];
119399
119525
  this.subnet = (_data$ = data[2]) !== null && _data$ !== void 0 ? _data$ : undefined;
119400
- this.date = data[3].date;
119401
- const signerContainer = data[4];
119526
+ this.idempotent = (_data$2 = data[3]) !== null && _data$2 !== void 0 ? _data$2 : undefined;
119527
+ this.date = data[4].date;
119528
+ const signerContainer = data[5];
119402
119529
  this.signer = client_lib_account.fromPublicKeyAndType(signerContainer).assertAccount();
119403
- const acctItem = data[5];
119530
+ const acctItem = data[6];
119404
119531
  if (acctItem === null) {
119405
119532
  this.account = this.signer;
119406
119533
  } else {
@@ -119409,20 +119536,21 @@ class src_client_Block {
119409
119536
  throw new Error('Account should not be in block when it is same as signer, we cannot use this block');
119410
119537
  }
119411
119538
  }
119412
- const prevHashBuf = data[6];
119539
+ const prevHashBuf = data[7];
119413
119540
  this.previous = new client_block_BlockHash(prevHashBuf);
119414
- this.operations = client_ImportOperationsASN1(data[7], this.network);
119415
- this.signatures = [data[8]];
119541
+ this.operations = client_ImportOperationsASN1(data[8], this.network);
119542
+ this.signatures = [data[9]];
119416
119543
  } else if (data.value === 1) {
119417
- var _container$;
119544
+ var _container$, _container$2;
119418
119545
  this.version = 2;
119419
119546
  const container = data.contains;
119420
119547
  this.network = container[0];
119421
119548
  this.subnet = (_container$ = container[1]) !== null && _container$ !== void 0 ? _container$ : undefined;
119422
- this.date = container[2].date;
119423
- this.purpose = client_toBlockPurpose(container[3]);
119424
- this.account = client_lib_account.fromPublicKeyAndType(container[4]);
119425
- const signersContainer = container[5];
119549
+ this.idempotent = (_container$2 = container[2]) !== null && _container$2 !== void 0 ? _container$2 : undefined;
119550
+ this.date = container[3].date;
119551
+ this.purpose = client_toBlockPurpose(container[4]);
119552
+ this.account = client_lib_account.fromPublicKeyAndType(container[5]);
119553
+ const signersContainer = container[6];
119426
119554
  if (signersContainer === null) {
119427
119555
  this.signer = this.account.assertAccount();
119428
119556
  } else if (client_block_Buffer.isBuffer(signersContainer)) {
@@ -119433,9 +119561,9 @@ class src_client_Block {
119433
119561
  } else {
119434
119562
  this.signer = client_parseBlockSignerFieldContainer(signersContainer).parsed;
119435
119563
  }
119436
- this.previous = new client_block_BlockHash(container[6]);
119437
- this.operations = client_ImportOperationsASN1(container[7], this.network);
119438
- const signatureContainer = container[8];
119564
+ this.previous = new client_block_BlockHash(container[7]);
119565
+ this.operations = client_ImportOperationsASN1(container[8], this.network);
119566
+ const signatureContainer = container[9];
119439
119567
  if (client_block_Buffer.isBuffer(signatureContainer)) {
119440
119568
  this.signatures = [signatureContainer];
119441
119569
  } else {
@@ -119453,6 +119581,7 @@ class src_client_Block {
119453
119581
  if (src_client_Block.isInstance(input)) {
119454
119582
  this.version = input.version;
119455
119583
  this.purpose = input.purpose;
119584
+ this.idempotent = input.idempotent;
119456
119585
  this.date = input.date;
119457
119586
  this.previous = input.previous;
119458
119587
  this.network = input.network;
@@ -119467,6 +119596,7 @@ class src_client_Block {
119467
119596
  */
119468
119597
  const {
119469
119598
  version,
119599
+ idempotent,
119470
119600
  date,
119471
119601
  previous,
119472
119602
  network,
@@ -119477,6 +119607,7 @@ class src_client_Block {
119477
119607
  } = client_MapV1InputValues(input);
119478
119608
  this.version = version;
119479
119609
  this.purpose = client_BlockPurpose.GENERIC;
119610
+ this.idempotent = idempotent;
119480
119611
  this.date = date;
119481
119612
  this.previous = previous;
119482
119613
  this.network = network;
@@ -119506,6 +119637,7 @@ class src_client_Block {
119506
119637
  */
119507
119638
  const {
119508
119639
  version,
119640
+ idempotent,
119509
119641
  date,
119510
119642
  previous,
119511
119643
  network,
@@ -119517,6 +119649,7 @@ class src_client_Block {
119517
119649
  } = client_MapV2InputValues(input);
119518
119650
  this.version = version;
119519
119651
  this.purpose = purpose;
119652
+ this.idempotent = idempotent;
119520
119653
  this.date = date;
119521
119654
  this.previous = previous;
119522
119655
  this.network = network;
@@ -119588,7 +119721,8 @@ class src_client_Block {
119588
119721
  account: this.account,
119589
119722
  network: this.network,
119590
119723
  subnet: this.subnet,
119591
- date: this.date
119724
+ date: this.date,
119725
+ idempotent: this.idempotent
119592
119726
  };
119593
119727
  let container;
119594
119728
  if (this.version === 1) {
@@ -119660,7 +119794,7 @@ class src_client_Block {
119660
119794
  if (input.version !== 1) {
119661
119795
  throw new Error('Cannot call getASN1ContainerWithoutSignature when version != 1');
119662
119796
  }
119663
- return [0n, input.network, (_input$subnet = input.subnet) !== null && _input$subnet !== void 0 ? _input$subnet : null, {
119797
+ return [0n, input.network, (_input$subnet = input.subnet) !== null && _input$subnet !== void 0 ? _input$subnet : null, input.idempotent, {
119664
119798
  type: 'date',
119665
119799
  kind: 'general',
119666
119800
  date: input.date
@@ -119678,7 +119812,7 @@ class src_client_Block {
119678
119812
  } else {
119679
119813
  signerContainer = input.signer.publicKeyAndType;
119680
119814
  }
119681
- return [input.network, input.subnet, {
119815
+ return [input.network, input.subnet, input.idempotent, {
119682
119816
  type: 'date',
119683
119817
  kind: 'general',
119684
119818
  date: input.date
@@ -119699,6 +119833,7 @@ class src_client_Block {
119699
119833
  }
119700
119834
  }
119701
119835
  toJSON(options) {
119836
+ var _this$idempotent;
119702
119837
  const additionalFields = {};
119703
119838
  if (options !== null && options !== void 0 && options.addBinary) {
119704
119839
  additionalFields['$binary'] = client_block_Buffer.from(this.toBytes()).toString('base64');
@@ -119713,6 +119848,7 @@ class src_client_Block {
119713
119848
  }
119714
119849
  return {
119715
119850
  version: this.version,
119851
+ idempotent: (_this$idempotent = this.idempotent) === null || _this$idempotent === void 0 ? void 0 : _this$idempotent.toString('base64'),
119716
119852
  date: this.date,
119717
119853
  previous: this.previous,
119718
119854
  account: this.account,
@@ -119915,6 +120051,7 @@ class src_client_BlockBuilder {
119915
120051
  }
119916
120052
  return {
119917
120053
  version: this.version,
120054
+ idempotent: this.idempotent,
119918
120055
  date: this.date,
119919
120056
  previous: this.previous,
119920
120057
  account: this.account,
@@ -119948,6 +120085,7 @@ class src_client_BlockBuilder {
119948
120085
  if (src_client_Block.isInstance(client_block_classPrivateFieldGet(client_block, this))) {
119949
120086
  client_block_classPrivateFieldSet(client_block, this, {
119950
120087
  version: client_block_classPrivateFieldGet(client_block, this).version,
120088
+ idempotent: client_block_classPrivateFieldGet(client_block, this).idempotent,
119951
120089
  date: client_block_classPrivateFieldGet(client_block, this).date,
119952
120090
  previous: client_block_classPrivateFieldGet(client_block, this).previous,
119953
120091
  account: client_block_classPrivateFieldGet(client_block, this).account,
@@ -120040,7 +120178,7 @@ class src_client_BlockBuilder {
120040
120178
  get previous() {
120041
120179
  const block = this.currentBlock;
120042
120180
  if (block === undefined) {
120043
- return;
120181
+ return undefined;
120044
120182
  }
120045
120183
  const previous = block.previous;
120046
120184
  if (previous === undefined) {
@@ -120076,6 +120214,26 @@ class src_client_BlockBuilder {
120076
120214
  const sentinel = src_client_Block.getAccountOpeningHash(account);
120077
120215
  return sentinel.compareHexString(previous);
120078
120216
  }
120217
+ set idempotent(idempotent) {
120218
+ if (typeof idempotent === 'string') {
120219
+ try {
120220
+ this.currentWIP.idempotent = client_validateBase64ToBuffer(idempotent);
120221
+ } catch (decodeError) {
120222
+ throw new src_client_KeetaNetBlockError('BLOCK_INVALID_IDEMPOTENT_FORMAT', 'Could not parse Block idempotent');
120223
+ }
120224
+ } else {
120225
+ this.currentWIP.idempotent = client_block_Buffer.from(idempotent);
120226
+ }
120227
+ }
120228
+ get idempotent() {
120229
+ if (this.currentBlock.idempotent === undefined) {
120230
+ return undefined;
120231
+ }
120232
+ if (client_block_Buffer.isBuffer(this.currentBlock.idempotent)) {
120233
+ return this.currentBlock.idempotent.toString('base64');
120234
+ }
120235
+ return this.currentBlock.idempotent;
120236
+ }
120079
120237
  set date(date) {
120080
120238
  if (date === undefined) {
120081
120239
  this.currentWIP.date = undefined;
@@ -120087,7 +120245,7 @@ class src_client_BlockBuilder {
120087
120245
  }
120088
120246
  get date() {
120089
120247
  if (this.currentBlock.date === undefined) {
120090
- return;
120248
+ return undefined;
120091
120249
  }
120092
120250
  return new Date(this.currentBlock.date);
120093
120251
  }
@@ -125514,17 +125672,20 @@ function client_getDurationRange(duration) {
125514
125672
  }
125515
125673
  /* harmony default export */ const client_stats = (client_Stats);
125516
125674
  ;// ./src/lib/ledger/index.ts
125517
- var client_Ledger;
125675
+ /* provided dependency */ var client_lib_ledger_Buffer = __webpack_require__(8287)["Buffer"];
125676
+ var client_IdempotentKey, client_Ledger;
125518
125677
  function client_usingCtx2() { var r = "function" == typeof SuppressedError ? SuppressedError : function (r, e) { var n = Error(); return n.name = "SuppressedError", n.error = r, n.suppressed = e, n; }, e = {}, n = []; function using(r, e) { if (null != e) { if (Object(e) !== e) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined."); if (r) var o = e[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]; if (void 0 === o && (o = e[Symbol.dispose || Symbol.for("Symbol.dispose")], r)) var t = o; if ("function" != typeof o) throw new TypeError("Object is not disposable."); t && (o = function () { try { t.call(e); } catch (r) { return Promise.reject(r); } }), n.push({ v: e, d: o, a: r }); } else r && n.push({ d: e, a: r }); return e; } return { e: e, u: using.bind(null, !1), a: using.bind(null, !0), d: function () { var o, t = this.e, s = 0; function next() { for (; o = n.pop();) try { if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next); if (o.d) { var r = o.d.call(o.v); if (o.a) return s |= 2, Promise.resolve(r).then(next, err); } else s |= 1; } catch (r) { return err(r); } if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve(); if (t !== e) throw t; } function err(n) { return t = t !== e ? new r(n, t) : n, next(); } return next(); } }; }
125519
- function client_lib_ledger_defineProperty(e, r, t) { return (r = client_lib_ledger_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
125520
- function client_lib_ledger_toPropertyKey(t) { var i = client_lib_ledger_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
125521
- function client_lib_ledger_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
125522
125678
  function client_ledger_classPrivateMethodInitSpec(e, a) { client_ledger_checkPrivateRedeclaration(e, a), a.add(e); }
125523
125679
  function client_ledger_classPrivateFieldInitSpec(e, t, a) { client_ledger_checkPrivateRedeclaration(e, t), t.set(e, a); }
125524
125680
  function client_ledger_checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
125525
125681
  function client_ledger_classPrivateFieldGet(s, a) { return s.get(client_ledger_assertClassBrand(s, a)); }
125526
125682
  function client_ledger_classPrivateFieldSet(s, a, r) { return s.set(client_ledger_assertClassBrand(s, a), r), r; }
125527
125683
  function client_ledger_assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
125684
+ function client_lib_ledger_defineProperty(e, r, t) { return (r = client_lib_ledger_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
125685
+ function client_lib_ledger_toPropertyKey(t) { var i = client_lib_ledger_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
125686
+ function client_lib_ledger_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
125687
+
125688
+
125528
125689
 
125529
125690
 
125530
125691
 
@@ -125569,9 +125730,43 @@ let client_LedgerKind = /*#__PURE__*/function (LedgerKind) {
125569
125730
  */
125570
125731
 
125571
125732
  /**
125572
- * Each transaction can contain the node object making the request to access things like timing information
125733
+ * Idempotent Key
125573
125734
  */
125735
+ class src_client_IdempotentKey extends src_client_BufferStorage {
125736
+ static fromAccountAndIdempotent(account, idempotent) {
125737
+ let idempotentBuffer;
125738
+ if (typeof idempotent === 'string') {
125739
+ idempotentBuffer = client_lib_ledger_Buffer.from(idempotent, 'base64');
125740
+ } else {
125741
+ idempotentBuffer = idempotent;
125742
+ }
125743
+ const data = client_lib_ledger_Buffer.concat([account.publicKeyAndType, idempotentBuffer]);
125744
+ return new src_client_IdempotentKey(client_hash_Hash(data), account, idempotentBuffer);
125745
+ }
125746
+ constructor(idempotentKey, account, idempotent) {
125747
+ super(idempotentKey, 32);
125748
+ this.account = account;
125749
+ this.userIdempotent = idempotent;
125750
+ }
125751
+ toJSON() {
125752
+ return this.toString();
125753
+ }
125754
+ toString() {
125755
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
125756
+ return super.toString('hex');
125757
+ }
125758
+ }
125574
125759
 
125760
+ /**
125761
+ * Each transaction can contain the node object making the request to access things like timing information
125762
+ */
125763
+ client_IdempotentKey = src_client_IdempotentKey;
125764
+ client_lib_ledger_defineProperty(src_client_IdempotentKey, "isInstance", client_checkableGenerator(client_IdempotentKey));
125765
+ client_lib_ledger_defineProperty(src_client_IdempotentKey, "Set", client_setGenerator(client_IdempotentKey, function (value) {
125766
+ return value.toString();
125767
+ }, function (value) {
125768
+ return new client_IdempotentKey(client_lib_ledger_Buffer.from(value, 'hex'));
125769
+ }));
125575
125770
  class client_LedgerStorageTransactionBase {
125576
125771
  constructor(options) {
125577
125772
  var _options$moment, _options$readOnly;
@@ -125761,7 +125956,16 @@ class client_LedgerAtomicInterface {
125761
125956
  throw new client_ledger_KeetaNetLedgerError('LEDGER_NO_PERM_WITHOUT_SELF_TEMP', 'Asked to give a permanent vote without a temporary vote from us');
125762
125957
  }
125763
125958
  }
125764
- const allLedgerHeads = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateBlocksForVote).call(this, blocks);
125959
+ const {
125960
+ allLedgerHeads,
125961
+ allLedgerIdempotentKeys
125962
+ } = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_validateBlocksForVote).call(this, blocks);
125963
+ for (const [blockHash, key] of allLedgerIdempotentKeys) {
125964
+ const foundBlockHash = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getIdempotentBlockHash(transaction, key, 'both', blockHash);
125965
+ if (foundBlockHash !== null) {
125966
+ throw new src_client_KeetaNetLedgerIdempotentKeyError('LEDGER_IDEMPOTENT_KEY_EXISTS', blockHash, foundBlockHash, key.account, key.userIdempotent);
125967
+ }
125968
+ }
125765
125969
  const needToGetHeadFor = new client_lib_account.Set(allLedgerHeads.keys());
125766
125970
  const allHeads = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getHeadBlockHashes(transaction, needToGetHeadFor);
125767
125971
  for (const [account, expectedBlock] of allLedgerHeads.entries()) {
@@ -126216,6 +126420,24 @@ class client_LedgerAtomicInterface {
126216
126420
  const effects = effectsInput !== null && effectsInput !== void 0 ? effectsInput : client_computeEffectOfBlocks(blocks, client_ledger_classPrivateFieldGet(client_ledger, this));
126217
126421
  return client_ledger_classPrivateFieldGet(client_computeFeeFromBlocks, this).call(this, client_ledger_classPrivateFieldGet(client_ledger, this), blocks, effects);
126218
126422
  }
126423
+ async getIdempotentBlockHash(account, idempotent) {
126424
+ let from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'both';
126425
+ let excludeBlockHash = arguments.length > 3 ? arguments[3] : undefined;
126426
+ const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
126427
+ const idempotentKey = src_client_IdempotentKey.fromAccountAndIdempotent(account, idempotent);
126428
+ const blockHash = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getIdempotentBlockHash(transaction, idempotentKey, from, excludeBlockHash);
126429
+ return blockHash;
126430
+ }
126431
+ async getBlockFromIdempotent(account, idempotent) {
126432
+ let from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'both';
126433
+ let excludeBlockHash = arguments.length > 3 ? arguments[3] : undefined;
126434
+ const blockHash = await this.getIdempotentBlockHash(account, idempotent, from, excludeBlockHash);
126435
+ if (blockHash === null) {
126436
+ return null;
126437
+ }
126438
+ const block = await this.getBlock(blockHash, from);
126439
+ return block;
126440
+ }
126219
126441
  async _testingRunStorageFunction(code) {
126220
126442
  const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
126221
126443
  const retval = await code(client_ledger_classPrivateFieldGet(client_ledger_storage, this), transaction);
@@ -126539,6 +126761,8 @@ async function client_validateBlocksForVote(blocks) {
126539
126761
  const seenBlockHashes = new client_block_BlockHash.Set();
126540
126762
  const usedPreviousBlockHashes = new client_block_BlockHash.Set();
126541
126763
  const allLedgerHeads = new Map();
126764
+ const allLedgerIdempotentKeys = new Map();
126765
+ const allLedgerIdempotentKeysReverse = new Map();
126542
126766
  for (const block of blocks) {
126543
126767
  const prevBlockHash = block.previous;
126544
126768
  seenBlockHashes.add(block.hash);
@@ -126548,6 +126772,20 @@ async function client_validateBlocksForVote(blocks) {
126548
126772
  if (block.subnet !== client_ledger_classPrivateFieldGet(client_subnet, this)) {
126549
126773
  throw new client_ledger_KeetaNetLedgerError('LEDGER_INVALID_SUBNET', 'Cannot vote on block for a different subnet');
126550
126774
  }
126775
+
126776
+ /*
126777
+ * Verify that no other blocks in this set of blocks have the same idempotent key
126778
+ */
126779
+ if (block.idempotent !== undefined) {
126780
+ const idempotentKey = src_client_IdempotentKey.fromAccountAndIdempotent(block.account, block.idempotent);
126781
+ const idempotentKeyString = idempotentKey.toString();
126782
+ const existingBlockHash = allLedgerIdempotentKeysReverse.get(idempotentKeyString);
126783
+ if (existingBlockHash !== undefined) {
126784
+ throw new src_client_KeetaNetLedgerIdempotentKeyError('LEDGER_IDEMPOTENT_KEY_EXISTS', block.hash, existingBlockHash, block.account, block.idempotent);
126785
+ }
126786
+ allLedgerIdempotentKeys.set(block.hash, idempotentKey);
126787
+ allLedgerIdempotentKeysReverse.set(idempotentKeyString, block.hash);
126788
+ }
126551
126789
  if (usedPreviousBlockHashes.has(prevBlockHash)) {
126552
126790
  throw new client_ledger_KeetaNetLedgerError('LEDGER_PREVIOUS_ALREADY_USED', `Invalid reference to block, previous: ${prevBlockHash} has already been used`);
126553
126791
  }
@@ -126576,7 +126814,10 @@ async function client_validateBlocksForVote(blocks) {
126576
126814
  allLedgerHeads.set(block.account, block);
126577
126815
  }
126578
126816
  }
126579
- return allLedgerHeads;
126817
+ return {
126818
+ allLedgerHeads,
126819
+ allLedgerIdempotentKeys
126820
+ };
126580
126821
  }
126581
126822
  async function client_voteOrQuoteWithFees(blocks, type, quote) {
126582
126823
  var _quote$fee;
@@ -127008,6 +127249,22 @@ class src_client_Ledger {
127008
127249
  return await transaction.getFee(...args);
127009
127250
  });
127010
127251
  }
127252
+ async getIdempotentBlockHash() {
127253
+ for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
127254
+ args[_key27] = arguments[_key27];
127255
+ }
127256
+ return await this.runReadOnly('db-getIdempotentBlockHash', async function (transaction) {
127257
+ return await transaction.getIdempotentBlockHash(...args);
127258
+ });
127259
+ }
127260
+ async getBlockFromIdempotent() {
127261
+ for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
127262
+ args[_key28] = arguments[_key28];
127263
+ }
127264
+ return await this.runReadOnly('db-getBlockFromIdempotent', async function (transaction) {
127265
+ return await transaction.getBlockFromIdempotent(...args);
127266
+ });
127267
+ }
127011
127268
  async stats() {
127012
127269
  try {
127013
127270
  var _this$node5;
@@ -127034,7 +127291,7 @@ client_lib_ledger_defineProperty(src_client_Ledger, "isInstance", client_checkab
127034
127291
  // EXTERNAL MODULE: ws (ignored)
127035
127292
  var client_ws_ignored_ = __webpack_require__(4708);
127036
127293
  ;// ./src/version.ts
127037
- const client_version = '0.14.5+g7ab6fd7b04246202abe16df362295a3a022d514a';
127294
+ const client_version = '0.14.7+gc361cc93bcd5918c1bfac43f60a0a68020a0ecb1';
127038
127295
  /* harmony default export */ const client_src_version = ((/* unused pure expression or super */ null && (client_version)));
127039
127296
  ;// ./src/lib/p2p.ts
127040
127297
  /* provided dependency */ var client_p2p_Buffer = __webpack_require__(8287)["Buffer"];
@@ -129020,6 +129277,545 @@ const client_p2p_Testing = {
129020
129277
  generateP2PPeerSigned: client_generateP2PPeerSigned,
129021
129278
  P2PPeerToJSO: client_P2PPeerToJSO
129022
129279
  };
129280
+ // EXTERNAL MODULE: ./node_modules/typia/lib/internal/_assertGuard.js
129281
+ var client_assertGuard = __webpack_require__(7422);
129282
+ ;// ./src/lib/log/helper.generated.ts
129283
+
129284
+ const client_assertLogOptionsParam = (() => {
129285
+ const _io0 = input => (undefined === input.userVisible || "boolean" === typeof input.userVisible) && (undefined === input.currentRequestInfo || "object" === typeof input.currentRequestInfo && null !== input.currentRequestInfo && _io1(input.currentRequestInfo));
129286
+ const _io1 = input => "string" === typeof input.id;
129287
+ const _ao0 = function (input, _path) {
129288
+ let _exceptionable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
129289
+ return (undefined === input.userVisible || "boolean" === typeof input.userVisible || client_assertGuard/* _assertGuard */.v(_exceptionable, {
129290
+ method: "createAssert",
129291
+ path: _path + ".userVisible",
129292
+ expected: "(boolean | undefined)",
129293
+ value: input.userVisible
129294
+ }, _errorFactory)) && (undefined === input.currentRequestInfo || ("object" === typeof input.currentRequestInfo && null !== input.currentRequestInfo || client_assertGuard/* _assertGuard */.v(_exceptionable, {
129295
+ method: "createAssert",
129296
+ path: _path + ".currentRequestInfo",
129297
+ expected: "(LogCurrentRequest | undefined)",
129298
+ value: input.currentRequestInfo
129299
+ }, _errorFactory)) && _ao1(input.currentRequestInfo, _path + ".currentRequestInfo", true && _exceptionable) || client_assertGuard/* _assertGuard */.v(_exceptionable, {
129300
+ method: "createAssert",
129301
+ path: _path + ".currentRequestInfo",
129302
+ expected: "(LogCurrentRequest | undefined)",
129303
+ value: input.currentRequestInfo
129304
+ }, _errorFactory));
129305
+ };
129306
+ const _ao1 = function (input, _path) {
129307
+ let _exceptionable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
129308
+ return "string" === typeof input.id || client_assertGuard/* _assertGuard */.v(_exceptionable, {
129309
+ method: "createAssert",
129310
+ path: _path + ".id",
129311
+ expected: "string",
129312
+ value: input.id
129313
+ }, _errorFactory);
129314
+ };
129315
+ const __is = input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
129316
+ let _errorFactory;
129317
+ return (input, errorFactory) => {
129318
+ if (false === __is(input)) {
129319
+ _errorFactory = errorFactory;
129320
+ (function (input, _path) {
129321
+ let _exceptionable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
129322
+ return ("object" === typeof input && null !== input && false === Array.isArray(input) || client_assertGuard/* _assertGuard */.v(true, {
129323
+ method: "createAssert",
129324
+ path: _path + "",
129325
+ expected: "__type",
129326
+ value: input
129327
+ }, _errorFactory)) && _ao0(input, _path + "", true) || client_assertGuard/* _assertGuard */.v(true, {
129328
+ method: "createAssert",
129329
+ path: _path + "",
129330
+ expected: "__type",
129331
+ value: input
129332
+ }, _errorFactory);
129333
+ })(input, "$input", true);
129334
+ }
129335
+ return input;
129336
+ };
129337
+ })();
129338
+ const client_assertLogTargetLevel = (() => {
129339
+ const __is = input => "ALL" === input || "DEBUG" === input || "INFO" === input || "WARN" === input || "ERROR" === input || "NONE" === input;
129340
+ let _errorFactory;
129341
+ return (input, errorFactory) => {
129342
+ if (false === __is(input)) {
129343
+ _errorFactory = errorFactory;
129344
+ (function (input, _path) {
129345
+ let _exceptionable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
129346
+ return "ALL" === input || "DEBUG" === input || "INFO" === input || "WARN" === input || "ERROR" === input || "NONE" === input || client_assertGuard/* _assertGuard */.v(true, {
129347
+ method: "createAssert",
129348
+ path: _path + "",
129349
+ expected: "(\"ALL\" | \"DEBUG\" | \"ERROR\" | \"INFO\" | \"NONE\" | \"WARN\")",
129350
+ value: input
129351
+ }, _errorFactory);
129352
+ })(input, "$input", true);
129353
+ }
129354
+ return input;
129355
+ };
129356
+ })();
129357
+ ;// ./src/lib/log/common.ts
129358
+ const client_numericLogLevels = {
129359
+ DEBUG: 0,
129360
+ INFO: 1,
129361
+ WARN: 2,
129362
+ ERROR: 3
129363
+ };
129364
+
129365
+ /* XXX:TODO -- Do something with this */
129366
+
129367
+ function client_canLogForLevel(level, currentLevel) {
129368
+ return client_numericLogLevels[level] >= client_numericLogLevels[currentLevel];
129369
+ }
129370
+ function client_canLogForTargetLevel(level, targetLevel) {
129371
+ if (targetLevel === 'ALL') {
129372
+ return true;
129373
+ }
129374
+ if (targetLevel === 'NONE') {
129375
+ return false;
129376
+ }
129377
+ return client_canLogForLevel(level, targetLevel);
129378
+ }
129379
+ function client_filterLog(target, message) {
129380
+ var _message$options$user, _message$options$curr, _message$options$curr2;
129381
+ if (!client_canLogForTargetLevel(message.level, target.logLevel)) {
129382
+ return null;
129383
+ }
129384
+ if (target.filter && !target.filter.test(message.from)) {
129385
+ return null;
129386
+ }
129387
+ return {
129388
+ ...message,
129389
+ options: {
129390
+ userVisible: (_message$options$user = message.options.userVisible) !== null && _message$options$user !== void 0 ? _message$options$user : true,
129391
+ currentRequestInfo: {
129392
+ id: (_message$options$curr = (_message$options$curr2 = message.options.currentRequestInfo) === null || _message$options$curr2 === void 0 ? void 0 : _message$options$curr2.id) !== null && _message$options$curr !== void 0 ? _message$options$curr : '<NO_REQUEST_ID>',
129393
+ ...message.options.currentRequestInfo
129394
+ },
129395
+ ...message.options
129396
+ }
129397
+ };
129398
+ }
129399
+ ;// ./src/lib/log/target_console.ts
129400
+ function client_target_console_classPrivateFieldInitSpec(e, t, a) { client_target_console_checkPrivateRedeclaration(e, t), t.set(e, a); }
129401
+ function client_target_console_checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
129402
+ function client_target_console_classPrivateFieldGet(s, a) { return s.get(client_target_console_assertClassBrand(s, a)); }
129403
+ function client_target_console_classPrivateFieldSet(s, a, r) { return s.set(client_target_console_assertClassBrand(s, a), r), r; }
129404
+ function client_target_console_assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
129405
+
129406
+
129407
+ var client_console = /*#__PURE__*/new WeakMap();
129408
+ class client_LogTargetConsole {
129409
+ constructor(config) {
129410
+ var _config$logLevel, _config$console, _config$filter;
129411
+ client_target_console_classPrivateFieldInitSpec(this, client_console, void 0);
129412
+ this.logLevel = (_config$logLevel = config === null || config === void 0 ? void 0 : config.logLevel) !== null && _config$logLevel !== void 0 ? _config$logLevel : 'ALL';
129413
+ client_target_console_classPrivateFieldSet(client_console, this, (_config$console = config === null || config === void 0 ? void 0 : config.console) !== null && _config$console !== void 0 ? _config$console : console);
129414
+ this.filter = (_config$filter = config === null || config === void 0 ? void 0 : config.filter) !== null && _config$filter !== void 0 ? _config$filter : null;
129415
+ }
129416
+ async emitLogs(logs) {
129417
+ for (const rawLog of logs) {
129418
+ const log = client_filterLog(this, rawLog);
129419
+ if (log === null) {
129420
+ continue;
129421
+ }
129422
+ let method;
129423
+ switch (log.level) {
129424
+ case 'ERROR':
129425
+ method = 'error';
129426
+ break;
129427
+ case 'WARN':
129428
+ method = 'warn';
129429
+ break;
129430
+ case 'INFO':
129431
+ method = 'info';
129432
+ break;
129433
+ case 'DEBUG':
129434
+ method = 'debug';
129435
+ break;
129436
+ default:
129437
+ client_assertNever(log.level);
129438
+ }
129439
+ const requestID = log.options.currentRequestInfo.id;
129440
+ client_target_console_classPrivateFieldGet(client_console, this)[method](`[${requestID}] ${log.level} ${log.from}:`, ...log.args);
129441
+ if (log.trace !== undefined) {
129442
+ client_target_console_classPrivateFieldGet(client_console, this)[method](`[${requestID}] ${log.level} ${log.from} TRACE:`, log.trace);
129443
+ }
129444
+ }
129445
+ }
129446
+ }
129447
+ /* harmony default export */ const client_target_console = (client_LogTargetConsole);
129448
+ ;// ./src/lib/log/index.ts
129449
+ /* provided dependency */ var client_log_process = __webpack_require__(5606);
129450
+ function client_log_classPrivateMethodInitSpec(e, a) { client_log_checkPrivateRedeclaration(e, a), a.add(e); }
129451
+ function client_log_classPrivateFieldInitSpec(e, t, a) { client_log_checkPrivateRedeclaration(e, t), t.set(e, a); }
129452
+ function client_log_checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
129453
+ function client_log_defineProperty(e, r, t) { return (r = client_log_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
129454
+ function client_log_toPropertyKey(t) { var i = client_log_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
129455
+ function client_log_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
129456
+ function client_log_classPrivateFieldSet(s, a, r) { return s.set(client_log_assertClassBrand(s, a), r), r; }
129457
+ function client_log_classPrivateFieldGet(s, a) { return s.get(client_log_assertClassBrand(s, a)); }
129458
+ function client_log_assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
129459
+
129460
+
129461
+ /**
129462
+ * Maximum number of logs to enqueue when there are no targets assigned to a
129463
+ * Log instance
129464
+ */
129465
+ const client_MAX_LOGS_TO_ENQUEUE_WITH_NO_TARGETS = 131072;
129466
+
129467
+ /**
129468
+ * Options for a Log instance
129469
+ */
129470
+
129471
+ const client_NullLogger = {
129472
+ log: () => {},
129473
+ info: () => {},
129474
+ debug: () => {},
129475
+ warn: () => {},
129476
+ error: () => {}
129477
+ };
129478
+ var client_logs = /*#__PURE__*/new WeakMap();
129479
+ var client_autoSyncInterval = /*#__PURE__*/new WeakMap();
129480
+ var client_isSyncing = /*#__PURE__*/new WeakMap();
129481
+ var client_shouldSyncAgain = /*#__PURE__*/new WeakMap();
129482
+ var client_destroyed = /*#__PURE__*/new WeakMap();
129483
+ var client_emitOnLog = /*#__PURE__*/new WeakMap();
129484
+ var client_logDebugTracing = /*#__PURE__*/new WeakMap();
129485
+ var client_targets = /*#__PURE__*/new WeakMap();
129486
+ var client_Log_brand = /*#__PURE__*/new WeakSet();
129487
+ class client_Log {
129488
+ /**
129489
+ * The Null logger, to disable logging entirely
129490
+ */
129491
+ static Null() {
129492
+ return client_NullLogger;
129493
+ }
129494
+
129495
+ /**
129496
+ * The legacy logger
129497
+ *
129498
+ * This is a singleton instance of the logger that registers a console
129499
+ * target that emits logs immediately to the console.
129500
+ *
129501
+ * This also sets the log level based on the `<name>_DEBUG`
129502
+ * environment variable, if available and adds filtering based on
129503
+ * the `<name>_DEBUG_FILTER` environment variable, if available.
129504
+ *
129505
+ * The default value for `<name>` is `KEETANET`.
129506
+ */
129507
+ static Legacy(name) {
129508
+ if (name === undefined) {
129509
+ name = 'KEETANET';
129510
+ }
129511
+ const extraConfig = {};
129512
+ if (client_log_process !== undefined) {
129513
+ var _process$env$toUpperC, _process$env, _process$env2;
129514
+ let environmentLogLevel = (_process$env$toUpperC = (_process$env = client_log_process.env[`${name}_DEBUG`]) === null || _process$env === void 0 ? void 0 : _process$env.toUpperCase()) !== null && _process$env$toUpperC !== void 0 ? _process$env$toUpperC : 'NONE';
129515
+ if (environmentLogLevel === 'TRUE') {
129516
+ environmentLogLevel = 'DEBUG';
129517
+ } else if (environmentLogLevel === 'FALSE') {
129518
+ environmentLogLevel = 'NONE';
129519
+ }
129520
+ extraConfig.logLevel = client_assertLogTargetLevel(environmentLogLevel);
129521
+ extraConfig.filter = new RegExp((_process$env2 = client_log_process.env[`${name}_DEBUG_FILTER`]) !== null && _process$env2 !== void 0 ? _process$env2 : '', 'i');
129522
+ }
129523
+ if (client_Log.legacyLoggerInstance) {
129524
+ if (client_log_classPrivateFieldGet(client_destroyed, client_Log.legacyLoggerInstance)) {
129525
+ client_Log.legacyLoggerInstance = undefined;
129526
+ }
129527
+ }
129528
+ if (client_Log.legacyLoggerInstance) {
129529
+ return client_Log.legacyLoggerInstance;
129530
+ }
129531
+ const logger = new client_Log();
129532
+ logger.registerConsoleTarget({
129533
+ logLevel: client_Log.defaultLevel,
129534
+ ...extraConfig
129535
+ });
129536
+ client_log_classPrivateFieldSet(client_emitOnLog, logger, true);
129537
+ client_Log.legacyLoggerInstance = logger;
129538
+ return client_Log.legacyLoggerInstance;
129539
+ }
129540
+
129541
+ /**
129542
+ * Queued logs to be sent
129543
+ */
129544
+
129545
+ constructor(_options) {
129546
+ client_log_classPrivateMethodInitSpec(this, client_Log_brand);
129547
+ client_log_classPrivateFieldInitSpec(this, client_logs, []);
129548
+ /**
129549
+ * Interval holding the current autoSync process
129550
+ */
129551
+ client_log_classPrivateFieldInitSpec(this, client_autoSyncInterval, undefined);
129552
+ /**
129553
+ * Keep track of whether or not we are currently syncing
129554
+ */
129555
+ client_log_classPrivateFieldInitSpec(this, client_isSyncing, false);
129556
+ /**
129557
+ * If `sync()` is called while we are syncing, we should sync again
129558
+ * to ensure all logs are sent
129559
+ */
129560
+ client_log_classPrivateFieldInitSpec(this, client_shouldSyncAgain, false);
129561
+ /**
129562
+ * Whether or not the logger has been destroyed
129563
+ */
129564
+ client_log_classPrivateFieldInitSpec(this, client_destroyed, false);
129565
+ /**
129566
+ * Always attempt to emit logs when a new log event is added
129567
+ *
129568
+ * This is only available for the legacy logger instance
129569
+ */
129570
+ client_log_classPrivateFieldInitSpec(this, client_emitOnLog, false);
129571
+ /**
129572
+ * Whether or not to generate debug tracing information for each log entry
129573
+ */
129574
+ client_log_classPrivateFieldInitSpec(this, client_logDebugTracing, false);
129575
+ client_log_classPrivateFieldInitSpec(this, client_targets, new Map());
129576
+ /**
129577
+ * The maximum number of log entries to send to each target at a time
129578
+ */
129579
+ client_log_defineProperty(this, "batchSize", 10);
129580
+ if ((_options === null || _options === void 0 ? void 0 : _options.logDebugTracing) !== undefined) {
129581
+ client_log_classPrivateFieldSet(client_logDebugTracing, this, _options.logDebugTracing);
129582
+ }
129583
+ }
129584
+ log() {
129585
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
129586
+ args[_key] = arguments[_key];
129587
+ }
129588
+ const {
129589
+ options,
129590
+ from
129591
+ } = client_log_assertClassBrand(client_Log_brand, this, client_extractArguments).call(this, args);
129592
+ client_log_assertClassBrand(client_Log_brand, this, client_log_log).call(this, 'INFO', options, from, ...args);
129593
+ }
129594
+ info() {
129595
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
129596
+ args[_key2] = arguments[_key2];
129597
+ }
129598
+ const {
129599
+ options,
129600
+ from
129601
+ } = client_log_assertClassBrand(client_Log_brand, this, client_extractArguments).call(this, args);
129602
+ client_log_assertClassBrand(client_Log_brand, this, client_log_log).call(this, 'INFO', options, from, ...args);
129603
+ }
129604
+ debug() {
129605
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
129606
+ args[_key3] = arguments[_key3];
129607
+ }
129608
+ const {
129609
+ options,
129610
+ from
129611
+ } = client_log_assertClassBrand(client_Log_brand, this, client_extractArguments).call(this, args);
129612
+ client_log_assertClassBrand(client_Log_brand, this, client_log_log).call(this, 'DEBUG', options, from, ...args);
129613
+ }
129614
+ warn() {
129615
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
129616
+ args[_key4] = arguments[_key4];
129617
+ }
129618
+ const {
129619
+ options,
129620
+ from
129621
+ } = client_log_assertClassBrand(client_Log_brand, this, client_extractArguments).call(this, args);
129622
+ client_log_assertClassBrand(client_Log_brand, this, client_log_log).call(this, 'WARN', options, from, ...args);
129623
+ }
129624
+ error() {
129625
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
129626
+ args[_key5] = arguments[_key5];
129627
+ }
129628
+ const {
129629
+ options,
129630
+ from
129631
+ } = client_log_assertClassBrand(client_Log_brand, this, client_extractArguments).call(this, args);
129632
+
129633
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
129634
+ client_log_assertClassBrand(client_Log_brand, this, client_log_log).call(this, 'ERROR', options, from, ...args);
129635
+ }
129636
+
129637
+ /**
129638
+ * Register a new logging target (sink) to send logs to
129639
+ */
129640
+ registerTarget(target) {
129641
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
129642
+ const id = Symbol('LogTargetID');
129643
+ client_log_classPrivateFieldGet(client_targets, this).set(id, target);
129644
+ return id;
129645
+ }
129646
+
129647
+ /**
129648
+ * Register a new logging target (sink) to send logs to, using the Console target
129649
+ *
129650
+ */
129651
+ registerConsoleTarget(config) {
129652
+ const target = new client_target_console({
129653
+ ...config
129654
+ });
129655
+ return this.registerTarget(target);
129656
+ }
129657
+
129658
+ /**
129659
+ * Unregister a logging target (sink) to stop sending logs to
129660
+ */
129661
+ unregisterTarget(id) {
129662
+ client_log_classPrivateFieldGet(client_targets, this).delete(id);
129663
+ }
129664
+
129665
+ /**
129666
+ * Emit a set of logs to all registered targets
129667
+ */
129668
+ async emitLogs(logs, targets) {
129669
+ await Promise.allSettled(targets.map(async function (target) {
129670
+ await target.emitLogs(logs);
129671
+ }));
129672
+ }
129673
+
129674
+ /**
129675
+ * Start a timer to periodically sync logs to all targets
129676
+ */
129677
+ startAutoSync() {
129678
+ let rate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
129679
+ this.stopAutoSync();
129680
+ client_log_classPrivateFieldSet(client_autoSyncInterval, this, setInterval(async () => {
129681
+ try {
129682
+ await this.sync();
129683
+ } catch {
129684
+ /* Ignored */
129685
+ }
129686
+ }, rate));
129687
+ }
129688
+
129689
+ /**
129690
+ * If a timer was started with `startAutoSync()`, stop it
129691
+ */
129692
+ stopAutoSync() {
129693
+ if (!client_log_classPrivateFieldGet(client_autoSyncInterval, this)) {
129694
+ return;
129695
+ }
129696
+ clearInterval(client_log_classPrivateFieldGet(client_autoSyncInterval, this));
129697
+ client_log_classPrivateFieldSet(client_autoSyncInterval, this, undefined);
129698
+ }
129699
+
129700
+ /**
129701
+ * Sync all currently enqueued logs to all targets
129702
+ */
129703
+ async sync() {
129704
+ /*
129705
+ * If there are currently no targets, do not dequeue logs
129706
+ * in case a target is added later; However, if there are
129707
+ * too many logs, drop the oldest ones
129708
+ */
129709
+ if (client_log_classPrivateFieldGet(client_targets, this).size === 0) {
129710
+ if (client_log_classPrivateFieldGet(client_logs, this).length > client_MAX_LOGS_TO_ENQUEUE_WITH_NO_TARGETS) {
129711
+ client_log_classPrivateFieldGet(client_logs, this).splice(0, client_log_classPrivateFieldGet(client_logs, this).length - client_MAX_LOGS_TO_ENQUEUE_WITH_NO_TARGETS);
129712
+ }
129713
+ return;
129714
+ }
129715
+
129716
+ /*
129717
+ * If we are already syncing, set a flag to sync again after the current sync is done
129718
+ */
129719
+ if (client_log_classPrivateFieldGet(client_isSyncing, this)) {
129720
+ client_log_classPrivateFieldSet(client_shouldSyncAgain, this, true);
129721
+ return;
129722
+ }
129723
+ client_log_classPrivateFieldSet(client_isSyncing, this, true);
129724
+
129725
+ /*
129726
+ * Create a copy of the currently registered targets in case
129727
+ * they are modified while a sync is on-going, we use the
129728
+ * same targets until the sync is complete
129729
+ *
129730
+ * This ensures no messages are lost if all targets are removed
129731
+ * while a sync is in progress -- they will continue to be sent
129732
+ * to the registered targets at the time of the sync
129733
+ */
129734
+ const targets = Array.from(client_log_classPrivateFieldGet(client_targets, this).values());
129735
+ do {
129736
+ try {
129737
+ client_log_classPrivateFieldSet(client_shouldSyncAgain, this, false);
129738
+ while (client_log_classPrivateFieldGet(client_logs, this).length > 0) {
129739
+ const logs = client_log_classPrivateFieldGet(client_logs, this).splice(0, this.batchSize);
129740
+ await this.emitLogs(logs, targets);
129741
+ }
129742
+ } catch {
129743
+ /* Ignore errors */
129744
+ }
129745
+ } while (client_log_classPrivateFieldGet(client_shouldSyncAgain, this));
129746
+ client_log_classPrivateFieldSet(client_isSyncing, this, false);
129747
+ }
129748
+
129749
+ /**
129750
+ * Dispose of the logger instance, clearing all logs and targets
129751
+ */
129752
+ [Symbol.dispose]() {
129753
+ this.destroy();
129754
+ }
129755
+
129756
+ /**
129757
+ * Terminate the logger instance, clearing all logs and targets
129758
+ */
129759
+ destroy() {
129760
+ this.stopAutoSync();
129761
+ client_log_classPrivateFieldSet(client_logs, this, []);
129762
+ client_log_classPrivateFieldGet(client_targets, this).clear();
129763
+ client_log_classPrivateFieldSet(client_isSyncing, this, false);
129764
+ client_log_classPrivateFieldSet(client_shouldSyncAgain, this, false);
129765
+ client_log_classPrivateFieldSet(client_emitOnLog, this, false);
129766
+ client_log_classPrivateFieldSet(client_destroyed, this, true);
129767
+ }
129768
+ }
129769
+ function client_log_log(level, options, from) {
129770
+ for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
129771
+ args[_key6 - 3] = arguments[_key6];
129772
+ }
129773
+ const log = {
129774
+ options,
129775
+ level,
129776
+ from,
129777
+ args
129778
+ };
129779
+ if (client_log_classPrivateFieldGet(client_logDebugTracing, this)) {
129780
+ var _Error$stack$split$sl, _Error$stack;
129781
+ log.trace = (_Error$stack$split$sl = (_Error$stack = new Error().stack) === null || _Error$stack === void 0 ? void 0 : _Error$stack.split('\n').slice(2).join('\n')) !== null && _Error$stack$split$sl !== void 0 ? _Error$stack$split$sl : '[No stack trace available]';
129782
+ }
129783
+ client_log_classPrivateFieldGet(client_logs, this).push(log);
129784
+ if (client_log_classPrivateFieldGet(client_emitOnLog, this)) {
129785
+ void this.sync().catch(function () {
129786
+ /* Ignore errors */
129787
+ });
129788
+ }
129789
+ }
129790
+ function client_extractArguments(args) {
129791
+ let firstArgIsOptions = false;
129792
+ if (typeof args[0] === 'object' && args[0] !== null && !Array.isArray(args[0])) {
129793
+ firstArgIsOptions = true;
129794
+ }
129795
+ const options = client_assertLogOptionsParam(firstArgIsOptions ? args.shift() : {});
129796
+ const from = args.shift();
129797
+ if (typeof from !== 'string') {
129798
+ throw new Error(`Expected string for 'from', got ${typeof from}`);
129799
+ }
129800
+ return {
129801
+ options,
129802
+ from
129803
+ };
129804
+ }
129805
+ /**
129806
+ * The default log level, used for new instances of the logger
129807
+ */
129808
+ client_log_defineProperty(client_Log, "defaultLevel", 'DEBUG');
129809
+ /**
129810
+ * The Console target, which is a basic logging target that outputs
129811
+ * logs to the console
129812
+ */
129813
+ client_log_defineProperty(client_Log, "ConsoleTarget", client_target_console);
129814
+ /**
129815
+ * The existing legacy logger instance, if it exists
129816
+ */
129817
+ client_log_defineProperty(client_Log, "legacyLoggerInstance", undefined);
129818
+ /* harmony default export */ const src_client_log = (client_Log);
129023
129819
  ;// ./src/lib/node/index.ts
129024
129820
  /* provided dependency */ var client_node_process = __webpack_require__(5606);
129025
129821
  /* provided dependency */ var client_node_Buffer = __webpack_require__(8287)["Buffer"];
@@ -129061,23 +129857,6 @@ class src_client_Node {
129061
129857
  });
129062
129858
  }
129063
129859
  constructor(configOrNode) {
129064
- var _this = this;
129065
- client_node_defineProperty(this, "log", {
129066
- debug: function (from) {
129067
- var _this$config;
129068
- for (var _len = arguments.length, message = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
129069
- message[_key - 1] = arguments[_key];
129070
- }
129071
- return client_internalLogger((_this$config = _this.config) === null || _this$config === void 0 ? void 0 : _this$config.nodeAlias, 'debug', from, ...message);
129072
- },
129073
- error: function (from) {
129074
- var _this$config2;
129075
- for (var _len2 = arguments.length, message = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
129076
- message[_key2 - 1] = arguments[_key2];
129077
- }
129078
- return client_internalLogger((_this$config2 = _this.config) === null || _this$config2 === void 0 ? void 0 : _this$config2.nodeAlias, 'error', from, ...message);
129079
- }
129080
- });
129081
129860
  this.timing = new src_client_timing();
129082
129861
  if (src_client_Node.isInstance(configOrNode, false)) {
129083
129862
  const node = configOrNode;
@@ -129087,9 +129866,15 @@ class src_client_Node {
129087
129866
  this.ledger = node.ledger.copy(this);
129088
129867
  this.switch = node.switch;
129089
129868
  this.stats = node.stats;
129869
+ this.log = node.log;
129090
129870
  return;
129091
129871
  }
129092
129872
  const config = configOrNode;
129873
+ if (config.log) {
129874
+ this.log = config.log;
129875
+ } else {
129876
+ this.log = src_client_log.Legacy();
129877
+ }
129093
129878
  this.log.debug('node', 'Starting up');
129094
129879
  const {
129095
129880
  networkAddress,
@@ -129111,12 +129896,7 @@ class src_client_Node {
129111
129896
  subnet: config.subnet,
129112
129897
  initialTrustedAccount: config.initialTrustedAccount,
129113
129898
  kind: ledgerKind,
129114
- log: function () {
129115
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
129116
- args[_key3] = arguments[_key3];
129117
- }
129118
- _this.log.debug('ledger', ...args);
129119
- },
129899
+ log: this.log,
129120
129900
  ...config.ledger
129121
129901
  }, this);
129122
129902
  this.switch = new src_client_P2PSwitch(this);
@@ -129147,7 +129927,7 @@ class src_client_Node {
129147
129927
  await this.switch.stop();
129148
129928
  }
129149
129929
  async sync() {
129150
- await Promise.all([this.stats.sync(), this.switch.wait()]);
129930
+ await Promise.all([this.stats.sync(), this.switch.wait(), this.log.sync()]);
129151
129931
  }
129152
129932
  async addToLedger(votesAndBlocks) {
129153
129933
  let broadcast = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -129329,6 +130109,8 @@ client_error_kv_defineProperty(src_client_KeetaNetKVError, "isInstance", client_
129329
130109
 
129330
130110
 
129331
130111
 
130112
+
130113
+
129332
130114
  const client_allErrorCodesWithoutPrefix = [...client_AccountErrorCodes, ...client_APIErrorCodes, ...client_BlockErrorCodes, ...client_CertificateErrorCodes, ...client_ClientErrorCodes, ...client_KVErrorCodes, ...client_LedgerBaseErrorCodes, ...client_LedgerVoteErrorCodes, ...client_PermissionsErrorCodes, ...client_VoteErrorCodes];
129333
130115
  const client_allFullErrorCodes = [...client_FullAccountErrorCodes, ...client_FullAPIErrorCodes, ...client_FullBlockErrorCodes, ...client_FullCertificateErrorCodes, ...client_FullClientErrorCodes, ...client_FullKVErrorCodes, ...client_FullLedgerErrorCodes, ...client_FullPermissionsErrorCodes, ...client_FullVoteErrorCodes];
129334
130116
  const client_errorCodeSet = new Set(client_allFullErrorCodes);
@@ -129338,7 +130120,22 @@ async function client_ExpectErrorCode(code, test) {
129338
130120
  }));
129339
130121
  }
129340
130122
  class client_KeetaNetError extends src_client_KeetaNetErrorBase {
129341
- static assertValidErrorCode(code) {
130123
+ static isInstance(error) {
130124
+ if (typeof error !== 'object' || error === null) {
130125
+ return false;
130126
+ }
130127
+ if (!('code' in error)) {
130128
+ return false;
130129
+ }
130130
+ if (typeof error.code !== 'string') {
130131
+ return false;
130132
+ }
130133
+ if (!client_KeetaNetError.isValidErrorCode(error.code)) {
130134
+ return false;
130135
+ }
130136
+ return true;
130137
+ }
130138
+ static isValidErrorCode(code) {
129342
130139
  return client_errorCodeSet.has(code);
129343
130140
  }
129344
130141
  static fromJSON(json) {
@@ -129366,7 +130163,35 @@ class client_KeetaNetError extends src_client_KeetaNetErrorBase {
129366
130163
  }
129367
130164
  retryDelay = json.retryDelay;
129368
130165
  }
129369
- if (src_client_KeetaNetLedgerVoteError.assertValidLedgerErrorCode(code)) {
130166
+ if (src_client_KeetaNetLedgerIdempotentKeyError.assertValidLedgerErrorCode(code)) {
130167
+ let account;
130168
+ let idempotentKey;
130169
+ if ('account' in json) {
130170
+ if (typeof json.account !== 'string') {
130171
+ return new Error('Invalid JSON for KeetaNetLedgerIdempotentKeyError (bad account)');
130172
+ }
130173
+ account = client_lib_account.fromPublicKeyString(json.account);
130174
+ }
130175
+ if ('idempotentKey' in json) {
130176
+ if (typeof json.idempotentKey !== 'string') {
130177
+ return new Error('Invalid JSON for KeetaNetLedgerIdempotentKeyError (bad idempotentKey)');
130178
+ }
130179
+ try {
130180
+ idempotentKey = client_bufferToArrayBuffer(client_validateBase64ToBuffer(json.idempotentKey));
130181
+ } catch {
130182
+ return new Error('Invalid JSON for KeetaNetLedgerIdempotentKeyError (bad idempotentKey)');
130183
+ }
130184
+ }
130185
+ if (!('blockhash' in json) || typeof json.blockhash !== 'string') {
130186
+ return new Error('Invalid JSON for KeetaNetLedgerIdempotentKeyError (bad blockhash)');
130187
+ }
130188
+ if (!('existingBlockhash' in json) || typeof json.existingBlockhash !== 'string') {
130189
+ return new Error('Invalid JSON for KeetaNetLedgerIdempotentKeyError (bad existingBlockhash)');
130190
+ }
130191
+ const blockhash = new client_block_BlockHash(json.blockhash);
130192
+ const existingBlockhash = new client_block_BlockHash(json.existingBlockhash);
130193
+ return new src_client_KeetaNetLedgerIdempotentKeyError(code, blockhash, existingBlockhash, account, idempotentKey);
130194
+ } else if (src_client_KeetaNetLedgerVoteError.assertValidLedgerErrorCode(code)) {
129370
130195
  if (!('accounts' in json) || !Array.isArray(json.accounts)) {
129371
130196
  return new Error('Invalid JSON for KeetaNetLedgerVoteError (bad accounts)');
129372
130197
  }
@@ -129379,7 +130204,7 @@ class client_KeetaNetError extends src_client_KeetaNetErrorBase {
129379
130204
  return new client_ledger_KeetaNetLedgerError(code, message, shouldRetry, retryDelay);
129380
130205
  }
129381
130206
  }
129382
- if (this.assertValidErrorCode(code)) {
130207
+ if (this.isValidErrorCode(code)) {
129383
130208
  return new client_KeetaNetError(code, message, {
129384
130209
  type,
129385
130210
  codes: client_allErrorCodesWithoutPrefix
@@ -129468,7 +130293,7 @@ function client_deserializeBloomFilter(input) {
129468
130293
  // Blocks that will return from generateInitialVoteStaple if you are adding supply
129469
130294
 
129470
130295
  async function client_generateInitialVoteStaple(options) {
129471
- var _options$baseTokenInf, _options$baseTokenInf2, _options$baseTokenInf3, _options$baseTokenInf4;
130296
+ var _options$baseNetworkI, _options$baseNetworkI2, _options$baseNetworkI3, _options$baseNetworkI4, _options$baseNetworkI5, _options$baseNetworkI6, _options$baseNetworkI7, _options$baseNetworkI8, _options$baseTokenInf, _options$baseTokenInf2, _options$baseTokenInf3, _options$baseTokenInf4, _options$baseTokenInf5, _options$baseTokenInf6;
129472
130297
  const {
129473
130298
  network,
129474
130299
  initialTrustedAccount,
@@ -129501,10 +130326,10 @@ async function client_generateInitialVoteStaple(options) {
129501
130326
  permissions: new client_permissions_Permissions(['OWNER'])
129502
130327
  }, {
129503
130328
  type: client_lib_block.OperationType.SET_INFO,
129504
- name: 'KEETANET',
129505
- description: 'Network Address For KeetaNet',
129506
- metadata: '',
129507
- defaultPermission: new client_permissions_Permissions(['STORAGE_CREATE'])
130329
+ name: (_options$baseNetworkI = (_options$baseNetworkI2 = options.baseNetworkInfo) === null || _options$baseNetworkI2 === void 0 ? void 0 : _options$baseNetworkI2.name) !== null && _options$baseNetworkI !== void 0 ? _options$baseNetworkI : 'KEETANET',
130330
+ description: (_options$baseNetworkI3 = (_options$baseNetworkI4 = options.baseNetworkInfo) === null || _options$baseNetworkI4 === void 0 ? void 0 : _options$baseNetworkI4.description) !== null && _options$baseNetworkI3 !== void 0 ? _options$baseNetworkI3 : 'Network Address For KeetaNet',
130331
+ metadata: (_options$baseNetworkI5 = (_options$baseNetworkI6 = options.baseNetworkInfo) === null || _options$baseNetworkI6 === void 0 ? void 0 : _options$baseNetworkI6.metadata) !== null && _options$baseNetworkI5 !== void 0 ? _options$baseNetworkI5 : '',
130332
+ defaultPermission: (_options$baseNetworkI7 = (_options$baseNetworkI8 = options.baseNetworkInfo) === null || _options$baseNetworkI8 === void 0 ? void 0 : _options$baseNetworkI8.defaultPermission) !== null && _options$baseNetworkI7 !== void 0 ? _options$baseNetworkI7 : new client_permissions_Permissions(['STORAGE_CREATE'])
129508
130333
  }]
129509
130334
  }).seal();
129510
130335
  setPrevious(networkAddress, blocks.networkAddress);
@@ -129534,7 +130359,7 @@ async function client_generateInitialVoteStaple(options) {
129534
130359
  metadata: options.baseTokenInfo ? btoa(JSON.stringify({
129535
130360
  decimalPlaces: options.baseTokenInfo.decimalPlaces
129536
130361
  })) : '',
129537
- defaultPermission: new client_permissions_Permissions(['ACCESS'])
130362
+ defaultPermission: (_options$baseTokenInf5 = (_options$baseTokenInf6 = options.baseTokenInfo) === null || _options$baseTokenInf6 === void 0 ? void 0 : _options$baseTokenInf6.defaultPermission) !== null && _options$baseTokenInf5 !== void 0 ? _options$baseTokenInf5 : new client_permissions_Permissions(['ACCESS'])
129538
130363
  }, ...additionalBaseTokenOperations]
129539
130364
  }).seal();
129540
130365
  setPrevious(baseToken, blocks.baseToken);
@@ -129606,6 +130431,7 @@ async function client_generateInitialVoteStaple(options) {
129606
130431
 
129607
130432
 
129608
130433
 
130434
+
129609
130435
  /* harmony default export */ const client_src_lib = ({
129610
130436
  /**
129611
130437
  * The `Account` module provides functionality for managing key pairs
@@ -129615,6 +130441,7 @@ async function client_generateInitialVoteStaple(options) {
129615
130441
  Block: client_lib_block,
129616
130442
  Error: client_KeetaNetError,
129617
130443
  Ledger: src_client_ledger,
130444
+ Log: src_client_log,
129618
130445
  Node: client_node,
129619
130446
  P2P: client_p2p,
129620
130447
  Permissions: client_permissions_Permissions,
@@ -131945,6 +132772,38 @@ class src_client_Client {
131945
132772
  }
131946
132773
  return successorStaple;
131947
132774
  }
132775
+
132776
+ /**
132777
+ * Fetch a block from a given idempotent key
132778
+ * @param account The account associated with the idempotent key
132779
+ * @param idempotent The idempotent key to check
132780
+ */
132781
+ async getBlockFromIdempotent(account, idempotent) {
132782
+ let side = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'main';
132783
+ let rep = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'ANY';
132784
+ account = client_lib_account.toAccount(account);
132785
+ const accountPubKey = account.publicKeyString.get();
132786
+ const query = {
132787
+ side: client_assertLedgerStorage(side)
132788
+ };
132789
+ let idempotentBase64;
132790
+ if (typeof idempotent === 'string') {
132791
+ idempotentBase64 = idempotent;
132792
+ } else {
132793
+ idempotentBase64 = client_client_Buffer.from(idempotent).toString('base64');
132794
+ }
132795
+ const result = await client_client_assertClassBrand(client_Client_brand, this, src_client_api).call(this, rep, 'GET /node/ledger/account/:account/idempotent/:idempotent', {
132796
+ queryParams: query,
132797
+ args: {
132798
+ account: accountPubKey,
132799
+ idempotent: idempotentBase64
132800
+ }
132801
+ });
132802
+ if (result.block === null) {
132803
+ return null;
132804
+ }
132805
+ return new client_lib_block(result.block);
132806
+ }
131948
132807
  async getVoteQuotes(blocks) {
131949
132808
  return await client_client_assertClassBrand(client_Client_brand, this, client_requestQuotes).call(this, blocks);
131950
132809
  }
@@ -132107,8 +132966,7 @@ async function client_apiRaw(rep, api, method) {
132107
132966
  break;
132108
132967
  }
132109
132968
  if (resultThrow) {
132110
- const toThrow = client_KeetaNetError.fromJSON(resultThrow);
132111
- throw toThrow;
132969
+ throw resultThrow;
132112
132970
  }
132113
132971
  return result;
132114
132972
  }
@@ -132347,6 +133205,9 @@ function client_formatAccountInfo(raw) {
132347
133205
  if (raw.defaultPermission !== undefined) {
132348
133206
  info.defaultPermission = client_client_assertClassBrand(client_Client_brand, this, client_parseResponsePermissions).call(this, raw.defaultPermission);
132349
133207
  }
133208
+ if (raw.multisigQuorum !== undefined) {
133209
+ info.multisigQuorum = BigInt(raw.multisigQuorum);
133210
+ }
132350
133211
  return info;
132351
133212
  }
132352
133213
  function client_parseAccountInfo(account, accountInfo) {
@@ -132690,7 +133551,8 @@ class src_client_UserClient {
132690
133551
  delegateTo = this.client.representatives[0].key,
132691
133552
  addSupplyAmount,
132692
133553
  voteSerial = 0n,
132693
- baseTokenInfo
133554
+ baseTokenInfo,
133555
+ baseNetworkInfo
132694
133556
  } = initOpts;
132695
133557
  if (this.signer === null) {
132696
133558
  throw new Error('May not initialize chain with a read-only UserClient (signer is null)');
@@ -132707,7 +133569,8 @@ class src_client_UserClient {
132707
133569
  recipient: client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options).assertAccount(),
132708
133570
  amount: addSupplyAmount
132709
133571
  },
132710
- baseTokenInfo
133572
+ baseTokenInfo,
133573
+ baseNetworkInfo
132711
133574
  });
132712
133575
  return await this.client.transmitStaple(voteStaple);
132713
133576
  }
@@ -133185,6 +134048,16 @@ class src_client_UserClient {
133185
134048
  return await client_client_classPrivateFieldGet(client_client, this).recoverAccount(client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options), publish);
133186
134049
  }
133187
134050
 
134051
+ /**
134052
+ * Fetch a block from a given idempotent key
134053
+ * @param idempotent The idempotent key to check
134054
+ * @param options User client options (common options)
134055
+ */
134056
+ async getBlockFromIdempotent(idempotent) {
134057
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
134058
+ return await client_client_classPrivateFieldGet(client_client, this).getBlockFromIdempotent(client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options), idempotent);
134059
+ }
134060
+
133188
134061
  /**
133189
134062
  * Sync any partially-published account artifacts
133190
134063
  *