@canton-network/core-ledger-client 0.11.0 → 0.12.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.
@@ -1,6 +1,16 @@
1
1
  import { LedgerClient } from './ledger-client.js';
2
2
  import { PartyId } from '@canton-network/core-types';
3
3
  import { SigningPublicKey, Enums_ParticipantPermission, SignedTopologyTransaction, AuthorizeResponse, GenerateTransactionsResponse } from '@canton-network/core-ledger-proto';
4
+ export interface TlsOptions {
5
+ rootCert?: string | Buffer;
6
+ clientCert?: string | Buffer;
7
+ clientKey?: string | Buffer;
8
+ mutual?: boolean;
9
+ }
10
+ export interface GrpcClientOptions {
11
+ useTls?: boolean;
12
+ tls: TlsOptions;
13
+ }
4
14
  export declare class TopologyWriteService {
5
15
  private synchronizerId;
6
16
  private userAdminToken;
@@ -8,7 +18,7 @@ export declare class TopologyWriteService {
8
18
  private topologyReadService;
9
19
  private ledgerClient;
10
20
  private storeId;
11
- constructor(synchronizerId: string, userAdminUrl: string, userAdminToken: string, ledgerClient: LedgerClient);
21
+ constructor(synchronizerId: string, userAdminUrl: string, userAdminToken: string, ledgerClient: LedgerClient, grpcClientOptions?: GrpcClientOptions);
12
22
  static combineHashes(hashes: Buffer[]): string;
13
23
  static createFingerprintFromKey(publicKey: string): string;
14
24
  /** @deprecated using the protobuf publickey is no longer supported -- use the string parameter instead */
@@ -1 +1 @@
1
- {"version":3,"file":"topology-write-service.d.ts","sourceRoot":"","sources":["../src/topology-write-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAIH,gBAAgB,EAOhB,2BAA2B,EAM3B,yBAAyB,EAMzB,iBAAiB,EAGjB,4BAA4B,EAK/B,MAAM,mCAAmC,CAAA;AAiC1C,qBAAa,oBAAoB;IAgBzB,OAAO,CAAC,cAAc;IAEtB,OAA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BAAgB,GAAG,MAAM;IACpE,0GAA0G;IAC1G,MAAM,CAAC,wBAAwB,CAC3B,SAAS,EAAE,gBAAgB,GAAG,MAAM,GACrC,MAAM;IAoBT,wDAAwD;IACxD,MAAM,CAAC,2BAA2B,CAC9B,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,EAC/B,qBAAqB,EAAE,UAAU,CAAC,eAAe,CAAC,EAClD,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,yBAAyB;IAqB5B,kBAAkB;IAClB,OAAO,CAAC,2BAA2B;IAoEnC,sDAAsD;IAChD,2BAA2B,CAC7B,iBAAiB,EAAE,yBAAyB,EAAE,EAC9C,OAAO,EAAE,OAAO;IAMpB,yCAAyC;IACnC,oBAAoB,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,EAChB,mBAAmB,GAAE,MAAU,EAC/B,wBAAwB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,2BAA2B,CAAC,GACpE,OAAO,CAAC,4BAA4B,CAAC;IAkCxC,kBAAkB;YACJ,eAAe;IAgB7B,kBAAkB;IACZ,iCAAiC,CACnC,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAiClC,kBAAkB;IACZ,2BAA2B,CAC7B,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,iBAAiB,CAAC;CAqBhC"}
@@ -4,6 +4,7 @@ import { createHash } from 'node:crypto';
4
4
  import { CryptoKeyFormat, SigningKeyScheme, SigningKeySpec, Signature, SignatureFormat, SigningAlgorithmSpec, TopologyManagerWriteServiceClient, StoreId, StoreId_Synchronizer, Enums_ParticipantPermission, Enums_TopologyChangeOp, NamespaceDelegation, PartyToKeyMapping, PartyToParticipant, PartyToParticipant_HostingParticipant, SignedTopologyTransaction, TopologyMapping, MultiTransactionSignatures, AddTransactionsRequest, AuthorizeRequest, GenerateTransactionsRequest, GenerateTransactionsRequest_Proposal, BaseQuery, ListPartyToParticipantRequest, Empty, TopologyManagerReadServiceClient, } from '@canton-network/core-ledger-proto';
5
5
  import { GrpcTransport } from '@protobuf-ts/grpc-transport';
6
6
  import { ChannelCredentials } from '@grpc/grpc-js';
7
+ import fs from 'fs';
7
8
  function prefixedInt(value, bytes) {
8
9
  const buffer = Buffer.alloc(4 + bytes.length);
9
10
  buffer.writeUInt32BE(value, 0);
@@ -28,6 +29,27 @@ function computeSha256CantonHash(purpose, bytes) {
28
29
  const multiprefix = Buffer.from([0x12, 0x20]);
29
30
  return Buffer.concat([multiprefix, hash]).toString('hex');
30
31
  }
32
+ function createGrpcTransport(options) {
33
+ const { useTls = false, tls } = options;
34
+ if (useTls) {
35
+ const readMaybeFile = (value) => typeof value === 'string' ? fs.readFileSync(value) : value;
36
+ const rootCert = readMaybeFile(tls?.rootCert);
37
+ const clientCert = readMaybeFile(tls?.clientCert);
38
+ const clientKey = readMaybeFile(tls?.clientKey);
39
+ if (tls?.mutual) {
40
+ if (!clientCert || !clientKey) {
41
+ throw new Error('mTLS enabled but clientCert or clientKey are missing');
42
+ }
43
+ return ChannelCredentials.createSsl(rootCert, clientKey, clientCert);
44
+ }
45
+ else {
46
+ return ChannelCredentials.createSsl(rootCert);
47
+ }
48
+ }
49
+ else {
50
+ return ChannelCredentials.createInsecure();
51
+ }
52
+ }
31
53
  export class TopologyWriteService {
32
54
  synchronizerId;
33
55
  userAdminToken;
@@ -42,13 +64,22 @@ export class TopologyWriteService {
42
64
  }),
43
65
  },
44
66
  });
45
- constructor(synchronizerId, userAdminUrl, userAdminToken, ledgerClient) {
67
+ constructor(synchronizerId, userAdminUrl, userAdminToken, ledgerClient, grpcClientOptions) {
46
68
  this.synchronizerId = synchronizerId;
47
69
  this.userAdminToken = userAdminToken;
48
- const transport = new GrpcTransport({
49
- host: userAdminUrl,
50
- channelCredentials: ChannelCredentials.createInsecure(),
51
- });
70
+ let transport;
71
+ if (grpcClientOptions) {
72
+ transport = new GrpcTransport({
73
+ host: userAdminUrl,
74
+ channelCredentials: createGrpcTransport(grpcClientOptions),
75
+ });
76
+ }
77
+ else {
78
+ transport = new GrpcTransport({
79
+ host: userAdminUrl,
80
+ channelCredentials: ChannelCredentials.createInsecure(),
81
+ });
82
+ }
52
83
  this.topologyClient = new TopologyManagerWriteServiceClient(transport);
53
84
  this.topologyReadService = new TopologyManagerReadServiceClient(transport);
54
85
  this.ledgerClient = ledgerClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canton-network/core-ledger-client",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "description": "Provides a TypeScript Canton Network ledger client, generated by the OpenAPI spec",
6
6
  "repository": "github:hyperledger-labs/splice-wallet-kernel",
@@ -28,10 +28,10 @@
28
28
  "typescript": "^5.8.3"
29
29
  },
30
30
  "dependencies": {
31
- "@canton-network/core-ledger-proto": "^0.7.0",
32
- "@canton-network/core-splice-client": "^0.8.0",
33
- "@canton-network/core-token-standard": "^0.7.0",
34
- "@canton-network/core-types": "^0.6.0",
31
+ "@canton-network/core-ledger-proto": "^0.8.0",
32
+ "@canton-network/core-splice-client": "^0.9.0",
33
+ "@canton-network/core-token-standard": "^0.8.0",
34
+ "@canton-network/core-types": "^0.7.0",
35
35
  "@grpc/grpc-js": "^1.14.0",
36
36
  "@protobuf-ts/grpc-transport": "^2.11.1",
37
37
  "bignumber.js": "^9.2.1",