import Piscina from 'piscina';

/**
 * Configuration options for the ModuleClient
 */
interface ModuleClientOptions {
    /** Path to a custom TLS library */
    customLibraryPath?: string;
    /** Path to download the TLS library */
    customLibraryDownloadPath?: string;
    /** Maximum number of threads in the worker pool */
    maxThreads?: number;
}
/**
 * Statistics about the worker pool
 */
interface PoolStats {
    /** Worker utilization of the pool as a ratio between 0 and 1 */
    utilization: number;
    /** The number of completed tasks */
    completed: number;
    /** The number of tasks waiting to be processed */
    waiting: number;
    /** The number of threads in the pool */
    threads: number;
}
/**
 * @classdesc Manages the TLS library and worker pool.
 */
declare class ModuleClient {
    private readonly customPath;
    private readonly tlsDependency;
    private readonly tlsDependencyPath;
    private readonly TLS_LIB_PATH;
    private readonly maxThreads;
    pool: Piscina | null;
    private opening;
    /**
     * @description Creates a new ModuleClient instance.
     * @param {ModuleClientOptions} [options] - Configuration options for the ModuleClient
     * @example const module = new ModuleClient();
     * @example const module = new ModuleClient({ customLibraryPath: '/path/to/tls-library' });
     */
    constructor(options?: ModuleClientOptions);
    /**
     * @description Checks if the TLS library exists.
     * @returns {boolean} True if the library exists, false otherwise.
     */
    private libraryExists;
    /**
     * @description Downloads the TLS library if it does not exist.
     * @returns {Promise<void>} Promise that resolves when the library is downloaded
     */
    private downloadLibrary;
    /**
     * @description Opens the TLS library and initializes the worker pool.
     * @returns {Promise<void>} Promise that resolves when the library is opened and pool is initialized
     */
    open(): Promise<void>;
    private initialize;
    /**
     * @description Starts the worker pool.
     * @returns {Piscina} The Piscina worker pool.
     */
    private startWorkerPool;
    /**
     * @description Get current pool statistics.
     * @returns {PoolStats | null} Pool statistics.
     */
    getPoolStats(): PoolStats | null;
    /**
     * @description Terminates the worker pool and unloads the TLS library.
     * @returns {Promise<boolean>} True if the termination was successful, false otherwise.
     */
    terminate(): Promise<boolean>;
}

/**
 * Accepted request body types. Objects are JSON-stringified, primitives are
 * converted via String(). Pass `null` to send no body.
 */
type RequestBody = string | object | number | boolean | null;
type ChromeProfile = 'chrome_103' | 'chrome_104' | 'chrome_105' | 'chrome_106' | 'chrome_107' | 'chrome_108' | 'chrome_109' | 'chrome_110' | 'chrome_111' | 'chrome_112' | 'chrome_116_PSK' | 'chrome_116_PSK_PQ' | 'chrome_117' | 'chrome_120' | 'chrome_124' | 'chrome_130_PSK' | 'chrome_131' | 'chrome_131_PSK' | 'chrome_133' | 'chrome_133_PSK' | 'chrome_144' | 'chrome_144_PSK' | 'chrome_146' | 'chrome_146_PSK';
type BraveProfile = 'brave_146' | 'brave_146_PSK';
type SafariProfile = 'safari_15_6_1' | 'safari_16_0';
type SafariIOSProfile = 'safari_ios_15_5' | 'safari_ios_15_6' | 'safari_ios_16_0' | 'safari_ios_17_0' | 'safari_ios_18_0' | 'safari_ios_18_5' | 'safari_ios_26_0';
type SafariIpadOSProfile = 'safari_ipad_15_6';
type FirefoxProfile = 'firefox_102' | 'firefox_104' | 'firefox_105' | 'firefox_106' | 'firefox_108' | 'firefox_110' | 'firefox_117' | 'firefox_120' | 'firefox_123' | 'firefox_132' | 'firefox_133' | 'firefox_135' | 'firefox_146_PSK' | 'firefox_147' | 'firefox_147_PSK' | 'firefox_148';
type OperaProfile = 'opera_89' | 'opera_90' | 'opera_91';
type OkHttp4Profile = 'okhttp4_android_7' | 'okhttp4_android_8' | 'okhttp4_android_9' | 'okhttp4_android_10' | 'okhttp4_android_11' | 'okhttp4_android_12' | 'okhttp4_android_13';
type CustomClientProfile = 'zalando_ios_mobile' | 'zalando_android_mobile' | 'nike_ios_mobile' | 'nike_android_mobile' | 'cloudscraper' | 'mms_ios' | 'mms_ios_1' | 'mms_ios_2' | 'mms_ios_3' | 'mesh_ios' | 'mesh_ios_1' | 'mesh_ios_2' | 'mesh_android' | 'mesh_android_1' | 'mesh_android_2' | 'confirmed_ios' | 'confirmed_android';
type ClientProfile = ChromeProfile | BraveProfile | SafariProfile | SafariIOSProfile | SafariIpadOSProfile | FirefoxProfile | OperaProfile | OkHttp4Profile | CustomClientProfile;
/**
 * Certificate compression algorithm types
 */
