@temporary-name/server 1.9.3-alpha.0d2fa3247b6b23bbc2e3097a95f631b86740e4d8 → 1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f

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 (39) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +12 -7
  2. package/dist/adapters/aws-lambda/index.d.ts +12 -7
  3. package/dist/adapters/aws-lambda/index.mjs +12 -4
  4. package/dist/adapters/fetch/index.d.mts +12 -7
  5. package/dist/adapters/fetch/index.d.ts +12 -7
  6. package/dist/adapters/fetch/index.mjs +12 -11
  7. package/dist/adapters/node/index.d.mts +12 -7
  8. package/dist/adapters/node/index.d.ts +12 -7
  9. package/dist/adapters/node/index.mjs +12 -11
  10. package/dist/adapters/standard/index.d.mts +27 -13
  11. package/dist/adapters/standard/index.d.ts +27 -13
  12. package/dist/adapters/standard/index.mjs +8 -100
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +82 -459
  15. package/dist/index.d.ts +82 -459
  16. package/dist/index.mjs +213 -366
  17. package/dist/openapi/index.d.mts +220 -0
  18. package/dist/openapi/index.d.ts +220 -0
  19. package/dist/openapi/index.mjs +709 -0
  20. package/dist/plugins/index.d.mts +5 -83
  21. package/dist/plugins/index.d.ts +5 -83
  22. package/dist/plugins/index.mjs +17 -189
  23. package/dist/shared/{server.Btxrgkj5.d.ts → server.25yUS-xw.d.mts} +7 -25
  24. package/dist/shared/server.BKwU5-Ea.d.mts +23 -0
  25. package/dist/shared/server.C1RJffw4.mjs +30 -0
  26. package/dist/shared/{server.Bo94xDTv.d.mts → server.Co-zpS8Y.d.ts} +7 -25
  27. package/dist/shared/server.DRYRuXpK.mjs +254 -0
  28. package/dist/shared/server.DV_PWBS2.d.ts +23 -0
  29. package/dist/shared/server.DWEp52Gx.mjs +379 -0
  30. package/dist/shared/server.JtIZ8YG7.mjs +237 -0
  31. package/dist/shared/server.VtI8pLxV.d.mts +242 -0
  32. package/dist/shared/server.VtI8pLxV.d.ts +242 -0
  33. package/package.json +18 -23
  34. package/dist/shared/server.BEQrAa3A.mjs +0 -207
  35. package/dist/shared/server.C1YnHvvf.d.mts +0 -192
  36. package/dist/shared/server.C1YnHvvf.d.ts +0 -192
  37. package/dist/shared/server.D6K9uoPI.mjs +0 -35
  38. package/dist/shared/server.DZ5BIITo.mjs +0 -9
  39. package/dist/shared/server.X0YaZxSJ.mjs +0 -13
@@ -1,58 +1,8 @@
1
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';
2
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.25yUS-xw.mjs';
3
+ import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.VtI8pLxV.mjs';
6
4
  import { Meta } from '@temporary-name/contract';
7
5
 
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
6
  interface CORSOptions<T extends Context> {
57
7
  origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
58
8
  origin: string,
@@ -80,32 +30,6 @@ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T>
80
30
  init(options: StandardHandlerOptions<T>): void;
81
31
  }
82
32
 
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
33
  interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
110
34
  /**
111
35
  * The name of the header to check.
@@ -126,9 +50,7 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
126
50
  * @default false
127
51
  *
128
52
  */
129
- exclude?: Value<Promisable<boolean>, [
130
- options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
131
- ]>;
53
+ exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Meta>]>;
132
54
  /**
133
55
  * The error thrown when the CSRF token is invalid.
134
56
  *
@@ -156,5 +78,5 @@ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements St
156
78
  init(options: StandardHandlerOptions<T>): void;
157
79
  }
158
80
 
159
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
160
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions };
81
+ export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
82
+ export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
@@ -1,58 +1,8 @@
1
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';
2
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.Co-zpS8Y.js';
3
+ import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.VtI8pLxV.js';
6
4
  import { Meta } from '@temporary-name/contract';
7
5
 
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
6
  interface CORSOptions<T extends Context> {
57
7
  origin?: Value<Promisable<string | readonly string[] | null | undefined>, [
58
8
  origin: string,
@@ -80,32 +30,6 @@ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T>
80
30
  init(options: StandardHandlerOptions<T>): void;
81
31
  }
82
32
 
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
33
  interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
110
34
  /**
111
35
  * The name of the header to check.
@@ -126,9 +50,7 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
126
50
  * @default false
127
51
  *
128
52
  */
