@orpc/server 0.0.0-next.68378b4 → 0.0.0-next.683f2ee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +149 -29
  2. package/dist/adapters/aws-lambda/index.d.mts +46 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +46 -0
  4. package/dist/adapters/aws-lambda/index.mjs +40 -0
  5. package/dist/adapters/bun-ws/index.d.mts +36 -0
  6. package/dist/adapters/bun-ws/index.d.ts +36 -0
  7. package/dist/adapters/bun-ws/index.mjs +47 -0
  8. package/dist/adapters/crossws/index.d.mts +33 -0
  9. package/dist/adapters/crossws/index.d.ts +33 -0
  10. package/dist/adapters/crossws/index.mjs +45 -0
  11. package/dist/adapters/fastify/index.d.mts +53 -0
  12. package/dist/adapters/fastify/index.d.ts +53 -0
  13. package/dist/adapters/fastify/index.mjs +52 -0
  14. package/dist/adapters/fetch/index.d.mts +108 -10
  15. package/dist/adapters/fetch/index.d.ts +108 -10
  16. package/dist/adapters/fetch/index.mjs +177 -7
  17. package/dist/adapters/message-port/index.d.mts +57 -0
  18. package/dist/adapters/message-port/index.d.ts +57 -0
  19. package/dist/adapters/message-port/index.mjs +55 -0
  20. package/dist/adapters/node/index.d.mts +86 -21
  21. package/dist/adapters/node/index.d.ts +86 -21
  22. package/dist/adapters/node/index.mjs +142 -23
  23. package/dist/adapters/standard/index.d.mts +11 -15
  24. package/dist/adapters/standard/index.d.ts +11 -15
  25. package/dist/adapters/standard/index.mjs +5 -3
  26. package/dist/adapters/standard-peer/index.d.mts +18 -0
  27. package/dist/adapters/standard-peer/index.d.ts +18 -0
  28. package/dist/adapters/standard-peer/index.mjs +21 -0
  29. package/dist/adapters/websocket/index.d.mts +56 -0
  30. package/dist/adapters/websocket/index.d.ts +56 -0
  31. package/dist/adapters/websocket/index.mjs +67 -0
  32. package/dist/adapters/ws/index.d.mts +31 -0
  33. package/dist/adapters/ws/index.d.ts +31 -0
  34. package/dist/adapters/ws/index.mjs +37 -0
  35. package/dist/helpers/index.d.mts +149 -0
  36. package/dist/helpers/index.d.ts +149 -0
  37. package/dist/helpers/index.mjs +198 -0
  38. package/dist/hibernation/index.d.mts +44 -0
  39. package/dist/hibernation/index.d.ts +44 -0
  40. package/dist/hibernation/index.mjs +65 -0
  41. package/dist/index.d.mts +680 -132
  42. package/dist/index.d.ts +680 -132
  43. package/dist/index.mjs +213 -54
  44. package/dist/plugins/index.d.mts +193 -20
  45. package/dist/plugins/index.d.ts +193 -20
  46. package/dist/plugins/index.mjs +241 -16
  47. package/dist/shared/server.7cEtMB30.d.ts +74 -0
  48. package/dist/shared/server.B8gYOD5g.d.mts +12 -0
  49. package/dist/shared/server.BOmqcs4W.mjs +421 -0
  50. package/dist/shared/server.BqadksTP.d.mts +74 -0
  51. package/dist/shared/server.C8_sRzQB.d.mts +42 -0
  52. package/dist/shared/server.ChUyt5-i.d.mts +32 -0
  53. package/dist/shared/server.ChyoA9XY.d.ts +42 -0
  54. package/dist/shared/server.DZ5BIITo.mjs +9 -0
  55. package/dist/shared/server.Dz5G6M6M.mjs +226 -0
  56. package/dist/shared/server.EfTOZ2Q7.d.ts +12 -0
  57. package/dist/shared/server.TEVCLCFC.mjs +39 -0
  58. package/dist/shared/server.qKsRrdxW.d.mts +193 -0
  59. package/dist/shared/server.qKsRrdxW.d.ts +193 -0
  60. package/dist/shared/server.yoEB3Fx4.d.ts +32 -0
  61. package/package.json +83 -23
  62. package/dist/adapters/hono/index.d.mts +0 -19
  63. package/dist/adapters/hono/index.d.ts +0 -19
  64. package/dist/adapters/hono/index.mjs +0 -32
  65. package/dist/adapters/next/index.d.mts +0 -26
  66. package/dist/adapters/next/index.d.ts +0 -26
  67. package/dist/adapters/next/index.mjs +0 -29
  68. package/dist/shared/server.BHIDiY4a.mjs +0 -28
  69. package/dist/shared/server.CtBp-i4f.d.mts +0 -77
  70. package/dist/shared/server.DKrKGnk2.mjs +0 -161
  71. package/dist/shared/server.Drm1Lma3.d.ts +0 -77
  72. package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
  73. package/dist/shared/server.V6zT5iYQ.mjs +0 -379
  74. package/dist/shared/server.ptXwNGQr.d.mts +0 -158
  75. package/dist/shared/server.ptXwNGQr.d.ts +0 -158
