import type { AbstractHttpCorsOptions } from '@navios/core'; /** * Function type for dynamic origin validation. * Called with the request origin and a callback to return the validation result. */ export type OriginFunction = (origin: string | undefined, callback: (error: Error | null, allow?: boolean | string) => void) => void; /** * Extended CORS options for the Bun adapter. * Extends the core AbstractHttpCorsOptions with support for function-based origin. */ export interface BunCorsOptions extends Omit { /** * Configures the Access-Control-Allow-Origin CORS header. * Can be a string, boolean, RegExp, array of these, or a function for dynamic validation. */ origin?: string | boolean | RegExp | (string | boolean | RegExp)[] | OriginFunction; } /** * CORS headers that can be set on a response. */ export interface CorsHeaders { 'Access-Control-Allow-Origin'?: string; 'Access-Control-Allow-Credentials'?: string; 'Access-Control-Expose-Headers'?: string; 'Access-Control-Allow-Headers'?: string; 'Access-Control-Allow-Methods'?: string; 'Access-Control-Max-Age'?: string; 'Cache-Control'?: string; Vary?: string; } /** * Calculates CORS headers for a request based on the provided options. * * @param requestOrigin - The Origin header from the request * @param options - CORS configuration options * @returns CORS headers object or null if origin is not allowed */ export declare function calculateCorsHeaders(requestOrigin: string | undefined, options: BunCorsOptions): Promise; /** * Calculates CORS headers specifically for preflight (OPTIONS) requests. * * @param requestOrigin - The Origin header from the request * @param requestMethod - The Access-Control-Request-Method header * @param requestHeaders - The Access-Control-Request-Headers header * @param options - CORS configuration options * @returns CORS headers object or null if origin is not allowed */ export declare function calculatePreflightHeaders(requestOrigin: string | undefined, requestMethod: string | null, requestHeaders: string | null, options: BunCorsOptions): Promise; /** * Checks if a request is a CORS preflight request. * * @param method - The HTTP method of the request * @param origin - The Origin header value * @param accessControlRequestMethod - The Access-Control-Request-Method header * @returns true if this is a preflight request */ export declare function isPreflight(method: string, origin: string | null, accessControlRequestMethod: string | null): boolean; /** * Applies CORS headers to a Response object. * * @param response - The original response * @param requestOrigin - The Origin header from the request * @param options - CORS configuration options * @returns A new Response with CORS headers, or the original if origin not allowed */ export declare function applyCorsToResponse(response: Response, requestOrigin: string | null, options: BunCorsOptions | null): Promise; //# sourceMappingURL=cors.util.d.mts.map