type CertCompressionAlgorithm = 'zlib' | 'brotli' | 'zstd';
/**
 * HTTP/2 settings keys
 */
type H2SettingsKey = 'HEADER_TABLE_SIZE' | 'ENABLE_PUSH' | 'MAX_CONCURRENT_STREAMS' | 'INITIAL_WINDOW_SIZE' | 'MAX_FRAME_SIZE' | 'MAX_HEADER_LIST_SIZE' | 'UNKNOWN_SETTING_7' | 'UNKNOWN_SETTING_8' | 'UNKNOWN_SETTING_9';
/**
 * HTTP/3 settings keys
 */
type H3SettingsKey = 'QPACK_MAX_TABLE_CAPACITY' | 'MAX_FIELD_SECTION_SIZE' | 'QPACK_BLOCKED_STREAMS' | 'H3_DATAGRAM';
/**
 * Supported TLS versions
 */
type SupportedVersion = 'GREASE' | '1.3' | '1.2' | '1.1' | '1.0';
/**
 * Supported signature algorithms
 */
type SignatureAlgorithm = 'PKCS1WithSHA256' | 'PKCS1WithSHA384' | 'PKCS1WithSHA512' | 'PSSWithSHA256' | 'PSSWithSHA384' | 'PSSWithSHA512' | 'ECDSAWithP256AndSHA256' | 'ECDSAWithP384AndSHA384' | 'ECDSAWithP521AndSHA512' | 'PKCS1WithSHA1' | 'ECDSAWithSHA1' | 'Ed25519' | 'SHA224_RSA' | 'SHA224_ECDSA';
/**
 * Key share curves
 */
type KeyShareCurve = 'GREASE' | 'P256' | 'P384' | 'P521' | 'X25519' | 'P256Kyber768' | 'X25519Kyber512D' | 'X25519Kyber768' | 'X25519Kyber768Old' | 'X25519MLKEM768';
/**
 * KDF identifiers
 */
type KdfId = 'HKDF_SHA256' | 'HKDF_SHA384' | 'HKDF_SHA512';
/**
 * AEAD identifiers
 */
type AeadId = 'AEAD_AES_128_GCM' | 'AEAD_AES_256_GCM' | 'AEAD_CHACHA20_POLY1305';
/**
 * Certificate pinning hosts configuration
 * @example { "example.com": ["sha256/AAAAAAAAAAAAAAAAAAAAAA=="] }
 */
interface CertificatePinningHosts {
    [hostname: string]: string[];
}
/**
 * HTTP/2 stream priority parameters
 */
interface PriorityParam {
    streamDep?: number;
    exclusive?: boolean;
    weight?: number;
}
/**
 * HTTP/2 priority frame configuration
 */
interface PriorityFrames {
    streamID: number;
    priorityParam: PriorityParam;
}
/**
 * ECH Candidate Cipher Suite configuration
 */
