UNPKG

2 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3/// <reference types="node" />
4/// <reference types="node" />
5import * as net from 'net';
6import * as tls from 'tls';
7import * as http from 'http';
8import { Agent, AgentConnectOpts } from 'agent-base';
9import { URL } from 'url';
10import type { OutgoingHttpHeaders } from 'http';
11type Protocol<T> = T extends `${infer Protocol}:${infer _}` ? Protocol : never;
12type ConnectOptsMap = {
13 http: Omit<net.TcpNetConnectOpts, 'host' | 'port'>;
14 https: Omit<tls.ConnectionOptions, 'host' | 'port'>;
15};
16type ConnectOpts<T> = {
17 [P in keyof ConnectOptsMap]: Protocol<T> extends P ? ConnectOptsMap[P] : never;
18}[keyof ConnectOptsMap];
19export type HttpsProxyAgentOptions<T> = ConnectOpts<T> & http.AgentOptions & {
20 headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
21};
22/**
23 * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
24 * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
25 *
26 * Outgoing HTTP requests are first tunneled through the proxy server using the
27 * `CONNECT` HTTP request method to establish a connection to the proxy server,
28 * and then the proxy server connects to the destination target and issues the
29 * HTTP request from the proxy server.
30 *
31 * `https:` requests have their socket connection upgraded to TLS once
32 * the connection to the proxy server has been established.
33 */
34export declare class HttpsProxyAgent<Uri extends string> extends Agent {
35 static protocols: readonly ["http", "https"];
36 readonly proxy: URL;
37 proxyHeaders: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
38 connectOpts: net.TcpNetConnectOpts & tls.ConnectionOptions;
39 constructor(proxy: Uri | URL, opts?: HttpsProxyAgentOptions<Uri>);
40 /**
41 * Called when the node-core HTTP client library is creating a
42 * new HTTP request.
43 */
44 connect(req: http.ClientRequest, opts: AgentConnectOpts): Promise<net.Socket>;
45}
46export {};
47//# sourceMappingURL=index.d.ts.map
\No newline at end of file