/** * @module utils/endpoint-validator * @description Endpoint validation utilities for SAP agent discovery. * * Fetches advertised endpoints and verifies they respond with JSON, * proper CORS headers, and SAP-compatible behavior. Designed to * fail fast when an endpoint 404s, requires CSRF tokens, or * serves HTML instead of JSON. * * Used by: * - CLI `discovery validate` command * - SDK programmatic validation before x402 calls * - Integration test harnesses * * @category Utils * @since v0.6.0 */ import type { EndpointDescriptor, HealthCheckDescriptor, EndpointValidationResult } from "../types/endpoint"; /** * @interface ValidateEndpointOptions * @description Options for endpoint validation. * @category Utils * @since v0.6.0 */ export interface ValidateEndpointOptions { /** Timeout in milliseconds (default: 10000). */ readonly timeoutMs?: number; /** Number of retries on failure (default: 1). */ readonly retries?: number; /** HTTP method override (default: uses descriptor or HEAD). */ readonly method?: string; /** Custom headers to include in the validation request. */ readonly headers?: Record; /** If true, also sends a preflight OPTIONS request. */ readonly checkCors?: boolean; } /** * @name validateEndpoint * @description Validate a single endpoint URL for SAP compatibility. * * Performs the following checks: * 1. URL is reachable (no 4xx/5xx) * 2. Response Content-Type is JSON * 3. CORS headers are present (if checkCors enabled) * 4. No redirect to HTML login pages * 5. Measures response latency * * @param url - The endpoint URL to validate. * @param opts - Validation options. * @returns An {@link EndpointValidationResult} with detailed check results. * * @category Utils * @since v0.6.0 * * @example * ```ts * const result = await validateEndpoint("https://api.example.com/x402"); * if (!result.reachable) console.error(result.error); * ``` */ export declare function validateEndpoint(url: string, opts?: ValidateEndpointOptions): Promise; /** * @name validateEndpointDescriptor * @description Validate an {@link EndpointDescriptor} with context-aware checks. * * Uses the descriptor's method, auth requirements, and other metadata to * perform a more targeted validation than raw URL checking. * * @param descriptor - The endpoint descriptor to validate. * @param opts - Additional options. * @returns An {@link EndpointValidationResult}. * * @category Utils * @since v0.6.0 */ export declare function validateEndpointDescriptor(descriptor: EndpointDescriptor, opts?: ValidateEndpointOptions): Promise; /** * @name validateHealthCheck * @description Validate an agent's health-check endpoint. * * @param health - The health-check descriptor. * @returns An {@link EndpointValidationResult}. * * @category Utils * @since v0.6.0 */ export declare function validateHealthCheck(health: HealthCheckDescriptor): Promise; /** * @name validateAgentEndpoints * @description Validate all endpoints for an agent (primary + health + tool overrides). * * @param params - Object containing the endpoints to validate. * @param params.endpoint - Primary endpoint descriptor. * @param params.healthCheck - Optional health-check descriptor. * @param params.toolEndpoints - Optional array of tool-specific endpoint overrides. * @param opts - Validation options. * @returns A map of `label → EndpointValidationResult`. * * @category Utils * @since v0.6.0 */ export declare function validateAgentEndpoints(params: { endpoint: EndpointDescriptor; healthCheck?: HealthCheckDescriptor; toolEndpoints?: Array<{ name: string; endpoint: EndpointDescriptor; }>; }, opts?: ValidateEndpointOptions): Promise>; //# sourceMappingURL=endpoint-validator.d.ts.map