@layerzerolabs/common-canton 0.2.111 → 0.2.112

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.
@@ -9,7 +9,7 @@
9
9
  ✅ dpm-3.4.8-openapi-generator-7.21.0
10
10
  🔧 openapi-generator version: 7.21.0
11
11
  $ docker image inspect --format {{.Architecture}} 438003944538.dkr.ecr.us-east-1.amazonaws.com/layerzerolabs/canton-openapi-tooling:openapi-generator-7.21.0-patch-2
12
- (node:83734) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/configs/vm-tooling/values/docker-image-repo.ts is not specified and it doesn't parse as CommonJS.
12
+ (node:83754) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/configs/vm-tooling/values/docker-image-repo.ts is not specified and it doesn't parse as CommonJS.
13
13
  Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
14
14
  To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
15
15
  (Use `node --trace-warnings ...` to show where the warning was created)
@@ -24,8 +24,8 @@ dfe8d6e6f390: Pulling fs layer
24
24
  e41c3f01e557: Pulling fs layer
25
25
  fe131d3b296c: Pulling fs layer
26
26
  dfe8d6e6f390: Waiting
27
- e41c3f01e557: Waiting
28
27
  fe131d3b296c: Waiting
28
+ e41c3f01e557: Waiting
29
29
  18a60288e8be: Verifying Checksum
30
30
  18a60288e8be: Download complete
31
31
  17639c486e57: Verifying Checksum
@@ -34,9 +34,9 @@ e41c3f01e557: Verifying Checksum
34
34
  e41c3f01e557: Download complete
35
35
  dfe8d6e6f390: Verifying Checksum
36
36
  dfe8d6e6f390: Download complete
37
+ 17639c486e57: Pull complete
37
38
  fe131d3b296c: Verifying Checksum
38
39
  fe131d3b296c: Download complete
39
- 17639c486e57: Pull complete
40
40
  051d551be118: Verifying Checksum
41
41
  051d551be118: Download complete
42
42
  051d551be118: Pull complete
@@ -729,24 +729,24 @@ $ docker run --rm --add-host=host.docker.internal:host-gateway -e LOCAL_UID=1001
729
729
  # We appreciate your support! Please consider donation to help us maintain this project. #
730
730
  # https://opencollective.com/openapi_generator/donate #
731
731
  ############################################################################################
732
- ⏳ bash -c set -euo pipefail && rm -rf "src/open-api" && canton-openapi-generator generate -g typescript-fetch -o "src/open-api" --additional-properties=importFileExtension=.js: 4.844s
732
+ ⏳ bash -c set -euo pipefail && rm -rf "src/open-api" && canton-openapi-generator generate -g typescript-fetch -o "src/open-api" --additional-properties=importFileExtension=.js: 3.741s
733
733
  Testing types with tsc and vue-tsc is an experimental feature.
734
734
  Breaking changes might not follow SemVer, please pin Vitest's version when using it.
735
735
 
736
736
   RUN  v3.2.6 /home/runner/work/monorepo-internal/monorepo-internal/packages/vms/canton/common
737
737
 
738
- ✓ test/provider.test.ts (7 tests) 40ms
739
- ✓ test/auth/local-token-provider.test.ts (5 tests) 14ms
740
- ✓ test/auth/client-credentials-token-provider.test.ts (7 tests) 17ms
741
- ✓ test/crypto.test.ts (6 tests) 22ms
742
- ✓ test/daml-serde.test.ts (19 tests) 41ms
738
+ ✓ test/auth/local-token-provider.test.ts (5 tests) 11ms
739
+ ✓ test/auth/client-credentials-token-provider.test.ts (7 tests) 12ms
740
+ ✓ test/provider.test.ts (7 tests) 46ms
741
+ ✓ test/crypto.test.ts (6 tests) 5ms
742
+ ✓ test/daml-serde.test.ts (19 tests) 9ms
743
743
  stderr | test/sdk.test.ts > Error Handling (Unhappy Paths) > should handle double archive error
744
744
  Mock miss: GET /v2/state/connected-synchronizers
745
745
 
746
746
  stderr | test/sdk.test.ts > Error Handling (Unhappy Paths) > should handle unauthorized party error
747
747
  Mock miss: GET /v2/state/connected-synchronizers
748
748
 