129
- exclude?: Value<Promisable<boolean>, [
130
- options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>
131
- ]>;
53
+ exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Meta>]>;
132
54
  /**
133
55
  * The error thrown when the CSRF token is invalid.
134
56
  *
@@ -156,5 +78,5 @@ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements St
156
78
  init(options: StandardHandlerOptions<T>): void;
157
79
  }
158
80
 
159
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
160
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions };
81
+ export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
82
+ export type { CORSOptions, SimpleCsrfProtectionHandlerPluginOptions };
@@ -1,119 +1,5 @@
1
- import { runWithSpan, value, setSpanError, isAsyncIteratorObject, AsyncIteratorClass, clone, ORPCError } from '@temporary-name/shared';
2
- import { flattenHeader } from '@temporary-name/standard-server';
3
- import { parseBatchRequest, toBatchResponse } from '@temporary-name/standard-server/batch';
4
- import { toFetchHeaders } from '@temporary-name/standard-server-fetch';
5
-
6
- class BatchHandlerPlugin {
7
- maxSize;
8
- mapRequestItem;
9
- successStatus;
10
- headers;
11
- order = 5e6;
12
- constructor(options = {}) {
13
- this.maxSize = options.maxSize ?? 10;
14
- this.mapRequestItem = options.mapRequestItem ?? ((request, { request: batchRequest }) => ({
15
- ...request,
16
- headers: {
17
- ...batchRequest.headers,
18
- ...request.headers
19
- }
20
- }));
21
- this.successStatus = options.successStatus ?? 207;
22
- this.headers = options.headers ?? {};
23
- }
24
- init(options) {
25
- options.rootInterceptors ??= [];
26
- options.rootInterceptors.unshift(async (options2) => {
27
- const xHeader = flattenHeader(options2.request.headers["x-orpc-batch"]);
28
- if (xHeader === void 0) {
29
- return options2.next();
30
- }
31
- let isParsing = false;
32
- try {
33
- return await runWithSpan({ name: "handle_batch_request" }, async (span) => {
34
- const mode = xHeader === "buffered" ? "buffered" : "streaming";
35
- isParsing = true;
36
- const parsed = parseBatchRequest({ ...options2.request, body: await options2.request.body() });
37
- isParsing = false;
38
- span?.setAttribute("batch.mode", mode);
39
- span?.setAttribute("batch.size", parsed.length);
40
- const maxSize = await value(this.maxSize, options2);
41
- if (parsed.length > maxSize) {
42
- const message = "Batch request size exceeds the maximum allowed size";
43
- setSpanError(span, message);
44
- return {
45
- matched: true,
46
- response: {
47
- status: 413,
48
- headers: {},
49
- body: message
50
- }
51
- };
52
- }
53
- const responses = parsed.map((request, index) => {
54
- const mapped = this.mapRequestItem(request, options2);
55
- return options2.next({ ...options2, request: { ...mapped, body: () => Promise.resolve(mapped.body) } }).then(({ response: response2, matched }) => {
56
- span?.addEvent(`response.${index}.${matched ? "success" : "not_matched"}`);
57
- if (matched) {
58
- if (response2.body instanceof Blob || response2.body instanceof FormData || isAsyncIteratorObject(response2.body)) {
59
- return {
60
- index,
61
- status: 500,
62
- headers: {},
63
- body: "Batch responses do not support file/blob, or event-iterator. Please call this procedure separately outside of the batch request."
64
- };
65
- }
66
- return { ...response2, index };
67
- }
68
- return { index, status: 404, headers: {}, body: "No procedure matched" };
69
- }).catch((err) => {
70
- Promise.reject(err);
71
- return { index, status: 500, headers: {}, body: "Internal server error" };
72
- });
73
- });
74
- await Promise.race(responses);
75
- const status = await value(this.successStatus, responses, options2);
76
- const headers = await value(this.headers, responses, options2);
77
- const promises = [...responses];
78
- const response = await toBatchResponse({
79
- status,
80
- headers,
81
- mode,
82
- body: new AsyncIteratorClass(
83
- async () => {
84
- const handling = promises.filter((p) => p !== void 0);
85
- if (handling.length <= 0) {
86
- return { done: true, value: void 0 };
87
- }
88
- const value2 = await Promise.race(handling);
89
- promises[value2.index] = void 0;
90
- return { done: false, value: value2 };
91
- },
92
- async () => {
93
- }
94
- )
95
- });
96
- return {
97
- matched: true,
98
- response
99
- };
100
- });
101
- } catch (cause) {
102
- if (isParsing) {
103
- return {
104
- matched: true,
105
- response: {
106
- status: 400,
107
- headers: {},
108
- body: "Invalid batch request, this could be caused by a malformed request body or a missing header"
109
- }
110
- };
111
- }
112
- throw cause;
113
- }
114
- });
115
- }
116
- }
1
+ import { value, ORPCError } from '@temporary-name/shared';
2
+ import { maybeSetHeader } from '@temporary-name/standard-server';
117
3
 
118
4
  class CORSPlugin {
119
5
  options;
@@ -132,17 +18,13 @@ class CORSPlugin {
132
18
  options.rootInterceptors ??= [];
133
19
  options.rootInterceptors.unshift(async (interceptorOptions) => {
134
20
  if (interceptorOptions.request.method === "OPTIONS") {
135
- const resHeaders = {};
21
+ const resHeaders = new Headers();
136
22
  if (this.options.maxAge !== void 0) {
137
- resHeaders["access-control-max-age"] = this.options.maxAge.toString();
138
- }
139
- if (this.options.allowMethods?.length) {
140
- resHeaders["access-control-allow-methods"] = flattenHeader(this.options.allowMethods);
141
- }
142
- const allowHeaders = this.options.allowHeaders ?? interceptorOptions.request.headers["access-control-request-headers"];
143
- if (typeof allowHeaders === "string" || allowHeaders?.length) {
144
- resHeaders["access-control-allow-headers"] = flattenHeader(allowHeaders);
23
+ resHeaders.set("access-control-max-age", this.options.maxAge.toString());
145
24
  }
25
+ maybeSetHeader(resHeaders, "access-control-allow-methods", this.options.allowMethods);
26
+ const allowHeaders = this.options.allowHeaders ?? interceptorOptions.request.headers.get("access-control-request-headers");
27
+ maybeSetHeader(resHeaders, "access-control-allow-headers", allowHeaders);
146
28
  return {
147
29
  matched: true,
148
30
  response: {
@@ -159,87 +41,33 @@ class CORSPlugin {
159
41
  if (!result.matched) {
160
42
  return result;
161
43
  }
162
- const origin = flattenHeader(interceptorOptions.request.headers.origin) ?? "";
44
+ const origin = interceptorOptions.request.headers.get("origin") ?? "";
163
45
  const allowedOrigin = await value(this.options.origin, origin, interceptorOptions);
164
46
  const allowedOriginArr = Array.isArray(allowedOrigin) ? allowedOrigin : [allowedOrigin];
165
47
  if (allowedOriginArr.includes("*")) {
166
- result.response.headers["access-control-allow-origin"] = "*";
48
+ result.response.headers.set("access-control-allow-origin", "*");
167
49
  } else {
168
50
  if (allowedOriginArr.includes(origin)) {
169
- result.response.headers["access-control-allow-origin"] = origin;
51
+ result.response.headers.set("access-control-allow-origin", origin);
170
52
  }
171
- result.response.headers.vary = interceptorOptions.request.headers.vary ?? "origin";
53
+ result.response.headers.set("vary", interceptorOptions.request.headers.get("vary") ?? "origin");
172
54
  }
173
55
  const allowedTimingOrigin = await value(this.options.timingOrigin, origin, interceptorOptions);
174
56
  const allowedTimingOriginArr = Array.isArray(allowedTimingOrigin) ? allowedTimingOrigin : [allowedTimingOrigin];
175
57
  if (allowedTimingOriginArr.includes("*")) {
176
- result.response.headers["timing-allow-origin"] = "*";
58
+ result.response.headers.set("timing-allow-origin", "*");
177
59
  } else if (allowedTimingOriginArr.includes(origin)) {
178
- result.response.headers["timing-allow-origin"] = origin;
60
+ result.response.headers.set("timing-allow-origin", origin);
179
61
  }
180
62
  if (this.options.credentials) {
181
- result.response.headers["access-control-allow-credentials"] = "true";
182
- }
183
- if (this.options.exposeHeaders?.length) {
184
- result.response.headers["access-control-expose-headers"] = flattenHeader(this.options.exposeHeaders);
63
+ result.response.headers.set("access-control-allow-credentials", "true");
185
64
  }
65
+ maybeSetHeader(result.response.headers, "access-control-expose-headers", this.options.exposeHeaders);
186
66
  return result;
187
67
  });
188
68
  }
189
69
  }
190
70
 
191
- class RequestHeadersPlugin {
192
- init(options) {
193
- options.rootInterceptors ??= [];
194
- options.rootInterceptors.push((interceptorOptions) => {
195
- const reqHeaders = interceptorOptions.context.reqHeaders ?? toFetchHeaders(interceptorOptions.request.headers);
196
- return interceptorOptions.next({
197
- ...interceptorOptions,
198
- context: {
199
- ...interceptorOptions.context,
200
- reqHeaders
201
- }
202
- });
203
- });
204
- }
205
- }
206
-
207
- class ResponseHeadersPlugin {
208
- init(options) {
209
- options.rootInterceptors ??= [];
210
- options.rootInterceptors.push(async (interceptorOptions) => {
211
- const resHeaders = interceptorOptions.context.resHeaders ?? new Headers();
212
- const result = await interceptorOptions.next({
213
- ...interceptorOptions,
214
- context: {
215
- ...interceptorOptions.context,
216
- resHeaders
217
- }
218
- });
219
- if (!result.matched) {
220
- return result;
221
- }
222
- const responseHeaders = clone(result.response.headers);
223
- for (const [key, value] of resHeaders) {
224
- if (Array.isArray(responseHeaders[key])) {
225
- responseHeaders[key].push(value);
226
- } else if (responseHeaders[key] !== void 0) {
227
- responseHeaders[key] = [responseHeaders[key], value];
228
- } else {
229
- responseHeaders[key] = value;
230
- }
231
- }
232
- return {
233
- ...result,
234
- response: {
235
- ...result.response,
236
- headers: responseHeaders
237
- }
238
- };
239
- });
240
- }
241
- }
242
-
243
71
  const SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL = Symbol("SIMPLE_CSRF_PROTECTION_CONTEXT");
244
72
  class SimpleCsrfProtectionHandlerPlugin {
245
73
  headerName;
@@ -266,7 +94,7 @@ class SimpleCsrfProtectionHandlerPlugin {
266
94
  ...options2,
267
95
  context: {
268
96
  ...options2.context,
269
- [SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL]: options2.request.headers[headerName] === headerValue
97
+ [SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL]: options2.request.headers.get(headerName) === headerValue
270
98
  }
271
99
  });
272
100
  });
@@ -285,4 +113,4 @@ class SimpleCsrfProtectionHandlerPlugin {
285
113
  }
286
114
  }
287
115
 
288
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
116
+ export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
@@ -1,7 +1,6 @@
1
1
  import { Meta } from '@temporary-name/contract';
2
- import { HTTPPath, ORPCError, Interceptor } from '@temporary-name/shared';
3
- import { StandardResponse, StandardLazyRequest } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, A as AnyRouter, a as AnyProcedure, P as ProcedureClientInterceptorOptions } from './server.C1YnHvvf.js';
2
+ import { HTTPPath, StandardLazyRequest, Interceptor, StandardResponse } from '@temporary-name/shared';
3
+ import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.VtI8pLxV.mjs';
5
4
 
6
5
  interface StandardHandlerPlugin<T extends Context> {
7
6
  order?: number;
@@ -13,22 +12,6 @@ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends
13
12
  init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
14
13
  }
15
14
 
16
- type StandardParams = Record<string, string>;
17
- type StandardMatchResult = {
18
- path: readonly string[];
19
- procedure: AnyProcedure;
20
- params?: StandardParams;
21
- } | undefined;
22
- interface StandardMatcher {
23
- init(router: AnyRouter): void;
24
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
25
- }
26
- interface StandardCodec {
27
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
28
- encodeError(error: ORPCError<any, any>): StandardResponse;
29
- decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
30
- }
31
-
32
15
  interface StandardHandleOptions<T extends Context> {
33
16
  prefix?: HTTPPath;
34
17
  context: T;
@@ -57,17 +40,16 @@ interface StandardHandlerOptions<TContext extends Context> {
57
40
  *
58
41
  * Interceptors for procedure client.
59
42
  */
