@keetanetwork/keetanet-client 0.16.2 → 0.18.0

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 (181) hide show
  1. package/client/index-browser.js +509 -159
  2. package/client/index.js +511 -137
  3. package/docs/assets/hierarchy.js +1 -1
  4. package/docs/assets/navigation.js +1 -1
  5. package/docs/assets/search.js +1 -1
  6. package/docs/classes/KeetaNetSDK.Client.html +4 -4
  7. package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
  8. package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
  9. package/docs/classes/KeetaNetSDK.Referenced.Block.html +3 -3
  10. package/docs/classes/KeetaNetSDK.Referenced.BlockBuilder.html +1 -1
  11. package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +1 -1
  12. package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
  13. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
  14. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
  15. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +2 -2
  16. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
  17. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
  18. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
  19. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
  20. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  21. package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  22. package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
  23. package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
  24. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
  25. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
  26. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
  27. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
  28. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
  29. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
  30. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
  31. package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
  32. package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
  33. package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
  34. package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
  35. package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
  36. package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
  37. package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
  38. package/docs/classes/KeetaNetSDK.Referenced.IdempotentKey.html +1 -1
  39. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
  40. package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
  41. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +2 -2
  42. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +1 -1
  43. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +2 -2
  44. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerIdempotentKeyError.html +1 -1
  45. package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.html +1 -1
  46. package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
  47. package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
  48. package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +1 -1
  49. package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +1 -1
  50. package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
  51. package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
  52. package/docs/classes/KeetaNetSDK.Referenced.PossiblyUnsignedBlock.html +3 -3
  53. package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
  54. package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
  55. package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
  56. package/docs/classes/KeetaNetSDK.Referenced.UnsignedBlock.html +3 -3
  57. package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
  58. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +2 -2
  59. package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +1 -1
  60. package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
  61. package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +1 -1
  62. package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
  63. package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +1 -1
  64. package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
  65. package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +2 -2
  66. package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
  67. package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
  68. package/docs/classes/KeetaNetSDK.UserClient.html +4 -4
  69. package/docs/hierarchy.html +1 -1
  70. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
  71. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
  72. package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
  73. package/docs/interfaces/KeetaNetSDK.Referenced.AccountACLRow.html +11 -0
  74. package/docs/interfaces/KeetaNetSDK.Referenced.AccountComputedEffect.html +4 -0
  75. package/docs/interfaces/KeetaNetSDK.Referenced.BaseACLRow.html +9 -0
  76. package/docs/interfaces/KeetaNetSDK.Referenced.BaseAccountInfo.html +1 -1
  77. package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
  78. package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
  79. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierAccountInfo.html +1 -1
  80. package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
  81. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
  82. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
  83. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
  84. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +2 -2
  85. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
  86. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
  87. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
  88. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
  89. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
  90. package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
  91. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
  92. package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
  93. package/docs/interfaces/KeetaNetSDK.Referenced.CertificateACLPrincipal.html +4 -0
  94. package/docs/interfaces/KeetaNetSDK.Referenced.CertificateACLRow.html +11 -0
  95. package/docs/interfaces/KeetaNetSDK.Referenced.CertificateComputedEffect.html +5 -0
  96. package/docs/interfaces/KeetaNetSDK.Referenced.ComputedBlocksEffectFields.html +2 -2
  97. package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
  98. package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
  99. package/docs/interfaces/KeetaNetSDK.Referenced.ECDSA_SECP256K1AccountInfo.html +1 -1
  100. package/docs/interfaces/KeetaNetSDK.Referenced.ECDSA_SECP256R1AccountInfo.html +1 -1
  101. package/docs/interfaces/KeetaNetSDK.Referenced.ED25519AccountInfo.html +1 -1
  102. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
  103. package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
  104. package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
  105. package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
  106. package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
  107. package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
  108. package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +3 -3
  109. package/docs/interfaces/KeetaNetSDK.Referenced.ListACLsByEntityFilters.html +4 -0
  110. package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
  111. package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
  112. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigAccountInfo.html +1 -1
  113. package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
  114. package/docs/interfaces/KeetaNetSDK.Referenced.NetworkAccountInfo.html +1 -1
  115. package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
  116. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
  117. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
  118. package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
  119. package/docs/interfaces/KeetaNetSDK.Referenced.PrincipalACLWithInfoParsed.html +2 -7
  120. package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
  121. package/docs/interfaces/KeetaNetSDK.Referenced.PublishOptions.html +1 -1
  122. package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
  123. package/docs/interfaces/KeetaNetSDK.Referenced.StorageAccountInfo.html +1 -1
  124. package/docs/interfaces/KeetaNetSDK.Referenced.TokenAccountInfo.html +1 -1
  125. package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
  126. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
  127. package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
  128. package/docs/interfaces/KeetaNetSDK.Referenced.VoteStapleJSON.html +2 -2
  129. package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
  130. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
  131. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
  132. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
  133. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
  134. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
  135. package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Struct.html +1 -1
  136. package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
  137. package/docs/types/KeetaNetSDK.Referenced.ACLEntryUnparsed.html +1 -5
  138. package/docs/types/KeetaNetSDK.Referenced.ACLPermissionRequirement.html +2 -0
  139. package/docs/types/KeetaNetSDK.Referenced.ACLPrincipalType.html +1 -0
  140. package/docs/types/KeetaNetSDK.Referenced.ACLRow.html +2 -0
  141. package/docs/types/KeetaNetSDK.Referenced.ACLUpdate.html +5 -0
  142. package/docs/types/KeetaNetSDK.Referenced.ComputedBlockEffect.html +2 -0
  143. package/docs/types/KeetaNetSDK.Referenced.ComputedEffectOfBlocks.html +2 -2
  144. package/docs/types/KeetaNetSDK.Referenced.ComputedEffectOfBlocksByEntity.html +2 -0
  145. package/docs/types/KeetaNetSDK.Referenced.ModifyPermissionsPrincipal.html +1 -0
  146. package/docs/types/KeetaNetSDK.Referenced.ModifyPermissionsPrincipalInput.html +1 -0
  147. package/docs/variables/KeetaNetSDK.Referenced.BlockOperationASN1Schema.html +2 -2
  148. package/docs/variables/KeetaNetSDK.Referenced.FullLedgerBaseErrorCode.html +1 -1
  149. package/docs/variables/KeetaNetSDK.Referenced.aclPrincipalType.html +1 -0
  150. package/docs/variables/KeetaNetSDK.Referenced.allFullErrorCodes.html +1 -1
  151. package/lib/block/index.d.ts +14 -2
  152. package/lib/block/operations.d.ts +40 -4
  153. package/lib/error/block.d.ts +2 -2
  154. package/lib/error/index.d.ts +1 -1
  155. package/lib/error/ledger.d.ts +3 -3
  156. package/lib/ledger/common.d.ts +7 -5
  157. package/lib/ledger/db_dynamodb.d.ts +2 -2
  158. package/lib/ledger/db_postgres.d.ts +3 -3
  159. package/lib/ledger/db_spanner.d.ts +3 -3
  160. package/lib/ledger/db_spanner_helper.d.ts +23 -3
  161. package/lib/ledger/db_sqlite.d.ts +3 -3
  162. package/lib/ledger/effects.d.ts +17 -9
  163. package/lib/ledger/index.d.ts +14 -5
  164. package/lib/ledger/types.d.ts +38 -14
  165. package/lib/log/target_gcp.js +19 -17
  166. package/lib/utils/external-keys/gcp-kms-wrapped.d.ts +85 -0
  167. package/lib/utils/external-keys/gcp-kms-wrapped.js +453 -0
  168. package/lib/utils/external-keys/gcp-kms.common.d.ts +17 -0
  169. package/lib/utils/external-keys/gcp-kms.d.ts +4 -9
  170. package/lib/utils/external-keys/gcp-kms.js +52 -39
  171. package/lib/utils/external-keys/passkey-prf.d.ts +42 -1
  172. package/lib/utils/external-keys/passkey-prf.js +107 -13
  173. package/lib/vote.d.ts +7 -1
  174. package/npm-shrinkwrap.json +24 -24
  175. package/package.json +1 -1
  176. package/version.d.ts +1 -1
  177. package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +0 -10
  178. package/docs/interfaces/KeetaNetSDK.Referenced.ACLRow.html +0 -10
  179. package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +0 -12
  180. package/docs/interfaces/KeetaNetSDK.Referenced.ComputedBlockEffect.html +0 -4
  181. package/docs/types/KeetaNetSDK.Referenced.ComputedEffectOfBlocksByAccount.html +0 -2