749
- ✓ test/sdk.test.ts (18 tests) 38ms
749
+ ✓ test/sdk.test.ts (18 tests) 28ms
750
750
  ✓  TS  test/sdk.test.ts (18 tests)
751
751
  ✓  TS  test/auth/client-credentials-token-provider.test.ts (7 tests)
752
752
  ✓  TS  test/daml-serde.test.ts (19 tests)
@@ -757,6 +757,6 @@ Breaking changes might not follow SemVer, please pin Vitest's version when using
757
757
   Test Files  12 passed (12)
758
758
   Tests  124 passed (124)
759
759
  Type Errors  no errors
760
-  Start at  21:23:50
761
-  Duration  5.22s (transform 1.61s, setup 0ms, collect 2.86s, tests 174ms, environment 1ms, prepare 1.24s, typecheck 4.73s)
760
+  Start at  02:26:48
761
+  Duration  3.07s (transform 1.08s, setup 0ms, collect 1.73s, tests 112ms, environment 1ms, prepare 858ms, typecheck 2.75s)
762
762
 
@@ -13,6 +13,8 @@ function parseCantonChainUri(uri) {
13
13
  throw new Error('Canton provider URI missing required "admin-api" query parameter');
14
14
  }
15
15
  const userId = url.searchParams.get("user-id") ?? "participant_admin";
16
+ const actAsParam = url.searchParams.get("act-as");
17
+ const actAs = actAsParam?.split(",").map((party) => party.trim()).filter((party) => party.length > 0) ?? [];
16
18
  const walletUrl = url.searchParams.get("wallet-url");
