import FormData from 'form-data'; type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "CONNECT" | "TRACE"; type AssertionType = "status" | "header" | "body" | "custom" | "response-time" | "json-schema"; interface RunOptions { verbose?: boolean; var?: string; parallel?: boolean; maxConcurrency?: number; timeout?: number; bail?: boolean; } interface VariableUpdate { key: string; value: string; } interface Assertion { type: AssertionType; key?: string; value?: unknown | ((value: unknown) => boolean) | string; description?: string; timeout?: number; } interface TestItem { type: "Assert"; name?: string; assertions: Assertion[]; timeout?: number; retries?: number; } interface ParsedScript$1 { type: 'inline' | 'file'; content?: string; path?: string; } /** * Authentication configuration for a request */ interface AuthConfig { type: 'basic' | 'bearer' | 'digest' | 'oauth2' | string; username?: string; password?: string; token?: string; /** Additional auth-specific options */ [key: string]: unknown; } interface HttpRequest { name: string; method: HttpMethod; url: string; headers: Record; body?: string | FormData | object; tests: TestItem[]; variableUpdates: VariableUpdate[]; expectError?: boolean; /** Named request identifier for REST Client @name directive */ requestId?: string; /** File path for body content (REST Client < filepath syntax) */ bodyFromFile?: string; /** Pre-request scripts (< {% %} or < filepath.js) */ preRequestScripts?: ParsedScript$1[]; /** Response handler scripts (> {% %} or > filepath.js) */ responseHandlers?: ParsedScript$1[]; /** Authentication configuration */ auth?: AuthConfig; } interface HttpResponse { status: number; statusText?: string; headers: Record; data: T; executionTime?: number; /** Response time in milliseconds (alias for executionTime) */ time?: number; } interface TestResult { name: string; passed: boolean; error?: Error; statusCode?: number; executionTime?: number; retryCount?: number; /** HTTP response data for displaying in UI */ response?: HttpResponse; } interface TestSummary { totalTests: number; passedTests: number; failedTests: number; skippedTests?: number; totalExecutionTime?: number; results: TestResult[]; startTime?: Date; endTime?: Date; } interface Variables { [key: string]: string | number | boolean; } /** * Stored response data for named requests */ interface StoredResponse { status: number; statusText?: string; headers: Record; body: unknown; } declare class VariableManager { private variables; private namedResponses; setVariables(variables: Variables): void; replaceVariables(content: string): string; setVariable(key: string, value: string | number | boolean): void; getVariable(key: string): string | number | boolean | undefined; getAllVariables(): Variables; /** * Store response for a named request */ storeNamedResponse(requestId: string, response: HttpResponse): void; /** * Get stored response for a named request */ getNamedResponse(requestId: string): StoredResponse | undefined; /** * Process named request reference syntax: * - {{requestName.response.body}} - entire body * - {{requestName.response.body.field}} - specific field * - {{requestName.response.body.$.jsonpath}} - JSONPath expression * - {{requestName.response.headers.Content-Type}} - specific header * - {{requestName.response.status}} - status code */ private processNamedRequestReferences; /** * Extract value from stored response using path */ private extractFromResponse; /** * Get nested value from object using dot notation */ private getNestedValue; /** * Clear all named responses (useful for test isolation) */ clearNamedResponses(): void; } declare class HttpFileParser { private variableManager; constructor(variableManager: VariableManager); parse(filePath: string): Promise; private removeComments; private splitIntoSections; private parseRequests; private handleGlobalVariables; } declare class AssertionEngine { private variableManager; private baseDir; constructor(variableManager: VariableManager, baseDir: string); assert(assertion: Assertion, response: HttpResponse, request: HttpRequest): Promise; private assertStatus; private assertHeader; private assertContentType; private assertBody; private parseResponseData; private assertJsonPath; private parseValue; private adjustJsonPath; private isEqual; private assertCustom; private runCustomValidator; private resolvePath; } interface HttpTestConfig { timeouts: { serverCheck: number; request: number; response: number; }; security: { rejectUnauthorized: boolean; allowInsecureConnections: boolean; }; retries: { maxAttempts: number; backoffMultiplier: number; initialDelay: number; }; logging: { level: 'silent' | 'error' | 'warn' | 'info' | 'verbose'; colorOutput: boolean; }; performance: { maxConcurrentRequests: number; requestBufferSize: number; }; } /** * CookieJar - Automatic Cookie Management * * Supports: * - Storing cookies from Set-Cookie headers * - Domain and path matching * - Cookie expiration (Max-Age, Expires) * - Secure and HttpOnly flags * - SameSite attribute */ interface Cookie { name: string; value: string; domain: string; path: string; expires?: Date; secure: boolean; httpOnly: boolean; sameSite?: 'Strict' | 'Lax' | 'None'; hostOnly: boolean; } declare class CookieJar { private cookies; /** * Set a cookie from a Set-Cookie header value */ setCookie(setCookieHeader: string, requestUrl: string): void; /** * Set multiple cookies from an array of Set-Cookie headers */ setCookies(setCookieHeaders: string[], requestUrl: string): void; /** * Get all cookies that match the given URL */ getCookies(requestUrl: string): string[]; /** * Get cookie header string for a request URL */ getCookieHeader(requestUrl: string): string; /** * Get a specific cookie by name for a URL */ getCookieByName(name: string, requestUrl: string): Cookie | undefined; /** * Get all stored cookies */ getAllCookies(): Cookie[]; /** * Clear all cookies */ clear(): void; /** * Clear cookies for a specific domain */ clearDomain(domain: string): void; private parseCookie; private getDefaultPath; private getMatchingCookies; private domainMatches; private pathMatches; private findCookieIndex; private removeCookie; } /** * Executes HTTP requests and processes responses. */ declare class RequestExecutor { private variableManager; private baseDir; private config; private axiosInstance; private cookieJar; /** * Creates an instance of RequestExecutor. * @param variableManager - The VariableManager instance to use. * @param baseDir - Base directory for resolving file paths. * @param customConfig - Optional custom configuration. * @param cookieJar - Optional CookieJar for automatic cookie management. */ constructor(variableManager: VariableManager, baseDir: string, customConfig?: Partial, cookieJar?: CookieJar); /** * Get the CookieJar instance */ getCookieJar(): CookieJar; execute(request: HttpRequest): Promise; private applyVariables; private validateUrl; private checkServerStatus; private sendRequest; private processCookiesFromResponse; private parseJsonBody; private parseFormData; private buildFormData; private handleRequestError; } declare class ResponseProcessor { private variableManager; constructor(variableManager: VariableManager); process(response: HttpResponse, variableUpdates: VariableUpdate[]): Promise; private processVariableUpdates; private evaluateExpression; private extractValueFromJsonPath; } declare class TestResultCollector { private results; addResult(result: TestResult): void; getResults(): TestResult[]; getSummary(): TestSummary; } /** * ScriptEngine - JetBrains HTTP Client Compatible Scripting Engine * * Provides sandboxed JavaScript execution for: * - Response handler scripts (> {% %}) * - Pre-request scripts (< {% %}) * * Implements client/response/request APIs compatible with JetBrains HTTP Client */ interface ScriptTestResult$1 { name: string; passed: boolean; error?: string; } interface ScriptResult$1 { success: boolean; error?: Error; logs?: string[]; tests?: ScriptTestResult$1[]; variables?: Map; } interface ScriptContext$1 { response?: HttpResponse; isPreRequest?: boolean; variables?: Map; } interface ParsedScript { type: 'inline' | 'file'; content?: string; path?: string; } interface ContentType { mimeType: string; charset?: string; } /** * Simple JSONPath implementation for basic path queries * Supports: $.property, $.array[index], $.array.length */ declare function jsonPath(obj: unknown, path: string): unknown; declare class ScriptEngine { private globals; /** * Execute a script in a sandboxed environment */ execute(script: string, context?: ScriptContext$1): Promise; /** * Execute a script from external file content */ executeFile(_filePath: string, content: string, context?: ScriptContext$1): Promise; /** * Clear all global variables */ clearGlobals(): void; /** * Get all global variables (for debugging/testing) */ getGlobals(): Map; /** * Parse response handler scripts from HTTP file content * Syntax: * > {% script content %} * > path/to/script.js */ static parseResponseHandlers(content: string): ParsedScript[]; /** * Parse pre-request scripts from HTTP file content * Syntax: * < {% script content %} * < path/to/script.js */ static parsePreRequestScripts(content: string): ParsedScript[]; } /** * Simple Dependency Injection Container * * Provides basic DI functionality for managing application dependencies. * Supports singleton and factory registrations. */ type Factory = (container: Container) => T; declare class Container { private registrations; /** * Register a singleton instance * @param key Unique identifier for the dependency * @param instance The singleton instance */ registerSingleton(key: string, instance: T): void; /** * Register a factory function that creates new instances * @param key Unique identifier for the dependency * @param factory Function that creates the instance */ registerFactory(key: string, factory: Factory): void; /** * Resolve a dependency by key * @param key Unique identifier for the dependency * @returns The resolved instance * @throws Error if dependency is not registered */ resolve(key: string): T; /** * Check if a dependency is registered * @param key Unique identifier for the dependency * @returns true if registered, false otherwise */ has(key: string): boolean; /** * Clear all registered dependencies */ clear(): void; /** * Get all registered keys * @returns Array of registered dependency keys */ getRegisteredKeys(): string[]; } /** * Default container instance for the application */ declare const container: Container; /** * Container registration keys for core dependencies */ declare const ContainerKeys: { readonly VariableManager: "IVariableManager"; readonly HttpFileParser: "IHttpFileParser"; readonly RequestExecutor: "IRequestExecutor"; readonly AssertionEngine: "IAssertionEngine"; readonly ScriptEngine: "IScriptEngine"; readonly EnvironmentManager: "EnvironmentManager"; readonly CookieJar: "CookieJar"; }; /** * Container Setup Module * * Provides factory functions to configure the DI container * for different use cases (testing, production). */ /** * Options for container setup */ interface ContainerSetupOptions { /** Base directory for file resolution */ baseDir: string; /** Whether to use singletons (default: true) */ useSingletons?: boolean; } /** * Extended container keys for internal components */ declare const InternalKeys: { readonly ResponseProcessor: "ResponseProcessor"; readonly TestResultCollector: "TestResultCollector"; }; /** * Setup the container with all core dependencies * @param options Configuration options * @param targetContainer Container to setup (defaults to global container) */ declare function setupContainer(options: ContainerSetupOptions, targetContainer?: Container): void; /** * Create a pre-configured container for testing * @param baseDir Base directory for file resolution * @returns Configured container instance */ declare function createTestContainer(baseDir: string): Container; /** * Resolve dependencies from container for TestManager construction * @param targetContainer Container to resolve from */ declare function resolveTestManagerDependencies(targetContainer?: Container): { variableManager: VariableManager; scriptEngine: ScriptEngine; requestExecutor: RequestExecutor; assertionEngine: AssertionEngine; responseProcessor: ResponseProcessor; resultCollector: TestResultCollector; }; /** * Dependencies required by TestManager */ interface TestManagerDependencies { variableManager: VariableManager; assertionEngine: AssertionEngine; requestExecutor: RequestExecutor; responseProcessor: ResponseProcessor; resultCollector: TestResultCollector; scriptEngine: ScriptEngine; } declare class TestManager { private requestExecutor; private responseProcessor; private resultCollector; private variableManager; private assertionEngine; private scriptEngine; private baseDir; /** * Create a TestManager instance * @param httpFilePath Path to the .http file (used for baseDir) * @param deps Optional pre-configured dependencies (for DI) */ constructor(httpFilePath: string, deps?: TestManagerDependencies); /** * Create a TestManager using DI container * @param httpFilePath Path to the .http file * @param container Optional container (uses global if not provided) */ static createWithContainer(httpFilePath: string, container?: Container): TestManager; run(requests: HttpRequest[], options?: RunOptions): Promise; private processRequest; /** * Execute pre-request scripts before making the HTTP request */ private executePreRequestScripts; /** * Execute response handler scripts after receiving HTTP response */ private executeResponseHandlers; /** * Resolve script content from inline or file reference */ private resolveScriptContent; private runTests; private createTestResult; private createDefaultStatusCodeTest; private handleRequestError; } /** * EnvironmentManager - JetBrains HTTP Client Compatible Environment Management * * Supports: * - http-client.env.json (public environments) * - http-client.private.env.json (private/sensitive variables) * - Multiple environment selection (dev, prod, test, etc.) * - Nested variable access with dot notation * - Runtime variable overrides */ interface EnvironmentConfig { [envName: string]: EnvironmentVariables; } interface EnvironmentVariables { [key: string]: string | number | boolean | object | unknown[]; } declare class EnvironmentManager { private baseDir; private publicEnv; private privateEnv; private mergedEnv; private currentEnvName; private runtimeVariables; constructor(baseDir: string); /** * Load environment files from the base directory */ load(): Promise; private loadPublicEnv; private loadPrivateEnv; private loadEnvFile; private mergeEnvironments; /** * Get list of available environment names */ getAvailableEnvironments(): string[]; /** * Select an environment by name */ selectEnvironment(envName: string): void; /** * Get the currently selected environment name */ getCurrentEnvironment(): string | undefined; /** * Auto-select a default environment * Priority: dev > development > first available */ autoSelectDefaultEnvironment(): void; /** * Get a variable value from the current environment * Supports dot notation for nested values (e.g., "database.host") */ getVariable(key: string): unknown; private getNestedValue; /** * Get all variables for the current environment */ getAllVariables(): EnvironmentVariables; /** * Set a runtime variable that overrides environment values */ setRuntimeVariable(key: string, value: unknown): void; /** * Replace {{variable}} placeholders in a string with environment values */ replaceVariables(content: string): string; /** * Export variables to a format compatible with VariableManager */ exportToVariables(): Record; private flattenObject; } /** * ScriptBlockParser * * Parses script blocks from HTTP request content. * Handles both pre-request scripts (< {% %}) and response handlers (> {% %}). * * JetBrains HTTP Client compatible syntax: * - Pre-request scripts: < {% script %} or < script.js * - Response handlers: > {% script %} or > script.js */ /** * Result from parsing all scripts in content */ interface ParsedScriptsResult { preRequestScripts: ParsedScript$1[]; responseHandlers: ParsedScript$1[]; } declare class ScriptBlockParser { /** * Parse response handler scripts from content * Syntax: * > {% script content %} * > path/to/script.js */ parseResponseHandlers(content: string): ParsedScript$1[]; /** * Parse pre-request scripts from content * Syntax: * < {% script content %} * < path/to/script.js (only .js files, not body references) */ parsePreRequestScripts(content: string): ParsedScript$1[]; /** * Remove all script blocks from content * Returns content with script blocks filtered out */ removeScriptBlocks(section: string): string; /** * Parse all scripts (pre-request and response handlers) from content */ parseAllScripts(content: string): ParsedScriptsResult; /** * Parse response handler scripts from HTTP file content * Syntax: * > {% script content %} * > path/to/script.js */ static parseResponseHandlers(content: string): ParsedScript$1[]; /** * Parse pre-request scripts from HTTP file content * Syntax: * < {% script content %} * < path/to/script.js (only .js files are treated as scripts) */ static parsePreRequestScripts(content: string): ParsedScript$1[]; } /** * VariableLineParser * * Parses variable lines from HTTP request content. * Handles REST Client @name directive and variable assignments. * * Supported syntax: * - @name requestId (REST Client named request) * - @key = value (variable assignment) * - @key = $.jsonpath (JSONPath for response variable extraction) */ /** * Type of variable line */ type VariableLineType = 'name' | 'variable' | 'jsonpath' | 'invalid'; /** * Result from parsing a variable line */ interface VariableLineResult { type: VariableLineType; /** Request ID for @name directive */ requestId?: string; /** Variable key */ key?: string; /** Variable value or JSONPath expression */ value?: string; /** Whether value is a JSONPath expression */ isJsonPath?: boolean; /** Error message for invalid lines */ error?: string; } declare class VariableLineParser { /** * Check if a line is a variable line (starts with @) */ isVariableLine(line: string): boolean; /** * Parse a single variable line */ parse(line: string): VariableLineResult; /** * Parse multiple lines, returning results for variable lines only */ parseMultiple(lines: string[]): VariableLineResult[]; /** * Extract all variable lines from content */ extractFromContent(content: string): VariableLineResult[]; /** * Convert a parse result to VariableUpdate format * Returns null for name directives or invalid results */ toVariableUpdate(result: VariableLineResult): VariableUpdate | null; /** * Check if a line is a variable line (starts with @) */ static isVariableLine(line: string): boolean; /** * Parse a single variable line */ static parse(line: string): VariableLineResult; } /** * RequestLineParser * * Parses HTTP request lines (method, URL) and header lines. * Handles all standard HTTP methods and header parsing. * * Supported syntax: * - METHOD URL [HTTP/version] * - Header-Name: header-value */ /** * Result from parsing a method line */ interface RequestLineResult { method: HttpMethod; url: string; } /** * Result from parsing a header line */ interface HeaderResult { key: string; value: string; } /** * Result from parsing multiple lines */ interface ParsedLinesResult { method: HttpMethod | null; url: string | null; headers: HeaderResult[]; /** Index where body content starts (after empty line) */ bodyStartIndex: number | null; } declare class RequestLineParser { /** * Regex pattern for detecting HTTP method lines */ private static readonly METHOD_PATTERN; /** * Check if a line is an HTTP method line */ isMethodLine(line: string): boolean; /** * Parse a method line to extract method and URL */ parseMethodLine(line: string): RequestLineResult | null; /** * Check if a line is a header line */ isHeaderLine(line: string): boolean; /** * Parse a header line to extract key and value */ parseHeaderLine(line: string): HeaderResult | null; /** * Parse multiple lines to extract method, URL, and headers * Stops at empty line (body start) */ parseLines(lines: string[]): ParsedLinesResult; /** * Check if a line is an HTTP method line */ static isMethodLine(line: string): boolean; /** * Parse a method line to extract method and URL */ static parseMethodLine(line: string): RequestLineResult | null; /** * Check if a line is a header line */ static isHeaderLine(line: string): boolean; /** * Parse a header line to extract key and value */ static parseHeaderLine(line: string): HeaderResult | null; } /** * Assertion Handler Interface * * Defines the contract for assertion handlers in the assertion pipeline. * Each handler is responsible for a specific type of assertion. */ /** * Result of an assertion check */ interface AssertionResult { /** Whether the assertion passed */ passed: boolean; /** The assertion key (e.g., "Status", "Content-Type", "$.data.id") */ assertionKey: string; /** The expected value */ expected: string; /** The actual value found */ actual: string; /** Optional message explaining the result */ message?: string; } /** * Assertion handler interface * * Handlers are responsible for: * 1. Determining if they can handle a specific assertion key * 2. Performing the assertion and returning the result */ interface IAssertionHandler { /** Unique type identifier for this handler */ readonly type: string; /** * Check if this handler can process the given assertion key * @param key The assertion key (e.g., "Status", "Content-Type", "$.data.id") * @returns true if this handler can process the assertion */ canHandle(key: string): boolean; /** * Perform the assertion * @param key The assertion key * @param value The expected value * @param response The HTTP response to assert against * @param request Optional HTTP request for context * @returns The assertion result */ assert(key: string, value: string, response: HttpResponse, request?: HttpRequest): AssertionResult; } /** * Options for assertion handlers */ interface AssertionHandlerOptions { /** Variable manager for variable replacement */ variableManager?: { replaceVariables(content: string): string; }; } /** * AssertionRegistry * * Manages assertion handler registration and lookup. * Provides a central registry for all assertion types. */ /** * Registration options */ interface RegistrationOptions { /** Force replace existing handler of same type */ force?: boolean; } /** * Assertion input for bulk assertions */ interface AssertionInput { key: string; value: string; } declare class AssertionRegistry { private handlers; /** * Register a handler * @param handler The handler to register * @param options Registration options * @throws Error if handler type already registered (unless force=true) */ register(handler: IAssertionHandler, options?: RegistrationOptions): void; /** * Check if a handler type is registered */ hasHandler(type: string): boolean; /** * Get the number of registered handlers */ getHandlerCount(): number; /** * Find a handler that can process the given assertion key * @param key The assertion key * @returns The handler or null if not found */ findHandler(key: string): IAssertionHandler | null; /** * Perform a single assertion * @param key The assertion key * @param value The expected value * @param response The HTTP response * @param request Optional HTTP request * @returns The assertion result * @throws Error if no handler found */ assert(key: string, value: string, response: HttpResponse, request?: HttpRequest): AssertionResult; /** * Perform multiple assertions * @param assertions Array of assertion inputs * @param response The HTTP response * @param request Optional HTTP request * @returns Array of assertion results */ assertAll(assertions: AssertionInput[], response: HttpResponse, request?: HttpRequest): AssertionResult[]; /** * Create a registry with all default handlers */ static createDefault(): AssertionRegistry; } /** * StatusCodeHandler * * Handles status code assertions. * Supports exact match, numeric values, and range patterns (2xx, 4xx, etc.) */ declare class StatusCodeHandler implements IAssertionHandler { readonly type = "status"; canHandle(key: string): boolean; assert(key: string, value: string, response: HttpResponse): AssertionResult; } /** * HeaderHandler * * Handles HTTP header assertions. * Supports exact match, existence check (*), and case-insensitive header names. */ declare class HeaderHandler implements IAssertionHandler { readonly type = "header"; private static readonly KNOWN_HEADERS; canHandle(key: string): boolean; assert(key: string, value: string, response: HttpResponse): AssertionResult; } /** * JsonPathHandler * * Handles JSONPath assertions against response body. * Supports JSONPath expressions starting with $. or $[ */ declare class JsonPathHandler implements IAssertionHandler { readonly type = "jsonpath"; canHandle(key: string): boolean; assert(key: string, value: string, response: HttpResponse): AssertionResult; private valueToString; private compareValues; } /** * ResponseTimeHandler * * Handles response time assertions. * Supports comparison operators: <, >, <=, >=, exact match */ declare class ResponseTimeHandler implements IAssertionHandler { readonly type = "responsetime"; canHandle(key: string): boolean; assert(key: string, value: string, response: HttpResponse): AssertionResult; private parseValue; private compare; } /** * BodyExistsHandler * * Handles body existence and content assertions. * Supports existence check (*) and exact content match. */ declare class BodyExistsHandler implements IAssertionHandler { readonly type = "body"; canHandle(key: string): boolean; assert(key: string, value: string, response: HttpResponse): AssertionResult; } /** * IHttpFileParser Interface * * Contract for .http file parsing implementations. * Parses HTTP request files into structured request objects. */ interface IHttpFileParser { /** * Parse an .http file and return an array of HTTP requests * @param filePath Path to the .http file * @returns Promise resolving to array of parsed HTTP requests * @throws Error if file cannot be read or parsed */ parse(filePath: string): Promise; } /** * IRequestExecutor Interface * * Contract for HTTP request execution implementations. * Handles sending HTTP requests and receiving responses. */ interface IRequestExecutor { /** * Execute an HTTP request and return the response * @param request The HTTP request to execute * @returns Promise resolving to the HTTP response * @throws Error if request fails or URL is invalid */ execute(request: HttpRequest): Promise; } /** * IAssertionEngine Interface * * Contract for assertion engine implementations. * Validates HTTP responses against defined assertions. */ interface IAssertionEngine { /** * Assert that a response matches the expected assertion * @param assertion The assertion to validate * @param response The HTTP response to validate against * @param request Optional HTTP request for context * @returns Promise that resolves if assertion passes, rejects if it fails */ assert(assertion: Assertion, response: HttpResponse, request?: HttpRequest): Promise; } /** * IVariableManager Interface * * Contract for variable management implementations. * Handles variable storage, retrieval, and template replacement. */ interface IVariableManager { /** * Set multiple variables at once from an object * @param variables Object containing key-value pairs */ setVariables(variables: Variables): void; /** * Set a single variable * @param key Variable name * @param value Variable value (string, number, or boolean) */ setVariable(key: string, value: string | number | boolean): void; /** * Get a variable value by key * @param key Variable name * @returns Variable value or undefined if not found */ getVariable(key: string): string | number | boolean | undefined; /** * Replace {{variable}} placeholders in a string with their values * @param content String containing variable placeholders * @returns String with variables replaced */ replaceVariables(content: string): string; /** * Get all stored variables * @returns Object containing all variables */ getAllVariables(): Variables; } /** * IScriptEngine Interface * * Contract for script engine implementations. * Executes JavaScript scripts in a sandboxed environment. * * Note: Re-exports types from core/ScriptEngine for compatibility. */ /** * Script test result from client.test() */ interface ScriptTestResult { name: string; passed: boolean; error?: string; } /** * Result of script execution */ interface ScriptResult { success: boolean; error?: Error; logs?: string[]; tests?: ScriptTestResult[]; variables?: Map; } /** * Context provided to script execution */ interface ScriptContext { response?: HttpResponse; isPreRequest?: boolean; variables?: Map; } interface IScriptEngine { /** * Execute a script in a sandboxed environment * @param script The script content as string * @param context The execution context (response, variables) * @returns Promise resolving to script execution result */ execute(script: string, context?: ScriptContext): Promise; /** * Execute a script from file * @param filePath Path to the script file * @param context The execution context * @returns Promise resolving to script execution result */ executeFile(filePath: string, context?: ScriptContext): Promise; /** * Get all global variables set by scripts * @returns Map containing all global variables */ getGlobals(): Map; /** * Clear all global variables */ clearGlobals(): void; } /** * Authentication Provider Interface * * Defines the contract for authentication providers. * Each provider handles a specific authentication scheme. */ /** * Context provided to auth providers */ interface AuthContext { /** Variable manager for variable replacement */ variables: { get(key: string): string | undefined; set(key: string, value: string): void; getAll(): Record; }; /** Optional challenge from previous 401 response (for digest auth) */ challenge?: string; } /** * Authentication provider interface */ interface IAuthProvider { /** Unique name for this provider */ readonly name: string; /** * Check if this provider can handle the given request * @param request The HTTP request * @returns true if this provider can handle authentication for this request */ canHandle(request: HttpRequest): boolean; /** * Apply authentication to the request * @param request The HTTP request to modify * @param context Authentication context with variables * @returns Modified request with authentication applied */ applyAuth(request: HttpRequest, context: AuthContext): Promise; } /** * AuthRegistry * * Manages authentication provider registration and lookup. */ /** * Registration options */ interface AuthRegistrationOptions { /** Force replace existing provider of same name */ force?: boolean; } declare class AuthRegistry { private providers; /** * Register an auth provider * @param provider The provider to register * @param options Registration options * @throws Error if provider name already registered (unless force=true) */ register(provider: IAuthProvider, options?: AuthRegistrationOptions): void; /** * Get the number of registered providers */ getProviderCount(): number; /** * Find a provider that can handle the given request * @param request The HTTP request * @returns The provider or null if none found */ findProvider(request: HttpRequest): IAuthProvider | null; /** * Apply authentication to a request using the appropriate provider * @param request The HTTP request * @param context Authentication context * @returns Modified request with authentication applied */ applyAuth(request: HttpRequest, context: AuthContext): Promise; /** * Create a registry with all default providers */ static createDefault(): AuthRegistry; } /** * BasicAuthProvider * * Handles HTTP Basic Authentication. * Supports @auth basic directive and Authorization: Basic header. */ declare class BasicAuthProvider implements IAuthProvider { readonly name = "basic"; canHandle(request: HttpRequest): boolean; applyAuth(request: HttpRequest, context: AuthContext): Promise; private getAuthHeader; private isBase64Encoded; private replaceVariables; } /** * BearerTokenProvider * * Handles Bearer Token Authentication. * Supports @auth bearer directive and Authorization: Bearer header. */ declare class BearerTokenProvider implements IAuthProvider { readonly name = "bearer"; canHandle(request: HttpRequest): boolean; applyAuth(request: HttpRequest, context: AuthContext): Promise; private getAuthHeader; private replaceVariables; } /** * DigestAuthProvider * * Handles HTTP Digest Authentication. * Note: Digest auth requires a challenge from the server first, * so this provider marks requests for digest auth handling. */ declare class DigestAuthProvider implements IAuthProvider { readonly name = "digest"; canHandle(request: HttpRequest): boolean; applyAuth(request: HttpRequest, context: AuthContext): Promise; private computeDigestHeader; private parseChallenge; private generateCnonce; private md5; private replaceVariables; } declare class OAuth2Provider implements IAuthProvider { readonly name = "oauth2"; /** Token cache keyed by cache key (tokenUrl + clientId + grantType) */ private tokenCache; /** Buffer time before token expiry to refresh (in milliseconds) */ private readonly expiryBufferMs; canHandle(request: HttpRequest): boolean; applyAuth(request: HttpRequest, context: AuthContext): Promise; /** * Clear the token cache */ clearTokenCache(): void; /** * Check if cached token is still valid */ private isTokenValid; /** * Generate cache key from auth config */ private generateCacheKey; /** * Fetch token from authorization server */ private fetchToken; /** * Add client_credentials grant parameters */ private addClientCredentialsParams; /** * Add password grant parameters */ private addPasswordParams; /** * Add refresh_token grant parameters */ private addRefreshTokenParams; /** * Replace variable placeholders with actual values */ private replaceVariables; } /** * Pipeline Stage Interface * * Defines the contract for pipeline stages that process * HTTP requests before execution and responses after. */ /** * Context shared across pipeline stages */ interface PipelineContext { /** Variable manager */ variables: { get(key: string): string | undefined; set(key: string, value: any): void; replace(content: string): string; }; /** Global variables (persisted across requests) */ globals: Map; /** Optional cookies */ cookies?: Map; } /** * Pipeline stage interface * * Stages can implement one or both of: * - processRequest: Modify request before execution * - processResponse: Process response after execution */ interface IPipelineStage { /** Unique name for this stage */ readonly name: string; /** * Process request before execution * @param request The HTTP request * @param context Pipeline context * @returns Modified request */ processRequest?(request: HttpRequest, context: PipelineContext): Promise; /** * Process response after execution * @param request The original request * @param response The HTTP response * @param context Pipeline context */ processResponse?(request: HttpRequest, response: HttpResponse, context: PipelineContext): Promise; } /** * ExecutionPipeline * * Manages pipeline stages for request/response processing. * Executes stages in order for request preprocessing and response postprocessing. */ declare class ExecutionPipeline { private stages; /** * Add a stage to the pipeline * @param stage The stage to add */ addStage(stage: IPipelineStage): void; /** * Get the number of stages in the pipeline */ getStageCount(): number; /** * Process a request through all stages * @param request The HTTP request * @param context Pipeline context * @returns Processed request */ processRequest(request: HttpRequest, context: PipelineContext): Promise; /** * Process a response through all stages * @param request The original request * @param response The HTTP response * @param context Pipeline context */ processResponse(request: HttpRequest, response: HttpResponse, context: PipelineContext): Promise; /** * Create a pipeline with default stages */ static createDefault(): ExecutionPipeline; } /** * RequestPreprocessor * * Pipeline stage that preprocesses requests before execution. * Handles variable replacement in URL, headers, and body. */ declare class RequestPreprocessor implements IPipelineStage { readonly name = "request-preprocessor"; processRequest(request: HttpRequest, context: PipelineContext): Promise; } /** * ResponsePostprocessor * * Pipeline stage that processes responses after execution. * Handles variable extraction using JSONPath expressions. */ declare class ResponsePostprocessor implements IPipelineStage { readonly name = "response-postprocessor"; processResponse(request: HttpRequest, response: HttpResponse, context: PipelineContext): Promise; private extractVariables; } /** * Plugin Interface * * Defines the contract for http-test plugins. * Plugins can hook into the request/response lifecycle. */ /** * Plugin hook types */ type PluginHook = 'init' | 'destroy' | 'beforeRequest' | 'afterResponse'; /** * Context provided to plugins */ interface PluginContext { /** Variable manager */ variables: { get(key: string): string | undefined; set(key: string, value: any): void; getAll(): Record; }; /** Logger */ logger: { info(message: string, ...args: any[]): void; warn(message: string, ...args: any[]): void; error(message: string, ...args: any[]): void; debug(message: string, ...args: any[]): void; }; /** Plugin configuration */ config: Record; } /** * Plugin interface */ interface IPlugin { /** Unique plugin name */ readonly name: string; /** Plugin version */ readonly version: string; /** Optional description */ readonly description?: string; /** * Initialize the plugin * Called when the plugin is registered * @param context Plugin context */ init(context?: PluginContext): Promise; /** * Cleanup the plugin * Called when the plugin is unregistered */ destroy?(): Promise; /** * Hook called before each request is executed * Can modify the request * @param request The HTTP request * @param context Plugin context * @returns Modified request */ beforeRequest?(request: HttpRequest, context: PluginContext): Promise; /** * Hook called after each response is received * @param request The original request * @param response The HTTP response * @param context Plugin context */ afterResponse?(request: HttpRequest, response: HttpResponse, context: PluginContext): Promise; } /** * Plugin information for listing */ interface PluginInfo { name: string; version: string; description?: string; } /** * PluginManager * * Manages plugin registration and lifecycle. * Executes plugin hooks at appropriate points. */ declare class PluginManager { private plugins; /** * Get the number of registered plugins */ getPluginCount(): number; /** * Check if a plugin is registered * @param name Plugin name */ hasPlugin(name: string): boolean; /** * Register a plugin * @param plugin The plugin to register * @param context Optional context for initialization * @throws Error if plugin with same name already registered */ register(plugin: IPlugin, context?: PluginContext): Promise; /** * Unregister a plugin * @param name Plugin name */ unregister(name: string): Promise; /** * List all registered plugins */ listPlugins(): PluginInfo[]; /** * Execute beforeRequest hooks for all plugins * @param request The HTTP request * @param context Plugin context * @returns Modified request */ executeBeforeRequest(request: HttpRequest, context: PluginContext): Promise; /** * Execute afterResponse hooks for all plugins * @param request The original request * @param response The HTTP response * @param context Plugin context */ executeAfterResponse(request: HttpRequest, response: HttpResponse, context: PluginContext): Promise; /** * Destroy all plugins */ destroyAll(): Promise; } export { AssertionRegistry, AuthRegistry, BasicAuthProvider, BearerTokenProvider, BodyExistsHandler, Container, ContainerKeys, CookieJar, DigestAuthProvider, EnvironmentManager, ExecutionPipeline, HeaderHandler, HttpFileParser, InternalKeys, JsonPathHandler, OAuth2Provider, PluginManager, RequestLineParser, RequestPreprocessor, ResponsePostprocessor, ResponseTimeHandler, ScriptBlockParser, ScriptEngine, StatusCodeHandler, TestManager, VariableLineParser, container, createTestContainer, jsonPath, resolveTestManagerDependencies, setupContainer }; export type { AssertionHandlerOptions, AssertionInput, AssertionResult, AuthContext, AuthRegistrationOptions, ContainerSetupOptions, ContentType, Cookie, EnvironmentConfig, EnvironmentVariables, HeaderResult, IAssertionEngine, IAssertionHandler, IAuthProvider, IHttpFileParser, IPipelineStage, IPlugin, IRequestExecutor, IScriptEngine, IVariableManager, ParsedLinesResult, ParsedScript, ParsedScriptsResult, PipelineContext, PluginContext, PluginHook, PluginInfo, RegistrationOptions, RequestLineResult, ScriptContext$1 as ScriptContext, ScriptResult$1 as ScriptResult, ScriptTestResult$1 as ScriptTestResult, TestManagerDependencies, VariableLineResult, VariableLineType };