@openclaw/proxyline 0.1.0 → 0.2.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.
package/dist/index.js CHANGED
@@ -1,522 +1,4 @@
1
- import http from "node:http";
2
- import https from "node:https";
3
- import net from "node:net";
4
- import { ProxyAgent as NodeProxyAgent } from "proxy-agent";
5
- import { Agent as UndiciAgent, EnvHttpProxyAgent, getGlobalDispatcher, ProxyAgent as UndiciProxyAgent, setGlobalDispatcher, } from "undici";
6
- import { ProxylineError, redactProxyUrl, resolveProxyTlsCa, } from "./shared.js";
7
- export { ProxylineError, redactProxyUrl, resolveProxyTlsCa, } from "./shared.js";
8
1
  export { openProxyConnectTunnel } from "./connect.js";
9
- function normalizeProxyUrl(value) {
10
- if (value === undefined) {
11
- return undefined;
12
- }
13
- const url = value instanceof URL ? new URL(value.href) : new URL(value);
14
- if (url.protocol !== "http:" && url.protocol !== "https:") {
15
- throw new ProxylineError("UNSUPPORTED_PROXY_PROTOCOL", `Proxyline only supports http:// and https:// proxy endpoints in this slice: ${url.protocol}`);
16
- }
17
- return url;
18
- }
19
- function emit(onEvent, event) {
20
- onEvent?.(event);
21
- }
22
- function formatUrl(value) {
23
- return value instanceof URL ? value.href : new URL(value).href;
24
- }
25
- const CALLER_AGENT_TLS_OPTION_KEYS = [
26
- "ca",
27
- "cert",
28
- "ciphers",
29
- "clientCertEngine",
30
- "crl",
31
- "dhparam",
32
- "ecdhCurve",
33
- "honorCipherOrder",
34
- "key",
35
- "maxVersion",
36
- "minVersion",
37
- "passphrase",
38
- "pfx",
39
- "rejectUnauthorized",
40
- "secureOptions",
41
- "secureProtocol",
42
- "sessionIdContext",
43
- ];
44
- let activeRuntime;
45
- const EMPTY_PROXY_ENV = {
46
- HTTP_PROXY: undefined,
47
- HTTPS_PROXY: undefined,
48
- ALL_PROXY: undefined,
49
- NO_PROXY: undefined,
50
- http_proxy: undefined,
51
- https_proxy: undefined,
52
- all_proxy: undefined,
53
- no_proxy: undefined,
54
- };
55
- function copyNodeHttpOptions(value) {
56
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
57
- return {};
58
- }
59
- return { ...value };
60
- }
61
- function readAgentOptions(agent) {
62
- if (agent === undefined || agent === false) {
63
- return undefined;
64
- }
65
- return agent.options;
66
- }
67
- function preserveCallerAgentOptions(options) {
68
- const agentOptions = readAgentOptions(options.agent);
69
- if (agentOptions === undefined) {
70
- return;
71
- }
72
- for (const key of CALLER_AGENT_TLS_OPTION_KEYS) {
73
- const value = agentOptions[key];
74
- if (value !== undefined && options[key] === undefined) {
75
- options[key] = value;
76
- }
77
- }
78
- }
79
- function inferDestinationHostname(url, options) {
80
- if (url !== undefined) {
81
- return url instanceof URL ? url.hostname : new URL(url).hostname;
82
- }
83
- if (typeof options.hostname === "string") {
84
- return options.hostname;
85
- }
86
- if (typeof options.host === "string") {
87
- return options.host.replace(/:\d*$/, "");
88
- }
89
- return undefined;
90
- }
91
- function preserveDestinationTlsIdentity(url, options) {
92
- if (options.servername !== undefined) {
93
- return;
94
- }
95
- const hostname = inferDestinationHostname(url, options);
96
- if (!hostname) {
97
- return;
98
- }
99
- if (net.isIP(hostname) === 0) {
100
- options.servername = hostname;
101
- }
102
- }
103
- function bindNodeHttpMethod(originalMethod, createAgent) {
104
- return ((...args) => {
105
- let url;
106
- let options;
107
- let callback;
108
- const firstArg = args[0];
109
- if (typeof firstArg === "string" || firstArg instanceof URL) {
110
- url = firstArg;
111
- if (typeof args[1] === "function") {
112
- options = {};
113
- callback = args[1];
114
- }
115
- else {
116
- options = copyNodeHttpOptions(args[1]);
117
- callback = args[2];
118
- }
119
- }
120
- else {
121
- options = copyNodeHttpOptions(firstArg);
122
- callback = args[1];
123
- }
124
- preserveCallerAgentOptions(options);
125
- preserveDestinationTlsIdentity(url, options);
126
- const agent = createAgent(options);
127
- options.agent = agent;
128
- delete options.createConnection;
129
- if (url !== undefined) {
130
- const request = originalMethod(url, options, callback);
131
- request.once("close", () => {
132
- agent.destroy();
133
- });
134
- return request;
135
- }
136
- const request = originalMethod(options, callback);
137
- request.once("close", () => {
138
- agent.destroy();
139
- });
140
- return request;
141
- });
142
- }
143
- function readProxyEnv() {
144
- return {
145
- HTTP_PROXY: process.env.HTTP_PROXY,
146
- HTTPS_PROXY: process.env.HTTPS_PROXY,
147
- ALL_PROXY: process.env.ALL_PROXY,
148
- NO_PROXY: process.env.NO_PROXY,
149
- http_proxy: process.env.http_proxy,
150
- https_proxy: process.env.https_proxy,
151
- all_proxy: process.env.all_proxy,
152
- no_proxy: process.env.no_proxy,
153
- };
154
- }
155
- function normalizeEnvValue(value) {
156
- const trimmed = value?.trim();
157
- return trimmed ? trimmed : undefined;
158
- }
159
- function upperProxyEnvKey(key) {
160
- switch (key) {
161
- case "http_proxy":
162
- return "HTTP_PROXY";
163
- case "https_proxy":
164
- return "HTTPS_PROXY";
165
- case "all_proxy":
166
- return "ALL_PROXY";
167
- case "no_proxy":
168
- return "NO_PROXY";
169
- }
170
- }
171
- function readProxyEnvValue(env, key) {
172
- return normalizeEnvValue(env[key]) ?? normalizeEnvValue(env[upperProxyEnvKey(key)]);
173
- }
174
- function proxyUrlWithDefaultScheme(proxyUrl) {
175
- return proxyUrl.includes("://") ? proxyUrl : `http://${proxyUrl}`;
176
- }
177
- function defaultPort(protocol) {
178
- if (protocol === "http:" || protocol === "ws:") {
179
- return 80;
180
- }
181
- if (protocol === "https:" || protocol === "wss:") {
182
- return 443;
183
- }
184
- return 0;
185
- }
186
- function matchesNoProxy(url, env) {
187
- const rawNoProxy = readProxyEnvValue(env, "no_proxy")?.toLowerCase();
188
- if (!rawNoProxy) {
189
- return false;
190
- }
191
- if (rawNoProxy === "*") {
192
- return true;
193
- }
194
- const hostname = normalizeNoProxyHost(url.hostname);
195
- const port = Number.parseInt(url.port, 10) || defaultPort(url.protocol);
196
- for (const rawEntry of rawNoProxy.split(/[,\s]/)) {
197
- if (!rawEntry) {
198
- continue;
199
- }
200
- const { host: parsedHost, port: entryPort } = parseNoProxyEntry(rawEntry);
201
- let entryHost = normalizeNoProxyHost(parsedHost);
202
- if (entryPort && entryPort !== port) {
203
- continue;
204
- }
205
- if (!/^[.*]/.test(entryHost)) {
206
- if (hostname === entryHost) {
207
- return true;
208
- }
209
- continue;
210
- }
211
- if (entryHost.startsWith("*")) {
212
- entryHost = entryHost.slice(1);
213
- }
214
- if (hostname.endsWith(entryHost)) {
215
- return true;
216
- }
217
- }
218
- return false;
219
- }
220
- function normalizeNoProxyHost(hostname) {
221
- const normalized = hostname.trim().toLowerCase().replace(/\.+$/, "");
222
- return normalized.startsWith("[") && normalized.endsWith("]")
223
- ? normalized.slice(1, -1)
224
- : normalized;
225
- }
226
- function parseNoProxyEntry(entry) {
227
- const bracketedIpv6 = entry.match(/^\[([^\]]+)\](?::(\d+))?$/);
228
- if (bracketedIpv6) {
229
- return {
230
- host: bracketedIpv6[1] ?? "",
231
- port: bracketedIpv6[2] ? Number.parseInt(bracketedIpv6[2], 10) : 0,
232
- };
233
- }
234
- const lastColon = entry.lastIndexOf(":");
235
- const hasSingleColon = lastColon !== -1 && entry.indexOf(":") === lastColon;
236
- if (hasSingleColon) {
237
- const possiblePort = entry.slice(lastColon + 1);
238
- if (/^\d+$/.test(possiblePort)) {
239
- return {
240
- host: entry.slice(0, lastColon),
241
- port: Number.parseInt(possiblePort, 10),
242
- };
243
- }
244
- }
245
- return { host: entry, port: 0 };
246
- }
247
- function formatNoProxyEntryForUndici(entry) {
248
- const { host, port } = parseNoProxyEntry(entry);
249
- const normalizedHost = normalizeNoProxyHost(host);
250
- const formattedHost = normalizedHost.includes(":") ? `[${normalizedHost}]` : host;
251
- return port ? `${formattedHost}:${port}` : formattedHost;
252
- }
253
- function normalizeNoProxyForUndici(noProxy) {
254
- if (noProxy === undefined) {
255
- return undefined;
256
- }
257
- const entries = noProxy
258
- .split(/[,\s]/)
259
- .map((entry) => entry.trim())
260
- .filter(Boolean)
261
- .map(formatNoProxyEntryForUndici);
262
- return entries.length > 0 ? entries.join(",") : undefined;
263
- }
264
- function proxyEnvKeyForProtocol(protocol) {
265
- if (protocol === "http:" || protocol === "ws:") {
266
- return "http_proxy";
267
- }
268
- if (protocol === "https:" || protocol === "wss:") {
269
- return "https_proxy";
270
- }
271
- return undefined;
272
- }
273
- function resolveAmbientProxyForUrl(url, env) {
274
- let parsedUrl;
275
- try {
276
- parsedUrl = url instanceof URL ? new URL(url.href) : new URL(url);
277
- }
278
- catch {
279
- return undefined;
280
- }
281
- const protocol = parsedUrl.protocol;
282
- if (protocol !== "http:" &&
283
- protocol !== "https:" &&
284
- protocol !== "ws:" &&
285
- protocol !== "wss:") {
286
- return undefined;
287
- }
288
- if (matchesNoProxy(parsedUrl, env)) {
289
- return undefined;
290
- }
291
- const protocolProxyKey = proxyEnvKeyForProtocol(protocol);
292
- if (protocolProxyKey === undefined) {
293
- return undefined;
294
- }
295
- const proxy = readProxyEnvValue(env, protocolProxyKey) ?? readProxyEnvValue(env, "all_proxy");
296
- return proxy ? proxyUrlWithDefaultScheme(proxy) : undefined;
297
- }
298
- function createManagedProxyResolver(proxyUrl) {
299
- const redactedProxyUrl = redactProxyUrl(proxyUrl);
300
- return {
301
- active: true,
302
- describeProxy: () => redactedProxyUrl,
303
- explain: (url, surface) => ({
304
- kind: "proxied",
305
- reason: "managed-proxy-active",
306
- surface,
307
- url: formatUrl(url),
308
- proxyUrl: redactedProxyUrl,
309
- }),
310
- getProxyForUrl: (url) => {
311
- const protocol = new URL(url).protocol;
312
- return protocol === "http:" ||
313
- protocol === "https:" ||
314
- protocol === "ws:" ||
315
- protocol === "wss:"
316
- ? proxyUrl.href
317
- : "";
318
- },
319
- };
320
- }
321
- function createAmbientProxyResolver(env) {
322
- const configuredProxy = readProxyEnvValue(env, "http_proxy") ??
323
- readProxyEnvValue(env, "https_proxy") ??
324
- readProxyEnvValue(env, "all_proxy");
325
- return {
326
- active: configuredProxy !== undefined,
327
- describeProxy: () => configuredProxy
328
- ? redactProxyUrl(proxyUrlWithDefaultScheme(configuredProxy))
329
- : undefined,
330
- explain: (url, surface) => {
331
- const formattedUrl = formatUrl(url);
332
- const proxyUrl = resolveAmbientProxyForUrl(formattedUrl, env);
333
- if (proxyUrl !== undefined) {
334
- return {
335
- kind: "proxied",
336
- reason: "ambient-proxy-active",
337
- surface,
338
- url: formattedUrl,
339
- proxyUrl: redactProxyUrl(proxyUrl),
340
- };
341
- }
342
- return {
343
- kind: "direct",
344
- reason: matchesNoProxy(new URL(formattedUrl), env)
345
- ? "no-proxy-match"
346
- : "ambient-proxy-not-configured",
347
- surface,
348
- url: formattedUrl,
349
- };
350
- },
351
- getProxyForUrl: (url) => resolveAmbientProxyForUrl(url, env) ?? "",
352
- };
353
- }
354
- function createNodeProxyAgent(resolver, proxyCa, options) {
355
- return new NodeProxyAgent({
356
- ...(proxyCa !== undefined ? { ca: proxyCa } : {}),
357
- ...(options?.cert !== undefined ? { cert: options.cert } : {}),
358
- ...(options?.ciphers !== undefined ? { ciphers: options.ciphers } : {}),
359
- ...(options?.clientCertEngine !== undefined ? { clientCertEngine: options.clientCertEngine } : {}),
360
- ...(options?.crl !== undefined ? { crl: options.crl } : {}),
361
- ...(options?.dhparam !== undefined ? { dhparam: options.dhparam } : {}),
362
- ...(options?.ecdhCurve !== undefined ? { ecdhCurve: options.ecdhCurve } : {}),
363
- ...(options?.honorCipherOrder !== undefined ? { honorCipherOrder: options.honorCipherOrder } : {}),
364
- ...(options?.key !== undefined ? { key: options.key } : {}),
365
- ...(options?.maxVersion !== undefined ? { maxVersion: options.maxVersion } : {}),
366
- ...(options?.minVersion !== undefined ? { minVersion: options.minVersion } : {}),
367
- ...(options?.passphrase !== undefined ? { passphrase: options.passphrase } : {}),
368
- ...(options?.pfx !== undefined ? { pfx: options.pfx } : {}),
369
- ...(options?.rejectUnauthorized !== undefined ? { rejectUnauthorized: options.rejectUnauthorized } : {}),
370
- ...(options?.secureOptions !== undefined ? { secureOptions: options.secureOptions } : {}),
371
- ...(options?.secureProtocol !== undefined ? { secureProtocol: options.secureProtocol } : {}),
372
- ...(options?.servername !== undefined ? { servername: options.servername } : {}),
373
- ...(options?.sessionIdContext !== undefined ? { sessionIdContext: options.sessionIdContext } : {}),
374
- getProxyForUrl: resolver.getProxyForUrl,
375
- httpAgent: new http.Agent(),
376
- httpsAgent: new https.Agent(),
377
- });
378
- }
379
- function createUndiciProxyDispatcher(options, proxyCa) {
380
- if (options.mode === "ambient") {
381
- if (!options.active) {
382
- return new UndiciAgent();
383
- }
384
- const rawHttpProxy = readProxyEnvValue(options.env, "http_proxy") ?? readProxyEnvValue(options.env, "all_proxy");
385
- const rawHttpsProxy = readProxyEnvValue(options.env, "https_proxy") ??
386
- readProxyEnvValue(options.env, "all_proxy");
387
- const noProxy = normalizeNoProxyForUndici(readProxyEnvValue(options.env, "no_proxy"));
388
- return new EnvHttpProxyAgent({
389
- ...(rawHttpProxy !== undefined
390
- ? { httpProxy: proxyUrlWithDefaultScheme(rawHttpProxy) }
391
- : {}),
392
- ...(rawHttpsProxy !== undefined
393
- ? { httpsProxy: proxyUrlWithDefaultScheme(rawHttpsProxy) }
394
- : {}),
395
- ...(noProxy !== undefined ? { noProxy } : {}),
396
- ...(proxyCa !== undefined ? { proxyTls: { ca: proxyCa } } : {}),
397
- });
398
- }
399
- return new UndiciProxyAgent({
400
- uri: options.proxyUrl,
401
- ...(proxyCa !== undefined ? { proxyTls: { ca: proxyCa } } : {}),
402
- });
403
- }
404
- function installRuntime(resolver, dispatcherOptions, proxyCa) {
405
- if (activeRuntime !== undefined) {
406
- throw new ProxylineError("RUNTIME_ALREADY_ACTIVE", "Proxyline already has an active runtime.");
407
- }
408
- const snapshot = {
409
- httpRequest: http.request,
410
- httpGet: http.get,
411
- httpGlobalAgent: http.globalAgent,
412
- httpsRequest: https.request,
413
- httpsGet: https.get,
414
- httpsGlobalAgent: https.globalAgent,
415
- };
416
- const nodeAgent = createNodeProxyAgent(resolver, proxyCa);
417
- const originalDispatcher = getGlobalDispatcher();
418
- const runtime = {
419
- nodeAgent,
420
- originalDispatcher,
421
- snapshot,
422
- };
423
- activeRuntime = runtime;
424
- try {
425
- http.globalAgent = nodeAgent;
426
- https.globalAgent = nodeAgent;
427
- http.request = bindNodeHttpMethod(snapshot.httpRequest, (options) => createNodeProxyAgent(resolver, proxyCa, options));
428
- http.get = bindNodeHttpMethod(snapshot.httpGet, (options) => createNodeProxyAgent(resolver, proxyCa, options));
429
- https.request = bindNodeHttpMethod(snapshot.httpsRequest, (options) => createNodeProxyAgent(resolver, proxyCa, options));
430
- https.get = bindNodeHttpMethod(snapshot.httpsGet, (options) => createNodeProxyAgent(resolver, proxyCa, options));
431
- setGlobalDispatcher(createUndiciProxyDispatcher(dispatcherOptions, proxyCa));
432
- }
433
- catch (error) {
434
- activeRuntime = undefined;
435
- nodeAgent.destroy();
436
- throw error;
437
- }
438
- return runtime;
439
- }
440
- function stopRuntime(runtime) {
441
- if (activeRuntime !== runtime) {
442
- return;
443
- }
444
- http.request = runtime.snapshot.httpRequest;
445
- http.get = runtime.snapshot.httpGet;
446
- http.globalAgent = runtime.snapshot.httpGlobalAgent;
447
- https.request = runtime.snapshot.httpsRequest;
448
- https.get = runtime.snapshot.httpsGet;
449
- https.globalAgent = runtime.snapshot.httpsGlobalAgent;
450
- setGlobalDispatcher(runtime.originalDispatcher);
451
- runtime.nodeAgent.destroy();
452
- activeRuntime = undefined;
453
- }
454
- export function installProxyline(options) {
455
- const proxyUrl = options.mode === "managed" ? normalizeProxyUrl(options.proxyUrl) : undefined;
456
- if (options.mode === "managed" && proxyUrl === undefined) {
457
- throw new ProxylineError("MANAGED_PROXY_URL_REQUIRED", "Proxyline managed mode requires an explicit proxyUrl.");
458
- }
459
- let stopped = false;
460
- const proxyCa = resolveProxyTlsCa(options.proxyTls);
461
- const ambientEnv = proxyUrl === undefined ? readProxyEnv() : undefined;
462
- const resolver = proxyUrl !== undefined
463
- ? createManagedProxyResolver(proxyUrl)
464
- : createAmbientProxyResolver(ambientEnv ?? EMPTY_PROXY_ENV);
465
- const redactedProxyUrl = resolver.describeProxy();
466
- const hasActiveProxy = resolver.active;
467
- const runtime = hasActiveProxy
468
- ? installRuntime(resolver, proxyUrl !== undefined
469
- ? { mode: "managed", proxyUrl: proxyUrl.href }
470
- : { mode: "ambient", env: ambientEnv ?? EMPTY_PROXY_ENV, active: hasActiveProxy }, proxyCa)
471
- : undefined;
472
- emit(options.onEvent, {
473
- type: "runtime.installed",
474
- mode: options.mode,
475
- active: hasActiveProxy,
476
- ...(redactedProxyUrl ? { proxyUrl: redactedProxyUrl } : {}),
477
- });
478
- const handle = {
479
- mode: options.mode,
480
- active: hasActiveProxy,
481
- ...(redactedProxyUrl ? { proxyUrl: redactedProxyUrl } : {}),
482
- createNodeAgent: () => {
483
- if (!hasActiveProxy) {
484
- return new http.Agent();
485
- }
486
- return createNodeProxyAgent(resolver, proxyCa);
487
- },
488
- createUndiciDispatcher: () => createUndiciProxyDispatcher(proxyUrl !== undefined
489
- ? { mode: "managed", proxyUrl: proxyUrl.href }
490
- : { mode: "ambient", env: ambientEnv ?? EMPTY_PROXY_ENV, active: hasActiveProxy }, proxyCa),
491
- createWebSocketAgent: () => {
492
- if (!hasActiveProxy) {
493
- return new http.Agent();
494
- }
495
- return createNodeProxyAgent(resolver, proxyCa);
496
- },
497
- explain: (url, explainOptions) => {
498
- const decision = stopped
499
- ? {
500
- kind: "direct",
501
- reason: "runtime-stopped",
502
- surface: explainOptions?.surface ?? "unknown",
503
- url: formatUrl(url),
504
- }
505
- : resolver.explain(url, explainOptions?.surface ?? "unknown");
506
- emit(options.onEvent, { type: "decision", decision });
507
- return decision;
508
- },
509
- stop: () => {
510
- if (stopped) {
511
- return;
512
- }
513
- stopped = true;
514
- if (runtime !== undefined) {
515
- stopRuntime(runtime);
516
- }
517
- emit(options.onEvent, { type: "runtime.stopped", mode: options.mode });
518
- },
519
- };
520
- return handle;
521
- }
522
- export const installGlobalProxy = installProxyline;
2
+ export { createAmbientNodeProxyAgent, hasAmbientNodeProxyConfigured, } from "./node-http.js";
3
+ export { installGlobalProxy, installProxyline } from "./runtime.js";
4
+ export { ProxylineError, redactProxyUrl, resolveProxyTlsCa, } from "./shared.js";
@@ -0,0 +1,52 @@
1
+ import http from "node:http";
2
+ import https from "node:https";
3
+ import { type ProxyEnvSnapshot } from "./env.js";
4
+ import { type ProxylineTlsOptions } from "./shared.js";
5
+ import type { ProxyResolver } from "./types.js";
6
+ export type NodeHttpRequestOptions = http.RequestOptions & https.RequestOptions & {
7
+ agent?: http.Agent | false;
8
+ };
9
+ type NodeHttpMethod = typeof http.request;
10
+ type NodeAgentFactory = (options: NodeHttpRequestOptions) => http.Agent;
11
+ type NodeAgentOptions = http.AgentOptions & https.AgentOptions;
12
+ type NodeAgentRequestOptions = http.RequestOptions & https.RequestOptions & {
13
+ secureEndpoint?: boolean;
14
+ };
15
+ type NodeProxyAgentOptions = NodeAgentOptions & {
16
+ defaultProtocol?: "http" | "https";
17
+ getProxyForUrl: (url: string, request?: http.ClientRequest) => string;
18
+ proxyTls?: ProxylineTlsOptions;
19
+ };
20
+ export declare const CALLER_AGENT_TLS_OPTION_KEYS: readonly ["ca", "cert", "ciphers", "clientCertEngine", "crl", "dhparam", "ecdhCurve", "honorCipherOrder", "key", "maxVersion", "minVersion", "passphrase", "pfx", "rejectUnauthorized", "secureOptions", "secureProtocol", "sessionIdContext"];
21
+ export type NodeHttpStackSnapshot = {
22
+ httpRequest: typeof http.request;
23
+ httpGet: typeof http.get;
24
+ httpGlobalAgent: typeof http.globalAgent;
25
+ httpsRequest: typeof https.request;
26
+ httpsGet: typeof https.get;
27
+ httpsGlobalAgent: typeof https.globalAgent;
28
+ };
29
+ export declare function bindNodeHttpMethod<TMethod extends NodeHttpMethod>(originalMethod: TMethod, createAgent: NodeAgentFactory): TMethod;
30
+ export declare class ProxylineNodeProxyAgent extends http.Agent {
31
+ #private;
32
+ readonly options: NodeAgentOptions;
33
+ constructor(options: NodeProxyAgentOptions);
34
+ get defaultPort(): number;
35
+ set defaultPort(value: number);
36
+ get protocol(): string;
37
+ set protocol(_value: string);
38
+ getProxyForUrl(url: string, request?: http.ClientRequest): string;
39
+ addRequest(req: http.ClientRequest, options: NodeAgentRequestOptions): void;
40
+ destroy(): void;
41
+ }
42
+ export declare function createNodeProxyAgent(resolver: ProxyResolver, proxyCa: string | undefined, defaultProtocol?: "http" | "https"): ProxylineNodeProxyAgent;
43
+ export declare function createDirectNodeAgent(): ProxylineNodeProxyAgent;
44
+ export type AmbientNodeProxyAgentOptions = {
45
+ env?: ProxyEnvSnapshot;
46
+ protocol?: "http" | "https";
47
+ proxyTls?: ProxylineTlsOptions;
48
+ };
49
+ export declare function hasAmbientNodeProxyConfigured(options?: AmbientNodeProxyAgentOptions): boolean;
50
+ export declare function createAmbientNodeProxyAgent(options?: AmbientNodeProxyAgentOptions): ProxylineNodeProxyAgent | undefined;
51
+ export {};
52
+ //# sourceMappingURL=node-http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-http.d.ts","sourceRoot":"","sources":["../src/node-http.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAI/B,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAqC,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,GAAG;IAChF,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;CAC5B,CAAC;AAEF,KAAK,cAAc,GAAG,OAAO,IAAI,CAAC,OAAO,CAAC;AAC1C,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC,KAAK,CAAC;AACxE,KAAK,gBAAgB,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