60
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
43
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Meta>, Promise<unknown>>[];
61
44
  }
62
45
  declare class StandardHandler<T extends Context> {
63
- private readonly matcher;
64
- private readonly codec;
65
46
  private readonly interceptors;
66
47
  private readonly clientInterceptors;
67
48
  private readonly rootInterceptors;
68
- constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
49
+ private readonly matcher;
50
+ constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
69
51
  handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
70
52
  }
71
53
 
72
- export { CompositeStandardHandlerPlugin as C, StandardHandler as S };
73
- export type { StandardHandlerPlugin as a, StandardHandleOptions as b, StandardHandlerInterceptorOptions as c, StandardHandlerOptions as d, StandardHandleResult as e, StandardParams as f, StandardMatchResult as g, StandardMatcher as h, StandardCodec as i };
54
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as e };
55
+ export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardHandleOptions as c, StandardHandleResult as d };
@@ -0,0 +1,23 @@
1
+ import { HTTPPath } from '@temporary-name/shared';
2
+ import { C as Context } from './server.VtI8pLxV.mjs';
3
+ import { c as StandardHandleOptions } from './server.25yUS-xw.mjs';
4
+
5
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
6
+ context?: T;
7
+ } : {
8
+ context: T;
9
+ });
10
+ declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
11
+ /**
12
+ * {@link https://github.com/unjs/rou3}
13
+ *
14
+ * @internal
15
+ */
16
+ declare function toRou3Pattern(path: HTTPPath): string;
17
+ /**
18
+ * @internal
19
+ */
20
+ declare function decodeParams(params: Record<string, string>): Record<string, string>;
21
+
22
+ export { decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
23
+ export type { FriendlyStandardHandleOptions as F };
@@ -0,0 +1,30 @@
1
+ import { parse, serialize } from 'cookie';
2
+
3
+ function setCookie(headers, name, value, options = {}) {
4
+ if (headers === void 0) {
5
+ return;
6
+ }
7
+ const cookieString = serialize(name, value, {
8
+ path: "/",
9
+ ...options
10
+ });
11
+ headers.append("Set-Cookie", cookieString);
12
+ }
13
+ function getCookie(headers, name, options = {}) {
14
+ if (headers === void 0) {
15
+ return void 0;
16
+ }
17
+ const cookieHeader = headers.get("cookie");
18
+ if (cookieHeader === null) {
19
+ return void 0;
20
+ }
21
+ return parse(cookieHeader, options)[name];
22
+ }
23
+ function deleteCookie(headers, name, options = {}) {
24
+ return setCookie(headers, name, "", {
25
+ ...options,
26
+ maxAge: 0
27
+ });
28
+ }
29
+
30
+ export { deleteCookie as d, getCookie as g, setCookie as s };
@@ -1,7 +1,6 @@
1
1
  import { Meta } from '@temporary-name/contract';
2
- import { HTTPPath, ORPCError, Interceptor } from '@temporary-name/shared';
3
- import { StandardResponse, StandardLazyRequest } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, A as AnyRouter, a as AnyProcedure, P as ProcedureClientInterceptorOptions } from './server.C1YnHvvf.mjs';
2
+ import { HTTPPath, StandardLazyRequest, Interceptor, StandardResponse } from '@temporary-name/shared';
3
+ import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.VtI8pLxV.js';
5
4
 
