@sap-cloud-sdk/connectivity
Version:
SAP Cloud SDK for JavaScript connectivity
53 lines (52 loc) • 1.87 kB
TypeScript
import http from 'node:http';
import https from 'node:https';
import { Cache } from '../scp-cf/cache';
import type { HttpDestination } from '../scp-cf/destination';
import type { BasicProxyConfiguration } from '../scp-cf/connectivity-service-types';
import type { HttpAgentConfig, HttpsAgentConfig } from './agent-config';
/**
* Returns a promise of the http or https-agent config depending on the destination URL.
* If the destination contains a proxy configuration, the agent will be a proxy-agent.
* If not it will be the default http-agent coming from node.
* @param destination - Determining which kind of configuration is returned.
* @returns A promise of the HTTP or HTTPS agent configuration.
*/
export declare function getAgentConfig(destination: HttpDestination): Promise<HttpAgentConfig | HttpsAgentConfig>;
/**
* Options used for establishing mTLS connections.
* @internal
*/
export interface MtlsOptions {
/**
* @internal
*/
cert: string;
/**
* @internal
*/
key: string;
}
/**
* Cache for http(s) agents.
* Exported for testing purposes only.
* @internal
*/
export declare const agentCache: Cache<HttpAgentConfig | HttpsAgentConfig>;
/**
* Default options for the http(s) agents.
* @internal
*/
export declare const defaultAgentOptions: https.AgentOptions | http.AgentOptions;
/**
* Builds part of the request config containing the URL and if needed proxy agents or normal http agents.
* Considers the `no_proxy` environment variable together with the `targetUri`.
* @internal
* @param targetUri - Used as baseURL in request config.
* @returns HttpRequestConfig containing baseUrl and http(s) agents.
*/
export declare function urlAndAgent(targetUri: string): Promise<{
baseURL: string;
proxy?: BasicProxyConfiguration | false;
httpAgent?: http.Agent;
httpsAgent?: http.Agent;
}>;