/** * @name remote/premium-routes * @description HTTP route handlers for the premium delivery rail. * * This module owns the 4 premium delivery endpoints that the `RemoteMCPServer` * delegates to. Each handler is an async function that receives the raw * Node.js `IncomingMessage` / `ServerResponse` pair and returns nothing * (the response is written directly). * * Endpoints: * POST /premium/activate — Activate a session with x402 receipt. * GET /premium/stream/:sessionId — SSE stream for an active session. * POST /premium/webhook/register — Register a webhook target. * GET /premium/webhook/:subId/status — Check webhook delivery status. * * Design principles: * - Each handler is pure async — no shared mutable state outside the premium modules. * - SSE streams use keep-alive with `X-Accel-Buffering: no` for nginx proxies. * - Webhook delivery runs in the background via `setImmediate` to not block the * HTTP response — the response returns the subscription immediately. * - All errors return structured JSON with `error` and `message` fields. * * @module remote/premium-routes */ import * as http from 'node:http'; /** * @name handlePremiumActivation * @description Activate a pending premium session with a payment receipt. * * Expects a JSON body: * { "sessionId": string, "paymentReceipt": string, "payerAddress"?: string } * * Returns: * - 200 + `{ activation: PremiumActivationResult }` on success. * - 400 if required fields are missing. * - 402 if the session is not in `pending_payment` status. * * @param req - HTTP request. * @param res - HTTP response. */ export declare function handlePremiumActivation(req: http.IncomingMessage, res: http.ServerResponse): Promise; /** * @name handlePremiumStream * @description Open an SSE stream for an active premium session. * * The client must send `Accept: text/event-stream`. The server: * 1. Validates the session is active. * 2. Replays past events within the replay window (if `since` query param is set). * 3. Opens a live provider subscription and streams events as SSE. * 4. Closes the stream when the client disconnects or the unit quota is exhausted. * * SSE format per event: * event: \n * data: {}\n\n * * @param req - HTTP request. * @param res - HTTP response. * @param sessionId - The session id extracted from the URL path. */ export declare function handlePremiumStream(req: http.IncomingMessage, res: http.ServerResponse, sessionId: string): Promise; /** * @name handlePremiumWebhookRegister * @description Register an HTTPS webhook target for signed event delivery. * * Expects a JSON body: * { "sessionId": string, "targetUrl": string, "events": string[], * "signingPublicKey"?: string } * * Returns 201 with the subscription record. The delivery worker starts in the * background via `setImmediate` — the response does not wait for delivery. * * @param req - HTTP request. * @param res - HTTP response. */ export declare function handlePremiumWebhookRegister(req: http.IncomingMessage, res: http.ServerResponse): Promise; /** * @name handlePremiumWebhookStatus * @description Return the status of a webhook subscription with recent delivery records. * * @param req - HTTP request. * @param res - HTTP response. * @param subscriptionId - The subscription id extracted from the URL path. */ export declare function handlePremiumWebhookStatus(req: http.IncomingMessage, res: http.ServerResponse, subscriptionId: string): Promise; /** * @name tryPremiumRoute * @description Check if a request targets a premium delivery endpoint and handle it. * * This is the single entry point called by the `RemoteMCPServer` request handler. * If the request matches a premium route, the handler runs and `true` is returned * (indicating the response was written). If no route matches, `false` is returned * and the caller continues to the next route handler. * * @param req - HTTP request. * @param res - HTTP response. * @returns `true` if a premium route handled the request, `false` otherwise. */ export declare function tryPremiumRoute(req: http.IncomingMessage, res: http.ServerResponse, auth?: { success: boolean; userId?: string; error?: string; }): Promise; //# sourceMappingURL=premium-routes.d.ts.map