@types/node 26.1.2 → 26.3.0
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.
- node/README.md +1 -1
- node/buffer.buffer.d.ts +5 -5
- node/child_process.d.ts +0 -1
- node/crypto.d.ts +8 -8
- node/dns/promises.d.ts +5 -5
- node/dns.d.ts +5 -5
- node/fs.d.ts +7 -0
- node/http.d.ts +46 -0
- node/http2.d.ts +14 -6
- node/os.d.ts +30 -30
- node/package.json +2 -2
- node/perf_hooks.d.ts +2 -1
- node/process.d.ts +94 -43
- node/quic.d.ts +1242 -95
- node/sqlite.d.ts +20 -3
- node/stream/iter.d.ts +3 -2
- node/test.d.ts +97 -0
- node/v8.d.ts +20 -23
node/quic.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
declare module "node:quic" {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { NonSharedBuffer } from "node:buffer";
|
|
3
|
+
import { KeyObject } from "node:crypto";
|
|
4
|
+
import { FileHandle } from "node:fs/promises";
|
|
5
|
+
import { BlockList, SocketAddress } from "node:net";
|
|
6
|
+
import { Writer } from "node:stream/iter";
|
|
7
|
+
import { EphemeralKeyInfo, PeerCertificate } from "node:tls";
|
|
5
8
|
/**
|
|
6
9
|
* @since v23.8.0
|
|
7
10
|
*/
|
|
@@ -13,11 +16,15 @@ declare module "node:quic" {
|
|
|
13
16
|
/**
|
|
14
17
|
* @since v23.8.0
|
|
15
18
|
*/
|
|
16
|
-
type OnDatagramCallback = (this: QuicSession, datagram:
|
|
19
|
+
type OnDatagramCallback = (this: QuicSession, datagram: NodeJS.NonSharedUint8Array, early: boolean) => void;
|
|
17
20
|
/**
|
|
18
21
|
* @since v23.8.0
|
|
19
22
|
*/
|
|
20
|
-
type OnDatagramStatusCallback = (
|
|
23
|
+
type OnDatagramStatusCallback = (
|
|
24
|
+
this: QuicSession,
|
|
25
|
+
id: bigint,
|
|
26
|
+
status: "acknowledged" | "lost" | "abandoned",
|
|
27
|
+
) => void;
|
|
21
28
|
/**
|
|
22
29
|
* @since v23.8.0
|
|
23
30
|
*/
|
|
@@ -26,8 +33,8 @@ declare module "node:quic" {
|
|
|
26
33
|
result: "success" | "failure" | "aborted",
|
|
27
34
|
newLocalAddress: SocketAddress,
|
|
28
35
|
newRemoteAddress: SocketAddress,
|
|
29
|
-
oldLocalAddress: SocketAddress,
|
|
30
|
-
oldRemoteAddress: SocketAddress,
|
|
36
|
+
oldLocalAddress: SocketAddress | null,
|
|
37
|
+
oldRemoteAddress: SocketAddress | null,
|
|
31
38
|
preferredAddress: boolean,
|
|
32
39
|
) => void;
|
|
33
40
|
/**
|
|
@@ -46,16 +53,32 @@ declare module "node:quic" {
|
|
|
46
53
|
/**
|
|
47
54
|
* @since v23.8.0
|
|
48
55
|
*/
|
|
49
|
-
type OnHandshakeCallback = (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
type OnHandshakeCallback = (this: QuicSession, info: SessionHandshakeInfo) => void;
|
|
57
|
+
/**
|
|
58
|
+
* @since v26.2.0
|
|
59
|
+
*/
|
|
60
|
+
type OnNewTokenCallback = (this: QuicSession, token: NonSharedBuffer, address: SocketAddress) => void;
|
|
61
|
+
/**
|
|
62
|
+
* @since v26.2.0
|
|
63
|
+
*/
|
|
64
|
+
type OnOriginCallback = (this: QuicSession, origins: string[]) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Called when TLS key material is available. Only fires when
|
|
67
|
+
* `sessionOptions.keylog` is `true`. Multiple lines are emitted during the
|
|
68
|
+
* TLS 1.3 handshake, each containing a secret label, the client random, and
|
|
69
|
+
* the secret value.
|
|
70
|
+
* @since v26.2.0
|
|
71
|
+
*/
|
|
72
|
+
type OnKeylogCallback = (this: QuicSession, line: string) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Called when qlog diagnostic data is available. Only fires when
|
|
75
|
+
* `sessionOptions.qlog` is `true`. The `data` chunks should be
|
|
76
|
+
* concatenated in order to produce the complete qlog output. When `fin` is
|
|
77
|
+
* `true`, no more chunks will be emitted and the concatenated result is a
|
|
78
|
+
* complete JSON-SEQ document.
|
|
79
|
+
* @since v26.2.0
|
|
80
|
+
*/
|
|
81
|
+
type OnQlogCallback = (this: QuicSession, data: string, fin: boolean) => void;
|
|
59
82
|
/**
|
|
60
83
|
* @since v23.8.0
|
|
61
84
|
*/
|
|
@@ -64,17 +87,35 @@ declare module "node:quic" {
|
|
|
64
87
|
* @since v23.8.0
|
|
65
88
|
*/
|
|
66
89
|
type OnStreamErrorCallback = (this: QuicStream, error: any) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Called when initial request or response headers are received. For HTTP/3,
|
|
92
|
+
* this delivers request pseudo-headers on the server and response headers
|
|
93
|
+
* on the client.
|
|
94
|
+
* @since v26.2.0
|
|
95
|
+
*/
|
|
96
|
+
type OnHeadersCallback = (this: QuicStream, headers: NodeJS.Dict<string | string[]>) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Called when trailing headers are received from the peer.
|
|
99
|
+
* @since v26.2.0
|
|
100
|
+
*/
|
|
101
|
+
type OnTrailersCallback = (this: QuicStream, trailers: NodeJS.Dict<string | string[]>) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Called when informational (1xx) headers are received from the server
|
|
104
|
+
* (e.g., 103 Early Hints).
|
|
105
|
+
* @since v26.2.0
|
|
106
|
+
*/
|
|
107
|
+
type OnInfoCallback = (this: QuicStream, headers: NodeJS.Dict<string | string[]>) => void;
|
|
67
108
|
/**
|
|
68
109
|
* @since v23.8.0
|
|
69
110
|
*/
|
|
70
111
|
interface TransportParams {
|
|
71
112
|
/**
|
|
72
|
-
* The preferred IPv4 address to advertise.
|
|
113
|
+
* The preferred IPv4 address to advertise (only used by servers).
|
|
73
114
|
* @since v23.8.0
|
|
74
115
|
*/
|
|
75
116
|
preferredAddressIpv4?: SocketAddress | undefined;
|
|
76
117
|
/**
|
|
77
|
-
* The preferred IPv6 address to advertise
|
|
118
|
+
* The preferred IPv6 address to advertise (only used by servers)
|
|
78
119
|
* @since v23.8.0
|
|
79
120
|
*/
|
|
80
121
|
preferredAddressIpv6?: SocketAddress | undefined;
|
|
@@ -119,16 +160,80 @@ declare module "node:quic" {
|
|
|
119
160
|
*/
|
|
120
161
|
maxAckDelay?: bigint | number | undefined;
|
|
121
162
|
/**
|
|
163
|
+
* The maximum size in bytes of a DATAGRAM frame payload that this endpoint
|
|
164
|
+
* is willing to receive. Set to `0` to disable datagram support. The peer
|
|
165
|
+
* will not send datagrams larger than this value. The actual maximum size of
|
|
166
|
+
* a datagram that can be _sent_ is determined by the peer's
|
|
167
|
+
* `maxDatagramFrameSize`, not this endpoint's value.
|
|
122
168
|
* @since v23.8.0
|
|
123
169
|
*/
|
|
124
170
|
maxDatagramFrameSize?: bigint | number | undefined;
|
|
125
171
|
}
|
|
126
172
|
interface SNIEntry {
|
|
173
|
+
/**
|
|
174
|
+
* The TLS private keys. **Required.**
|
|
175
|
+
*/
|
|
127
176
|
keys: KeyObject | readonly KeyObject[];
|
|
177
|
+
/**
|
|
178
|
+
* The TLS certificates. **Required.**
|
|
179
|
+
*/
|
|
128
180
|
certs: ArrayBuffer | NodeJS.ArrayBufferView | ReadonlyArray<ArrayBuffer | NodeJS.ArrayBufferView>;
|
|
129
|
-
|
|
130
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Verify the private key. Default: `false`.
|
|
183
|
+
*/
|
|
131
184
|
verifyPrivateKey?: boolean | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* The port to advertise in ORIGIN frames (RFC 9412) for this host name. **Default:** `443`. Only used for HTTP/3 sessions.
|
|
187
|
+
*/
|
|
188
|
+
port?: number | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Whether to include this host name in ORIGIN frames. **Default:** `true`. Set to `false` to exclude a host name
|
|
191
|
+
* from ORIGIN advertisements. Wildcard (`'*'`) entries are always excluded regardless of this setting.
|
|
192
|
+
*/
|
|
193
|
+
authoritative?: boolean | undefined;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @since v26.3.0
|
|
197
|
+
*/
|
|
198
|
+
interface ApplicationOptions {
|
|
199
|
+
/**
|
|
200
|
+
* Maximum number of header name-value pairs accepted per header block.
|
|
201
|
+
* Headers beyond this limit are silently dropped. **Default:** `128`
|
|
202
|
+
*/
|
|
203
|
+
maxHeaderPairs?: bigint | number | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* Maximum total byte length of all header names and values combined per header
|
|
206
|
+
* block. Headers that would push the total over this limit are silently
|
|
207
|
+
* dropped. **Default:** `8192`
|
|
208
|
+
*/
|
|
209
|
+
maxHeaderLength?: bigint | number | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* Maximum size of a compressed header field section (QPACK). `0` means
|
|
212
|
+
* unlimited. **Default:** `0`
|
|
213
|
+
*/
|
|
214
|
+
maxFieldSectionSize?: bigint | number | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* QPACK dynamic table capacity in bytes. Set to `0` to disable the dynamic
|
|
217
|
+
* table. **Default:** `4096`
|
|
218
|
+
*/
|
|
219
|
+
qpackMaxDTableCapacity?: bigint | number | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* QPACK encoder maximum dynamic table capacity. **Default:** `4096`
|
|
222
|
+
*/
|
|
223
|
+
qpackEncoderMaxDTableCapacity?: bigint | number | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* Maximum number of streams that can e blocked waiting for QPACK dynamic table
|
|
226
|
+
* updates. **Default:** `100`
|
|
227
|
+
*/
|
|
228
|
+
qpackBlockedStreams?: bigint | number | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Enable the extended CONNECT protocol (RFC 9220). **Default:** `false`
|
|
231
|
+
*/
|
|
232
|
+
enableConnectProtocol?: boolean | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Enable HTTP/3 datagrams (RFC 9297). **Default:** `false`
|
|
235
|
+
*/
|
|
236
|
+
enableDatagrams?: boolean | undefined;
|
|
132
237
|
}
|
|
133
238
|
/**
|
|
134
239
|
* @since v23.8.0
|
|
@@ -156,6 +261,11 @@ declare module "node:quic" {
|
|
|
156
261
|
* @since v26.1.0
|
|
157
262
|
*/
|
|
158
263
|
alpn?: string | readonly string[] | undefined;
|
|
264
|
+
/**
|
|
265
|
+
* Application-specific options.
|
|
266
|
+
* @since v26.2.0
|
|
267
|
+
*/
|
|
268
|
+
application?: ApplicationOptions | undefined;
|
|
159
269
|
/**
|
|
160
270
|
* The CA certificates to use for client sessions. For server sessions, CA
|
|
161
271
|
* certificates are specified per-identity in the `sessionOptions.sni` map.
|
|
@@ -188,12 +298,23 @@ declare module "node:quic" {
|
|
|
188
298
|
*/
|
|
189
299
|
crl?: ArrayBuffer | NodeJS.ArrayBufferView | ReadonlyArray<ArrayBuffer | NodeJS.ArrayBufferView> | undefined;
|
|
190
300
|
/**
|
|
191
|
-
*
|
|
301
|
+
* When `true`, enables TLS 0-RTT early data for this session. Early data
|
|
302
|
+
* allows the client to send application data before the TLS handshake
|
|
303
|
+
* completes, reducing latency on reconnection when a valid session ticket
|
|
304
|
+
* is available. Set to `false` to disable early data support.
|
|
305
|
+
* @since v26.2.0
|
|
306
|
+
*/
|
|
307
|
+
enableEarlyData?: boolean | undefined;
|
|
308
|
+
/**
|
|
309
|
+
* The list of supported TLS 1.3 cipher groups.
|
|
192
310
|
* @since v23.8.0
|
|
193
311
|
*/
|
|
194
312
|
groups?: string | undefined;
|
|
195
313
|
/**
|
|
196
|
-
*
|
|
314
|
+
* When `true`, enables TLS key logging for the session. Key material is
|
|
315
|
+
* delivered to the `session.onkeylog` callback in [NSS Key Log Format](https://udn.realityripple.com/docs/Mozilla/Projects/NSS/Key_Log_Format).
|
|
316
|
+
* Each callback invocation receives a single line of key material. The output
|
|
317
|
+
* can be used with tools such as Wireshark to decrypt captured QUIC traffic.
|
|
197
318
|
* @since v23.8.0
|
|
198
319
|
*/
|
|
199
320
|
keylog?: boolean | undefined;
|
|
@@ -226,12 +347,20 @@ declare module "node:quic" {
|
|
|
226
347
|
minVersion?: number | undefined;
|
|
227
348
|
/**
|
|
228
349
|
* When the remote peer advertises a preferred address, this option specifies whether
|
|
229
|
-
* to use it or ignore it.
|
|
350
|
+
* to use it or ignore it. The default is `'ignore'` because honoring a server's
|
|
351
|
+
* preferred address causes the client to migrate its connection to a different IP
|
|
352
|
+
* address, which can be exploited for data exfiltration attacks that are
|
|
353
|
+
* indistinguishable from legitimate QUIC connection migration at the network level.
|
|
354
|
+
* Set to `'use'` only when connecting to trusted servers that require preferred
|
|
355
|
+
* address migration.
|
|
230
356
|
* @since v23.8.0
|
|
231
357
|
*/
|
|
232
358
|
preferredAddressPolicy?: "use" | "ignore" | "default" | undefined;
|
|
233
359
|
/**
|
|
234
|
-
*
|
|
360
|
+
* When `true`, enables [qlog](https://datatracker.ietf.org/doc/draft-ietf-quic-qlog-main-schema/) diagnostic output for the session. Qlog data
|
|
361
|
+
* is delivered to the `session.onqlog` callback as chunks of [JSON-SEQ](https://www.rfc-editor.org/rfc/rfc7464)
|
|
362
|
+
* formatted text. The output can be analyzed with qlog visualization tools
|
|
363
|
+
* such as [qvis](https://qvis.quictools.info/).
|
|
235
364
|
* @since v23.8.0
|
|
236
365
|
*/
|
|
237
366
|
qlog?: boolean | undefined;
|
|
@@ -241,11 +370,82 @@ declare module "node:quic" {
|
|
|
241
370
|
*/
|
|
242
371
|
sessionTicket?: NodeJS.ArrayBufferView | undefined;
|
|
243
372
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
373
|
+
* Controls which datagram to drop when the pending datagram queue
|
|
374
|
+
* (sized by `session.maxPendingDatagrams`) is full. Must be one of
|
|
375
|
+
* `'drop-oldest'` (discard the oldest queued datagram to make room) or
|
|
376
|
+
* `'drop-newest'` (reject the incoming datagram). Dropped datagrams are
|
|
377
|
+
* reported as lost via the `ondatagramstatus` callback.
|
|
378
|
+
*
|
|
379
|
+
* This option is immutable after session creation.
|
|
380
|
+
* @since v26.2.0
|
|
381
|
+
*/
|
|
382
|
+
datagramDropPolicy?: "drop-oldest" | "drop-newest" | undefined;
|
|
383
|
+
/**
|
|
384
|
+
* The maximum time in milliseconds that a peer-initiated stream can be idle
|
|
385
|
+
* (no data received) before it is automatically destroyed. This protects
|
|
386
|
+
* against slowloris-style attacks where a remote peer opens streams but never
|
|
387
|
+
* sends data, holding server resources indefinitely. Only peer-initiated
|
|
388
|
+
* streams are checked — locally-initiated streams are the application's
|
|
389
|
+
* responsibility. Set to `0` to disable.
|
|
390
|
+
*
|
|
391
|
+
* The idle check runs as part of the normal send processing loop, so it adds
|
|
392
|
+
* no additional timers or event loop overhead. The
|
|
393
|
+
* `session.stats.streamsIdleTimedOut` counter tracks how many streams have been
|
|
394
|
+
* destroyed by this mechanism.
|
|
395
|
+
* @since v26.3.0
|
|
396
|
+
*/
|
|
397
|
+
streamIdleTimeout?: bigint | number | undefined;
|
|
398
|
+
/**
|
|
399
|
+
* The maximum number of `SendPendingData` cycles a datagram can survive
|
|
400
|
+
* without being sent before it is abandoned. When a datagram cannot be
|
|
401
|
+
* sent due to congestion control or packet size constraints, it remains
|
|
402
|
+
* in the queue and the attempt counter increments. Once the limit is
|
|
403
|
+
* reached, the datagram is dropped and reported as `'abandoned'` via the
|
|
404
|
+
* `ondatagramstatus` callback. Valid range: `1` to `255`.
|
|
405
|
+
* @since v26.2.0
|
|
406
|
+
*/
|
|
407
|
+
maxDatagramSendAttempts?: number | undefined;
|
|
408
|
+
/**
|
|
409
|
+
* A multiplier applied to the Probe Timeout (PTO) to compute the draining
|
|
410
|
+
* period duration after receiving a `CONNECTION_CLOSE` frame from the peer.
|
|
411
|
+
* RFC 9000 Section 10.2 requires the draining period to persist for at least
|
|
412
|
+
* three times the current PTO. The valid range is `3` to `255`. Values below
|
|
413
|
+
* `3` are clamped to `3`.
|
|
414
|
+
* @since v26.2.0
|
|
415
|
+
*/
|
|
416
|
+
drainingPeriodMultiplier?: number | undefined;
|
|
417
|
+
/**
|
|
418
|
+
* Specifies the keep-alive timeout in milliseconds. When set to a non-zero
|
|
419
|
+
* value, PING frames will be sent automatically to keep the connection alive
|
|
420
|
+
* before the idle timeout fires. The value should be less than the effective
|
|
421
|
+
* idle timeout (`maxIdleTimeout` transport parameter) to be useful.
|
|
246
422
|
* @since v23.8.0
|
|
247
423
|
*/
|
|
248
424
|
handshakeTimeout?: bigint | number | undefined;
|
|
425
|
+
/**
|
|
426
|
+
* Controls how the client handles server certificate validation:
|
|
427
|
+
*
|
|
428
|
+
* * `'strict'` — OpenSSL aborts the TLS handshake immediately if the server's
|
|
429
|
+
* certificate fails validation. The `session.opened` promise rejects with a
|
|
430
|
+
* TLS error. The application cannot inspect the certificate or the error
|
|
431
|
+
* details. This is the most secure mode.
|
|
432
|
+
*
|
|
433
|
+
* * `'auto'` — The TLS handshake completes regardless of validation result.
|
|
434
|
+
* If validation fails, the `session.opened` promise is rejected with an error
|
|
435
|
+
* containing the validation reason, and the session is destroyed. The
|
|
436
|
+
* `onhandshake` callback (if set) fires before rejection, allowing diagnostic
|
|
437
|
+
* logging. This is the default and matches the behavior of `tls.connect()`
|
|
438
|
+
* with `rejectUnauthorized: true`.
|
|
439
|
+
*
|
|
440
|
+
* * `'manual'` — The TLS handshake completes regardless of validation result.
|
|
441
|
+
* The `session.opened` promise resolves with the handshake info, which includes
|
|
442
|
+
* `validationErrorReason` and `validationErrorCode` if validation failed. The
|
|
443
|
+
* application is responsible for checking these values and deciding whether to
|
|
444
|
+
* continue. Use this mode for custom validation logic, certificate pinning, or
|
|
445
|
+
* intentionally accepting self-signed certificates.
|
|
446
|
+
* @since v26.3.0
|
|
447
|
+
*/
|
|
448
|
+
verifyPeer?: "strict" | "auto" | "manual" | undefined;
|
|
249
449
|
/**
|
|
250
450
|
* The peer server name to target (SNI). Defaults to `'localhost'`.
|
|
251
451
|
* @since v26.1.0
|
|
@@ -253,28 +453,12 @@ declare module "node:quic" {
|
|
|
253
453
|
servername?: string | undefined;
|
|
254
454
|
/**
|
|
255
455
|
* An object mapping host names to TLS identity options for Server Name
|
|
256
|
-
* Indication (SNI) support. This is required for server sessions
|
|
257
|
-
* special key `'*'` specifies the
|
|
258
|
-
* no other host name matches.
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* sni: {
|
|
263
|
-
* '*': { keys: [defaultKey], certs: [defaultCert] },
|
|
264
|
-
* 'api.example.com': { keys: [apiKey], certs: [apiCert] },
|
|
265
|
-
* 'www.example.com': { keys: [wwwKey], certs: [wwwCert], ca: [customCA] },
|
|
266
|
-
* },
|
|
267
|
-
* });
|
|
268
|
-
* ```
|
|
269
|
-
*
|
|
270
|
-
* Shared TLS options (such as `ciphers`, `groups`, `keylog`, and `verifyClient`)
|
|
271
|
-
* are specified at the top level of the session options and apply to all
|
|
272
|
-
* identities. Each SNI entry overrides only the per-identity certificate
|
|
273
|
-
* fields.
|
|
274
|
-
*
|
|
275
|
-
* The SNI map can be replaced at runtime using `endpoint.setSNIContexts()`,
|
|
276
|
-
* which atomically swaps the map for new sessions while existing sessions
|
|
277
|
-
* continue to use their original identity.
|
|
456
|
+
* Indication (SNI) support. This is required for server sessions and must
|
|
457
|
+
* contain at least one entry. The special key `'*'` specifies the optional
|
|
458
|
+
* default/fallback identity used when no other host name matches. If no
|
|
459
|
+
* wildcard entry is provided, connections with unrecognized server names
|
|
460
|
+
* will be rejected with a TLS `unrecognized_name` alert. Each entry may
|
|
461
|
+
* contain:
|
|
278
462
|
* @since v26.1.0
|
|
279
463
|
*/
|
|
280
464
|
sni?: Record<string, SNIEntry> | undefined;
|
|
@@ -283,6 +467,14 @@ declare module "node:quic" {
|
|
|
283
467
|
* @since v23.8.0
|
|
284
468
|
*/
|
|
285
469
|
tlsTrace?: boolean | undefined;
|
|
470
|
+
/**
|
|
471
|
+
* An opaque address validation token previously received from the server
|
|
472
|
+
* via the `session.onnewtoken` callback. Providing a valid token on
|
|
473
|
+
* reconnection allows the client to skip the server's address validation,
|
|
474
|
+
* reducing handshake latency.
|
|
475
|
+
* @since v26.2.0
|
|
476
|
+
*/
|
|
477
|
+
token?: NodeJS.ArrayBufferView | undefined;
|
|
286
478
|
/**
|
|
287
479
|
* The QUIC transport parameters to use for the session.
|
|
288
480
|
* @since v23.8.0
|
|
@@ -293,6 +485,27 @@ declare module "node:quic" {
|
|
|
293
485
|
* @since v23.8.0
|
|
294
486
|
*/
|
|
295
487
|
unacknowledgedPacketThreshold?: bigint | number | undefined;
|
|
488
|
+
/**
|
|
489
|
+
* If `true`, the peer certificate is verified against the list of supplied CAs.
|
|
490
|
+
* An error is emitted if verification fails; the error can be inspected via
|
|
491
|
+
* the `validationErrorReason` and `validationErrorCode` fields in the
|
|
492
|
+
* handshake callback. If `false`, peer certificate verification errors are
|
|
493
|
+
* ignored.
|
|
494
|
+
*/
|
|
495
|
+
rejectUnauthorized?: boolean | undefined;
|
|
496
|
+
/**
|
|
497
|
+
* When `true` (the default), `connect()` will attempt to reuse an existing
|
|
498
|
+
* endpoint rather than creating a new one for each session. This provides
|
|
499
|
+
* connection pooling behavior — multiple sessions can share a single UDP
|
|
500
|
+
* socket. The reuse logic will not return an endpoint that is listening on
|
|
501
|
+
* the same address as the connect target (to prevent CID routing conflicts).
|
|
502
|
+
*
|
|
503
|
+
* Set to `false` to force creation of a new endpoint for the session. This
|
|
504
|
+
* is useful when endpoint isolation is required (e.g., testing stateless
|
|
505
|
+
* reset behavior where source port identity matters).
|
|
506
|
+
* @since v26.2.0
|
|
507
|
+
*/
|
|
508
|
+
reuseEndpoint?: boolean | undefined;
|
|
296
509
|
/**
|
|
297
510
|
* True to require verification of TLS client certificate.
|
|
298
511
|
* @since v23.8.0
|
|
@@ -311,6 +524,25 @@ declare module "node:quic" {
|
|
|
311
524
|
* @since v23.8.0
|
|
312
525
|
*/
|
|
313
526
|
version?: number | undefined;
|
|
527
|
+
// Undocumented
|
|
528
|
+
onerror?: QuicSession["onerror"] | undefined;
|
|
529
|
+
onstream?: QuicSession["onstream"] | undefined;
|
|
530
|
+
ondatagram?: QuicSession["ondatagram"] | undefined;
|
|
531
|
+
ondatagramstatus?: QuicSession["ondatagramstatus"] | undefined;
|
|
532
|
+
onpathvalidation?: QuicSession["onpathvalidation"] | undefined;
|
|
533
|
+
onsessionticket?: QuicSession["onsessionticket"] | undefined;
|
|
534
|
+
onversionnegotiation?: QuicSession["onversionnegotiation"] | undefined;
|
|
535
|
+
onhandshake?: QuicSession["onhandshake"] | undefined;
|
|
536
|
+
onnewtoken?: QuicSession["onnewtoken"] | undefined;
|
|
537
|
+
onearlyrejected?: QuicSession["onearlyrejected"] | undefined;
|
|
538
|
+
onorigin?: QuicSession["onorigin"] | undefined;
|
|
539
|
+
ongoaway?: QuicSession["ongoaway"] | undefined;
|
|
540
|
+
onkeylog?: QuicSession["onkeylog"] | undefined;
|
|
541
|
+
onqlog?: QuicSession["onqlog"] | undefined;
|
|
542
|
+
onheaders?: QuicStream["onheaders"] | undefined;
|
|
543
|
+
ontrailers?: QuicStream["ontrailers"] | undefined;
|
|
544
|
+
oninfo?: QuicStream["oninfo"] | undefined;
|
|
545
|
+
onwanttrailers?: QuicStream["onwanttrailers"] | undefined;
|
|
314
546
|
}
|
|
315
547
|
/**
|
|
316
548
|
* Initiate a new client-side session.
|
|
@@ -386,39 +618,150 @@ declare module "node:quic" {
|
|
|
386
618
|
* @since v23.8.0
|
|
387
619
|
*/
|
|
388
620
|
address?: SocketAddress | string | undefined;
|
|
621
|
+
/**
|
|
622
|
+
* An optional `net.BlockList` instance for filtering incoming packets by
|
|
623
|
+
* source address. When configured, every received UDP packet is checked against
|
|
624
|
+
* the block list before any QUIC processing occurs, minimizing resource
|
|
625
|
+
* expenditure on blocked sources. The block list is evaluated live — rules
|
|
626
|
+
* added to the `BlockList` object after the endpoint is created take effect
|
|
627
|
+
* immediately.
|
|
628
|
+
*
|
|
629
|
+
* See `endpointOptions.blockListPolicy` for how matches are interpreted.
|
|
630
|
+
* @since v26.3.0
|
|
631
|
+
*/
|
|
632
|
+
blockList?: BlockList | undefined;
|
|
633
|
+
/**
|
|
634
|
+
* Controls how the `endpointOptions.blockList` is interpreted:
|
|
635
|
+
*
|
|
636
|
+
* * `'deny'` — Packets from addresses matching the block list are dropped.
|
|
637
|
+
* All other addresses are accepted. This is the typical blocklist mode.
|
|
638
|
+
* * `'allow'` — Only packets from addresses matching the block list are
|
|
639
|
+
* accepted. All other addresses are dropped. This is an allowlist mode
|
|
640
|
+
* for restricting access to known clients.
|
|
641
|
+
*
|
|
642
|
+
* If no block list is configured, this option has no effect.
|
|
643
|
+
* @since v26.3.0
|
|
644
|
+
*/
|
|
645
|
+
blockListPolicy?: "deny" | "allow" | undefined;
|
|
389
646
|
/**
|
|
390
647
|
* The endpoint maintains an internal cache of validated socket addresses as a
|
|
391
648
|
* performance optimization. This option sets the maximum number of addresses
|
|
392
|
-
* that are
|
|
649
|
+
* that are cached. This is an advanced option that users typically won't have
|
|
393
650
|
* need to specify.
|
|
394
651
|
* @since v23.8.0
|
|
395
652
|
*/
|
|
396
653
|
addressLRUSize?: bigint | number | undefined;
|
|
654
|
+
/**
|
|
655
|
+
* When `true`, the endpoint will not send stateless reset packets in response
|
|
656
|
+
* to packets from unknown connections. Stateless resets allow a peer to detect
|
|
657
|
+
* that a connection has been lost even when the server has no state for it.
|
|
658
|
+
* Disabling them may be useful in testing or when stateless resets are handled
|
|
659
|
+
* at a different layer.
|
|
660
|
+
* @since v26.2.0
|
|
661
|
+
*/
|
|
662
|
+
disableStatelessReset?: boolean | undefined;
|
|
663
|
+
/**
|
|
664
|
+
* The number of seconds an endpoint will remain alive after all sessions have
|
|
665
|
+
* closed and it is no longer listening. A value of `0` (default) means the
|
|
666
|
+
* endpoint is only destroyed when explicitly closed via `endpoint.close()` or
|
|
667
|
+
* `endpoint.destroy()`. A positive value starts an idle timer when the endpoint
|
|
668
|
+
* becomes idle; if no new sessions are created before the timer fires, the
|
|
669
|
+
* endpoint is automatically destroyed. This is useful for connection pooling
|
|
670
|
+
* where endpoints should linger briefly for reuse by future `connect()` calls.
|
|
671
|
+
* @since v26.2.0
|
|
672
|
+
*/
|
|
673
|
+
idleTimeout?: number | undefined;
|
|
397
674
|
/**
|
|
398
675
|
* When `true`, indicates that the endpoint should bind only to IPv6 addresses.
|
|
399
676
|
* @since v23.8.0
|
|
400
677
|
*/
|
|
401
678
|
ipv6Only?: boolean | undefined;
|
|
402
679
|
/**
|
|
403
|
-
* Specifies the maximum number of concurrent sessions allowed per remote
|
|
680
|
+
* Specifies the maximum number of concurrent sessions allowed per remote IP
|
|
681
|
+
* address (ignoring port). When the limit is reached, new connections from the
|
|
682
|
+
* same IP are refused with `CONNECTION_REFUSED`. A value of `0` disables the
|
|
683
|
+
* limit. The maximum value is `65535`.
|
|
684
|
+
*
|
|
685
|
+
* This limit can also be changed dynamically after construction via
|
|
686
|
+
* `endpoint.maxConnectionsPerHost`.
|
|
404
687
|
* @since v23.8.0
|
|
405
688
|
*/
|
|
406
|
-
maxConnectionsPerHost?:
|
|
689
|
+
maxConnectionsPerHost?: number | undefined;
|
|
407
690
|
/**
|
|
408
|
-
* Specifies the maximum total number of concurrent sessions
|
|
691
|
+
* Specifies the maximum total number of concurrent sessions across all remote
|
|
692
|
+
* addresses. When the limit is reached, new connections are refused with
|
|
693
|
+
* `CONNECTION_REFUSED`. A value of `0` disables the limit. The maximum value is
|
|
694
|
+
* `65535`.
|
|
695
|
+
*
|
|
696
|
+
* This limit can also be changed dynamically after construction via
|
|
697
|
+
* `endpoint.maxConnectionsTotal`.
|
|
409
698
|
* @since v23.8.0
|
|
410
699
|
*/
|
|
411
|
-
maxConnectionsTotal?:
|
|
700
|
+
maxConnectionsTotal?: number | undefined;
|
|
412
701
|
/**
|
|
413
|
-
*
|
|
414
|
-
*
|
|
702
|
+
* The maximum number of QUIC retry packets the endpoint will send per second.
|
|
703
|
+
* This is a global rate limit (not per-host) that caps the total server-wide
|
|
704
|
+
* retry response rate, preventing spoofed-source floods from consuming unbounded
|
|
705
|
+
* resources.
|
|
706
|
+
* @since v26.3.0
|
|
415
707
|
*/
|
|
416
|
-
|
|
708
|
+
retryRate?: number | undefined;
|
|
417
709
|
/**
|
|
418
|
-
*
|
|
419
|
-
* @since
|
|
710
|
+
* The maximum burst of retry packets allowed before rate limiting takes effect.
|
|
711
|
+
* @since v26.3.0
|
|
420
712
|
*/
|
|
421
|
-
|
|
713
|
+
retryBurst?: number | undefined;
|
|
714
|
+
/**
|
|
715
|
+
* The maximum number of stateless reset packets the endpoint will send per second.
|
|
716
|
+
* @since v26.3.0
|
|
717
|
+
*/
|
|
718
|
+
statelessResetRate?: number | undefined;
|
|
719
|
+
/**
|
|
720
|
+
* The maximum burst of stateless reset packets allowed before rate limiting
|
|
721
|
+
* takes effect.
|
|
722
|
+
* @since v26.3.0
|
|
723
|
+
*/
|
|
724
|
+
statelessResetBurst?: number | undefined;
|
|
725
|
+
/**
|
|
726
|
+
* The maximum number of version negotiation packets the endpoint will send per
|
|
727
|
+
* second.
|
|
728
|
+
* @since v26.3.0
|
|
729
|
+
*/
|
|
730
|
+
versionNegotiationRate?: number | undefined;
|
|
731
|
+
/**
|
|
732
|
+
* The maximum number of immediate connection close packets the endpoint will
|
|
733
|
+
* send per second.
|
|
734
|
+
* @since v26.3.0
|
|
735
|
+
*/
|
|
736
|
+
versionNegotiationBurst?: number | undefined;
|
|
737
|
+
/**
|
|
738
|
+
* The maximum number of immediate connection close packets the endpoint will
|
|
739
|
+
* send per second.
|
|
740
|
+
* @since v26.3.0
|
|
741
|
+
*/
|
|
742
|
+
immediateCloseRate?: number | undefined;
|
|
743
|
+
/**
|
|
744
|
+
* The maximum burst of immediate connection close packets allowed before rate
|
|
745
|
+
* limiting takes effect.
|
|
746
|
+
* @since v26.3.0
|
|
747
|
+
*/
|
|
748
|
+
immediateCloseBurst?: number | undefined;
|
|
749
|
+
/**
|
|
750
|
+
* The maximum number of new sessions that a single remote address can create per
|
|
751
|
+
* second. This is a per-host rate limit tracked in the address validation LRU
|
|
752
|
+
* cache. It prevents a validated remote address from churning through sessions
|
|
753
|
+
* (rapidly opening and abandoning connections) faster than the server can handle.
|
|
754
|
+
* For benchmarking where traffic comes from a single source, set this to a high
|
|
755
|
+
* value.
|
|
756
|
+
* @since v26.3.0
|
|
757
|
+
*/
|
|
758
|
+
sessionCreationRate?: number | undefined;
|
|
759
|
+
/**
|
|
760
|
+
* The maximum burst of new session creations allowed from a single remote address
|
|
761
|
+
* before rate limiting takes effect.
|
|
762
|
+
* @since v26.3.0
|
|
763
|
+
*/
|
|
764
|
+
sessionCreationBurst?: number | undefined;
|
|
422
765
|
/**
|
|
423
766
|
* Specifies the length of time a QUIC retry token is considered valid.
|
|
424
767
|
* @since v23.8.0
|
|
@@ -525,9 +868,25 @@ declare module "node:quic" {
|
|
|
525
868
|
readonly destroyed: boolean;
|
|
526
869
|
/**
|
|
527
870
|
* True if the endpoint is actively listening for incoming connections. Read only.
|
|
528
|
-
* @since v26.
|
|
871
|
+
* @since v26.2.0
|
|
529
872
|
*/
|
|
530
873
|
readonly listening: boolean;
|
|
874
|
+
/**
|
|
875
|
+
* The maximum number of concurrent connections allowed per remote IP address.
|
|
876
|
+
* `0` means unlimited (default). Can be set at construction time via the
|
|
877
|
+
* `maxConnectionsPerHost` option and changed dynamically at any time.
|
|
878
|
+
* The valid range is `0` to `65535`.
|
|
879
|
+
* @since v26.2.0
|
|
880
|
+
*/
|
|
881
|
+
maxConnectionsPerHost: number;
|
|
882
|
+
/**
|
|
883
|
+
* The maximum total number of concurrent connections across all remote
|
|
884
|
+
* addresses. `0` means unlimited (default). Can be set at construction time via
|
|
885
|
+
* the `maxConnectionsTotal` option and changed dynamically at any time.
|
|
886
|
+
* The valid range is `0` to `65535`.
|
|
887
|
+
* @since v26.2.0
|
|
888
|
+
*/
|
|
889
|
+
maxConnectionsTotal: number;
|
|
531
890
|
/**
|
|
532
891
|
* Replaces or updates the SNI TLS contexts for this endpoint. This allows
|
|
533
892
|
* changing the TLS identity (key/certificate) used for specific host names
|
|
@@ -550,7 +909,7 @@ declare module "node:quic" {
|
|
|
550
909
|
*/
|
|
551
910
|
setSNIContexts(entries: Record<string, SNIEntry>, options?: SetSNIContextsOptions): void;
|
|
552
911
|
/**
|
|
553
|
-
* The statistics collected for an active
|
|
912
|
+
* The statistics collected for an active endpoint. Read only.
|
|
554
913
|
* @since v23.8.0
|
|
555
914
|
*/
|
|
556
915
|
readonly stats: QuicEndpoint.Stats;
|
|
@@ -615,30 +974,187 @@ declare module "node:quic" {
|
|
|
615
974
|
*/
|
|
616
975
|
readonly serverBusyCount: bigint;
|
|
617
976
|
/**
|
|
618
|
-
* The total number of
|
|
977
|
+
* The total number of retry packets sent by this endpoint. Read only.
|
|
619
978
|
* @since v23.8.0
|
|
620
979
|
*/
|
|
621
980
|
readonly retryCount: bigint;
|
|
622
981
|
/**
|
|
623
|
-
* The total number
|
|
982
|
+
* The total number of retry packets dropped by the global rate
|
|
983
|
+
* limiter. Read only. A non-zero value indicates the endpoint is under retry
|
|
984
|
+
* flood pressure.
|
|
985
|
+
* @since v26.3.0
|
|
986
|
+
*/
|
|
987
|
+
readonly retryRateLimited: bigint;
|
|
988
|
+
/**
|
|
989
|
+
* The total number of version negotiation packets sent by this
|
|
990
|
+
* endpoint. Read only.
|
|
624
991
|
* @since v23.8.0
|
|
625
992
|
*/
|
|
626
993
|
readonly versionNegotiationCount: bigint;
|
|
627
994
|
/**
|
|
628
|
-
* The total number of
|
|
995
|
+
* The total number of version negotiation packets dropped by
|
|
996
|
+
* the global rate limiter. Read only.
|
|
997
|
+
* @since v26.3.0
|
|
998
|
+
*/
|
|
999
|
+
readonly versionNegotiationRateLimited: bigint;
|
|
1000
|
+
/**
|
|
1001
|
+
* The total number of stateless reset packets sent by this
|
|
1002
|
+
* endpoint. Read only.
|
|
629
1003
|
* @since v23.8.0
|
|
630
1004
|
*/
|
|
631
1005
|
readonly statelessResetCount: bigint;
|
|
632
1006
|
/**
|
|
633
|
-
* The total number of
|
|
1007
|
+
* The total number of stateless reset packets dropped by the
|
|
1008
|
+
* global rate limiter. Read only.
|
|
1009
|
+
* @since v26.3.0
|
|
1010
|
+
*/
|
|
1011
|
+
readonly statelessResetRateLimited: bigint;
|
|
1012
|
+
/**
|
|
1013
|
+
* The total number of immediate connection close packets sent
|
|
1014
|
+
* by this endpoint. Read only.
|
|
634
1015
|
* @since v23.8.0
|
|
635
1016
|
*/
|
|
636
1017
|
readonly immediateCloseCount: bigint;
|
|
1018
|
+
/**
|
|
1019
|
+
* The total number of immediate connection close packets
|
|
1020
|
+
* dropped by the global rate limiter. Read only.
|
|
1021
|
+
* @since v26.3.0
|
|
1022
|
+
*/
|
|
1023
|
+
readonly immediateCloseRateLimited: bigint;
|
|
1024
|
+
/**
|
|
1025
|
+
* The total number of session creation attempts dropped by the
|
|
1026
|
+
* per-host rate limiter. Read only. A non-zero value indicates one or more
|
|
1027
|
+
* remote addresses are creating sessions faster than the configured rate allows.
|
|
1028
|
+
* @since v26.3.0
|
|
1029
|
+
*/
|
|
1030
|
+
readonly sessionCreationRateLimited: bigint;
|
|
1031
|
+
/**
|
|
1032
|
+
* The total number of incoming packets dropped by the
|
|
1033
|
+
* block list filter. Read only.
|
|
1034
|
+
* @since v26.3.0
|
|
1035
|
+
*/
|
|
1036
|
+
readonly packetsBlocked: bigint;
|
|
637
1037
|
}
|
|
638
1038
|
}
|
|
639
1039
|
interface CreateStreamOptions {
|
|
640
|
-
|
|
641
|
-
|
|
1040
|
+
/**
|
|
1041
|
+
* The outbound body source. See `stream.setBody()` for details on
|
|
1042
|
+
* supported types. When omitted, the stream starts half-closed (writable
|
|
1043
|
+
* side open, no body queued).
|
|
1044
|
+
*/
|
|
1045
|
+
body?: StreamBody | undefined;
|
|
1046
|
+
/**
|
|
1047
|
+
* Initial request or response headers to send. Only
|
|
1048
|
+
* used when the session supports headers (e.g. HTTP/3). If `body` is not
|
|
1049
|
+
* specified and `headers` is provided, the stream is treated as
|
|
1050
|
+
* headers-only (terminal).
|
|
1051
|
+
*/
|
|
1052
|
+
headers?: NodeJS.Dict<string | readonly string[]> | readonly string[] | undefined;
|
|
1053
|
+
/**
|
|
1054
|
+
* The priority level of the stream. One of `'high'`,
|
|
1055
|
+
* `'default'`, or `'low'`. **Default:** `'default'`.
|
|
1056
|
+
*/
|
|
1057
|
+
priority?: "high" | "default" | "low" | undefined;
|
|
1058
|
+
/**
|
|
1059
|
+
* When `true`, data from this stream may be
|
|
1060
|
+
* interleaved with data from other streams of the same priority level.
|
|
1061
|
+
* When `false`, the stream should be completed before same-priority peers.
|
|
1062
|
+
* **Default:** `false`.
|
|
1063
|
+
*/
|
|
1064
|
+
incremental?: boolean | undefined;
|
|
1065
|
+
/**
|
|
1066
|
+
* The maximum number of bytes that the writer
|
|
1067
|
+
* will buffer before `writeSync()` returns `false`. When the buffered
|
|
1068
|
+
* data exceeds this limit, the caller should wait for drain before
|
|
1069
|
+
* writing more. **Default:** `65536` (64 KB).
|
|
1070
|
+
*/
|
|
1071
|
+
highWaterMark?: number | undefined;
|
|
1072
|
+
/**
|
|
1073
|
+
* Callback for received initial response headers.
|
|
1074
|
+
* Called with `(headers)`.
|
|
1075
|
+
*/
|
|
1076
|
+
onheaders?: QuicStream["onheaders"] | undefined;
|
|
1077
|
+
/**
|
|
1078
|
+
* Callback for received trailing headers.
|
|
1079
|
+
* Called with `(trailers)`.
|
|
1080
|
+
*/
|
|
1081
|
+
ontrailers?: QuicStream["ontrailers"] | undefined;
|
|
1082
|
+
/**
|
|
1083
|
+
* Callback for received informational (1xx) headers.
|
|
1084
|
+
* Called with `(headers)`.
|
|
1085
|
+
*/
|
|
1086
|
+
oninfo?: QuicStream["oninfo"] | undefined;
|
|
1087
|
+
/**
|
|
1088
|
+
* Callback when trailers should be sent.
|
|
1089
|
+
*/
|
|
1090
|
+
onwanttrailers?: QuicStream["onwanttrailers"] | undefined;
|
|
1091
|
+
}
|
|
1092
|
+
interface SessionDestroyOptions {
|
|
1093
|
+
/**
|
|
1094
|
+
* The error code to include in the `CONNECTION_CLOSE`
|
|
1095
|
+
* frame sent to the peer. **Default:** `0` (no error).
|
|
1096
|
+
*/
|
|
1097
|
+
code?: bigint | number | undefined;
|
|
1098
|
+
/**
|
|
1099
|
+
* Either `'transport'` or `'application'`. Determines the
|
|
1100
|
+
* error code namespace used in the `CONNECTION_CLOSE` frame. When `'transport'`
|
|
1101
|
+
* (the default), the frame type is `0x1c` and the code is interpreted as a QUIC
|
|
1102
|
+
* transport error. When `'application'`, the frame type is `0x1d` and the code
|
|
1103
|
+
* is application-specific. **Default:** `'transport'`.
|
|
1104
|
+
*/
|
|
1105
|
+
type?: "transport" | "application" | undefined;
|
|
1106
|
+
/**
|
|
1107
|
+
* An optional human-readable reason string included in
|
|
1108
|
+
* the `CONNECTION_CLOSE` frame. Per RFC 9000, this is for diagnostic purposes
|
|
1109
|
+
* only and should not be used for machine-readable error descriptions.
|
|
1110
|
+
*/
|
|
1111
|
+
reason?: string | undefined;
|
|
1112
|
+
}
|
|
1113
|
+
interface SessionHandshakeInfo {
|
|
1114
|
+
/**
|
|
1115
|
+
* The local socket address.
|
|
1116
|
+
*/
|
|
1117
|
+
local: SocketAddress;
|
|
1118
|
+
/**
|
|
1119
|
+
* The remote socket address.
|
|
1120
|
+
*/
|
|
1121
|
+
remote: SocketAddress;
|
|
1122
|
+
/**
|
|
1123
|
+
* The SNI server name negotiated during the handshake.
|
|
1124
|
+
*/
|
|
1125
|
+
servername: string;
|
|
1126
|
+
/**
|
|
1127
|
+
* The ALPN protocol negotiated during the handshake.
|
|
1128
|
+
*/
|
|
1129
|
+
protocol: string;
|
|
1130
|
+
/**
|
|
1131
|
+
* The name of the negotiated TLS cipher suite.
|
|
1132
|
+
*/
|
|
1133
|
+
cipher: string;
|
|
1134
|
+
/**
|
|
1135
|
+
* The TLS protocol version of the cipher suite
|
|
1136
|
+
* (e.g., `'TLSv1.3'`).
|
|
1137
|
+
*/
|
|
1138
|
+
cipherVersion: string;
|
|
1139
|
+
/**
|
|
1140
|
+
* If certificate validation failed, the
|
|
1141
|
+
* reason string. Empty string if validation succeeded.
|
|
1142
|
+
*/
|
|
1143
|
+
validationErrorReason: string;
|
|
1144
|
+
/**
|
|
1145
|
+
* If certificate validation failed, the
|
|
1146
|
+
* error code. `0` if validation succeeded.
|
|
1147
|
+
*/
|
|
1148
|
+
validationErrorCode: number;
|
|
1149
|
+
/**
|
|
1150
|
+
* Whether 0-RTT early data was attempted.
|
|
1151
|
+
*/
|
|
1152
|
+
earlyDataAttempted: boolean;
|
|
1153
|
+
/**
|
|
1154
|
+
* Whether 0-RTT early data was accepted by
|
|
1155
|
+
* the server.
|
|
1156
|
+
*/
|
|
1157
|
+
earlyDataAccepted: boolean;
|
|
642
1158
|
}
|
|
643
1159
|
interface SessionPath {
|
|
644
1160
|
local: SocketAddress;
|
|
@@ -650,40 +1166,96 @@ declare module "node:quic" {
|
|
|
650
1166
|
*/
|
|
651
1167
|
class QuicSession implements AsyncDisposable {
|
|
652
1168
|
private constructor();
|
|
1169
|
+
/**
|
|
1170
|
+
* The current application-level options for this session. These include settings
|
|
1171
|
+
* that are specific to the negotiated application protocol (e.g. HTTP/3) and may
|
|
1172
|
+
* be negotiated separately from the transport parameters. Read only.
|
|
1173
|
+
* @since v26.3.0
|
|
1174
|
+
*/
|
|
1175
|
+
readonly applicationOptions: { [K in keyof ApplicationOptions]-?: ApplicationOptions[K] & (bigint | boolean) };
|
|
653
1176
|
/**
|
|
654
1177
|
* Initiate a graceful close of the session. Existing streams will be allowed
|
|
655
1178
|
* to complete but no new streams will be opened. Once all streams have closed,
|
|
656
1179
|
* the session will be destroyed. The returned promise will be fulfilled once
|
|
657
|
-
* the session has been destroyed.
|
|
1180
|
+
* the session has been destroyed. If a non-zero `code` is specified, the
|
|
1181
|
+
* promise will reject with an `ERR_QUIC_TRANSPORT_ERROR` or
|
|
1182
|
+
* `ERR_QUIC_APPLICATION_ERROR` depending on the `type`.
|
|
658
1183
|
* @since v23.8.0
|
|
659
1184
|
*/
|
|
660
|
-
close(): Promise<void>;
|
|
1185
|
+
close(options?: SessionDestroyOptions): Promise<void>;
|
|
1186
|
+
/**
|
|
1187
|
+
* A promise that is fulfilled once the TLS handshake completes successfully.
|
|
1188
|
+
* The resolved value contains information about the established session
|
|
1189
|
+
* including the negotiated protocol, cipher suite, certificate validation
|
|
1190
|
+
* status, and 0-RTT early data status.
|
|
1191
|
+
*
|
|
1192
|
+
* If the handshake fails or the session is destroyed before the handshake
|
|
1193
|
+
* completes, the promise will be rejected.
|
|
1194
|
+
* @since v26.2.0
|
|
1195
|
+
*/
|
|
1196
|
+
readonly opened: Promise<SessionHandshakeInfo>;
|
|
661
1197
|
/**
|
|
662
1198
|
* A promise that is fulfilled once the session is destroyed.
|
|
663
1199
|
* @since v23.8.0
|
|
664
1200
|
*/
|
|
665
1201
|
readonly closed: Promise<void>;
|
|
666
1202
|
/**
|
|
667
|
-
*
|
|
668
|
-
*
|
|
1203
|
+
* True if `session.close()` has been called and the session has not yet
|
|
1204
|
+
* been destroyed. Read only.
|
|
1205
|
+
* @since v26.2.0
|
|
1206
|
+
*/
|
|
1207
|
+
readonly closing: boolean;
|
|
1208
|
+
/**
|
|
1209
|
+
* Immediately destroy the session. All streams will be destroyed and the
|
|
1210
|
+
* session will be closed. If `error` is provided and [`session.onerror`][] is
|
|
1211
|
+
* set, the `onerror` callback is invoked before destruction. The
|
|
1212
|
+
* `session.closed` promise will reject with the error. If `options` is
|
|
1213
|
+
* provided, the `CONNECTION_CLOSE` frame sent to the peer will include the
|
|
1214
|
+
* specified error code, type, and reason.
|
|
669
1215
|
* @since v23.8.0
|
|
670
1216
|
*/
|
|
671
|
-
destroy(error?: any): void;
|
|
1217
|
+
destroy(error?: any, options?: SessionDestroyOptions): void;
|
|
672
1218
|
/**
|
|
673
1219
|
* True if `session.destroy()` has been called. Read only.
|
|
674
1220
|
* @since v23.8.0
|
|
675
1221
|
*/
|
|
676
1222
|
readonly destroyed: boolean;
|
|
677
1223
|
/**
|
|
678
|
-
* The endpoint that created this session.
|
|
1224
|
+
* The endpoint that created this session. Returns `null` if the session
|
|
1225
|
+
* has been destroyed. Read only.
|
|
679
1226
|
* @since v23.8.0
|
|
680
1227
|
*/
|
|
681
|
-
readonly endpoint: QuicEndpoint;
|
|
1228
|
+
readonly endpoint: QuicEndpoint | null;
|
|
1229
|
+
/**
|
|
1230
|
+
* An optional callback invoked when the session is destroyed with an error.
|
|
1231
|
+
* This includes errors caused by user callbacks that throw or reject (see
|
|
1232
|
+
* [Callback error handling](https://nodejs.org/docs/latest-v26.x/api/quic.html#callback-error-handling)). The callback receives a single argument: the
|
|
1233
|
+
* error that triggered the destruction. If the `onerror` callback itself throws
|
|
1234
|
+
* or returns a promise that rejects, the error is surfaced as an uncaught
|
|
1235
|
+
* exception. Read/write.
|
|
1236
|
+
*
|
|
1237
|
+
* Can also be set via the `onerror` option in `quic.connect()` or
|
|
1238
|
+
* `quic.listen()`.
|
|
1239
|
+
* @since v26.2.0
|
|
1240
|
+
*/
|
|
1241
|
+
onerror: ((this: QuicSession, error: any) => void) | undefined;
|
|
682
1242
|
/**
|
|
683
1243
|
* The callback to invoke when a new stream is initiated by a remote peer. Read/write.
|
|
684
1244
|
* @since v23.8.0
|
|
685
1245
|
*/
|
|
686
1246
|
onstream: OnStreamCallback | undefined;
|
|
1247
|
+
/**
|
|
1248
|
+
* The callback to invoke when the server rejects 0-RTT early data. When
|
|
1249
|
+
* this fires, all streams that were opened during the 0-RTT phase have
|
|
1250
|
+
* been destroyed. The application should re-open streams if needed.
|
|
1251
|
+
* Read/write.
|
|
1252
|
+
*
|
|
1253
|
+
* This callback only fires on the client side when the server rejects
|
|
1254
|
+
* the client's 0-RTT attempt. The connection falls back to 1-RTT and
|
|
1255
|
+
* continues normally.
|
|
1256
|
+
* @since v26.2.0
|
|
1257
|
+
*/
|
|
1258
|
+
onearlyrejected: ((this: QuicSession) => void) | undefined;
|
|
687
1259
|
/**
|
|
688
1260
|
* The callback to invoke when a new datagram is received from a remote peer. Read/write.
|
|
689
1261
|
* @since v23.8.0
|
|
@@ -714,15 +1286,81 @@ declare module "node:quic" {
|
|
|
714
1286
|
* @since v23.8.0
|
|
715
1287
|
*/
|
|
716
1288
|
onhandshake: OnHandshakeCallback | undefined;
|
|
1289
|
+
/**
|
|
1290
|
+
* The callback to invoke when a NEW\_TOKEN token is received from the server.
|
|
1291
|
+
* The token can be passed as the `token` option on a future connection to
|
|
1292
|
+
* the same server to skip address validation. Read/write.
|
|
1293
|
+
* @since v26.2.0
|
|
1294
|
+
*/
|
|
1295
|
+
onnewtoken: OnNewTokenCallback | undefined;
|
|
1296
|
+
/**
|
|
1297
|
+
* The callback to invoke when an ORIGIN frame (RFC 9412) is received from
|
|
1298
|
+
* the server, indicating which origins the server is authoritative for.
|
|
1299
|
+
* Read/write.
|
|
1300
|
+
* @since v26.2.0
|
|
1301
|
+
*/
|
|
1302
|
+
onorigin: OnOriginCallback | undefined;
|
|
1303
|
+
/**
|
|
1304
|
+
* The callback to invoke when the peer sends an HTTP/3 GOAWAY frame,
|
|
1305
|
+
* indicating it is initiating a graceful shutdown. The callback receives
|
|
1306
|
+
* `(lastStreamId)` where `lastStreamId` is a `{bigint}`:
|
|
1307
|
+
*
|
|
1308
|
+
* * When `lastStreamId` is `-1n`, the peer sent a shutdown notice (intent
|
|
1309
|
+
* to close) without specifying a stream boundary. All existing streams
|
|
1310
|
+
* may still be processed.
|
|
1311
|
+
* * When `lastStreamId` is `>= 0n`, it is the highest stream ID the peer
|
|
1312
|
+
* may have processed. Streams with IDs above this value were NOT
|
|
1313
|
+
* processed and can be safely retried on a new connection.
|
|
1314
|
+
*
|
|
1315
|
+
* After GOAWAY is received, `session.createBidirectionalStream()` will
|
|
1316
|
+
* throw `ERR_INVALID_STATE`. Existing streams continue until they
|
|
1317
|
+
* complete or the session closes.
|
|
1318
|
+
*
|
|
1319
|
+
* This callback is only relevant for HTTP/3 sessions. Read/write.
|
|
1320
|
+
* @since v26.2.0
|
|
1321
|
+
*/
|
|
1322
|
+
ongoaway: ((this: QuicSession, lastStreamId: bigint) => void) | undefined;
|
|
1323
|
+
/**
|
|
1324
|
+
* The callback to invoke when TLS key material is available. Requires
|
|
1325
|
+
* `sessionOptions.keylog` to be `true`. Each invocation receives a single
|
|
1326
|
+
* line of [NSS Key Log Format](https://udn.realityripple.com/docs/Mozilla/Projects/NSS/Key_Log_Format) text (including a trailing newline). This is
|
|
1327
|
+
* useful for decrypting packet captures with tools like Wireshark. Read/write.
|
|
1328
|
+
*
|
|
1329
|
+
* Can also be set via the `onkeylog` option in `quic.connect()` or
|
|
1330
|
+
* `quic.listen()`.
|
|
1331
|
+
* @since v26.2.0
|
|
1332
|
+
*/
|
|
1333
|
+
onkeylog: OnKeylogCallback | undefined;
|
|
1334
|
+
/**
|
|
1335
|
+
* The callback to invoke when qlog data is available. Requires
|
|
1336
|
+
* `sessionOptions.qlog` to be `true`. The callback receives a string
|
|
1337
|
+
* chunk of [JSON-SEQ](https://www.rfc-editor.org/rfc/rfc7464) formatted qlog data and a boolean `fin` flag. When
|
|
1338
|
+
* `fin` is `true`, the chunk is the final qlog output for this session and
|
|
1339
|
+
* the concatenated chunks form a complete qlog trace. Read/write.
|
|
1340
|
+
*
|
|
1341
|
+
* Qlog data arrives during the connection lifecycle. The first chunk contains
|
|
1342
|
+
* the qlog header with format metadata. Subsequent chunks contain trace
|
|
1343
|
+
* events. The final chunk (with `fin` set to `true`) is emitted during
|
|
1344
|
+
* session destruction and completes the JSON-SEQ output.
|
|
1345
|
+
*
|
|
1346
|
+
* Can also be set via the `onqlog` option in `quic.connect()` or
|
|
1347
|
+
* `quic.listen()`.
|
|
1348
|
+
* @since v26.2.0
|
|
1349
|
+
*/
|
|
1350
|
+
onqlog: OnQlogCallback | undefined;
|
|
717
1351
|
/**
|
|
718
1352
|
* Open a new bidirectional stream. If the `body` option is not specified,
|
|
719
|
-
* the outgoing stream will be half-closed.
|
|
1353
|
+
* the outgoing stream will be half-closed. The `priority` and `incremental`
|
|
1354
|
+
* options are only used when the session supports priority (e.g. HTTP/3).
|
|
1355
|
+
* The `headers`, `onheaders`, `ontrailers`, `oninfo`, and `onwanttrailers`
|
|
1356
|
+
* options are only used when the session supports headers (e.g. HTTP/3).
|
|
720
1357
|
* @since v23.8.0
|
|
721
1358
|
*/
|
|
722
1359
|
createBidirectionalStream(options?: CreateStreamOptions): Promise<QuicStream>;
|
|
723
1360
|
/**
|
|
724
1361
|
* Open a new unidirectional stream. If the `body` option is not specified,
|
|
725
|
-
* the outgoing stream will be closed.
|
|
1362
|
+
* the outgoing stream will be closed. The `priority` and `incremental`
|
|
1363
|
+
* options are only used when the session supports priority (e.g. HTTP/3).
|
|
726
1364
|
* @since v23.8.0
|
|
727
1365
|
*/
|
|
728
1366
|
createUnidirectionalStream(options?: CreateStreamOptions): Promise<QuicStream>;
|
|
@@ -732,12 +1370,92 @@ declare module "node:quic" {
|
|
|
732
1370
|
*/
|
|
733
1371
|
path: SessionPath | undefined;
|
|
734
1372
|
/**
|
|
735
|
-
* Sends an unreliable datagram to the remote peer, returning
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
1373
|
+
* Sends an unreliable datagram to the remote peer, returning a promise for
|
|
1374
|
+
* the datagram ID.
|
|
1375
|
+
*
|
|
1376
|
+
* If `datagram` is a string, it will be encoded using the specified `encoding`.
|
|
1377
|
+
*
|
|
1378
|
+
* If `datagram` is an `ArrayBufferView`, the bytes are copied into an
|
|
1379
|
+
* internal buffer; the caller's source buffer is unchanged and may be reused
|
|
1380
|
+
* or mutated immediately after the call returns. Callers that want to ensure
|
|
1381
|
+
* their source cannot be mutated after the call (for example, when handing
|
|
1382
|
+
* the buffer off to another async consumer) can call
|
|
1383
|
+
* `ArrayBuffer.prototype.transfer()` themselves before passing the buffer.
|
|
1384
|
+
*
|
|
1385
|
+
* If `datagram` is a `Promise`, it will be awaited before sending. If the
|
|
1386
|
+
* session closes while awaiting, `0n` is returned silently (datagrams are
|
|
1387
|
+
* inherently unreliable).
|
|
1388
|
+
*
|
|
1389
|
+
* If the datagram payload is zero-length (empty string after encoding, detached
|
|
1390
|
+
* buffer, or zero-length view), `0n` is returned and no datagram is sent.
|
|
1391
|
+
*
|
|
1392
|
+
* For HTTP/3 sessions, the peer must advertise `SETTINGS_H3_DATAGRAM=1`
|
|
1393
|
+
* (via `application: { enableDatagrams: true }`) for datagrams to be sent.
|
|
1394
|
+
* If the peer's setting is `0`, `sendDatagram()` returns `0n` (per RFC 9297
|
|
1395
|
+
* §3, an endpoint MUST NOT send HTTP Datagrams unless the peer indicated
|
|
1396
|
+
* support).
|
|
1397
|
+
*
|
|
1398
|
+
* Datagrams cannot be fragmented — each must fit within a single QUIC packet.
|
|
1399
|
+
* The maximum datagram size is determined by the peer's
|
|
1400
|
+
* `maxDatagramFrameSize` transport parameter (which the peer advertises during
|
|
1401
|
+
* the handshake). If the peer sets this to `0`, datagrams are not supported
|
|
1402
|
+
* and `0n` will be returned. If the datagram exceeds the peer's limit, it
|
|
1403
|
+
* will be silently dropped and `0n` returned. The local
|
|
1404
|
+
* `maxDatagramFrameSize` transport parameter (default: `1200` bytes) controls
|
|
1405
|
+
* what this endpoint advertises to the peer as its own maximum.
|
|
1406
|
+
* @since v23.8.0
|
|
1407
|
+
* @param encoding The encoding to use if `datagram` is a string.
|
|
1408
|
+
* **Default:** `'utf8'`.
|
|
1409
|
+
*/
|
|
1410
|
+
sendDatagram(
|
|
1411
|
+
datagram: string | NodeJS.ArrayBufferView | Promise<string | NodeJS.ArrayBufferView>,
|
|
1412
|
+
encoding?: BufferEncoding,
|
|
1413
|
+
): Promise<bigint>;
|
|
1414
|
+
/**
|
|
1415
|
+
* The local certificate as an object with properties such as `subject`,
|
|
1416
|
+
* `issuer`, `valid_from`, `valid_to`, `fingerprint`, etc. Returns `undefined`
|
|
1417
|
+
* if the session is destroyed or no certificate is available.
|
|
1418
|
+
* @since v26.2.0
|
|
1419
|
+
*/
|
|
1420
|
+
readonly certificate: PeerCertificate | undefined;
|
|
1421
|
+
/**
|
|
1422
|
+
* The peer's certificate as an object with properties such as `subject`,
|
|
1423
|
+
* `issuer`, `valid_from`, `valid_to`, `fingerprint`, etc. Returns `undefined`
|
|
1424
|
+
* if the session is destroyed or the peer did not present a certificate.
|
|
1425
|
+
* @since v26.2.0
|
|
1426
|
+
*/
|
|
1427
|
+
readonly peerCertificate: PeerCertificate | undefined;
|
|
1428
|
+
/**
|
|
1429
|
+
* The ephemeral key information for the session, with properties such as
|
|
1430
|
+
* `type`, `name`, and `size`. Only available on client sessions. Returns
|
|
1431
|
+
* `undefined` for server sessions or if the session is destroyed.
|
|
1432
|
+
* @since v26.2.0
|
|
1433
|
+
*/
|
|
1434
|
+
readonly ephemeralKeyInfo: EphemeralKeyInfo | undefined;
|
|
1435
|
+
/**
|
|
1436
|
+
* The maximum datagram payload size in bytes that the peer will accept.
|
|
1437
|
+
* This is derived from the peer's `maxDatagramFrameSize` transport
|
|
1438
|
+
* parameter minus the DATAGRAM frame overhead (type byte and variable-length
|
|
1439
|
+
* integer encoding). Returns `0` if the peer does not support datagrams or
|
|
1440
|
+
* if the handshake has not yet completed. Datagrams larger than this value
|
|
1441
|
+
* will not be sent.
|
|
1442
|
+
* @since v26.2.0
|
|
1443
|
+
*/
|
|
1444
|
+
readonly maxDatagramSize: number;
|
|
1445
|
+
/**
|
|
1446
|
+
* The maximum number of datagrams that can be queued for sending. Datagrams
|
|
1447
|
+
* are queued when `sendDatagram()` is called and sent opportunistically
|
|
1448
|
+
* alongside stream data by the packet serialization loop. When the queue
|
|
1449
|
+
* is full, the `sessionOptions.datagramDropPolicy` determines whether
|
|
1450
|
+
* the oldest or newest datagram is dropped. Dropped datagrams are reported
|
|
1451
|
+
* as lost via the `ondatagramstatus` callback.
|
|
1452
|
+
*
|
|
1453
|
+
* This property can be changed dynamically to adjust queue capacity
|
|
1454
|
+
* based on application activity or memory pressure. The valid range
|
|
1455
|
+
* is `0` to `65535`.
|
|
1456
|
+
* @since v26.2.0
|
|
739
1457
|
*/
|
|
740
|
-
|
|
1458
|
+
maxPendingDatagrams: number;
|
|
741
1459
|
/**
|
|
742
1460
|
* Return the current statistics for the session. Read only.
|
|
743
1461
|
* @since v23.8.0
|
|
@@ -804,7 +1522,7 @@ declare module "node:quic" {
|
|
|
804
1522
|
/**
|
|
805
1523
|
* @since v23.8.0
|
|
806
1524
|
*/
|
|
807
|
-
readonly
|
|
1525
|
+
readonly maxBytesInFlight: bigint;
|
|
808
1526
|
/**
|
|
809
1527
|
* @since v23.8.0
|
|
810
1528
|
*/
|
|
@@ -853,57 +1571,466 @@ declare module "node:quic" {
|
|
|
853
1571
|
* @since v23.8.0
|
|
854
1572
|
*/
|
|
855
1573
|
readonly datagramsLost: bigint;
|
|
1574
|
+
/**
|
|
1575
|
+
* The total number of peer-initiated streams destroyed by the
|
|
1576
|
+
* stream idle timeout. Read only.
|
|
1577
|
+
* @since v26.3.0
|
|
1578
|
+
*/
|
|
1579
|
+
readonly streamsIdleTimedOut: bigint;
|
|
856
1580
|
}
|
|
857
1581
|
}
|
|
1582
|
+
interface QuicErrorOptions {
|
|
1583
|
+
/**
|
|
1584
|
+
* The numeric QUIC error code. Numbers
|
|
1585
|
+
* are coerced to `BigInt`. Must be a non-negative 62-bit unsigned
|
|
1586
|
+
* varint (`0n <= errorCode <= 2n ** 62n - 1n`).
|
|
1587
|
+
*/
|
|
1588
|
+
errorCode?: bigint | number | undefined;
|
|
1589
|
+
/**
|
|
1590
|
+
* The Node.js-style error code string assigned to
|
|
1591
|
+
* `error.code`. Defaults to `'ERR_QUIC_STREAM_ABORTED'`.
|
|
1592
|
+
*/
|
|
1593
|
+
code?: string | undefined;
|
|
1594
|
+
/**
|
|
1595
|
+
* Either `'application'` (default) or `'transport'`.
|
|
1596
|
+
* Indicates whether the code is defined by the negotiated
|
|
1597
|
+
* application protocol (e.g. RFC 9114 for HTTP/3) or by the QUIC
|
|
1598
|
+
* transport layer (RFC 9000). Stream resets always carry application
|
|
1599
|
+
* codes, so the default is `'application'`.
|
|
1600
|
+
*/
|
|
1601
|
+
type?: "application" | "transport" | undefined;
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* A `QuicError` is an `Error` subclass that carries an explicit numeric
|
|
1605
|
+
* QUIC error code. Use it to abort a QUIC stream or session with a
|
|
1606
|
+
* specific application-protocol-defined error code rather than letting
|
|
1607
|
+
* the implementation pick a generic fallback.
|
|
1608
|
+
*
|
|
1609
|
+
* The class is exported from `node:quic`:
|
|
1610
|
+
*
|
|
1611
|
+
* ```js
|
|
1612
|
+
* import { QuicError } from 'node:quic';
|
|
1613
|
+
* ```
|
|
1614
|
+
*
|
|
1615
|
+
* When a `QuicError` is supplied to APIs that emit a wire frame
|
|
1616
|
+
* (`writer.fail()`, `stream.destroy()`), the QUIC stack uses
|
|
1617
|
+
* `error.errorCode` as the wire code for the resulting frame.
|
|
1618
|
+
* When any other value is supplied (for example a plain `Error`), the
|
|
1619
|
+
* implementation falls back to the negotiated application protocol's
|
|
1620
|
+
* "internal error" code (`H3_INTERNAL_ERROR` (`0x102`) for HTTP/3, or
|
|
1621
|
+
* the QUIC transport-layer `INTERNAL_ERROR` (`0x1`) for raw QUIC).
|
|
1622
|
+
*
|
|
1623
|
+
* The Node.js error code (`error.code`) defaults to
|
|
1624
|
+
* `'ERR_QUIC_STREAM_ABORTED'`. Callers who need a more specific code
|
|
1625
|
+
* string can override it via `options.code` — the numeric QUIC code
|
|
1626
|
+
* is unaffected.
|
|
1627
|
+
*
|
|
1628
|
+
* The Node.js error code is fixed at `'ERR_QUIC_STREAM_ABORTED'` so that
|
|
1629
|
+
* catch blocks can distinguish a `QuicError` from other Node.js errors
|
|
1630
|
+
* without checking the prototype chain. The numeric QUIC code lives on
|
|
1631
|
+
* the separate `error.errorCode` property to avoid colliding with
|
|
1632
|
+
* the Node.js convention that `error.code` is a string.
|
|
1633
|
+
* @since v26.2.0
|
|
1634
|
+
* @experimental
|
|
1635
|
+
*/
|
|
1636
|
+
class QuicError extends Error {
|
|
1637
|
+
/**
|
|
1638
|
+
* ```js
|
|
1639
|
+
* import { QuicError } from 'node:quic';
|
|
1640
|
+
*
|
|
1641
|
+
* const err = new QuicError('rejecting stream', { errorCode: 0x10cn });
|
|
1642
|
+
* console.log(err.code); // 'ERR_QUIC_STREAM_ABORTED'
|
|
1643
|
+
* console.log(err.errorCode); // 268n
|
|
1644
|
+
* console.log(err.type); // 'application'
|
|
1645
|
+
*
|
|
1646
|
+
* const custom = new QuicError('custom failure', {
|
|
1647
|
+
* errorCode: 0x10cn,
|
|
1648
|
+
* code: 'ERR_MY_QUIC_FAILURE',
|
|
1649
|
+
* });
|
|
1650
|
+
* console.log(custom.code); // 'ERR_MY_QUIC_FAILURE'
|
|
1651
|
+
* ```
|
|
1652
|
+
* @param message A human-readable description of the error.
|
|
1653
|
+
*/
|
|
1654
|
+
constructor(message: string, options?: QuicErrorOptions);
|
|
1655
|
+
/**
|
|
1656
|
+
* The numeric QUIC error code carried by this error.
|
|
1657
|
+
* @since v26.2.0
|
|
1658
|
+
*/
|
|
1659
|
+
readonly errorCode: bigint;
|
|
1660
|
+
/**
|
|
1661
|
+
* Either `'application'` or `'transport'`. Indicates the namespace of
|
|
1662
|
+
* `error.errorCode`.
|
|
1663
|
+
* @since v26.2.0
|
|
1664
|
+
*/
|
|
1665
|
+
readonly type: "application" | "transport";
|
|
1666
|
+
}
|
|
1667
|
+
type StreamBody =
|
|
1668
|
+
| null
|
|
1669
|
+
| string
|
|
1670
|
+
| ArrayBufferLike
|
|
1671
|
+
| NodeJS.ArrayBufferView
|
|
1672
|
+
| Blob
|
|
1673
|
+
| FileHandle
|
|
1674
|
+
| Iterable<string | Uint8Array>
|
|
1675
|
+
| AsyncIterable<string | Uint8Array>
|
|
1676
|
+
| Promise<StreamBody>;
|
|
1677
|
+
interface StreamPriority {
|
|
1678
|
+
/**
|
|
1679
|
+
* One of `'high'`, `'default'`, or `'low'`.
|
|
1680
|
+
*/
|
|
1681
|
+
level: "high" | "default" | "low";
|
|
1682
|
+
/**
|
|
1683
|
+
* Whether the stream data should be interleaved
|
|
1684
|
+
* with other streams of the same priority level.
|
|
1685
|
+
*/
|
|
1686
|
+
incremental: boolean;
|
|
1687
|
+
}
|
|
1688
|
+
interface StreamDestroyOptions {
|
|
1689
|
+
/**
|
|
1690
|
+
* The application error code to include in the
|
|
1691
|
+
* `RESET_STREAM` and `STOP_SENDING` frames sent to the peer. Numbers are
|
|
1692
|
+
* coerced to `BigInt`. When omitted, the wire code is derived from `error`
|
|
1693
|
+
* (see below).
|
|
1694
|
+
*/
|
|
1695
|
+
code?: bigint | number | undefined;
|
|
1696
|
+
/**
|
|
1697
|
+
* An optional human-readable reason string. Accepted for
|
|
1698
|
+
* symmetry with `session.close()` and `session.destroy()`, but
|
|
1699
|
+
* **not transmitted on the wire** — neither `RESET_STREAM` nor
|
|
1700
|
+
* `STOP_SENDING` carry a reason field. Provided for application logging
|
|
1701
|
+
* and for use by the `stream.onerror` callback.
|
|
1702
|
+
*/
|
|
1703
|
+
reason?: string | undefined;
|
|
1704
|
+
}
|
|
1705
|
+
interface StreamSendHeadersOptions {
|
|
1706
|
+
/**
|
|
1707
|
+
* If `true`, the stream is closed for sending
|
|
1708
|
+
* after the headers (no body will follow). **Default:** `false`.
|
|
1709
|
+
*/
|
|
1710
|
+
terminal?: boolean | undefined;
|
|
1711
|
+
}
|
|
858
1712
|
/**
|
|
859
1713
|
* @since v23.8.0
|
|
860
1714
|
*/
|
|
861
1715
|
class QuicStream {
|
|
862
1716
|
private constructor();
|
|
863
1717
|
/**
|
|
864
|
-
* A promise that is fulfilled when the stream is fully closed.
|
|
1718
|
+
* A promise that is fulfilled when the stream is fully closed. It resolves
|
|
1719
|
+
* when the stream closes cleanly (including idle timeout). It rejects with
|
|
1720
|
+
* an `ERR_QUIC_APPLICATION_ERROR` or `ERR_QUIC_TRANSPORT_ERROR` when the
|
|
1721
|
+
* stream is closed due to a QUIC error (e.g., stream reset by the peer,
|
|
1722
|
+
* CONNECTION\_CLOSE with a non-zero error code).
|
|
865
1723
|
* @since v23.8.0
|
|
866
1724
|
*/
|
|
867
1725
|
readonly closed: Promise<void>;
|
|
868
1726
|
/**
|
|
869
|
-
* Immediately and abruptly destroys the stream.
|
|
1727
|
+
* Immediately and abruptly destroys the stream. If `error` is provided and
|
|
1728
|
+
* `stream.onerror` is set, the `onerror` callback is invoked before
|
|
1729
|
+
* destruction. The `stream.closed` promise rejects with the error.
|
|
1730
|
+
*
|
|
1731
|
+
* When the stream is destroyed with an `error` (or with an explicit
|
|
1732
|
+
* `options.code`), the QUIC stack signals the abort to the peer:
|
|
1733
|
+
*
|
|
1734
|
+
* * If the writable side is still open, a `RESET_STREAM` frame is sent.
|
|
1735
|
+
* * If the readable side is still open (a bidirectional stream, or a
|
|
1736
|
+
* remote-initiated unidirectional stream), a `STOP_SENDING` frame is sent.
|
|
1737
|
+
*
|
|
1738
|
+
* Both frames carry the same wire code, resolved with the following
|
|
1739
|
+
* precedence:
|
|
1740
|
+
*
|
|
1741
|
+
* 1. `options.code`, when explicitly provided.
|
|
1742
|
+
* 2. [`error.errorCode`][], when `error` is a [`QuicError`][].
|
|
1743
|
+
* 3. The negotiated application protocol's "internal error" code
|
|
1744
|
+
* (`H3_INTERNAL_ERROR` (`0x102`) for HTTP/3, or the QUIC transport-layer
|
|
1745
|
+
* `INTERNAL_ERROR` (`0x1`) for raw QUIC).
|
|
1746
|
+
*
|
|
1747
|
+
* A clean destroy — no `error` and no `options.code` — does not emit
|
|
1748
|
+
* `RESET_STREAM` or `STOP_SENDING`; the stream's existing close machinery
|
|
1749
|
+
* handles teardown.
|
|
1750
|
+
*
|
|
1751
|
+
* See [Aborting a stream](https://nodejs.org/docs/latest-v26.x/api/quic.html#aborting-a-stream) for an overview of the available stream-abort
|
|
1752
|
+
* APIs.
|
|
870
1753
|
* @since v23.8.0
|
|
871
1754
|
*/
|
|
872
|
-
destroy(error?: any): void;
|
|
1755
|
+
destroy(error?: any, options?: StreamDestroyOptions): void;
|
|
873
1756
|
/**
|
|
874
1757
|
* True if `stream.destroy()` has been called.
|
|
875
1758
|
* @since v23.8.0
|
|
876
1759
|
*/
|
|
877
1760
|
readonly destroyed: boolean;
|
|
878
1761
|
/**
|
|
879
|
-
*
|
|
1762
|
+
* True if any data on this stream was received as 0-RTT (early data)
|
|
1763
|
+
* before the TLS handshake completed. Early data is less secure and
|
|
1764
|
+
* could potentially be replayed by an attacker. Applications should
|
|
1765
|
+
* treat early data with appropriate caution.
|
|
1766
|
+
*
|
|
1767
|
+
* This property is only meaningful on the server side. On the client
|
|
1768
|
+
* side, it is always `false`.
|
|
1769
|
+
* @since v26.2.0
|
|
1770
|
+
*/
|
|
1771
|
+
readonly early: boolean;
|
|
1772
|
+
/**
|
|
1773
|
+
* The directionality of the stream, or `null` if the stream has been destroyed
|
|
1774
|
+
* or is still pending. Read only.
|
|
880
1775
|
* @since v23.8.0
|
|
881
1776
|
*/
|
|
882
|
-
readonly direction: "bidi" | "uni";
|
|
1777
|
+
readonly direction: "bidi" | "uni" | null;
|
|
1778
|
+
/**
|
|
1779
|
+
* The maximum number of bytes that the writer will buffer before
|
|
1780
|
+
* `writeSync()` returns `false`. When the buffered data exceeds this limit,
|
|
1781
|
+
* the caller should wait for drain before writing more.
|
|
1782
|
+
*
|
|
1783
|
+
* The value can be changed dynamically at any time. This is particularly
|
|
1784
|
+
* useful for streams received via the `onstream` callback, where the
|
|
1785
|
+
* default (65536) may need to be adjusted based on application needs.
|
|
1786
|
+
* The valid range is `0` to `4294967295`.
|
|
1787
|
+
* @since v26.2.0
|
|
1788
|
+
*/
|
|
1789
|
+
highWaterMark: number;
|
|
883
1790
|
/**
|
|
884
|
-
* The stream ID
|
|
1791
|
+
* The stream ID, or `null` if the stream has been destroyed or is still
|
|
1792
|
+
* pending. Read only.
|
|
885
1793
|
* @since v23.8.0
|
|
886
1794
|
*/
|
|
887
|
-
readonly id: bigint;
|
|
1795
|
+
readonly id: bigint | null;
|
|
1796
|
+
/**
|
|
1797
|
+
* An optional callback invoked when the stream is destroyed with an error.
|
|
1798
|
+
* This includes errors caused by user callbacks that throw or reject (see
|
|
1799
|
+
* [Callback error handling](https://nodejs.org/docs/latest-26.x/api/quic.html#callback-error-handling)). The callback receives a single argument: the
|
|
1800
|
+
* error that triggered the destruction. If the `onerror` callback itself throws
|
|
1801
|
+
* or returns a promise that rejects, the error is surfaced as an uncaught
|
|
1802
|
+
* exception. Read/write.
|
|
1803
|
+
* @since v26.2.0
|
|
1804
|
+
*/
|
|
1805
|
+
onerror: ((this: QuicStream, error: any) => void) | undefined;
|
|
888
1806
|
/**
|
|
889
1807
|
* The callback to invoke when the stream is blocked. Read/write.
|
|
890
1808
|
* @since v23.8.0
|
|
891
1809
|
*/
|
|
892
1810
|
onblocked: OnBlockedCallback | undefined;
|
|
893
1811
|
/**
|
|
894
|
-
* The callback to invoke when the
|
|
1812
|
+
* The callback to invoke when the peer aborts a direction of the stream by
|
|
1813
|
+
* sending a `RESET_STREAM` frame (the peer abandons their writable side, so
|
|
1814
|
+
* no further data will arrive on our readable side) or a `STOP_SENDING`
|
|
1815
|
+
* frame (the peer asks us to stop writing on our writable side).
|
|
1816
|
+
*
|
|
1817
|
+
* The callback receives a Node.js error whose `errorCode` (`bigint`)
|
|
1818
|
+
* property carries the application error code from the wire frame.
|
|
1819
|
+
*
|
|
1820
|
+
* The stream is **not** automatically destroyed when this callback fires —
|
|
1821
|
+
* the application chooses how to react. Common patterns are: ignore (and
|
|
1822
|
+
* continue using the still-active direction on a bidirectional stream),
|
|
1823
|
+
* abort the other direction with `writer.fail()`, or tear down the
|
|
1824
|
+
* whole stream with `stream.destroy()`. Read/write.
|
|
895
1825
|
* @since v23.8.0
|
|
896
1826
|
*/
|
|
897
1827
|
onreset: OnStreamErrorCallback | undefined;
|
|
898
1828
|
/**
|
|
899
|
-
*
|
|
1829
|
+
* The buffered initial headers received on this stream, or `undefined` if the
|
|
1830
|
+
* application does not support headers or no headers have been received yet.
|
|
1831
|
+
* For server-side streams, this contains the request headers (e.g., `:method`,
|
|
1832
|
+
* `:path`, `:scheme`). For client-side streams, this contains the response
|
|
1833
|
+
* headers (e.g., `:status`).
|
|
1834
|
+
*
|
|
1835
|
+
* Header names are lowercase strings. Multi-value headers are represented as
|
|
1836
|
+
* arrays. The object has `__proto__: null`.
|
|
1837
|
+
* @since v26.2.0
|
|
1838
|
+
*/
|
|
1839
|
+
readonly headers: NodeJS.Dict<string | string[]> | undefined;
|
|
1840
|
+
/**
|
|
1841
|
+
* The callback to invoke when initial headers are received on the stream. The
|
|
1842
|
+
* callback receives `(headers)` where `headers` is an object (same format as
|
|
1843
|
+
* `stream.headers`). For HTTP/3, this delivers request pseudo-headers on the
|
|
1844
|
+
* server side and response headers on the client side. Throws
|
|
1845
|
+
* `ERR_INVALID_STATE` if set on a session that does not support headers.
|
|
1846
|
+
* Read/write.
|
|
1847
|
+
* @since v26.2.0
|
|
1848
|
+
*/
|
|
1849
|
+
onheaders: ((this: QuicStream, headers: NodeJS.Dict<string | string[]>) => void) | undefined;
|
|
1850
|
+
/**
|
|
1851
|
+
* The callback to invoke when trailing headers are received from the peer.
|
|
1852
|
+
* The callback receives `(trailers)` where `trailers` is an object in the
|
|
1853
|
+
* same format as `stream.headers`. Throws `ERR_INVALID_STATE` if set on a
|
|
1854
|
+
* session that does not support headers. Read/write.
|
|
1855
|
+
* @since v26.2.0
|
|
1856
|
+
*/
|
|
1857
|
+
ontrailers: ((this: QuicStream, trailers: NodeJS.Dict<string | string[]>) => void) | undefined;
|
|
1858
|
+
/**
|
|
1859
|
+
* The callback to invoke when informational (1xx) headers are received from
|
|
1860
|
+
* the server. The callback receives `(headers)` where `headers` is an object
|
|
1861
|
+
* in the same format as `stream.headers`. Informational headers are sent
|
|
1862
|
+
* before the final response (e.g., 103 Early Hints). Throws
|
|
1863
|
+
* `ERR_INVALID_STATE` if set on a session that does not support headers.
|
|
1864
|
+
* Read/write.
|
|
1865
|
+
* @since v26.2.0
|
|
1866
|
+
*/
|
|
1867
|
+
oninfo: ((this: QuicStream, headers: NodeJS.Dict<string | string[]>) => void) | undefined;
|
|
1868
|
+
/**
|
|
1869
|
+
* The callback to invoke when the application is ready for trailing headers
|
|
1870
|
+
* to be sent. This is called synchronously — the user must call
|
|
1871
|
+
* `stream.sendTrailers()` within this callback. Throws
|
|
1872
|
+
* `ERR_INVALID_STATE` if set on a session that does not support headers.
|
|
1873
|
+
* Read/write.
|
|
1874
|
+
* @since v26.2.0
|
|
1875
|
+
*/
|
|
1876
|
+
onwanttrailers: ((this: QuicStream) => void) | undefined;
|
|
1877
|
+
/**
|
|
1878
|
+
* Set trailing headers to be sent automatically when the application requests
|
|
1879
|
+
* them. This is an alternative to the `stream.onwanttrailers` callback
|
|
1880
|
+
* for cases where the trailers are known before the body completes. Throws
|
|
1881
|
+
* `ERR_INVALID_STATE` if set on a session that does not support headers.
|
|
1882
|
+
* Read/write.
|
|
1883
|
+
* @since v26.2.0
|
|
1884
|
+
*/
|
|
1885
|
+
pendingTrailers: NodeJS.Dict<string | string[]> | undefined;
|
|
1886
|
+
/**
|
|
1887
|
+
* Sends initial or response headers on the stream. For client-side streams,
|
|
1888
|
+
* this sends request headers. For server-side streams, this sends response
|
|
1889
|
+
* headers. Throws `ERR_INVALID_STATE` if the session does not support headers.
|
|
1890
|
+
* @since v26.2.0
|
|
1891
|
+
* @param headers Header object with string keys and string or
|
|
1892
|
+
* string-array values. Pseudo-headers (`:method`, `:path`, etc.) must
|
|
1893
|
+
* appear before regular headers.
|
|
1894
|
+
*/
|
|
1895
|
+
sendHeaders(headers: NodeJS.Dict<string | string[]>, options?: StreamSendHeadersOptions): boolean;
|
|
1896
|
+
/**
|
|
1897
|
+
* Sends informational (1xx) response headers. Server only. Throws
|
|
1898
|
+
* `ERR_INVALID_STATE` if the session does not support headers.
|
|
1899
|
+
* @since v26.2.0
|
|
1900
|
+
* @param headers Header object. Must include `:status` with a 1xx
|
|
1901
|
+
* value (e.g., `{ ':status': '103', 'link': '</style.css>; rel=preload' }`).
|
|
1902
|
+
*/
|
|
1903
|
+
sendInformationalHeaders(headers: NodeJS.Dict<string | string[]>): boolean;
|
|
1904
|
+
/**
|
|
1905
|
+
* Sends trailing headers on the stream. Must be called synchronously during
|
|
1906
|
+
* the `stream.onwanttrailers` callback, or set ahead of time via
|
|
1907
|
+
* `stream.pendingTrailers`. Throws `ERR_INVALID_STATE` if the session
|
|
1908
|
+
* does not support headers.
|
|
1909
|
+
* @since v26.2.0
|
|
1910
|
+
* @param headers Trailing header object. Pseudo-headers must not be
|
|
1911
|
+
* included in trailers.
|
|
1912
|
+
*/
|
|
1913
|
+
sendTrailers(headers: NodeJS.Dict<string | string[]>): boolean;
|
|
1914
|
+
/**
|
|
1915
|
+
* The current priority of the stream. Returns `null` if the session does not
|
|
1916
|
+
* support priority (e.g. non-HTTP/3) or if the stream has been destroyed.
|
|
1917
|
+
* Read only. Use `stream.setPriority()` to change the priority.
|
|
1918
|
+
*
|
|
1919
|
+
* On client-side HTTP/3 sessions, the value reflects what was set via
|
|
1920
|
+
* `stream.setPriority()`. On server-side HTTP/3 sessions, the value
|
|
1921
|
+
* reflects the peer's requested priority (e.g., from `PRIORITY_UPDATE` frames).
|
|
1922
|
+
* @since v26.2.0
|
|
1923
|
+
*/
|
|
1924
|
+
readonly priority: StreamPriority | null;
|
|
1925
|
+
/**
|
|
1926
|
+
* Sets the priority of the stream. Throws `ERR_INVALID_STATE` if the session
|
|
1927
|
+
* does not support priority (e.g. non-HTTP/3). Has no effect if the stream
|
|
1928
|
+
* has been destroyed.
|
|
1929
|
+
* @since v26.2.0
|
|
1930
|
+
*/
|
|
1931
|
+
setPriority(options?: NodeJS.PartialOptions<StreamPriority>): void;
|
|
1932
|
+
/**
|
|
1933
|
+
* The stream implements `Symbol.asyncIterator`, making it directly usable
|
|
1934
|
+
* in `for await...of` loops. Each iteration yields a batch of `Uint8Array`
|
|
1935
|
+
* chunks.
|
|
1936
|
+
*
|
|
1937
|
+
* Only one async iterator can be obtained per stream. A second call throws
|
|
1938
|
+
* `ERR_INVALID_STATE`. Non-readable streams (outbound-only unidirectional
|
|
1939
|
+
* or closed) return an immediately-finished iterator.
|
|
1940
|
+
*
|
|
1941
|
+
* ```js
|
|
1942
|
+
* for await (const chunks of stream) {
|
|
1943
|
+
* for (const chunk of chunks) {
|
|
1944
|
+
* // Process each Uint8Array chunk
|
|
1945
|
+
* }
|
|
1946
|
+
* }
|
|
1947
|
+
* ```
|
|
1948
|
+
*
|
|
1949
|
+
* Compatible with stream/iter utilities:
|
|
1950
|
+
*
|
|
1951
|
+
* ```js
|
|
1952
|
+
* import Stream from 'node:stream/iter';
|
|
1953
|
+
* const body = await Stream.bytes(stream);
|
|
1954
|
+
* const text = await Stream.text(stream);
|
|
1955
|
+
* await Stream.pipeTo(stream, someWriter);
|
|
1956
|
+
* ```
|
|
1957
|
+
* @since v26.2.0
|
|
1958
|
+
*/
|
|
1959
|
+
[Symbol.asyncIterator](): NodeJS.AsyncIterator<NodeJS.NonSharedUint8Array[]>;
|
|
1960
|
+
/**
|
|
1961
|
+
* Returns a Writer object for pushing data to the stream incrementally.
|
|
1962
|
+
* The Writer implements the stream/iter Writer interface with the
|
|
1963
|
+
* try-sync-fallback-to-async pattern.
|
|
1964
|
+
*
|
|
1965
|
+
* Only available when no `body` source was provided at creation time or via
|
|
1966
|
+
* `stream.setBody()`. Non-writable streams return an already-closed
|
|
1967
|
+
* Writer. Throws `ERR_INVALID_STATE` if the outbound is already configured.
|
|
1968
|
+
*
|
|
1969
|
+
* The Writer has the following methods:
|
|
1970
|
+
*
|
|
1971
|
+
* * `writeSync(chunk)` — Synchronous write. Returns `true` if accepted,
|
|
1972
|
+
* `false` if flow-controlled. Data is NOT accepted on `false`.
|
|
1973
|
+
* * `write(chunk[, options])` — Async write with drain wait. `options.signal`
|
|
1974
|
+
* is checked at entry but not observed during the write.
|
|
1975
|
+
* * `writevSync(chunks)` — Synchronous vectored write. All-or-nothing.
|
|
1976
|
+
* * `writev(chunks[, options])` — Async vectored write.
|
|
1977
|
+
* * `endSync()` — Synchronous close. Returns total bytes or `-1`.
|
|
1978
|
+
* * `end([options])` — Async close.
|
|
1979
|
+
* * `fail(reason)` — Errors the stream (sends `RESET_STREAM` to peer).
|
|
1980
|
+
* When `reason` is a `QuicError`, its `error.errorCode` is used
|
|
1981
|
+
* as the wire code on the resulting `RESET_STREAM` frame; otherwise
|
|
1982
|
+
* the wire code falls back to the negotiated application protocol's
|
|
1983
|
+
* "internal error" code (`H3_INTERNAL_ERROR` (`0x102`) for HTTP/3, or
|
|
1984
|
+
* the QUIC transport-layer `INTERNAL_ERROR` (`0x1`) for raw QUIC).
|
|
1985
|
+
* See `stream.destroy()` for a full-stream abort that also resets
|
|
1986
|
+
* the readable side via `STOP_SENDING`.
|
|
1987
|
+
* * `desiredSize` — Available capacity in bytes, or `null` if closed/errored.
|
|
1988
|
+
*
|
|
1989
|
+
* The bytes from each `writeSync()` / `writevSync()` / `write()` / `writev()`
|
|
1990
|
+
* input chunk are copied into an internal buffer, so the caller's source
|
|
1991
|
+
* buffer is unchanged and may be reused or mutated immediately after the
|
|
1992
|
+
* call returns. Callers that want to ensure a source buffer cannot be
|
|
1993
|
+
* mutated after handing it off can call `ArrayBuffer.prototype.transfer()`
|
|
1994
|
+
* themselves before passing the buffer.
|
|
1995
|
+
* @since v26.2.0
|
|
1996
|
+
*/
|
|
1997
|
+
readonly writer: Writer;
|
|
1998
|
+
/**
|
|
1999
|
+
* Sets the outbound body source for the stream. Can only be called once.
|
|
2000
|
+
* Mutually exclusive with `stream.writer`.
|
|
2001
|
+
*
|
|
2002
|
+
* The following body source types are supported:
|
|
2003
|
+
*
|
|
2004
|
+
* * `null` — The writable side is closed immediately (FIN sent with no data).
|
|
2005
|
+
* * `string` — UTF-8 encoded and sent as a single chunk.
|
|
2006
|
+
* * `ArrayBuffer`, `SharedArrayBuffer`, `ArrayBufferView` — Sent as a single
|
|
2007
|
+
* chunk. The bytes are copied into an internal buffer, so the caller's
|
|
2008
|
+
* source buffer is unchanged and may be reused or mutated immediately
|
|
2009
|
+
* after the call returns. Callers wanting to ensure their source cannot
|
|
2010
|
+
* be mutated after handing it off can call
|
|
2011
|
+
* `ArrayBuffer.prototype.transfer()` themselves before passing the buffer.
|
|
2012
|
+
* * `Blob` — Sent from the Blob's underlying data queue.
|
|
2013
|
+
* * {FileHandle} — The file contents are read asynchronously via an
|
|
2014
|
+
* fd-backed data source. The `FileHandle` must be opened for reading
|
|
2015
|
+
* (e.g. via [`fs.promises.open(path, 'r')`][]). Once passed as a body, the
|
|
2016
|
+
* `FileHandle` is locked and cannot be used as a body for another stream.
|
|
2017
|
+
* The `FileHandle` is automatically closed when the stream finishes.
|
|
2018
|
+
* * `AsyncIterable`, `Iterable` — Each yielded chunk (string or
|
|
2019
|
+
* `Uint8Array`) is written incrementally in streaming mode.
|
|
2020
|
+
* * `Promise` — Awaited; the resolved value is used as the body (subject
|
|
2021
|
+
* to the same type rules).
|
|
2022
|
+
*
|
|
2023
|
+
* Throws `ERR_INVALID_STATE` if the outbound is already configured or if
|
|
2024
|
+
* the writer has been accessed.
|
|
2025
|
+
* @since v26.2.0
|
|
900
2026
|
*/
|
|
901
|
-
|
|
2027
|
+
setBody(body: StreamBody): void;
|
|
902
2028
|
/**
|
|
903
|
-
* The session that created this stream
|
|
2029
|
+
* The session that created this stream, or `null` if the stream has been
|
|
2030
|
+
* destroyed. Read only.
|
|
904
2031
|
* @since v23.8.0
|
|
905
2032
|
*/
|
|
906
|
-
readonly session: QuicSession;
|
|
2033
|
+
readonly session: QuicSession | null;
|
|
907
2034
|
/**
|
|
908
2035
|
* The current statistics for the stream. Read only.
|
|
909
2036
|
* @since v23.8.0
|
|
@@ -966,13 +2093,33 @@ declare module "node:quic" {
|
|
|
966
2093
|
readonly receivedAt: bigint;
|
|
967
2094
|
}
|
|
968
2095
|
}
|
|
2096
|
+
/**
|
|
2097
|
+
* An object containing commonly used constants for QUIC configuration.
|
|
2098
|
+
* @since v26.2.0
|
|
2099
|
+
*/
|
|
969
2100
|
namespace constants {
|
|
2101
|
+
/**
|
|
2102
|
+
* Congestion control algorithm identifiers, for use with the
|
|
2103
|
+
* `sessionOptions.cc` option:
|
|
2104
|
+
*
|
|
2105
|
+
* * `quic.constants.cc.RENO` — Reno congestion control.
|
|
2106
|
+
* * `quic.constants.cc.CUBIC` — CUBIC congestion control.
|
|
2107
|
+
* * `quic.constants.cc.BBR` — BBR congestion control.
|
|
2108
|
+
*/
|
|
970
2109
|
enum cc {
|
|
971
2110
|
RENO = "reno",
|
|
972
2111
|
CUBIC = "cubic",
|
|
973
2112
|
BBR = "bbr",
|
|
974
2113
|
}
|
|
2114
|
+
/**
|
|
2115
|
+
* The default TLS 1.3 cipher suite list used when `sessionOptions.ciphers`
|
|
2116
|
+
* is not specified.
|
|
2117
|
+
*/
|
|
975
2118
|
const DEFAULT_CIPHERS: string;
|
|
2119
|
+
/**
|
|
2120
|
+
* The default TLS 1.3 key-exchange group list used when
|
|
2121
|
+
* `sessionOptions.groups` is not specified.
|
|
2122
|
+
*/
|
|
976
2123
|
const DEFAULT_GROUPS: string;
|
|
977
2124
|
}
|
|
978
2125
|
}
|