import { Value, Promisable, ThrowableError } from '@orpc/shared'; import { StandardRequest, StandardHeaders } from '@orpc/standard-server'; import { BatchResponseBodyItem } from '@orpc/standard-server/batch'; import { d as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.7cEtMB30.js'; import { C as Context, d as ProcedureClientInterceptorOptions } from '../shared/server.qKsRrdxW.js'; import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract'; import { ORPCError } from '@orpc/client'; interface BatchHandlerOptions { /** * The max size of the batch allowed. * * @default 10 */ maxSize?: Value, [StandardHandlerInterceptorOptions]>; /** * Map the request before processing it. * * @default merged back batch request headers into the request */ mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions): StandardRequest; /** * Success batch response status code. * * @default 207 */ successStatus?: Value, [responses: Promise[], batchOptions: StandardHandlerInterceptorOptions]>; /** * success batch response headers. * * @default {} */ headers?: Value, [responses: Promise[], batchOptions: StandardHandlerInterceptorOptions]>; } /** * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch, * reducing the overhead of sending each one separately. * * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs} */ declare class BatchHandlerPlugin implements StandardHandlerPlugin { private readonly maxSize; private readonly mapRequestItem; private readonly successStatus; private readonly headers; order: number; constructor(options?: BatchHandlerOptions); init(options: StandardHandlerOptions): void; } interface CORSOptions { origin?: Value, [origin: string, options: StandardHandlerInterceptorOptions]>; timingOrigin?: Value, [origin: string, options: StandardHandlerInterceptorOptions]>; allowMethods?: readonly string[]; allowHeaders?: readonly string[]; maxAge?: number; credentials?: boolean; exposeHeaders?: readonly string[]; } /** * CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API. * * @see {@link https://orpc.dev/docs/plugins/cors CORS Plugin Docs} */ declare class CORSPlugin implements StandardHandlerPlugin { private readonly options; order: number; constructor(options?: CORSOptions); init(options: StandardHandlerOptions): void; } interface RequestHeadersPluginContext { reqHeaders?: Headers; } /** * The Request Headers Plugin injects a `reqHeaders` instance into the context, * allowing access to request headers in oRPC. * * @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin Docs} */ declare class RequestHeadersPlugin implements StandardHandlerPlugin { init(options: StandardHandlerOptions): void; } interface ResponseHeadersPluginContext { resHeaders?: Headers; } /** * The Response Headers Plugin allows you to set response headers in oRPC. * It injects a resHeaders instance into the context, enabling you to modify response headers easily. * * @see {@link https://orpc.dev/docs/plugins/response-headers Response Headers Plugin Docs} */ declare class ResponseHeadersPlugin implements StandardHandlerPlugin { init(options: StandardHandlerOptions): void; } interface experimental_RethrowHandlerPluginOptions { /** * Decide which errors should be rethrown. * * @example * ```ts * const rethrowPlugin = new RethrowHandlerPlugin({ * filter: (error) => { * // Rethrow all non-ORPCError errors * return !(error instanceof ORPCError) * } * }) * ``` */ filter: Value]>; } /** * The plugin allows you to catch and rethrow specific errors that occur during request handling. * This is particularly useful when your framework has its own error handling mechanism * (e.g., global exception filters in NestJS, error middleware in Express) * and you want certain errors to be processed by that mechanism instead of being handled by the * oRPC error handling flow. * * @see {@link https://orpc.dev/docs/plugins/rethrow-handler Rethrow Handler Plugin Docs} */ declare class experimental_RethrowHandlerPlugin implements StandardHandlerPlugin { private readonly filter; CONTEXT_SYMBOL: symbol; constructor(options: experimental_RethrowHandlerPluginOptions); init(options: StandardHandlerOptions): void; } interface SimpleCsrfProtectionHandlerPluginOptions { /** * The name of the header to check. * * @default 'x-csrf-token' */ headerName?: Value, [options: StandardHandlerInterceptorOptions]>; /** * The value of the header to check. * * @default 'orpc' * */ headerValue?: Value, [options: StandardHandlerInterceptorOptions]>; /** * Exclude a procedure from the plugin. * * @default false * */ exclude?: Value, [options: ProcedureClientInterceptorOptions, Meta>]>; /** * The error thrown when the CSRF token is invalid. * * @default new ORPCError('CSRF_TOKEN_MISMATCH', { * status: 403, * message: 'Invalid CSRF token', * }) */ error?: InstanceType; } /** * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application. * It helps ensure that requests to your procedures originate from JavaScript code, * not from other sources like standard HTML forms or direct browser navigation. * * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs} */ declare class SimpleCsrfProtectionHandlerPlugin implements StandardHandlerPlugin { private readonly headerName; private readonly headerValue; private readonly exclude; private readonly error; constructor(options?: SimpleCsrfProtectionHandlerPluginOptions); order: number; init(options: StandardHandlerOptions): void; } interface StrictGetMethodPluginOptions { /** * The error thrown when a GET request is made to a procedure that doesn't allow GET. * * @default new ORPCError('METHOD_NOT_SUPPORTED') */ error?: InstanceType; } /** * This plugin enhances security by ensuring only procedures explicitly marked to accept GET requests * can be called using the HTTP GET method for RPC Protocol. This helps prevent certain types of * Cross-Site Request Forgery (CSRF) attacks. * * @see {@link https://orpc.dev/docs/plugins/strict-get-method Strict Get Method Plugin Docs} */ declare class StrictGetMethodPlugin implements StandardHandlerPlugin { private readonly error; /** * make sure execute before batch plugin to get real method */ order: number; constructor(options?: StrictGetMethodPluginOptions); init(options: StandardHandlerOptions): void; } export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin, experimental_RethrowHandlerPlugin }; export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions, experimental_RethrowHandlerPluginOptions };