gdc-sdk-node-ts 2.1.0 → 2.1.1

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.
@@ -70,6 +70,7 @@ export declare class HttpRuntimeClient implements NodeRuntimeClient {
70
70
  private readonly requestTimeoutMs;
71
71
  private readonly httpTraceFile?;
72
72
  private readonly tokenCache;
73
+ private warnedDefaultHostNetwork;
73
74
  /**
74
75
  * @param options.baseUrl Gateway base URL without trailing slash.
75
76
  * @param options.interopMode Optional runtime interoperability mode from the SDK config layer (`demo`, `compat`, `strict`).
@@ -432,18 +433,19 @@ export declare class HttpRuntimeClient implements NodeRuntimeClient {
432
433
  private wrapBundleAsGatewayTransactionMessage;
433
434
  private hostRegistryPath;
434
435
  /**
435
- * Resolves the host route segment without forcing callers to remember whether
436
- * the same raw string is named `hostNetwork` or `sector` in a given layer.
436
+ * Resolves the host route segment without allowing tenant-route `sector`
437
+ * semantics to leak into host onboarding.
437
438
  *
438
439
  * Step by step:
439
440
  * - host routes use `/host/cds-{jurisdiction}/v1/{host-network}`
440
441
  * - tenant routes use `/{tenantId}/cds-{jurisdiction}/v1/{tenant-sector}`
441
- * - older live tests and adapters sometimes passed the host segment under
442
- * `sector`, which is semantically wrong for host routes
443
- * - new code should prefer `hostNetwork`
444
- * - compatibility code may pass `hostNetworkOrTenantSector`
442
+ * - passing the host segment under `sector` is rejected because that name is
443
+ * reserved for tenant business sectors such as `health-care`
444
+ * - compatibility code may still pass `hostNetworkOrTenantSector`, but the
445
+ * value must still be one of the allowed host runtime/network selectors
445
446
  */
446
447
  private requireHostRouteContext;
448
+ private isSupportedHostNetwork;
447
449
  hostRegistryOrganizationTransactionPath(ctx?: HostRouteContext): string;
448
450
  hostRegistryOrganizationTransactionPollPath(ctx?: HostRouteContext): string;
449
451
  hostRegistryOrganizationIssuePath(ctx?: HostRouteContext): string;
@@ -41,6 +41,7 @@ export class HttpRuntimeClient {
41
41
  */
42
42
  constructor(options) {
43
43
  this.tokenCache = new Map();
44
+ this.warnedDefaultHostNetwork = false;
44
45
  this.baseUrl = String(options.baseUrl || '').replace(/\/+$/, '');
45
46
  this.runtimeVpToken = String(options.runtimeVpToken || '').trim() || undefined;
46
47
  this.bearerToken = String(options.bearerToken || '').trim()
@@ -913,32 +914,52 @@ export class HttpRuntimeClient {
913
914
  return `/host/cds-${encodeURIComponent(hostCtx.jurisdiction)}/v1/${encodeURIComponent(hostCtx.hostNetwork || '')}/registry/org.schema/${encodeURIComponent(resourceType)}/${encodeURIComponent(action)}`;
914
915
  }
915
916
  /**
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.
917
+ * Resolves the host route segment without allowing tenant-route `sector`
918
+ * semantics to leak into host onboarding.
918
919
  *
919
920
  * Step by step:
920
921
  * - host routes use `/host/cds-{jurisdiction}/v1/{host-network}`
921
922
  * - 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`
923
+ * - passing the host segment under `sector` is rejected because that name is
924
+ * reserved for tenant business sectors such as `health-care`
925
+ * - compatibility code may still pass `hostNetworkOrTenantSector`, but the
926
+ * value must still be one of the allowed host runtime/network selectors
926
927
  */
927
928
  requireHostRouteContext(ctx) {
928
929
  const hostCtx = (ctx || {});
929
930
  const runtimeCtx = (this.ctx || {});
930
931
  const jurisdiction = String(hostCtx.jurisdiction || this.ctx?.jurisdiction || '').trim();
931
- const hostNetwork = String(hostCtx.hostNetwork
932
- || hostCtx.hostNetworkOrTenantSector
933
- || hostCtx.sector
934
- || runtimeCtx.hostNetwork
932
+ const explicitHostNetwork = String(hostCtx.hostNetwork || runtimeCtx.hostNetwork || '').trim();
933
+ const compatibilityHostNetwork = String(hostCtx.hostNetworkOrTenantSector
935
934
  || runtimeCtx.hostNetworkOrTenantSector
936
- || runtimeCtx.sector
937
935
  || '').trim();
938
- if (!jurisdiction || !hostNetwork)
936
+ const deprecatedSector = String(hostCtx.sector || '').trim();
937
+ if (!explicitHostNetwork && !compatibilityHostNetwork && deprecatedSector) {
938
+ throw new Error(`Host route context must use 'hostNetwork', not 'sector'. Received deprecated sector='${deprecatedSector}'.`);
939
+ }
940
+ const hostNetwork = String(explicitHostNetwork
941
+ || compatibilityHostNetwork
942
+ || '').trim();
943
+ if (!jurisdiction)
939
944
  throw new Error('Host route context is required.');
945
+ if (!hostNetwork) {
946
+ if (!this.warnedDefaultHostNetwork) {
947
+ this.warnedDefaultHostNetwork = true;
948
+ console.warn("[gdc-sdk-node-ts] Missing hostNetwork in host route context. Defaulting to 'test'. Pass hostNetwork explicitly to avoid environment drift.");
949
+ }
950
+ return { jurisdiction, hostNetwork: 'test' };
951
+ }
952
+ if (!this.isSupportedHostNetwork(hostNetwork)) {
953
+ throw new Error(`Invalid hostNetwork '${hostNetwork}'. Allowed values: test, local-network, test-network, network.`);
954
+ }
940
955
  return { jurisdiction, hostNetwork };
941
956
  }
957
+ isSupportedHostNetwork(value) {
958
+ return (value === 'test'
959
+ || value === 'local-network'
960
+ || value === 'test-network'
961
+ || value === 'network');
962
+ }
942
963
  hostRegistryOrganizationTransactionPath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.Transaction); }
943
964
  hostRegistryOrganizationTransactionPollPath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.TransactionResponse); }
944
965
  hostRegistryOrganizationIssuePath(ctx) { return this.hostRegistryPath(ctx, 'Organization', GwCoreLifecycleAction.Issue); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-sdk-node-ts",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Next-generation Node runtime package for the GDC SDK family",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Antifraud Services Inc.",