@@ -1,31 +1,204 @@
1
- import { a as StandardHandlerInterceptorOptions, P as Plugin, b as StandardHandlerOptions } from '../shared/server.CtBp-i4f.mjs';
2
- export { C as CompositePlugin } from '../shared/server.CtBp-i4f.mjs';
3
- import { Value } from '@orpc/shared';
4
- import { C as Context } from '../shared/server.ptXwNGQr.mjs';
5
- import '@orpc/contract';
6
- import '@orpc/standard-server';
7
- import '@orpc/client';
8
-
9
- interface CORSOptions<TContext extends Context> {
10
- origin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
11
- timingOrigin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
12
- allowMethods?: string[];
13
- allowHeaders?: string[];
1
+ import { Value, Promisable, ThrowableError } from '@orpc/shared';
2
+ import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
3
+ import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
4
+ import { C as Context, d as ProcedureClientInterceptorOptions } from '../shared/server.qKsRrdxW.mjs';
5
+ import { d as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.BqadksTP.mjs';
6
+ import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
7
+ import { ORPCError } from '@orpc/client';
8
+
9
+ interface BatchHandlerOptions<T extends Context> {
10
+ /**
11
+ * The max size of the batch allowed.
12
+ *
13
+ * @default 10
14
+ */
15
+ maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
16
+ /**
17
+ * Map the request before processing it.
18
+ *
19
+ * @default merged back batch request headers into the request
20
+ */
21
+ mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
22
+ /**
23
+ * Success batch response status code.
24
+ *
25
+ * @default 207
26
+ */
27
+ successStatus?: Value<Promisable<number>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
28
+ /**
29
+ * success batch response headers.
30
+ *
31
+ * @default {}
32
+ */
33
+ headers?: Value<Promisable<StandardHeaders>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
34
+ }
35
+ /**
36
+ * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
37
+ * reducing the overhead of sending each one separately.
38
+ *
39
+ * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
40
+ */
41
+ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
42
+ private readonly maxSize;
43
+ private readonly mapRequestItem;
44
+ private readonly successStatus;
45
+ private readonly headers;
46
+ order: number;
47
+ constructor(options?: BatchHandlerOptions<T>);
48
+ init(options: StandardHandlerOptions<T>): void;
49
+ }
50
+
51
+ interface CORSOptions<T extends Context> {
52
+ origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
+ timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
54
+ allowMethods?: readonly string[];
55
+ allowHeaders?: readonly string[];
14
56
  maxAge?: number;
15
57
  credentials?: boolean;
16
- exposeHeaders?: string[];
58
+ exposeHeaders?: readonly string[];
17
59
  }
18
- declare class CORSPlugin<TContext extends Context> implements Plugin<TContext> {
60
+ /**
61
+ * CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
62
+ *
63
+ * @see {@link https://orpc.dev/docs/plugins/cors CORS Plugin Docs}
64
+ */
65
+ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
19
66
  private readonly options;
20
- constructor(options?: Partial<CORSOptions<TContext>>);
21
- init(options: StandardHandlerOptions<TContext>): void;
67
+ order: number;
68
+ constructor(options?: CORSOptions<T>);
69
+ init(options: StandardHandlerOptions<T>): void;
70
+ }
71
+
72
+ interface RequestHeadersPluginContext {
73
+ reqHeaders?: Headers;
74
+ }
75
+ /**
76
+ * The Request Headers Plugin injects a `reqHeaders` instance into the context,
77
+ * allowing access to request headers in oRPC.
78
+ *
79
+ * @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin Docs}
80
+ */
81
+ declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
82
+ init(options: StandardHandlerOptions<T>): void;
22
83
  }