@@ -6,7 +6,17 @@ import Vote, { PossiblyExpiredVote, VoteBlockHash } from '../vote';
6
6
  import type { BaseSet, ExternalSet } from '../permissions';
7
7
  import type { SpannerTransaction } from './db_spanner';
8
8
  import { Certificate, CertificateBundle, CertificateHash } from '../utils/certificate';
9
+ import type { ACLPrincipalType } from './types';
9
10
  declare const ColumnTypes: {
11
+ readonly GENERIC_ACCOUNT_OR_CERTIFICATE_HASH: {
12
+ readonly fromSpanner: (value: string) => GenericAccount | CertificateHash;
13
+ readonly toSpanner: (value: CertificateHash | GenericAccount) => import("../account").TokenPublicKeyString | import("../account").NetworkPublicKeyString | import("../account").StoragePublicKeyString | import("../account").MultisigPublicKeyString | import("../account").Secp256K1PublicKeyString | import("../account").Secp256R1PublicKeyString | import("../account").ED25519PublicKeyString | (string & {
14
+ readonly __certificateHash: never;
15
+ });
16
+ readonly toComparable: (name: string | CertificateHash | GenericAccount) => string;
17
+ readonly dbType: string;
18
+ readonly dbSize: number;
19
+ };
10
20
  readonly LEDGER: {
11
21
  readonly dbType: "STRING";
12
22
  readonly dbSize: 4;
@@ -212,6 +222,13 @@ declare const ColumnTypes: {
212
222
  fromSpanner: (value: Buffer) => bigint;
213
223
  toComparable: (val: Buffer | bigint | string) => bigint;
214
224
  };
225
+ readonly ACL_ROW_TYPE: {
226
+ dbType: string;
227
+ dbSize: number;
228
+ toComparable: (input: string | ACLPrincipalType) => "ACCOUNT" | "CERTIFICATE";
229
+ fromSpanner: (input: string) => "ACCOUNT" | "CERTIFICATE";
230
+ toSpanner: (input: ACLPrincipalType) => "ACCOUNT" | "CERTIFICATE";
231
+ };
215
232
  };
216
233
  type ColumnTypeName = keyof typeof ColumnTypes;
217
234
  type ColumnOutputTypeArg<T extends ColumnTypeName> = Parameters<typeof ColumnTypes[T]['fromSpanner']>[0];
@@ -221,6 +238,7 @@ type ColumnOutputTypeInfer<X> = X extends ColumnInterface<infer TR, infer Nullab
221
238
  type ColumnInputTypeArg<T extends ColumnTypeName> = Parameters<typeof ColumnTypes[T]['toSpanner']>[0];
222
239
  type ColumnInputTypeReturn<T extends ColumnTypeName> = ReturnType<typeof ColumnTypes[T]['toSpanner']>;
223
240
  interface ColumnInterface<T extends ColumnTypeName, Nullable extends boolean = boolean> {
241
+ default: (value: ColumnOutputTypeReturn<T>) => ColumnInterface<T, Nullable>;
224
242
  nullable: <SetNullable extends boolean>(nullable: SetNullable) => ColumnInterface<T, SetNullable>;
225
243
  fromSpanner: (value: ColumnOutputTypeArg<T>, transaction: SpannerTransaction) => ColumnOutputTypeReturn<T>;
226
244
  toSpanner: (value: ColumnInputTypeArg<T>, transaction: SpannerTransaction) => ColumnInputTypeReturn<T>;
@@ -247,7 +265,7 @@ declare const schema: {
247
265
  readonly accountInfo: {
248
266
  readonly type: "TABLE";
249
267
  readonly columns: {
250
- readonly account: ColumnInterface<"GENERIC_ACCOUNT", false>;
268
+ readonly account: ColumnInterface<"GENERIC_ACCOUNT_OR_CERTIFICATE_HASH", false>;
251
269
  readonly name: ColumnInterface<"INFO_NAME", true>;
252
270
  readonly description: ColumnInterface<"INFO_DESCRIPTION", true>;
253
271
  readonly metadata: ColumnInterface<"INFO_METADATA", true>;
@@ -261,11 +279,13 @@ declare const schema: {
261
279
  readonly permissions: {
262
280
  readonly type: "TABLE";
263
281
  readonly columns: {
264
- readonly account: ColumnInterface<"GENERIC_ACCOUNT", false>;
282
+ readonly account: ColumnInterface<"GENERIC_ACCOUNT_OR_CERTIFICATE_HASH", false>;
265
283
  readonly entity: ColumnInterface<"GENERIC_ACCOUNT", false>;
266
284
  readonly target: ColumnInterface<"GENERIC_ACCOUNT", false>;
267
285
  readonly basePermission: ColumnInterface<"BASE_PERMISSION", false>;
268
286
  readonly externalPermission: ColumnInterface<"EXTERNAL_PERMISSION", false>;
287
+ readonly principalType: ColumnInterface<"ACL_ROW_TYPE", false>;
288
+ readonly certificateAccount: ColumnInterface<"GENERIC_ACCOUNT", true>;
269
289
  };
270
290
  readonly key: readonly [Key, Key, Key];
271
291
  readonly interleave: Interleave;
@@ -391,7 +411,7 @@ declare const schema: {
391
411
  readonly type: "INDEX";
392
412
  readonly table: "permissions";
393
413
  readonly key: readonly [Key];
394
- readonly storing: readonly [Key, Key];
414
+ readonly storing: readonly [Key, Key, Key, Key];
395
415
  };
396
416
  readonly permissionsEntityBasePerm: {
397
417
  readonly type: "INDEX";
@@ -4,7 +4,7 @@ import { 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, LedgerStorageTransactionBaseOptions } from '../ledger';
7
+ import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions, LedgerStorageTransactionBaseOptions, ListACLsByEntityFilters } from '../ledger';
8
8
  import { IdempotentKey, LedgerStorageTransactionBase } from '../ledger';
9
9
  import type { ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates, AccountInfoForType } from './types';
10
10
  import { LedgerStorageBase } from './common';
@@ -40,8 +40,8 @@ export declare class DBSqlite extends LedgerStorageBase implements LedgerStorage
40
40
  */
41
41
  protected adjustDefer(transaction: DBSqliteTransaction, input: VoteStaple): Promise<void>;
42
42
  listOwners(transaction: DBSqliteTransaction, entity: IdentifierAddress): Promise<Account<AccountKeyAlgorithm.TOKEN>[]>;
43
- listACLsByEntity(transaction: DBSqliteTransaction, entity: GenericAccount): Promise<ACLRow[]>;
44
- listACLsByPrincipal(transaction: DBSqliteTransaction, principal: GenericAccount, entityList?: GenericAccount[]): Promise<ACLRow[]>;
43
+ listACLsByEntity(transaction: DBSqliteTransaction, entity: GenericAccount, options?: ListACLsByEntityFilters): Promise<ACLRow[]>;
44
+ listACLsByPrincipal(transaction: DBSqliteTransaction, principal: ACLRow['principal'], entityList?: GenericAccount[]): Promise<ACLRow[]>;
45
45
  getAccountInfo<T extends AccountKeyAlgorithm = AccountKeyAlgorithm>(transaction: DBSqliteTransaction, account: Account<T> | string): Promise<AccountInfoForType<T>>;
46
46
  adjust(transaction: DBSqliteTransaction, input: VoteStaple, changes: ComputedEffectOfBlocks, mayDefer?: boolean, completedStaples?: Set<string>): Promise<VoteStaple[]>;
47
47
  getBlock(transaction: DBSqliteTransaction, block: BlockHash, from: LedgerSelector): Promise<Block | null>;
@@ -3,7 +3,7 @@ import Account from '../account';
3
3
  import type { AdjustMethod } from '../block';
4
4
  import { Block } from '../block';
5
5
  import type * as Operations from '../block/operations';
6
- import type { ACLEntry, ACLUpdate, AccountInfo } from '../ledger/types';
6
+ import type { AccountInfo, ACLUpdate, ACLPermissionRequirement } from '../ledger/types';
7
7
  import type { Certificate, CertificateBundle } from '../utils/certificate';
8
8
  import { CertificateHash } from '../utils/certificate';
9
9
  import type { DistributiveOmit } from '../utils/helper';
@@ -56,27 +56,35 @@ interface ComputedBlocksEffectFields {
56
56
  supply?: NumericValueEntry[];
57
57
  info?: Partial<UserEditableAccountInfo>;
58
58
  permissions?: ACLUpdate[];
59
- permissionRequirements?: ACLEntry[];
59
+ permissionRequirements?: ACLPermissionRequirement[];
60
60
  createRequests?: CreateIdentifierRequest[];
61
61
  delegation?: DelegationUpdate;
62
62
  certificate?: CertificateUpdate[];
63
63
  minSignerSetLength?: bigint;
64
64
  }
65
- /**
66
- * Which accounts and fields are affected by a set of block
67
- */
68
- interface ComputedBlockEffect {
65
+ interface CertificateComputedEffect {
66
+ type: 'CERTIFICATE';
67
+ certificateHash: CertificateHash;
68
+ certificateAccount: GenericAccount;
69
+ fields: ComputedBlocksEffectFields;
70
+ }
71
+ interface AccountComputedEffect {
72
+ type: 'ACCOUNT';
69
73
  account: GenericAccount;
70
74
  fields: ComputedBlocksEffectFields;
71
75
  }
76
+ /**
77
+ * Which accounts and fields are affected by a set of block
78
+ */
79
+ type ComputedBlockEffect = CertificateComputedEffect | AccountComputedEffect;
72
80
  /**
73
81
  * A breakdown of computed effects by account public key
74
82
  */
75
- export type ComputedEffectOfBlocksByAccount = {
76
- [accountPubKey: string]: ComputedBlockEffect;
83
+ export type ComputedEffectOfBlocksByEntity = {
84
+ [entityKey: string]: ComputedBlockEffect;
77
85
  };
78
86
  export type ComputedEffectOfBlocks = {
79
- accounts: ComputedEffectOfBlocksByAccount;
87
+ accounts: ComputedEffectOfBlocksByEntity;
80
88
  touched: InstanceType<typeof Account.Set>;
81
89
  possibleNewAccounts: InstanceType<typeof Account.Set>;
82
90
  metadata: {
@@ -6,7 +6,7 @@ import Account from '../account';
6
6
  import type Node from '../node';
7
7
  import type { BloomFilter } from '../utils/bloom';
8
8
  import type { ComputedEffectOfBlocks } from './effects';
9
- import type { ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates, AccountInfoForType } from './types';
9
+ import type { ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates, AccountInfoForType, ACLPrincipalType } from './types';
10
10
  import LedgerRequestCache from './cache';
11
11
  import type { Logger } from '../log';
12
12
  import type { CertificateHash } from '../utils/certificate';
@@ -109,6 +109,15 @@ export type GetVotesAfterOptions = {
109
109
  */
110
110
  timeout?: number;
111
111
  };
112
+ /**
113
+ * Filters for listing ACLs by entity
114
+ */
115
+ export interface ListACLsByEntityFilters {
116
+ /**
117
+ * If provided, only return ACL rows of this type
118
+ */
119
+ principalType?: ACLPrincipalType;
120
+ }
112
121
  type IdempotentKeyString = string & {
113
122
  readonly __idempotentKey: never;
114
123
  };
@@ -197,11 +206,11 @@ export interface LedgerStorageAPI {
197
206
  /**
198
207
  * List permissions principal has on all provided entity's
199
208
  */
200
- listACLsByPrincipal: (transaction: any, principal: GenericAccount, entityList?: GenericAccount[]) => Promise<ACLRow[]>;
209
+ listACLsByPrincipal: (transaction: any, principal: ACLRow['principal'], entityList?: GenericAccount[]) => Promise<ACLRow[]>;
201
210
  /**
202
211
  * List permissions any principal has on provided entity
203
212
  */
204
- listACLsByEntity: (transaction: any, entity: GenericAccount) => Promise<ACLRow[]>;
213
+ listACLsByEntity: (transaction: any, entity: GenericAccount, options?: ListACLsByEntityFilters) => Promise<ACLRow[]>;
205
214
  /**
206
215
  * Adjust the ledger by performing a set of changes based on some blocks and votes
207
216
  */
@@ -338,8 +347,8 @@ declare class LedgerAtomicInterface {
338
347
  getAllBalances(account: GenericAccount): Promise<GetAllBalancesResponse>;
339
348
  getAccountCertificates(account: GenericAccount): Promise<CertificateWithIntermediates[]>;
340
349
  getAccountCertificateByHash(account: GenericAccount, hash: CertificateHash): Promise<CertificateWithIntermediates | null>;
341
- listACLsByPrincipal(principal: GenericAccount, entityList?: GenericAccount[]): Promise<ACLRow[]>;
342
- listACLsByEntity(entity: GenericAccount): Promise<ACLRow[]>;
350
+ listACLsByPrincipal(principal: ACLRow['principal'], entityList?: GenericAccount[]): Promise<ACLRow[]>;
351
+ listACLsByEntity(entity: GenericAccount, options?: ListACLsByEntityFilters): Promise<ACLRow[]>;
343
352
  votingPower(rep?: Account): Promise<bigint>;
344
353
  getVotes(block: BlockHash, from?: LedgerStorage): Promise<Vote[] | null>;
345
354
  getVotesFromMultiplePrevious(prevBlocks: BlockHash[], from?: LedgerSelector, issuer?: Account): Promise<{
@@ -2,7 +2,7 @@ import type { Account, AccountKeyAlgorithm, GenericAccount, IdentifierKeyAlgorit
2
2
  import type { AdjustMethod } from '../block';
3
3
  import type { Permissions } from '../permissions';
4
4
  import type { DbStats, TimeStats } from '../stats';
5
- import type { Certificate, CertificateBundle } from '../utils/certificate';
5
+ import type { Certificate, CertificateBundle, CertificateHash } from '../utils/certificate';
6
6
  import type { DistributiveOmit } from '../utils/helper';
7
7
  export interface MultisigConfig {
8
8
  signers: (Account | MultisigAddress)[];
@@ -70,14 +70,21 @@ export declare function isKeyPairAccountInfo(info: AccountInfo): info is KeyPair
70
70
  export declare function isAccountInfoOfType<T extends AccountKeyAlgorithm>(info: AccountInfo, type: T): info is Extract<AccountInfo, {
71
71
  account: Account<T>;
72
72
  }>;
73
- /**
74
- * Permissions types
75
- */
76
- export interface ACLRow {
73
+ declare const aclPrincipalType: readonly ["ACCOUNT", "CERTIFICATE"];
74
+ export type ACLPrincipalType = typeof aclPrincipalType[number];
75
+ export declare function isACLPrincipalType(type: string): type is ACLPrincipalType;
76
+ export declare function assertACLPrincipalType(type: string): asserts type is ACLPrincipalType;
77
+ export declare function asACLPrincipalType(type: string): ACLPrincipalType;
78
+ interface CertificateACLPrincipal {
79
+ usingCertificate: true;
80
+ certificate: CertificateHash;
81
+ certificateAccount: GenericAccount;
82
+ }
83
+ interface BaseACLRow<PrincipalType extends ACLPrincipalType> {
77
84
  /**
78
- * The account that these permissions apply to
85
+ * The type of ACL row, which determines the shape of the principal
79
86
  */
80
- principal: GenericAccount;
87
+ principalType: PrincipalType;
81
88
  /**
82
89
  * The account that this row is for
83
90
  */
@@ -91,19 +98,36 @@ export interface ACLRow {
91
98
  */
92
99
  permissions: Permissions;
93
100
  }
101
+ interface AccountACLRow extends BaseACLRow<'ACCOUNT'> {
102
+ /**
103
+ * The account that these permissions apply to
104
+ */
105
+ principal: GenericAccount;
106
+ }
107
+ interface CertificateACLRow extends BaseACLRow<'CERTIFICATE'> {
108
+ /**
109
+ * Accounts having certificate issued by this certificate will be granted the permissions in this ACL row
110
+ */
111
+ principal: CertificateACLPrincipal;
112
+ }
94
113
  /**
95
- * An entry for the ACL
96
- * @expandType ACLRow
114
+ * Permissions types
97
115
  */
98
- export interface ACLEntry extends Omit<ACLRow, 'target'> {
116
+ export type ACLRow = AccountACLRow | CertificateACLRow;
117
+ /**
118
+ * A permission requirement for ledger effects
119
+ * @expandType AccountACLRow
120
+ */
121
+ export type ACLPermissionRequirement = Omit<AccountACLRow, 'target' | 'principalType'> & {
99
122
  target?: GenericAccount;
100
123
  method?: AdjustMethod.SET;
101
- }
124
+ };
102
125
  /**
103
126
  * Update an ACL for an account
104
- * @expandType ACLEntry
127
+ * @expandType ACLRow
105
128
  */
106
- export interface ACLUpdate extends Omit<ACLEntry, 'method' | 'permissions'> {
129
+ export type ACLUpdate = DistributiveOmit<ACLRow, 'method' | 'permissions' | 'target'> & {
130
+ target?: GenericAccount;
107
131
  /**
108
132
  * The method to use to update the ACL
109
133
  */
@@ -114,7 +138,7 @@ export interface ACLUpdate extends Omit<ACLEntry, 'method' | 'permissions'> {
114
138
  * If this is set to null, the permissions will be unset
115
139
  */
116
140
  permissions: Permissions | null;
117
- }
141
+ };
118
142
  /**
119
143
  * All balances for each token on an account
120
144
  */
@@ -274,7 +274,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
274
274
  var __importDefault = (this && this.__importDefault) || function (mod) {
275
275
  return (mod && mod.__esModule) ? mod : { "default": mod };
276
276
  };
277
- var _LogTargetGCP_instances, _LogTargetGCP_googleCloudLoggingOptions, _LogTargetGCP_googleCloudLogging, _LogTargetGCP_consoleLoggingTarget, _LogTargetGCP_console, _LogTargetGCP_gcpLoggingTarget_get;
277
+ var _LogTargetGCP_instances, _LogTargetGCP_googleCloudLoggingOptions, _LogTargetGCP_googleCloudLogging, _LogTargetGCP_consoleLoggingTarget, _LogTargetGCP_console, _LogTargetGCP_getLabels, _LogTargetGCP_logStartupInformationToConsole, _LogTargetGCP_gcpLoggingTarget_get;
278
278
  Object.defineProperty(exports, "__esModule", ({ value: true }));
279
279
  exports.Testing = void 0;
280
280
  const common_1 = __webpack_require__(364);
@@ -403,6 +403,7 @@ class LogTargetGCP {
403
403
  instance: instance,
404
404
  log: instance.log(__classPrivateFieldGet(this, _LogTargetGCP_instances, "a", _LogTargetGCP_gcpLoggingTarget_get))
405
405
  }, "f");
406
+ __classPrivateFieldGet(this, _LogTargetGCP_instances, "m", _LogTargetGCP_logStartupInformationToConsole).call(this);
406
407
  }
407
408
  /**
408
409
  * This function tries to log a test message to GCP Logging, and if it fails,
@@ -413,8 +414,7 @@ class LogTargetGCP {
413
414
  */
414
415
  async test(canRun, elseRun) {
415
416
  const gcpLogging = __classPrivateFieldGet(this, _LogTargetGCP_googleCloudLogging, "f");
416
- const [vendor, product] = __classPrivateFieldGet(this, _LogTargetGCP_instances, "a", _LogTargetGCP_gcpLoggingTarget_get).split('/');
417
- const environment = __classPrivateFieldGet(this, _LogTargetGCP_googleCloudLoggingOptions, "f").environment;
417
+ const labels = __classPrivateFieldGet(this, _LogTargetGCP_instances, "m", _LogTargetGCP_getLabels).call(this);
418
418
  try {
419
419
  await gcpLogging.log.write(gcpLogging.instance.entry({
420
420
  jsonPayload: {
@@ -427,11 +427,7 @@ class LogTargetGCP {
427
427
  resource: {
428
428
  type: 'global'
429
429
  },
430
- labels: {
431
- vendor: vendor,
432
- product: product,
433
- environment: environment
434
- },
430
+ labels: labels,
435
431
  severity: 'DEBUG'
436
432
  }));
437
433
  await canRun();
@@ -450,8 +446,7 @@ class LogTargetGCP {
450
446
  if (logs.length === 0) {
451
447
  return;
452
448
  }
453
- const [vendor, product] = __classPrivateFieldGet(this, _LogTargetGCP_instances, "a", _LogTargetGCP_gcpLoggingTarget_get).split('/');
454
- const environment = __classPrivateFieldGet(this, _LogTargetGCP_googleCloudLoggingOptions, "f").environment;
449
+ const labels = __classPrivateFieldGet(this, _LogTargetGCP_instances, "m", _LogTargetGCP_getLabels).call(this);
455
450
  const logEntries = logs.map((log) => {
456
451
  const addLogFields = {};
457
452
  if (log.trace !== undefined) {
@@ -479,12 +474,7 @@ class LogTargetGCP {
479
474
  resource: {
480
475
  type: 'global'
481
476
  },
482
- labels: {
483
- vendor: vendor,
484
- product: product,
485
- environment: environment,
486
- ...(this.context ?? {})
487
- },
477
+ labels: labels,
488
478
  severity: log.level
489
479
  }));
490
480
  });
@@ -497,7 +487,19 @@ class LogTargetGCP {
497
487
  }
498
488
  }
499
489
  }
500
- _LogTargetGCP_googleCloudLoggingOptions = new WeakMap(), _LogTargetGCP_googleCloudLogging = new WeakMap(), _LogTargetGCP_consoleLoggingTarget = new WeakMap(), _LogTargetGCP_console = new WeakMap(), _LogTargetGCP_instances = new WeakSet(), _LogTargetGCP_gcpLoggingTarget_get = function _LogTargetGCP_gcpLoggingTarget_get() {
490
+ _LogTargetGCP_googleCloudLoggingOptions = new WeakMap(), _LogTargetGCP_googleCloudLogging = new WeakMap(), _LogTargetGCP_consoleLoggingTarget = new WeakMap(), _LogTargetGCP_console = new WeakMap(), _LogTargetGCP_instances = new WeakSet(), _LogTargetGCP_getLabels = function _LogTargetGCP_getLabels() {
491
+ const [vendor, product] = __classPrivateFieldGet(this, _LogTargetGCP_instances, "a", _LogTargetGCP_gcpLoggingTarget_get).split('/');
492
+ const environment = __classPrivateFieldGet(this, _LogTargetGCP_googleCloudLoggingOptions, "f").environment;
493
+ return ({
494
+ vendor: vendor,
495
+ product: product,
496
+ environment: environment,
497
+ ...this.context
498
+ });
499
+ }, _LogTargetGCP_logStartupInformationToConsole = function _LogTargetGCP_logStartupInformationToConsole() {
500
+ const labels = __classPrivateFieldGet(this, _LogTargetGCP_instances, "m", _LogTargetGCP_getLabels).call(this);
501
+ __classPrivateFieldGet(this, _LogTargetGCP_console, "f").info(`[LogTargetGCP] Initializing Google Cloud Logging with ${JSON.stringify(labels)}`);
502
+ }, _LogTargetGCP_gcpLoggingTarget_get = function _LogTargetGCP_gcpLoggingTarget_get() {
501
503
  return (`${__classPrivateFieldGet(this, _LogTargetGCP_googleCloudLoggingOptions, "f").vendor}/${__classPrivateFieldGet(this, _LogTargetGCP_googleCloudLoggingOptions, "f").product}`);
502
504
  };
503
505
  /** @internal */
@@ -0,0 +1,85 @@
1
+ /**
2
+ * ExternalKeyPair for the Keeta Network which uses Google Cloud KMS
3
+ * to wrap private key operations. This allows users to leverage GCP KMS for
4
+ * decrypting an encrypted private key and performing signing and encryption
5
+ * operations without exposing the private key material to the application.
6
+ *
7
+ * Internally, it uses RSA keys on GCP KMS to support decrypting the
8
+ * supplied encrypted keying material.
9
+ */
10
+ import type { KeyManagementServiceClient } from '@google-cloud/kms';
11
+ import type * as KeetaNet from '../../../client';
12
+ import type { AccountKeyAlgorithm } from '../../../lib/account';
13
+ import type * as crypto from 'node:crypto';
14
+ import type { GCPKMSKeyConfig } from './gcp-kms.common';
15
+ type KeetaGCPKMSWrappedKeyPairPackages = {
16
+ /**
17
+ * GCP KMS Key Management Service Client, used to interact with GCP KMS
18
+ * for key lookups and decryption operations
19
+ */
20
+ KeyManagementServiceClient: typeof KeyManagementServiceClient;
21
+ /**
22
+ * Keeta Network client library
23
+ */
24
+ KeetaNet: {
25
+ lib: {
26
+ Account: typeof KeetaNet.lib.Account;
27
+ Utils: {
28
+ Helper: {
29
+ bufferToArrayBuffer: typeof KeetaNet.lib.Utils.Helper.bufferToArrayBuffer;
30
+ };
31
+ Buffer: typeof KeetaNet.lib.Utils.Buffer;
32
+ };
33
+ };
34
+ };
35
+ /**
36
+ * NodeJS Crypto module, only required for encrypting the seed material
37
+ * not required otherwise
38
+ */
39
+ crypto?: {
40
+ createPublicKey: typeof crypto.createPublicKey;
41
+ publicEncrypt: typeof crypto.publicEncrypt;
42
+ constants: {
43
+ RSA_PKCS1_OAEP_PADDING: typeof crypto.constants.RSA_PKCS1_OAEP_PADDING;
44
+ };
45
+ };
46
+ };
47
+ type AccountKeyAlgorithmNumberOrString = AccountKeyAlgorithm | keyof typeof AccountKeyAlgorithm;
48
+ type KeetaGCPKMSWrappedKeyPairOptions = {
49
+ /**
50
+ * The GCP KMS key resource name or config object.
51
+ * Format: projects/<project>/locations/<location>/keyRings/<keyRing>/cryptoKeys/<key>
52
+ */
53
+ kmsKey: string | GCPKMSKeyConfig;
54
+ /**
55
+ * The encrypted seed to use for account creation
56
+ */
57
+ encryptedSeed: ArrayBuffer;
58
+ /**
59
+ * The index of the key to use for account creation (default is 0)
60
+ */
61
+ index?: number;
62
+ /**
63
+ * Key type for this key
64
+ */
65
+ keyType: AccountKeyAlgorithmNumberOrString;
66
+ };
67
+ interface KeetaGCPKMSWrappedKeyPairClass {
68
+ encryptSeed: (input: ArrayBuffer, options: Omit<KeetaGCPKMSWrappedKeyPairOptions, 'encryptedSeed'>) => Promise<ArrayBuffer>;
69
+ lookup: (options: KeetaGCPKMSWrappedKeyPairOptions) => Promise<InstanceType<typeof KeetaNet.lib.Account>>;
70
+ lookupFromJSON: ((input: Pick<KeetaGCPKMSWrappedKeyPairOptions, 'kmsKey' | 'keyType' | 'index'> & {
71
+ encryptedSeed: string;
72
+ type: 'gcpkmswrapped';
73
+ }) => Promise<InstanceType<typeof KeetaNet.lib.Account>>) | ((input: unknown) => Promise<InstanceType<typeof KeetaNet.lib.Account>>);
74
+ lookupFromString: (input: string) => Promise<InstanceType<typeof KeetaNet.lib.Account>>;
75
+ getJSONFromOptions: (options: KeetaGCPKMSWrappedKeyPairOptions) => Promise<{
76
+ type: 'gcpkmswrapped';
77
+ kmsKey: string;
78
+ keyType: string;
79
+ encryptedSeed: string;
80
+ index: number;
81
+ }>;
82
+ getStringFromOptions: (options: KeetaGCPKMSWrappedKeyPairOptions) => Promise<string>;
83
+ }
84
+ export declare function KeetaGCPKMSWrappedKeyPairFactory(packages: KeetaGCPKMSWrappedKeyPairPackages): Omit<KeetaGCPKMSWrappedKeyPairClass, '_Testing'>;
85
+ export {};