import { IncomingHttpEvent } from '../IncomingHttpEvent.js'; import { OutgoingHttpResponse } from '../OutgoingHttpResponse.js'; import { IBlueprint, NextMiddleware, type MetaMiddleware } from '@stone-js/core'; /** * Kernel Middleware for adding Cross-Origin Resource Sharing (CORS) headers to HTTP responses. * It allows controlling how clients from different origins can access the server's resources. * * @template TEvent - Represents the type of the incoming HTTP event. * @template UResponse - Represents the type of the outgoing HTTP response. * @author Mr. Stone */ export declare class HandleCorsMiddleware { private readonly headers; private readonly headerVary; private readonly blueprint; /** * Construct an instance of HandleCorsMiddleware. * * @param blueprint - The configuration blueprint used for managing CORS settings. */ constructor({ blueprint }: { blueprint: IBlueprint; }); /** * Handle CORS by modifying the response headers based on the configuration. * * @param event - The incoming HTTP event. * @param next - The next middleware function to continue processing the event. * @returns The outgoing HTTP response with CORS headers. */ handle(event: IncomingHttpEvent, next: NextMiddleware): Promise; /** * Get the CORS options by merging the blueprint configuration with defaults. * * @returns The merged CORS options. */ private getOptions; /** * Check if the given origin is allowed based on the provided configuration. * * @param origin - The origin to check. * @param allowedOrigin - The allowed origins configuration. * @returns Whether the origin is allowed. */ private isOriginAllowed; /** * Configure the `Access-Control-Allow-Origin` header based on the event origin and CORS options. * * @param {origin} HttpCorsConfig - The CORS options. * @param event - The incoming event. * @returns The middleware instance for method chaining. */ private configureOrigin; /** * Configure the `Access-Control-Allow-Methods` header based on the CORS options. * * @param {methods} HttpCorsConfig - The CORS options. * @returns The middleware instance for method chaining. */ private configureMethods; /** * Configure the `Access-Control-Allow-Credentials` header if allowed. * * @param {credentials} HttpCorsConfig - The CORS options. * @returns The middleware instance for method chaining. */ private configureCredentials; /** * Configure the `Access-Control-Allow-Headers` header based on the event headers and CORS options. * * @param {allowedHeaders} HttpCorsConfig - The CORS options. * @param event - The incoming event. * @returns The middleware instance for method chaining. */ private configureAllowedHeaders; /** * Configure the `Access-Control-Expose-Headers` header based on the CORS options. * * @param {exposedHeaders} HttpCorsConfig - The CORS options. * @returns The middleware instance for method chaining. */ private configureExposedHeaders; /** * Configure the `Access-Control-Max-Age` header if provided in the CORS options. * * @param {maxAge} HttpCorsConfig - The CORS options. * @returns The middleware instance for method chaining. */ private configureMaxAge; /** * Set a response header. * * @param name - The name of the header to set. * @param value - The value of the header to set. * @returns The middleware instance for method chaining. */ private setHeader; /** * Add a header to the `Vary` list for the response. * * @param value - The header name to add to `Vary`. * @returns The middleware instance for method chaining. */ private addVary; /** * Get the default CORS options. * * @returns An object containing the default CORS options. */ private getDefaults; } /** * Meta Middleware for processing CORS headers. */ export declare const MetaHandleCorsMiddleware: MetaMiddleware;