import { RequestHeaderMap, RequestHeaderName, ResponseHeaderMap, ResponseHeaderName, TypedHeaders } from 'fetchdts'; import { CookieSerializeOptions } from 'cookie-es'; import { Session, SessionConfig, SessionData, SessionManager, SessionUpdate } from './session.js'; import { StandardSchemaV1 } from '@standard-schema/spec'; import { RequestHandler } from './request-handler.js'; export type { ResponseHeaderName, RequestHeaderName }; export declare function requestHandler(handler: RequestHandler): (request: Request, requestOpts: any) => Promise | Response; export declare function getRequest(): Request; export declare function getRequestHeaders(): TypedHeaders; export declare function getRequestHeader(name: RequestHeaderName): string | undefined; export declare function getRequestIP(opts?: { /** * Use the X-Forwarded-For HTTP header set by proxies. * * Note: Make sure that this header can be trusted (your application running behind a CDN or reverse proxy) before enabling. */ xForwardedFor?: boolean; }): string | undefined; /** * Get the request hostname. * * If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists. * * If no host header is found, it will default to "localhost". */ export declare function getRequestHost(opts?: { xForwardedHost?: boolean; }): string; /** * Get the full incoming request URL. * * If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists. * * If `xForwardedProto` is `false`, it will not use the `x-forwarded-proto` header. */ export declare function getRequestUrl(opts?: { xForwardedHost?: boolean; xForwardedProto?: boolean; }): URL; /** * Get the request protocol. * * If `x-forwarded-proto` header is set to "https", it will return "https". You can disable this behavior by setting `xForwardedProto` to `false`. * * If protocol cannot be determined, it will default to "http". */ export declare function getRequestProtocol(opts?: { xForwardedProto?: boolean; }): 'http' | 'https' | (string & {}); export declare function setResponseHeaders(headers: TypedHeaders): void; export declare function getResponseHeaders(): TypedHeaders; export declare function getResponseHeader(name: ResponseHeaderName): string | undefined; export declare function setResponseHeader(name: ResponseHeaderName, value: string | Array): void; export declare function removeResponseHeader(name: ResponseHeaderName): void; export declare function clearResponseHeaders(headerNames?: Array): void; export declare function getResponseStatus(): number; export declare function setResponseStatus(code?: number, text?: string): void; /** * Parse the request to get HTTP Cookie header string and return an object of all cookie name-value pairs. * @returns Object of cookie name-value pairs * ```ts * const cookies = getCookies() * ``` */ export declare function getCookies(): Record; /** * Get a cookie value by name. * @param name Name of the cookie to get * @returns {*} Value of the cookie (String or undefined) * ```ts * const authorization = getCookie('Authorization') * ``` */ export declare function getCookie(name: string): string | undefined; /** * Set a cookie value by name. * @param name Name of the cookie to set * @param value Value of the cookie to set * @param options {CookieSerializeOptions} Options for serializing the cookie * ```ts * setCookie('Authorization', '1234567') * ``` */ export declare function setCookie(name: string, value: string, options?: CookieSerializeOptions): void; /** * Remove a cookie by name. * @param name Name of the cookie to delete * @param serializeOptions {CookieSerializeOptions} Cookie options * ```ts * deleteCookie('SessionId') * ``` */ export declare function deleteCookie(name: string, options?: CookieSerializeOptions): void; /** * Create a session manager for the current request. */ export declare function useSession(config: SessionConfig): Promise>; /** * Get the session for the current request */ export declare function getSession(config: SessionConfig): Promise>; /** * Update the session data for the current request. */ export declare function updateSession(config: SessionConfig, update?: SessionUpdate): Promise>; /** * Encrypt and sign the session data for the current request. */ export declare function sealSession(config: SessionConfig): Promise; /** * Decrypt and verify the session data for the current request. */ export declare function unsealSession(config: SessionConfig, sealed: string): Promise>; /** * Clear the session data for the current request. */ export declare function clearSession(config: Partial): Promise; export declare function getResponse(): { status?: number; statusText?: string; get headers(): Headers; }; export declare function getValidatedQuery(schema: StandardSchemaV1): Promise>;