6
5
  interface StandardHandlerPlugin<T extends Context> {
7
6
  order?: number;
@@ -13,22 +12,6 @@ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends
13
12
  init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
14
13
  }
15
14
 
16
- type StandardParams = Record<string, string>;
17
- type StandardMatchResult = {
18
- path: readonly string[];
19
- procedure: AnyProcedure;
20
- params?: StandardParams;
21
- } | undefined;
22
- interface StandardMatcher {
23
- init(router: AnyRouter): void;
24
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
25
- }
26
- interface StandardCodec {
27
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
28
- encodeError(error: ORPCError<any, any>): StandardResponse;
29
- decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
30
- }
31
-
32
15
  interface StandardHandleOptions<T extends Context> {
33
16
  prefix?: HTTPPath;
34
17
  context: T;
@@ -57,17 +40,16 @@ interface StandardHandlerOptions<TContext extends Context> {
57
40
  *
58
41
  * Interceptors for procedure client.
59
42
  */
60
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
43
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Meta>, Promise<unknown>>[];
61
44
  }
62
45
  declare class StandardHandler<T extends Context> {
63
- private readonly matcher;
64
- private readonly codec;
65
46
  private readonly interceptors;
66
47
  private readonly clientInterceptors;
67
48
  private readonly rootInterceptors;
68
- constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
49
+ private readonly matcher;
50
+ constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
69
51
  handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
70
52
  }
71
53
 
72
- export { CompositeStandardHandlerPlugin as C, StandardHandler as S };
73
- export type { StandardHandlerPlugin as a, StandardHandleOptions as b, StandardHandlerInterceptorOptions as c, StandardHandlerOptions as d, StandardHandleResult as e, StandardParams as f, StandardMatchResult as g, StandardMatcher as h, StandardCodec as i };
54
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as e };
55
+ export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardHandleOptions as c, StandardHandleResult as d };