@fairmint/canton-node-sdk 0.0.296 → 0.0.298

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 (41) hide show
  1. package/README.md +44 -2
  2. package/build/src/clients/ledger-json-api/index.d.ts +2 -2
  3. package/build/src/clients/ledger-json-api/index.d.ts.map +1 -1
  4. package/build/src/clients/ledger-json-api/index.js +5 -1
  5. package/build/src/clients/ledger-json-api/index.js.map +1 -1
  6. package/build/src/external-parties/directory.d.ts +96 -0
  7. package/build/src/external-parties/directory.d.ts.map +1 -0
  8. package/build/src/external-parties/directory.js +238 -0
  9. package/build/src/external-parties/directory.js.map +1 -0
  10. package/build/src/external-parties/discovery.d.ts +72 -0
  11. package/build/src/external-parties/discovery.d.ts.map +1 -0
  12. package/build/src/external-parties/discovery.js +160 -0
  13. package/build/src/external-parties/discovery.js.map +1 -0
  14. package/build/src/external-parties/errors.d.ts +28 -0
  15. package/build/src/external-parties/errors.d.ts.map +1 -0
  16. package/build/src/external-parties/errors.js +33 -0
  17. package/build/src/external-parties/errors.js.map +1 -0
  18. package/build/src/external-parties/hints.d.ts +42 -0
  19. package/build/src/external-parties/hints.d.ts.map +1 -0
  20. package/build/src/external-parties/hints.js +83 -0
  21. package/build/src/external-parties/hints.js.map +1 -0
  22. package/build/src/external-parties/index.d.ts +20 -0
  23. package/build/src/external-parties/index.d.ts.map +1 -0
  24. package/build/src/external-parties/index.js +43 -0
  25. package/build/src/external-parties/index.js.map +1 -0
  26. package/build/src/external-parties/keys.d.ts +34 -0
  27. package/build/src/external-parties/keys.d.ts.map +1 -0
  28. package/build/src/external-parties/keys.js +209 -0
  29. package/build/src/external-parties/keys.js.map +1 -0
  30. package/build/src/index.d.ts +1 -0
  31. package/build/src/index.d.ts.map +1 -1
  32. package/build/src/index.js +2 -1
  33. package/build/src/index.js.map +1 -1
  34. package/build/src/utils/external-signing/canton-protocol.d.ts.map +1 -1
  35. package/build/src/utils/external-signing/canton-protocol.js +11 -14
  36. package/build/src/utils/external-signing/canton-protocol.js.map +1 -1
  37. package/build/src/wallets/index.d.ts +2 -3
  38. package/build/src/wallets/index.d.ts.map +1 -1
  39. package/build/src/wallets/index.js +2 -3
  40. package/build/src/wallets/index.js.map +1 -1
  41. package/package.json +16 -88
package/README.md CHANGED
@@ -69,14 +69,56 @@ same way; it requires an explicit `userId` and a non-empty `parties` list, as th
69
69
  See
