@orpc/client 1.14.11 → 1.14.12
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/README.md +68 -52
- package/dist/adapters/fetch/index.d.mts +35 -54
- package/dist/adapters/fetch/index.d.ts +35 -54
- package/dist/adapters/fetch/index.mjs +27 -74
- package/dist/adapters/message-port/index.d.mts +30 -25
- package/dist/adapters/message-port/index.d.ts +30 -25
- package/dist/adapters/message-port/index.mjs +30 -39
- package/dist/adapters/standard/index.d.mts +9 -59
- package/dist/adapters/standard/index.d.ts +9 -59
- package/dist/adapters/standard/index.mjs +5 -5
- package/dist/adapters/websocket/index.d.mts +21 -113
- package/dist/adapters/websocket/index.d.ts +21 -113
- package/dist/adapters/websocket/index.mjs +37 -95
- package/dist/index.d.mts +184 -75
- package/dist/index.d.ts +184 -75
- package/dist/index.mjs +63 -74
- package/dist/plugins/index.d.mts +122 -191
- package/dist/plugins/index.d.ts +122 -191
- package/dist/plugins/index.mjs +281 -627
- package/dist/shared/client.2jUAqzYU.d.ts +45 -0
- package/dist/shared/client.B3pNRBih.d.ts +91 -0
- package/dist/shared/client.BFAVy68H.d.mts +91 -0
- package/dist/shared/client.BLtwTQUg.mjs +40 -0
- package/dist/shared/client.C1VUaWTu.mjs +404 -0
- package/dist/shared/client.CpCa3si8.d.mts +45 -0
- package/dist/shared/client.DrCRv_sG.mjs +174 -0
- package/dist/shared/client.i2uoJbEp.d.mts +83 -0
- package/dist/shared/client.i2uoJbEp.d.ts +83 -0
- package/package.json +7 -7
- package/dist/shared/client.8f4DNmdE.d.mts +0 -96
- package/dist/shared/client.BBZBQID8.d.mts +0 -167
- package/dist/shared/client.BBZBQID8.d.ts +0 -167
- package/dist/shared/client.BMKYqpdy.d.ts +0 -96
- package/dist/shared/client.BRJnOJ0R.mjs +0 -174
- package/dist/shared/client.BdItY5DT.d.mts +0 -111
- package/dist/shared/client.BdItY5DT.d.ts +0 -111
- package/dist/shared/client.Dnfj8jnT.mjs +0 -92
- package/dist/shared/client.DqYwRDUO.mjs +0 -343
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,253 +1,168 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
|
|
3
|
+
import { BatchResponseMode } from '@orpc/standard-server/batch';
|
|
4
|
+
import { b as ClientContext } from '../shared/client.i2uoJbEp.js';
|
|
5
|
+
import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.2jUAqzYU.js';
|
|
5
6
|
|
|
6
|
-
type BatchLinkPluginMode = 'streaming' | 'buffered';
|
|
7
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* If no group's condition returns true, the request will not be batched.
|
|
13
|
-
*/
|
|
14
|
-
condition: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
|
|
15
|
-
/**
|
|
16
|
-
* The client context applied to requests in this batch group for the remainder of the link chain.
|
|
17
|
-
*/
|
|
18
|
-
context: Value<T, [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
|
|
19
|
-
/**
|
|
20
|
-
* The path segments applied to requests in this batch group for the remainder of the link chain.
|
|
21
|
-
*
|
|
22
|
-
* @default []
|
|
23
|
-
*/
|
|
24
|
-
path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
|
|
25
|
-
}
|
|
26
|
-
declare class BatchLinkPluginError extends TypeError {
|
|
8
|
+
condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
|
|
9
|
+
context: T;
|
|
10
|
+
path?: readonly string[];
|
|
11
|
+
input?: unknown;
|
|
27
12
|
}
|
|
28
13
|
interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
29
|
-
groups: [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
|
|
30
|
-
/**
|
|
31
|
-
* Filters requests to batch.
|
|
32
|
-
*
|
|
33
|
-
* @default () => true
|
|
34
|
-
*/
|
|
35
|
-
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
|
|
14
|
+
groups: readonly [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
|
|
36
15
|
/**
|
|
37
16
|
* The maximum number of requests in the batch.
|
|
38
17
|
*
|
|
39
18
|
* @default 10
|
|
40
19
|
*/
|
|
41
|
-
maxSize?: Value<Promisable<number>, [
|
|
20
|
+
maxSize?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
42
21
|
/**
|
|
43
22
|
* The batch response mode.
|
|
44
23
|
*
|
|
45
24
|
* @default 'streaming'
|
|
46
25
|
*/
|
|
47
|
-
mode?: Value<
|
|
26
|
+
mode?: Value<BatchResponseMode, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
48
27
|
/**
|
|
49
|
-
* URL for the batch request.
|
|
28
|
+
* Defines the URL to use for the batch request.
|
|
50
29
|
*
|
|
51
|
-
* @default URL of the first
|
|
30
|
+
* @default the URL of the first request in the batch + '/__batch__'
|
|
52
31
|
*/
|
|
53
|
-
url?: Value<Promisable<
|
|
32
|
+
url?: Value<Promisable<string | URL>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
54
33
|
/**
|
|
55
|
-
* The maximum length of the URL
|
|
56
|
-
* if exceeded, the batch will be split into smaller batches and sent sequentially.
|
|
57
|
-
*
|
|
58
|
-
* This only applies to GET batch requests where the batch data is sent via URL query parameter.
|
|
34
|
+
* The maximum length of the URL.
|
|
59
35
|
*
|
|
60
36
|
* @default 2083
|
|
61
37
|
*/
|
|
62
|
-
maxUrlLength?: Value<Promisable<number>, [
|
|
38
|
+
maxUrlLength?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
63
39
|
/**
|
|
64
|
-
*
|
|
40
|
+
* Defines the HTTP headers to use for the batch request.
|
|
65
41
|
*
|
|
66
|
-
* @default
|
|
42
|
+
* @default The same headers of all requests in the batch
|
|
67
43
|
*/
|
|
68
|
-
headers?: Value<Promisable<StandardHeaders>, [
|
|
44
|
+
headers?: Value<Promisable<StandardHeaders>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
69
45
|
/**
|
|
70
|
-
* Map
|
|
46
|
+
* Map the batch request items before sending them.
|
|
71
47
|
*
|
|
72
|
-
* @default Removes headers that are duplicated
|
|
48
|
+
* @default Removes headers that are duplicated in the batch headers.
|
|
73
49
|
*/
|
|
74
|
-
|
|
50
|
+
mapRequestItem?: (options: StandardLinkClientInterceptorOptions<T> & {
|
|
51
|
+
batchUrl: URL;
|
|
52
|
+
batchHeaders: StandardHeaders;
|
|
53
|
+
}) => StandardRequest;
|
|
75
54
|
/**
|
|
76
|
-
*
|
|
55
|
+
* Exclude a request from the batch.
|
|
77
56
|
*
|
|
78
|
-
* @default
|
|
57
|
+
* @default () => false
|
|
79
58
|
*/
|
|
80
|
-
|
|
59
|
+
exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
|
|
81
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
|
|
63
|
+
* reducing the overhead of sending each one separately.
|
|
64
|
+
*
|
|
65
|
+
* @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
|
|
66
|
+
*/
|
|
82
67
|
declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
83
|
-
|
|
68
|
+
#private;
|
|
84
69
|
private readonly groups;
|
|
85
|
-
private readonly filter;
|
|
86
70
|
private readonly maxSize;
|
|
87
|
-
private readonly mode;
|
|
88
71
|
private readonly batchUrl;
|
|
89
72
|
private readonly maxUrlLength;
|
|
90
73
|
private readonly batchHeaders;
|
|
91
|
-
private readonly
|
|
92
|
-
private readonly
|
|
93
|
-
private readonly
|
|
74
|
+
private readonly mapRequestItem;
|
|
75
|
+
private readonly exclude;
|
|
76
|
+
private readonly mode;
|
|
77
|
+
private pending;
|
|
78
|
+
order: number;
|
|
94
79
|
constructor(options: NoInfer<BatchLinkPluginOptions<T>>);
|
|
95
|
-
init(options: StandardLinkOptions<T>):
|
|
96
|
-
private processPendingBatches;
|
|
97
|
-
private executeBatch;
|
|
80
|
+
init(options: StandardLinkOptions<T>): void;
|
|
98
81
|
}
|
|
99
82
|
|
|
100
|
-
interface
|
|
101
|
-
condition
|
|
83
|
+
interface DedupeRequestsPluginGroup<T extends ClientContext> {
|
|
84
|
+
condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
|
|
102
85
|
/**
|
|
103
86
|
* The context used for the rest of the request lifecycle.
|
|
104
87
|
*/
|
|
105
|
-
context:
|
|
106
|
-
items: [
|
|
107
|
-
StandardLinkTransportInterceptorOptions<T>,
|
|
108
|
-
StandardLinkTransportInterceptorOptions<T>,
|
|
109
|
-
...StandardLinkTransportInterceptorOptions<T>[]
|
|
110
|
-
]
|
|
111
|
-
]>;
|
|
88
|
+
context: T;
|
|
112
89
|
}
|
|
113
|
-
interface
|
|
90
|
+
interface DedupeRequestsPluginOptions<T extends ClientContext> {
|
|
114
91
|
/**
|
|
115
92
|
* To enable deduplication, a request must match at least one defined group.
|
|
116
93
|
* Requests that fall into the same group are considered for deduplication together.
|
|
117
94
|
*/
|
|
118
|
-
groups: [
|
|
95
|
+
groups: readonly [DedupeRequestsPluginGroup<T>, ...DedupeRequestsPluginGroup<T>[]];
|
|
119
96
|
/**
|
|
120
|
-
* Filters requests to dedupe
|
|
97
|
+
* Filters requests to dedupe
|
|
121
98
|
*
|
|
122
|
-
* @default ({ request }) => request.method === 'GET'
|
|
123
|
-
*/
|
|
124
|
-
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
|
|
125
|
-
}
|
|
126
|
-
declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
127
|
-
name: string;
|
|
128
|
-
before: string[];
|
|
129
|
-
private readonly groups;
|
|
130
|
-
private readonly filter;
|
|
131
|
-
private readonly queue;
|
|
132
|
-
constructor(options: NoInfer<DedupeLinkPluginOptions<T>>);
|
|
133
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
134
|
-
private enqueue;
|
|
135
|
-
private processPendingRequests;
|
|
136
|
-
private execute;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
interface RequestCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
140
|
-
/**
|
|
141
|
-
* The compression scheme to use for request compression.
|
|
142
|
-
*
|
|
143
|
-
* @default 'gzip'
|
|
144
|
-
*/
|
|
145
|
-
encoding?: 'gzip' | 'deflate' | 'deflate-raw';
|
|
146
|
-
/**
|
|
147
|
-
* The minimum request size in bytes required to trigger compression.
|
|
148
|
-
* Requests smaller than this threshold will not be compressed to avoid overhead.
|
|
149
|
-
* If the request size cannot be determined, compression will still be applied.
|
|
150
|
-
*
|
|
151
|
-
* @default 1024 (1KB)
|
|
152
|
-
*/
|
|
153
|
-
threshold?: number;
|
|
154
|
-
}
|
|
155
|
-
declare class RequestCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
156
|
-
name: string;
|
|
157
|
-
/**
|
|
158
|
-
* Compression should be done after batching, to compress the final request
|
|
99
|
+
* @default (({ request }) => request.method === 'GET')
|
|
159
100
|
*/
|
|
160
|
-
|
|
161
|
-
private readonly encoding;
|
|
162
|
-
private readonly threshold;
|
|
163
|
-
constructor(options?: RequestCompressionLinkPluginOptions<T>);
|
|
164
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
168
|
-
/**
|
|
169
|
-
* Compression schemes to advertise via Accept-Encoding, in preference order.
|
|
170
|
-
* Only schemes that can be decompressed by this plugin should be listed.
|
|
171
|
-
*
|
|
172
|
-
* @default ['gzip', 'deflate']
|
|
173
|
-
*/
|
|
174
|
-
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
101
|
+
filter?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
|
|
175
102
|
}
|
|
176
103
|
/**
|
|
177
|
-
*
|
|
178
|
-
* based on the Content-Encoding header. Works at the standard link level,
|
|
179
|
-
* so it supports all adapters.
|
|
104
|
+
* Prevents duplicate requests by deduplicating similar ones to reduce server load.
|
|
180
105
|
*
|
|
181
|
-
* @see {@link https://orpc.dev/docs/plugins/
|
|
106
|
+
* @see {@link https://orpc.dev/docs/plugins/dedupe-requests Dedupe Requests Plugin}
|
|
182
107
|
*/
|
|
183
|
-
declare class
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
after: string[];
|
|
189
|
-
private readonly encodings;
|
|
190
|
-
constructor(options?: ResponseCompressionLinkPluginOptions<T>);
|
|
191
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
108
|
+
declare class DedupeRequestsPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
109
|
+
#private;
|
|
110
|
+
order: number;
|
|
111
|
+
constructor(options: NoInfer<DedupeRequestsPluginOptions<T>>);
|
|
112
|
+
init(options: StandardLinkOptions<T>): void;
|
|
192
113
|
}
|
|
193
114
|
|
|
194
|
-
interface
|
|
195
|
-
/**
|
|
196
|
-
* Latest retry delay advertised by the server via event metadata.
|
|
197
|
-
*/
|
|
115
|
+
interface ClientRetryPluginAttemptOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
|
|
198
116
|
lastEventRetry: number | undefined;
|
|
199
|
-
|
|
200
|
-
* Current retry attempt number, starting at 1.
|
|
201
|
-
*/
|
|
202
|
-
attempt: number;
|
|
203
|
-
/**
|
|
204
|
-
* Error that triggered this retry attempt.
|
|
205
|
-
*/
|
|
117
|
+
attemptIndex: number;
|
|
206
118
|
error: unknown;
|
|
207
119
|
}
|
|
208
|
-
interface
|
|
120
|
+
interface ClientRetryPluginContext {
|
|
209
121
|
/**
|
|
210
|
-
* Maximum retry attempts before throwing
|
|
211
|
-
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g
|
|
122
|
+
* Maximum retry attempts before throwing
|
|
123
|
+
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g., when handling Server-Sent Events).
|
|
212
124
|
*
|
|
213
125
|
* @default 0
|
|
214
126
|
*/
|
|
215
|
-
retry?: Value<Promisable<number>, [
|
|
127
|
+
retry?: Value<Promisable<number>, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
|
|
216
128
|
/**
|
|
217
129
|
* Delay (in ms) before retrying.
|
|
218
130
|
*
|
|
219
|
-
* @info Why 2000ms? The EventSource spec suggests a default retry delay of 2 seconds if it doesn't specify
|
|
220
131
|
* @default (o) => o.lastEventRetry ?? 2000
|
|
221
132
|
*/
|
|
222
|
-
retryDelay?: Value<Promisable<number>, [
|
|
133
|
+
retryDelay?: Value<Promisable<number>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
|
|
223
134
|
/**
|
|
224
|
-
* Determine
|
|
135
|
+
* Determine should retry or not.
|
|
225
136
|
*
|
|
226
137
|
* @default true
|
|
227
138
|
*/
|
|
228
|
-
shouldRetry?: Value<Promisable<boolean>, [
|
|
139
|
+
shouldRetry?: Value<Promisable<boolean>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
|
|
229
140
|
/**
|
|
230
|
-
*
|
|
141
|
+
* The hook called when retrying, and return the unsubscribe function.
|
|
231
142
|
*/
|
|
232
|
-
onRetry?: (options:
|
|
143
|
+
onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | ((isSuccess: boolean) => void);
|
|
233
144
|
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Default retry options. Can be overridden by individual calls via the context.
|
|
237
|
-
*/
|
|
238
|
-
default?: RetryLinkPluginContext | undefined;
|
|
145
|
+
declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
|
|
239
146
|
}
|
|
240
|
-
|
|
147
|
+
interface ClientRetryPluginOptions {
|
|
148
|
+
default?: ClientRetryPluginContext;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The Client Retry Plugin enables retrying client calls when errors occur.
|
|
152
|
+
*
|
|
153
|
+
* @see {@link https://orpc.dev/docs/plugins/client-retry Client Retry Plugin Docs}
|
|
154
|
+
*/
|
|
155
|
+
declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
|
|
241
156
|
private readonly defaultRetry;
|
|
242
157
|
private readonly defaultRetryDelay;
|
|
243
158
|
private readonly defaultShouldRetry;
|
|
244
159
|
private readonly defaultOnRetry;
|
|
245
|
-
|
|
246
|
-
constructor(options?:
|
|
247
|
-
init(options: StandardLinkOptions<T>):
|
|
160
|
+
order: number;
|
|
161
|
+
constructor(options?: ClientRetryPluginOptions);
|
|
162
|
+
init(options: StandardLinkOptions<T>): void;
|
|
248
163
|
}
|
|
249
164
|
|
|
250
|
-
interface
|
|
165
|
+
interface RetryAfterPluginOptions<T extends ClientContext> {
|
|
251
166
|
/**
|
|
252
167
|
* Override condition to determine whether to retry or not.
|
|
253
168
|
*
|
|
@@ -255,7 +170,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
255
170
|
*/
|
|
256
171
|
condition?: Value<boolean, [
|
|
257
172
|
response: StandardLazyResponse,
|
|
258
|
-
options:
|
|
173
|
+
options: StandardLinkClientInterceptorOptions<T>
|
|
259
174
|
]>;
|
|
260
175
|
/**
|
|
261
176
|
* Maximum attempts before giving up retries.
|
|
@@ -264,7 +179,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
264
179
|
*/
|
|
265
180
|
maxAttempts?: Value<number, [
|
|
266
181
|
response: StandardLazyResponse,
|
|
267
|
-
options:
|
|
182
|
+
options: StandardLinkClientInterceptorOptions<T>
|
|
268
183
|
]>;
|
|
269
184
|
/**
|
|
270
185
|
* Maximum timeout in milliseconds to wait before giving up retries.
|
|
@@ -273,46 +188,62 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
273
188
|
*/
|
|
274
189
|
timeout?: Value<number, [
|
|
275
190
|
response: StandardLazyResponse,
|
|
276
|
-
options:
|
|
191
|
+
options: StandardLinkClientInterceptorOptions<T>
|
|
277
192
|
]>;
|
|
278
193
|
}
|
|
279
194
|
/**
|
|
280
|
-
* The Retry After
|
|
195
|
+
* The Retry After Plugin automatically retries requests based on server `Retry-After` headers.
|
|
281
196
|
* This is particularly useful for handling rate limiting and temporary server unavailability.
|
|
282
197
|
*
|
|
283
198
|
* @see {@link https://orpc.dev/docs/plugins/retry-after Retry After Plugin Docs}
|
|
284
199
|
*/
|
|
285
|
-
declare class
|
|
200
|
+
declare class RetryAfterPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
286
201
|
private readonly condition;
|
|
287
202
|
private readonly maxAttempts;
|
|
288
203
|
private readonly timeout;
|
|
289
|
-
|
|
290
|
-
constructor(options?:
|
|
291
|
-
init(options: StandardLinkOptions<T>):
|
|
204
|
+
order: number;
|
|
205
|
+
constructor(options?: RetryAfterPluginOptions<T>);
|
|
206
|
+
init(options: StandardLinkOptions<T>): void;
|
|
207
|
+
private parseRetryAfterHeader;
|
|
208
|
+
private delayExecution;
|
|
292
209
|
}
|
|
293
210
|
|
|
294
|
-
interface
|
|
211
|
+
interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
|
|
295
212
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
213
|
+
* The name of the header to check.
|
|
214
|
+
*
|
|
215
|
+
* @default 'x-csrf-token'
|
|
298
216
|
*/
|
|
299
|
-
|
|
217
|
+
headerName?: Value<Promisable<string>, [options: StandardLinkClientInterceptorOptions<T>]>;
|
|
218
|
+
/**
|
|
219
|
+
* The value of the header to check.
|
|
220
|
+
*
|
|
221
|
+
* @default 'orpc'
|
|
222
|
+
*
|
|
223
|
+
*/
|
|
224
|
+
headerValue?: Value<Promisable<string>, [options: StandardLinkClientInterceptorOptions<T>]>;
|
|
225
|
+
/**
|
|
226
|
+
* Exclude a procedure from the plugin.
|
|
227
|
+
*
|
|
228
|
+
* @default false
|
|
229
|
+
*/
|
|
230
|
+
exclude?: Value<Promisable<boolean>, [options: StandardLinkClientInterceptorOptions<T>]>;
|
|
300
231
|
}
|
|
301
232
|
/**
|
|
302
|
-
*
|
|
233
|
+
* This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
|
|
234
|
+
* It helps ensure that requests to your procedures originate from JavaScript code,
|
|
235
|
+
* not from other sources like standard HTML forms or direct browser navigation.
|
|
303
236
|
*
|
|
304
|
-
* @see {@link https://orpc.dev/docs/plugins/
|
|
237
|
+
* @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
|
|
305
238
|
*/
|
|
306
|
-
declare class
|
|
307
|
-
private readonly
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
constructor(options: NoInfer<TimeoutLinkPluginOptions<T>>);
|
|
314
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
239
|
+
declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
240
|
+
private readonly headerName;
|
|
241
|
+
private readonly headerValue;
|
|
242
|
+
private readonly exclude;
|
|
243
|
+
constructor(options?: SimpleCsrfProtectionLinkPluginOptions<T>);
|
|
244
|
+
order: number;
|
|
245
|
+
init(options: StandardLinkOptions<T>): void;
|
|
315
246
|
}
|
|
316
247
|
|
|
317
|
-
export { BatchLinkPlugin,
|
|
318
|
-
export type { BatchLinkPluginGroup,
|
|
248
|
+
export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, RetryAfterPlugin, SimpleCsrfProtectionLinkPlugin };
|
|
249
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, RetryAfterPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
|