23
84
 
24
85
  interface ResponseHeadersPluginContext {
25
86
  resHeaders?: Headers;
26
87
  }
27
- declare class ResponseHeadersPlugin<TContext extends ResponseHeadersPluginContext & Context> implements Plugin<TContext> {
28
- init(options: StandardHandlerOptions<TContext>): void;
88
+ /**
89
+ * The Response Headers Plugin allows you to set response headers in oRPC.
90
+ * It injects a resHeaders instance into the context, enabling you to modify response headers easily.
91
+ *
92
+ * @see {@link https://orpc.dev/docs/plugins/response-headers Response Headers Plugin Docs}
93
+ */
94
+ declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
95
+ init(options: StandardHandlerOptions<T>): void;
96
+ }
97
+
98
+ interface experimental_RethrowHandlerPluginOptions<T extends Context> {
99
+ /**
100
+ * Decide which errors should be rethrown.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const rethrowPlugin = new RethrowHandlerPlugin({
105
+ * filter: (error) => {
106
+ * // Rethrow all non-ORPCError errors
107
+ * return !(error instanceof ORPCError)
108
+ * }
109
+ * })
110
+ * ```
111
+ */
112
+ filter: Value<boolean, [error: ThrowableError, options: StandardHandlerInterceptorOptions<T>]>;
113
+ }
114
+ /**
115
+ * The plugin allows you to catch and rethrow specific errors that occur during request handling.
116
+ * This is particularly useful when your framework has its own error handling mechanism
117
+ * (e.g., global exception filters in NestJS, error middleware in Express)
118
+ * and you want certain errors to be processed by that mechanism instead of being handled by the
119
+ * oRPC error handling flow.
120
+ *
121
+ * @see {@link https://orpc.dev/docs/plugins/rethrow-handler Rethrow Handler Plugin Docs}
122
+ */
123
+ declare class experimental_RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
124
+ private readonly filter;
125
+ CONTEXT_SYMBOL: symbol;
126
+ constructor(options: experimental_RethrowHandlerPluginOptions<T>);
127
+ init(options: StandardHandlerOptions<T>): void;
128
+ }
129
+
130
+ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
131
+ /**
132
+ * The name of the header to check.
133
+ *
134
+ * @default 'x-csrf-token'
135
+ */
136
+ headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
137
+ /**
138
+ * The value of the header to check.
139
+ *
140
+ * @default 'orpc'
141
+ *
142
+ */
143
+ headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
144
+ /**
145
+ * Exclude a procedure from the plugin.
146
+ *
147
+ * @default false
148
+ *
149
+ */
150
+ exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
151
+ /**
152
+ * The error thrown when the CSRF token is invalid.
153
+ *
154
+ * @default new ORPCError('CSRF_TOKEN_MISMATCH', {
155
+ * status: 403,
156
+ * message: 'Invalid CSRF token',
157
+ * })
158
+ */
159
+ error?: InstanceType<typeof ORPCError>;
160
+ }
161
+ /**
162
+ * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
163
+ * It helps ensure that requests to your procedures originate from JavaScript code,
164
+ * not from other sources like standard HTML forms or direct browser navigation.
165
+ *
166
+ * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
167
+ */
168
+ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
169
+ private readonly headerName;
170
+ private readonly headerValue;
171
+ private readonly exclude;
172
+ private readonly error;
173
+ constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
174
+ order: number;
175
+ init(options: StandardHandlerOptions<T>): void;
176
+ }
177
+
178
+ interface StrictGetMethodPluginOptions {
179
+ /**
180
+ * The error thrown when a GET request is made to a procedure that doesn't allow GET.
181
+ *
182
+ * @default new ORPCError('METHOD_NOT_SUPPORTED')
183
+ */
184
+ error?: InstanceType<typeof ORPCError$1>;
185
+ }
186
+ /**
187
+ * This plugin enhances security by ensuring only procedures explicitly marked to accept GET requests
188
+ * can be called using the HTTP GET method for RPC Protocol. This helps prevent certain types of
189
+ * Cross-Site Request Forgery (CSRF) attacks.
190
+ *
191
+ * @see {@link https://orpc.dev/docs/plugins/strict-get-method Strict Get Method Plugin Docs}
192
+ */
193
+ declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
194
+ private readonly error;
195
+ /**
196
+ * make sure execute before batch plugin to get real method
197
+ */
198
+ order: number;
199
+ constructor(options?: StrictGetMethodPluginOptions);
200
+ init(options: StandardHandlerOptions<T>): void;
29
201
  }
