@keetanetwork/keetanet-client 0.14.11 → 0.14.12

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 (119) hide show
  1. package/client/index-browser.js +656 -9
  2. package/client/index.js +573 -8
  3. package/docs/assets/hierarchy.js +1 -1
  4. package/docs/assets/search.js +1 -1
  5. package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
  6. package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
  7. package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
  8. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
  9. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
  10. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
  11. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
  12. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
  13. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
  14. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
  15. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  16. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  17. package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
  18. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
  19. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
  20. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
  21. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
  22. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
  23. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
  24. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
  25. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
  26. package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
  27. package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
  28. package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
  29. package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
  30. package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
  31. package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
  32. package/docs/classes/KeetaNetSDK.Referenced.IdempotentKey.html +1 -1
  33. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
  34. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
  35. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +1 -1
  36. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +1 -1
  37. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerIdempotentKeyError.html +1 -1
  38. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +1 -1
  39. package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
  40. package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
  41. package/docs/classes/KeetaNetSDK.Referenced.Log.html +6 -4
  42. package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
  43. package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
  44. package/docs/classes/KeetaNetSDK.Referenced.RequestTiming.html +1 -1
  45. package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
  46. package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
  47. package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
  48. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +1 -1
  49. package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
  50. package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +1 -1
  51. package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
  52. package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
  53. package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
  54. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.html +32 -4
  55. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
  56. package/docs/hierarchy.html +1 -1
  57. package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
  58. package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
  59. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
  60. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
  61. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
  62. package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
  63. package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
  64. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
  65. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
  66. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
  67. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
  68. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +1 -1
  69. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
  70. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
  71. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
  72. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
  73. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
  74. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  75. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  76. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
  77. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
  78. package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
  79. package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
  80. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
  81. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
  82. package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
  83. package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
  84. package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
  85. package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
  86. package/docs/interfaces/KeetaNetSDK.Referenced.Logger.html +4 -2
  87. package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
  88. package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
  89. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
  90. package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
  91. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
  92. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
  93. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
  94. package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
  95. package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
  96. package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
  97. package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
  98. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
  99. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
  100. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
  101. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
  102. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
  103. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Struct.html +1 -1
  104. package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
  105. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.html +1 -1
  106. package/docs/types/KeetaNetSDK.Referenced.BasicSchemaMapJS.html +14 -0
  107. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.Schema.html +1 -1
  108. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.SchemaMap.html +1 -1
  109. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.SchemaMapJS.html +5 -0
  110. package/lib/kv/kv_redis.d.ts +3 -3
  111. package/lib/log/common.d.ts +4 -0
  112. package/lib/log/index.d.ts +4 -0
  113. package/lib/log/target_gcp.d.ts +1 -1
  114. package/lib/log/target_gcp.js +2 -2
  115. package/lib/node/timing.d.ts +4 -3
  116. package/lib/utils/asn1.d.ts +139 -5
  117. package/npm-shrinkwrap.json +2 -2
  118. package/package.json +1 -1
  119. package/version.d.ts +1 -1
@@ -113844,7 +113844,8 @@ var client_schema = /*#__PURE__*/new WeakMap();
113844
113844
  * - {@link ValidateASN1.IsNull}
113845
113845
  *
113846
113846
  * More complex types are defined as:
113847
- * - Choice: `{ choice: [ schema1, schema2, ... ] }`
113847
+ * - Choice (named): `{ choice: { name1: schema1, name2: schema2, ... } }` - Converts to `{ name1: value }` or `{ name2: value }`
113848
+ * - Choice (legacy array): `{ choice: [ schema1, schema2, ... ] }` - Converts to union type (ambiguous for re-encoding)
113848
113849
  * - Sequence of: `{ sequenceOf: schema }`
113849
113850
  * - Optional: `{ optional: schema }`
113850
113851
  * - Context Tag: `{ type: 'context'; kind: 'implicit' | 'explicit'; contains: schema; value: number }`
