import type { SocketConnectRequest, SocketContext, SocketDisconnectRequest, SocketHandlerContext, SocketMessageRequest, SocketRequest, SocketResponse } from "./socket.js"; export interface SocketMiddlewareInput { request: Request; context: In; next: (context: O) => Promise>; } export type SocketMiddlewareOutput = SocketResponse & { context?: Context; }; export type SocketMiddlewareFunction = (input: SocketMiddlewareInput) => Promise> | SocketMiddlewareOutput; export interface SocketMiddleware { connect?: SocketMiddlewareFunction; disconnect?: SocketMiddlewareFunction; message?: SocketMiddlewareFunction; } /** * Utility for creating a Socket Middleware function that combines its output context * with the input context. * * ```ts * const auth = socketMiddleware(({request, context, next}) => { * return next({ * ...context, * isAuthenticated: request.headers.Authorization !== undefined * }) * }); * * socket.use(auth)("myAuthorizedCommand", async (request, { isAuthenticated }) => { * if (isAuthenticated) { * // do work * } * }) * ``` */ export declare function socketMiddleware(fn: SocketMiddlewareFunction | SocketMiddleware): { connect: ((input: SocketMiddlewareInput) => Promise>) | undefined; disconnect: ((input: SocketMiddlewareInput) => Promise>) | undefined; message: ((input: SocketMiddlewareInput) => Promise>) | undefined; }; //# sourceMappingURL=middleware.d.ts.map