import type { StorageArea } from 'kv-storage-interface'; import type { Context } from './context.js'; import type { Awaitable } from './utils/common-types.js'; import type { UnsignedCookiesContext, SignedCookiesContext, EncryptedCookiesContext } from './cookies.js'; import type { FlushedContext } from './flushed.js'; declare type Rec = Record; declare type CookieContext = Context & (EncryptedCookiesContext | SignedCookiesContext | UnsignedCookiesContext); interface SessionContext { session: S; } export interface CookieSessionContext extends SessionContext { cookieSession: S; } export interface StorageSessionContext extends SessionContext { storageSession: S; } export interface CookieSessionOptions { /** The name of the session cookie. Defaults to `sid`. */ cookieName?: string; /** Session expiration time in seconds. Defaults to five minutes. */ expirationTtl?: number; /** Provide a record that serves as the default session object. Also used for type inference. */ defaultSession?: S; } export interface StorageSessionOptions extends CookieSessionOptions { /** The storage area where to persist the session objects. */ storage: StorageArea; } /** * Cookie session middleware for worker runtimes. * * Requires a cookie store, preferably encrypted or signed. * * Important: This will serialize the entire session data and store it in a cookie. It is sent with every request! * Only applicable for small session objects. Use `storageSession` for a traditional, KV store-backed session. */ export declare function cookieSession(options?: CookieSessionOptions): (ax: Awaitable) => Promise>; /** * Session middleware for worker runtimes. * * Need to provide a `StorageArea` to persist the session between requests. * See `@worker-tools/kv-storage`. * */ export declare function storageSession(options: StorageSessionOptions): >(ax: Awaitable) => Promise>; export {};