@tetrascience-npm/ts-connectors-sdk 3.2.0 → 4.0.0-beta.182.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +42 -3
  3. package/dist/api-tests/auth-token.test.js +25 -37
  4. package/dist/api-tests/auth-token.test.js.map +1 -1
  5. package/dist/api-tests/aws-timeout.test.d.ts +2 -0
  6. package/dist/api-tests/aws-timeout.test.d.ts.map +1 -0
  7. package/dist/api-tests/aws-timeout.test.js +251 -0
  8. package/dist/api-tests/aws-timeout.test.js.map +1 -0
  9. package/dist/api-tests/fixture/config.d.ts +4 -0
  10. package/dist/api-tests/fixture/config.d.ts.map +1 -1
  11. package/dist/api-tests/fixture/config.js +1 -0
  12. package/dist/api-tests/fixture/config.js.map +1 -1
  13. package/dist/api-tests/fixture/data-app-api.d.ts +60 -0
  14. package/dist/api-tests/fixture/data-app-api.d.ts.map +1 -0
  15. package/dist/api-tests/fixture/data-app-api.js +89 -0
  16. package/dist/api-tests/fixture/data-app-api.js.map +1 -0
  17. package/dist/api-tests/fixture/fixture.d.ts +1 -0
  18. package/dist/api-tests/fixture/fixture.d.ts.map +1 -1
  19. package/dist/api-tests/fixture/test-proxy-server.d.ts +74 -0
  20. package/dist/api-tests/fixture/test-proxy-server.d.ts.map +1 -0
  21. package/dist/api-tests/fixture/test-proxy-server.js +240 -0
  22. package/dist/api-tests/fixture/test-proxy-server.js.map +1 -0
  23. package/dist/src/auth/aws-client-provider.d.ts +2 -0
  24. package/dist/src/auth/aws-client-provider.d.ts.map +1 -1
  25. package/dist/src/auth/aws-env-client-provider.d.ts +7 -2
  26. package/dist/src/auth/aws-env-client-provider.d.ts.map +1 -1
  27. package/dist/src/auth/aws-env-client-provider.js +9 -6
  28. package/dist/src/auth/aws-env-client-provider.js.map +1 -1
  29. package/dist/src/auth/aws-refresh-client-provider.d.ts +8 -2
  30. package/dist/src/auth/aws-refresh-client-provider.d.ts.map +1 -1
  31. package/dist/src/auth/aws-refresh-client-provider.js +9 -6
  32. package/dist/src/auth/aws-refresh-client-provider.js.map +1 -1
  33. package/dist/src/index.d.ts +1 -0
  34. package/dist/src/index.d.ts.map +1 -1
  35. package/dist/src/index.js +4 -0
  36. package/dist/src/index.js.map +1 -1
  37. package/dist/src/tdp-client.d.ts +46 -10
  38. package/dist/src/tdp-client.d.ts.map +1 -1
  39. package/dist/src/tdp-client.js +128 -40
  40. package/dist/src/tdp-client.js.map +1 -1
  41. package/dist/test/auth/aws-env-client-provider.test.js +6 -2
  42. package/dist/test/auth/aws-env-client-provider.test.js.map +1 -1
  43. package/dist/test/auth/aws-refresh-client-provider.test.js +6 -2
  44. package/dist/test/auth/aws-refresh-client-provider.test.js.map +1 -1
  45. package/dist/test/tdp-client.test.js +350 -7
  46. package/dist/test/tdp-client.test.js.map +1 -1
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +3 -3
@@ -6,4 +6,5 @@ export * from './tdp-client';
6
6
  export * from './types';
7
7
  export * from './auth';
8
8
  export * from './schemas';
9
+ export { loadTdpCertificates, loadCertificatesFromLocalVolume } from './certificates';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/src/index.js CHANGED
@@ -14,6 +14,7 @@ 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.loadCertificatesFromLocalVolume = exports.loadTdpCertificates = void 0;
17
18
  __exportStar(require("./logger"), exports);
18
19
  __exportStar(require("./api"), exports);
19
20
  __exportStar(require("./connector"), exports);
@@ -22,4 +23,7 @@ __exportStar(require("./tdp-client"), exports);
22
23
  __exportStar(require("./types"), exports);
23
24
  __exportStar(require("./auth"), exports);
24
25
  __exportStar(require("./schemas"), exports);