interface CandidateCipherSuite {
    kdfId: KdfId;
    aeadId: AeadId;
}
/**
 * Custom TLS client configuration for advanced fingerprint customization
 */
interface CustomTLSClient {
    /** Certificate compression algorithms */
    certCompressionAlgos?: CertCompressionAlgorithm[];
    /** Connection flow identifier */
    connectionFlow?: number;
    /** HTTP/2 settings map */
    h2Settings?: Partial<Record<H2SettingsKey, number>>;
    /** Array of H2Settings keys in order */
    h2SettingsOrder?: H2SettingsKey[];
    /** HTTP/3 settings map */
    h3Settings?: Partial<Record<H3SettingsKey, number>>;
    /** Array of H3Settings keys in order */
    h3SettingsOrder?: H3SettingsKey[];
    /** Pseudo header order for HTTP/3 requests */
    h3PseudoHeaderOrder?: string[];
    /** HTTP/3 priority parameter */
    h3PriorityParam?: number;
    /** Whether to send GREASE frames in HTTP/3 */
    h3SendGreaseFrames?: boolean;
    /** Priority parameters for headers */
    headerPriority?: PriorityParam;
    /** JA3 fingerprint string */
    ja3String?: string;
    /** Key share curves */
    keyShareCurves?: KeyShareCurve[];
    /** Array of priority frames configuration */
    priorityFrames?: PriorityFrames[];
    /** List of supported protocols for the ALPN Extension */
    alpnProtocols?: string[];
    /** List of supported protocols for the ALPS Extension */
    alpsProtocols?: string[];
    /** List of ECH Candidate Payloads */
    ECHCandidatePayloads?: number[];
    /** ECH Candidate Cipher Suites */
    ECHCandidateCipherSuites?: CandidateCipherSuite[];
    /** Order of pseudo headers */
    pseudoHeaderOrder?: string[];
    /** Supported algorithms for delegated credentials */
    supportedDelegatedCredentialsAlgorithms?: SignatureAlgorithm[];
    /** Supported signature algorithms */
    supportedSignatureAlgorithms?: SignatureAlgorithm[];
    /** Supported TLS versions */
    supportedVersions?: SupportedVersion[];
    /** TLS record size limit extension value */
    recordSizeLimit?: number;
    /** Initial HTTP/2 stream ID */
    streamId?: number;
    /** Allow plaintext HTTP connections */
    allowHttp?: boolean;
}
/**
 * HTTP transport configuration options
 */
interface TransportOptions {
    /** If true, keep-alives will be disabled */
    disableKeepAlives?: boolean;
    /** If true, compression will be disabled */
    disableCompression?: boolean;
    /** Maximum number of idle connections */
    maxIdleConns?: number;
    /** Maximum number of idle connections per host */
    maxIdleConnsPerHost?: number;
    /** Maximum number of connections per host */
    maxConnsPerHost?: number;
    /** Maximum number of response header bytes. If zero, a default is used */
    maxResponseHeaderBytes?: number;
    /** Write buffer size. If zero, a default (currently 4KB) is used */
    writeBufferSize?: number;
    /** Read buffer size. If zero, a default (currently 4KB) is used */
    readBufferSize?: number;
    /** Maximum time an idle (keep-alive) connection remains idle before closing itself, in nanoseconds. Zero means no limit */
    idleConnTimeout?: number;
}
/**
 * HTTP Cookie representation
 */
interface Cookie {
    /** The domain of the cookie */
    domain?: string;
    /** The expiration time of the cookie (Unix timestamp) */
    expires?: number;
    /** Number of seconds the cookie is valid. If both expires and maxAge are set, maxAge has precedence */
    maxAge?: number;
    /** The name of the cookie */
    name: string;
    /** The path of the cookie */
    path?: string;
    /** The value of the cookie */
    value: string;
    /** Whether the cookie should only be sent over HTTPS */
    secure?: boolean;
    /** Whether the cookie is inaccessible to client-side scripts */
    httpOnly?: boolean;
}
/**
 * Default options for TLS client configuration
 */
