@keetanetwork/keetanet-client 0.12.2 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/api/index.d.ts +23 -2
  2. package/api/node.d.ts +7 -1
  3. package/api/p2p.d.ts +13 -0
  4. package/api/vote.d.ts +10 -0
  5. package/client/builder.d.ts +13 -6
  6. package/client/client_common_tests.d.ts +18 -0
  7. package/client/index-browser.d.ts +42 -14
  8. package/client/index-browser.js +2899 -1382
  9. package/client/index.d.ts +42 -14
  10. package/client/index.js +2138 -655
  11. package/config/index.d.ts +2 -0
  12. package/docs/assets/hierarchy.js +1 -1
  13. package/docs/assets/search.js +1 -1
  14. package/docs/classes/KeetaNetSDK.Client.html +14 -10
  15. package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +2 -2
  16. package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +10 -0
  17. package/docs/classes/KeetaNetSDK.Referenced.Block.html +9 -5
  18. package/docs/classes/KeetaNetSDK.Referenced.BlockBuilder.html +3 -2
  19. package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +1 -1
  20. package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
  21. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +4 -4
  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.Certificate.html +6 -2
  31. package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
  32. package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
  33. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
  34. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
  35. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
  36. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
  37. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
  38. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
  39. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
  40. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
  41. package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
  42. package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
  43. package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
  44. package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
  45. package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
  46. package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
  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 +1 -1
  50. package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
  51. package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
  52. package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +5 -2
  53. package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +3 -1
  54. package/docs/classes/KeetaNetSDK.Referenced.LedgerStorageTransactionBase.html +8 -0
  55. package/docs/classes/KeetaNetSDK.Referenced.P2PSwitch.html +6 -2
  56. package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
  57. package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +31 -27
  58. package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
  59. package/docs/classes/KeetaNetSDK.Referenced.Stats.html +10 -4
  60. package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +10 -0
  61. package/docs/classes/KeetaNetSDK.Referenced.UserClientBuilder.html +4 -3
  62. package/docs/classes/KeetaNetSDK.Referenced.Vote.html +7 -3
  63. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +3 -3
  64. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +2 -2
  65. package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +10 -8
  66. package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +2 -2
  67. package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +32 -0
  68. package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +34 -0
  69. package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +11 -0
  70. package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +3 -3
  71. package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +2 -2
  72. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.html +2 -2
  73. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
  74. package/docs/classes/KeetaNetSDK.UserClient.html +7 -2
  75. package/docs/enums/KeetaNetSDK.Referenced.BaseFlag.html +2 -1
  76. package/docs/enums/KeetaNetSDK.Referenced.BasePermissionGroup.html +3 -1
  77. package/docs/enums/KeetaNetSDK.Referenced.BlockPurpose.html +3 -0
  78. package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_helper.bufferToBigInt.html +1 -0
  79. package/docs/hierarchy.html +1 -1
  80. package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
  81. package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
  82. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
  83. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
  84. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
  85. package/docs/interfaces/KeetaNetSDK.Referenced.AccountInfo.html +4 -2
  86. package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
  87. package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
  88. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +3 -0
  89. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
  90. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +3 -3
  91. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
  92. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +1 -1
  93. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
  94. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
  95. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
  96. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
  97. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
  98. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  99. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  100. package/docs/interfaces/{KeetaNetSDK.Referenced.BlockCanonical.html → KeetaNetSDK.Referenced.BlockV1Canonical.html} +1 -1
  101. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1JSON.html +12 -0
  102. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1UnsignedCanonical.html +11 -0
  103. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +11 -0
  104. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2JSON.html +12 -0
  105. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2UnsignedCanonical.html +11 -0
  106. package/docs/interfaces/KeetaNetSDK.Referenced.BuilderBlockOptions.html +3 -0
  107. package/docs/interfaces/KeetaNetSDK.Referenced.ComputedBlocksEffectFields.html +3 -2
  108. package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
  109. package/docs/interfaces/KeetaNetSDK.Referenced.CreateIdentifierRequest.html +4 -0
  110. package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
  111. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
  112. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
  113. package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
  114. package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
  115. package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
  116. package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
  117. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerConfig.html +5 -3
  118. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +4 -4
  119. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageTransactionBaseOptions.html +6 -0
  120. package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
  121. package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +5 -0
  122. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +3 -0
  123. package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
  124. package/docs/interfaces/KeetaNetSDK.Referenced.P2PConfig.html +4 -2
  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 +4 -2
  128. package/docs/interfaces/KeetaNetSDK.Referenced.PrincipalACLWithInfoParsed.html +1 -0
  129. package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
  130. package/docs/interfaces/KeetaNetSDK.Referenced.PublishOptions.html +5 -0
  131. package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
  132. package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
  133. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +5 -3
  134. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +4 -2
  135. package/docs/interfaces/KeetaNetSDK.Referenced.VoteJSON.html +3 -2
  136. package/docs/interfaces/KeetaNetSDK.Referenced.VoteStapleJSON.html +2 -2
  137. package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
  138. package/docs/interfaces/KeetaNetSDK.Referenced.src_config.ValidationConfig.html +2 -2
  139. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
  140. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
  141. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
  142. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
  143. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
  144. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_helper.InstanceSetConstructor.html +2 -2
  145. package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
  146. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_asn1.html +1 -1
  147. package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_helper.html +1 -1
  148. package/docs/types/KeetaNetSDK.Referenced.BlockASN1SchemaWithoutSignature.html +1 -0
  149. package/docs/types/KeetaNetSDK.Referenced.BlockJSON.html +1 -0
  150. package/docs/types/KeetaNetSDK.Referenced.BlockJSONIncomplete.html +1 -1
  151. package/docs/types/KeetaNetSDK.Referenced.BlockOperationASN1SchemaType.html +1 -0
  152. package/docs/types/KeetaNetSDK.Referenced.BlockOperationTypes.html +1 -0
  153. package/docs/types/KeetaNetSDK.Referenced.BlockSignature.html +2 -0
  154. package/docs/types/KeetaNetSDK.Referenced.BlockSignatureField.html +1 -0
  155. package/docs/types/KeetaNetSDK.Referenced.BlockSignerField.html +1 -0
  156. package/docs/types/KeetaNetSDK.Referenced.BlockSignerFieldJSON.html +1 -0
  157. package/docs/types/KeetaNetSDK.Referenced.BlockV1ASN1WithoutSignature.html +1 -0
  158. package/docs/types/KeetaNetSDK.Referenced.BlockV2ASN1WithoutSignature.html +1 -0
  159. package/docs/types/KeetaNetSDK.Referenced.CertificateBuilderParams.html +8 -3
  160. package/docs/types/KeetaNetSDK.Referenced.ComputedEffectOfBlocks.html +2 -2
  161. package/docs/types/KeetaNetSDK.Referenced.GetAccountStateAPIResponseFormatted.html +1 -0
  162. package/docs/types/KeetaNetSDK.Referenced.HashNames.html +1 -0
  163. package/docs/types/KeetaNetSDK.Referenced.MultisigAddress.html +1 -0
  164. package/docs/types/KeetaNetSDK.Referenced.MultisigSignerField.html +1 -0
  165. package/docs/types/KeetaNetSDK.Referenced.MultisigSignerFieldJSON.html +1 -0
  166. package/docs/types/KeetaNetSDK.Referenced.OmitLastArrayValue.html +1 -0
  167. package/docs/types/KeetaNetSDK.Referenced.P2PUpdateOptions.html +1 -0
  168. package/docs/types/KeetaNetSDK.Referenced.UserEditableAccountInfo.html +1 -0
  169. package/docs/types/KeetaNetSDK.Referenced.src_config.NetworkConfig.html +1 -1
  170. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.Schema.html +1 -1
  171. package/docs/types/KeetaNetSDK.Referenced.src_lib_utils_asn1.ValidateASN1.SchemaMap.html +1 -1
  172. package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes-1.html +1 -1
  173. package/docs/variables/KeetaNetSDK.Referenced.BlockErrorCodes.html +1 -1
  174. package/docs/variables/KeetaNetSDK.Referenced.BlockOperationASN1Schema.html +2 -0
  175. package/docs/variables/KeetaNetSDK.Referenced.LedgerErrorCodes.html +1 -1
  176. package/docs/variables/KeetaNetSDK.Referenced.VoteErrorCodes.html +1 -1
  177. package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1CheckUtilities.html +1 -0
  178. package/lib/block/index.d.ts +104 -36
  179. package/lib/block/operations.d.ts +31 -3
  180. package/lib/error/block.d.ts +1 -1
  181. package/lib/error/certificate.d.ts +1 -1
  182. package/lib/error/ledger.d.ts +1 -1
  183. package/lib/error/vote.d.ts +1 -1
  184. package/lib/ledger/common.d.ts +14 -1
  185. package/lib/ledger/db_dynamodb.d.ts +7 -11
  186. package/lib/ledger/db_postgres.d.ts +12 -4
  187. package/lib/ledger/db_spanner.d.ts +6 -13
  188. package/lib/ledger/db_spanner_helper.d.ts +29 -6
  189. package/lib/ledger/db_sqlite.d.ts +12 -4
  190. package/lib/ledger/effects.d.ts +10 -9
  191. package/lib/ledger/index.d.ts +28 -10
  192. package/lib/ledger/types.d.ts +10 -1
  193. package/lib/node/utils.d.ts +5 -0
  194. package/lib/p2p.d.ts +32 -0
  195. package/lib/permissions.d.ts +5 -2
  196. package/lib/stats.d.ts +22 -3
  197. package/lib/utils/asn1.d.ts +22 -5
  198. package/lib/utils/certificate.d.ts +38 -1
  199. package/lib/utils/helper.d.ts +2 -1
  200. package/lib/utils/static-types.d.ts +11 -0
  201. package/lib/vote.d.ts +55 -20
  202. package/package.json +1 -1
  203. package/version.d.ts +1 -1
  204. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSON.html +0 -11
  205. package/docs/interfaces/KeetaNetSDK.Referenced.BlockUnsignedCanonical.html +0 -11
  206. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageTransactionBase.html +0 -6
  207. package/docs/types/KeetaNetSDK.Referenced.CreateIdentifierRequest.html +0 -6
