@temporary-name/server 1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc → 1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e

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 (46) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +5 -7
  2. package/dist/adapters/aws-lambda/index.d.ts +5 -7
  3. package/dist/adapters/aws-lambda/index.mjs +6 -9
  4. package/dist/adapters/fetch/index.d.mts +8 -86
  5. package/dist/adapters/fetch/index.d.ts +8 -86
  6. package/dist/adapters/fetch/index.mjs +18 -160
  7. package/dist/adapters/node/index.d.mts +9 -64
  8. package/dist/adapters/node/index.d.ts +9 -64
  9. package/dist/adapters/node/index.mjs +16 -125
  10. package/dist/handler/index.d.mts +28 -0
  11. package/dist/handler/index.d.ts +28 -0
  12. package/dist/handler/index.mjs +8 -0
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +373 -493
  15. package/dist/index.d.ts +373 -493
  16. package/dist/index.mjs +547 -469
  17. package/dist/openapi/index.d.mts +18 -53
  18. package/dist/openapi/index.d.ts +18 -53
  19. package/dist/openapi/index.mjs +384 -378
  20. package/dist/shared/server.B5ntjz_x.d.mts +800 -0
  21. package/dist/shared/server.B5ntjz_x.d.ts +800 -0
  22. package/dist/shared/server.BGG3eatg.mjs +315 -0
  23. package/dist/shared/server.BM9lK_Yv.mjs +523 -0
  24. package/dist/shared/server.BxyeakF-.d.mts +39 -0
  25. package/dist/shared/server.C1RJffw4.mjs +30 -0
  26. package/dist/shared/server.CjPiuQYH.d.mts +51 -0
  27. package/dist/shared/server.CjPiuQYH.d.ts +51 -0
  28. package/dist/shared/server.CmNVzZVe.mjs +156 -0
  29. package/dist/shared/server.Coz0LFSE.d.ts +39 -0
  30. package/dist/shared/server.X8F6e8eV.mjs +499 -0
  31. package/package.json +13 -30
  32. package/dist/adapters/standard/index.d.mts +0 -42
  33. package/dist/adapters/standard/index.d.ts +0 -42
  34. package/dist/adapters/standard/index.mjs +0 -11
  35. package/dist/plugins/index.d.mts +0 -160
  36. package/dist/plugins/index.d.ts +0 -160
  37. package/dist/plugins/index.mjs +0 -288
  38. package/dist/shared/server.BEHw7Eyx.mjs +0 -247
  39. package/dist/shared/server.BKSOrA6h.d.mts +0 -192
  40. package/dist/shared/server.BKSOrA6h.d.ts +0 -192
  41. package/dist/shared/server.BKh8I1Ny.mjs +0 -239
  42. package/dist/shared/server.BeuTpcmO.d.mts +0 -23
  43. package/dist/shared/server.C1fnTLq0.d.mts +0 -57
  44. package/dist/shared/server.CQyYNJ1H.d.ts +0 -57
  45. package/dist/shared/server.DLsti1Pv.mjs +0 -293
  46. package/dist/shared/server.SLLuK6_v.d.ts +0 -23
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@temporary-name/server",
3
3
  "type": "module",
4
- "version": "1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc",
4
+ "version": "1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.stainless.com/",
7
7
  "repository": {
@@ -23,15 +23,10 @@
23
23
  "import": "./dist/helpers/index.mjs",
24
24
  "default": "./dist/helpers/index.mjs"
25
25
  },
26
- "./plugins": {
27
- "types": "./dist/plugins/index.d.mts",
28
- "import": "./dist/plugins/index.mjs",
29
- "default": "./dist/plugins/index.mjs"
30
- },
31
26
  "./standard": {
32
- "types": "./dist/adapters/standard/index.d.mts",
33
- "import": "./dist/adapters/standard/index.mjs",
34
- "default": "./dist/adapters/standard/index.mjs"
27
+ "types": "./dist/handler/index.d.mts",
28
+ "import": "./dist/handler/index.mjs",
29
+ "default": "./dist/handler/index.mjs"
35
30
  },