30
202
 
31
- export { type CORSOptions, CORSPlugin, Plugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
203
+ export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin, experimental_RethrowHandlerPlugin };
204
+ export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions, experimental_RethrowHandlerPluginOptions };
@@ -1,31 +1,204 @@
1
- import { a as StandardHandlerInterceptorOptions, P as Plugin, b as StandardHandlerOptions } from '../shared/server.Drm1Lma3.js';
2
- export { C as CompositePlugin } from '../shared/server.Drm1Lma3.js';
3
- import { Value } from '@orpc/shared';
4
- import { C as Context } from '../shared/server.ptXwNGQr.js';
5
- import '@orpc/contract';
6
- import '@orpc/standard-server';
7
- import '@orpc/client';
8
-
9
- interface CORSOptions<TContext extends Context> {
10
- origin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
11
- timingOrigin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
12
- allowMethods?: string[];
13
- allowHeaders?: string[];
1
+ import { Value, Promisable, ThrowableError } from '@orpc/shared';
2
+ import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
3
+ import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
4
+ import { C as Context, d as ProcedureClientInterceptorOptions } from '../shared/server.qKsRrdxW.js';
5
+ import { d as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.7cEtMB30.js';
6
+ import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
7
+ import { ORPCError } from '@orpc/client';
8
+
9
+ interface BatchHandlerOptions<T extends Context> {
10
+ /**
11
+ * The max size of the batch allowed.
12
+ *
13
+ * @default 10
14
+ */
15
+ maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
16
+ /**
17
+ * Map the request before processing it.
18
+ *
19
+ * @default merged back batch request headers into the request
20
+ */
21
+ mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
22
+ /**
23
+ * Success batch response status code.
24
+ *
25
+ * @default 207
26
+ */
27
+ successStatus?: Value<Promisable<number>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
28
+ /**
29
+ * success batch response headers.
30
+ *
31
+ * @default {}
32
+ */
33
+ headers?: Value<Promisable<StandardHeaders>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
34
+ }
35
+ /**
36
+ * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
37
+ * reducing the overhead of sending each one separately.
38
+ *
39
+ * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
40
+ */
41
+ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
42
+ private readonly maxSize;
43
+ private readonly mapRequestItem;
44
+ private readonly successStatus;
45
+ private readonly headers;
46
+ order: number;
47
+ constructor(options?: BatchHandlerOptions<T>);
48
+ init(options: StandardHandlerOptions<T>): void;
49
+ }
50
+
51
+ interface CORSOptions<T extends Context> {
52
+ origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
+ timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
54
+ allowMethods?: readonly string[];
55
+ allowHeaders?: readonly string[];
14
56
  maxAge?: number;
15
57
  credentials?: boolean;
16
- exposeHeaders?: string[];
58
+ exposeHeaders?: readonly string[];
17
59
  }
18
- declare class CORSPlugin<TContext extends Context> implements Plugin<TContext> {
60
+ /**
61
+ * CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
62
+ *
63
+ * @see {@link https://orpc.dev/docs/plugins/cors CORS Plugin Docs}
64
+ */
65
+ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
19
66
  private readonly options;
20
- constructor(options?: Partial<CORSOptions<TContext>>);
21
- init(options: StandardHandlerOptions<TContext>): void;
67
+ order: number;
68
+ constructor(options?: CORSOptions<T>);
69
+ init(options: StandardHandlerOptions<T>): void;
70
+ }
71
+
72
+ interface RequestHeadersPluginContext {
73
+ reqHeaders?: Headers;
74
+ }
75
+ /**
76
+ * The Request Headers Plugin injects a `reqHeaders` instance into the context,
77
+ * allowing access to request headers in oRPC.
78
+ *
79
+ * @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin Docs}
80
+ */
81
+ declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
82
+ init(options: StandardHandlerOptions<T>): void;
22
83
  }
23
84
 
24
85
  interface ResponseHeadersPluginContext {
25
86
  resHeaders?: Headers;
26
87
  }
