import type * as http from 'node:http'; import type * as https from 'node:https'; import type { CookieJar } from 'tough-cookie'; export interface CookieOptions { jar: CookieJar; } export type CookieAgentOptions = { cookies?: CookieOptions | undefined; }; type CookieAgent = BaseAgent; type WithCookieAgentOptions = T extends http.AgentOptions ? T & CookieAgentOptions : T; type ConstructorParams = { [Index in keyof Params]: WithCookieAgentOptions; }; export function createCookieAgent( BaseAgentClass: new (...rest: Params) => BaseAgent, ): new (...rest: ConstructorParams) => CookieAgent; export const HttpCookieAgent: new (options: http.AgentOptions & CookieAgentOptions) => CookieAgent; export const HttpsCookieAgent: new (options: https.AgentOptions & CookieAgentOptions) => CookieAgent; export const MixedCookieAgent: new ( options: http.AgentOptions & https.AgentOptions & CookieAgentOptions, ) => CookieAgent;