26
+ var certificates_1 = require("./certificates");
27
+ Object.defineProperty(exports, "loadTdpCertificates", { enumerable: true, get: function () { return certificates_1.loadTdpCertificates; } });
28
+ Object.defineProperty(exports, "loadCertificatesFromLocalVolume", { enumerable: true, get: function () { return certificates_1.loadCertificatesFromLocalVolume; } });
25
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wCAAsB;AACtB,8CAA4B;AAC5B,sDAAoC;AACpC,+CAA6B;AAC7B,0CAAwB;AACxB,yCAAuB;AACvB,4CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wCAAsB;AACtB,8CAA4B;AAC5B,sDAAoC;AACpC,+CAA6B;AAC7B,0CAAwB;AACxB,yCAAuB;AACvB,4CAA0B;AAC1B,+CAAsF;AAA7E,mHAAA,mBAAmB,OAAA;AAAE,+HAAA,+BAA+B,OAAA"}
@@ -117,12 +117,14 @@ export declare class TDPClient {
117
117
  private _manifest;
118
118
  get manifest(): ConnectorManifest | null | undefined;
119
119
  private awsClientProvider;
120
+ private awsNodeHttpHandlers;
120
121
  private authTokenProvider;
121
122
  private isProxyInitialized;
122
123
  private isAwsInitialized;
123
124
  private awsInitPromise;
124
125
  private userAgent;
125
126
  private _certificates;
127
+ private _tdpDeploymentCertificates;
126
128
  listeningForCommands: boolean;
127
129
  constructor(options?: TDPClientOptions);
128
130
  get isInitialized(): "" | {
@@ -148,6 +150,12 @@ export declare class TDPClient {
148
150
  getCertificates: (options?: ApiOtherOptions) => Promise<import("./api").GetCertificatesResponse>;
149
151
  } | undefined;
150
152
  get certificates(): CertificateDto[];
153
+ /**
154
+ * TDP deployment certificates loaded during init() from local volume or S3.
155
+ * Automatically included in CA bundles created by createAxiosInstance and
156
+ * createProxyAgentsForBaseUrl when includeAdditionalCertificates is truthy.
157
+ */
158
+ get tdpDeploymentCertificates(): readonly string[];
151
159
  private setUserAgent;
152
160
  /**
153
161
  * Assert that the client is initialized with JWT and API.
@@ -192,7 +200,7 @@ export declare class TDPClient {
192
200
  getCertificates: (options?: ApiOtherOptions) => Promise<import("./api").GetCertificatesResponse>;
193
201
  };
194
202
  protected getAdditionalAxiosHeaders(): Headers;
195
- createAxiosInstanceWithCertificatesAndHeaders(tdpEndpoint: string, orgSlug: string, jwt: string, certificates: string[], timeout_ms?: number): AxiosInstance;
203
+ createAxiosInstanceWithCertificatesAndHeaders(tdpEndpoint: string, orgSlug: string, jwt: string, certificates?: string[], timeout_ms?: number): AxiosInstance;
196
204
  /**
197
205
  * Creates an axios instance for the given base url, with the given config and rejectUnauthorized, and using
198
206
  * the appropriate proxies configured for the connector. TDPClient.init must be called first. baseUrl is required
@@ -200,7 +208,8 @@ export declare class TDPClient {
200
208
  * @param options.baseUrl base url for proxy selection when this connector is hosted in a Hub
201
209
  * @param options.config axios config
202
210
  * @param options.rejectUnauthorized rejectUnauthorized, passed to the underlying http(s) Agent
203
- * @param options.includeAdditionalCertificates whether to include organization certificates in the http agent
211
+ * @param options.includeAdditionalCertificates Whether to include TDP deployment certificates and
212
+ * organization certificates in the http agent. Defaults to true.
204
213
  * @param timeout_ms - The axios http request timeout in milliseconds
205
214
  * @returns an Axios instance configured with these settings and with proxying http(s) Agents
206
215
  */
@@ -221,11 +230,12 @@ export declare class TDPClient {
221
230
  * a related axios bug.
222
231
  * @param options.baseURL The URL that determines which proxy env var (http_proxy, https_proxy, no_proxy) should apply
223
232
  * @param options.rejectUnauthorized Whether to inject unauthorized requests in the httpsAgent
224
- * @param options.includeAdditionalCertificates Whether to include organization certificates in the httpsAgent.
225
- * If omitted or set falsy: only Node's built-in certificates will be included
226
- * If set to true, built-in plus org certificates will be included.
227
- * If set to an array, built-in plus this array of certificates will be included.
228
- * @returns httpAgent and httpsAgent with proxy, rejectUnauthorized, and includeAdditionalCertificates settings
233
+ * @param options.includeAdditionalCertificates Whether to include TDP deployment certificates and
234
+ * organization certificates in the httpsAgent. When true (the default), the CA bundle includes
235
+ * Node built-in certs, TDP deployment certs loaded during init(), and org certs from the TDP API.
236
+ * When false, only Node built-in certs are included.
237
+ * If set to an array, built-in certs plus this array of certificates will be included.
238
+ * @returns httpAgent and httpsAgent with proxy, rejectUnauthorized, and certificate settings
229
239
  */
230
240
  createProxyAgentsForBaseUrl({ baseUrl, rejectUnauthorized, includeAdditionalCertificates, }: {
231
241
  baseUrl: string;
@@ -236,13 +246,38 @@ export declare class TDPClient {
236
246
  httpsAgent: https.Agent;
237
247
  } | undefined;
238
248
  /**
239
- * Creates a NodeHttpHandler using npm proxy-agent, which will select a correct proxy per request.
249
+ * Creates NodeHttpHandlers for AWS clients (S3, SQS, and generic) with proxy support.
250
+ *
251
+ * When the `IAM_PROXY` environment variable is set, all three handlers use a fixed
252
+ * `HttpsProxyAgent` pointed at that URL, providing an explicit proxy override for AWS
253
+ * traffic in network-restricted deployments.
254
+ *
255
+ * When `IAM_PROXY` is not set, handlers fall back to `proxy-agent`, which performs
256
+ * per-request proxy selection based on the standard `http_proxy`/`https_proxy`
257
+ * environment variables.
258
+ *
240
259
  * Only works for connections where rejectUnauthorized or additional certificates are not needed,
241
260
  * such as to AWS or trusted servers; if you need to connect to an untrusted server or use organization certificates,
242
261
  * use createProxyAgentsForBaseUrl and specify a baseUrl and (optionally) rejectUnauthorized: false.
243
- * @returns A NodeHttpHandler with agents that will choose a correct proxy for each request.
262
+ * @param options - Optional timeout configuration for the handlers
263
+ * @param options.s3ConnectionTimeout - Connection timeout for S3 handler in milliseconds (default: 10000)
264
+ * @param options.s3SocketTimeout - Socket timeout for S3 handler in milliseconds (default: 10000)
265
+ * @param options.sqsRequestTimeout - Request timeout for SQS handler in milliseconds (default: 20000)
266
+ * @param options.genericRequestTimeout - Request timeout for generic AWS handler in milliseconds (default: 120000)
267
+ * @returns a set of proxy-aware NodeHttpHandlers for S3, SQS, and generic AWS clients
244
268
  */
245
- createProxyNodeHttpHandler(): NodeHttpHandler;
269
+ createProxyAWSNodeHttpHandlers(options?: {
270
+ s3ConnectionTimeout?: number;
271
+ s3SocketTimeout?: number;
272
+ sqsRequestTimeout?: number;
273
+ genericRequestTimeout?: number;
274
+ }): {
275
+ s3Handler: NodeHttpHandler;
276
+ sqsHandler: NodeHttpHandler;
277
+ genericHandler: NodeHttpHandler;
278
+ };
279
+ private ensureAwsClientDependenciesInitialized;
280
+ createAwsClient<TClient>(ClientClass: new (config: object) => TClient, overrides?: Record<string, unknown>): TClient;
246
281
  private createLogger;
247
282
  /**
248
283
  * Initialize the TDPClient.
@@ -357,5 +392,6 @@ export declare class TDPClient {
357
392
  transformTraceMetadata(trace: Trace): {};
358
393
  private buildS3Key;
359
394
  }
395
+ export declare const shouldRejectUnauthorized: () => boolean;
360
396
  export {};
361
397
  //# sourceMappingURL=tdp-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tdp-client.d.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e;IAIhF,SAAS,CAAC,OAAO,CAAC,EAAE,eAAe;IAInC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrC,OAAO,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAKtC;;;;OAIG;IACH,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;IAa9C;;;;;;;;;OASG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,GAAE,OAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsI/G;;;;;;;;OAQG;IACH,sBAAsB,CAAC,KAAK,EAAE,KAAK;IAInC,OAAO,CAAC,UAAU;CAInB;AAID,eAAO,MAAM,wBAAwB,eAMpC,CAAC"}
@@ -56,7 +56,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
56
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
57
57
  };
58
58
  Object.defineProperty(exports, "__esModule", { value: true });
59
- exports.TDPClient = exports.Directive = void 0;
59
+ exports.shouldRejectUnauthorized = exports.TDPClient = exports.Directive = void 0;
60
60
  exports.sanitizeConfig = sanitizeConfig;
61
61
  const fs = __importStar(require("node:fs"));
62
62
  const s3 = __importStar(require("@aws-sdk/client-s3"));
@@ -70,6 +70,7 @@ const fsPromises = __importStar(require("fs/promises"));
70
70
  const hpagent_1 = require("hpagent");
71
71
  const http = __importStar(require("http"));
72
72
  const https = __importStar(require("https"));
73
+ const https_proxy_agent_1 = require("https-proxy-agent");
73
74
  const proxy_agent_1 = require("proxy-agent");
74
75
  const proxy_from_env_1 = require("proxy-from-env");
75
76
  const tls = __importStar(require("tls"));
@@ -82,7 +83,7 @@ const certificates_1 = require("./certificates");
82
83
  const checksums_1 = require("./checksums");
83
84
  const config_1 = require("./config");
84
85
  const constants_1 = require("./constants");
85
- const https_proxy_agent_1 = require("./https-proxy-agent");
86
+ const https_proxy_agent_2 = require("./https-proxy-agent");
86
87
  const logger_1 = require("./logger");
87
88
  const manifest_1 = require("./manifest");
88
89
  const schemas_1 = require("./schemas");
@@ -90,7 +91,13 @@ const types_1 = require("./types");
90
91
  const utils_1 = require("./utils");
91
92
  const hubProxyPath = '/etc/hub/proxy.env';
92
93
  const HP_AGENT = 'hpagent';
93
- const AWS_SQS_TIMEOUT = 20 * 1000;
94
+ const AWS_SQS_TIMEOUT_MS = 25 * 1000;
95
+ // TODO: these are called defaults at the moment, but in this initial
96
+ // implementation they are all you get. At some point revisit
97
+ const DEFAULT_S3_CONNECTION_TIMEOUT_MS = 10 * 1000;
98
+ const DEFAULT_S3_SOCKET_TIMEOUT_MS = 10 * 1000;
99
+ // this applies to SSM and CloudWatch, at the moment
100
+ const DEFAULT_GENERIC_AWS_REQUEST_TIMEOUT_MS = 120 * 1000;
94
101
  // Key in connector KV store for connector SDK settings
95
102
  // The value is expected to be a JSON object
96
103
  const TS_SDK_SETTINGS_KEY = 'TS_SDK';
@@ -150,6 +157,7 @@ class TDPClient {
150
157
  this.config = new config_1.TDPClientConfig(options);
151
158
  this.logger = this.createLogger();
152
159
  this._certificates = [];
160
+ this._tdpDeploymentCertificates = [];
153
161
  }
154
162
  get isInitialized() {
155
163
  var _a;
@@ -161,6 +169,14 @@ class TDPClient {
161
169
  }
162
170
  return this._certificates;
163
171
  }
172
+ /**
173
+ * TDP deployment certificates loaded during init() from local volume or S3.
174
+ * Automatically included in CA bundles created by createAxiosInstance and
175
+ * createProxyAgentsForBaseUrl when includeAdditionalCertificates is truthy.
176
+ */
177
+ get tdpDeploymentCertificates() {
178
+ return this._tdpDeploymentCertificates;
179
+ }
164
180
  setUserAgent(userAgent) {
165
181
  var _a;
166
182
  this.logger.debug('Setting TDPClient user agent, will be used for all API requests and axios clients created from this point on', {
@@ -222,11 +238,13 @@ class TDPClient {
222
238
  return headers;
223
239
  }
224
240
  /*
225
- * Creates an axios instance with extra provided certificates, TDP jwt + orgSlug headers.
241
+ * Creates an axios instance with TDP jwt + orgSlug headers and TDP deployment certificates.
242
+ * When certificates are provided, they are passed as explicit additional certificates.
243
+ * When omitted, deployment certificates from the instance (loaded during init) are used automatically.
226
244
  * @param tdpEndpoint - The TDP endpoint
227
245
  * @param orgSlug - The organization slug
228
246
  * @param jwt - The TDP jwt
229
- * @param certificates - The extra certificates to include
247
+ * @param certificates - Optional extra certificates to include. If omitted, uses instance deployment certs via includeAdditionalCertificates: true.
230
248
  * @param timeout_ms - The axios http request timeout in milliseconds
231
249
  */
232
250
  createAxiosInstanceWithCertificatesAndHeaders(tdpEndpoint, orgSlug, jwt, certificates, timeout_ms) {
@@ -235,8 +253,8 @@ class TDPClient {
235
253
  this.logger.info('Creating axios instance with certificates and headers', { baseUrl: tdpEndpoint, timeout });
236
254
  return axios_1.default.create(Object.assign(Object.assign({}, this.createProxyAgentsForBaseUrl({
237
255
  baseUrl: tdpEndpoint,
238
- rejectUnauthorized: shouldRejectUnauthorized(),
239
- includeAdditionalCertificates: certificates,
256
+ rejectUnauthorized: (0, exports.shouldRejectUnauthorized)(),
257
+ includeAdditionalCertificates: certificates !== null && certificates !== void 0 ? certificates : true,
240
258
  })), { proxy: false, timeout, baseURL: tdpEndpoint, headers: Object.assign({ [constants_1.HTTPAuthKeys.scopeToOrgHeaderKey]: orgSlug, [constants_1.HTTPAuthKeys.jwtAuthTokenHeaderKey]: jwt }, additionalHeaders) }));
241
259
  }
242
260
  /**
@@ -246,14 +264,20 @@ class TDPClient {
246
264
  * @param options.baseUrl base url for proxy selection when this connector is hosted in a Hub
247
265
  * @param options.config axios config
248
266
  * @param options.rejectUnauthorized rejectUnauthorized, passed to the underlying http(s) Agent
249
- * @param options.includeAdditionalCertificates whether to include organization certificates in the http agent
267
+ * @param options.includeAdditionalCertificates Whether to include TDP deployment certificates and
268
+ * organization certificates in the http agent. Defaults to true.
250
269
  * @param timeout_ms - The axios http request timeout in milliseconds
251
270
  * @returns an Axios instance configured with these settings and with proxying http(s) Agents
252
271
  */
253
272
  createAxiosInstance({ baseUrl, config, timeout_ms, rejectUnauthorized = true, includeAdditionalCertificates = true, }) {
254
273
  this.assertInitialized();
255
274
  const timeout = timeout_ms !== undefined ? timeout_ms : this.config.httpRequestTimeout;
256
- this.logger.info('Creating axios instance', { baseUrl, config: sanitizeConfig(config), rejectUnauthorized, timeout });
275
+ this.logger.info('Creating axios instance', {
276
+ baseUrl,
277
+ config: sanitizeConfig(config),
278
+ rejectUnauthorized,
279
+ timeout,
280
+ });
257
281
  const headers = this.getAdditionalAxiosHeaders();
258
282
  return axios_1.default.create(Object.assign(Object.assign(Object.assign({ baseURL: baseUrl, timeout }, this.createProxyAgentsForBaseUrl({ baseUrl, rejectUnauthorized, includeAdditionalCertificates })), { proxy: false, headers }), config));
259
283
  }
@@ -267,20 +291,25 @@ class TDPClient {
267
291
  * a related axios bug.
268
292
  * @param options.baseURL The URL that determines which proxy env var (http_proxy, https_proxy, no_proxy) should apply
269
293
  * @param options.rejectUnauthorized Whether to inject unauthorized requests in the httpsAgent
270
- * @param options.includeAdditionalCertificates Whether to include organization certificates in the httpsAgent.
271
- * If omitted or set falsy: only Node's built-in certificates will be included
272
- * If set to true, built-in plus org certificates will be included.
273
- * If set to an array, built-in plus this array of certificates will be included.
274
- * @returns httpAgent and httpsAgent with proxy, rejectUnauthorized, and includeAdditionalCertificates settings
294
+ * @param options.includeAdditionalCertificates Whether to include TDP deployment certificates and
295
+ * organization certificates in the httpsAgent. When true (the default), the CA bundle includes
296
+ * Node built-in certs, TDP deployment certs loaded during init(), and org certs from the TDP API.
297
+ * When false, only Node built-in certs are included.
298
+ * If set to an array, built-in certs plus this array of certificates will be included.
299
+ * @returns httpAgent and httpsAgent with proxy, rejectUnauthorized, and certificate settings
275
300
  */
276
301
  createProxyAgentsForBaseUrl({ baseUrl, rejectUnauthorized = true, includeAdditionalCertificates = true, }) {
277
302
  this.assertProxyInitialized();
278
303
  this.logger.info('Checking proxy for url', { baseUrl });
279
304
  const proxyUrl = (0, proxy_from_env_1.getProxyForUrl)(baseUrl);
280
305
  const builtInCertStrings = tls.rootCertificates;
306
+ const deploymentCertStrings = includeAdditionalCertificates ? this._tdpDeploymentCertificates : [];
281
307
  const orgCertStrings = includeAdditionalCertificates === true ? this.certificates.map((c) => c.content) : [];
282
308
  const additionalCertStrings = Array.isArray(includeAdditionalCertificates) ? includeAdditionalCertificates : [];
283
- const ca = [...builtInCertStrings, ...orgCertStrings, ...additionalCertStrings];
309
+ const ca = [...builtInCertStrings, ...deploymentCertStrings, ...orgCertStrings, ...additionalCertStrings];
310
+ if (deploymentCertStrings.length > 0) {
311
+ this.logger.info(`Using ${deploymentCertStrings.length} TDP deployment certificates`);
312
+ }
284
313
  if (orgCertStrings.length > 0) {
285
314
  this.logger.info(`Using ${orgCertStrings.length} organization certificates`, {
286
315
  certificates: this.certificates.map((c) => ({ id: c.id, name: c.name })),
@@ -306,7 +335,7 @@ class TDPClient {
306
335
  }
307
336
  else {
308
337
  this.logger.info('Using default https agent');
309
- httpsAgent = new https_proxy_agent_1.PatchedHttpsProxyAgent(proxyUrl, {
338
+ httpsAgent = new https_proxy_agent_2.PatchedHttpsProxyAgent(proxyUrl, {
310
339
  ca,
311
340
  rejectUnauthorized,
312
341
  });
@@ -327,19 +356,72 @@ class TDPClient {
327
356
  return undefined;
328
357
  }
329
358
  /**
330
- * Creates a NodeHttpHandler using npm proxy-agent, which will select a correct proxy per request.
359
+ * Creates NodeHttpHandlers for AWS clients (S3, SQS, and generic) with proxy support.
360
+ *
361
+ * When the `IAM_PROXY` environment variable is set, all three handlers use a fixed
362
+ * `HttpsProxyAgent` pointed at that URL, providing an explicit proxy override for AWS
363
+ * traffic in network-restricted deployments.
364
+ *
365
+ * When `IAM_PROXY` is not set, handlers fall back to `proxy-agent`, which performs
366
+ * per-request proxy selection based on the standard `http_proxy`/`https_proxy`
367
+ * environment variables.
368
+ *
331
369
  * Only works for connections where rejectUnauthorized or additional certificates are not needed,
332
370
  * such as to AWS or trusted servers; if you need to connect to an untrusted server or use organization certificates,
333
371
  * use createProxyAgentsForBaseUrl and specify a baseUrl and (optionally) rejectUnauthorized: false.
334
- * @returns A NodeHttpHandler with agents that will choose a correct proxy for each request.
372
+ * @param options - Optional timeout configuration for the handlers
373
+ * @param options.s3ConnectionTimeout - Connection timeout for S3 handler in milliseconds (default: 10000)
374
+ * @param options.s3SocketTimeout - Socket timeout for S3 handler in milliseconds (default: 10000)
375
+ * @param options.sqsRequestTimeout - Request timeout for SQS handler in milliseconds (default: 20000)
376
+ * @param options.genericRequestTimeout - Request timeout for generic AWS handler in milliseconds (default: 120000)
377
+ * @returns a set of proxy-aware NodeHttpHandlers for S3, SQS, and generic AWS clients
335
378
  */
336
- createProxyNodeHttpHandler() {
379
+ createProxyAWSNodeHttpHandlers(options) {
380
+ var _a, _b, _c, _d;
337
381
  this.assertProxyInitialized();
338
- this.logger.info('Creating NodeHttpHandler');
339
- return new node_http_handler_1.NodeHttpHandler({
340
- httpAgent: new proxy_agent_1.ProxyAgent(),
341
- httpsAgent: new proxy_agent_1.ProxyAgent(),
382
+ this.logger.info('Creating NodeHttpHandlers for AWS clients');
383
+ const iamProxy = process.env.IAM_PROXY;
384
+ const makeAgent = () => (iamProxy ? new https_proxy_agent_1.HttpsProxyAgent(iamProxy) : new proxy_agent_1.ProxyAgent());
385
+ // because file uploads might take a long time, structure this using socket
386
+ // idle timeouts rather than request timeout
387
+ const s3Handler = new node_http_handler_1.NodeHttpHandler({
388
+ httpAgent: makeAgent(),
389
+ httpsAgent: makeAgent(),
390
+ connectionTimeout: (_a = options === null || options === void 0 ? void 0 : options.s3ConnectionTimeout) !== null && _a !== void 0 ? _a : DEFAULT_S3_CONNECTION_TIMEOUT_MS,
391
+ socketTimeout: (_b = options === null || options === void 0 ? void 0 : options.s3SocketTimeout) !== null && _b !== void 0 ? _b : DEFAULT_S3_SOCKET_TIMEOUT_MS,
392
+ });
393
+ const sqsHandler = new node_http_handler_1.NodeHttpHandler({
394
+ httpAgent: makeAgent(),
395
+ httpsAgent: makeAgent(),
396
+ requestTimeout: (_c = options === null || options === void 0 ? void 0 : options.sqsRequestTimeout) !== null && _c !== void 0 ? _c : AWS_SQS_TIMEOUT_MS,
397
+ throwOnRequestTimeout: true,
342
398
  });
399
+ const genericHandler = new node_http_handler_1.NodeHttpHandler({
400
+ httpAgent: makeAgent(),
401
+ httpsAgent: makeAgent(),
402
+ requestTimeout: (_d = options === null || options === void 0 ? void 0 : options.genericRequestTimeout) !== null && _d !== void 0 ? _d : DEFAULT_GENERIC_AWS_REQUEST_TIMEOUT_MS,
403
+ throwOnRequestTimeout: true,
404
+ });
405
+ return { s3Handler, sqsHandler, genericHandler };
406
+ }
407
+ ensureAwsClientDependenciesInitialized() {
408
+ if (!this.awsNodeHttpHandlers) {
409
+ this.awsNodeHttpHandlers = this.createProxyAWSNodeHttpHandlers();
410
+ }
411
+ if (!this.awsClientProvider) {
412
+ this.awsClientProvider = new auth_1.AwsEnvClientProvider(this.config.awsRegion, this.awsNodeHttpHandlers);
413
+ }
414
+ }
415
+ createAwsClient(ClientClass, overrides) {
416
+ if (!this.isProxyInitialized) {
417
+ throw new Error('AWS not initialized. Call init() first.');
418
+ }
419
+ this.ensureAwsClientDependenciesInitialized();
420
+ if (!this.awsClientProvider || !this.awsNodeHttpHandlers) {
421
+ throw new Error('AWS client dependencies are unavailable. Call init() first, and if AWS setup was deferred, ensure environment-based AWS configuration is available.');
422
+ }
423
+ const credentials = this.awsClientProvider.getCredentialsProvider();
424
+ return new ClientClass(Object.assign(Object.assign(Object.assign({ region: this.config.awsRegion }, (credentials && { credentials })), { requestHandler: this.awsNodeHttpHandlers.genericHandler }), overrides));
343
425
  }
344
426
  createLogger() {
345
427
  return new logger_1.Logger({
@@ -367,14 +449,18 @@ class TDPClient {
367
449
  this.authTokenProvider = new auth_1.UserSuppliedAuthTokenProvider(this.config.authToken);
368
450
  this.jwt = this.config.authToken;
369
451
  // Load certificates from local file only (no S3 access without AWS init)
370
- const localTdpCertificates = yield (0, certificates_1.loadCertificatesFromLocalVolume)(this.config, this.logger);
371
- this.api = new api_1.Api(this.config, this.createAxiosInstanceWithCertificatesAndHeaders(this.config.tdpEndpoint, this.config.orgSlug, this.jwt, localTdpCertificates), this.logger);
452
+ this._tdpDeploymentCertificates = yield (0, certificates_1.loadCertificatesFromLocalVolume)(this.config, this.logger);
453
+ this.api = new api_1.Api(this.config, this.createAxiosInstanceWithCertificatesAndHeaders(this.config.tdpEndpoint, this.config.orgSlug, this.jwt), this.logger);
372
454
  }
373
455
  // Priority 2: CONNECTOR_TOKEN env var (Hub connector flow)
374
456
  else if (process.env.CONNECTOR_TOKEN) {
375
- const localTdpCertificates = yield (0, certificates_1.loadCertificatesFromLocalVolume)(this.config, this.logger);
376
- const axiosClientWithLocalCertificates = this.createAxiosInstanceWithCertificatesAndHeaders(this.config.tdpEndpoint, this.config.orgSlug, process.env.CONNECTOR_TOKEN, localTdpCertificates);
377
- this.awsClientProvider = new auth_1.AwsRefreshClientProvider(this.createProxyNodeHttpHandler(), axiosClientWithLocalCertificates, this.config.awsRegion, this.config.connectorId, this.logger);
457
+ // Load local certs first for the bootstrap axios (S3 not yet available).
458
+ // These are set on the instance so createAxiosInstanceWithCertificatesAndHeaders
459
+ // picks them up via includeAdditionalCertificates: true.
460
+ this._tdpDeploymentCertificates = yield (0, certificates_1.loadCertificatesFromLocalVolume)(this.config, this.logger);
461
+ const axiosClientWithLocalCertificates = this.createAxiosInstanceWithCertificatesAndHeaders(this.config.tdpEndpoint, this.config.orgSlug, process.env.CONNECTOR_TOKEN);
462
+ this.awsNodeHttpHandlers = this.createProxyAWSNodeHttpHandlers();
463
+ this.awsClientProvider = new auth_1.AwsRefreshClientProvider(this.awsNodeHttpHandlers, axiosClientWithLocalCertificates, this.config.awsRegion, this.config.connectorId, this.logger);
378
464
  this.authTokenProvider = new auth_1.UserSuppliedAuthTokenProvider(process.env.CONNECTOR_TOKEN);
379
465
  if (!process.env.SKIP_CLOUDWATCH) {
380
466
  yield this.logger.startCloudwatch(this.awsClientProvider.getCloudwatchLogsClient());
@@ -386,13 +472,15 @@ class TDPClient {
386
472
  const authToken = yield this.authTokenProvider.getAuthToken();
387
473
  this.logger.info('Retrieved connector auth token');
388
474
  this.jwt = authToken.value;
389
- const tdpCertificates = yield (0, certificates_1.loadTdpCertificates)(this.awsClientProvider.getS3Client(), this.logger, this.config);
390
- this.api = new api_1.Api(this.config, this.createAxiosInstanceWithCertificatesAndHeaders(this.config.tdpEndpoint, this.config.orgSlug, this.jwt, tdpCertificates), this.logger);
475
+ // Full load: local file with S3 fallback. Overwrites the local-only certs above.
476
+ this._tdpDeploymentCertificates = yield (0, certificates_1.loadTdpCertificates)(this.awsClientProvider.getS3Client(), this.logger, this.config);
477
+ this.api = new api_1.Api(this.config, this.createAxiosInstanceWithCertificatesAndHeaders(this.config.tdpEndpoint, this.config.orgSlug, this.jwt), this.logger);
391
478
  this.isAwsInitialized = true;
392
479
  }
393
480
  // Priority 3: AWS credentials from environment (Cloud connector flow)
394
481
  else {
395
- this.awsClientProvider = new auth_1.AwsEnvClientProvider(this.config.awsRegion, this.createProxyNodeHttpHandler());
482
+ this.awsNodeHttpHandlers = this.createProxyAWSNodeHttpHandlers();
483
+ this.awsClientProvider = new auth_1.AwsEnvClientProvider(this.config.awsRegion, this.awsNodeHttpHandlers);
396
484
  this.authTokenProvider =
397
485
  this.config.authTokenProvider ||
398
486
  new auth_1.AwsSecretAuthTokenProvider(this.awsClientProvider.getSsmClient(), this.config.jwtTokenParameter);
@@ -403,8 +491,8 @@ class TDPClient {
403
491
  const authToken = yield this.authTokenProvider.getAuthToken();
404
492
  this.logger.info('Retrieved connector auth token');
405
493
  this.jwt = authToken.value;
406
- const tdpCertificates = yield (0, certificates_1.loadTdpCertificates)(this.awsClientProvider.getS3Client(), this.logger, this.config);
407
- this.api = new api_1.Api(this.config, this.createAxiosInstanceWithCertificatesAndHeaders(this.config.tdpEndpoint, this.config.orgSlug, this.jwt, tdpCertificates), this.logger);
494
+ this._tdpDeploymentCertificates = yield (0, certificates_1.loadTdpCertificates)(this.awsClientProvider.getS3Client(), this.logger, this.config);
495
+ this.api = new api_1.Api(this.config, this.createAxiosInstanceWithCertificatesAndHeaders(this.config.tdpEndpoint, this.config.orgSlug, this.jwt), this.logger);
408
496
  this.isAwsInitialized = true;
409
497
  }
410
498
  const requestId = (0, uuid_1.v4)();
@@ -453,7 +541,8 @@ class TDPClient {
453
541
  return __awaiter(this, void 0, void 0, function* () {
454
542
  this.logger.info('Lazily initializing AWS clients');
455
543
  try {
456
- this.awsClientProvider = new auth_1.AwsEnvClientProvider(this.config.awsRegion, this.createProxyNodeHttpHandler());
544
+ this.awsNodeHttpHandlers = this.createProxyAWSNodeHttpHandlers();
545
+ this.awsClientProvider = new auth_1.AwsEnvClientProvider(this.config.awsRegion, this.awsNodeHttpHandlers);
457
546
  this.isAwsInitialized = true;
458
547
  this.logger.info('AWS clients initialized successfully');
459
548
  }
@@ -548,9 +637,7 @@ class TDPClient {
548
637
  QueueUrl: this._connector.commandQueue,
549
638
  MaxNumberOfMessages: 1,
550
639
  WaitTimeSeconds: waitTimeSeconds,
551
- }), {
552
- abortSignal: AbortSignal.timeout(waitTimeSeconds + AWS_SQS_TIMEOUT),
553
- });
640
+ }));
554
641
  return Messages.length > 0 ? Messages[0] : null;
555
642
  });
556
643
  }
@@ -592,7 +679,7 @@ class TDPClient {
592
679
  yield sqsClient.send(new sqs.DeleteMessageCommand({
593
680
  QueueUrl: this._connector.commandQueue,
594
681
  ReceiptHandle,
595
- }), { abortSignal: AbortSignal.timeout(AWS_SQS_TIMEOUT) });
682
+ }));
596
683
  this.logger.info('Deleted SQS message', { messageId: message.MessageId });
597
684
  });
598
685
  }
@@ -638,7 +725,7 @@ class TDPClient {
638
725
  yield sqsClient.send(new sqs.SendMessageCommand({
639
726
  QueueUrl: this.config.outboundCommandQueue || undefined,
640
727
  MessageBody: JSON.stringify(messageBody),
641
- }), { abortSignal: AbortSignal.timeout(AWS_SQS_TIMEOUT) });
728
+ }));
642
729
  this.logger.info('Sent command response', { commandId: command.commandId });
643
730
  });
644
731
  }
@@ -906,7 +993,7 @@ class TDPClient {
906
993
  const isHubConnector = hostType === api_1.ConnectorHostType.HUB;
907
994
  const integrationType = isHubConnector ? constants_1.IntegrationTypes.HUB : constants_1.IntegrationTypes.API;
908
995
  const integrationId = isHubConnector
909
- ? (_e = (_d = this._connector) === null || _d === void 0 ? void 0 : _d.hub.id) !== null && _e !== void 0 ? _e : constants_1.Constants.API_UPLOAD_V1_INTEGRATION_ID
996
+ ? ((_e = (_d = this._connector) === null || _d === void 0 ? void 0 : _d.hub.id) !== null && _e !== void 0 ? _e : constants_1.Constants.API_UPLOAD_V1_INTEGRATION_ID)
910
997
  : constants_1.Constants.API_UPLOAD_V1_INTEGRATION_ID;
911
998
  const sourceName = (_g = (_f = this._connector) === null || _f === void 0 ? void 0 : _f.name) !== null && _g !== void 0 ? _g : 'unknown';
912
999
  const trace = request.trace || {};
@@ -962,4 +1049,5 @@ const shouldRejectUnauthorized = () => {
962
1049
  }
963
1050
  return !['false', '0'].includes(process.env.NODE_TLS_REJECT_UNAUTHORIZED);
964
1051
  };
1052
+ exports.shouldRejectUnauthorized = shouldRejectUnauthorized;
965
1053
  //# sourceMappingURL=tdp-client.js.map