interface TlsClientDefaultOptions {
    /** Identifier of the TLS client (default: 'chrome_146') */
    tlsClientIdentifier?: ClientProfile;
    /** If true, wrapper will retry the request based on retryStatusCodes (default: true) */
    retryIsEnabled?: boolean;
    /** Maximum number of total attempts per request, including the first one (default: 3) */
    retryMaxCount?: number;
    /** Status codes for retries (default: [408, 429, 500, 502, 503, 504, 521, 522, 523, 524]) */
    retryStatusCodes?: number[];
    /** If true, panics will be caught (default: false) */
    catchPanics?: boolean;
    /** Hosts for certificate pinning */
    certificatePinningHosts?: CertificatePinningHosts | null;
    /** Custom TLS client configuration */
    customTlsClient?: CustomTLSClient | null;
    /** Transport options */
    transportOptions?: TransportOptions | null;
    /** If true, redirects will be followed (default: false). Can be changed within a session */
    followRedirects?: boolean;
    /** If true, HTTP/1 will be forced (default: false) */
    forceHttp1?: boolean;
    /** If true, HTTP/3 will be disabled (default: false) */
    disableHttp3?: boolean;
    /** If true, races HTTP/3 (QUIC) and HTTP/2 (TCP) connections in parallel, similar to Chrome's "Happy Eyeballs" approach (default: false). Cannot be used together with forceHttp1 or disableHttp3 */
    withProtocolRacing?: boolean;
    /** Order of headers */
    headerOrder?: string[];
    /** Default headers which will be used in every request */
    defaultHeaders?: Record<string, string> | null;
    /** Headers to be used during the CONNECT request */
    connectHeaders?: Record<string, string[]> | null;
    /** If true, certificate verification will be skipped (default: false). Cannot be changed during a session */
    insecureSkipVerify?: boolean;
    /** If true, the request body must be a base64 encoded string, e.g. for uploading images (default: false) */
    isByteRequest?: boolean;
    /** If true, the response body will be a base64 encoded string, e.g. for downloading images (default: false) */
    isByteResponse?: boolean;
    /** If true, the proxy is rotating (default: false) */
    isRotatingProxy?: boolean;
    /** URL of the proxy. Example: http://user:password@ip:port. Can be changed within a session */
    proxyUrl?: string | null;
    /** Default cookies for requests */
    defaultCookies?: Cookie[] | null;
    /** Override the request host */
    requestHostOverride?: string | null;
    /** If true, IPV6 will be disabled (default: false) */
    disableIPV6?: boolean;
    /** If true, IPV4 will be disabled (default: false) */
    disableIPV4?: boolean;
    /** Local address [not Sure? Docs are not clear] */
    localAddress?: string | null;
    /** Server name overwrite. See: https://bogdanfinn.gitbook.io/open-source-oasis/tls-client/client-options */
    serverNameOverwrite?: string;
    /** Block size of the stream output */
    streamOutputBlockSize?: number | null;
    /** EOF symbol of the stream output */
    streamOutputEOFSymbol?: string | null;
    /** Path of the stream output */
    streamOutputPath?: string | null;
    /** Timeout in milliseconds, takes precedence over timeoutSeconds when set (default: 0) */
    timeoutMilliseconds?: number;
    /** Timeout in seconds (default: 60). Cannot be changed during a session */
    timeoutSeconds?: number;
    /** If true, debug mode is enabled (default: false) */
    withDebug?: boolean;
    /** If true, the old tls-client custom cookie jar is used instead of Go's default jar (default: false) */
    withCustomCookieJar?: boolean;
    /** If true, the cookie jar is not used (default: false) */
    withoutCookieJar?: boolean;
    /** If true, the order of TLS extensions is randomized (default: true) */
    withRandomTLSExtensionOrder?: boolean;
    /** @deprecated Not part of the tls-client payload and ignored; response charset is auto-detected since tls-client 1.15.0 */
    euckrResponse?: boolean;
    /** Custom path to download the TLS library */
    customLibraryDownloadPath?: string | null;
}
/**
 * Options for individual TLS client requests
 * Custom configurable options for the TLS client
 */
