UNPKG

1.98 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as http from 'http';
3import LRUCache from 'lru-cache';
4import { Agent, AgentConnectOpts } from 'agent-base';
5import { PacProxyAgentOptions } from 'pac-proxy-agent';
6import { HttpProxyAgentOptions } from 'http-proxy-agent';
7import { HttpsProxyAgentOptions } from 'https-proxy-agent';
8import { SocksProxyAgentOptions } from 'socks-proxy-agent';
9declare const PROTOCOLS: readonly ["http", "https", "socks", "socks4", "socks4a", "socks5", "socks5h", ...("pac-http" | "pac-https" | "pac-data" | "pac-file" | "pac-ftp")[]];
10type ValidProtocol = (typeof PROTOCOLS)[number];
11/**
12 * Supported proxy types.
13 */
14export declare const proxies: {
15 [P in ValidProtocol]: new (...args: never[]) => Agent;
16};
17export type ProxyAgentOptions = HttpProxyAgentOptions<''> & HttpsProxyAgentOptions<''> & SocksProxyAgentOptions & PacProxyAgentOptions<''> & {
18 /**
19 * Default `http.Agent` instance to use when no proxy is
20 * configured for a request. Defaults to a new `http.Agent()`
21 * instance with the proxy agent options passed in.
22 */
23 httpAgent?: http.Agent;
24 /**
25 * Default `http.Agent` instance to use when no proxy is
26 * configured for a request. Defaults to a new `https.Agent()`
27 * instance with the proxy agent options passed in.
28 */
29 httpsAgent?: http.Agent;
30};
31/**
32 * Uses the appropriate `Agent` subclass based off of the "proxy"
33 * environment variables that are currently set.
34 *
35 * An LRU cache is used, to prevent unnecessary creation of proxy
36 * `http.Agent` instances.
37 */
38export declare class ProxyAgent extends Agent {
39 /**
40 * Cache for `Agent` instances.
41 */
42 cache: LRUCache<string, Agent>;
43 connectOpts?: ProxyAgentOptions;
44 httpAgent: http.Agent;
45 httpsAgent: http.Agent;
46 constructor(opts?: ProxyAgentOptions);
47 connect(req: http.ClientRequest, opts: AgentConnectOpts): Promise<http.Agent>;
48 destroy(): void;
49}
50export {};
51//# sourceMappingURL=index.d.ts.map
\No newline at end of file