@@ -114197,6 +114198,7 @@ class client_ValidateASN1 {
114197
114198
  {
114198
114199
  const outputStruct = {
114199
114200
  type: 'struct',
114201
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114200
114202
  fieldNames: schema.fieldNames,
114201
114203
  contains: {}
114202
114204
  };
@@ -114228,6 +114230,49 @@ class client_ValidateASN1 {
114228
114230
  client_assertNever(schema);
114229
114231
  }
114230
114232
  } else if ('choice' in schema) {
114233
+ // Handle named choices: { choice: { a: schema1, b: schema2 } }
114234
+ if (!Array.isArray(schema.choice)) {
114235
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114236
+ const choiceObj = schema.choice;
114237
+
114238
+ // For context tags, match by value and kind
114239
+ if (client_isASN1ContextTag(input)) {
114240
+ const inputAsChoice = input;
114241
+ for (const choiceName in choiceObj) {
114242
+ const choice = choiceObj[choiceName];
114243
+ if (choice === undefined) {
114244
+ continue;
114245
+ }
114246
+ if (!client_isASN1ContextTag(choice)) {
114247
+ continue;
114248
+ }
114249
+ if (choice.value !== inputAsChoice.value) {
114250
+ continue;
114251
+ }
114252
+ if (choice.kind !== inputAsChoice.kind) {
114253
+ continue;
114254
+ }
114255
+ return client_ValidateASN1.againstSchema(input, choice);
114256
+ }
114257
+ throw new Error('No valid choice found');
114258
+ }
114259
+
114260
+ // Try each choice
114261
+ for (const choiceName in choiceObj) {
114262
+ const choice = choiceObj[choiceName];
114263
+ if (choice === undefined) {
114264
+ continue;
114265
+ }
114266
+ try {
114267
+ return client_ValidateASN1.againstSchema(input, choice);
114268
+ } catch (_ignored_checkError) {
114269
+ /* Ignored error */
114270
+ }
114271
+ }
114272
+ throw new Error('No valid choice found');
114273
+ }
114274
+
114275
+ // Handle array choices (legacy)
114231
114276
  if (client_isASN1ContextTag(input)) {
114232
114277
  const inputAsChoice = input;
114233
114278
  const matchingSchema = schema.choice.find(function (choice) {
@@ -114249,7 +114294,6 @@ class client_ValidateASN1 {
114249
114294
  }
114250
114295
  for (const choice of schema.choice) {
114251
114296
  try {
114252
- // @ts-ignore
114253
114297
  return client_ValidateASN1.againstSchema(input, choice);
114254
114298
  } catch (_ignored_checkError) {
114255
114299
  /* Ignored error */
@@ -114339,6 +114383,578 @@ class client_ValidateASN1 {
114339
114383
  validate(input) {
114340
114384
  return client_ValidateASN1.againstSchema(input, client_asn1_classPrivateFieldGet(client_schema, this));
114341
114385
  }
114386
+
114387
+ /**
114388
+ * Convert an ASN.1 object to a JavaScript object (including primitives)
114389
+ * based on the schema.
114390
+ *
114391
+ * Converts ASN1 objects to plain JavaScript objects according to the schema:
114392
+ * - Structs are converted to plain objects with field names as keys
114393
+ * - For ambiguous types (IsAnyString, IsAnyDate), returns ASN.1-like objects: { type: 'string', kind: 'utf8', value: 'text' }
114394
+ * - Arrays/sequences are preserved as arrays
114395
+ * - Primitive types (bigint, string, boolean, null, Buffer, Date) are preserved
114396
+ *
114397
+ * Example schema: { type: 'struct', fieldNames: ['name', 'age'], contains: { name: ValidateASN1.IsAnyString, age: ValidateASN1.IsInteger } }
114398
+ * Input: { type: 'struct', fieldNames: ['name', 'age'], contains: { name: { type: 'string', kind: 'utf8', value: 'John Doe' }, age: 30n } }
114399
+ * Output: { name: { type: 'string', kind: 'utf8', value: 'John Doe' }, age: 30n }
114400
+ */
114401
+ toJavaScriptObject(input) {
114402
+ this.validate(input);
114403
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114404
+ return client_ValidateASN1.toPlainObject(input, client_asn1_classPrivateFieldGet(client_schema, this));
114405
+ }
114406
+
114407
+ /**
114408
+ * Convert a plain JavaScript object back to an ASN.1 object based on the schema.
114409
+ *
114410
+ * Converts plain JavaScript objects back to ASN1 representation according to the schema:
114411
+ * - Plain objects with field names are converted to ASN1Struct
114412
+ * - For ambiguous schemas, recognizes ASN.1-like objects: { type: 'string', kind: 'utf8', value: 'text' }
114413
+ * - Arrays are preserved as sequences
114414
+ * - Primitive types are preserved or wrapped in appropriate ASN1 types
114415
+ *
114416
+ * Example schema: { type: 'struct', fieldNames: ['name', 'age'], contains: { name: ValidateASN1.IsAnyString, age: ValidateASN1.IsInteger } }
114417
+ * Input: { name: { type: 'string', kind: 'utf8', value: 'John Doe' }, age: 30n }
114418
+ * Output: { type: 'struct', fieldNames: ['name', 'age'], contains: { name: { type: 'string', kind: 'utf8', value: 'John Doe' }, age: 30n } }
114419
+ */
114420
+ fromJavaScriptObject(input) {
114421
+ const retval = client_ValidateASN1.fromPlainObject(input, client_asn1_classPrivateFieldGet(client_schema, this));
114422
+ this.validate(retval);
114423
+ return retval;
114424
+ }
114425
+
114426
+ /**
114427
+ * Convert an ASN.1 object to a plain JavaScript object based on a schema
114428
+ */
114429
+ static toPlainObject(input, schemaIn) {
114430
+ let schema = schemaIn;
114431
+ if (typeof schema === 'function') {
114432
+ schema = schema();
114433
+ }
114434
+
114435
+ // Handle choice schemas first (before primitive checks)
114436
+ // This ensures named choices wrap their values correctly
114437
+ if (typeof schema === 'object' && schema !== null && 'choice' in schema) {
114438
+ // Handle named choices: { choice: { a: schema1, b: schema2 } }
114439
+ if (!Array.isArray(schema.choice)) {
114440
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114441
+ const choiceObj = schema.choice;
114442
+ for (const choiceName in choiceObj) {
114443
+ const choiceSchema = choiceObj[choiceName];
114444
+ if (choiceSchema === undefined) {
114445
+ continue;
114446
+ }
114447
+ try {
114448
+ // Validate that the input matches this choice schema
114449
+ client_ValidateASN1.againstSchema(input, choiceSchema);
114450
+ // If validation passes, convert and wrap in named object
114451
+ const converted = client_ValidateASN1.toPlainObject(input, choiceSchema);
114452
+ return {
114453
+ [choiceName]: converted
114454
+ };
114455
+ } catch {
114456
+ // Try next choice
114457
+ }
114458
+ }
114459
+ throw new Error('No valid choice found');
114460
+ }
114461
+
114462
+ // Handle array choices (legacy): { choice: [schema1, schema2] }
114463
+ // For choices, recursively convert the selected choice
114464
+ for (const choice of schema.choice) {
114465
+ try {
114466
+ return client_ValidateASN1.toPlainObject(input, choice);
114467
+ } catch {
114468
+ // Try next choice
114469
+ }
114470
+ }
114471
+ throw new Error('No valid choice found');
114472
+ }
114473
+
114474
+ // Handle primitives that don't need conversion
114475
+ if (typeof input === 'bigint' || typeof input === 'boolean' || input === null || client_isBuffer(input) || client_util.types.isDate(input)) {
114476
+ return input;
114477
+ }
114478
+
114479
+ // Handle plain strings
114480
+ if (typeof input === 'string') {
114481
+ return input;
114482
+ }
114483
+
114484
+ // Handle basic schema types
114485
+ if (typeof schema === 'symbol') {
114486
+ switch (schema) {
114487
+ case client_ValidateASN1.IsInteger:
114488
+ case client_ValidateASN1.IsBoolean:
114489
+ case client_ValidateASN1.IsNull:
114490
+ case client_ValidateASN1.IsOctetString:
114491
+ case client_ValidateASN1.IsString:
114492
+ case client_ValidateASN1.IsDate:
114493
+ return input;
114494
+ case client_ValidateASN1.IsAnyString:
114495
+ if (client_isASN1String(input)) {
114496
+ // For ambiguous schemas, return ASN.1-like object
114497
+ return {
114498
+ type: 'string',
114499
+ kind: input.kind,
114500
+ value: input.value
114501
+ };
114502
+ }
114503
+ return input;
114504
+ case client_ValidateASN1.IsAnyDate:
114505
+ if (client_isASN1Date(input)) {
114506
+ // For ambiguous schemas, return ASN.1-like object
114507
+ return {
114508
+ type: 'date',
114509
+ kind: input.kind,
114510
+ value: input.date
114511
+ };
114512
+ }
114513
+ return input;
114514
+ case client_ValidateASN1.IsBitString:
114515
+ if (client_isASN1BitString(input)) {
114516
+ // Use expanded form to preserve unusedBits information
114517
+ // This distinguishes between bit strings like 111 and 0111
114518
+ return {
114519
+ type: 'bitstring',
114520
+ value: input.value,
114521
+ unusedBits: input.unusedBits
114522
+ };
114523
+ }
114524
+ return input;
114525
+ case client_ValidateASN1.IsOID:
114526
+ if (client_isASN1OID(input)) {
114527
+ return input.oid;
114528
+ }
114529
+ return input;
114530
+ case client_ValidateASN1.IsSet:
114531
+ return input;
114532
+ case client_ValidateASN1.IsAny:
114533
+ case client_ValidateASN1.IsUnknown:
114534
+ return input;
114535
+ }
114536
+ }
114537
+
114538
+ // Handle bigint schema (fixed value)
114539
+ if (typeof schema === 'bigint') {
114540
+ return input;
114541
+ }
114542
+
114543
+ // Handle object schemas
114544
+ if (typeof schema === 'object' && schema !== null) {
114545
+ if ('type' in schema) {
114546
+ switch (schema.type) {
114547
+ case 'struct':
114548
+ {
114549
+ if (!client_isASN1Struct(input)) {
114550
+ throw new Error('Expected ASN1Struct');
114551
+ }
114552
+ const result = {};
114553
+ for (const fieldName of schema.fieldNames) {
114554
+ const fieldValue = input.contains[fieldName];
114555
+ if (fieldValue === undefined) {
114556
+ continue;
114557
+ }
114558
+ const fieldSchema = schema.contains[fieldName];
114559
+ if (client_isASN1ContextTag(fieldValue)) {
114560
+ // Context tags are metadata like optional - unwrap them completely
114561
+ // Need to unwrap optional and get the context tag schema
114562
+ let contextSchema = fieldSchema;
114563
+ if (typeof contextSchema === 'object' && contextSchema !== null && 'optional' in contextSchema) {
114564
+ contextSchema = contextSchema.optional;
114565
+ }
114566
+
114567
+ // For implicit context tags with ArrayBuffer, can't convert further
114568
+ if (fieldValue.kind === 'implicit' && client_util.types.isArrayBuffer(fieldValue.contains)) {
114569
+ result[fieldName] = fieldValue.contains;
114570
+ } else if (typeof contextSchema === 'object' && contextSchema !== null && 'type' in contextSchema && contextSchema.type === 'context' && 'contains' in contextSchema) {
114571
+ // Unwrap the context tag - just convert the inner value
114572
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114573
+ result[fieldName] = client_ValidateASN1.toPlainObject(fieldValue.contains, contextSchema.contains);
114574
+ } else {
114575
+ // Fallback: convert the inner value with full field schema
114576
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114577
+ result[fieldName] = client_ValidateASN1.toPlainObject(fieldValue.contains, fieldSchema);
114578
+ }
114579
+ } else {
114580
+ // For all other types (including strings and dates), recursively convert
114581
+ const plainValue = client_ValidateASN1.toPlainObject(fieldValue, fieldSchema);
114582
+ result[fieldName] = plainValue;
114583
+ }
114584
+ }
114585
+ return result;
114586
+ }
114587
+ case 'string':
114588
+ if (client_isASN1String(input)) {
114589
+ return input.value;
114590
+ }
114591
+ return input;
114592
+ case 'date':
114593
+ if (client_isASN1Date(input)) {
114594
+ return input.date;
114595
+ }
114596
+ return input;
114597
+ case 'oid':
114598
+ if (client_isASN1OID(input)) {
114599
+ return input.oid;
114600
+ }
114601
+ return input;
114602
+ case 'context':
114603
+ if (client_isASN1ContextTag(input)) {
114604
+ // For implicit context tags with ArrayBuffer, we can't convert further
114605
+ if (input.kind === 'implicit' && client_util.types.isArrayBuffer(input.contains)) {
114606
+ return input.contains;
114607
+ }
114608
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114609
+ return client_ValidateASN1.toPlainObject(input.contains, schema.contains);
114610
+ }
114611
+ return input;
114612
+ }
114613
+ }
114614
+ if ('sequenceOf' in schema) {
114615
+ if (!Array.isArray(input)) {
114616
+ throw new Error('Expected array for sequenceOf');
114617
+ }
114618
+ return input.map(item => client_ValidateASN1.toPlainObject(item, schema.sequenceOf));
114619
+ }
114620
+ if ('optional' in schema) {
114621
+ if (input === undefined) {
114622
+ return undefined;
114623
+ }
114624
+ return client_ValidateASN1.toPlainObject(input, schema.optional);
114625
+ }
114626
+ if (Array.isArray(schema)) {
114627
+ if (!Array.isArray(input)) {
114628
+ throw new Error('Expected array');
114629
+ }
114630
+ const result = [];
114631
+ for (let i = 0; i < Math.min(input.length, schema.length); i++) {
114632
+ const item = input[i];
114633
+ if (item === undefined) {
114634
+ result.push(undefined);
114635
+ } else {
114636
+ result.push(client_ValidateASN1.toPlainObject(item, schema[i]));
114637
+ }
114638
+ }
114639
+ return result;
114640
+ }
114641
+ }
114642
+ return input;
114643
+ }
114644
+
114645
+ /**
114646
+ * Convert a plain JavaScript object to an ASN.1 object based on a schema
114647
+ */
114648
+ static fromPlainObject(input, schemaIn) {
114649
+ let schema = schemaIn;
114650
+ if (typeof schema === 'function') {
114651
+ schema = schema();
114652
+ }
114653
+
114654
+ // Handle null/undefined
114655
+ if (input === null || input === undefined) {
114656
+ /* Verify that the schema for this is actually is nullable */
114657
+ let nullable = false;
114658
+ if (schema === client_ValidateASN1.IsNull) {
114659
+ nullable = true;
114660
+ } else if (typeof schema === 'object' && schema !== null) {
114661
+ if ('optional' in schema) {
114662
+ nullable = true;
114663
+ }
114664
+ }
114665
+ if (!nullable) {
114666
+ throw new Error(`Expected non-null value, got ${input}`);
114667
+ }
114668
+
114669
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114670
+ return input;
114671
+ }
114672
+
114673
+ // For ambiguous schemas (IsAnyString, IsAnyDate), check if input is already in ASN.1-like format
114674
+ // These are objects like { type: 'string', kind: 'utf8', value: 'text' } or { type: 'date', kind: 'general', value: Date }
114675
+ // Also handle expanded bitstring format: { type: 'bitstring', value: Buffer, unusedBits: number }
114676
+ if (typeof input === 'object' && input !== null && !client_isBuffer(input) && !client_util.types.isDate(input) && !Array.isArray(input)) {
114677
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114678
+ const inputObj = input;
114679
+
114680
+ // Check for string-like format: { type: 'string', kind, value }
114681
+ if (inputObj.type === 'string' && typeof inputObj.kind === 'string' && 'value' in inputObj) {
114682
+ const kind = inputObj.kind;
114683
+ if (kind === 'printable' || kind === 'ia5' || kind === 'utf8') {
114684
+ if (typeof inputObj.value === 'string') {
114685
+ return {
114686
+ type: 'string',
114687
+ kind,
114688
+ value: inputObj.value
114689
+ };
114690
+ }
114691
+ }
114692
+ }
114693
+
114694
+ // Check for date-like format: { type: 'date', kind, value }
114695
+ if (inputObj.type === 'date' && typeof inputObj.kind === 'string' && 'value' in inputObj) {
114696
+ const kind = inputObj.kind;
114697
+ if (kind === 'utc' || kind === 'general') {
114698
+ if (client_util.types.isDate(inputObj.value)) {
114699
+ return {
114700
+ type: 'date',
114701
+ kind,
114702
+ date: inputObj.value
114703
+ };
114704
+ }
114705
+ }
114706
+ }
114707
+
114708
+ // Check for bitstring format: { type: 'bitstring', value, unusedBits }
114709
+ if (inputObj.type === 'bitstring' && 'value' in inputObj && 'unusedBits' in inputObj) {
114710
+ if (client_isBuffer(inputObj.value) && typeof inputObj.unusedBits === 'number') {
114711
+ return {
114712
+ type: 'bitstring',
114713
+ value: inputObj.value,
114714
+ unusedBits: inputObj.unusedBits
114715
+ };
114716
+ }
114717
+ }
114718
+ }
114719
+
114720
+ // Check schema FIRST before doing any primitive handling
114721
+ // This is important for context tags and other wrappers
114722
+
114723
+ // Handle object schemas
114724
+ if (typeof schema === 'object' && schema !== null) {
114725
+ if ('type' in schema) {
114726
+ switch (schema.type) {
114727
+ case 'context':
114728
+ {
114729
+ // Context tags: reconstruct from schema definition (metadata like optional)
114730
+ // Schema has the kind and value, input is the plain value
114731
+ // At this point we know schema.type === 'context', so it must have kind, value, contains
114732
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114733
+ const contextTagSchema = schema;
114734
+ return {
114735
+ type: 'context',
114736
+ kind: contextTagSchema.kind,
114737
+ value: contextTagSchema.value,
114738
+ contains: client_ValidateASN1.fromPlainObject(input, contextTagSchema.contains)
114739
+ };
114740
+ }
114741
+ case 'struct':
114742
+ {
114743
+ if (typeof input !== 'object' || input === null) {
114744
+ throw new Error('Expected object for struct');
114745
+ }
114746
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114747
+ const inputObj = input;
114748
+ const result = {
114749
+ type: 'struct',
114750
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114751
+ fieldNames: schema.fieldNames,
114752
+ contains: {}
114753
+ };
114754
+ for (const fieldName of schema.fieldNames) {
114755
+ const fieldValue = inputObj[fieldName];
114756
+ if (fieldValue === undefined) {
114757
+ continue;
114758
+ }
114759
+ const fieldSchema = schema.contains[fieldName];
114760
+ result.contains[fieldName] = client_ValidateASN1.fromPlainObject(fieldValue, fieldSchema);
114761
+ }
114762
+ return result;
114763
+ }
114764
+ case 'string':
114765
+ if (typeof input === 'string') {
114766
+ return {
114767
+ type: 'string',
114768
+ kind: schema.kind,
114769
+ value: input
114770
+ };
114771
+ }
114772
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114773
+ return input;
114774
+ case 'date':
114775
+ if (client_util.types.isDate(input)) {
114776
+ return {
114777
+ type: 'date',
114778
+ kind: schema.kind,
114779
+ date: input
114780
+ };
114781
+ }
114782
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114783
+ return input;
114784
+ case 'oid':
114785
+ if (typeof input === 'string') {
114786
+ return {
114787
+ type: 'oid',
114788
+ oid: input
114789
+ };
114790
+ }
114791
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114792
+ return input;
114793
+ }
114794
+ }
114795
+ if ('choice' in schema) {
114796
+ // Handle named choices: { choice: { a: schema1, b: schema2 } }
114797
+ if (!Array.isArray(schema.choice)) {
114798
+ if (typeof input === 'object' && input !== null && !client_isBuffer(input) && !client_util.types.isDate(input)) {
114799
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114800
+ const inputObj = input;
114801
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114802
+ const choiceObj = schema.choice;
114803
+
114804
+ // Find which choice name is present in the input
114805
+ for (const choiceName in choiceObj) {
114806
+ if (choiceName in inputObj) {
114807
+ const choiceSchema = choiceObj[choiceName];
114808
+ if (choiceSchema === undefined) {
114809
+ continue;
114810
+ }
114811
+ const choiceValue = inputObj[choiceName];
114812
+ return client_ValidateASN1.fromPlainObject(choiceValue, choiceSchema);
114813
+ }
114814
+ }
114815
+ }
114816
+ throw new Error('No valid choice found for input - expected object with one of: ' + Object.keys(schema.choice).join(', '));
114817
+ }
114818
+
114819
+ // Handle array choices (legacy): { choice: [schema1, schema2] }
114820
+ // For choices, try to convert with each choice schema
114821
+ for (const choice of schema.choice) {
114822
+ try {
114823
+ return client_ValidateASN1.fromPlainObject(input, choice);
114824
+ } catch {
114825
+ // Try next choice
114826
+ }
114827
+ }
114828
+ throw new Error('No valid choice found for input');
114829
+ }
114830
+ if ('sequenceOf' in schema) {
114831
+ if (!Array.isArray(input)) {
114832
+ throw new Error('Expected array for sequenceOf');
114833
+ }
114834
+ return input.map(item => client_ValidateASN1.fromPlainObject(item, schema.sequenceOf));
114835
+ }
114836
+ if ('optional' in schema) {
114837
+ return client_ValidateASN1.fromPlainObject(input, schema.optional);
114838
+ }
114839
+ if (Array.isArray(schema)) {
114840
+ if (!Array.isArray(input)) {
114841
+ throw new Error('Expected array');
114842
+ }
114843
+ const result = [];
114844
+ for (let i = 0; i < schema.length; i++) {
114845
+ if (i < input.length && input[i] !== undefined) {
114846
+ result.push(client_ValidateASN1.fromPlainObject(input[i], schema[i]));
114847
+ } else if (client_isASN1ModifierOptional(schema[i])) {
114848
+ result.push(undefined);
114849
+ } else {
114850
+ throw new Error(`Missing required field at index ${i}`);
114851
+ }
114852
+ }
114853
+ return result;
114854
+ }
114855
+ }
114856
+
114857
+ // Handle symbol schemas (basic types)
114858
+ if (typeof schema === 'symbol') {
114859
+ switch (schema) {
114860
+ case client_ValidateASN1.IsInteger:
114861
+ case client_ValidateASN1.IsBoolean:
114862
+ case client_ValidateASN1.IsNull:
114863
+ case client_ValidateASN1.IsDate:
114864
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114865
+ return input;
114866
+ case client_ValidateASN1.IsOctetString:
114867
+ // OctetString can accept a Buffer directly
114868
+ if (client_isBuffer(input)) {
114869
+ return input;
114870
+ }
114871
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114872
+ return input;
114873
+ case client_ValidateASN1.IsString:
114874
+ if (typeof input === 'string') {
114875
+ return input;
114876
+ }
114877
+ throw new Error('Expected string');
114878
+ case client_ValidateASN1.IsAnyString:
114879
+ if (typeof input === 'string') {
114880
+ // Determine appropriate string kind
114881
+ if (client_isStringValidForKind(input, 'printable')) {
114882
+ return {
114883
+ type: 'string',
114884
+ kind: 'printable',
114885
+ value: input
114886
+ };
114887
+ } else if (client_isStringValidForKind(input, 'ia5')) {
114888
+ return {
114889
+ type: 'string',
114890
+ kind: 'ia5',
114891
+ value: input
114892
+ };
114893
+ } else {
114894
+ return {
114895
+ type: 'string',
114896
+ kind: 'utf8',
114897
+ value: input
114898
+ };
114899
+ }
114900
+ }
114901
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114902
+ return input;
114903
+ case client_ValidateASN1.IsAnyDate:
114904
+ if (client_util.types.isDate(input)) {
114905
+ if (input.getUTCFullYear() < 2050) {
114906
+ return {
114907
+ type: 'date',
114908
+ kind: 'utc',
114909
+ date: input
114910
+ };
114911
+ } else {
114912
+ return {
114913
+ type: 'date',
114914
+ kind: 'general',
114915
+ date: input
114916
+ };
114917
+ }
114918
+ }
114919
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114920
+ return input;
114921
+ case client_ValidateASN1.IsBitString:
114922
+ if (client_isBuffer(input)) {
114923
+ return {
114924
+ type: 'bitstring',
114925
+ value: input,
114926
+ unusedBits: 0
114927
+ };
114928
+ }
114929
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114930
+ return input;
114931
+ case client_ValidateASN1.IsOID:
114932
+ if (typeof input === 'string') {
114933
+ return {
114934
+ type: 'oid',
114935
+ oid: input
114936
+ };
114937
+ }
114938
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114939
+ return input;
114940
+ case client_ValidateASN1.IsSet:
114941
+ case client_ValidateASN1.IsAny:
114942
+ case client_ValidateASN1.IsUnknown:
114943
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114944
+ return input;
114945
+ }
114946
+ }
114947
+
114948
+ // Handle bigint schema (fixed value)
114949
+ if (typeof schema === 'bigint') {
114950
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114951
+ return input;
114952
+ }
114953
+
114954
+ // Default: return input as-is
114955
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
114956
+ return input;
114957
+ }
114342
114958
  }
114343
114959
 
114344
114960
  /**
@@ -125606,6 +126222,10 @@ class client_Log {
125606
126222
  * Register a new logging target (sink) to send logs to
125607
126223
  */
125608
126224
  registerTarget(target) {
126225
+ if (client_log_classPrivateFieldGet(client_destroyed, this)) {
126226
+ throw new Error('Cannot register target on destroyed Log instance');
126227
+ }
126228
+
125609
126229
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
125610
126230
  const id = Symbol('LogTargetID');
125611
126231
  client_log_classPrivateFieldGet(client_targets, this).set(id, target);
@@ -125627,6 +126247,9 @@ class client_Log {
125627
126247
  * Unregister a logging target (sink) to stop sending logs to
125628
126248
  */
125629
126249
  unregisterTarget(id) {
126250
+ if (client_log_classPrivateFieldGet(client_destroyed, this)) {
126251
+ return;
126252
+ }
125630
126253
  client_log_classPrivateFieldGet(client_targets, this).delete(id);
125631
126254
  }
125632
126255
 
@@ -125644,6 +126267,9 @@ class client_Log {
125644
126267
  */
125645
126268
  startAutoSync() {
125646
126269
  let rate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
126270
+ if (client_log_classPrivateFieldGet(client_destroyed, this)) {
126271
+ throw new Error('Cannot start auto sync on destroyed Log instance');
126272
+ }
125647
126273
  this.stopAutoSync();
125648
126274
  client_log_classPrivateFieldSet(client_autoSyncInterval, this, setInterval(async () => {
125649
126275
  try {
@@ -125721,6 +126347,15 @@ class client_Log {
125721
126347
  this.destroy();
125722
126348
  }
125723
126349
 
126350
+ /**
126351
+ * Dispose of the logger instance, syncing all logs, and clearing targets
126352
+ */
126353
+ async [Symbol.asyncDispose]() {
126354
+ client_log_classPrivateFieldSet(client_destroyed, this, true);
126355
+ await this.sync();
126356
+ this.destroy();
126357
+ }
126358
+
125724
126359
  /**
125725
126360
  * Terminate the logger instance, clearing all logs and targets
125726
126361
  */
@@ -125735,6 +126370,9 @@ class client_Log {
125735
126370
  }
125736
126371
  }
125737
126372
  function client_log_log(level, options, from) {
126373
+ if (client_log_classPrivateFieldGet(client_destroyed, this)) {
126374
+ return;
126375
+ }
125738
126376
  for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
125739
126377
  args[_key6 - 3] = arguments[_key6];
125740
126378
  }
@@ -125794,7 +126432,6 @@ function client_timing_classPrivateFieldSet(s, a, r) { return s.set(client_timin
125794
126432
  function client_timing_classPrivateFieldGet(s, a) { return s.get(client_timing_assertClassBrand(s, a)); }
125795
126433
  function client_timing_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"); }
125796
126434
 
125797
-
125798
126435
  /**
125799
126436
  * Support the old way of doing timing where the callers could call
125800
126437
  * startTime/endTime with the same string to terminate a timing section
@@ -125820,8 +126457,13 @@ class client_RequestTiming {
125820
126457
  constructor() {
125821
126458
  client_timing_classPrivateFieldInitSpec(this, client_timing, new Map());
125822
126459
  client_timing_classPrivateFieldInitSpec(this, client_counter, 0);
125823
- client_timing_defineProperty(this, "log", client_RequestTiming.defaultLogger);
126460
+ if (client_RequestTiming.defaultLogger === '@legacy') {
126461
+ this.log = src_client_log.Legacy();
126462
+ } else {
126463
+ this.log = client_RequestTiming.defaultLogger;
126464
+ }
125824
126465
  }
126466
+
125825
126467
  /**
125826
126468
  * Start timing a section of code
125827
126469
  * @param section Name of the section to time -- should be unique within the code base so that it can be identified later
@@ -125835,12 +126477,17 @@ class client_RequestTiming {
125835
126477
  start: Date.now()
125836
126478
  };
125837
126479
  client_timing_classPrivateFieldGet(client_timing, this).set(id, data);
126480
+ let endCalled = false;
125838
126481
  return {
125839
- id,
126482
+ id: id,
125840
126483
  end: () => {
126484
+ endCalled = true;
125841
126485
  this.endTime(id);
125842
126486
  },
125843
126487
  [Symbol.dispose]: () => {
126488
+ if (endCalled) {
126489
+ return;
126490
+ }
125844
126491
  this.endTime(id);
125845
126492
  }
125846
126493
  };
@@ -125859,11 +126506,11 @@ class client_RequestTiming {
125859
126506
  if (typeof section === 'symbol') {
125860
126507
  const timingInfo = client_timing_classPrivateFieldGet(client_timing, this).get(section);
125861
126508
  if (timingInfo === undefined) {
125862
- this.log.error(`Timing section ${String(section)} does not exist but "end" was called on it!`);
126509
+ this.log.error('timing::endTime', `Timing section ${String(section)} does not exist but "end" was called on it!`);
125863
126510
  return;
125864
126511
  }
125865
126512
  if (timingInfo.end !== undefined) {
125866
- this.log.error(`Timing section ${timingInfo.id} already ended but "end" was called on it again!`);
126513
+ this.log.error('timing::endTime', `Timing section ${timingInfo.id} already ended but "end" was called on it again!`);
125867
126514
  return;
125868
126515
  }
125869
126516
  timingInfo.end = Date.now();
@@ -125963,7 +126610,7 @@ class client_RequestTiming {
125963
126610
  return client_timing_classPrivateFieldSet(client_counter, this, (_this$counter = client_timing_classPrivateFieldGet(client_counter, this), _this$counter2 = _this$counter++, _this$counter)), _this$counter2;
125964
126611
  }
125965
126612
  }
125966
- client_timing_defineProperty(client_RequestTiming, "defaultLogger", src_client_log.Legacy());
126613
+ client_timing_defineProperty(client_RequestTiming, "defaultLogger", '@legacy');
125967
126614
  /* harmony default export */ const src_client_timing = (client_RequestTiming);
125968
126615
  ;// ./src/lib/kv/index.ts
125969
126616
  function client_kv_defineProperty(e, r, t) { return (r = client_kv_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -128150,7 +128797,7 @@ client_lib_ledger_defineProperty(src_client_Ledger, "isInstance", client_checkab
128150
128797
  // EXTERNAL MODULE: ws (ignored)
128151
128798
  var client_ws_ignored_ = __webpack_require__(4708);
128152
128799
  ;// ./src/version.ts
128153
- const client_version = '0.14.11+gfb27e304d06f586fd5f3532fae4f1504a46d359b';
128800
+ const client_version = '0.14.12+g091eeeea12610658c71c9ee6a7c5e2eac6aabdde';
128154
128801
  /* harmony default export */ const client_src_version = ((/* unused pure expression or super */ null && (client_version)));
128155
128802
  ;// ./src/lib/p2p.ts
128156
128803
  /* provided dependency */ var client_p2p_Buffer = __webpack_require__(8287)["Buffer"];