36
31
  "./fetch": {
37
32
  "types": "./dist/adapters/fetch/index.d.mts",
@@ -57,30 +52,17 @@
57
52
  "files": [
58
53
  "dist"
59
54
  ],
60
- "peerDependencies": {
61
- "drizzle-orm": "^0.44.5",
62
- "drizzle-zod": "^0.8.3"
63
- },
64
- "peerDependenciesMeta": {
65
- "drizzle-orm": {
66
- "optional": true
67
- },
68
- "drizzle-zod": {
69
- "optional": true
70
- }
71
- },
72
55
  "dependencies": {
73
56
  "cookie": "^1.0.2",
74
- "@standard-schema/spec": "^1.0.0",
75
57
  "rou3": "^0.7.7",
76
58
  "zod": "^4.1.12",
77
- "@temporary-name/contract": "1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc",
78
- "@temporary-name/interop": "1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc",
79
- "@temporary-name/standard-server": "1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc",
80
- "@temporary-name/shared": "1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc",
81
- "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc",
82
- "@temporary-name/standard-server-fetch": "1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc",
83
- "@temporary-name/standard-server-node": "1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc"
59
+ "@temporary-name/interop": "1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e",
60
+ "@temporary-name/shared": "1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e",
61
+ "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e",
62
+ "@temporary-name/standard-server": "1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e",
63
+ "@temporary-name/standard-server-fetch": "1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e",
64
+ "@temporary-name/zod": "1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e",
65
+ "@temporary-name/standard-server-node": "1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e"
84
66
  },
85
67
  "devDependencies": {
86
68
  "@types/supertest": "^6.0.3",
@@ -90,6 +72,7 @@
90
72
  "scripts": {
91
73
  "build": "unbuild",
92
74
  "build:watch": "pnpm run build --watch",
93
- "type:check": "tsc -b"
75
+ "clean": "tsc -b --clean",
76
+ "lint:tsc": "tsc -b"
94
77
  }
95
78
  }
@@ -1,42 +0,0 @@
1
- export { C as CompositeStandardHandlerPlugin, c as StandardHandleOptions, d as StandardHandleResult, e as StandardHandler, S as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, a as StandardHandlerPlugin } from '../../shared/server.C1fnTLq0.mjs';
2
- import { AnyProcedure, AnyRouter } from '@temporary-name/server';
3
- import { StandardCodec as StandardCodec$1, StandardParams as StandardParams$1, StandardMatcher as StandardMatcher$1, StandardMatchResult as StandardMatchResult$1 } from '@temporary-name/server/standard';
4
- import { ORPCError, HTTPPath } from '@temporary-name/shared';
5
- import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
6
- import { h as AnyProcedure$1, f as AnyRouter$1 } from '../../shared/server.BKSOrA6h.mjs';
7
- export { F as FriendlyStandardHandleOptions, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.BeuTpcmO.mjs';
8
- import '@temporary-name/contract';
9
-
10
- declare class StandardOpenAPICodec implements StandardCodec$1 {
11
- #private;
12
- constructor();
13
- decode(request: StandardLazyRequest, params: StandardParams$1 | undefined, procedure: AnyProcedure): Promise<unknown>;
14
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
15
- encodeError(error: ORPCError<any, any>): StandardResponse;
16
- }
17
-
18
- declare class StandardOpenAPIMatcher implements StandardMatcher$1 {
19
- private readonly tree;
20
- private pendingRouters;
21
- init(router: AnyRouter, path?: readonly string[]): void;
22
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult$1>;
23
- }
24
-
25
- type StandardParams = Record<string, string>;
26
- type StandardMatchResult = {
27
- path: readonly string[];
28
- procedure: AnyProcedure$1;
29
- params?: StandardParams;
30
- } | undefined;
31
- interface StandardMatcher {
32
- init(router: AnyRouter$1): void;
33
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
34
- }
35
- interface StandardCodec {
36
- encode(output: unknown, procedure: AnyProcedure$1): StandardResponse;
37
- encodeError(error: ORPCError<any, any>): StandardResponse;
38
- decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure$1): Promise<unknown>;
39
- }
40
-
41
- export { StandardOpenAPICodec, StandardOpenAPIMatcher };
42
- export type { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams };
@@ -1,42 +0,0 @@
1
- export { C as CompositeStandardHandlerPlugin, c as StandardHandleOptions, d as StandardHandleResult, e as StandardHandler, S as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, a as StandardHandlerPlugin } from '../../shared/server.CQyYNJ1H.js';
2
- import { AnyProcedure, AnyRouter } from '@temporary-name/server';
3
- import { StandardCodec as StandardCodec$1, StandardParams as StandardParams$1, StandardMatcher as StandardMatcher$1, StandardMatchResult as StandardMatchResult$1 } from '@temporary-name/server/standard';
4
- import { ORPCError, HTTPPath } from '@temporary-name/shared';
5
- import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
6
- import { h as AnyProcedure$1, f as AnyRouter$1 } from '../../shared/server.BKSOrA6h.js';
7
- export { F as FriendlyStandardHandleOptions, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.SLLuK6_v.js';
8
- import '@temporary-name/contract';
9
-
10
- declare class StandardOpenAPICodec implements StandardCodec$1 {
11
- #private;
12
- constructor();
13
- decode(request: StandardLazyRequest, params: StandardParams$1 | undefined, procedure: AnyProcedure): Promise<unknown>;
14
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
15
- encodeError(error: ORPCError<any, any>): StandardResponse;
16
- }
17
-
18
- declare class StandardOpenAPIMatcher implements StandardMatcher$1 {
19
- private readonly tree;
20
- private pendingRouters;
21
- init(router: AnyRouter, path?: readonly string[]): void;
22
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult$1>;
23
- }
24
-
25
- type StandardParams = Record<string, string>;
26
- type StandardMatchResult = {
27
- path: readonly string[];
28
- procedure: AnyProcedure$1;
29
- params?: StandardParams;
30
- } | undefined;
31
- interface StandardMatcher {
32
- init(router: AnyRouter$1): void;
33
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
34
- }
35
- interface StandardCodec {
36
- encode(output: unknown, procedure: AnyProcedure$1): StandardResponse;
37
- encodeError(error: ORPCError<any, any>): StandardResponse;
38
- decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure$1): Promise<unknown>;
39
- }
40
-
41
- export { StandardOpenAPICodec, StandardOpenAPIMatcher };
42
- export type { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams };
@@ -1,11 +0,0 @@
1
- export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardOpenAPICodec, b as StandardOpenAPIMatcher, d as decodeParams, r as resolveFriendlyStandardHandleOptions, t as toRou3Pattern } from '../../shared/server.DLsti1Pv.mjs';
2
- import '@temporary-name/shared';
3
- import '@temporary-name/standard-server';
4
- import '../../shared/server.BKh8I1Ny.mjs';
5
- import '@temporary-name/contract';
6
- import 'node:async_hooks';
7
- import 'zod';
8
- import 'zod/v4/core';
9
- import '../../shared/server.BEHw7Eyx.mjs';
10
- import '@temporary-name/server';
11
- import 'rou3';
@@ -1,160 +0,0 @@
1
- import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
- import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
- import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.C1fnTLq0.mjs';
5
- import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.BKSOrA6h.mjs';
6
- import { Meta } from '@temporary-name/contract';
7
-
8
- interface BatchHandlerOptions<T extends Context> {
9
- /**
10
- * The max size of the batch allowed.
11
- *
12
- * @default 10
13
- */
14
- maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
15
- /**
16
- * Map the request before processing it.
17
- *
18
- * @default merged back batch request headers into the request
19
- */
20
- mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
21
- /**
22
- * Success batch response status code.
23
- *
24
- * @default 207
25
- */
26
- successStatus?: Value<Promisable<number>, [
27
- responses: Promise<BatchResponseBodyItem>[],
28
- batchOptions: StandardHandlerInterceptorOptions<T>
29
- ]>;
30
- /**
31
- * success batch response headers.
32
- *
33
- * @default {}
34
- */
35
- headers?: Value<Promisable<StandardHeaders>, [
36
- responses: Promise<BatchResponseBodyItem>[],
37
- batchOptions: StandardHandlerInterceptorOptions<T>
38
- ]>;
39
- }
40
- /**
41
- * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
42
- * reducing the overhead of sending each one separately.
43
- *
44
- * @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
45
- */
46
- declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
47
- private readonly maxSize;
48
- private readonly mapRequestItem;
49
- private readonly successStatus;
50
- private readonly headers;
51
- order: number;
52
- constructor(options?: BatchHandlerOptions<T>);
53
- init(options: StandardHandlerOptions<T>): void;
54
- }
55
-
56
- interface CORSOptions<T extends Context> {
57
- origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
58
- origin: string,
59
- options: StandardHandlerInterceptorOptions<T>
60
- ]>;
61
- timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [
62
- origin: string,
63
- options: StandardHandlerInterceptorOptions<T>
64
- ]>;
65
- allowMethods?: readonly string[];
66
- allowHeaders?: readonly string[];
67
- maxAge?: number;
68
- credentials?: boolean;
69
- exposeHeaders?: readonly string[];
70
- }
71
- /**
72
- * CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
73
- *
74
- * @see {@link https://orpc.unnoq.com/docs/plugins/cors CORS Plugin Docs}
75
- */
76
- declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
77
- private readonly options;
78
- order: number;
79
- constructor(options?: CORSOptions<T>);
80
- init(options: StandardHandlerOptions<T>): void;
81
- }
82
-
83
- interface RequestHeadersPluginContext {
84
- reqHeaders?: Headers;
85
- }
86
- /**
87
- * The Request Headers Plugin injects a `reqHeaders` instance into the context,
88
- * allowing access to request headers in oRPC.
89
- *
90
- * @see {@link https://orpc.unnoq.com/docs/plugins/request-headers Request Headers Plugin Docs}
91
- */
92
- declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
93
- init(options: StandardHandlerOptions<T>): void;
94
- }
95
-
96
- interface ResponseHeadersPluginContext {
97
- resHeaders?: Headers;
98
- }
99
- /**
100
- * The Response Headers Plugin allows you to set response headers in oRPC.
101
- * It injects a resHeaders instance into the context, enabling you to modify response headers easily.
102
- *
103
- * @see {@link https://orpc.unnoq.com/docs/plugins/response-headers Response Headers Plugin Docs}
104
- */
105
- declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
106
- init(options: StandardHandlerOptions<T>): void;
107
- }
108
-
109
- interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
110
- /**
111
- * The name of the header to check.
112
- *
113
- * @default 'x-csrf-token'
114
- */
115
- headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
116
- /**
117
- * The value of the header to check.
118
- *
119
- * @default 'orpc'
120
- *
121
- */
122
- headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
123
- /**
124
- * Exclude a procedure from the plugin.
125
- *
126
- * @default false
127
- *
128
- */
129
- exclude?: Value<Promisable<boolean>, [
130
- options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
131
- ]>;
132
- /**
133
- * The error thrown when the CSRF token is invalid.
134
- *
135
- * @default new ORPCError('CSRF_TOKEN_MISMATCH', {
136
- * status: 403,
137
- * message: 'Invalid CSRF token',
138
- * })
139
- */
140
- error?: InstanceType<typeof ORPCError>;
141
- }
142
- /**
143
- * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
144
- * It helps ensure that requests to your procedures originate from JavaScript code,
145
- * not from other sources like standard HTML forms or direct browser navigation.
146
- *
147
- * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
148
- */
149
- declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
150
- private readonly headerName;
151
- private readonly headerValue;
152
- private readonly exclude;
153
- private readonly error;
154
- constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
155
- order: number;
156
- init(options: StandardHandlerOptions<T>): void;
157
- }
158
-
159
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
160
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions };
@@ -1,160 +0,0 @@
1
- import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
- import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
- import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CQyYNJ1H.js';
5
- import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.BKSOrA6h.js';
6
- import { Meta } from '@temporary-name/contract';
7
-
8
- interface BatchHandlerOptions<T extends Context> {
9
- /**
10
- * The max size of the batch allowed.
11
- *
12
- * @default 10
13
- */
14
- maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
15
- /**
16
- * Map the request before processing it.
17
- *
18
- * @default merged back batch request headers into the request
19
- */
20
- mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
21
- /**
22
- * Success batch response status code.
23
- *
24
- * @default 207
25
- */
26
- successStatus?: Value<Promisable<number>, [
27
- responses: Promise<BatchResponseBodyItem>[],
28
- batchOptions: StandardHandlerInterceptorOptions<T>
29
- ]>;
30
- /**
31
- * success batch response headers.
32
- *
33
- * @default {}
34
- */
35
- headers?: Value<Promisable<StandardHeaders>, [
36
- responses: Promise<BatchResponseBodyItem>[],
37
- batchOptions: StandardHandlerInterceptorOptions<T>
38
- ]>;
39
- }
40
- /**
41
- * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
42
- * reducing the overhead of sending each one separately.
43
- *
44
- * @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
45
- */
46
- declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
47
- private readonly maxSize;
48
- private readonly mapRequestItem;
49
- private readonly successStatus;
50
- private readonly headers;
51
- order: number;
52
- constructor(options?: BatchHandlerOptions<T>);
53
- init(options: StandardHandlerOptions<T>): void;
54
- }
55
-
56
- interface CORSOptions<T extends Context> {
57
- origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
58
- origin: string,
59
- options: StandardHandlerInterceptorOptions<T>
60
- ]>;
61
- timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [
62
- origin: string,
63
- options: StandardHandlerInterceptorOptions<T>
64
- ]>;
65
- allowMethods?: readonly string[];
66
- allowHeaders?: readonly string[];
67
- maxAge?: number;
68
- credentials?: boolean;
69
- exposeHeaders?: readonly string[];
70
- }
71
- /**
72
- * CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
73
- *
74
- * @see {@link https://orpc.unnoq.com/docs/plugins/cors CORS Plugin Docs}
75
- */
76
- declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
77
- private readonly options;
78
- order: number;
79
- constructor(options?: CORSOptions<T>);
80
- init(options: StandardHandlerOptions<T>): void;
81
- }
82
-
83
- interface RequestHeadersPluginContext {
84
- reqHeaders?: Headers;
85
- }
86
- /**
87
- * The Request Headers Plugin injects a `reqHeaders` instance into the context,
88
- * allowing access to request headers in oRPC.
89
- *
90
- * @see {@link https://orpc.unnoq.com/docs/plugins/request-headers Request Headers Plugin Docs}
91
- */
92
- declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
93
- init(options: StandardHandlerOptions<T>): void;
94
- }
95
-
96
- interface ResponseHeadersPluginContext {
97
- resHeaders?: Headers;
98
- }
99
- /**
100
- * The Response Headers Plugin allows you to set response headers in oRPC.
101
- * It injects a resHeaders instance into the context, enabling you to modify response headers easily.
102
- *
103
- * @see {@link https://orpc.unnoq.com/docs/plugins/response-headers Response Headers Plugin Docs}
104
- */
105
- declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
106
- init(options: StandardHandlerOptions<T>): void;
107
- }
108
-
109
- interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
110
- /**
111
- * The name of the header to check.
112
- *
113
- * @default 'x-csrf-token'
114
- */
115
- headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
116
- /**
117
- * The value of the header to check.
118
- *
119
- * @default 'orpc'
120
- *
121
- */
122
- headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
123
- /**
124
- * Exclude a procedure from the plugin.
125
- *
126
- * @default false
127
- *
128
- */
129
- exclude?: Value<Promisable<boolean>, [
130
- options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
131
- ]>;
132
- /**
133
- * The error thrown when the CSRF token is invalid.
134
- *
135
- * @default new ORPCError('CSRF_TOKEN_MISMATCH', {
136
- * status: 403,
137
- * message: 'Invalid CSRF token',
138
- * })
139
- */
140
- error?: InstanceType<typeof ORPCError>;
141
- }
142
- /**
143
- * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
144
- * It helps ensure that requests to your procedures originate from JavaScript code,
145
- * not from other sources like standard HTML forms or direct browser navigation.
146
- *
147
- * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
148
- */
149
- declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
150
- private readonly headerName;
151
- private readonly headerValue;
152
- private readonly exclude;
153
- private readonly error;
154
- constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
155
- order: number;
156
- init(options: StandardHandlerOptions<T>): void;
157
- }
158
-
159
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
160
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions };