@foss.global/codefeed 5.4.0 → 5.6.0

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.
@@ -72,14 +72,32 @@ export interface INodeResponse extends IForgeTransportResponse {
72
72
  sent: Promise<void>;
73
73
  }
74
74
 
75
+ /**
76
+ * A lookup that answers every name with `addressArg`, an IP address, in the
77
+ * form the caller asks for (one address, or a list with `all`).
78
+ */
79
+ const fixedLookup = (addressArg: string): plugins.net.LookupFunction => {
80
+ const family = plugins.net.isIP(addressArg);
81
+ return (_hostnameArg, optionsArg, callbackArg) => {
82
+ if (optionsArg.all) callbackArg(null, [{ address: addressArg, family }]);
83
+ else callbackArg(null, addressArg, family);
84
+ };
85
+ };
86
+
75
87
  /**
76
88
  * Idle keep-alive agents that unreference their pooled sockets, so pooled
77
- * connections never keep the process alive.
89
+ * connections never keep the process alive. With `connectAddressArg`, an IP
90
+ * address, every connection goes to that address on the URL's port instead
91
+ * of the one DNS gives for the URL's host; the Host header, the TLS server
92
+ * name and the certificate check stay the URL's host.
78
93
  */
79
- export const createNodeAgents = (caCertificatesArg?: string[], allowHttpArg = false): INodeRequestAgents => ({
80
- https: new plugins.https.Agent({ ...(caCertificatesArg ? { ca: caCertificatesArg } : {}), keepAlive: true, timeout: idleSocketTimeoutMs }),
81
- ...(allowHttpArg ? { http: new plugins.http.Agent({ keepAlive: true, timeout: idleSocketTimeoutMs }) } : {}),
82
- });
94
+ export const createNodeAgents = (caCertificatesArg?: string[], allowHttpArg = false, connectAddressArg?: string): INodeRequestAgents => {
95
+ const lookup = connectAddressArg === undefined ? {} : { lookup: fixedLookup(connectAddressArg) };
96
+ return {
97
+ https: new plugins.https.Agent({ ...(caCertificatesArg ? { ca: caCertificatesArg } : {}), ...lookup, keepAlive: true, timeout: idleSocketTimeoutMs }),
98
+ ...(allowHttpArg ? { http: new plugins.http.Agent({ ...lookup, keepAlive: true, timeout: idleSocketTimeoutMs }) } : {}),
99
+ };
100
+ };
83
101
 
84
102
  /** Waits until the request can take more body bytes; rejects once it has closed. */
85
103
  const drained = (requestArg: InstanceType<typeof plugins.http.ClientRequest>): Promise<void> => new Promise((resolve, reject) => {
@@ -160,17 +178,17 @@ export const sendNodeRequest = (url: URL, requestArg: INodeRequest): Promise<INo
160
178
  });
161
179
  });
162
180
 
181
+ /** `sendNodeRequest` through `agentsArg` as a transport: a GET, or a POST of the body. */
182
+ export const createAgentTransport = (agentsArg: INodeRequestAgents): TForgeTransport => async (url, headers, signal, body, options) => {
183
+ const { sent: _sent, ...response } = await sendNodeRequest(url, {
184
+ method: body ? 'POST' : 'GET', headers, body, signal, agents: agentsArg, redirect: options?.redirect,
185
+ });
186
+ return response;
187
+ };
188
+
163
189
  /**
164
190
  * `node:https` with an owned keep-alive agent whose `ca` list replaces the
165
191
  * default trust store for these connections only. The agent unreferences idle
166
192
  * sockets, so pooled connections never keep the process alive.
167
193
  */
168
- export const createHttpsTransport = (caCertificates: string[]): TForgeTransport => {
169
- const agents = createNodeAgents(caCertificates);
170
- return async (url, headers, signal, body, options) => {
171
- const { sent: _sent, ...response } = await sendNodeRequest(url, {
172
- method: body ? 'POST' : 'GET', headers, body, signal, agents, redirect: options?.redirect,
173
- });
174
- return response;
175
- };
176
- };
194
+ export const createHttpsTransport = (caCertificates: string[]): TForgeTransport => createAgentTransport(createNodeAgents(caCertificates));
package/ts/index.ts CHANGED
@@ -487,6 +487,7 @@ export class CodeFeed {
487
487
  }
488
488
  export * from './classes.forgeinventory.js';
489
489
  export * from './classes.forgeinventoryscanner.js';
490
+ export * from './classes.giteasourcefreeze.js';
490
491
  export * from './classes.giteasourceinventory.js';
491
492
  export * from './classes.giteasourcetransfer.js';
492
493
  export * from './classes.lfsbatchclient.js';