70
70
  [`examples/read-any-party.ts`](https://github.com/Fairmint/canton-node-sdk/blob/main/examples/read-any-party.ts).
71
71
 
72
+ ## Finding every party a key controls
73
+
74
+ An external party's ID is `hint::fingerprint`, where the fingerprint is Canton's SHA-256 multihash
75
+ of the Ed25519 key: `1220` + hex(sha256(int32be(12) || rawKey)). Nothing about it depends on the
76
+ signer, so one module serves any wallet. It is browser-safe: import
77
+ `@fairmint/canton-node-sdk/external-parties` (it loads `@noble/hashes` and none of the SDK's Node
78
+ dependencies); the package root also exports it as the `ExternalParties` namespace.
79
+
80
+ ```typescript
81
+ import {
82
+ createExternalPartyDirectory,
83
+ suggestExternalPartyHint,
84
+ validateExternalPartyHint,
85
+ } from '@fairmint/canton-node-sdk/external-parties';
86
+
87
+ // One directory per participant: one scan of its party store answers every key for 30 s.
88
+ const directory = createExternalPartyDirectory({ ledgerClient }); // a LedgerJsonApiClient
89
+ const { parties, complete } = await directory.listPartiesForKey({
90
+ publicKeyBase64, // raw or DER Ed25519 key; or pass publicKeyFingerprint
91
+ hints: ['wallet'], // looked up exactly when the scan does not show them
92
+ signal,
93
+ });
94
+ // parties: [{ partyId, partyHint, hostedHere }], sorted by hint
95
+ const hint = suggestExternalPartyHint({ base: 'My app', taken: parties.map((p) => p.partyHint) });
96
+ validateExternalPartyHint(hint); // null, or 'empty' | 'too-long' | 'charset' | 'taken'
97
+ ```
98
+
99
+ The participant API has no namespace filter, so a scan reads `GET /v2/parties` page by page and
100
+ keeps the parties ending in `::fingerprint`. Each scan is bounded (`pageSize` 1000, `maxPages` 10,
101
+ `timeoutMs` 10 s, a stalled page included) and cached for every key (`cacheMs` 30 s; concurrent
102
+ callers share one scan). When a bound stops it first the answer is `complete: false`, and the hints
103
+ asked for are still looked up with `GET /v2/parties/{party}` (also when the scan is complete, since
104
+ a cached scan can predate a newer party). `noteAllocated(partyId)` lists a party you just allocated
105
+ at once; `findParty({ partyId })` is the exact lookup on its own. `discoverExternalParties` is the
106
+ same list-plus-lookups logic over your own `listParties` / `findParty` callbacks. Errors are
107
+ `ExternalPartyError` with a `code` (`INVALID_INPUT`, `INVALID_RESPONSE`, `ABORTED`, `LIST_FAILED`,
108
+ `LOOKUP_FAILED`); a ledger failure is its `cause`.
109
+
110
+ The same module has the identity helpers: `deriveCantonEd25519PublicKeyFingerprint`,
111
+ `buildExternalPartyId`, `parseExternalPartyId`, `readPartyNamespace`,
112
+ `normalizeEd25519PublicKeyForCanton` and `decodeEd25519PublicKey`. The Node helpers of the same
113
+ names under the package root (which throw `ValidationError`) derive the fingerprint through it.
114
+
72
115
  ## Token actions through a CIP-0103 wallet
73
116
 
74
117
  `Wallets` runs Digital Asset Utility Registry holder actions through any CIP-0103 (Canton dApp API)
75
118
  wallet provider, on one DA network (`devnet` or `mainnet`). It talks to the wallet only through
76
119
  CIP-0103 and to DA's public Utilities API through `fetch`, so no wallet SDK is involved. It is
77
120
  browser-safe: import `@fairmint/canton-node-sdk/wallets`, which loads none of the SDK's Node
78
- dependencies (the older deep path `@fairmint/canton-node-sdk/build/src/wallets/index.js` still
79
- works). The package root also exports it as the `Wallets` namespace.
121
+ dependencies. The package root also exports it as the `Wallets` namespace.
80
122
 
81
123
  - `discoverCip103Wallets()`: the CIP-0103 wallets installed in the browser as extensions, as
82
124
  `{ id, name, icon?, load(network) }`; `load` resolves the wallet's provider for a network. It runs
@@ -5,11 +5,11 @@ export type { GetActiveContractsParams } from './operations/v2/state/get-active-
5
5
  export type { ActiveContractsStream, StreamActiveContractsParams } from './operations/v2/state/stream-active-contracts';
6
6
  export type { RawCompletionFrame, RawCompletionKind, SubscribeToRawCompletionsParams, } from './operations/v2/commands/subscribe-to-raw-completions';
7
7
  export { GetUpdatesPageParamsSchema, decodeRawUpdatesPage, type GetUpdatesPageParams, type GetUpdatesPageRequest, type GetUpdatesPageResponse, type RawPageUpdate, type RawUpdatesPage, } from './operations/v2/updates/get-updates-page';
8
- export type { RawUpdateFrame, RawUpdateKind, SubscribeToRawUpdatesParams, } from './operations/v2/updates/subscribe-to-raw-updates';
8
+ export { SubscribeToRawUpdates, type RawUpdateFrame, type RawUpdateKind, type SubscribeToRawUpdatesParams, } from './operations/v2/updates/subscribe-to-raw-updates';
9
9
  export { TransactionShape } from './operations/v2/updates/subscribe-to-updates';
10
10
  export { buildEventFormat, buildTransactionFormat, buildUpdateFormat, type AnyPartyEventFormatBuilderParams, type AnyPartyScope, type AnyPartyTransactionFormatBuilderParams, type AnyPartyUpdateFormatBuilderParams, type BuiltEventFormat, type EventFilterOptions, type EventFormatBuilderParams, type PartiesScope, type PartyScope, type TransactionFormatBuilderParams, type UpdateFormatBuilderParams, } from './operations/v2/utils/event-format-builder';
11
11
  export { isAnyPartyScope } from './operations/v2/utils/party-scope';
12
12
  export { RAW_STREAM_HIGH_WATER_MARK, RawStreamError, type RawFrame, type RawFrameKind, type RawStreamEnd, type RawStreamEndReason, type RawStreamErrorReason, type RawStreamOutOfOrderOffsets, type RawStreamSubscription, } from './operations/v2/utils/raw-frame-stream';
13
- export { GetContractByIdRequestSchema, GetContractByIdResponseSchema, LedgerContractIdSchema, LedgerContractKeyHashSchema, LedgerCreatedEventSchema, LedgerInterfaceIdSchema, LedgerJsonValueSchema, LedgerPackageIdSchema, LedgerPackageNameSchema, LedgerPartyIdSchema, LedgerSynchronizerIdSchema, LedgerTemplateIdSchema, NonEmptyDarFileSchema, UploadDarParamsSchema, UploadDarResponseSchema, ValidateDarParamsSchema, ValidateDarResponseSchema, } from './schemas';
13
+ export { CommandSchema, DisclosedContractSchema, GetContractByIdRequestSchema, GetContractByIdResponseSchema, LedgerContractIdSchema, LedgerContractKeyHashSchema, LedgerCreatedEventSchema, LedgerInterfaceIdSchema, LedgerJsonValueSchema, LedgerPackageIdSchema, LedgerPackageNameSchema, LedgerPartyIdSchema, LedgerSynchronizerIdSchema, LedgerTemplateIdSchema, NonEmptyDarFileSchema, UploadDarParamsSchema, UploadDarResponseSchema, ValidateDarParamsSchema, ValidateDarResponseSchema, } from './schemas';
14
14
  export type { AssignCommand, Command, CommandRequest, CompositeCommand, CreateAndExerciseCommand, CreateCommand, DisclosedContract, ExerciseByKeyCommand, ExerciseCommand, GetContractByIdCreatedEvent, GetContractByIdParams, GetContractByIdRequest, GetContractByIdResponse, JsCommands, JsGetActiveContractsResponse, JsGetActiveContractsResponseItem, LedgerCreatedEvent, LedgerInterfaceView, LedgerJsonValue, LedgerNonNullJsonValue, LedgerProtoAny, LedgerStatus, TraceContext, UnassignCommand, UploadDarParams, UploadDarResponse, ValidateDarParams, ValidateDarResponse, } from './schemas';
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/clients/ledger-json-api/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,YAAY,EACV,iCAAiC,EACjC,mCAAmC,GACpC,MAAM,0DAA0D,CAAC;AAClE,YAAY,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAC3F,YAAY,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AACxH,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,+BAA+B,GAChC,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,0CAA0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B,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/clients/ledger-json-api/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,YAAY,EACV,iCAAiC,EACjC,mCAAmC,GACpC,MAAM,0DAA0D,CAAC;AAClE,YAAY,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAC3F,YAAY,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AACxH,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,+BAA+B,GAChC,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,2BAA2B,GACjC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,gCAAgC,EACrC,KAAK,aAAa,EAClB,KAAK,sCAAsC,EAC3C,KAAK,iCAAiC,EACtC,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,GAC/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,GAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,4BAA4B,EAC5B,6BAA6B,EAC7B,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,aAAa,EACb,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAC"}
@@ -14,13 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ValidateDarResponseSchema = exports.ValidateDarParamsSchema = exports.UploadDarResponseSchema = exports.UploadDarParamsSchema = exports.NonEmptyDarFileSchema = exports.LedgerTemplateIdSchema = exports.LedgerSynchronizerIdSchema = exports.LedgerPartyIdSchema = exports.LedgerPackageNameSchema = exports.LedgerPackageIdSchema = exports.LedgerJsonValueSchema = exports.LedgerInterfaceIdSchema = exports.LedgerCreatedEventSchema = exports.LedgerContractKeyHashSchema = exports.LedgerContractIdSchema = exports.GetContractByIdResponseSchema = exports.GetContractByIdRequestSchema = exports.RawStreamError = exports.RAW_STREAM_HIGH_WATER_MARK = exports.isAnyPartyScope = exports.buildUpdateFormat = exports.buildTransactionFormat = exports.buildEventFormat = exports.TransactionShape = exports.decodeRawUpdatesPage = exports.GetUpdatesPageParamsSchema = exports.LedgerJsonApiClient = void 0;
17
+ exports.ValidateDarResponseSchema = exports.ValidateDarParamsSchema = exports.UploadDarResponseSchema = exports.UploadDarParamsSchema = exports.NonEmptyDarFileSchema = exports.LedgerTemplateIdSchema = exports.LedgerSynchronizerIdSchema = exports.LedgerPartyIdSchema = exports.LedgerPackageNameSchema = exports.LedgerPackageIdSchema = exports.LedgerJsonValueSchema = exports.LedgerInterfaceIdSchema = exports.LedgerCreatedEventSchema = exports.LedgerContractKeyHashSchema = exports.LedgerContractIdSchema = exports.GetContractByIdResponseSchema = exports.GetContractByIdRequestSchema = exports.DisclosedContractSchema = exports.CommandSchema = exports.RawStreamError = exports.RAW_STREAM_HIGH_WATER_MARK = exports.isAnyPartyScope = exports.buildUpdateFormat = exports.buildTransactionFormat = exports.buildEventFormat = exports.TransactionShape = exports.SubscribeToRawUpdates = exports.decodeRawUpdatesPage = exports.GetUpdatesPageParamsSchema = exports.LedgerJsonApiClient = void 0;
18
18
  __exportStar(require("./completion-stream"), exports);
19
19
  var LedgerJsonApiClient_generated_1 = require("./LedgerJsonApiClient.generated");
20
20
  Object.defineProperty(exports, "LedgerJsonApiClient", { enumerable: true, get: function () { return LedgerJsonApiClient_generated_1.LedgerJsonApiClient; } });
21
21
  var get_updates_page_1 = require("./operations/v2/updates/get-updates-page");
22
22
  Object.defineProperty(exports, "GetUpdatesPageParamsSchema", { enumerable: true, get: function () { return get_updates_page_1.GetUpdatesPageParamsSchema; } });
23
23
  Object.defineProperty(exports, "decodeRawUpdatesPage", { enumerable: true, get: function () { return get_updates_page_1.decodeRawUpdatesPage; } });
24
+ var subscribe_to_raw_updates_1 = require("./operations/v2/updates/subscribe-to-raw-updates");
25
+ Object.defineProperty(exports, "SubscribeToRawUpdates", { enumerable: true, get: function () { return subscribe_to_raw_updates_1.SubscribeToRawUpdates; } });
24
26
  var subscribe_to_updates_1 = require("./operations/v2/updates/subscribe-to-updates");
25
27
  Object.defineProperty(exports, "TransactionShape", { enumerable: true, get: function () { return subscribe_to_updates_1.TransactionShape; } });
26
28
  var event_format_builder_1 = require("./operations/v2/utils/event-format-builder");
@@ -33,6 +35,8 @@ var raw_frame_stream_1 = require("./operations/v2/utils/raw-frame-stream");
33
35
  Object.defineProperty(exports, "RAW_STREAM_HIGH_WATER_MARK", { enumerable: true, get: function () { return raw_frame_stream_1.RAW_STREAM_HIGH_WATER_MARK; } });
34
36
  Object.defineProperty(exports, "RawStreamError", { enumerable: true, get: function () { return raw_frame_stream_1.RawStreamError; } });
35
37
  var schemas_1 = require("./schemas");
38
+ Object.defineProperty(exports, "CommandSchema", { enumerable: true, get: function () { return schemas_1.CommandSchema; } });
39
+ Object.defineProperty(exports, "DisclosedContractSchema", { enumerable: true, get: function () { return schemas_1.DisclosedContractSchema; } });
36
40
  Object.defineProperty(exports, "GetContractByIdRequestSchema", { enumerable: true, get: function () { return schemas_1.GetContractByIdRequestSchema; } });
37
41
  Object.defineProperty(exports, "GetContractByIdResponseSchema", { enumerable: true, get: function () { return schemas_1.GetContractByIdResponseSchema; } });
38
42
  Object.defineProperty(exports, "LedgerContractIdSchema", { enumerable: true, get: function () { return schemas_1.LedgerContractIdSchema; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/clients/ledger-json-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,i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,sBAAsB,OAAA;AACtB,yHAAA,iBAAiB,OAAA;AAanB,iEAAoE;AAA3D,8GAAA,eAAe,OAAA;AACxB,2EAUgD;AAT9C,8HAAA,0BAA0B,OAAA;AAC1B,kHAAA,cAAc,OAAA;AAShB,qCAoBmB;AAnBjB,wGAAA,aAAa,OAAA;AACb,kHAAA,uBAAuB,OAAA;AACvB,uHAAA,4BAA4B,OAAA;AAC5B,wHAAA,6BAA6B,OAAA;AAC7B,iHAAA,sBAAsB,OAAA;AACtB,sHAAA,2BAA2B,OAAA;AAC3B,mHAAA,wBAAwB,OAAA;AACxB,kHAAA,uBAAuB,OAAA;AACvB,gHAAA,qBAAqB,OAAA;AACrB,gHAAA,qBAAqB,OAAA;AACrB,kHAAA,uBAAuB,OAAA;AACvB,8GAAA,mBAAmB,OAAA;AACnB,qHAAA,0BAA0B,OAAA;AAC1B,iHAAA,sBAAsB,OAAA;AACtB,gHAAA,qBAAqB,OAAA;AACrB,gHAAA,qBAAqB,OAAA;AACrB,kHAAA,uBAAuB,OAAA;AACvB,kHAAA,uBAAuB,OAAA;AACvB,oHAAA,yBAAyB,OAAA"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Every party a key controls on one participant, over the Ledger JSON API: a bounded, cached read of `GET /v2/parties`
3
+ * filtered to the key's namespace, plus exact `GET /v2/parties/{party}` lookups of the hints the read may not show.
4
+ * Browser-safe: it takes the ledger client by its shape (node-sdk's `LedgerJsonApiClient` fits), and loads nothing
5
+ * else.
6
+ */
7
+ import { type ExternalPartyListing } from './discovery';
8
+ /** The request options the directory passes to the ledger client. */
9
+ export interface ExternalPartyDirectoryRequestConfig {
10
+ readonly contentType?: 'application/json';
11
+ readonly includeBearerToken?: boolean;
12
+ }
13
+ /**
14
+ * The part of node-sdk's `LedgerJsonApiClient` the directory uses: its base URL and its authenticated JSON GET, which
15
+ * throws an error carrying the participant's HTTP `status` (node-sdk's `ApiError`) on a failure.
16
+ */
17
+ export interface ExternalPartyDirectoryLedgerClient {
18
+ getApiUrl(): string;
19
+ makeGetRequest<T>(url: string, config?: ExternalPartyDirectoryRequestConfig,
20
+ /** `signal` aborts the request (an older client may ignore it). */
21
+ options?: {
22
+ readonly signal?: AbortSignal;
23
+ }): Promise<T>;
24
+ }
25
+ export interface ExternalPartyDirectoryOptions {
26
+ readonly ledgerClient: ExternalPartyDirectoryLedgerClient;
27
+ /** The identity provider parties are read under. Defaults to "" (the participant's default). */
28
+ readonly identityProviderId?: string;
29
+ /** Parties per `GET /v2/parties` page. Defaults to 1000; 1 to 10000. */
30
+ readonly pageSize?: number;
31
+ /** Pages one scan reads at most. Defaults to 10; 1 to 1000. */
32
+ readonly maxPages?: number;
33
+ /** How long one scan may take, in milliseconds, a stalled page included. Defaults to 10 seconds; 100 to 120000. */
34
+ readonly timeoutMs?: number;
35
+ /** How long one scan answers for every key, in milliseconds. Defaults to 30 seconds; 0 (no cache) to 600000. */
36
+ readonly cacheMs?: number;
37
+ /** The clock, for tests. Defaults to `Date.now`. */
38
+ readonly now?: () => number;
39
+ }
40
+ /**
41
+ * The key whose parties are asked for: its public key (raw or DER, base64), or its Canton fingerprint. With both, they
42
+ * must match.
43
+ */
44
+ export type ExternalPartyKey = {
45
+ readonly publicKeyBase64: string;
46
+ readonly publicKeyFingerprint?: string;
47
+ } | {
48
+ readonly publicKeyFingerprint: string;
49
+ readonly publicKeyBase64?: undefined;
50
+ };
51
+ /** What {@link ExternalPartyDirectory.findParty} answers. */
52
+ export type ExternalPartyFound = {
53
+ readonly exists: false;
54
+ } | {
55
+ readonly exists: true;
56
+ readonly hostedHere: boolean;
57
+ };
58
+ export interface ExternalPartyDirectory {
59
+ /**
60
+ * Every party of the key: the scan's parties in the key's namespace and the parties {@link noteAllocated} recorded,
61
+ * plus an exact {@link findParty} of each of `hints` (at most 16) they do not show, sorted by hint. `complete` is the
62
+ * scan's: false when a page or time bound stopped it first. With a complete scan a failed lookup is skipped; with an
63
+ * incomplete one it fails the call. `signal` stops this caller's wait, not the shared scan.
64
+ *
65
+ * Throws {@link ExternalPartyError}: `INVALID_INPUT`, `ABORTED`, `INVALID_RESPONSE`, `LIST_FAILED` (the scan's request
66
+ * failed: the ledger client's error is `cause`) or `LOOKUP_FAILED`.
67
+ */
68
+ listPartiesForKey(request: ExternalPartyKey & {
69
+ readonly hints?: readonly string[];
70
+ readonly signal?: AbortSignal;
71
+ }): Promise<ExternalPartyListing>;
72
+ /**
73
+ * One party by ID (`GET /v2/parties/{party}`): 404 or an answer that does not list it is not found; else it exists,
74
+ * and `hostedHere` is its `isLocal`. The ledger client's errors pass through; an unreadable answer is
75
+ * `INVALID_RESPONSE`.
76
+ */
77
+ findParty(request: {
78
+ readonly partyId: string;
79
+ readonly signal?: AbortSignal;
80
+ }): Promise<ExternalPartyFound>;
81
+ /**
82
+ * Records a party allocated (or confirmed to exist) on this participant, so {@link listPartiesForKey} lists it as
83
+ * hosted here at once, even from a scan read before it. Kept for one cache window plus one scan timeout.
84
+ */
85
+ noteAllocated(partyId: string): void;
86
+ }
87
+ /**
88
+ * A directory of the external parties on one participant. The participant API has no namespace filter, so a scan reads
89
+ * the participant's whole party store: one scan serves every key and caller for `cacheMs` (concurrent calls share one
90
+ * scan), and parties recorded with `noteAllocated` are added to it at once. Each scan is bounded: at most `maxPages`
91
+ * pages of `pageSize` and `timeoutMs` overall, a stalled page included (its request is aborted at the deadline); when a
92
+ * bound stops it first, the listing is `complete: false` with what was read. At the defaults one scan is at most 10
93
+ * requests of 1000 parties.
94
+ */
95
+ export declare function createExternalPartyDirectory(options: ExternalPartyDirectoryOptions): ExternalPartyDirectory;
96
+ //# sourceMappingURL=directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../../src/external-parties/directory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAML,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AAIrB,qEAAqE;AACrE,MAAM,WAAW,mCAAmC;IAClD,QAAQ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,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;OAQG;IACH,iBAAiB,CACf,OAAO,EAAE,gBAAgB,GAAG;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAChG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC7G;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAcD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,6BAA6B,GAAG,sBAAsB,CAiL3G"}
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createExternalPartyDirectory = createExternalPartyDirectory;
4
+ /**
5
+ * Every party a key controls on one participant, over the Ledger JSON API: a bounded, cached read of `GET /v2/parties`
6
+ * filtered to the key's namespace, plus exact `GET /v2/parties/{party}` lookups of the hints the read may not show.
7
+ * Browser-safe: it takes the ledger client by its shape (node-sdk's `LedgerJsonApiClient` fits), and loads nothing
8
+ * else.
9
+ */
10
+ const discovery_1 = require("./discovery");
11
+ const errors_1 = require("./errors");
12
+ const keys_1 = require("./keys");
13
+ const CONFIG = Object.freeze({
14
+ contentType: 'application/json',
15
+ includeBearerToken: true,
16
+ });
17
+ /**
18
+ * A directory of the external parties on one participant. The participant API has no namespace filter, so a scan reads
19
+ * the participant's whole party store: one scan serves every key and caller for `cacheMs` (concurrent calls share one
20
+ * scan), and parties recorded with `noteAllocated` are added to it at once. Each scan is bounded: at most `maxPages`
21
+ * pages of `pageSize` and `timeoutMs` overall, a stalled page included (its request is aborted at the deadline); when a
22
+ * bound stops it first, the listing is `complete: false` with what was read. At the defaults one scan is at most 10
23
+ * requests of 1000 parties.
24
+ */
25
+ function createExternalPartyDirectory(options) {
26
+ const { ledgerClient } = options;
27
+ // Checked as untyped input: a JavaScript caller may pass anything.
28
+ const shape = ledgerClient;
29
+ if (!isRecord(shape) || typeof shape['getApiUrl'] !== 'function' || typeof shape['makeGetRequest'] !== 'function') {
30
+ throw (0, errors_1.invalidInput)("ledgerClient must be @fairmint/canton-node-sdk's LedgerJsonApiClient.");
31
+ }
32
+ const identityProviderId = options.identityProviderId ?? '';
33
+ if (typeof identityProviderId !== 'string')
34
+ throw (0, errors_1.invalidInput)('identityProviderId must be a string.');
35
+ const pageSize = bounded(options.pageSize, 1000, 1, 10000, 'pageSize');
36
+ const maxPages = bounded(options.maxPages, 10, 1, 1000, 'maxPages');
37
+ const timeoutMs = bounded(options.timeoutMs, 10000, 100, 120000, 'timeoutMs');
38
+ const cacheMs = bounded(options.cacheMs, 30000, 0, 600000, 'cacheMs');
39
+ const now = options.now ?? Date.now;
40
+ const url = (path) => `${ledgerClient.getApiUrl()}${path}`;
41
+ const invalidResponse = (message, partyId) => new errors_1.ExternalPartyError('INVALID_RESPONSE', message, partyId === undefined ? {} : { partyId });
42
+ let cachedScan;
43
+ let scanInFlight;
44
+ /** Parties recorded here, by ID, with when: a scan that started earlier may not hold them. */
45
+ const allocatedHere = new Map();
46
+ /** Entries older than any scan that could still answer: a scan read after them holds those parties. */
47
+ const allocationHorizon = () => now() - cacheMs - timeoutMs;
48
+ async function scanParties() {
49
+ const startedAt = now();
50
+ const deadline = startedAt + timeoutMs;
51
+ const byNamespace = new Map();
52
+ const controller = new AbortController();
53
+ let expire = () => undefined;
54
+ const expired = new Promise((resolve) => {
55
+ expire = () => resolve('expired');
56
+ });
57
+ const timer = setTimeout(() => {
58
+ expire();
59
+ controller.abort();
60
+ }, timeoutMs);
61
+ const finish = (complete) => ({ startedAt, byNamespace, complete });
62
+ try {
63
+ let pageToken = '';
64
+ for (let page = 0; page < maxPages; page += 1) {
65
+ if (page > 0 && now() >= deadline)
66
+ break;
67
+ const query = new URLSearchParams({ pageSize: String(pageSize) });
68
+ if (pageToken !== '')
69
+ query.set('pageToken', pageToken);
70
+ if (identityProviderId.length > 0)
71
+ query.set('identity-provider-id', identityProviderId);
72
+ const request = ledgerClient.makeGetRequest(url(`/v2/parties?${query.toString()}`), CONFIG, {
73
+ signal: controller.signal,
74
+ });
75
+ // Read below when it wins; once the deadline wins, its (abort) failure is not ours to report.
76
+ request.catch(() => undefined);
77
+ const response = await Promise.race([request, expired]);
78
+ if (response === 'expired')
79
+ break;
80
+ const record = isRecord(response) ? response : undefined;
81
+ const details = Array.isArray(record?.['partyDetails']) ? record['partyDetails'] : null;
82
+ const next = record?.['nextPageToken'];
83
+ if (details === null || (next !== undefined && typeof next !== 'string')) {
84
+ throw invalidResponse('The participant returned an invalid party list.');
85
+ }
86
+ for (const detail of details) {
87
+ if (!isRecord(detail))
88
+ continue;
89
+ const { party } = detail;
90
+ // `hint::namespace` only: one separator, a non-empty hint and namespace.
91
+ // And one a listing may answer (at most 255 characters, trimmed, one line), so one odd party in the store
92
+ // never fails every key's listing.
93
+ const parsed = (0, keys_1.parseExternalPartyId)(party);
94
+ if (parsed === null || !(0, discovery_1.isBoundedIdentifier)(party))
95
+ continue;
96
+ let parties = byNamespace.get(parsed.namespace);
97
+ if (parties === undefined) {
98
+ parties = new Map();
99
+ byNamespace.set(parsed.namespace, parties);
100
+ }
101
+ parties.set(party, (parties.get(party) ?? false) || detail['isLocal'] === true);
102
+ }
103
+ if (next === undefined || next === '')
104
+ return finish(true);
105
+ if (next === pageToken)
106
+ break;
107
+ pageToken = next;
108
+ }
109
+ return finish(false);
110
+ }
111
+ finally {
112
+ clearTimeout(timer);
113
+ }
114
+ }
115
+ /** The cached scan while it is fresh, else the scan in flight, else a new one. */
116
+ async function currentScan() {
117
+ if (cachedScan !== undefined && now() - cachedScan.startedAt < cacheMs)
118
+ return Promise.resolve(cachedScan);
119
+ if (scanInFlight === undefined) {
120
+ const scan = scanParties().then((result) => {
121
+ if (cacheMs > 0)
122
+ cachedScan = result;
123
+ return result;
124
+ });
125
+ scanInFlight = scan;
126
+ const clear = () => {
127
+ if (scanInFlight === scan)
128
+ scanInFlight = undefined;
129
+ };
130
+ scan.then(clear, clear);
131
+ }
132
+ return scanInFlight;
133
+ }
134
+ /** The key's parties from the current scan and the recorded allocations, without lookups. */
135
+ async function scannedParties(publicKeyFingerprint, signal) {
136
+ const scan = await (0, discovery_1.raceAbort)(currentScan, signal, 'The party listing was aborted.');
137
+ const parties = new Map(scan.byNamespace.get(publicKeyFingerprint) ?? []);
138
+ const suffix = `::${publicKeyFingerprint}`;
139
+ const horizon = allocationHorizon();
140
+ for (const [partyId, at] of allocatedHere) {
141
+ if (at < horizon) {
142
+ allocatedHere.delete(partyId);
143
+ }
144
+ else if (partyId.endsWith(suffix)) {
145
+ // Allocated here, so hosted here, whether or not this scan (or its pages) reached it yet.
146
+ parties.set(partyId, true);
147
+ }
148
+ }
149
+ return { parties: (0, discovery_1.sortedEntries)(parties), complete: scan.complete };
150
+ }
151
+ const directory = {
152
+ async listPartiesForKey(request) {
153
+ const publicKeyFingerprint = keyFingerprint(request);
154
+ const { signal } = request;
155
+ return (0, discovery_1.discoverExternalParties)({
156
+ publicKeyFingerprint,
157
+ ...(request.hints === undefined ? {} : { hints: request.hints }),
158
+ ...(signal === undefined ? {} : { signal }),
159
+ listParties: async () => scannedParties(publicKeyFingerprint, signal),
160
+ findParty: async ({ partyId }) => directory.findParty(signal === undefined ? { partyId } : { partyId, signal }),
161
+ }).then(({ parties, complete }) => Object.freeze({ parties, complete }));
162
+ },
163
+ async findParty(request) {
164
+ const { partyId, signal } = request;
165
+ if (typeof partyId !== 'string' || partyId.trim() === '')
166
+ throw (0, errors_1.invalidInput)('partyId is required.');
167
+ let response;
168
+ try {
169
+ // Same identity provider as the scan, as node-sdk's GetPartyDetails sends it.
170
+ const query = identityProviderId.length > 0
171
+ ? `?${new URLSearchParams({ 'identity-provider-id': identityProviderId }).toString()}`
172
+ : '';
173
+ response = await ledgerClient.makeGetRequest(url(`/v2/parties/${encodeURIComponent(partyId)}${query}`), CONFIG, ...(signal === undefined ? [] : [{ signal }]));
174
+ }
175
+ catch (error) {
176
+ if (readStatus(error) === 404)
177
+ return { exists: false };
178
+ throw error;
179
+ }
180
+ const record = isRecord(response) ? response : undefined;
181
+ const details = Array.isArray(record?.['partyDetails']) ? record['partyDetails'] : null;
182
+ if (details === null)
183
+ throw invalidResponse('The participant returned invalid party details.', partyId);
184
+ const entry = details.find((detail) => isRecord(detail) && detail['party'] === partyId);
185
+ if (!isRecord(entry))
186
+ return { exists: false };
187
+ return { exists: true, hostedHere: entry['isLocal'] === true };
188
+ },
189
+ noteAllocated(partyId) {
190
+ // Only an ID a listing may answer: one it refuses would fail every listing of its key until it expired.
191
+ if ((0, keys_1.parseExternalPartyId)(partyId) === null || !(0, discovery_1.isBoundedIdentifier)(partyId)) {
192
+ throw (0, errors_1.invalidInput)('partyId must be a hint::namespace party ID of at most 255 characters, trimmed, on one line.');
193
+ }
194
+ // Drops expired entries as it records one, so the map holds one cache window, not the process lifetime.
195
+ const horizon = allocationHorizon();
196
+ for (const [id, at] of allocatedHere) {
197
+ if (at < horizon)
198
+ allocatedHere.delete(id);
199
+ }
200
+ allocatedHere.set(partyId, now());
201
+ },
202
+ };
203
+ return Object.freeze(directory);
204
+ }
205
+ function keyFingerprint(key) {
206
+ if (typeof key.publicKeyBase64 === 'string') {
207
+ const fingerprint = (0, keys_1.deriveCantonEd25519PublicKeyFingerprint)(key.publicKeyBase64);
208
+ if (key.publicKeyFingerprint !== undefined && key.publicKeyFingerprint !== fingerprint) {
209
+ throw (0, errors_1.invalidInput)('publicKeyFingerprint does not match publicKeyBase64.');
210
+ }
211
+ return fingerprint;
212
+ }
213
+ if ((0, keys_1.isCantonPublicKeyFingerprint)(key.publicKeyFingerprint))
214
+ return key.publicKeyFingerprint;
215
+ throw (0, errors_1.invalidInput)('Pass publicKeyBase64 or a Canton publicKeyFingerprint.');
216
+ }
217
+ function bounded(value, fallback, min, max, label) {
218
+ const resolved = value ?? fallback;
219
+ if (!Number.isSafeInteger(resolved) || resolved < min || resolved > max) {
220
+ throw (0, errors_1.invalidInput)(`${label} must be an integer from ${min} to ${max}.`);
221
+ }
222
+ return resolved;
223
+ }
224
+ /** The HTTP status on an error or (for wrappers) its `cause`, at most three levels down. */
225
+ function readStatus(error) {
226
+ let next = error;
227
+ for (let depth = 0; depth <= 3 && isRecord(next); depth += 1) {
228
+ const status = next['status'] ?? next['statusCode'];
229
+ if (typeof status === 'number')
230
+ return status;
231
+ next = next['cause'];
232
+ }
233
+ return undefined;
234
+ }
235
+ function isRecord(value) {
236
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
237
+ }
238
+ //# sourceMappingURL=directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory.js","sourceRoot":"","sources":["../../../src/external-parties/directory.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,2CAOqB;AACrB,qCAA4D;AAC5D,iCAAqH;AA2ErH,MAAM,MAAM,GAAwC,MAAM,CAAC,MAAM,CAAC;IAChE,WAAW,EAAE,kBAAkB;IAC/B,kBAAkB,EAAE,IAAI;CACzB,CAAC,CAAC;AASH;;;;;;;GAOG;AACH,sCAA6C,OAAsC;IACjF,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACjC,mEAAmE;IACnE,MAAM,KAAK,GAAY,YAAY,CAAC;IACpC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,WAAW,CAAC,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,gBAAgB,CAAC,KAAK,UAAU,EAAE,CAA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CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,GAAG,IAAI,QAAQ,GAAG,GAAG,EAAE,CAAC;QACxE,MAAM,IAAA,qBAAY,EAAC,GAAG,KAAK,4BAA4B,GAAG,OAAO,GAAG,GAAG,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,4FAA4F;AAC5F,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,IAAI,GAAY,KAAK,CAAC;IAC1B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QACpD,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC;QAC9C,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,72 @@
1
+ /** One of a key's parties. */
2
+ export interface ExternalPartyEntry {
3
+ readonly partyId: string;
4
+ /** What precedes `::` in the party ID. */
5
+ readonly partyHint: string;
6
+ /** Whether this participant hosts the party (it can prepare and submit for it here). */
7
+ readonly hostedHere: boolean;
8
+ }
9
+ /** A key's parties, sorted by hint, and whether the party list they came from was read to its end. */
10
+ export interface ExternalPartyListing {
11
+ readonly parties: readonly ExternalPartyEntry[];
12
+ /**
13
+ * False when the list was cut short (a page or time bound, or no list at all): a party the list and the exact lookups
14
+ * did not show may still exist.
15
+ */
16
+ readonly complete: boolean;
17
+ }
18
+ /** {@link discoverExternalParties}' answer. */
19
+ export interface ExternalPartyDiscovery extends ExternalPartyListing {
20
+ /**
21
+ * False when hints were asked for, the list was not complete and there was no `findParty` to look them up: a hint
22
+ * outside `parties` may then be taken. True otherwise.
23
+ */
24
+ readonly hintsChecked: boolean;
25
+ }
26
+ /** What a party list answers: party IDs (any namespace; only the key's are kept) and whether it was read to its end. */
27
+ export interface ExternalPartyListAnswer {
28
+ readonly parties: ReadonlyArray<{
29
+ readonly partyId: string;
30
+ readonly hostedHere: boolean;
31
+ }>;
32
+ readonly complete: boolean;
33
+ }
34
+ /** What an exact party lookup answers. `hostedHere` omitted counts as hosted. */
35
+ export interface ExternalPartyLookupAnswer {
36
+ readonly exists: boolean;
37
+ readonly hostedHere?: boolean;
38
+ }
39
+ /** The most hints {@link discoverExternalParties} looks up in one call. */
40
+ export declare const MAX_EXTERNAL_PARTY_LOOKUP_HINTS = 16;
41
+ /**
42
+ * A key's parties: what `listParties` answers in the key's namespace, plus an exact `findParty` of each of `hints` the
43
+ * list did not show. The lookups run even when the list says complete (a cached list can predate a party allocated
44
+ * since); with a complete list a failed lookup is skipped, with an incomplete one it fails the call (`LOOKUP_FAILED`).
45
+ * Either callback may be left out: without `listParties` the answer is never complete; without `findParty` the hints
46
+ * are not checked (`hintsChecked: false` when the list is incomplete).
47
+ *
48
+ * `signal` goes to each callback and each call is raced against it, so a callback that ignores it does not hold the
49
+ * call open (`ABORTED`). A callback's failure is `LIST_FAILED` or `LOOKUP_FAILED` with its error as `cause` (an
50
+ * {@link ExternalPartyError} `ABORTED` or `INVALID_RESPONSE` it throws passes through as it is), and an unreadable
51
+ * answer is `INVALID_RESPONSE`. Nothing is recorded or allocated.
52
+ */
53
+ export declare function discoverExternalParties(input: {
54
+ readonly publicKeyFingerprint: string;
55
+ /** Hints to look up exactly (each non-empty, trimmed, without `::`); duplicates are looked up once. */
56
+ readonly hints?: readonly string[];
57
+ readonly signal?: AbortSignal;
58
+ readonly listParties?: (request: {
59
+ readonly signal?: AbortSignal;
60
+ }) => Promise<ExternalPartyListAnswer>;
61
+ readonly findParty?: (request: {
62
+ readonly partyId: string;
63
+ readonly signal?: AbortSignal;
64
+ }) => Promise<ExternalPartyLookupAnswer>;
65
+ }): Promise<ExternalPartyDiscovery>;
66
+ /** `parties` (party ID → hosted here) as frozen entries, sorted by hint (then party ID), in code-unit order. */
67
+ export declare function sortedEntries(parties: ReadonlyMap<string, boolean>): readonly ExternalPartyEntry[];
68
+ /** Awaits `start()`, unless `signal` aborts first (`ABORTED`); an already-aborted signal never starts it. */
69
+ export declare function raceAbort<T>(start: () => Promise<T>, signal: AbortSignal | undefined, message: string, partyId?: string): Promise<T>;
70
+ /** A string of 1 to 255 characters (a Daml-LF Party at most), trimmed, on one line: what a listing may answer. */
71
+ export declare function isBoundedIdentifier(value: unknown): value is string;
72
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/external-parties/discovery.ts"],"names":[],"mappings":"AAaA,8BAA8B;AAC9B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED,sGAAsG;AACtG,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,+CAA+C;AAC/C,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,wHAAwH;AACxH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAAE,QAAQ,CAA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