import https from "https"; import { LogCallback } from "."; export type Method = "get" | "GET" | "delete" | "DELETE" | "head" | "HEAD" | "options" | "OPTIONS" | "post" | "POST" | "put" | "PUT" | "patch" | "PATCH" | "purge" | "PURGE" | "link" | "LINK" | "unlink" | "UNLINK"; export declare enum session_types { stateful = "stateful", stateless = "stateless", keep = "" } export interface HttpResponse { body: string; } export interface BasicCredentials { username: string; password: string; } export interface ClientOptions { headers?: Record; httpsAgent?: https.Agent; baseURL?: string; debugCallback?: LogCallback; timeout?: number; auth?: BasicCredentials; keepAlive?: boolean; } export interface RequestOptions extends ClientOptions { method?: Method; headers?: Record; httpsAgent?: https.Agent; qs?: Record; baseURL?: string; timeout?: number; auth?: BasicCredentials; body?: string; url?: string; } export type HeaderValue = string | string[] | number | boolean | null; export declare const isHeaderValue: (v: any) => v is HeaderValue; export type ResponseHeaders = Record & Partial<{ "set-cookie": string[]; }>; export type BearerFetcher = () => Promise; export interface HttpClientResponse { body: string; status: number; statusText: string; headers: ResponseHeaders; request?: any; } export interface RequestMetadata { adtRequestNumber?: number; adtStartTime?: Date; } export interface HttpClientOptions extends RequestOptions, RequestMetadata { url: string; } /** * Abstract HTTP client * cookies, authentication and CSRF tokens usually handled by higher level intercacve */ export interface HttpClient { /** * HTTP request * @param options url, headers,... * @returns the result of the HTTP call * * expected to throw only AdtException errors */ request: (options: HttpClientOptions) => Promise; } export declare class HttpClientException extends Error { readonly code: string | undefined; readonly status: number | undefined; readonly config: ClientOptions | undefined; readonly request: HttpClientOptions; readonly response?: HttpClientResponse | undefined; readonly parent?: unknown | undefined; constructor(message: string, code: string | undefined, status: number | undefined, config: ClientOptions | undefined, request: HttpClientOptions, response?: HttpClientResponse | undefined, parent?: unknown | undefined); } export declare const isHttpClientException: (error: unknown) => error is HttpClientException; export declare class AdtHTTP { readonly username: string; readonly client: string; readonly language: string; readonly baseURL: string; readonly id: number; readonly password?: string; isClone: boolean; private currentSession; private _stateful; private needKeepalive; readonly keepAlive?: NodeJS.Timer; private commonHeaders; private bearer?; private getToken?; private auth?; private httpclient; private debugCallback?; private loginPromise?; get isStateful(): boolean; get stateful(): session_types; set stateful(value: session_types); get csrfToken(): string; set csrfToken(token: string); get loggedin(): boolean; constructor(baseURLOrClient: string | HttpClient, username: string, password: string | BearerFetcher, client: string, language: string, config?: ClientOptions); login(): Promise; private cookie; ascookies(): string; logout(): Promise; dropSession(): Promise; request(url: string, config?: RequestOptions): Promise; private keep_session; private updateCookies; private logResponse; /** * HTTP request without automated login / retry * * @param url URL suffix * @param options request options */ private _request; } //# sourceMappingURL=AdtHTTP.d.ts.map