@temporary-name/server 1.9.3-alpha.6ef4729e23affbe6454d37025d1dfc4d998b0649 → 1.9.3-alpha.72daecd600ae901064d3c4f8ab780582c1335ffe
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.
- package/dist/adapters/aws-lambda/index.d.mts +11 -7
- package/dist/adapters/aws-lambda/index.d.ts +11 -7
- package/dist/adapters/aws-lambda/index.mjs +11 -4
- package/dist/adapters/fetch/index.d.mts +15 -87
- package/dist/adapters/fetch/index.d.ts +15 -87
- package/dist/adapters/fetch/index.mjs +22 -161
- package/dist/adapters/node/index.d.mts +15 -64
- package/dist/adapters/node/index.d.ts +15 -64
- package/dist/adapters/node/index.mjs +20 -126
- package/dist/handler/index.d.mts +28 -0
- package/dist/handler/index.d.ts +28 -0
- package/dist/handler/index.mjs +8 -0
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +373 -546
- package/dist/index.d.ts +373 -546
- package/dist/index.mjs +547 -470
- package/dist/openapi/index.d.mts +185 -0
- package/dist/openapi/index.d.ts +185 -0
- package/dist/openapi/index.mjs +782 -0
- package/dist/shared/server.BwcJq6aP.d.mts +808 -0
- package/dist/shared/server.BwcJq6aP.d.ts +808 -0
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/server.CjPiuQYH.d.mts +51 -0
- package/dist/shared/server.CjPiuQYH.d.ts +51 -0
- package/dist/shared/server.D1LXM1bf.mjs +523 -0
- package/dist/shared/server.DEC2sW8B.mjs +496 -0
- package/dist/shared/server.Deg5phAY.d.ts +39 -0
- package/dist/shared/server.H11763QX.mjs +315 -0
- package/dist/shared/server.gSXsB9Bn.mjs +156 -0
- package/dist/shared/server.hAH-LVh_.d.mts +39 -0
- package/package.json +20 -31
- package/dist/adapters/standard/index.d.mts +0 -16
- package/dist/adapters/standard/index.d.ts +0 -16
- package/dist/adapters/standard/index.mjs +0 -101
- package/dist/plugins/index.d.mts +0 -160
- package/dist/plugins/index.d.ts +0 -160
- package/dist/plugins/index.mjs +0 -288
- package/dist/shared/server.BEQrAa3A.mjs +0 -207
- package/dist/shared/server.Bo94xDTv.d.mts +0 -73
- package/dist/shared/server.Btxrgkj5.d.ts +0 -73
- package/dist/shared/server.C1YnHvvf.d.mts +0 -192
- package/dist/shared/server.C1YnHvvf.d.ts +0 -192
- package/dist/shared/server.D6K9uoPI.mjs +0 -35
- package/dist/shared/server.DZ5BIITo.mjs +0 -9
- package/dist/shared/server.X0YaZxSJ.mjs +0 -13
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
|
|
2
|
-
import { flattenHeader } from '@temporary-name/standard-server';
|
|
3
|
-
import { c as createProcedureClient } from '../../shared/server.BEQrAa3A.mjs';
|
|
4
|
-
import { C as CompositeStandardHandlerPlugin } from '../../shared/server.X0YaZxSJ.mjs';
|
|
5
|
-
export { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
6
|
-
import '@temporary-name/contract';
|
|
7
|
-
import '../../shared/server.D6K9uoPI.mjs';
|
|
8
|
-
import 'node:async_hooks';
|
|
9
|
-
import 'zod';
|
|
10
|
-
import 'zod/v4/core';
|
|
11
|
-
|
|
12
|
-
class StandardHandler {
|
|
13
|
-
constructor(router, matcher, codec, options) {
|
|
14
|
-
this.matcher = matcher;
|
|
15
|
-
this.codec = codec;
|
|
16
|
-
const plugins = new CompositeStandardHandlerPlugin(options.plugins);
|
|
17
|
-
plugins.init(options, router);
|
|
18
|
-
this.interceptors = toArray(options.interceptors);
|
|
19
|
-
this.clientInterceptors = toArray(options.clientInterceptors);
|
|
20
|
-
this.rootInterceptors = toArray(options.rootInterceptors);
|
|
21
|
-
this.matcher.init(router);
|
|
22
|
-
}
|
|
23
|
-
interceptors;
|
|
24
|
-
clientInterceptors;
|
|
25
|
-
rootInterceptors;
|
|
26
|
-
async handle(request, options) {
|
|
27
|
-
const prefix = options.prefix?.replace(/\/$/, "") || void 0;
|
|
28
|
-
if (prefix && !request.url.pathname.startsWith(`${prefix}/`) && request.url.pathname !== prefix) {
|
|
29
|
-
return { matched: false, response: void 0 };
|
|
30
|
-
}
|
|
31
|
-
return intercept(this.rootInterceptors, { ...options, request, prefix }, async (interceptorOptions) => {
|
|
32
|
-
return runWithSpan({ name: `${request.method} ${request.url.pathname}` }, async (span) => {
|
|
33
|
-
let step;
|
|
34
|
-
try {
|
|
35
|
-
return await intercept(
|
|
36
|
-
this.interceptors,
|
|
37
|
-
interceptorOptions,
|
|
38
|
-
async ({ request: request2, context, prefix: prefix2 }) => {
|
|
39
|
-
const method = request2.method;
|
|
40
|
-
const url = request2.url;
|
|
41
|
-
const pathname = prefix2 ? url.pathname.replace(prefix2, "") : url.pathname;
|
|
42
|
-
const match = await runWithSpan(
|
|
43
|
-
{ name: "find_procedure" },
|
|
44
|
-
() => this.matcher.match(method, `/${pathname.replace(/^\/|\/$/g, "")}`)
|
|
45
|
-
);
|
|
46
|
-
if (!match) {
|
|
47
|
-
return { matched: false, response: void 0 };
|
|
48
|
-
}
|
|
49
|
-
span?.updateName(`${ORPC_NAME}.${match.path.join("/")}`);
|
|
50
|
-
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
51
|
-
span?.setAttribute("rpc.method", match.path.join("."));
|
|
52
|
-
step = "decode_input";
|
|
53
|
-
let input = await runWithSpan(
|
|
54
|
-
{ name: "decode_input" },
|
|
55
|
-
() => this.codec.decode(request2, match.params, match.procedure)
|
|
56
|
-
);
|
|
57
|
-
step = void 0;
|
|
58
|
-
if (isAsyncIteratorObject(input)) {
|
|
59
|
-
input = asyncIteratorWithSpan(
|
|
60
|
-
{ name: "consume_event_iterator_input", signal: request2.signal },
|
|
61
|
-
input
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
const client = createProcedureClient(match.procedure, {
|
|
65
|
-
context,
|
|
66
|
-
path: match.path,
|
|
67
|
-
interceptors: this.clientInterceptors
|
|
68
|
-
});
|
|
69
|
-
step = "call_procedure";
|
|
70
|
-
const output = await client(input, {
|
|
71
|
-
signal: request2.signal,
|
|
72
|
-
lastEventId: flattenHeader(request2.headers["last-event-id"])
|
|
73
|
-
});
|
|
74
|
-
step = void 0;
|
|
75
|
-
const response = this.codec.encode(output, match.procedure);
|
|
76
|
-
return {
|
|
77
|
-
matched: true,
|
|
78
|
-
response
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
} catch (e) {
|
|
83
|
-
if (step !== "call_procedure") {
|
|
84
|
-
setSpanError(span, e);
|
|
85
|
-
}
|
|
86
|
-
const error = step === "decode_input" && !(e instanceof ORPCError) ? new ORPCError("BAD_REQUEST", {
|
|
87
|
-
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
88
|
-
cause: e
|
|
89
|
-
}) : toORPCError(e);
|
|
90
|
-
const response = this.codec.encodeError(error);
|
|
91
|
-
return {
|
|
92
|
-
matched: true,
|
|
93
|
-
response
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export { CompositeStandardHandlerPlugin, StandardHandler };
|
package/dist/plugins/index.d.mts
DELETED
|
@@ -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 { c as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, d as StandardHandlerOptions } from '../shared/server.Bo94xDTv.mjs';
|
|
5
|
-
import { C as Context, P as ProcedureClientInterceptorOptions } from '../shared/server.C1YnHvvf.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 };
|
package/dist/plugins/index.d.ts
DELETED
|
@@ -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 { c as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, d as StandardHandlerOptions } from '../shared/server.Btxrgkj5.js';
|
|
5
|
-
import { C as Context, P as ProcedureClientInterceptorOptions } from '../shared/server.C1YnHvvf.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 };
|