27
- declare class ResponseHeadersPlugin<TContext extends ResponseHeadersPluginContext & Context> implements Plugin<TContext> {
28
- init(options: StandardHandlerOptions<TContext>): void;
88
+ /**
89
+ * The Response Headers Plugin allows you to set response headers in oRPC.
90
+ * It injects a resHeaders instance into the context, enabling you to modify response headers easily.
91
+ *
92
+ * @see {@link https://orpc.dev/docs/plugins/response-headers Response Headers Plugin Docs}
93
+ */
94
+ declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
95
+ init(options: StandardHandlerOptions<T>): void;
96
+ }
97
+
98
+ interface experimental_RethrowHandlerPluginOptions<T extends Context> {
99
+ /**
100
+ * Decide which errors should be rethrown.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const rethrowPlugin = new RethrowHandlerPlugin({
105
+ * filter: (error) => {
106
+ * // Rethrow all non-ORPCError errors
107
+ * return !(error instanceof ORPCError)
108
+ * }
109
+ * })
110
+ * ```
111
+ */
112
+ filter: Value<boolean, [error: ThrowableError, options: StandardHandlerInterceptorOptions<T>]>;
113
+ }
114
+ /**
115
+ * The plugin allows you to catch and rethrow specific errors that occur during request handling.
116
+ * This is particularly useful when your framework has its own error handling mechanism
117
+ * (e.g., global exception filters in NestJS, error middleware in Express)
118
+ * and you want certain errors to be processed by that mechanism instead of being handled by the
119
+ * oRPC error handling flow.
120
+ *
121
+ * @see {@link https://orpc.dev/docs/plugins/rethrow-handler Rethrow Handler Plugin Docs}
122
+ */
123
+ declare class experimental_RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
124
+ private readonly filter;
125
+ CONTEXT_SYMBOL: symbol;
126
+ constructor(options: experimental_RethrowHandlerPluginOptions<T>);
127
+ init(options: StandardHandlerOptions<T>): void;
128
+ }
129
+
130
+ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
131
+ /**
132
+ * The name of the header to check.
133
+ *
134
+ * @default 'x-csrf-token'
135
+ */
136
+ headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
137
+ /**
138
+ * The value of the header to check.
139
+ *
140
+ * @default 'orpc'
141
+ *
142
+ */
143
+ headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
144
+ /**
145
+ * Exclude a procedure from the plugin.
146
+ *
147
+ * @default false
148
+ *
149
+ */
150
+ exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
151
+ /**
152
+ * The error thrown when the CSRF token is invalid.
153
+ *
154
+ * @default new ORPCError('CSRF_TOKEN_MISMATCH', {
155
+ * status: 403,
156
+ * message: 'Invalid CSRF token',
157
+ * })
158
+ */
159
+ error?: InstanceType<typeof ORPCError>;
160
+ }
161
+ /**
162
+ * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
163
+ * It helps ensure that requests to your procedures originate from JavaScript code,
164
+ * not from other sources like standard HTML forms or direct browser navigation.
165
+ *
166
+ * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
167
+ */
168
+ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
169
+ private readonly headerName;
170
+ private readonly headerValue;
171
+ private readonly exclude;
172
+ private readonly error;
173
+ constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
174
+ order: number;
175
+ init(options: StandardHandlerOptions<T>): void;
176
+ }
177
+
178
+ interface StrictGetMethodPluginOptions {
179
+ /**
180
+ * The error thrown when a GET request is made to a procedure that doesn't allow GET.
181
+ *
182
+ * @default new ORPCError('METHOD_NOT_SUPPORTED')
183
+ */
184
+ error?: InstanceType<typeof ORPCError$1>;
185
+ }
186
+ /**
187
+ * This plugin enhances security by ensuring only procedures explicitly marked to accept GET requests
188
+ * can be called using the HTTP GET method for RPC Protocol. This helps prevent certain types of
189
+ * Cross-Site Request Forgery (CSRF) attacks.
190
+ *
191
+ * @see {@link https://orpc.dev/docs/plugins/strict-get-method Strict Get Method Plugin Docs}
192
+ */
193
+ declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
194
+ private readonly error;
195
+ /**
196
+ * make sure execute before batch plugin to get real method
197
+ */
198
+ order: number;
199
+ constructor(options?: StrictGetMethodPluginOptions);
200
+ init(options: StandardHandlerOptions<T>): void;
29
201
  }
30
202
 
31
- export { type CORSOptions, CORSPlugin, Plugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
203
+ export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin, experimental_RethrowHandlerPlugin };
204
+ export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions, experimental_RethrowHandlerPluginOptions };