@distrohelena/canton-typescript-sdk 1.0.3 → 1.0.4

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,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GrpcTransport = exports.GrpcLedgerClient = void 0;
3
+ exports.ListPartyToParticipantResponseCodec = exports.ListPartyToKeyMappingResponseCodec = exports.GrpcTransport = exports.GrpcLedgerClient = void 0;
4
4
  var grpc_ledger_client_js_1 = require("../transports/grpc/grpc-ledger-client.js");
5
5
  Object.defineProperty(exports, "GrpcLedgerClient", { enumerable: true, get: function () { return grpc_ledger_client_js_1.GrpcLedgerClient; } });
6
6
  var grpc_transport_js_1 = require("../transports/grpc/grpc-transport.js");
7
7
  Object.defineProperty(exports, "GrpcTransport", { enumerable: true, get: function () { return grpc_transport_js_1.GrpcTransport; } });
8
+ var topology_response_codec_js_1 = require("../transports/grpc/mappers/topology-response-codec.js");
9
+ Object.defineProperty(exports, "ListPartyToKeyMappingResponseCodec", { enumerable: true, get: function () { return topology_response_codec_js_1.ListPartyToKeyMappingResponseCodec; } });
10
+ Object.defineProperty(exports, "ListPartyToParticipantResponseCodec", { enumerable: true, get: function () { return topology_response_codec_js_1.ListPartyToParticipantResponseCodec; } });
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ListPartyToParticipantResponseCodec = exports.ListPartyToKeyMappingResponseCodec = void 0;
4
+ const participant_permission_js_1 = require("../../../core/types/topology/participant-permission.js");
5
+ const crypto_js_1 = require("../generated/canton/com/digitalasset/canton/crypto/v30/crypto.js");
6
+ const topology_js_1 = require("../generated/canton/com/digitalasset/canton/protocol/v30/topology.js");
7
+ const topology_manager_read_service_js_1 = require("../generated/canton/com/digitalasset/canton/topology/admin/v30/topology_manager_read_service.js");
8
+ const topology_common_mapper_js_1 = require("./topology-common-mapper.js");
9
+ const topology_manager_read_mapper_js_1 = require("./topology-manager-read-mapper.js");
10
+ /** Converts ListPartyToKeyMappingResponse between raw topology-read protobuf and the normalized SDK shape. */
11
+ class ListPartyToKeyMappingResponseCodec {
12
+ constructor() { }
13
+ static fromProto(payload) {
14
+ return (0, topology_manager_read_mapper_js_1.mapGrpcListPartyToKeyMappingResponse)(payload);
15
+ }
16
+ static toProto(response) {
17
+ return {
18
+ results: response.results.map((result) => ({
19
+ context: baseResultToProto(result.context),
20
+ item: partyToKeyMappingToProto(result.item),
21
+ })),
22
+ };
23
+ }
24
+ static fromBinary(bytes) {
25
+ return ListPartyToKeyMappingResponseCodec.fromProto(topology_manager_read_service_js_1.ListPartyToKeyMappingResponse.fromBinary(bytes));
26
+ }
27
+ static toBinary(response) {
28
+ return topology_manager_read_service_js_1.ListPartyToKeyMappingResponse.toBinary(ListPartyToKeyMappingResponseCodec.toProto(response));
29
+ }
30
+ }
31
+ exports.ListPartyToKeyMappingResponseCodec = ListPartyToKeyMappingResponseCodec;
32
+ /** Converts ListPartyToParticipantResponse between raw topology-read protobuf and the normalized SDK shape. */
33
+ class ListPartyToParticipantResponseCodec {
34
+ constructor() { }
35
+ static fromProto(payload) {
36
+ return (0, topology_manager_read_mapper_js_1.mapGrpcListPartyToParticipantResponse)(payload);
37
+ }
38
+ static toProto(response) {
39
+ return {
40
+ results: response.results.map((result) => ({
41
+ context: baseResultToProto(result.context),
42
+ item: partyToParticipantToProto(result.item),
43
+ })),
44
+ };
45
+ }
46
+ static fromBinary(bytes) {
47
+ return ListPartyToParticipantResponseCodec.fromProto(topology_manager_read_service_js_1.ListPartyToParticipantResponse.fromBinary(bytes));
48
+ }
49
+ static toBinary(response) {
50
+ return topology_manager_read_service_js_1.ListPartyToParticipantResponse.toBinary(ListPartyToParticipantResponseCodec.toProto(response));
51
+ }
52
+ }
53
+ exports.ListPartyToParticipantResponseCodec = ListPartyToParticipantResponseCodec;
54
+ function baseResultToProto(value) {
55
+ if (value === undefined) {
56
+ return undefined;
57
+ }
58
+ return {
59
+ store: (0, topology_common_mapper_js_1.mapGrpcTopologyStoreId)(value.storeId),
60
+ sequenced: (0, topology_common_mapper_js_1.mapGrpcTimestamp)(value.sequencedAt),
61
+ validFrom: (0, topology_common_mapper_js_1.mapGrpcTimestamp)(value.validFrom),
62
+ validUntil: (0, topology_common_mapper_js_1.mapGrpcTimestamp)(value.validUntil),
63
+ operation: (0, topology_common_mapper_js_1.mapGrpcTopologyChangeOp)(value.operation),
64
+ transactionHash: new Uint8Array(value.transactionHash),
65
+ serial: value.serial,
66
+ signedByFingerprints: [...value.signedByFingerprints],
67
+ };
68
+ }
69
+ function partyToKeyMappingToProto(value) {
70
+ return {
71
+ party: value.party,
72
+ threshold: value.threshold,
73
+ signingKeys: value.signingKeys.map(signingPublicKeyToProto),
74
+ };
75
+ }
76
+ function partyToParticipantToProto(value) {
77
+ return {
78
+ party: value.party,
79
+ threshold: value.threshold,
80
+ participants: value.participants.map(hostingParticipantToProto),
81
+ partySigningKeys: signingKeysWithThresholdToProto(value.partySigningKeys),
82
+ };
83
+ }
84
+ function hostingParticipantToProto(value) {
85
+ return {
86
+ participantUid: value.participantUid,
87
+ permission: participantPermissionToProto(value.permission),
88
+ onboarding: value.onboarding === undefined ? undefined : {},
89
+ };
90
+ }
91
+ function signingKeysWithThresholdToProto(value) {
92
+ if (value === undefined) {
93
+ return undefined;
94
+ }
95
+ return {
96
+ threshold: value.threshold,
97
+ keys: value.keys.map(signingPublicKeyToProto),
98
+ };
99
+ }
100
+ // The wire format carries no fingerprint (reads recompute it) and the deprecated scheme is never emitted.
101
+ function signingPublicKeyToProto(value) {
102
+ return {
103
+ format: cryptoKeyFormatToProto(value.format),
104
+ publicKey: new Uint8Array(value.publicKey),
105
+ scheme: crypto_js_1.SigningKeyScheme.UNSPECIFIED,
106
+ usage: value.usage.map(signingKeyUsageToProto),
107
+ keySpec: signingKeySpecToProto(value.keySpec),
108
+ };
109
+ }
110
+ function participantPermissionToProto(value) {
111
+ switch (value) {
112
+ case participant_permission_js_1.ParticipantPermission.submission:
113
+ return topology_js_1.Enums_ParticipantPermission.SUBMISSION;
114
+ case participant_permission_js_1.ParticipantPermission.confirmation:
115
+ return topology_js_1.Enums_ParticipantPermission.CONFIRMATION;
116
+ case participant_permission_js_1.ParticipantPermission.observation:
117
+ return topology_js_1.Enums_ParticipantPermission.OBSERVATION;
118
+ case participant_permission_js_1.ParticipantPermission.unspecified:
119
+ default:
120
+ return topology_js_1.Enums_ParticipantPermission.UNSPECIFIED;
121
+ }
122
+ }
123
+ function cryptoKeyFormatToProto(value) {
124
+ switch (value) {
125
+ case "der":
126
+ return crypto_js_1.CryptoKeyFormat.DER;
127
+ case "raw":
128
+ return crypto_js_1.CryptoKeyFormat.RAW;
129
+ case "derX509SubjectPublicKeyInfo":
130
+ return crypto_js_1.CryptoKeyFormat.DER_X509_SUBJECT_PUBLIC_KEY_INFO;
131
+ case "derPkcs8PrivateKeyInfo":
132
+ return crypto_js_1.CryptoKeyFormat.DER_PKCS8_PRIVATE_KEY_INFO;
133
+ case "symbolic":
134
+ return crypto_js_1.CryptoKeyFormat.SYMBOLIC;
135
+ default:
136
+ return crypto_js_1.CryptoKeyFormat.UNSPECIFIED;
137
+ }
138
+ }
139
+ function signingKeyUsageToProto(value) {
140
+ switch (value) {
141
+ case "namespace":
142
+ return crypto_js_1.SigningKeyUsage.NAMESPACE;
143
+ case "identityDelegation":
144
+ return crypto_js_1.SigningKeyUsage.IDENTITY_DELEGATION;
145
+ case "sequencerAuthentication":
146
+ return crypto_js_1.SigningKeyUsage.SEQUENCER_AUTHENTICATION;
147
+ case "protocol":
148
+ return crypto_js_1.SigningKeyUsage.PROTOCOL;
149
+ case "proofOfOwnership":
150
+ return crypto_js_1.SigningKeyUsage.PROOF_OF_OWNERSHIP;
151
+ default:
152
+ return crypto_js_1.SigningKeyUsage.UNSPECIFIED;
153
+ }
154
+ }
155
+ function signingKeySpecToProto(value) {
156
+ switch (value) {
157
+ case "ecCurve25519":
158
+ return crypto_js_1.SigningKeySpec.EC_CURVE25519;
159
+ case "ecP256":
160
+ return crypto_js_1.SigningKeySpec.EC_P256;
161
+ case "ecP384":
162
+ return crypto_js_1.SigningKeySpec.EC_P384;
163
+ case "ecSecp256k1":
164
+ return crypto_js_1.SigningKeySpec.EC_SECP256K1;
165
+ case "mlDsa65":
166
+ return crypto_js_1.SigningKeySpec.ML_DSA_65;
167
+ default:
168
+ return crypto_js_1.SigningKeySpec.UNSPECIFIED;
169
+ }
170
+ }
@@ -1,2 +1,3 @@
1
1
  export { GrpcLedgerClient } from "../transports/grpc/grpc-ledger-client.js";
