import { IClientResponse, ILogger, IProxyConfig, RetryOnStatusCode } from '../model'; import { HttpsProxyAgent } from 'https-proxy-agent'; export declare class HttpClient { private logger?; private static readonly AUTHORIZATION_HEADER; private static readonly USER_AGENT_HEADER; private static readonly DEFAULT_RETRIES; private static readonly DEFAULT_RETRY_DELAY_IN_MILLISECONDS; static readonly DEFAULT_TIMEOUT_IN_MILLISECONDS: number; private readonly _basicAuth; private readonly _accessToken; private readonly _axiosInstance; constructor(config: IHttpConfig, logger?: ILogger | undefined); private addRetryInterceptor; private shouldRetry; doRequest(requestParams: IRequestParams): Promise; doAuthRequest(requestParams: IRequestParams): Promise; /** * Method to use for beforeRedirect attribute in IRequestParams. * Before redirecting checks if the target location for the redirect is for 'reactivate-server' and throws ServerNotActiveError if so. */ static validateServerIsActive(_: Record, responseDetails: { headers: Record; }): void; private addUserAgentHeader; private addAuthHeader; /** * Use to create httpsAgent to handle Http proxy sending to a https server. * (Artifactory is https server, proxy protocol can be both) * @param proxyConfig - Receives on of the three: * 1. IProxyConfig to use specific proxy config. * 2. 'false' to disable proxy. * 3. 'undefined' to use environment variables if exist. * @returns if the proxy is http protocol return httpsAgent else return undefined */ static getHttpToHttpsProxyConfig(proxyConfig: IProxyConfig | false | undefined): HttpsProxyAgent | undefined; /** * @param proxyConfig - Receives on of the three: * 1. IProxyConfig to use specific proxy config. * 2. 'false' to disable proxy. * 3. 'undefined' to use environment variables if exist. * * @returns AxiosProxyConfig to use specific proxy config, false to disable proxy or undefined to use environment. */ private getAxiosProxyConfig; } export declare class ServerNotActiveError extends Error { readonly activationUrl: string; constructor(activationUrl: string); } interface BasicAuth { username: string; password: string; } export interface IHttpConfig { serverUrl?: string; username?: string; password?: string; accessToken?: string; proxy?: IProxyConfig | false; headers?: { [key: string]: string; }; retries?: number; retryDelay?: number; timeout?: number; retryOnStatusCode?: RetryOnStatusCode; } export declare type method = 'GET' | 'POST' | 'HEAD' | 'PUT'; export declare type responseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'; export interface IRequestParams { url: string; method: method; data?: any; auth?: BasicAuth; timeout?: number; headers?: any; responseType?: responseType; validateStatus?: ((status: number) => boolean) | null; beforeRedirect?: (options: Record, responseDetails: { headers: Record; }) => void; } export {};