17
19
  if (!walletUrl) {
18
20
  throw new Error('Canton provider URI missing required "wallet-url" query parameter');
@@ -25,6 +27,7 @@ function parseCantonChainUri(uri) {
25
27
  for (const key of [
26
28
  "admin-api",
27
29
  "user-id",
30
+ "act-as",
28
31
  "wallet-url",
29
32
  "sequencer-url",
30
33
  "sequencer-validators",
@@ -49,6 +52,7 @@ function parseCantonChainUri(uri) {
49
52
  jsonApiUrl,
50
53
  adminApiHost,
51
54
  userId,
55
+ actAs,
52
56
  walletUrl,
53
57
  oauth2
54
58
  };
@@ -90,5 +94,5 @@ function createTokenProvider(params, isLocal) {
90
94
  __name(createTokenProvider, "createTokenProvider");
91
95
 
92
96
  export { createCantonChainProvider, parseCantonChainUri };
93
- //# sourceMappingURL=GOPXFEBJ.js.map
94
- //# sourceMappingURL=GOPXFEBJ.js.map
97
+ //# sourceMappingURL=4CJTJBWF.js.map
98
+ //# sourceMappingURL=4CJTJBWF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/provider.ts"],"names":["parseCantonChainUri","uri","url","URL","adminApiHost","searchParams","get","Error","userId","actAsParam","actAs","split","map","party","trim","filter","length","walletUrl","tokenUrl","undefined","clientId","clientSecret","scope","audience","key","delete","jsonApiUrl","toString","replace","oauth2","createCantonChainProvider","isLocal","params","tokenProvider","createTokenProvider","configuration","Configuration","basePath","accessToken","getToken","client","CantonClient","grpcClient","CantonGrpcClient","host","LocalTokenProvider","admin","ClientCredentialsTokenProvider"],"mappings":";;;;;;;;AA0DO,SAASA,oBAAoBC,GAAAA,EAAW;AAC3C,EAAA,MAAMC,GAAAA,GAAM,IAAIC,GAAAA,CAAIF,GAAAA,CAAAA;AAEpB,EAAA,MAAMG,YAAAA,GAAeF,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,WAAA,CAAA;AAC1C,EAAA,IAAI,CAACF,YAAAA,EAAc;AACf,IAAA,MAAM,IAAIG,MAAM,kEAAA,CAAA;AACpB,EAAA;AAEA,EAAA,MAAMC,MAAAA,GAASN,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,SAAA,CAAA,IAAc,mBAAA;AAClD,EAAA,MAAMG,UAAAA,GAAaP,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,QAAA,CAAA;AACxC,EAAA,MAAMI,QACFD,UAAAA,EACME,KAAAA,CAAM,GAAA,CAAA,CACPC,GAAAA,CAAI,CAACC,KAAAA,KAAUA,KAAAA,CAAMC,MAAI,CAAA,CACzBC,OAAO,CAACF,KAAAA,KAAUA,MAAMG,MAAAA,GAAS,CAAA,KAAM,EAAA;AAChD,EAAA,MAAMC,SAAAA,GAAYf,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,YAAA,CAAA;AACvC,EAAA,IAAI,CAACW,SAAAA,EAAW;AACZ,IAAA,MAAM,IAAIV,MAAM,mEAAA,CAAA;AACpB,EAAA;AACA,EAAA,MAAMW,QAAAA,GAAWhB,GAAAA,CAAIG,YA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AItB,MACN,uGAAA,CAAA;AAER,EAAA;AAEA,EAAA,OAAO,IAAIwC,8BAAAA,CAA+Bf,MAAAA,CAAOH,MAAM,CAAA;AAC3D;AAjBSK,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"4CJTJBWF.js","sourcesContent":["import {\n ClientCredentialsTokenProvider,\n type ClientCredentialsTokenProviderConfig,\n} from './auth/client-credentials-token-provider';\nimport { LocalTokenProvider } from './auth/local-token-provider';\nimport type { TokenProvider } from './auth/token-provider';\nimport { CantonClient } from './client/canton-client';\nimport { CantonGrpcClient } from './client/grpc';\nimport type { ICantonClient } from './client/interface';\nimport { Configuration } from './open-api/runtime';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Type\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * - {@link client} — JSON Ledger API (commands, queries, updates)\n * - {@link grpcClient} — gRPC Admin API (topology transactions, namespace queries)\n * - {@link tokenProvider} — Shared Bearer-token source used by both transports\n * - {@link walletUrl} — Canton Network validator wallet (scan-proxy CIP-56 endpoints)\n */\nexport type CantonChainProvider = {\n client: ICantonClient;\n grpcClient: CantonGrpcClient;\n tokenProvider: TokenProvider;\n /** Validator wallet URL for scan-proxy CIP-56 endpoints. Required. */\n walletUrl: string;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// URI Parsing\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CantonChainUriParams = {\n /** Base URL of the JSON Ledger API (e.g. \"http://localhost:5975\") */\n jsonApiUrl: string;\n /** Host:port of the gRPC Admin API (e.g. \"localhost:5076\") */\n adminApiHost: string;\n /** Ledger API user ID (default: \"participant_admin\") */\n userId: string;\n /** Parties granted `actAs` on localnet tokens (comma-separated in the URI). */\n actAs: string[];\n /** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. \"http://localhost:7201\"). Required. */\n walletUrl: string;\n /** OAuth2 client credentials config — present only for non-local environments */\n oauth2?: ClientCredentialsTokenProviderConfig;\n};\n\n/**\n * Parse a Canton chain provider URI into its constituent parts.\n *\n * URI format:\n * `<json-api-base>?admin-api=<host:port>&user-id=<id>&wallet-url=<url>[&token-url=...&client-id=...&client-secret=...&scope=...&audience=...]`\n *\n * The base URL (everything before the query string) is the JSON Ledger API endpoint.\n * Canton-specific params are extracted and removed; any remaining query params are\n * preserved on the JSON API URL.\n */\nexport function parseCantonChainUri(uri: string): CantonChainUriParams {\n const url = new URL(uri);\n\n const adminApiHost = url.searchParams.get('admin-api');\n if (!adminApiHost) {\n throw new Error('Canton provider URI missing required \"admin-api\" query parameter');\n }\n\n const userId = url.searchParams.get('user-id') ?? 'participant_admin';\n const actAsParam = url.searchParams.get('act-as');\n const actAs =\n actAsParam\n ?.split(',')\n .map((party) => party.trim())\n .filter((party) => party.length > 0) ?? [];\n const walletUrl = url.searchParams.get('wallet-url');\n if (!walletUrl) {\n throw new Error('Canton provider URI missing required \"wallet-url\" query parameter');\n }\n const tokenUrl = url.searchParams.get('token-url') ?? undefined;\n const clientId = url.searchParams.get('client-id') ?? undefined;\n const clientSecret = url.searchParams.get('client-secret') ?? undefined;\n const scope = url.searchParams.get('scope') ?? undefined;\n const audience = url.searchParams.get('audience') ?? undefined;\n\n for (const key of [\n 'admin-api',\n 'user-id',\n 'act-as',\n 'wallet-url',\n 'sequencer-url',\n 'sequencer-validators',\n 'sequencer-quorum',\n 'token-url',\n 'client-id',\n 'client-secret',\n 'scope',\n 'audience',\n ]) {\n url.searchParams.delete(key);\n }\n\n const jsonApiUrl = url.toString().replace(/\\/$/, '');\n\n const oauth2 =\n tokenUrl && clientId && clientSecret\n ? { tokenUrl, clientId, clientSecret, scope, audience }\n : undefined;\n\n return {\n jsonApiUrl,\n adminApiHost,\n userId,\n actAs,\n walletUrl,\n oauth2,\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Factory\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CreateCantonChainProviderOptions = {\n /** Raw provider URI (from provider config) */\n uri: string;\n /** When true, uses LocalTokenProvider (self-signed JWTs) instead of OAuth2 */\n isLocal: boolean;\n};\n\n/**\n * Create a {@link CantonChainProvider} from a provider URI.\n *\n * - **isLocal=true**: Uses {@link LocalTokenProvider} with admin-level access (self-signed JWTs).\n * - **isLocal=false**: Uses {@link ClientCredentialsTokenProvider} with OAuth2 client\n * credentials extracted from the URI query parameters.\n */\nexport function createCantonChainProvider({\n uri,\n isLocal,\n}: CreateCantonChainProviderOptions): CantonChainProvider {\n const params = parseCantonChainUri(uri);\n\n const tokenProvider = createTokenProvider(params, isLocal);\n\n // ── JSON Ledger API Client ──────────────────────────────────────────\n const configuration = new Configuration({\n basePath: params.jsonApiUrl,\n accessToken: () => tokenProvider.getToken(),\n });\n const client = new CantonClient(configuration, params.userId);\n\n // ── gRPC Admin API Client ───────────────────────────────────────────\n const grpcClient = new CantonGrpcClient({\n host: params.adminApiHost,\n tokenProvider,\n });\n\n return {\n client,\n grpcClient,\n tokenProvider,\n walletUrl: params.walletUrl,\n };\n}\n\nfunction createTokenProvider(params: CantonChainUriParams, isLocal: boolean): TokenProvider {\n if (isLocal) {\n return new LocalTokenProvider({\n userId: params.userId,\n actAs: [],\n admin: true,\n });\n }\n\n // TODO(canton): add other prod auth methods (direct JWT passthrough, etc.).\n if (!params.oauth2) {\n throw new Error(\n 'Canton provider requires OAuth2 credentials (token-url, client-id, client-secret) in the provider URI',\n );\n }\n\n return new ClientCredentialsTokenProvider(params.oauth2);\n}\n"]}
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ export { IntLikeSchema, assertHexLength, codePointLength, formatDamlDecimal, int
12
12
  export { cantonActiveContractIdRef, cantonActiveContractIdsRef, cantonAmuletContextRef, cantonAmuletRulesCidRef, cantonDeferredValueSchema, cantonRefreshPartyFilterSchema, cantonSenderPartyRef, encodeCantonDeferredValue, isCantonPlaceholder, parseCantonDeferredValue } from './5PRNJEPB.js';
13
13
  export { cantonDeploymentSucceeded, fetchCreatedEvents, findMatchingCreatedEvent, findMatchingCreatedEventFromTx, getExercisedEvent, waitForArchival } from './FPRRDKT5.js';
14
14
  export { buildCantonTransaction, cantonAssignedTransactionSchema, cantonCommandSchema, cantonDisclosedContractSchema, cantonMinedTransactionSchema, cantonSignedTransactionSchema, cantonTransactionSchema, cantonTransactionWithResultSchema } from './EYLCZMM4.js';
15
- export { createCantonChainProvider, parseCantonChainUri } from './GOPXFEBJ.js';
15
+ export { createCantonChainProvider, parseCantonChainUri } from './4CJTJBWF.js';
16
16
  export { ClientCredentialsTokenProvider } from './V2H2WXKE.js';
17
17
  export { LocalTokenProvider } from './SCEF7TLZ.js';
18
18
  export { CantonClient } from './SMLSAWCA.js';
@@ -22,6 +22,8 @@ export type CantonChainUriParams = {
22
22
  adminApiHost: string;
23
23
  /** Ledger API user ID (default: "participant_admin") */
24
24
  userId: string;
25
+ /** Parties granted `actAs` on localnet tokens (comma-separated in the URI). */
26
+ actAs: string[];
25
27
  /** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. "http://localhost:7201"). Required. */
26
28
  walletUrl: string;
27
29
  /** OAuth2 client credentials config — present only for non-local environments */
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,oCAAoC,EAC5C,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOxD;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,aAAa,EAAE,aAAa,CAAC;IAC7B,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAMF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,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,CAAC;IACf,+EAA+E;IAC/E,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,qGAAqG;IACrG,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,MAAM,CAAC,EAAE,oCAAoC,CAAC;CACjD,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAyDrE;AAMD,MAAM,MAAM,gCAAgC,GAAG;IAC3C,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,EACtC,GAAG,EACH,OAAO,GACV,EAAE,gCAAgC,GAAG,mBAAmB,CAwBxD"}
package/dist/provider.js CHANGED
@@ -1,4 +1,4 @@
1
- export { createCantonChainProvider, parseCantonChainUri } from './GOPXFEBJ.js';
1
+ export { createCantonChainProvider, parseCantonChainUri } from './4CJTJBWF.js';
2
2
  import './V2H2WXKE.js';
3
3
  import './SCEF7TLZ.js';
4
4
  import './SMLSAWCA.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/common-canton",
3
- "version": "0.2.111",
3
+ "version": "0.2.112",
4
4
  "private": false,
5
5
  "description": "Canton VM client and utilities",
6
6
  "license": "MIT",
@@ -23,10 +23,10 @@
23
23
  "@protobuf-ts/grpc-transport": "^2.9.4",
24
24
  "es-toolkit": "^1.39.10",
25
25
  "zod": "4.3.5",
26
- "@layerzerolabs/common-chain-model": "0.2.111",
27
- "@layerzerolabs/common-error-utils": "0.2.111",
28
- "@layerzerolabs/common-encoding-utils": "0.2.111",
29
- "@layerzerolabs/typescript-utils": "0.2.111"
26
+ "@layerzerolabs/common-chain-model": "0.2.112",
27
+ "@layerzerolabs/common-encoding-utils": "0.2.112",
28
+ "@layerzerolabs/typescript-utils": "0.2.112",
29
+ "@layerzerolabs/common-error-utils": "0.2.112"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.18.6",
@@ -35,12 +35,12 @@
35
35
  "tsup": "^8.4.0",
36
36
  "typescript": "^5.8.2",
37
37
  "vitest": "^3.2.6",
38
- "@layerzerolabs/eslint-configuration": "^0.2.111",
39
- "@layerzerolabs/tsup-configuration": "0.2.111",
40
- "@layerzerolabs/typescript-configuration": "0.2.111",
41
- "@layerzerolabs/ver-signer-adapter": "0.2.111",
42
- "@layerzerolabs/vitest-configuration": "0.2.111",
43
- "@layerzerolabs/vm-tooling-canton": "0.2.111"
38
+ "@layerzerolabs/eslint-configuration": "^0.2.112",
39
+ "@layerzerolabs/tsup-configuration": "0.2.112",
40
+ "@layerzerolabs/typescript-configuration": "0.2.112",
41
+ "@layerzerolabs/ver-signer-adapter": "0.2.112",
42
+ "@layerzerolabs/vitest-configuration": "0.2.112",
43
+ "@layerzerolabs/vm-tooling-canton": "0.2.112"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "restricted",
package/src/provider.ts CHANGED
@@ -38,6 +38,8 @@ export type CantonChainUriParams = {
38
38
  adminApiHost: string;
39
39
  /** Ledger API user ID (default: "participant_admin") */
40
40
  userId: string;
41
+ /** Parties granted `actAs` on localnet tokens (comma-separated in the URI). */
42
+ actAs: string[];
41
43
  /** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. "http://localhost:7201"). Required. */
42
44
  walletUrl: string;
43
45
  /** OAuth2 client credentials config — present only for non-local environments */
@@ -63,6 +65,12 @@ export function parseCantonChainUri(uri: string): CantonChainUriParams {
63
65
  }
64
66
 
65
67
  const userId = url.searchParams.get('user-id') ?? 'participant_admin';
68
+ const actAsParam = url.searchParams.get('act-as');
69
+ const actAs =
70
+ actAsParam
71
+ ?.split(',')
72
+ .map((party) => party.trim())
73
+ .filter((party) => party.length > 0) ?? [];
66
74
  const walletUrl = url.searchParams.get('wallet-url');
67
75
  if (!walletUrl) {
68
76
  throw new Error('Canton provider URI missing required "wallet-url" query parameter');
@@ -76,6 +84,7 @@ export function parseCantonChainUri(uri: string): CantonChainUriParams {
76
84
  for (const key of [
77
85
  'admin-api',
78
86
  'user-id',
87
+ 'act-as',
79
88
  'wallet-url',
80
89
  'sequencer-url',
81
90
  'sequencer-validators',
@@ -100,6 +109,7 @@ export function parseCantonChainUri(uri: string): CantonChainUriParams {
100
109
  jsonApiUrl,
101
110
  adminApiHost,
102
111
  userId,
112
+ actAs,
103
113
  walletUrl,
104
114
  oauth2,
105
115
  };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/provider.ts"],"names":["parseCantonChainUri","uri","url","URL","adminApiHost","searchParams","get","Error","userId","walletUrl","tokenUrl","undefined","clientId","clientSecret","scope","audience","key","delete","jsonApiUrl","toString","replace","oauth2","createCantonChainProvider","isLocal","params","tokenProvider","createTokenProvider","configuration","Configuration","basePath","accessToken","getToken","client","CantonClient","grpcClient","CantonGrpcClient","host","LocalTokenProvider","actAs","admin","ClientCredentialsTokenProvider"],"mappings":";;;;;;;;AAwDO,SAASA,oBAAoBC,GAAAA,EAAW;AAC3C,EAAA,MAAMC,GAAAA,GAAM,IAAIC,GAAAA,CAAIF,GAAAA,CAAAA;AAEpB,EAAA,MAAMG,YAAAA,GAAeF,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,WAAA,CAAA;AAC1C,EAAA,IAAI,CAACF,YAAAA,EAAc;AACf,IAAA,MAAM,IAAIG,MAAM,kEAAA,CAAA;AACpB,EAAA;AAEA,EAAA,MAAMC,MAAAA,GAASN,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,SAAA,CAAA,IAAc,mBAAA;AAClD,EAAA,MAAMG,SAAAA,GAAYP,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,YAAA,CAAA;AACvC,EAAA,IAAI,CAACG,SAAAA,EAAW;AACZ,IAAA,MAAM,IAAIF,MAAM,mEAAA,CAAA;AACpB,EAAA;AACA,EAAA,MAAMG,QAAAA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;AAER,EAAA;AAEA,EAAA,OAAO,IAAIiC,8BAAAA,CAA+BhB,MAAAA,CAAOH,MAAM,CAAA;AAC3D;AAjBSK,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"GOPXFEBJ.js","sourcesContent":["import {\n ClientCredentialsTokenProvider,\n type ClientCredentialsTokenProviderConfig,\n} from './auth/client-credentials-token-provider';\nimport { LocalTokenProvider } from './auth/local-token-provider';\nimport type { TokenProvider } from './auth/token-provider';\nimport { CantonClient } from './client/canton-client';\nimport { CantonGrpcClient } from './client/grpc';\nimport type { ICantonClient } from './client/interface';\nimport { Configuration } from './open-api/runtime';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Type\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * - {@link client} — JSON Ledger API (commands, queries, updates)\n * - {@link grpcClient} — gRPC Admin API (topology transactions, namespace queries)\n * - {@link tokenProvider} — Shared Bearer-token source used by both transports\n * - {@link walletUrl} — Canton Network validator wallet (scan-proxy CIP-56 endpoints)\n */\nexport type CantonChainProvider = {\n client: ICantonClient;\n grpcClient: CantonGrpcClient;\n tokenProvider: TokenProvider;\n /** Validator wallet URL for scan-proxy CIP-56 endpoints. Required. */\n walletUrl: string;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// URI Parsing\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CantonChainUriParams = {\n /** Base URL of the JSON Ledger API (e.g. \"http://localhost:5975\") */\n jsonApiUrl: string;\n /** Host:port of the gRPC Admin API (e.g. \"localhost:5076\") */\n adminApiHost: string;\n /** Ledger API user ID (default: \"participant_admin\") */\n userId: string;\n /** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. \"http://localhost:7201\"). Required. */\n walletUrl: string;\n /** OAuth2 client credentials config — present only for non-local environments */\n oauth2?: ClientCredentialsTokenProviderConfig;\n};\n\n/**\n * Parse a Canton chain provider URI into its constituent parts.\n *\n * URI format:\n * `<json-api-base>?admin-api=<host:port>&user-id=<id>&wallet-url=<url>[&token-url=...&client-id=...&client-secret=...&scope=...&audience=...]`\n *\n * The base URL (everything before the query string) is the JSON Ledger API endpoint.\n * Canton-specific params are extracted and removed; any remaining query params are\n * preserved on the JSON API URL.\n */\nexport function parseCantonChainUri(uri: string): CantonChainUriParams {\n const url = new URL(uri);\n\n const adminApiHost = url.searchParams.get('admin-api');\n if (!adminApiHost) {\n throw new Error('Canton provider URI missing required \"admin-api\" query parameter');\n }\n\n const userId = url.searchParams.get('user-id') ?? 'participant_admin';\n const walletUrl = url.searchParams.get('wallet-url');\n if (!walletUrl) {\n throw new Error('Canton provider URI missing required \"wallet-url\" query parameter');\n }\n const tokenUrl = url.searchParams.get('token-url') ?? undefined;\n const clientId = url.searchParams.get('client-id') ?? undefined;\n const clientSecret = url.searchParams.get('client-secret') ?? undefined;\n const scope = url.searchParams.get('scope') ?? undefined;\n const audience = url.searchParams.get('audience') ?? undefined;\n\n for (const key of [\n 'admin-api',\n 'user-id',\n 'wallet-url',\n 'sequencer-url',\n 'sequencer-validators',\n 'sequencer-quorum',\n 'token-url',\n 'client-id',\n 'client-secret',\n 'scope',\n 'audience',\n ]) {\n url.searchParams.delete(key);\n }\n\n const jsonApiUrl = url.toString().replace(/\\/$/, '');\n\n const oauth2 =\n tokenUrl && clientId && clientSecret\n ? { tokenUrl, clientId, clientSecret, scope, audience }\n : undefined;\n\n return {\n jsonApiUrl,\n adminApiHost,\n userId,\n walletUrl,\n oauth2,\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Factory\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CreateCantonChainProviderOptions = {\n /** Raw provider URI (from provider config) */\n uri: string;\n /** When true, uses LocalTokenProvider (self-signed JWTs) instead of OAuth2 */\n isLocal: boolean;\n};\n\n/**\n * Create a {@link CantonChainProvider} from a provider URI.\n *\n * - **isLocal=true**: Uses {@link LocalTokenProvider} with admin-level access (self-signed JWTs).\n * - **isLocal=false**: Uses {@link ClientCredentialsTokenProvider} with OAuth2 client\n * credentials extracted from the URI query parameters.\n */\nexport function createCantonChainProvider({\n uri,\n isLocal,\n}: CreateCantonChainProviderOptions): CantonChainProvider {\n const params = parseCantonChainUri(uri);\n\n const tokenProvider = createTokenProvider(params, isLocal);\n\n // ── JSON Ledger API Client ──────────────────────────────────────────\n const configuration = new Configuration({\n basePath: params.jsonApiUrl,\n accessToken: () => tokenProvider.getToken(),\n });\n const client = new CantonClient(configuration, params.userId);\n\n // ── gRPC Admin API Client ───────────────────────────────────────────\n const grpcClient = new CantonGrpcClient({\n host: params.adminApiHost,\n tokenProvider,\n });\n\n return {\n client,\n grpcClient,\n tokenProvider,\n walletUrl: params.walletUrl,\n };\n}\n\nfunction createTokenProvider(params: CantonChainUriParams, isLocal: boolean): TokenProvider {\n if (isLocal) {\n return new LocalTokenProvider({\n userId: params.userId,\n actAs: [],\n admin: true,\n });\n }\n\n // TODO(canton): add other prod auth methods (direct JWT passthrough, etc.).\n if (!params.oauth2) {\n throw new Error(\n 'Canton provider requires OAuth2 credentials (token-url, client-id, client-secret) in the provider URI',\n );\n }\n\n return new ClientCredentialsTokenProvider(params.oauth2);\n}\n"]}