interface TlsClientOptions extends Omit<TlsClientDefaultOptions, 'defaultHeaders' | 'defaultCookies'> {
    /** Headers for this specific request */
    headers?: Record<string, string> | null;
    /** Body of the request */
    requestBody?: string | null;
    /** Cookies for this specific request */
    requestCookies?: Cookie[] | null;
    /** ID of the session [not recommended to use, use the SessionClient instead] */
    sessionId?: string | null;
    /** The target URL */
    requestUrl?: string;
    /** HTTP method (GET, POST, etc.) - internal use only */
    requestMethod?: string;
}
/**
 * Response from TLS client request
 */
interface TlsClientResponse {
    /** The reusable sessionId if provided on the request */
    sessionId?: string;
    /** The status code of the response, or 0 in case of an unexpected error */
    status: number;
    /** The target URL of the request */
    target: string;
    /** The response body as a string (base64 encoded if isByteResponse is set), or the error message */
    body: string;
    /** The headers of the response, each header name mapping to its list of values */
    headers: Record<string, string[]>;
    /** The cookies of the response as name-value pairs */
    cookies: Record<string, string>;
    /** The protocol used for the request (e.g. "h2", "HTTP/2.0", "HTTP/1.1") */
    usedProtocol: string;
    /** The number of retries */
    retryCount: number;
}
/**
 * Response containing cookies
 */
interface CookieResponse {
    /** The cookies from the response */
    cookies: Cookie[] | null;
}
/**
 * SessionClient class for managing TLS client sessions
 */
