UNPKG

@journeyapps/https-proxy-socket

Version:

Node library to enable opening Socket connections via an HTTPS proxy.

43 lines (42 loc) 1.47 kB
/// <reference types="node" /> import * as tls from 'tls'; export interface HttpsProxyConfig extends tls.ConnectionOptions { headers?: { [key: string]: string; }; auth?: string; } export interface ConnectionOptions { host: string; port: number; } /** * The HttpsProxySocket class allows creating Socket connections via an HTTPS proxy. * HTTP proxies are not supported. * For http(s) requests, use HttpsProxyAgent as a wrapper around this. */ export declare class HttpsProxySocket { proxy: tls.ConnectionOptions; proxyConfig: HttpsProxyConfig; /** * * @param opts - The connection options to the proxy. At least host and port are required. * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint). * @param proxyConfig - { auth: 'username:password' } for basic auth. * { headers: {key: 'value'} } for custom headers. */ constructor(opts: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig); /** * Create a new Socket connection. * * @param opts - host and port */ connect(opts: ConnectionOptions): Promise<tls.TLSSocket>; /** * Construct an agent for http(s) requests. * * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized */ agent(options?: tls.ConnectionOptions): import("agent-base").Agent; private _connect; }