gdc-sdk-node-ts 2.1.0 → 2.1.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,11 +1,7 @@
1
1
  // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
2
  // Always create JSDoc, do not use strings inline in keys nor values, use types instead, and reuse the data test examples.
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import { DIDCOMM_DEFAULT_ACCEPT_HEADER, DIDCOMM_PLAINTEXT_JSON_MEDIA_TYPE, } from 'gdc-common-utils-ts/utils/didcomm-submit';
6
- import { buildLegalOrganizationVerificationGatewayRequestBundle, buildOrganizationDidBindingBundle, buildAppHeaders, createBootstrapFacade, resolveAppInfo, } from 'gdc-sdk-core-ts';
7
- import { buildConsentClaimsSimpleWithCid } from 'gdc-common-utils-ts/utils/consent';
8
- import { buildDidcommPlaintextTransportMetadata } from 'gdc-common-utils-ts/utils/activation-request';
3
+ import { DIDCOMM_PLAINTEXT_JSON_MEDIA_TYPE, } from 'gdc-common-utils-ts/utils/didcomm-submit';
4
+ import { buildAppHeaders, createBootstrapFacade, resolveAppInfo, } from 'gdc-sdk-core-ts';
9
5
  import { pollUntilCompleteWithMethod } from './async-polling.js';
10
6
  import { confirmLegalOrganizationOrderWithDeps, HostLifecycleRequestType, HostedTenantLifecycleRequestType, submitHostedTenantLifecycleWithDeps, } from './host-onboarding.js';
11
7
  import { confirmIndividualOrganizationOrderWithDeps, } from './individual-onboarding.js';
@@ -17,7 +13,11 @@ import { confirmOrganizationLicenseOrderWithDeps } from './organization-license-
17
13
  import { startIndividualOrganizationWithDeps } from './individual-start.js';
18
14
  import { createOrganizationEmployeeWithDeps, disableIndividualMemberWithDeps, disableIndividualOrganizationWithDeps, disableOrganizationEmployeeWithDeps, listIndividualLicenseOffersWithDeps, listIndividualLicenseOrdersWithDeps, listIndividualLicensesWithDeps, listOrganizationLicenseOffersWithDeps, listOrganizationLicenseOrdersWithDeps, listOrganizationLicensesWithDeps, grantProfessionalAccessWithDeps, ingestCommunicationAndUpdateIndexWithDeps, revokeProfessionalAccessWithDeps, searchCommunicationParticipantsWithDeps, purgeIndividualMemberWithDeps, purgeIndividualOrganizationWithDeps, purgeOrganizationEmployeeWithDeps, searchIndividualLicensesWithDeps, searchIndividualLicenseOffersWithDeps, searchIndividualLicenseOrdersWithDeps, searchOrganizationLicensesWithDeps, searchOrganizationLicenseOffersWithDeps, searchOrganizationLicenseOrdersWithDeps, searchOrganizationEmployeesWithDeps, searchClinicalBundleWithDeps, searchLatestIpsWithDeps, upsertRelatedPersonAndPollWithDeps, } from './resource-operations.js';
19
15
  import { submitAndPollWithMethods } from './orchestration/client-port.js';
20
- import { GwCoreLifecycleAction } from './constants/lifecycle.js';
16
+ import { buildRuntimeHeaders, fetchWithTimeout, parseResponseBody, pollBatchResponseWithRuntimeConfig, postJsonWithRuntimeConfig, } from './runtime-transport.js';
17
+ import { activateOrganizationInGatewayFromIcaProofWithDeps, submitLegalOrganizationIssueWithDeps, submitLegalOrganizationVerificationTransactionWithDeps, submitOrganizationDidBindingWithDeps, } from './runtime-host-submission.js';
18
+ import { buildGrantProfessionalAccessClaimsWithCid } from './runtime-consent.js';
19
+ import { RuntimeClientPaths } from './runtime-client-paths.js';
20
+ import { runtimeUuid, wrapBundleAsGatewayTransactionMessage } from './runtime-message.js';
21
21
  const bootstrapFacade = createBootstrapFacade();
22
22
  /**
23
23
  * Runtime-oriented HTTP client for Node backends, BFFs, and workers that need
@@ -28,6 +28,15 @@ const bootstrapFacade = createBootstrapFacade();
28
28
  * re-exported from `gdc-sdk-core-ts`.
29
29
  */