declare class SessionClient {
    defaultOptions: TlsClientDefaultOptions;
    private readonly sessionId;
    private readonly moduleClient;
    private destroyed;
    /**
     * @description Create a new SessionClient
     * @param {ModuleClient} moduleClient - The shared ModuleClient instance
     * @param {TlsClientDefaultOptions} [options={}] - SessionClient options
     */
    constructor(moduleClient: ModuleClient, options?: TlsClientDefaultOptions);
    /**
     * Explicit async cleanup for `await using session = new SessionClient(...)` (TypeScript 5.2+).
     */
    [Symbol.asyncDispose](): Promise<void>;
    /**
     * @description Set the default cookies for the SessionClient
     * @param {Cookie[]} cookies - Array of cookies to set as defaults
     * @returns {void}
     */
    setDefaultCookies(cookies: Cookie[]): void;
    /**
     * @description Set the default headers for the SessionClient
     * @param {Record<string, string>} headers - Object containing header key-value pairs
     * @returns {void}
     */
    setDefaultHeaders(headers: Record<string, string>): void;
    private combineOptions;
    private convertBody;
    private convertUrl;
    /**
     * @description Gets the session ID.
     * @returns {string} The session ID.
     */
    getSession(): string;
    /**
     * @description Destroys the sessionId
     * @param {string} [id=this.sessionId] - The ID associated with the memory to free.
     * @returns {Promise<unknown>} Promise that resolves when the session is destroyed
     */
    destroySession(id?: string): Promise<unknown>;
    private sendRequest;
    private retryRequest;
    private request;
    private send;
    /**
     * @description Send a GET request
     * @param {URL|string} url - The URL to send the request to
     * @param {Partial<TlsClientOptions>} [options={}] - The request options
     * @returns {Promise<TlsClientResponse>} The response from the server
     */
    get(url: URL | string, options?: Partial<TlsClientOptions>): Promise<TlsClientResponse>;
    /**
     * @description Send a POST request
     * @param {URL|string} url - The URL to send the request to
     * @param {object|string} body - The request body
     * @param {Partial<TlsClientOptions>} [options={}] - The request options
     * @returns {Promise<TlsClientResponse>} The response from the server
     */
    post(url: URL | string, body?: RequestBody, options?: Partial<TlsClientOptions>): Promise<TlsClientResponse>;
    /**
     * @description Send a PUT request
     * @param {URL|string} url - The URL to send the request to
     * @param {object|string} body - The request body
     * @param {Partial<TlsClientOptions>} [options={}] - The request options
     * @returns {Promise<TlsClientResponse>} The response from the server
     */
    put(url: URL | string, body?: RequestBody, options?: Partial<TlsClientOptions>): Promise<TlsClientResponse>;
    /**
     * @description Send a DELETE request
     * @param {URL|string} url - The URL to send the request to
     * @param {Partial<TlsClientOptions>} [options={}] - The request options
     * @returns {Promise<TlsClientResponse>} The response from the server
     */
    delete(url: URL | string, options?: Partial<TlsClientOptions>): Promise<TlsClientResponse>;
    /**
     * @description Send a HEAD request
     * @param {URL|string} url - The URL to send the request to
     * @param {Partial<TlsClientOptions>} [options={}] - The request options
     * @returns {Promise<TlsClientResponse>} The response from the server
     */
    head(url: URL | string, options?: Partial<TlsClientOptions>): Promise<TlsClientResponse>;
    /**
     * @description Send a PATCH request
     * @param {URL|string} url - The URL to send the request to
     * @param {object|string} body - The request body
     * @param {Partial<TlsClientOptions>} [options={}] - The request options
     * @returns {Promise<TlsClientResponse>} The response from the server
     */
    patch(url: URL | string, body?: RequestBody, options?: Partial<TlsClientOptions>): Promise<TlsClientResponse>;
    /**
     * @description Send an OPTIONS request
     * @param {URL|string} url - The URL to send the request to
     * @param {Partial<TlsClientOptions>} [options={}] - The request options
     * @returns {Promise<TlsClientResponse>} The response from the server
     */
    options(url: URL | string, options?: Partial<TlsClientOptions>): Promise<TlsClientResponse>;
    /**
     * @description Get the cookies for a given session and URL
     * @param {string} sessionId - The existing session ID.
     * @param {string} url - The URL to get cookies for.
     * @returns {Promise<CookieResponse>} Promise that resolves to the cookie response
     */
    getCookiesFromSession(sessionId: string, url: string): Promise<CookieResponse>;
    /**
     * @deprecated Use requestCookies instead
     * @description Add cookies to a given session
     * @param {string} sessionId - The existing session ID.
     * @param {string} url - The URL to add cookies for.
     * @param {Cookie[]} cookies - The cookies to add.
     * @returns {Promise<CookieResponse>} Promise that resolves to the cookie response
     */
    addCookiesToSession(sessionId: string, url: string, cookies: Cookie[]): Promise<CookieResponse>;
    /**
     * @description Destroy all existing sessions in order to release allocated memory.
     * @returns {Promise<unknown>} Promise that resolves when all sessions are destroyed
     */
    destroyAll(): Promise<unknown>;
    private exec;
}
declare const _default: {
    SessionClient: typeof SessionClient;
    ModuleClient: typeof ModuleClient;
};

// @ts-ignore
export = _default;
export { type AeadId, type BraveProfile, type CandidateCipherSuite, type CertCompressionAlgorithm, type CertificatePinningHosts, type ChromeProfile, type ClientProfile, type Cookie, type CookieResponse, type CustomClientProfile, type CustomTLSClient, type FirefoxProfile, type H2SettingsKey, type H3SettingsKey, type KdfId, type KeyShareCurve, ModuleClient, type ModuleClientOptions, type OkHttp4Profile, type OperaProfile, type PoolStats, type PriorityFrames, type PriorityParam, type RequestBody, type SafariIOSProfile, type SafariIpadOSProfile, type SafariProfile, SessionClient, type SignatureAlgorithm, type SupportedVersion, type TlsClientDefaultOptions, type TlsClientOptions, type TlsClientResponse, type TransportOptions };
