@sap-cloud-sdk/core
Version:
SAP Cloud SDK for JavaScript core
46 lines • 2.88 kB
TypeScript
/// <reference types="node" />
import { AgentOptions } from 'https';
import { Destination } from '../connectivity/scp-cf/destination';
import { ProxyConfiguration } from '../connectivity/scp-cf/connectivity-service-types';
import { HttpAgentConfig, HttpsAgentConfig } from './agent-config';
/**
* Determines the proxy strategy. If noProxy is set the ProxyConfiguration in the destination is omitted.
* For onPremProxy or internetProxy the connectivity service or environment variables are checked to fill the [[ProxyConfiguration]].
* @param destination - from which the proxy strategy is derived.
* @returns ProxyStrategy possible values are noProxy, internetProxy or onPremProxy.
*/
export declare function proxyStrategy(destination: Destination): ProxyStrategy;
/**
* Parses the environment variable for the web proxy and extracts the values considering defaults like http for the protocol and 80 or 443 for the port.
* The general pattern to be parsed is `protocol://user:password@host:port`, where everything besides the host is optional.
* Special characters in the user and password need to be percent encoded.
* @param proxyEnvValue - Environment variable which is parsed.
* @returns Configuration with default values or `undefined` if the parsing failed.
*/
export declare function parseProxyEnv(proxyEnvValue: string): ProxyConfiguration | undefined;
/**
* Adds the proxy configuration to a destination based on web proxies defined in environment variables. See [[ProxyConfiguration]] and [[proxyStrategy]] for details.
* @param destination - to which the proxy configuration is added.
* @returns Destination containing the configuration for web proxy.
*/
export declare function addProxyConfigurationInternet(destination: any): Destination;
/**
* Builds the http(s)-agent config. Note that the proxy agent type like http or https is determined by the destination RUL protocol.
* The protocol from the proxy is unrelated to this and in most cases http.
* All additional options are forwarded to tls.connect and net.connect see https://github.com/TooTallNate/node-https-proxy-agent#new-httpsproxyagentobject-options
* @param destination - Destination containing the proxy configurations
* @param options - Additional options for the agent
* @returns The http(s)-agent containing the proxy configuration
*/
export declare function proxyAgent(destination: Destination, options?: AgentOptions): HttpAgentConfig | HttpsAgentConfig;
/**
* Enum representing the different strategies for proxies on requests. Possible situations are "NO_PROXY", use the connectivity service proxy for On-Premise connection or a usual web proxy.
* See also [[ProxyConfiguration]] for more details.
*/
export declare enum ProxyStrategy {
NO_PROXY = 0,
ON_PREMISE_PROXY = 1,
INTERNET_PROXY = 2,
PRIVATELINK_PROXY = 3
}
//# sourceMappingURL=proxy-util.d.ts.map