30
30
  export class HttpRuntimeClient {
31
+ get transportConfig() {
32
+ return {
33
+ baseUrl: this.baseUrl,
34
+ bearerToken: this.bearerToken,
35
+ defaultHeaders: this.defaultHeaders,
36
+ requestTimeoutMs: this.requestTimeoutMs,
37
+ httpTraceFile: this.httpTraceFile,
38
+ };
39
+ }
31
40
  /**
32
41
  * @param options.baseUrl Gateway base URL without trailing slash.
33
42
  * @param options.interopMode Optional runtime interoperability mode from the SDK config layer (`demo`, `compat`, `strict`).
@@ -54,6 +63,7 @@ export class HttpRuntimeClient {
54
63
  };
55
64
  this.requestTimeoutMs = Math.max(1, Math.floor(options.requestTimeoutMs ?? 15000));
56
65
  this.httpTraceFile = String(process.env.SDK_HTTP_TRACE_FILE || '').trim() || undefined;
66
+ this.paths = new RuntimeClientPaths(this.ctx);
57
67
  }
58
68
  /**
59
69
  * Returns the canonical GW CORE app identity resolved by the Node client.
@@ -79,8 +89,7 @@ export class HttpRuntimeClient {
79
89
  * Builds a canonical GDC v1 resource/action path from a route context.
80
90
  */
81
91
  v1Path(ctx, section, format, resourceType, action) {
82
- const routeCtx = this.requireRouteContext(ctx);
83
- return `/${encodeURIComponent(routeCtx.tenantId)}/cds-${encodeURIComponent(routeCtx.jurisdiction)}/v1/${encodeURIComponent(routeCtx.sector)}/${encodeURIComponent(section)}/${encodeURIComponent(format)}/${encodeURIComponent(resourceType)}/${encodeURIComponent(action)}`;
92
+ return this.paths.v1Path(ctx, section, format, resourceType, action);
84
93
  }
85
94
  /**
86
95
  * Submits a batch payload to a gateway batch endpoint.
@@ -121,16 +130,16 @@ export class HttpRuntimeClient {
121
130
  * `confirmLegalOrganizationOrder(...)`
122
131
  */
123
132
  async submitLegalOrganizationVerificationTransaction(hostCtx, input, pollOptions) {
124
- const thid = `organization-verification-transaction-${runtimeUuid()}`;
125
- const jti = `organization-verification-transaction-jti-${runtimeUuid()}`;
126
- const verificationBundle = buildLegalOrganizationVerificationGatewayRequestBundle(input);
127
- const payload = this.wrapBundleAsGatewayTransactionMessage({
128
- thid,
129
- jti,
133
+ return submitLegalOrganizationVerificationTransactionWithDeps({
130
134
  hostCtx,
131
- bundle: verificationBundle,
135
+ verificationInput: input,
136
+ pollOptions,
137
+ createRuntimeUuid: runtimeUuid,
138
+ wrapBundleAsGatewayTransactionMessage: this.wrapBundleAsGatewayTransactionMessage.bind(this),
139
+ submitPath: this.hostRegistryOrganizationTransactionPath.bind(this),
140
+ pollPath: this.hostRegistryOrganizationTransactionPollPath.bind(this),
141
+ submitAndPoll: this.submitAndPoll.bind(this),
132
142
  });
133
- return this.submitAndPoll(this.hostRegistryOrganizationTransactionPath(hostCtx), this.hostRegistryOrganizationTransactionPollPath(hostCtx), payload, pollOptions);
134
143
  }
135
144
  /**
136
145
  * Starts the host-side existing-tenant legal-organization reissue flow that
@@ -143,16 +152,16 @@ export class HttpRuntimeClient {
143
152
  * - do not call `confirmLegalOrganizationOrder(...)` after this flow
144
153
  */
145
154
  async submitLegalOrganizationIssue(hostCtx, input, pollOptions) {
146
- const thid = `organization-issue-${runtimeUuid()}`;
147
- const jti = `organization-issue-jti-${runtimeUuid()}`;
148
- const verificationBundle = buildLegalOrganizationVerificationGatewayRequestBundle(input);
149
- const payload = this.wrapBundleAsGatewayTransactionMessage({
150
- thid,
151
- jti,
155
+ return submitLegalOrganizationIssueWithDeps({
152
156
  hostCtx,
153
- bundle: verificationBundle,
157
+ verificationInput: input,
158
+ pollOptions,
159
+ createRuntimeUuid: runtimeUuid,
160
+ wrapBundleAsGatewayTransactionMessage: this.wrapBundleAsGatewayTransactionMessage.bind(this),
161
+ submitPath: this.hostRegistryOrganizationIssuePath.bind(this),
162
+ pollPath: this.hostRegistryOrganizationIssuePollPath.bind(this),
163
+ submitAndPoll: this.submitAndPoll.bind(this),
154
164
  });
155
- return this.submitAndPoll(this.hostRegistryOrganizationIssuePath(hostCtx), this.hostRegistryOrganizationIssuePollPath(hostCtx), payload, pollOptions);
156
165
  }
157
166
  /**
158
167
  * Submits one tenant-scoped DID document binding request.
@@ -164,15 +173,15 @@ export class HttpRuntimeClient {
164
173
  * - the flow does not rotate or replace organization public keys
165
174
  */
166
175
  async submitOrganizationDidBinding(ctx, input, pollOptions) {
167
- const thid = `organization-did-binding-${runtimeUuid()}`;
168
- const jti = `organization-did-binding-jti-${runtimeUuid()}`;
169
- const payload = {
170
- jti,
171
- thid,
172
- type: 'application/api+json',
173
- body: buildOrganizationDidBindingBundle(input),
174
- };
175
- return this.submitAndPoll(this.organizationDidBindingPath(ctx), this.organizationDidBindingPollPath(ctx), payload, pollOptions);
176
+ return submitOrganizationDidBindingWithDeps({
177
+ routeCtx: ctx,
178
+ bindingInput: input,
179
+ pollOptions,
180
+ createRuntimeUuid: runtimeUuid,
181
+ organizationDidBindingPath: this.organizationDidBindingPath.bind(this),
182
+ organizationDidBindingPollPath: this.organizationDidBindingPollPath.bind(this),
183
+ submitAndPoll: this.submitAndPoll.bind(this),
184
+ });
176
185
  }
177
186
  /**
178
187
  * Activates a legal organization in the gateway host registry using an ICA
@@ -197,49 +206,16 @@ export class HttpRuntimeClient {
197
206
  * `confirmLegalOrganizationOrder(...)`
198
207
  */
199
208
  async activateOrganizationInGatewayFromIcaProof(hostCtx, input, pollOptions) {
200
- const thid = `activate-org-${runtimeUuid()}`;
201
- const activationDraft = bootstrapFacade.createOrganizationActivationDraft({
202
- vpToken: input.vpToken,
203
- controller: input.controller,
204
- service: input.service,
205
- additionalClaims: input.additionalClaims,
206
- });
207
- const serviceClaims = activationDraft.buildServiceClaims();
208
- const transportMeta = buildDidcommPlaintextTransportMetadata({
209
- controller: input.controller,
210
- contentType: 'application/didcomm-plain+json',
209
+ return activateOrganizationInGatewayFromIcaProofWithDeps({
210
+ hostCtx,
211
+ activationInput: input,
212
+ pollOptions,
213
+ createRuntimeUuid: runtimeUuid,
214
+ activationDraftFactory: (draftInput) => bootstrapFacade.createOrganizationActivationDraft(draftInput),
215
+ submitPath: this.hostRegistryOrganizationActivatePath.bind(this),
216
+ pollPath: this.hostRegistryOrganizationActivatePollPath.bind(this),
217
+ submitAndPoll: this.submitAndPoll.bind(this),
211
218
  });
212
- const payload = {
213
- thid,
214
- iss: String(hostCtx.controllerDid || '').trim() || undefined,
215
- aud: String(hostCtx.hostDid || '').trim() || undefined,
216
- type: 'application/api+json',
217
- ...(transportMeta ? { meta: transportMeta } : {}),
218
- body: {
219
- vp_token: input.vpToken,
220
- ...(input.controller ? { controller: input.controller } : {}),
221
- data: [{
222
- type: 'Organization-activation-request-v1.0',
223
- meta: {
224
- claims: {
225
- '@context': 'org.schema',
226
- ...serviceClaims,
227
- ...(input.additionalClaims || {}),
228
- },
229
- },
230
- resource: {
231
- meta: {
232
- claims: {
233
- '@context': 'org.schema',
234
- ...serviceClaims,
235
- ...(input.additionalClaims || {}),
236
- },
237
- },
238
- },
239
- }],
240
- },
241
- };
242
- return this.submitAndPoll(this.hostRegistryOrganizationActivatePath(hostCtx), this.hostRegistryOrganizationActivatePollPath(hostCtx), payload, pollOptions);
243
219
  }
244
220
  /**
245
221
  * Confirms a host-side legal organization order after the initial activation.
@@ -251,8 +227,8 @@ export class HttpRuntimeClient {
251
227
  return confirmLegalOrganizationOrderWithDeps({
252
228
  input,
253
229
  hostCtx,
254
- hostRegistryOrderBatchPath: this.hostRegistryOrderBatchPath.bind(this),
255
- hostRegistryOrderPollPath: this.hostRegistryOrderPollPath.bind(this),
230
+ hostRegistryOrderBatchPath: this.paths.hostRegistryOrderBatchPath.bind(this.paths),
231
+ hostRegistryOrderPollPath: this.paths.hostRegistryOrderPollPath.bind(this.paths),
256
232
  submitAndPoll: this.submitAndPoll.bind(this),
257
233
  defaultTimeoutMs: pollOptions?.timeoutMs,
258
234
  defaultIntervalMs: pollOptions?.intervalMs,
@@ -267,8 +243,8 @@ export class HttpRuntimeClient {
267
243
  hostCtx,
268
244
  input,
269
245
  requestType: HostLifecycleRequestType.Disable,
270
- submitPath: this.hostRegistryOrganizationDisablePath.bind(this),
271
- pollPath: this.hostRegistryOrganizationDisablePollPath.bind(this),
246
+ submitPath: this.paths.hostRegistryOrganizationDisablePath.bind(this.paths),
247
+ pollPath: this.paths.hostRegistryOrganizationDisablePollPath.bind(this.paths),
272
248
  thidPrefix: 'host-disable',
273
249
  submitAndPoll: this.submitAndPoll.bind(this),
274
250
  defaultTimeoutMs: pollOptions?.timeoutMs,
@@ -284,8 +260,8 @@ export class HttpRuntimeClient {
284
260
  hostCtx,
285
261
  input,
286
262
  requestType: HostLifecycleRequestType.Purge,
287
- submitPath: this.hostRegistryOrganizationPurgePath.bind(this),
288
- pollPath: this.hostRegistryOrganizationPurgePollPath.bind(this),
263
+ submitPath: this.paths.hostRegistryOrganizationPurgePath.bind(this.paths),
264
+ pollPath: this.paths.hostRegistryOrganizationPurgePollPath.bind(this.paths),
289
265
  thidPrefix: 'host-purge',
290
266
  submitAndPoll: this.submitAndPoll.bind(this),
291
267
  defaultTimeoutMs: pollOptions?.timeoutMs,
@@ -301,8 +277,8 @@ export class HttpRuntimeClient {
301
277
  hostCtx,
302
278
  input,
303
279
  requestType: HostedTenantLifecycleRequestType.Disable,
304
- submitPath: this.hostRegistryOrganizationDisablePath.bind(this),
305
- pollPath: this.hostRegistryOrganizationDisablePollPath.bind(this),
280
+ submitPath: this.paths.hostRegistryOrganizationDisablePath.bind(this.paths),
281
+ pollPath: this.paths.hostRegistryOrganizationDisablePollPath.bind(this.paths),
306
282
  thidPrefix: 'tenant-disable',
307
283
  submitAndPoll: this.submitAndPoll.bind(this),
308
284
  defaultTimeoutMs: pollOptions?.timeoutMs,
@@ -317,8 +293,8 @@ export class HttpRuntimeClient {
317
293
  hostCtx,
318
294
  input,
319
295
  requestType: HostedTenantLifecycleRequestType.Purge,
320
- submitPath: this.hostRegistryOrganizationPurgePath.bind(this),
321
- pollPath: this.hostRegistryOrganizationPurgePollPath.bind(this),
296
+ submitPath: this.paths.hostRegistryOrganizationPurgePath.bind(this.paths),
297
+ pollPath: this.paths.hostRegistryOrganizationPurgePollPath.bind(this.paths),
322
298
  thidPrefix: 'tenant-purge',
323
299
  submitAndPoll: this.submitAndPoll.bind(this),
324
300
  defaultTimeoutMs: pollOptions?.timeoutMs,
@@ -330,8 +306,8 @@ export class HttpRuntimeClient {
330
306
  */
331
307
  async createOrganizationEmployee(ctx, input, pollOptions) {
332
308
  return createOrganizationEmployeeWithDeps(ctx, input, pollOptions, {
333
- employeeBatchPath: this.employeeBatchPath.bind(this),
334
- employeePollPath: this.employeePollPath.bind(this),
309
+ employeeBatchPath: this.paths.employeeBatchPath.bind(this.paths),
310
+ employeePollPath: this.paths.employeePollPath.bind(this.paths),
335
311
  submitAndPoll: this.submitAndPoll.bind(this),
336
312
  });
337
313
  }
@@ -343,8 +319,8 @@ export class HttpRuntimeClient {
343
319
  */
344
320
  async disableOrganizationEmployee(ctx, input, pollOptions) {
345
321
  return disableOrganizationEmployeeWithDeps(ctx, input, pollOptions, {
346
- employeeBatchPath: this.employeeBatchPath.bind(this),
347
- employeePollPath: this.employeePollPath.bind(this),
322
+ employeeBatchPath: this.paths.employeeBatchPath.bind(this.paths),
323
+ employeePollPath: this.paths.employeePollPath.bind(this.paths),
348
324
  submitAndPoll: this.submitAndPoll.bind(this),
349
325
  });
350
326
  }
@@ -362,8 +338,8 @@ export class HttpRuntimeClient {
362
338
  */
363
339
  async purgeOrganizationEmployee(ctx, input, pollOptions) {
364
340
  return purgeOrganizationEmployeeWithDeps(ctx, input, pollOptions, {
365
- employeePurgePath: this.employeePurgePath.bind(this),
366
- employeePurgePollPath: this.employeePurgePollPath.bind(this),
341
+ employeePurgePath: this.paths.employeePurgePath.bind(this.paths),
342
+ employeePurgePollPath: this.paths.employeePurgePollPath.bind(this.paths),
367
343
  submitAndPoll: this.submitAndPoll.bind(this),
368
344
  });
369
345
  }
@@ -378,8 +354,8 @@ export class HttpRuntimeClient {
378
354
  */
379
355
  async searchOrganizationEmployees(ctx, input) {
380
356
  return searchOrganizationEmployeesWithDeps(ctx, input, {
381
- employeeSearchPath: this.employeeSearchPath.bind(this),
382
- employeeSearchPollPath: this.employeeSearchPollPath.bind(this),
357
+ employeeSearchPath: this.paths.employeeSearchPath.bind(this.paths),
358
+ employeeSearchPollPath: this.paths.employeeSearchPollPath.bind(this.paths),
383
359
  submitAndPoll: this.submitAndPoll.bind(this),
384
360
  });
385
361
  }
@@ -389,8 +365,8 @@ export class HttpRuntimeClient {
389
365
  */
390
366
  async searchOrganizationLicenses(ctx, input) {
391
367
  return searchOrganizationLicensesWithDeps(ctx, input, {
392
- organizationLicenseSearchPath: this.organizationLicenseSearchPath.bind(this),
393
- organizationLicenseSearchPollPath: this.organizationLicenseSearchPollPath.bind(this),
368
+ organizationLicenseSearchPath: this.paths.organizationLicenseSearchPath.bind(this.paths),
369
+ organizationLicenseSearchPollPath: this.paths.organizationLicenseSearchPollPath.bind(this.paths),
394
370
  submitAndPoll: this.submitAndPoll.bind(this),
395
371
  });
396
372
  }
@@ -400,36 +376,36 @@ export class HttpRuntimeClient {
400
376
  */
401
377
  async listOrganizationLicenses(ctx, input = {}) {
402
378
  return listOrganizationLicensesWithDeps(ctx, input, {
403
- organizationLicenseSearchPath: this.organizationLicenseSearchPath.bind(this),
404
- organizationLicenseSearchPollPath: this.organizationLicenseSearchPollPath.bind(this),
379
+ organizationLicenseSearchPath: this.paths.organizationLicenseSearchPath.bind(this.paths),
380
+ organizationLicenseSearchPollPath: this.paths.organizationLicenseSearchPollPath.bind(this.paths),
405
381
  submitAndPoll: this.submitAndPoll.bind(this),
406
382
  });
407
383
  }
408
384
  async searchOrganizationLicenseOffers(ctx, input) {
409
385
  return searchOrganizationLicenseOffersWithDeps(ctx, input, {
410
- organizationLicenseOfferSearchPath: this.organizationLicenseOfferSearchPath.bind(this),
411
- organizationLicenseOfferSearchPollPath: this.organizationLicenseOfferSearchPollPath.bind(this),
386
+ organizationLicenseOfferSearchPath: this.paths.organizationLicenseOfferSearchPath.bind(this.paths),
387
+ organizationLicenseOfferSearchPollPath: this.paths.organizationLicenseOfferSearchPollPath.bind(this.paths),
412
388
  submitAndPoll: this.submitAndPoll.bind(this),
413
389
  });
414
390
  }
415
391
  async listOrganizationLicenseOffers(ctx, input = {}) {
416
392
  return listOrganizationLicenseOffersWithDeps(ctx, input, {
417
- organizationLicenseOfferSearchPath: this.organizationLicenseOfferSearchPath.bind(this),
418
- organizationLicenseOfferSearchPollPath: this.organizationLicenseOfferSearchPollPath.bind(this),
393
+ organizationLicenseOfferSearchPath: this.paths.organizationLicenseOfferSearchPath.bind(this.paths),
394
+ organizationLicenseOfferSearchPollPath: this.paths.organizationLicenseOfferSearchPollPath.bind(this.paths),
419
395
  submitAndPoll: this.submitAndPoll.bind(this),
420
396
  });
421
397
  }
422
398
  async searchOrganizationLicenseOrders(ctx, input) {
423
399
  return searchOrganizationLicenseOrdersWithDeps(ctx, input, {
424
- organizationLicenseOrderSearchPath: this.organizationLicenseOrderSearchPath.bind(this),
425
- organizationLicenseOrderSearchPollPath: this.organizationLicenseOrderSearchPollPath.bind(this),
400
+ organizationLicenseOrderSearchPath: this.paths.organizationLicenseOrderSearchPath.bind(this.paths),
401
+ organizationLicenseOrderSearchPollPath: this.paths.organizationLicenseOrderSearchPollPath.bind(this.paths),
426
402
  submitAndPoll: this.submitAndPoll.bind(this),
427
403
  });
428
404
  }
429
405
  async listOrganizationLicenseOrders(ctx, input = {}) {
430
406
  return listOrganizationLicenseOrdersWithDeps(ctx, input, {
431
- organizationLicenseOrderSearchPath: this.organizationLicenseOrderSearchPath.bind(this),
432
- organizationLicenseOrderSearchPollPath: this.organizationLicenseOrderSearchPollPath.bind(this),
407
+ organizationLicenseOrderSearchPath: this.paths.organizationLicenseOrderSearchPath.bind(this.paths),
408
+ organizationLicenseOrderSearchPollPath: this.paths.organizationLicenseOrderSearchPollPath.bind(this.paths),
433
409
  submitAndPoll: this.submitAndPoll.bind(this),
434
410
  });
435
411
  }
@@ -449,8 +425,8 @@ export class HttpRuntimeClient {
449
425
  input,
450
426
  defaultTimeoutMs: pollOptions?.timeoutMs,
451
427
  defaultIntervalMs: pollOptions?.intervalMs,
452
- hostRegistryOrderBatchPath: this.hostRegistryOrderBatchPath.bind(this),
453
- hostRegistryOrderPollPath: this.hostRegistryOrderPollPath.bind(this),
428
+ hostRegistryOrderBatchPath: this.paths.hostRegistryOrderBatchPath.bind(this.paths),
429
+ hostRegistryOrderPollPath: this.paths.hostRegistryOrderPollPath.bind(this.paths),
454
430
  submitAndPoll: this.submitAndPoll.bind(this),
455
431
  });
456
432
  }
@@ -467,12 +443,12 @@ export class HttpRuntimeClient {
467
443
  * GW CORE that may persist an individual record without minting an Offer.
468
444
  */
469
445
  async startIndividualOrganization(input) {
470
- const routeCtx = this.routeCtxFromInput(input);
446
+ const routeCtx = this.paths.routeCtxFromInput(input);
471
447
  return startIndividualOrganizationWithDeps({
472
448
  input,
473
449
  routeCtx,
474
- individualFamilyOrganizationBatchPath: this.individualFamilyOrganizationTransactionPath.bind(this),
475
- individualFamilyOrganizationPollPath: this.individualFamilyOrganizationTransactionPollPath.bind(this),
450
+ individualFamilyOrganizationBatchPath: this.paths.individualFamilyOrganizationTransactionPath.bind(this.paths),
451
+ individualFamilyOrganizationPollPath: this.paths.individualFamilyOrganizationTransactionPollPath.bind(this.paths),
476
452
  submitAndPoll: this.submitAndPoll.bind(this),
477
453
  getOfferIdFromResponse: (result) => extractOfferIdFromResponseBody(result.poll.body),
478
454
  getOfferPreviewFromResponse: (result) => extractOfferPreviewFromResponseBody(result.poll.body),
@@ -488,8 +464,8 @@ export class HttpRuntimeClient {
488
464
  input,
489
465
  defaultTimeoutMs: 20000,
490
466
  defaultIntervalMs: 1000,
491
- individualFamilyOrganizationSearchPath: this.individualFamilyOrganizationSearchPath.bind(this),
492
- individualFamilyOrganizationSearchPollPath: this.individualFamilyOrganizationSearchPollPath.bind(this),
467
+ individualFamilyOrganizationSearchPath: this.paths.individualFamilyOrganizationSearchPath.bind(this.paths),
468
+ individualFamilyOrganizationSearchPollPath: this.paths.individualFamilyOrganizationSearchPollPath.bind(this.paths),
493
469
  submitAndPoll: this.submitAndPoll.bind(this),
494
470
  });
495
471
  }
@@ -503,10 +479,10 @@ export class HttpRuntimeClient {
503
479
  input,
504
480
  defaultTimeoutMs: 20000,
505
481
  defaultIntervalMs: 1000,
506
- individualFamilyOrganizationSearchPath: this.individualFamilyOrganizationSearchPath.bind(this),
507
- individualFamilyOrganizationSearchPollPath: this.individualFamilyOrganizationSearchPollPath.bind(this),
508
- individualFamilyOrganizationBatchPath: this.individualFamilyOrganizationTransactionPath.bind(this),
509
- individualFamilyOrganizationPollPath: this.individualFamilyOrganizationTransactionPollPath.bind(this),
482
+ individualFamilyOrganizationSearchPath: this.paths.individualFamilyOrganizationSearchPath.bind(this.paths),
483
+ individualFamilyOrganizationSearchPollPath: this.paths.individualFamilyOrganizationSearchPollPath.bind(this.paths),
484
+ individualFamilyOrganizationBatchPath: this.paths.individualFamilyOrganizationTransactionPath.bind(this.paths),
485
+ individualFamilyOrganizationPollPath: this.paths.individualFamilyOrganizationTransactionPollPath.bind(this.paths),
510
486
  submitAndPoll: this.submitAndPoll.bind(this),
511
487
  });
512
488
  }
@@ -514,12 +490,12 @@ export class HttpRuntimeClient {
514
490
  * Confirms the order returned by `startIndividualOrganization(...)`.
515
491
  */
516
492
  async confirmIndividualOrganizationOrder(input) {
517
- const routeCtx = this.routeCtxFromInput(input);
493
+ const routeCtx = this.paths.routeCtxFromInput(input);
518
494
  return confirmIndividualOrganizationOrderWithDeps({
519
495
  input,
520
496
  routeCtx,
521
- individualFamilyOrderBatchPath: this.individualFamilyOrderBatchPath.bind(this),
522
- individualFamilyOrderPollPath: this.individualFamilyOrderPollPath.bind(this),
497
+ individualFamilyOrderBatchPath: this.paths.individualFamilyOrderBatchPath.bind(this.paths),
498
+ individualFamilyOrderPollPath: this.paths.individualFamilyOrderPollPath.bind(this.paths),
523
499
  submitAndPoll: this.submitAndPoll.bind(this),
524
500
  });
525
501
  }
@@ -531,8 +507,8 @@ export class HttpRuntimeClient {
531
507
  */
532
508
  async disableIndividualOrganization(ctx, input, pollOptions) {
533
509
  return disableIndividualOrganizationWithDeps(ctx, input, pollOptions, {
534
- individualOrganizationDisablePath: this.individualFamilyOrganizationDisablePath.bind(this),
535
- individualOrganizationDisablePollPath: this.individualFamilyOrganizationDisablePollPath.bind(this),
510
+ individualOrganizationDisablePath: this.paths.individualFamilyOrganizationDisablePath.bind(this.paths),
511
+ individualOrganizationDisablePollPath: this.paths.individualFamilyOrganizationDisablePollPath.bind(this.paths),
536
512
  submitAndPoll: this.submitAndPoll.bind(this),
537
513
  });
538
514
  }
@@ -550,8 +526,8 @@ export class HttpRuntimeClient {
550
526
  */
551
527
  async purgeIndividualOrganization(ctx, input, pollOptions) {
552
528
  return purgeIndividualOrganizationWithDeps(ctx, input, pollOptions, {
553
- individualOrganizationPurgePath: this.individualFamilyOrganizationPurgePath.bind(this),
554
- individualOrganizationPurgePollPath: this.individualFamilyOrganizationPurgePollPath.bind(this),
529
+ individualOrganizationPurgePath: this.paths.individualFamilyOrganizationPurgePath.bind(this.paths),
530
+ individualOrganizationPurgePollPath: this.paths.individualFamilyOrganizationPurgePollPath.bind(this.paths),
555
531
  submitAndPoll: this.submitAndPoll.bind(this),
556
532
  });
557
533
  }
@@ -567,8 +543,8 @@ export class HttpRuntimeClient {
567
543
  */
568
544
  async disableIndividualMember(ctx, input, pollOptions) {
569
545
  return disableIndividualMemberWithDeps(ctx, input, pollOptions, {
570
- individualRelatedPersonBatchPath: this.individualRelatedPersonBatchPath.bind(this),
571
- individualRelatedPersonPollPath: this.individualRelatedPersonPollPath.bind(this),
546
+ individualRelatedPersonBatchPath: this.paths.individualRelatedPersonBatchPath.bind(this.paths),
547
+ individualRelatedPersonPollPath: this.paths.individualRelatedPersonPollPath.bind(this.paths),
572
548
  submitAndPoll: this.submitAndPoll.bind(this),
573
549
  });
574
550
  }
@@ -578,8 +554,8 @@ export class HttpRuntimeClient {
578
554
  */
579
555
  async searchIndividualLicenses(ctx, input) {
580
556
  return searchIndividualLicensesWithDeps(ctx, input, {
581
- individualLicenseSearchPath: this.individualLicenseSearchPath.bind(this),
582
- individualLicenseSearchPollPath: this.individualLicenseSearchPollPath.bind(this),
557
+ individualLicenseSearchPath: this.paths.individualLicenseSearchPath.bind(this.paths),
558
+ individualLicenseSearchPollPath: this.paths.individualLicenseSearchPollPath.bind(this.paths),
583
559
  submitAndPoll: this.submitAndPoll.bind(this),
584
560
  });
585
561
  }
@@ -589,49 +565,47 @@ export class HttpRuntimeClient {
589
565
  */
590
566
  async listIndividualLicenses(ctx, input = {}) {
591
567
  return listIndividualLicensesWithDeps(ctx, input, {
592
- individualLicenseSearchPath: this.individualLicenseSearchPath.bind(this),
593
- individualLicenseSearchPollPath: this.individualLicenseSearchPollPath.bind(this),
568
+ individualLicenseSearchPath: this.paths.individualLicenseSearchPath.bind(this.paths),
569
+ individualLicenseSearchPollPath: this.paths.individualLicenseSearchPollPath.bind(this.paths),
594
570
  submitAndPoll: this.submitAndPoll.bind(this),
595
571
  });
596
572
  }
597
573
  async searchIndividualLicenseOffers(ctx, input) {
598
574
  return searchIndividualLicenseOffersWithDeps(ctx, input, {
599
- individualLicenseOfferSearchPath: this.individualLicenseOfferSearchPath.bind(this),
600
- individualLicenseOfferSearchPollPath: this.individualLicenseOfferSearchPollPath.bind(this),
575
+ individualLicenseOfferSearchPath: this.paths.individualLicenseOfferSearchPath.bind(this.paths),
576
+ individualLicenseOfferSearchPollPath: this.paths.individualLicenseOfferSearchPollPath.bind(this.paths),
601
577
  submitAndPoll: this.submitAndPoll.bind(this),
602
578
  });
603
579
  }
604
580
  async listIndividualLicenseOffers(ctx, input = {}) {
605
581
  return listIndividualLicenseOffersWithDeps(ctx, input, {
606
- individualLicenseOfferSearchPath: this.individualLicenseOfferSearchPath.bind(this),
607
- individualLicenseOfferSearchPollPath: this.individualLicenseOfferSearchPollPath.bind(this),
582
+ individualLicenseOfferSearchPath: this.paths.individualLicenseOfferSearchPath.bind(this.paths),
583
+ individualLicenseOfferSearchPollPath: this.paths.individualLicenseOfferSearchPollPath.bind(this.paths),
608
584
  submitAndPoll: this.submitAndPoll.bind(this),
609
585
  });
610
586
  }
611
587
  async searchIndividualLicenseOrders(ctx, input) {
612
588
  return searchIndividualLicenseOrdersWithDeps(ctx, input, {
613
- individualLicenseOrderSearchPath: this.individualLicenseOrderSearchPath.bind(this),
614
- individualLicenseOrderSearchPollPath: this.individualLicenseOrderSearchPollPath.bind(this),
589
+ individualLicenseOrderSearchPath: this.paths.individualLicenseOrderSearchPath.bind(this.paths),
590
+ individualLicenseOrderSearchPollPath: this.paths.individualLicenseOrderSearchPollPath.bind(this.paths),
615
591
  submitAndPoll: this.submitAndPoll.bind(this),
616
592
  });
617
593
  }
618
594
  async listIndividualLicenseOrders(ctx, input = {}) {
619
595
  return listIndividualLicenseOrdersWithDeps(ctx, input, {
620
- individualLicenseOrderSearchPath: this.individualLicenseOrderSearchPath.bind(this),
621
- individualLicenseOrderSearchPollPath: this.individualLicenseOrderSearchPollPath.bind(this),
596
+ individualLicenseOrderSearchPath: this.paths.individualLicenseOrderSearchPath.bind(this.paths),
597
+ individualLicenseOrderSearchPollPath: this.paths.individualLicenseOrderSearchPollPath.bind(this.paths),
622
598
  submitAndPoll: this.submitAndPoll.bind(this),
623
599
  });
624
600
  }
625
601
  /**
626
- * Placeholder for a future GW CORE member/caregiver lifecycle contract.
627
- *
628
- * Current GW CORE does not yet expose a stable lifecycle route for
629
- * `RelatedPerson` / individual-member purge.
602
+ * Purges one previously disabled `RelatedPerson` membership/contact through
603
+ * the explicit public purge path.
630
604
  */
631
605
  async purgeIndividualMember(ctx, input, pollOptions) {
632
606
  return purgeIndividualMemberWithDeps(ctx, input, pollOptions, {
633
- individualRelatedPersonPurgePath: this.individualRelatedPersonPurgePath.bind(this),
634
- individualRelatedPersonPurgePollPath: this.individualRelatedPersonPurgePollPath.bind(this),
607
+ individualRelatedPersonPurgePath: this.paths.individualRelatedPersonPurgePath.bind(this.paths),
608
+ individualRelatedPersonPurgePollPath: this.paths.individualRelatedPersonPurgePollPath.bind(this.paths),
635
609
  submitAndPoll: this.submitAndPoll.bind(this),
636
610
  });
637
611
  }
@@ -641,8 +615,8 @@ export class HttpRuntimeClient {
641
615
  async grantProfessionalAccess(ctx, input) {
642
616
  return grantProfessionalAccessWithDeps(ctx, input, {
643
617
  buildConsentClaimsWithCid: this.buildConsentClaimsWithCid.bind(this),
644
- individualConsentR4BatchPath: this.individualConsentR4BatchPath.bind(this),
645
- individualConsentR4PollPath: this.individualConsentR4PollPath.bind(this),
618
+ individualConsentR4BatchPath: this.paths.individualConsentR4BatchPath.bind(this.paths),
619
+ individualConsentR4PollPath: this.paths.individualConsentR4PollPath.bind(this.paths),
646
620
  submitAndPoll: this.submitAndPoll.bind(this),
647
621
  });
648
622
  }
@@ -652,8 +626,8 @@ export class HttpRuntimeClient {
652
626
  */
653
627
  async revokeProfessionalAccess(ctx, input) {
654
628
  return revokeProfessionalAccessWithDeps(ctx, input, {
655
- individualConsentR4BatchPath: this.individualConsentR4BatchPath.bind(this),
656
- individualConsentR4PollPath: this.individualConsentR4PollPath.bind(this),
629
+ individualConsentR4BatchPath: this.paths.individualConsentR4BatchPath.bind(this.paths),
630
+ individualConsentR4PollPath: this.paths.individualConsentR4PollPath.bind(this.paths),
657
631
  submitAndPoll: this.submitAndPoll.bind(this),
658
632
  });
659
633
  }
@@ -666,17 +640,17 @@ export class HttpRuntimeClient {
666
640
  * the default client route context configured in the constructor.
667
641
  */
668
642
  async requestSmartToken(input) {
669
- const routeCtx = this.routeCtxFromInput(input);
643
+ const routeCtx = this.paths.routeCtxFromInput(input);
670
644
  return requestSmartTokenWithDeps({
671
645
  input,
672
646
  routeCtx,
673
647
  baseUrl: this.baseUrl,
674
648
  defaultTimeoutMs: undefined,
675
649
  defaultIntervalMs: undefined,
676
- identityTokenExchangePath: this.identityTokenExchangePath.bind(this),
677
- identityTokenExchangePollPath: this.identityTokenExchangePollPath.bind(this),
678
- identityOpenIdSmartTokenPath: this.identityOpenIdSmartTokenPath.bind(this),
679
- identityOpenIdSmartTokenPollPath: this.identityOpenIdSmartTokenPollPath.bind(this),
650
+ identityTokenExchangePath: this.paths.identityTokenExchangePath.bind(this.paths),
651
+ identityTokenExchangePollPath: this.paths.identityTokenExchangePollPath.bind(this.paths),
652
+ identityOpenIdSmartTokenPath: this.paths.identityOpenIdSmartTokenPath.bind(this.paths),
653
+ identityOpenIdSmartTokenPollPath: this.paths.identityOpenIdSmartTokenPollPath.bind(this.paths),
680
654
  submitAndPoll: this.submitAndPoll.bind(this),
681
655
  setTokenCache: (tokenCacheKey, token) => this.tokenCache.set(tokenCacheKey, token),
682
656
  });
@@ -687,8 +661,8 @@ export class HttpRuntimeClient {
687
661
  */
688
662
  async upsertRelatedPersonAndPoll(ctx, input) {
689
663
  return upsertRelatedPersonAndPollWithDeps(ctx, input, {
690
- individualRelatedPersonBatchPath: this.individualRelatedPersonBatchPath.bind(this),
691
- individualRelatedPersonPollPath: this.individualRelatedPersonPollPath.bind(this),
664
+ individualRelatedPersonBatchPath: this.paths.individualRelatedPersonBatchPath.bind(this.paths),
665
+ individualRelatedPersonPollPath: this.paths.individualRelatedPersonPollPath.bind(this.paths),
692
666
  submitAndPoll: this.submitAndPoll.bind(this),
693
667
  });
694
668
  }
@@ -701,8 +675,8 @@ export class HttpRuntimeClient {
701
675
  */
702
676
  async ingestCommunicationAndUpdateIndex(ctx, input) {
703
677
  return ingestCommunicationAndUpdateIndexWithDeps(ctx, input, {
704
- individualCommunicationBatchPath: this.individualCommunicationBatchPath.bind(this),
705
- individualCommunicationPollPath: this.individualCommunicationPollPath.bind(this),
678
+ individualCommunicationBatchPath: this.paths.individualCommunicationBatchPath.bind(this.paths),
679
+ individualCommunicationPollPath: this.paths.individualCommunicationPollPath.bind(this.paths),
706
680
  submitAndPoll: this.submitAndPoll.bind(this),
707
681
  });
708
682
  }
@@ -712,8 +686,8 @@ export class HttpRuntimeClient {
712
686
  */
713
687
  async searchCommunicationParticipants(ctx, input) {
714
688
  return searchCommunicationParticipantsWithDeps(ctx, input, {
715
- communicationSearchPath: this.individualCommunicationSearchPath.bind(this),
716
- communicationSearchPollPath: this.individualCommunicationSearchPollPath.bind(this),
689
+ communicationSearchPath: this.paths.individualCommunicationSearchPath.bind(this.paths),
690
+ communicationSearchPollPath: this.paths.individualCommunicationSearchPollPath.bind(this.paths),
717
691
  submitAndPoll: this.submitAndPoll.bind(this),
718
692
  });
719
693
  }
@@ -734,8 +708,8 @@ export class HttpRuntimeClient {
734
708
  */
735
709
  async searchClinicalBundle(ctx, input) {
736
710
  return searchClinicalBundleWithDeps(ctx, input, {
737
- bundleSearchPath: this.individualBundleSearchPath.bind(this),
738
- bundleSearchPollPath: this.individualBundleSearchPollPath.bind(this),
711
+ bundleSearchPath: this.paths.individualBundleSearchPath.bind(this.paths),
712
+ bundleSearchPollPath: this.paths.individualBundleSearchPollPath.bind(this.paths),
739
713
  submitAndPoll: this.submitAndPoll.bind(this),
740
714
  });
741
715
  }
@@ -772,303 +746,95 @@ export class HttpRuntimeClient {
772
746
  });
773
747
  }
774
748
  buildConsentClaimsWithCid(input) {
775
- return buildConsentClaimsSimpleWithCid({
776
- subjectDid: input.subjectDid,
777
- subjectPhone: input.subjectPhone,
778
- subjectGivenName: input.subjectGivenName,
779
- actor: input.actorId ?? input.actor ?? '',
780
- actorRole: String(input?.actorRole || ''),
781
- purpose: String(input?.purpose || ''),
782
- actions: Array.isArray(input?.actions) ? input.actions : [],
783
- consentIdentifier: input.consentIdentifier,
784
- consentDate: input.consentDate,
785
- decision: input.decision,
786
- attachmentContentType: input.attachmentContentType,
787
- attachmentBase64: input.attachmentBase64,
788
- }, {
789
- errorPrefix: 'grantProfessionalAccess:',
790
- consentIdentifierFactory: () => `urn:uuid:${runtimeUuid()}`,
791
- });
749
+ return buildGrantProfessionalAccessClaimsWithCid(input, runtimeUuid);
792
750
  }
793
751
  async pollBatchResponse(path, request) {
794
- const response = await this.fetchWithTimeout(path, {
795
- method: 'POST',
796
- headers: this.buildHeaders('application/json'),
797
- body: JSON.stringify(request),
798
- });
799
- const retryAfter = Number(response.headers.get('retry-after'));
800
- return {
801
- status: response.status,
802
- body: await this.parseResponseBody(response),
803
- retryAfterMs: Number.isFinite(retryAfter) ? retryAfter * 1000 : undefined,
804
- };
752
+ return pollBatchResponseWithRuntimeConfig(this.transportConfig, path, request);
805
753
  }
806
754
  async postJson(path, payload, contentType) {
807
- const response = await this.fetchWithTimeout(path, {
808
- method: 'POST',
809
- headers: this.buildHeaders(contentType),
810
- body: JSON.stringify(payload),
811
- });
812
- return { status: response.status, location: response.headers.get('location') || undefined, body: await this.parseResponseBody(response) };
755
+ return postJsonWithRuntimeConfig(this.transportConfig, path, payload, contentType);
813
756
  }
814
757
  buildHeaders(contentType) {
815
- const headers = {
816
- ...this.defaultHeaders,
817
- 'Content-Type': contentType,
818
- Accept: DIDCOMM_DEFAULT_ACCEPT_HEADER,
819
- };
820
- if (this.bearerToken)
821
- headers.Authorization = `Bearer ${this.bearerToken}`;
822
- return headers;
758
+ return buildRuntimeHeaders(this.transportConfig, contentType);
823
759
  }
824
760
  async fetchWithTimeout(path, init) {
825
- const controller = new AbortController();
826
- const timeout = setTimeout(() => controller.abort(), this.requestTimeoutMs);
827
- const url = /^https?:\/\//.test(path) ? path : `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;
828
- const requestBody = this.parseTraceBody(init.body);
829
- const traceBase = {
830
- ts: new Date().toISOString(),
831
- request: {
832
- url,
833
- method: String(init.method || 'GET').toUpperCase(),
834
- headers: this.redactTraceValue(init.headers || {}),
835
- body: this.redactTraceValue(requestBody),
836
- },
837
- };
838
- try {
839
- const response = await fetch(url, { ...init, signal: controller.signal });
840
- const responseClone = response.clone();
841
- const responseRaw = await responseClone.text();
842
- this.appendHttpTrace({
843
- ...traceBase,
844
- response: {
845
- status: response.status,
846
- headers: this.redactTraceValue(Object.fromEntries(response.headers.entries())),
847
- body: this.redactTraceValue(this.parseTraceRawText(responseRaw)),
848
- },
849
- });
850
- return response;
851
- }
852
- catch (error) {
853
- this.appendHttpTrace({
854
- ...traceBase,
855
- error: {
856
- name: error instanceof Error ? error.name : 'Error',
857
- message: error instanceof Error ? error.message : String(error),
858
- },
859
- });
860
- throw error;
861
- }
862
- finally {
863
- clearTimeout(timeout);
864
- }
761
+ return fetchWithTimeout(this.transportConfig, path, init);
865
762
  }
866
763
  async parseResponseBody(response) {
867
- const raw = await response.text();
868
- if (!raw)
869
- return {};
870
- try {
871
- return JSON.parse(raw);
872
- }
873
- catch {
874
- return raw;
875
- }
876
- }
877
- requireRouteContext(ctx) {
878
- const resolved = ctx || this.ctx;
879
- const tenantId = String(resolved?.tenantId || '').trim();
880
- const jurisdiction = String(resolved?.jurisdiction || '').trim();
881
- const sector = String(resolved?.sector || '').trim();
882
- if (!tenantId || !jurisdiction || !sector) {
883
- throw new Error('Route context is required.');
884
- }
885
- return { tenantId, jurisdiction, sector };
886
- }
887
- routeCtxFromInput(input) {
888
- const tenantId = String(input.serviceProviderDid || input.tenantId || '').trim();
889
- return this.requireRouteContext(tenantId && input.jurisdiction && input.sector
890
- ? { tenantId, jurisdiction: input.jurisdiction, sector: input.sector }
891
- : undefined);
764
+ return parseResponseBody(response);
892
765
  }
893
766
  /**
894
767
  * Reuses the shared bundle business contract while keeping attachment
895
768
  * transport fields at the DIDComm/plaintext message layer expected by GW.
896
769
  */
897
770
  wrapBundleAsGatewayTransactionMessage(input) {
898
- const rawBundle = (input.bundle || {});
899
- const attachments = Array.isArray(rawBundle.attachments) ? rawBundle.attachments : undefined;
900
- const { attachments: _ignoredAttachments, ...body } = rawBundle;
901
- return {
902
- jti: input.jti,
903
- thid: input.thid,
904
- iss: String(input.hostCtx.controllerDid || '').trim() || undefined,
905
- aud: String(input.hostCtx.hostDid || '').trim() || undefined,
906
- type: 'application/api+json',
907
- body,
908
- ...(attachments && attachments.length > 0 ? { attachments } : {}),
909
- };
910
- }
911
- hostRegistryPath(ctx, resourceType, action) {
912
- const hostCtx = this.requireHostRouteContext(ctx);
913
- return `/host/cds-${encodeURIComponent(hostCtx.jurisdiction)}/v1/${encodeURIComponent(hostCtx.hostNetwork || '')}/registry/org.schema/${encodeURIComponent(resourceType)}/${encodeURIComponent(action)}`;
914
- }
915
- /**
916
- * Resolves the host route segment without forcing callers to remember whether
917
- * the same raw string is named `hostNetwork` or `sector` in a given layer.
918
- *
919
- * Step by step:
920
- * - host routes use `/host/cds-{jurisdiction}/v1/{host-network}`
921
- * - tenant routes use `/{tenantId}/cds-{jurisdiction}/v1/{tenant-sector}`
922
- * - older live tests and adapters sometimes passed the host segment under
923
- * `sector`, which is semantically wrong for host routes
924
- * - new code should prefer `hostNetwork`
925
- * - compatibility code may pass `hostNetworkOrTenantSector`
926
- */
927
- requireHostRouteContext(ctx) {
928
- const hostCtx = (ctx || {});
929
- const runtimeCtx = (this.ctx || {});
930
- const jurisdiction = String(hostCtx.jurisdiction || this.ctx?.jurisdiction || '').trim();
931
- const hostNetwork = String(hostCtx.hostNetwork
932
- || hostCtx.hostNetworkOrTenantSector
933
- || hostCtx.sector
934
- || runtimeCtx.hostNetwork
935
- || runtimeCtx.hostNetworkOrTenantSector
936
- || runtimeCtx.sector
937
- || '').trim();
938
- if (!jurisdiction || !hostNetwork)
939
- throw new Error('Host route context is required.');
940
- return { jurisdiction, hostNetwork };
941
- }
942
- hostRegistryOrganizationTransactionPath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.Transaction); }
943
- hostRegistryOrganizationTransactionPollPath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.TransactionResponse); }
944
- hostRegistryOrganizationIssuePath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.Issue); }
945
- hostRegistryOrganizationIssuePollPath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.IssueResponse); }
946
- hostRegistryOrganizationActivatePath(ctx) { return this.hostRegistryPath(ctx, 'Organization', '_activate'); }
947
- hostRegistryOrganizationActivatePollPath(ctx) { return this.hostRegistryPath(ctx, 'Organization', '_activate-response'); }
948
- hostRegistryOrganizationDisablePath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.Disable); }
949
- hostRegistryOrganizationDisablePollPath(ctx) { return this.hostRegistryPath(ctx, 'Organization', `${GwCoreLifecycleAction.Disable}-response`); }
950
- hostRegistryOrganizationPurgePath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.Purge); }
951
- hostRegistryOrganizationPurgePollPath(ctx) { return this.hostRegistryPath(ctx, 'Organization', `${GwCoreLifecycleAction.Purge}-response`); }
952
- hostRegistryOrderBatchPath(ctx) { return this.hostRegistryPath(ctx, 'Order', '_batch'); }
953
- hostRegistryOrderPollPath(ctx) { return this.hostRegistryPath(ctx, 'Order', '_batch-response'); }
954
- employeeBatchPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Employee', GwCoreLifecycleAction.Batch); }
955
- employeePollPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Employee', GwCoreLifecycleAction.BatchResponse); }
956
- employeeSearchPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Employee', '_search'); }
957
- employeeSearchPollPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Employee', '_search-response'); }
958
- organizationLicenseSearchPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'License', '_search'); }
959
- organizationLicenseSearchPollPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'License', '_search-response'); }
960
- organizationDidBindingPath(ctx) {
961
- const resolved = this.requireRouteContext(ctx);
962
- return `/${encodeURIComponent(resolved.tenantId)}/cds-${encodeURIComponent(resolved.jurisdiction)}/v1/${encodeURIComponent(resolved.sector)}/did/document/_binding`;
963
- }
964
- organizationDidBindingPollPath(ctx) {
965
- const resolved = this.requireRouteContext(ctx);
966
- return `/${encodeURIComponent(resolved.tenantId)}/cds-${encodeURIComponent(resolved.jurisdiction)}/v1/${encodeURIComponent(resolved.sector)}/did/document/_binding-response`;
967
- }
968
- organizationLicenseOfferSearchPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Offer', '_search'); }
969
- organizationLicenseOfferSearchPollPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Offer', '_search-response'); }
970
- organizationLicenseOrderSearchPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Order', '_search'); }
971
- organizationLicenseOrderSearchPollPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Order', '_search-response'); }
972
- employeePurgePath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Employee', GwCoreLifecycleAction.Purge); }
973
- employeePurgePollPath(ctx) { return this.v1Path(ctx, 'entity', 'org.schema', 'Employee', `${GwCoreLifecycleAction.Purge}-response`); }
974
- individualFamilyOrganizationBatchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', GwCoreLifecycleAction.Batch); }
975
- individualFamilyOrganizationPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', GwCoreLifecycleAction.BatchResponse); }
976
- individualFamilyOrganizationSearchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', '_search'); }
977
- individualFamilyOrganizationSearchPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', '_search-response'); }
978
- individualFamilyOrganizationTransactionPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', GwCoreLifecycleAction.Transaction); }
979
- individualFamilyOrganizationTransactionPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', GwCoreLifecycleAction.TransactionResponse); }
980
- individualFamilyOrganizationDisablePath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', GwCoreLifecycleAction.Disable); }
981
- individualFamilyOrganizationDisablePollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', `${GwCoreLifecycleAction.Disable}-response`); }
982
- individualFamilyOrganizationPurgePath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', GwCoreLifecycleAction.Purge); }
983
- individualFamilyOrganizationPurgePollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Organization', `${GwCoreLifecycleAction.Purge}-response`); }
984
- individualLicenseSearchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'License', '_search'); }
985
- individualLicenseSearchPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'License', '_search-response'); }
986
- individualLicenseOfferSearchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Offer', '_search'); }
987
- individualLicenseOfferSearchPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Offer', '_search-response'); }
988
- individualLicenseOrderSearchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Order', '_search'); }
989
- individualLicenseOrderSearchPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Order', '_search-response'); }
990
- individualFamilyOrderBatchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Order', '_batch'); }
991
- individualFamilyOrderPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.schema', 'Order', '_batch-response'); }
992
- individualRelatedPersonBatchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'RelatedPerson', '_batch'); }
993
- individualRelatedPersonPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'RelatedPerson', '_batch-response'); }
994
- individualRelatedPersonPurgePath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'RelatedPerson', '_purge'); }
995
- individualRelatedPersonPurgePollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'RelatedPerson', '_purge-response'); }
996
- individualConsentR4BatchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'Consent', '_batch'); }
997
- individualConsentR4PollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'Consent', '_batch-response'); }
998
- individualCommunicationBatchPath(ctx, format) { return this.v1Path(ctx, 'individual', format, 'Communication', '_batch'); }
999
- individualCommunicationPollPath(ctx, format) { return this.v1Path(ctx, 'individual', format, 'Communication', '_batch-response'); }
1000
- individualCommunicationSearchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'Communication', '_search'); }
1001
- individualCommunicationSearchPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'Communication', '_search-response'); }
1002
- individualBundleSearchPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'Bundle', '_search'); }
1003
- individualBundleSearchPollPath(ctx) { return this.v1Path(ctx, 'individual', 'org.hl7.fhir.r4', 'Bundle', '_search-response'); }
1004
- identityTokenExchangePath(ctx) {
1005
- return `/${encodeURIComponent('host')}/cds-${encodeURIComponent(ctx.jurisdiction)}/v1/${encodeURIComponent(ctx.sector)}/${encodeURIComponent(ctx.tenantId)}/identity/auth/_exchange`;
1006
- }
1007
- identityTokenExchangePollPath(ctx) {
1008
- return `/${encodeURIComponent('host')}/cds-${encodeURIComponent(ctx.jurisdiction)}/v1/${encodeURIComponent(ctx.sector)}/${encodeURIComponent(ctx.tenantId)}/identity/auth/_exchange-response`;
1009
- }
1010
- identityDeviceDcrPath(ctx) {
1011
- return `/${encodeURIComponent('host')}/cds-${encodeURIComponent(ctx.jurisdiction)}/v1/${encodeURIComponent(ctx.sector)}/${encodeURIComponent(ctx.tenantId)}/identity/auth/_dcr`;
1012
- }
1013
- identityDeviceDcrPollPath(ctx) {
1014
- return `/${encodeURIComponent('host')}/cds-${encodeURIComponent(ctx.jurisdiction)}/v1/${encodeURIComponent(ctx.sector)}/${encodeURIComponent(ctx.tenantId)}/identity/auth/_dcr-response`;
1015
- }
1016
- identityOpenIdSmartTokenPath(ctx) {
1017
- return `/${encodeURIComponent(ctx.tenantId)}/cds-${encodeURIComponent(ctx.jurisdiction)}/v1/${encodeURIComponent(ctx.sector)}/identity/openid/smart/token`;
1018
- }
1019
- identityOpenIdSmartTokenPollPath(ctx) {
1020
- return `/${encodeURIComponent(ctx.tenantId)}/cds-${encodeURIComponent(ctx.jurisdiction)}/v1/${encodeURIComponent(ctx.sector)}/identity/openid/smart/_batch-response`;
1021
- }
1022
- appendHttpTrace(entry) {
1023
- if (!this.httpTraceFile)
1024
- return;
1025
- try {
1026
- fs.mkdirSync(path.dirname(this.httpTraceFile), { recursive: true });
1027
- fs.appendFileSync(this.httpTraceFile, `${JSON.stringify(entry)}\n`);
1028
- }
1029
- catch {
1030
- // Tracing must never break runtime requests.
1031
- }
1032
- }
1033
- parseTraceBody(body) {
1034
- if (body == null)
1035
- return undefined;
1036
- if (typeof body === 'string')
1037
- return this.parseTraceRawText(body);
1038
- if (body instanceof URLSearchParams)
1039
- return Object.fromEntries(body.entries());
1040
- return '[non-text-body]';
1041
- }
1042
- parseTraceRawText(raw) {
1043
- if (!raw)
1044
- return '';
1045
- try {
1046
- return JSON.parse(raw);
1047
- }
1048
- catch {
1049
- return raw;
1050
- }
1051
- }
1052
- redactTraceValue(value) {
1053
- if (value === undefined)
1054
- return value;
1055
- const serialized = JSON.stringify(value, (key, nestedValue) => {
1056
- if (/token|authorization|secret|password/i.test(String(key || ''))) {
1057
- return '[redacted]';
1058
- }
1059
- return nestedValue;
1060
- });
1061
- return serialized === undefined ? value : JSON.parse(serialized);
1062
- }
771
+ return wrapBundleAsGatewayTransactionMessage(input);
772
+ }
773
+ hostRegistryOrganizationTransactionPath(ctx) { return this.paths.hostRegistryOrganizationTransactionPath(ctx); }
774
+ hostRegistryOrganizationTransactionPollPath(ctx) { return this.paths.hostRegistryOrganizationTransactionPollPath(ctx); }
775
+ hostRegistryOrganizationIssuePath(ctx) { return this.paths.hostRegistryOrganizationIssuePath(ctx); }
776
+ hostRegistryOrganizationIssuePollPath(ctx) { return this.paths.hostRegistryOrganizationIssuePollPath(ctx); }
777
+ hostRegistryOrganizationActivatePath(ctx) { return this.paths.hostRegistryOrganizationActivatePath(ctx); }
778
+ hostRegistryOrganizationActivatePollPath(ctx) { return this.paths.hostRegistryOrganizationActivatePollPath(ctx); }
779
+ hostRegistryOrganizationDisablePath(ctx) { return this.paths.hostRegistryOrganizationDisablePath(ctx); }
780
+ hostRegistryOrganizationDisablePollPath(ctx) { return this.paths.hostRegistryOrganizationDisablePollPath(ctx); }
781
+ hostRegistryOrganizationPurgePath(ctx) { return this.paths.hostRegistryOrganizationPurgePath(ctx); }
782
+ hostRegistryOrganizationPurgePollPath(ctx) { return this.paths.hostRegistryOrganizationPurgePollPath(ctx); }
783
+ hostRegistryOrderBatchPath(ctx) { return this.paths.hostRegistryOrderBatchPath(ctx); }
784
+ hostRegistryOrderPollPath(ctx) { return this.paths.hostRegistryOrderPollPath(ctx); }
785
+ employeeBatchPath(ctx) { return this.paths.employeeBatchPath(ctx); }
786
+ employeePollPath(ctx) { return this.paths.employeePollPath(ctx); }
787
+ employeeSearchPath(ctx) { return this.paths.employeeSearchPath(ctx); }
788
+ employeeSearchPollPath(ctx) { return this.paths.employeeSearchPollPath(ctx); }
789
+ organizationLicenseSearchPath(ctx) { return this.paths.organizationLicenseSearchPath(ctx); }
790
+ organizationLicenseSearchPollPath(ctx) { return this.paths.organizationLicenseSearchPollPath(ctx); }
791
+ organizationDidBindingPath(ctx) { return this.paths.organizationDidBindingPath(ctx); }
792
+ organizationDidBindingPollPath(ctx) { return this.paths.organizationDidBindingPollPath(ctx); }
793
+ organizationLicenseOfferSearchPath(ctx) { return this.paths.organizationLicenseOfferSearchPath(ctx); }
794
+ organizationLicenseOfferSearchPollPath(ctx) { return this.paths.organizationLicenseOfferSearchPollPath(ctx); }
795
+ organizationLicenseOrderSearchPath(ctx) { return this.paths.organizationLicenseOrderSearchPath(ctx); }
796
+ organizationLicenseOrderSearchPollPath(ctx) { return this.paths.organizationLicenseOrderSearchPollPath(ctx); }
797
+ employeePurgePath(ctx) { return this.paths.employeePurgePath(ctx); }
798
+ employeePurgePollPath(ctx) { return this.paths.employeePurgePollPath(ctx); }
799
+ individualFamilyOrganizationBatchPath(ctx) { return this.paths.individualFamilyOrganizationBatchPath(ctx); }
800
+ individualFamilyOrganizationPollPath(ctx) { return this.paths.individualFamilyOrganizationPollPath(ctx); }
801
+ individualFamilyOrganizationSearchPath(ctx) { return this.paths.individualFamilyOrganizationSearchPath(ctx); }
802
+ individualFamilyOrganizationSearchPollPath(ctx) { return this.paths.individualFamilyOrganizationSearchPollPath(ctx); }
803
+ individualFamilyOrganizationTransactionPath(ctx) { return this.paths.individualFamilyOrganizationTransactionPath(ctx); }
804
+ individualFamilyOrganizationTransactionPollPath(ctx) { return this.paths.individualFamilyOrganizationTransactionPollPath(ctx); }
805
+ individualFamilyOrganizationDisablePath(ctx) { return this.paths.individualFamilyOrganizationDisablePath(ctx); }
806
+ individualFamilyOrganizationDisablePollPath(ctx) { return this.paths.individualFamilyOrganizationDisablePollPath(ctx); }
807
+ individualFamilyOrganizationPurgePath(ctx) { return this.paths.individualFamilyOrganizationPurgePath(ctx); }
808
+ individualFamilyOrganizationPurgePollPath(ctx) { return this.paths.individualFamilyOrganizationPurgePollPath(ctx); }
809
+ individualLicenseSearchPath(ctx) { return this.paths.individualLicenseSearchPath(ctx); }
810
+ individualLicenseSearchPollPath(ctx) { return this.paths.individualLicenseSearchPollPath(ctx); }
811
+ individualLicenseOfferSearchPath(ctx) { return this.paths.individualLicenseOfferSearchPath(ctx); }
812
+ individualLicenseOfferSearchPollPath(ctx) { return this.paths.individualLicenseOfferSearchPollPath(ctx); }
813
+ individualLicenseOrderSearchPath(ctx) { return this.paths.individualLicenseOrderSearchPath(ctx); }
814
+ individualLicenseOrderSearchPollPath(ctx) { return this.paths.individualLicenseOrderSearchPollPath(ctx); }
815
+ individualFamilyOrderBatchPath(ctx) { return this.paths.individualFamilyOrderBatchPath(ctx); }
816
+ individualFamilyOrderPollPath(ctx) { return this.paths.individualFamilyOrderPollPath(ctx); }
817
+ individualRelatedPersonBatchPath(ctx) { return this.paths.individualRelatedPersonBatchPath(ctx); }
818
+ individualRelatedPersonPollPath(ctx) { return this.paths.individualRelatedPersonPollPath(ctx); }
819
+ individualRelatedPersonPurgePath(ctx) { return this.paths.individualRelatedPersonPurgePath(ctx); }
820
+ individualRelatedPersonPurgePollPath(ctx) { return this.paths.individualRelatedPersonPurgePollPath(ctx); }
821
+ individualConsentR4BatchPath(ctx) { return this.paths.individualConsentR4BatchPath(ctx); }
822
+ individualConsentR4PollPath(ctx) { return this.paths.individualConsentR4PollPath(ctx); }
823
+ individualCommunicationBatchPath(ctx, format) { return this.paths.individualCommunicationBatchPath(ctx, format); }
824
+ individualCommunicationPollPath(ctx, format) { return this.paths.individualCommunicationPollPath(ctx, format); }
825
+ individualCommunicationSearchPath(ctx) { return this.paths.individualCommunicationSearchPath(ctx); }
826
+ individualCommunicationSearchPollPath(ctx) { return this.paths.individualCommunicationSearchPollPath(ctx); }
827
+ individualBundleSearchPath(ctx) { return this.paths.individualBundleSearchPath(ctx); }
828
+ individualBundleSearchPollPath(ctx) { return this.paths.individualBundleSearchPollPath(ctx); }
829
+ identityTokenExchangePath(ctx) { return this.paths.identityTokenExchangePath(ctx); }
830
+ identityTokenExchangePollPath(ctx) { return this.paths.identityTokenExchangePollPath(ctx); }
831
+ identityDeviceDcrPath(ctx) { return this.paths.identityDeviceDcrPath(ctx); }
832
+ identityDeviceDcrPollPath(ctx) { return this.paths.identityDeviceDcrPollPath(ctx); }
833
+ identityOpenIdSmartTokenPath(ctx) { return this.paths.identityOpenIdSmartTokenPath(ctx); }
834
+ identityOpenIdSmartTokenPollPath(ctx) { return this.paths.identityOpenIdSmartTokenPollPath(ctx); }
1063
835
  }
1064
836
  /**
1065
837
  * @deprecated Prefer `HttpRuntimeClient`.
1066
838
  */
1067
839
  export class NodeHttpClient extends HttpRuntimeClient {
1068
840
  }
1069
- function runtimeUuid() {
1070
- const fromCrypto = globalThis.crypto?.randomUUID?.();
1071
- if (fromCrypto)
1072
- return fromCrypto;
1073
- return `fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
1074
- }