2
2
  export { GrpcTransport } from "../transports/grpc/grpc-transport.js";
3
+ export { ListPartyToKeyMappingResponseCodec, ListPartyToParticipantResponseCodec } from "../transports/grpc/mappers/topology-response-codec.js";
@@ -1,2 +1,3 @@
1
1
  export { GrpcLedgerClient } from "../transports/grpc/grpc-ledger-client.js";
2
2
  export { GrpcTransport } from "../transports/grpc/grpc-transport.js";
3
+ export { ListPartyToKeyMappingResponseCodec, ListPartyToParticipantResponseCodec } from "../transports/grpc/mappers/topology-response-codec.js";
@@ -0,0 +1,19 @@
1
+ import { ListPartyToKeyMappingResponse } from "../../../core/types/responses/list-party-to-key-mapping-response.js";
2
+ import { ListPartyToParticipantResponse } from "../../../core/types/responses/list-party-to-participant-response.js";
3
+ import { ListPartyToKeyMappingResponse as GrpcListPartyToKeyMappingResponse, ListPartyToParticipantResponse as GrpcListPartyToParticipantResponse } from "../generated/canton/com/digitalasset/canton/topology/admin/v30/topology_manager_read_service.js";
4
+ /** Converts ListPartyToKeyMappingResponse between raw topology-read protobuf and the normalized SDK shape. */
5
+ export declare class ListPartyToKeyMappingResponseCodec {
6
+ private constructor();
7
+ static fromProto(payload: Partial<GrpcListPartyToKeyMappingResponse>): ListPartyToKeyMappingResponse;
8
+ static toProto(response: ListPartyToKeyMappingResponse): GrpcListPartyToKeyMappingResponse;
9
+ static fromBinary(bytes: Uint8Array): ListPartyToKeyMappingResponse;
10
+ static toBinary(response: ListPartyToKeyMappingResponse): Uint8Array;
11
+ }
12
+ /** Converts ListPartyToParticipantResponse between raw topology-read protobuf and the normalized SDK shape. */
13
+ export declare class ListPartyToParticipantResponseCodec {
14
+ private constructor();
15
+ static fromProto(payload: Partial<GrpcListPartyToParticipantResponse>): ListPartyToParticipantResponse;
16
+ static toProto(response: ListPartyToParticipantResponse): GrpcListPartyToParticipantResponse;
17
+ static fromBinary(bytes: Uint8Array): ListPartyToParticipantResponse;
18
+ static toBinary(response: ListPartyToParticipantResponse): Uint8Array;
19
+ }
@@ -0,0 +1,165 @@
1
+ import { ParticipantPermission } from "../../../core/types/topology/participant-permission.js";
2
+ import { CryptoKeyFormat, SigningKeyScheme, SigningKeySpec, SigningKeyUsage, } from "../generated/canton/com/digitalasset/canton/crypto/v30/crypto.js";
3
+ import { Enums_ParticipantPermission, } from "../generated/canton/com/digitalasset/canton/protocol/v30/topology.js";
4
+ import { ListPartyToKeyMappingResponse as GrpcListPartyToKeyMappingResponse, ListPartyToParticipantResponse as GrpcListPartyToParticipantResponse, } from "../generated/canton/com/digitalasset/canton/topology/admin/v30/topology_manager_read_service.js";
5
+ import { mapGrpcTimestamp, mapGrpcTopologyChangeOp, mapGrpcTopologyStoreId, } from "./topology-common-mapper.js";
6
+ import { mapGrpcListPartyToKeyMappingResponse, mapGrpcListPartyToParticipantResponse, } from "./topology-manager-read-mapper.js";
7
+ /** Converts ListPartyToKeyMappingResponse between raw topology-read protobuf and the normalized SDK shape. */
8
+ export class ListPartyToKeyMappingResponseCodec {
9
+ constructor() { }
10
+ static fromProto(payload) {
11
+ return mapGrpcListPartyToKeyMappingResponse(payload);
12
+ }
13
+ static toProto(response) {
14
+ return {
15
+ results: response.results.map((result) => ({
16
+ context: baseResultToProto(result.context),
17
+ item: partyToKeyMappingToProto(result.item),
18
+ })),
19
+ };
20
+ }
21
+ static fromBinary(bytes) {
22
+ return ListPartyToKeyMappingResponseCodec.fromProto(GrpcListPartyToKeyMappingResponse.fromBinary(bytes));
23
+ }
24
+ static toBinary(response) {
25
+ return GrpcListPartyToKeyMappingResponse.toBinary(ListPartyToKeyMappingResponseCodec.toProto(response));
26
+ }
27
+ }
28
+ /** Converts ListPartyToParticipantResponse between raw topology-read protobuf and the normalized SDK shape. */
29
+ export class ListPartyToParticipantResponseCodec {
30
+ constructor() { }
31
+ static fromProto(payload) {
32
+ return mapGrpcListPartyToParticipantResponse(payload);
33
+ }
34
+ static toProto(response) {
35
+ return {
36
+ results: response.results.map((result) => ({
37
+ context: baseResultToProto(result.context),
38
+ item: partyToParticipantToProto(result.item),
39
+ })),
40
+ };
41
+ }
42
+ static fromBinary(bytes) {
43
+ return ListPartyToParticipantResponseCodec.fromProto(GrpcListPartyToParticipantResponse.fromBinary(bytes));
44
+ }
45
+ static toBinary(response) {
46
+ return GrpcListPartyToParticipantResponse.toBinary(ListPartyToParticipantResponseCodec.toProto(response));
47
+ }
48
+ }
49
+ function baseResultToProto(value) {
50
+ if (value === undefined) {
51
+ return undefined;
52
+ }
53
+ return {
54
+ store: mapGrpcTopologyStoreId(value.storeId),
55
+ sequenced: mapGrpcTimestamp(value.sequencedAt),
56
+ validFrom: mapGrpcTimestamp(value.validFrom),
57
+ validUntil: mapGrpcTimestamp(value.validUntil),
58
+ operation: mapGrpcTopologyChangeOp(value.operation),
59
+ transactionHash: new Uint8Array(value.transactionHash),
60
+ serial: value.serial,
61
+ signedByFingerprints: [...value.signedByFingerprints],
62
+ };
63
+ }
64
+ function partyToKeyMappingToProto(value) {
65
+ return {
66
+ party: value.party,
67
+ threshold: value.threshold,
68
+ signingKeys: value.signingKeys.map(signingPublicKeyToProto),
69
+ };
70
+ }
71
+ function partyToParticipantToProto(value) {
72
+ return {
73
+ party: value.party,
74
+ threshold: value.threshold,
75
+ participants: value.participants.map(hostingParticipantToProto),
76
+ partySigningKeys: signingKeysWithThresholdToProto(value.partySigningKeys),
77
+ };
78
+ }
79
+ function hostingParticipantToProto(value) {
80
+ return {
81
+ participantUid: value.participantUid,
82
+ permission: participantPermissionToProto(value.permission),
83
+ onboarding: value.onboarding === undefined ? undefined : {},
84
+ };
85
+ }
86
+ function signingKeysWithThresholdToProto(value) {
87
+ if (value === undefined) {
88
+ return undefined;
89
+ }
90
+ return {
91
+ threshold: value.threshold,
92
+ keys: value.keys.map(signingPublicKeyToProto),
93
+ };
94
+ }
95
+ // The wire format carries no fingerprint (reads recompute it) and the deprecated scheme is never emitted.
96
+ function signingPublicKeyToProto(value) {
97
+ return {
98
+ format: cryptoKeyFormatToProto(value.format),
99
+ publicKey: new Uint8Array(value.publicKey),
100
+ scheme: SigningKeyScheme.UNSPECIFIED,
101
+ usage: value.usage.map(signingKeyUsageToProto),
102
+ keySpec: signingKeySpecToProto(value.keySpec),
103
+ };
104
+ }
105
+ function participantPermissionToProto(value) {
106
+ switch (value) {
107
+ case ParticipantPermission.submission:
108
+ return Enums_ParticipantPermission.SUBMISSION;
109
+ case ParticipantPermission.confirmation:
110
+ return Enums_ParticipantPermission.CONFIRMATION;
111
+ case ParticipantPermission.observation:
112
+ return Enums_ParticipantPermission.OBSERVATION;
113
+ case ParticipantPermission.unspecified:
114
+ default:
115
+ return Enums_ParticipantPermission.UNSPECIFIED;
116
+ }
117
+ }
118
+ function cryptoKeyFormatToProto(value) {
119
+ switch (value) {
120
+ case "der":
121
+ return CryptoKeyFormat.DER;
122
+ case "raw":
123
+ return CryptoKeyFormat.RAW;
124
+ case "derX509SubjectPublicKeyInfo":
125
+ return CryptoKeyFormat.DER_X509_SUBJECT_PUBLIC_KEY_INFO;
126
+ case "derPkcs8PrivateKeyInfo":
127
+ return CryptoKeyFormat.DER_PKCS8_PRIVATE_KEY_INFO;
128
+ case "symbolic":
129
+ return CryptoKeyFormat.SYMBOLIC;
130
+ default:
131
+ return CryptoKeyFormat.UNSPECIFIED;
132
+ }
133
+ }
134
+ function signingKeyUsageToProto(value) {
135
+ switch (value) {
136
+ case "namespace":
137
+ return SigningKeyUsage.NAMESPACE;
138
+ case "identityDelegation":
139
+ return SigningKeyUsage.IDENTITY_DELEGATION;
140
+ case "sequencerAuthentication":
141
+ return SigningKeyUsage.SEQUENCER_AUTHENTICATION;
142
+ case "protocol":
143
+ return SigningKeyUsage.PROTOCOL;
144
+ case "proofOfOwnership":
145
+ return SigningKeyUsage.PROOF_OF_OWNERSHIP;
146
+ default:
147
+ return SigningKeyUsage.UNSPECIFIED;
148
+ }
149
+ }
150
+ function signingKeySpecToProto(value) {
151
+ switch (value) {
152
+ case "ecCurve25519":
153
+ return SigningKeySpec.EC_CURVE25519;
154
+ case "ecP256":
155
+ return SigningKeySpec.EC_P256;
156
+ case "ecP384":
157
+ return SigningKeySpec.EC_P384;
158
+ case "ecSecp256k1":
159
+ return SigningKeySpec.EC_SECP256K1;
160
+ case "mlDsa65":
161
+ return SigningKeySpec.ML_DSA_65;
162
+ default:
163
+ return SigningKeySpec.UNSPECIFIED;
164
+ }
165
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distrohelena/canton-typescript-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",