@@ -184,7 +184,21 @@ declare const ColumnTypes: {
184
184
  fromSpanner: (pubKey: string) => GenericAccount;
185
185
  toSpanner: (account: GenericAccount) => import("../account").TokenPublicKeyString | import("../account").NetworkPublicKeyString | import("../account").StoragePublicKeyString | import("../account").MultisigPublicKeyString | import("../account").Secp256K1PublicKeyString | import("../account").Secp256R1PublicKeyString | import("../account").ED25519PublicKeyString;
186
186
  };
187
- readonly BUFFER_BIGINT: {
187
+ readonly BUFFER_BIGINT_39: {
188
+ dbType: string;
189
+ dbSize: string;
190
+ toSpanner: (buf: bigint) => Buffer;
191
+ fromSpanner: (value: Buffer) => bigint;
192
+ toComparable: (val: Buffer | bigint | string) => bigint;
193
+ };
194
+ readonly BUFFER_BIGINT_16: {
195
+ dbType: string;
196
+ dbSize: string;
197
+ toSpanner: (buf: bigint) => Buffer;
198
+ fromSpanner: (value: Buffer) => bigint;
199
+ toComparable: (val: Buffer | bigint | string) => bigint;
200
+ };
201
+ readonly BUFFER_BIGINT_8: {
188
202
  dbType: string;
189
203
  dbSize: string;
190
204
  toSpanner: (buf: bigint) => Buffer;
@@ -231,6 +245,7 @@ declare const schema: {
231
245
  readonly description: ColumnInterface<"INFO_DESCRIPTION", true>;
232
246
  readonly metadata: ColumnInterface<"INFO_METADATA", true>;
233
247
  readonly supply: ColumnInterface<"SUPPLY", true>;
248
+ readonly multisigQuorum: ColumnInterface<"BIGINT", true>;
234
249
  readonly defaultBasePermission: ColumnInterface<"BASE_PERMISSION", true>;
235
250
  readonly defaultExternalPermission: ColumnInterface<"EXTERNAL_PERMISSION", true>;
236
251
  };
@@ -274,7 +289,7 @@ declare const schema: {
274
289
  readonly columns: {
275
290
  readonly account: ColumnInterface<"GENERIC_ACCOUNT", false>;
276
291
  readonly voteBlockHash: ColumnInterface<"VOTEBLOCKHASH", false>;
277
- readonly orderIndex: ColumnInterface<"BUFFER_BIGINT", false>;
292
+ readonly orderIndex: ColumnInterface<"BUFFER_BIGINT_39", false>;
278
293
  };
279
294
  readonly key: readonly [Key, Key];
280
295
  readonly interleave: Interleave;
@@ -295,9 +310,10 @@ declare const schema: {
295
310
  readonly onLedger: ColumnInterface<"LEDGER", false>;
296
311
  readonly vote: ColumnInterface<"VOTE", false>;
297
312
  readonly timestamp: ColumnInterface<"TIMESTAMP", false>;
298
- readonly expires: ColumnInterface<"TIMESTAMP", false>;
299
313
  readonly issuer: ColumnInterface<"ACCOUNT", false>;
300
314
  readonly voteBlockHash: ColumnInterface<"VOTEBLOCKHASH", false>;
315
+ readonly orderIndex: ColumnInterface<"BUFFER_BIGINT_16", false>;
316
+ readonly expiresIndex: ColumnInterface<"BUFFER_BIGINT_8", true>;
301
317
  };
302
318
  readonly key: readonly [Key, Key];
303
319
  };
@@ -365,11 +381,17 @@ declare const schema: {
365
381
  readonly table: "permissions";
366
382
  readonly key: readonly [Key, Key];
367
383
  };
368
- readonly historyVoteBlockHash: {
384
+ readonly historyVoteBlockHashAccount: {
369
385
  readonly type: "INDEX";
370
386
  readonly table: "history";
371
387
  readonly key: readonly [Key, Key];
372
388
  };
389
+ readonly historyOrdered: {
390
+ readonly type: "INDEX";
391
+ readonly table: "history";
392
+ readonly key: readonly [Key];
393
+ readonly storing: readonly [Key];
394
+ };
373
395
  readonly chainAccountHash: {
374
396
  readonly type: "INDEX";
375
397
  readonly table: "chain";
@@ -383,15 +405,16 @@ declare const schema: {
383
405
  readonly key: readonly [Key];
384
406
  readonly storing: readonly [Key];
385
407
  };
386
- readonly votesTimestamp: {
408
+ readonly votesOrderIndex: {
387
409
  readonly type: "INDEX";
388
410
  readonly table: "votes";
389
411
  readonly key: readonly [Key, Key];
390
412
  readonly storing: readonly [Key];
391
413
  };
392
- readonly votesOnLedgerExpired: {
414
+ readonly votesExpiredIndex: {
393
415
  readonly type: "INDEX";
394
416
  readonly table: "votes";
417
+ readonly nullFiltered: true;
395
418
  readonly key: readonly [Key, Key];
396
419
  readonly storing: readonly [Key];
397
420
  };
@@ -4,16 +4,18 @@ import type { BlockHash } from '../block';
4
4
  import { Block } from '../block';
5
5
  import type { GenericAccount, IdentifierAddress, TokenAddress } from '../account';
6
6
  import Account, { AccountKeyAlgorithm } from '../account';
7
- import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions, LedgerStorageTransactionBase } from '../ledger';
7
+ import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions, LedgerStorageTransactionBaseOptions } from '../ledger';
8
+ import { LedgerStorageTransactionBase } from '../ledger';
8
9
  import type { AccountInfo, ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates } from './types';
9
10
  import { LedgerStorageBase } from './common';
10
11
  import * as sqlite from 'sqlite';
11
12
  import type { ComputedEffectOfBlocks } from './effects';
12
13
  import type { CertificateHash } from '../utils/certificate';
13
- interface DBSqliteTransaction extends LedgerStorageTransactionBase {
14
+ declare class DBSqliteTransaction extends LedgerStorageTransactionBase {
14
15
  sql: Awaited<ReturnType<typeof sqlite['open']>>;
15
16
  release: null | ((value: null | number) => void);
16
17
  lock: null | Promise<null | number>;
18
+ constructor(baseTransaction: LedgerStorageTransactionBaseOptions, db: Awaited<ReturnType<typeof sqlite['open']>>);
17
19
  }
18
20
  export interface DBSqliteConfig {
19
21
  filename: string;
@@ -24,7 +26,7 @@ export declare class DBSqlite extends LedgerStorageBase implements LedgerStorage
24
26
  constructor();
25
27
  init(config: LedgerConfig, ledger: Ledger): void;
26
28
  destroy(): Promise<void>;
27
- beginTransaction(transactionBase: LedgerStorageTransactionBase): Promise<DBSqliteTransaction>;
29
+ beginTransaction(transactionBase: LedgerStorageTransactionBaseOptions): Promise<DBSqliteTransaction>;
28
30
  commitTransaction(transaction: DBSqliteTransaction): Promise<void>;
29
31
  abortTransaction(transaction: DBSqliteTransaction): Promise<void>;
30
32
  evaluateError(error: any): Promise<any>;
@@ -44,9 +46,15 @@ export declare class DBSqlite extends LedgerStorageBase implements LedgerStorage
44
46
  adjust(transaction: DBSqliteTransaction, input: VoteStaple, changes: ComputedEffectOfBlocks, mayDefer?: boolean, completedStaples?: Set<string>): Promise<VoteStaple[]>;
45
47
  getBlock(transaction: DBSqliteTransaction, block: BlockHash, from: LedgerSelector): Promise<Block | null>;
46
48
  getBlockHeight(transaction: DBSqliteTransaction, blockHash: BlockHash, account: GenericAccount): Promise<bigint | null>;
49
+ getBlockHeights(transaction: DBSqliteTransaction, toFetch: {
50
+ blockHash: BlockHash;
51
+ account: GenericAccount;
52
+ }[]): Promise<{
53
+ [blockHash: string]: bigint | null;
54
+ }>;
47
55
  getVotes(transaction: DBSqliteTransaction, block: BlockHash, from: LedgerSelector): Promise<Vote[] | null>;
48
56
  getVoteStaples(transaction: DBSqliteTransaction, voteBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise<VoteBlockHashMap<VoteStaple | null>>;
49
- getHistory(transaction: DBSqliteTransaction, account: GenericAccount, start: VoteBlockHash | null, limit?: number): Promise<VoteBlockHash[]>;
57
+ getHistory(transaction: DBSqliteTransaction, account: GenericAccount | null, start: VoteBlockHash | null, limit?: number): Promise<VoteBlockHash[]>;
50
58
  getBlockFromPrevious(transaction: DBSqliteTransaction, prevBlock: BlockHash, from: LedgerSelector): Promise<Block | null>;
51
59
  getVotesFromMultiplePrevious(transaction: DBSqliteTransaction, prevBlocks: BlockHash[], from: LedgerSelector, issuer?: GenericAccount): Promise<{
52
60
  [hash: string]: Vote[] | null;
@@ -1,8 +1,9 @@
1
1
  import type { GenericAccount, IdentifierAddress, NetworkAddress, TokenAddress } from '../account';
2
2
  import Account from '../account';
3
- import type { AdjustMethod, BlockHash } from '../block';
3
+ import type { AdjustMethod } from '../block';
4
4
  import { Block } from '../block';
5
- import type { AccountInfo, ACLEntry, ACLUpdate } from '../ledger/types';
5
+ import type * as Operations from '../block/operations';
6
+ import type { UserEditableAccountInfo, ACLEntry, ACLUpdate } from '../ledger/types';
6
7
  import type { Certificate, CertificateBundle } from '../utils/certificate';
7
8
  import { CertificateHash } from '../utils/certificate';
8
9
  interface NumericValueEntry {
@@ -41,24 +42,23 @@ interface ComputedBlocksEffectTokenChangesField {
41
42
  /**
42
43
  * Which fields may be affected by blocks
43
44
  */
44
- type CreateIdentifierRequest = {
45
- previousBlockHash: BlockHash;
46
- requestedIdentifier: IdentifierAddress;
47
- operationIndex: number;
48
- account: GenericAccount;
49
- };
45
+ interface CreateIdentifierRequest {
46
+ createdIdentifier: IdentifierAddress;
47
+ createArguments?: Operations.IdentifierCreateArguments;
48
+ }
50
49
  type DelegationUpdate = {
51
50
  delegateTo: Account;
52
51
  };
53
52
  interface ComputedBlocksEffectFields {
54
53
  balance?: ComputedBlocksEffectTokenChangesField;
55
54
  supply?: NumericValueEntry[];
56
- info?: AccountInfo;
55
+ info?: Partial<UserEditableAccountInfo>;
57
56
  permissions?: ACLUpdate[];
58
57
  permissionRequirements?: ACLEntry[];
59
58
  createRequests?: CreateIdentifierRequest[];
60
59
  delegation?: DelegationUpdate;
61
60
  certificate?: CertificateUpdate[];
61
+ minSignerSetLength?: bigint;
62
62
  }
63
63
  /**
64
64
  * Which accounts and fields are affected by a set of block
@@ -80,6 +80,7 @@ export type ComputedEffectOfBlocks = {
80
80
  metadata: {
81
81
  operationCount: number;
82
82
  blockCount: number;
83
+ feeUnits: bigint;
83
84
  };
84
85
  };
85
86
  type LedgerOptions = {
@@ -1,7 +1,7 @@
1
1
  import { VoteStaple, Vote, VoteBlockHashMap } from '../vote';
2
2
  import { Block, BlockHash } from '../block';
3
- import type { VoteBlockHash } from '../vote';
4
- import type { GenericAccount, IdentifierAddress, NetworkAddress, TokenAddress } from '../account';
3
+ import type { FeeAmountAndToken, VoteBlockHash, VoteQuote } from '../vote';
4
+ import type { GenericAccount, IdentifierAddress, NetworkAddress, StorageAddress, TokenAddress } from '../account';
5
5
  import Account from '../account';
6
6
  import type Node from '../node';
7
7
  import type { BloomFilter } from '../utils/bloom';
@@ -9,6 +9,7 @@ import type { ComputedEffectOfBlocks } from './effects';
9
9
  import type { ACLRow, AccountInfo, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates } from './types';
10
10
  import LedgerRequestCache from './cache';
11
11
  import type { CertificateHash } from '../utils/certificate';
12
+ import { StatsPending } from '../stats';
12
13
  /**
13
14
  * Kind of ledger
14
15
  */
@@ -31,6 +32,10 @@ export interface LedgerConfig {
31
32
  * Private key for the ledger if it is acting as a representative
32
33
  */
33
34
  privateKey?: Account;
35
+ /**
36
+ * Provided function to compute fees for a given set of Blocks and computed effects
37
+ */
38
+ computeFeeFromBlocks: (ledger: Ledger, blocks: Block[], effects: ComputedEffectOfBlocks) => FeeAmountAndToken | null;
34
39
  /**
35
40
  * Storage mechanism
36
41
  */
@@ -98,11 +103,19 @@ export type GetVotesAfterOptions = {
98
103
  /**
99
104
  * Each transaction can contain the node object making the request to access things like timing information
100
105
  */
101
- export interface LedgerStorageTransactionBase {
106
+ export interface LedgerStorageTransactionBaseOptions {
107
+ node?: Node;
108
+ moment?: Date;
109
+ identifier: string;
110
+ readOnly?: boolean;
111
+ }
112
+ export declare class LedgerStorageTransactionBase implements LedgerStorageTransactionBaseOptions {
102
113
  node?: Node;
103
114
  moment: Date;
104
115
  identifier: string;
105
116
  readOnly: boolean;
117
+ statsPending: StatsPending;
118
+ constructor(options: LedgerStorageTransactionBaseOptions);
106
119
  }
107
120
  /**
108
121
  * Each Ledger Storage backend must implement this interface
@@ -119,7 +132,7 @@ export interface LedgerStorageAPI {
119
132
  /**
120
133
  * Begin a transaction
121
134
  */
122
- beginTransaction: (transactionBase: LedgerStorageTransactionBase) => Promise<LedgerStorageTransactionBase>;
135
+ beginTransaction: (transactionBase: LedgerStorageTransactionBaseOptions) => Promise<LedgerStorageTransactionBase>;
123
136
  /**
124
137
  * Commit an active transaction
125
138
  */
@@ -208,9 +221,9 @@ export interface LedgerStorageAPI {
208
221
  */
209
222
  getVoteStaples: (transaction: any, voteBlockHashes: VoteBlockHash[], from: LedgerSelector) => Promise<VoteBlockHashMap<VoteStaple | null>>;
210
223
  /**
211
- * Get the history for a specific account
224
+ * Get the history for a specific account or all accounts if account is null
212
225
  */
213
- getHistory: (transaction: any, account: GenericAccount, start: VoteBlockHash | null, limit?: number) => Promise<VoteBlockHash[]>;
226
+ getHistory: (transaction: any, account: GenericAccount | null, start: VoteBlockHash | null, limit?: number) => Promise<VoteBlockHash[]>;
214
227
  /**
215
228
  * Get multiple head blocks at the same time for a set of accounts
216
229
  */
@@ -250,7 +263,7 @@ export interface LedgerStorageAPI {
250
263
  /**
251
264
  * Perform Garbage Collection
252
265
  */
253
- gc: (transaction: any) => Promise<boolean>;
266
+ gc: (transaction: any, timeLimitMS?: number) => Promise<boolean>;
254
267
  /**
255
268
  * Get the next serial number for a representative
256
269
  */
@@ -276,7 +289,8 @@ declare class LedgerAtomicInterface {
276
289
  constructor(transaction: LedgerStorageTransactionBase, storage: LedgerStorageAPI, config: LedgerConfig, ledger: Ledger);
277
290
  commit(): Promise<void>;
278
291
  abort(): Promise<void>;
279
- vote(blocks: Block[], otherVotes?: Vote[]): Promise<Vote>;
292
+ vote(blocks: Block[], otherVotes?: Vote[], quote?: VoteQuote): Promise<Vote>;
293
+ quote(blocks: Block[]): Promise<VoteQuote>;
280
294
  add(votesAndBlocks: VoteStaple, from?: 'bootstrap' | string): Promise<VoteStaple[]>;
281
295
  getBalance(account: GenericAccount, token: TokenAddress): Promise<bigint>;
282
296
  getAllBalances(account: GenericAccount): Promise<GetAllBalancesResponse>;
@@ -299,10 +313,11 @@ declare class LedgerAtomicInterface {
299
313
  getBlock(blockhash: BlockHash, from?: LedgerSelector): Promise<Block | null>;
300
314
  getVoteStaple(stapleBlockHash: VoteBlockHash, from?: LedgerSelector): Promise<VoteStaple | null>;
301
315
  getVoteStaples(stapleBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise<VoteBlockHashMap<VoteStaple | null>>;
302
- getHistory(account: GenericAccount, start: VoteBlockHash | null, limit?: number): Promise<VoteStaple[]>;
316
+ getHistory(account: GenericAccount | null, start: VoteBlockHash | null, limit?: number): Promise<VoteStaple[]>;
303
317
  getStaplesFromBlockHashes(hashes: BlockHash[]): Promise<VoteStaple[]>;
304
318
  getVoteStaplesAfter(moment: Date, limit?: number, options?: GetVotesAfterOptions): Promise<VoteStaple[]>;
305
- gc(): Promise<boolean>;
319
+ gc(timeLimitMS?: number): Promise<boolean>;
320
+ getFee(blocks: Block[], effectsInput?: ComputedEffectOfBlocks): Promise<FeeAmountAndToken | null>;
306
321
  _testingRunStorageFunction<T>(code: (storage: LedgerStorageAPI, transaction: LedgerStorageTransactionBase) => Promise<T>): Promise<T>;
307
322
  }
308
323
  /**
@@ -319,6 +334,7 @@ export declare class Ledger implements Omit<LedgerAtomicInterface, 'commit' | 'a
319
334
  constructor(config: LedgerConfig, node?: Node, existingStorage?: LedgerStorageAPI);
320
335
  get ledgerWriteMode(): NonNullable<LedgerConfig['ledgerWriteMode']>;
321
336
  copy(newNode: Node): Ledger;
337
+ getFeePayToAndToken(accounts?: (Account | StorageAddress)[], token?: TokenAddress): Partial<FeeAmountAndToken>;
322
338
  /**
323
339
  * Execute some code with a transaction held, if the code fails the
324
340
  * transaction is aborted, otherwise it is committed
@@ -330,6 +346,7 @@ export declare class Ledger implements Omit<LedgerAtomicInterface, 'commit' | 'a
330
346
  runReadOnly<T>(identifier: string, code: (transaction: LedgerAtomicInterface) => Promise<T>): ReturnType<typeof code>;
331
347
  beginTransaction(identifier: string, readOnly?: boolean): Promise<LedgerAtomicInterface>;
332
348
  vote(...args: Parameters<LedgerAtomicInterface['vote']>): ReturnType<LedgerAtomicInterface['vote']>;
349
+ quote(...args: Parameters<LedgerAtomicInterface['quote']>): ReturnType<LedgerAtomicInterface['quote']>;
333
350
  add(...args: Parameters<LedgerAtomicInterface['add']>): ReturnType<LedgerAtomicInterface['add']>;
334
351
  listACLsByPrincipal(...args: Parameters<LedgerAtomicInterface['listACLsByPrincipal']>): ReturnType<LedgerAtomicInterface['listACLsByPrincipal']>;
335
352
  listACLsByEntity(...args: Parameters<LedgerAtomicInterface['listACLsByEntity']>): ReturnType<LedgerAtomicInterface['listACLsByEntity']>;
@@ -352,6 +369,7 @@ export declare class Ledger implements Omit<LedgerAtomicInterface, 'commit' | 'a
352
369
  getStaplesFromBlockHashes(...args: Parameters<LedgerAtomicInterface['getStaplesFromBlockHashes']>): ReturnType<LedgerAtomicInterface['getStaplesFromBlockHashes']>;
353
370
  getVoteStaplesAfter(...args: Parameters<LedgerAtomicInterface['getVoteStaplesAfter']>): ReturnType<LedgerAtomicInterface['getVoteStaplesAfter']>;
354
371
  gc(...args: Parameters<LedgerAtomicInterface['gc']>): ReturnType<LedgerAtomicInterface['gc']>;
372
+ getFee(...args: Parameters<LedgerAtomicInterface['getFee']>): ReturnType<LedgerAtomicInterface['getFee']>;
355
373
  stats(): Promise<LedgerStatistics>;
356
374
  _testingRunStorageFunction<T>(code: (storage: LedgerStorageAPI, transaction: LedgerStorageTransactionBase) => Promise<T>): Promise<T>;
357
375
  }
@@ -1,8 +1,12 @@
1
- import type { GenericAccount, TokenAddress } from '../account';
1
+ import type { Account, GenericAccount, MultisigAddress, TokenAddress } from '../account';
2
2
  import type { AdjustMethod } from '../block';
3
3
  import type { Permissions } from '../permissions';
4
4
  import type { DbStats, TimeStats } from '../stats';
5
5
  import type { Certificate, CertificateBundle } from '../utils/certificate';
6
+ export interface MultisigConfig {
7
+ signers: (Account | MultisigAddress)[];
8
+ quorum: bigint;
9
+ }
6
10
  /**
7
11
  * Account info entry
8
12
  */
@@ -27,7 +31,12 @@ export interface AccountInfo {
27
31
  * The default permissions for the account
28
32
  */
29
33
  defaultPermission?: Permissions;
34
+ /**
35
+ * If this is a multisig account, the number of signers required
36
+ */
37
+ multisigQuorum?: bigint;
30
38
  }
39
+ export type UserEditableAccountInfo = Omit<AccountInfo, 'supply'>;
31
40
  /**
32
41
  * Permissions types
33
42
  */
@@ -1,4 +1,9 @@
1
+ import Account, { type StorageAddress, type TokenAddress } from '../account';
1
2
  import type { NodeConfig } from '.';
2
3
  export declare function getConfigFromEnv(type: 'local' | 'lambda'): Partial<Omit<NodeConfig, 'ledger'> & {
3
4
  ledger: Partial<NodeConfig['ledger']>;
4
5
  }>;
6
+ export declare function getFeeConfigFromEnv(type: 'local' | 'lambda'): {
7
+ feeAccounts: (Account | StorageAddress)[];
8
+ feeToken: TokenAddress | undefined;
9
+ };
package/lib/p2p.d.ts CHANGED
@@ -48,6 +48,10 @@ export interface P2PConfig {
48
48
  * Forget about seen message ids after this many milliseconds
49
49
  */
50
50
  seenMessageTTL?: number;
51
+ /**
52
+ * Whether to republish over http or p2p websockets
53
+ */
54
+ useHTTPRepublish?: boolean;
51
55
  }
52
56
  /**
53
57
  * Shape of statistics
@@ -66,6 +70,7 @@ export interface P2PSwitchStatistics {
66
70
  interface P2PPeerBase {
67
71
  kind: NodeKind;
68
72
  }
73
+ export type P2PUpdateOptions = 'http' | 'websocket';
69
74
  /**
70
75
  * Peering information for a Representative (Basic, unsigned information)
71
76
  */
@@ -82,6 +87,10 @@ interface P2PPeerRepBase extends P2PPeerBase {
82
87
  * Public key of the representative (used as the ID)
83
88
  */
84
89
  key: Account;
90
+ /**
91
+ * Prefer to receive updates over http or websocket
92
+ */
93
+ preferUpdates: P2PUpdateOptions;
85
94
  }
86
95
  /**
87
96
  * Peering information for a Representative
@@ -200,6 +209,23 @@ type JSONMessage = {
200
209
  };
201
210
  export declare function randomizeReps(reps: Representative[]): Representative[];
202
211
  export declare function formatRepEndpoints(peers: P2PPeer[]): Representative[];
212
+ export declare class P2PHttpConnection implements P2PConnection {
213
+ #private;
214
+ abort: boolean;
215
+ peer: P2PPeer;
216
+ validatedPeer: P2PPeer | null;
217
+ timeout: number;
218
+ static readonly isInstance: (obj: any, strict?: boolean) => obj is P2PHttpConnection;
219
+ /**
220
+ * Initiate an outbound http connection and attach it to the specified switch
221
+ */
222
+ static initiate(peer: P2PPeer, p2pSwitch: P2PSwitch): Promise<P2PHttpConnection | null>;
223
+ constructor(peer: P2PPeer, p2pSwitch: P2PSwitch);
224
+ get connString(): string;
225
+ get peerString(): string | null;
226
+ send(messageBuffer: Buffer): Promise<boolean>;
227
+ close(): Promise<void>;
228
+ }
203
229
  /**
204
230
  * A P2PConnection using the "ws" package
205
231
  */
@@ -275,6 +301,7 @@ export declare class P2PSwitch {
275
301
  * Our own peer information
276
302
  */
277
303
  selfPeer(): Promise<P2PPeer | null>;
304
+ getOutgoingGreetingInfo(): Promise<JSONSerializableObject>;
278
305
  /**
279
306
  * Receive a message from a connection
280
307
  *
@@ -299,5 +326,10 @@ export declare class P2PSwitch {
299
326
  * @returns If the message could be delivered to at least one peer
300
327
  */
301
328
  sendMessage(to: P2PConnection | Account | P2PPeer | null, id: string, type: string, data: any, ttl?: number, exclude?: (string | P2PConnection)[], skipConnectToPeers?: boolean): Promise<boolean>;
329
+ /**
330
+ * TODO - make this private after refactoring websockets to handle higher load
331
+ * https://github.com/KeetaNetwork/node/issues/785
332
+ */
333
+ haveAnyFilter(data: any): Promise<boolean>;
302
334
  }
303
335
  export default P2PSwitch;
@@ -18,7 +18,8 @@ declare enum BaseFlag {
18
18
  TOKEN_ADMIN_MODIFY_BALANCE = 7,/* 0x0080 */
19
19
  PERMISSION_DELEGATE_ADD = 11,/* 0x0800 */
20
20
  PERMISSION_DELEGATE_REMOVE = 12,/* 0x1000 */
21
- MANAGE_CERTIFICATE = 13
21
+ MANAGE_CERTIFICATE = 13,/* 0x2000 */
22
+ MULTISIG_SIGNER = 14
22
23
  }
23
24
  type ExternalFlagName = `${typeof externalFlagPrefix}${string}`;
24
25
  export type BaseFlagName = keyof typeof BaseFlag;
@@ -42,7 +43,9 @@ declare enum BasePermissionGroup {
42
43
  NONIDENTIFIER = 2,
43
44
  NETWORK = 3,
44
45
  TOKEN = 4,
45
- STORAGE = 5
46
+ STORAGE = 5,
47
+ NONIDENTIFIER_OR_MULTISIG = 6,
48
+ MULTISIG = 7
46
49
  }
47
50
  interface BaseFlagRule {
48
51
  canBeDefault: boolean;
package/lib/stats.d.ts CHANGED
@@ -37,15 +37,34 @@ export type TimeStats = {
37
37
  export type DbStats = {
38
38
  retries: number;
39
39
  };
40
- export declare class Stats {
40
+ export declare class StatsPending {
41
+ protected localDBIncr: {
42
+ [key: string]: number;
43
+ };
44
+ protected localDBXOR: {
45
+ [key: string]: bigint;
46
+ };
47
+ protected consume(): {
48
+ incrChanges: {
49
+ [key: string]: number;
50
+ };
51
+ xorChanges: {
52
+ [key: string]: bigint;
53
+ };
54
+ };
55
+ protected compoundKey(arena: string, key: string): string;
56
+ protected incrCompoundKey(compoundKey: string, change: number): void;
57
+ incr(arena: string, key: string, change?: number): void;
58
+ xor(key: string, change: BlockHash | BufferStorage | bigint): void;
59
+ merge(pending: StatsPending): void;
60
+ }
61
+ export declare class Stats extends StatsPending {
41
62
  #private;
42
63
  constructor(config: StatsConfig);
43
64
  static durationBreakdownList(): DurationBreakdowns[];
44
65
  static assertDurationBreakdown(duration: string): asserts duration is DurationBreakdowns;
45
66
  static durationBreakdown(duration: number): DurationBreakdowns;
46
67
  static placeholderTimingData(): TimeStats;
47
- incr(arena: string, key: string, change?: number): void;
48
- xor(key: string, change: BlockHash | BufferStorage): void;
49
68
  getXor(key: string): Promise<BufferStorage>;
50
69
  addTimingPoint(arena: string, category: string, duration: number, returnOnly?: boolean): Parameters<Stats['incr']>;
51
70
  addRequestTiming(arena: string, timing: RequestTiming, returnOnly?: boolean): Parameters<Stats['incr']>[];
@@ -45,6 +45,23 @@ export interface ASN1String extends ASN1Object {
45
45
  value: string;
46
46
  }
47
47
  export declare function isASN1Object(input: unknown): input is ASN1Object;
48
+ declare function isASN1OID(input: unknown): input is ASN1OID;
49
+ declare function isASN1String(input: unknown): input is ASN1String;
50
+ declare function isASN1Set(input: unknown): input is ASN1Set;
51
+ declare function isASN1ContextTag<T extends ASN1ContextTag['kind']>(input: unknown, tagKind?: T): input is Extract<ASN1ContextTag, {
52
+ kind: T;
53
+ }>;
54
+ declare function isASN1BitString(input: unknown): input is ASN1BitString;
55
+ declare function isASN1Date(input: unknown): input is ASN1Date;
56
+ export declare const ASN1CheckUtilities: {
57
+ isASN1Object: typeof isASN1Object;
58
+ isASN1OID: typeof isASN1OID;
59
+ isASN1String: typeof isASN1String;
60
+ isASN1Set: typeof isASN1Set;
61
+ isASN1ContextTag: typeof isASN1ContextTag;
62
+ isASN1BitString: typeof isASN1BitString;
63
+ isASN1Date: typeof isASN1Date;
64
+ };
48
65
  /**
49
66
  * Validation function for {@link isValidSequenceSchema}
50
67
  */
@@ -59,7 +76,7 @@ declare function jsASN1toJS(input: ArrayBuffer): ASN1AnyJS;
59
76
  declare const ASN1toJS: typeof jsASN1toJS, JStoASN1: typeof jsJStoASN1, ASN1IntegerToBigInt: typeof jsIntegerToBigInt, ASN1BigIntToBuffer: typeof jsBigIntToBuffer;
60
77
  export declare namespace ValidateASN1 {
61
78
  export type Schema = keyof BasicSchemaMap | {
62
- choice: Schema[];
79
+ choice: Schema[] | readonly Schema[];
63
80
  } | {
64
81
  sequenceOf: Schema;
65
82
  } | {
@@ -87,7 +104,7 @@ export declare namespace ValidateASN1 {
87
104
  } | {
88
105
  type: 'date';
89
106
  kind: 'general';
90
- } | readonly [Schema, ...Schema[]];
107
+ } | readonly [Schema, ...Schema[]] | (() => Schema);
91
108
  type BasicSchemaMap = {
92
109
  [ValidateASN1.IsAny]: ASN1AnyJS;
93
110
  [ValidateASN1.IsUnknown]: unknown;
@@ -103,7 +120,7 @@ export declare namespace ValidateASN1 {
103
120
  [ValidateASN1.IsSet]: ASN1Set;
104
121
  [ValidateASN1.IsNull]: null;
105
122
  };
106
- export type SchemaMap<T extends Schema> = T extends keyof BasicSchemaMap ? BasicSchemaMap[T] : T extends {
123
+ export type SchemaMap<T extends Schema> = T extends () => infer U ? U extends Schema ? SchemaMap<U> : never : T extends keyof BasicSchemaMap ? BasicSchemaMap[T] : T extends {
107
124
  choice: Schema[];
108
125
  } ? SchemaMap<T['choice'][number]> : T extends {
109
126
  choice: readonly Schema[];
@@ -113,7 +130,7 @@ export declare namespace ValidateASN1 {
113
130
  optional: Schema;
114
131
  } ? SchemaMap<T['optional']> | undefined : T extends bigint ? T : T extends {
115
132
  type: 'context';
116
- kind: infer U extends 'implicit' | 'explicit';
133
+ kind: infer U extends ASN1ContextTag['kind'];
117
134
  value: number;
118
135
  contains: Schema;
119
136
  } ? Omit<ASN1ContextTag, 'contains' | 'value' | 'kind'> & {
@@ -163,7 +180,7 @@ export declare class ValidateASN1<T extends ValidateASN1.Schema> {
163
180
  * Given a schema, validate the ASN.1 object against it and return the
164
181
  * object as the validated type
165
182
  */
166
- static againstSchema<T extends ValidateASN1.Schema>(input: ASN1AnyJS, schema: T): ValidateASN1.SchemaMap<T>;
183
+ static againstSchema<T extends ValidateASN1.Schema>(input: ASN1AnyJS, schemaIn: T): ValidateASN1.SchemaMap<T>;
167
184
  constructor(schema: T);
168
185
  validate(input: ASN1AnyJS): ValidateASN1.SchemaMap<T>;
169
186
  }
@@ -44,6 +44,7 @@ type CertificateSchema = [
44
44
  signatureAlgorithm: ASN1.ASN1OID[],
45
45
  signature: ASN1.ASN1BitString
46
46
  ];
47
+ type HashNames = 'sha256' | 'sha3-256';
47
48
  type CertificateBuilderParams = {
48
49
  /**
49
50
  * Subject for the certificate, to store as the public key within the certificate
@@ -93,15 +94,45 @@ type CertificateBuilderParams = {
93
94
  includeCommonExts?: boolean;
94
95
  /**
95
96
  * Hashing library to use
97
+ *
98
+ * Because several different things are hashed this is
99
+ * @deprecated Use `hashParams` instead
96
100
  */
97
- hashLib: {
101
+ hashLib?: {
98
102
  hash: (...args: Parameters<typeof HashLib.Hash>) => ReturnType<typeof HashLib.Hash>;
99
103
  name: string;
100
104
  };
105
+ /**
106
+ * This option lets you control the hashing method used for the
107
+ * certificate signature as well as provide alternative implementations
108
+ */
109
+ hashParams: {
110
+ functions?: {
111
+ [name in HashNames]?: (...args: Parameters<typeof HashLib.Hash>) => ReturnType<typeof HashLib.Hash>;
112
+ };
113
+ defaults?: {
114
+ /**
115
+ * Default hashing function to use for the certificate signature
116
+ */
117
+ signature?: HashNames;
118
+ /**
119
+ * Default hashing function to use for the Subject Key Identifier
120
+ */
121
+ ski?: HashNames;
122
+ /**
123
+ * Default hashing function to use for the Authority Key Identifier
124
+ * (must match the issuer certificate's Subject Key Identifier
125
+ * hashing function)
126
+ */
127
+ aki?: HashNames;
128
+ };
129
+ };
101
130
  };
102
131
  export declare class CertificateBuilder {
103
132
  #private;
104
133
  constructor(params?: Partial<CertificateBuilderParams>);
134
+ private static hashName;
135
+ private static hash;
105
136
  /**
106
137
  * Construct an extension
107
138
  */
@@ -367,6 +398,12 @@ export declare class Certificate {
367
398
  * Get the issuer account
368
399
  */
369
400
  getIssuerAccount(): Account | null;
401
+ /**
402
+ * Get the extensions present in the certificate -- this is the raw
403
+ * extensions as they were parsed from the certificate, and may
404
+ * contain extensions that are not processed by this class.
405
+ */
406
+ getExtensions(): NonNullable<CertificateSchema[0][7]>['contains'] | undefined;
370
407
  private assertConstructed;
371
408
  /**
372
409
  * Compare the certificate with another certificate and return true if they
@@ -2,6 +2,7 @@ import _crypto from 'crypto';
2
2
  import type { JSONSerializable } from './conversion';
3
3
  export type DistributiveOmit<T, P extends PropertyKey> = T extends T ? Omit<T, P> : never;
4
4
  export declare function bufferToArrayBuffer(input: Buffer): ArrayBuffer;
5
+ export declare function bufferToBigInt(buffer: Buffer): bigint;
5
6
  /**
6
7
  * Check if a value is an integer or a bigint.
7
8
  */
@@ -73,7 +74,7 @@ interface InstanceSet<Instance, Encoded = string> extends Set<Instance> {
73
74
  */
74
75
  export declare const AsyncDisposableStack: AsyncDisposableStackConstructor;
75
76
  export interface InstanceSetConstructor<Instance, Encoded = string> {
76
- new (data?: (Instance)[]): InstanceSet<Instance, Encoded>;
77
+ new (data?: Iterable<(Instance)>): InstanceSet<Instance, Encoded>;
77
78
  }
78
79
  export declare function setGenerator<P extends WithIsInstance<Instance>, E extends EncodeFunc<Instance, Encoded>, D extends DecodeFunc<Instance, Encoded>, Instance = InstanceType<P>, Encoded = ReturnType<E>>(parent: P, rawEncode: E, rawDecode: D): InstanceSetConstructor<Instance, Encoded>;
79
80
  export declare const crypto: {
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Utility types for static type checking
3
+ */
4
+ /**
5
+ * Expects a type to be true, otherwise raises a type error.
6
+ */
7
+ export type Expect<T extends true> = T;
8
+ /**
9
+ * Checks if two types are equal.
10
+ */
11
+ export type Equal<A, B> = A extends B ? (B extends A ? true : false) : false;