@moqt/quic 0.5.7
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/LICENSE.txt +202 -0
- package/README.md +19 -0
- package/dist/connect.d.ts +40 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/connect.js +278 -0
- package/dist/connect.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/native.d.ts +63 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +3 -0
- package/dist/native.js.map +1 -0
- package/dist/transport.d.ts +58 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +405 -0
- package/dist/transport.js.map +1 -0
- package/package.json +50 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- Generated by scripts/generate-package-readmes.mjs — do not edit.
|
|
2
|
+
Content derives from this package's package.json (name, description).
|
|
3
|
+
Run `node scripts/generate-package-readmes.mjs --write` after editing it. -->
|
|
4
|
+
|
|
5
|
+
# @moqt/quic
|
|
6
|
+
|
|
7
|
+
Experimental Node.js native QUIC binding for Media over QUIC Transport (MoQT).
|
|
8
|
+
|
|
9
|
+
Part of [Playa](https://github.com/openmoq/moq-playa) — a TypeScript implementation of Media over QUIC (MoQ). See the [project README](https://github.com/openmoq/moq-playa#readme) for architecture and API documentation.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @moqt/quic
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
[Apache-2.0](https://github.com/openmoq/moq-playa/blob/main/LICENSE.txt)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { NativeQuicRuntime } from './native.js';
|
|
2
|
+
import { type MoqtQuicTransport } from './transport.js';
|
|
3
|
+
export interface QuicConnectOptions {
|
|
4
|
+
/** Trust a self-signed or otherwise unverified peer certificate. */
|
|
5
|
+
readonly allowUnauthorized?: boolean;
|
|
6
|
+
/** Additional certificate authorities accepted by Node's TLS verifier. */
|
|
7
|
+
readonly ca?: ArrayBuffer | ArrayBufferView | readonly (ArrayBuffer | ArrayBufferView)[];
|
|
8
|
+
/** Maximum handshake duration in milliseconds. */
|
|
9
|
+
readonly handshakeTimeoutMs?: number;
|
|
10
|
+
/** Maximum QUIC DATAGRAM frame size advertised to the peer. */
|
|
11
|
+
readonly maxDatagramFrameSize?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ParsedMoqtUri {
|
|
14
|
+
readonly address: string;
|
|
15
|
+
readonly servername: string;
|
|
16
|
+
readonly setup: {
|
|
17
|
+
readonly authority: string;
|
|
18
|
+
readonly path: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export type HostLookup = (hostname: string) => Promise<readonly {
|
|
22
|
+
address: string;
|
|
23
|
+
family: number;
|
|
24
|
+
}[]>;
|
|
25
|
+
/** Parse one native `moqt` URI into QUIC and MOQT routing fields. */
|
|
26
|
+
export declare function parseMoqtUri(input: string | URL): ParsedMoqtUri;
|
|
27
|
+
/**
|
|
28
|
+
* Connect to a native-QUIC MoQT endpoint using Node's experimental QUIC API.
|
|
29
|
+
*
|
|
30
|
+
* Requires a Node build configured with `--experimental-quic`, launched with
|
|
31
|
+
* `--experimental-quic`. The returned transport is draft-18 only.
|
|
32
|
+
*/
|
|
33
|
+
export declare function connectQuic(uri: string | URL, options?: QuicConnectOptions): Promise<MoqtQuicTransport>;
|
|
34
|
+
/** Resolve a URI host to numeric socket addresses accepted by Node QUIC. */
|
|
35
|
+
export declare function resolveDialAddresses(parsed: ParsedMoqtUri, lookup: HostLookup): Promise<string[]>;
|
|
36
|
+
/** @internal Try each address for one URI without changing its MOQT identity. */
|
|
37
|
+
export declare function connectQuicCandidatesWithRuntime(uri: string | URL, options: QuicConnectOptions, runtime: NativeQuicRuntime, addresses: readonly string[]): Promise<MoqtQuicTransport>;
|
|
38
|
+
/** @internal Runtime-injected seam used by deterministic transport tests. */
|
|
39
|
+
export declare function connectQuicWithRuntime(uri: string | URL, options: QuicConnectOptions, runtime: NativeQuicRuntime): Promise<MoqtQuicTransport>;
|
|
40
|
+
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,iBAAiB,EAAqB,MAAM,aAAa,CAAC;AAClG,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AASxB,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,CAAC,EAAE,WAAW,GAAG,eAAe,GAAG,SAAS,CAAC,WAAW,GAAG,eAAe,CAAC,EAAE,CAAC;IACzF,kDAAkD;IAClD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,+DAA+D;IAC/D,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,MAAM,MAAM,UAAU,GAAG,CACvB,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,SAAS;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAAC;AAE7D,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,aAAa,CAkD/D;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAoB5B;AAED,4EAA4E;AAC5E,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBnB;AAED,iFAAiF;AACjF,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAwB5B;AAED,6EAA6E;AAC7E,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAwH5B"}
|
package/dist/connect.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { lookup as nodeLookup } from 'node:dns/promises';
|
|
2
|
+
import { isIP } from 'node:net';
|
|
3
|
+
import { BoundedReadableQueue, NodeQuicTransport, routeNativeStream, } from './transport.js';
|
|
4
|
+
const ALPN = 'moqt-18';
|
|
5
|
+
const DEFAULT_PORT = '443';
|
|
6
|
+
const DEFAULT_MAX_DATAGRAM_FRAME_SIZE = 1200;
|
|
7
|
+
const DEFAULT_HANDSHAKE_TIMEOUT_MS = 10_000;
|
|
8
|
+
const STARTUP_QUEUE_LIMIT = 256;
|
|
9
|
+
/** Parse one native `moqt` URI into QUIC and MOQT routing fields. */
|
|
10
|
+
export function parseMoqtUri(input) {
|
|
11
|
+
const raw = input instanceof URL ? input.href : input;
|
|
12
|
+
const components = /^moqt:\/\/([^/?#]*)(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i.exec(raw);
|
|
13
|
+
if (!components) {
|
|
14
|
+
let protocol = 'an invalid URI';
|
|
15
|
+
try {
|
|
16
|
+
protocol = new URL(raw).protocol;
|
|
17
|
+
}
|
|
18
|
+
catch { /* use the syntax diagnostic */ }
|
|
19
|
+
throw new TypeError(`native MoQT URI must use moqt: with an authority, not ${protocol}`);
|
|
20
|
+
}
|
|
21
|
+
const [, authority, path = '', query = '', fragment] = components;
|
|
22
|
+
if (!authority)
|
|
23
|
+
throw new TypeError('native MoQT URI must include a host');
|
|
24
|
+
if (authority.includes('@'))
|
|
25
|
+
throw new TypeError('native MoQT URI must not include credentials');
|
|
26
|
+
validateUriComponent(path, 'path', false);
|
|
27
|
+
validateUriComponent(query.startsWith('?') ? query.slice(1) : query, 'query', true);
|
|
28
|
+
if (fragment !== undefined && !/^#[a-z0-9-]+:/.test(fragment)) {
|
|
29
|
+
throw new TypeError('native MoQT URI fragment must have the form #<type>:<value>');
|
|
30
|
+
}
|
|
31
|
+
if (fragment !== undefined) {
|
|
32
|
+
const colon = fragment.indexOf(':');
|
|
33
|
+
validateUriComponent(fragment.slice(colon + 1), 'fragment value', true);
|
|
34
|
+
}
|
|
35
|
+
if (!isValidAuthority(authority) || !hasValidPercentEncoding(authority)) {
|
|
36
|
+
throw new TypeError('native MoQT URI has an invalid authority');
|
|
37
|
+
}
|
|
38
|
+
let authorityUrl;
|
|
39
|
+
try {
|
|
40
|
+
authorityUrl = new URL(`https://${authority}/`);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new TypeError('native MoQT URI has an invalid authority', { cause: error });
|
|
44
|
+
}
|
|
45
|
+
if (!authorityUrl.hostname)
|
|
46
|
+
throw new TypeError('native MoQT URI must include a host');
|
|
47
|
+
if (authorityUrl.username || authorityUrl.password) {
|
|
48
|
+
throw new TypeError('native MoQT URI must not include credentials');
|
|
49
|
+
}
|
|
50
|
+
const port = authorityUrl.port || DEFAULT_PORT;
|
|
51
|
+
const hostname = authorityUrl.hostname;
|
|
52
|
+
const address = `${hostname}:${port}`;
|
|
53
|
+
const servername = hostname.startsWith('[') && hostname.endsWith(']')
|
|
54
|
+
? hostname.slice(1, -1)
|
|
55
|
+
: hostname;
|
|
56
|
+
return {
|
|
57
|
+
address,
|
|
58
|
+
servername,
|
|
59
|
+
setup: {
|
|
60
|
+
authority,
|
|
61
|
+
path: `${path}${query}`,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Connect to a native-QUIC MoQT endpoint using Node's experimental QUIC API.
|
|
67
|
+
*
|
|
68
|
+
* Requires a Node build configured with `--experimental-quic`, launched with
|
|
69
|
+
* `--experimental-quic`. The returned transport is draft-18 only.
|
|
70
|
+
*/
|
|
71
|
+
export async function connectQuic(uri, options = {}) {
|
|
72
|
+
const features = process.features;
|
|
73
|
+
if (features.quic !== true) {
|
|
74
|
+
throw new Error('Node QUIC is unavailable; use a Node build configured and launched with --experimental-quic');
|
|
75
|
+
}
|
|
76
|
+
const specifier = 'node:quic';
|
|
77
|
+
let runtime;
|
|
78
|
+
try {
|
|
79
|
+
runtime = await import(specifier);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw new Error('failed to load Node experimental QUIC runtime', { cause: error });
|
|
83
|
+
}
|
|
84
|
+
const parsed = parseMoqtUri(uri);
|
|
85
|
+
const addresses = await resolveDialAddresses(parsed, async (hostname) => nodeLookup(hostname, { all: true }));
|
|
86
|
+
return connectQuicCandidatesWithRuntime(uri, options, runtime, addresses);
|
|
87
|
+
}
|
|
88
|
+
/** Resolve a URI host to numeric socket addresses accepted by Node QUIC. */
|
|
89
|
+
export async function resolveDialAddresses(parsed, lookup) {
|
|
90
|
+
const uri = new URL(`moqt://${parsed.setup.authority}`);
|
|
91
|
+
const port = uri.port || DEFAULT_PORT;
|
|
92
|
+
const literal = parsed.servername;
|
|
93
|
+
const resolved = isIP(literal) === 0
|
|
94
|
+
? await lookup(literal)
|
|
95
|
+
: [{ address: literal, family: isIP(literal) }];
|
|
96
|
+
const addresses = [];
|
|
97
|
+
for (const result of resolved) {
|
|
98
|
+
const family = isIP(result.address);
|
|
99
|
+
if (family === 0 || (result.family !== 4 && result.family !== 6)) {
|
|
100
|
+
throw new Error(`DNS lookup returned a non-IP address for ${JSON.stringify(literal)}`);
|
|
101
|
+
}
|
|
102
|
+
const address = family === 6 ? `[${result.address}]:${port}` : `${result.address}:${port}`;
|
|
103
|
+
if (!addresses.includes(address))
|
|
104
|
+
addresses.push(address);
|
|
105
|
+
}
|
|
106
|
+
if (addresses.length === 0) {
|
|
107
|
+
throw new Error(`DNS lookup returned no addresses for ${JSON.stringify(literal)}`);
|
|
108
|
+
}
|
|
109
|
+
return addresses;
|
|
110
|
+
}
|
|
111
|
+
/** @internal Try each address for one URI without changing its MOQT identity. */
|
|
112
|
+
export async function connectQuicCandidatesWithRuntime(uri, options, runtime, addresses) {
|
|
113
|
+
if (addresses.length === 0)
|
|
114
|
+
throw new Error('native QUIC requires at least one dial address');
|
|
115
|
+
const failures = [];
|
|
116
|
+
for (const address of addresses) {
|
|
117
|
+
const localAddress = address.startsWith('[') ? '[::]:0' : '0.0.0.0:0';
|
|
118
|
+
const candidateRuntime = {
|
|
119
|
+
// Node's default endpoint is IPv6. On platforms without working
|
|
120
|
+
// IPv4-mapped UDP egress that silently strands an IPv4 handshake, so
|
|
121
|
+
// bind each candidate to a wildcard endpoint of the same address family.
|
|
122
|
+
connect: (_ignored, connectOptions) => runtime.connect(address, {
|
|
123
|
+
...connectOptions,
|
|
124
|
+
endpoint: { address: localAddress },
|
|
125
|
+
reuseEndpoint: false,
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
128
|
+
try {
|
|
129
|
+
return await connectQuicWithRuntime(uri, options, candidateRuntime);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
133
|
+
failures.push(new Error(`native QUIC handshake to ${address} failed: ${cause.message}`, { cause }));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (failures.length === 1)
|
|
137
|
+
throw failures[0];
|
|
138
|
+
throw new AggregateError(failures, 'native QUIC handshake failed for every resolved address');
|
|
139
|
+
}
|
|
140
|
+
/** @internal Runtime-injected seam used by deterministic transport tests. */
|
|
141
|
+
export async function connectQuicWithRuntime(uri, options, runtime) {
|
|
142
|
+
const parsed = parseMoqtUri(uri);
|
|
143
|
+
const maxDatagramFrameSize = options.maxDatagramFrameSize ?? DEFAULT_MAX_DATAGRAM_FRAME_SIZE;
|
|
144
|
+
const handshakeTimeoutMs = options.handshakeTimeoutMs ?? DEFAULT_HANDSHAKE_TIMEOUT_MS;
|
|
145
|
+
positiveInteger(maxDatagramFrameSize, 'maxDatagramFrameSize');
|
|
146
|
+
positiveInteger(handshakeTimeoutMs, 'handshakeTimeoutMs');
|
|
147
|
+
const unidirectional = new BoundedReadableQueue(STARTUP_QUEUE_LIMIT, undefined, (stream, reason) => stream.cancel(reason));
|
|
148
|
+
const bidirectional = new BoundedReadableQueue(STARTUP_QUEUE_LIMIT, undefined, async (stream, reason) => {
|
|
149
|
+
await Promise.allSettled([
|
|
150
|
+
stream.readable.cancel(reason),
|
|
151
|
+
stream.writable.abort(reason),
|
|
152
|
+
]);
|
|
153
|
+
});
|
|
154
|
+
const datagrams = new BoundedReadableQueue(STARTUP_QUEUE_LIMIT);
|
|
155
|
+
let session = null;
|
|
156
|
+
let startupError = null;
|
|
157
|
+
let observedSessionError;
|
|
158
|
+
let closedFailure;
|
|
159
|
+
let teardownStarted = false;
|
|
160
|
+
const destroySession = (failure) => {
|
|
161
|
+
if (!session || teardownStarted)
|
|
162
|
+
return;
|
|
163
|
+
teardownStarted = true;
|
|
164
|
+
try {
|
|
165
|
+
session.destroy(failure, { code: 1, type: 'application', reason: failure.message });
|
|
166
|
+
}
|
|
167
|
+
catch { /* backend is already terminal */ }
|
|
168
|
+
};
|
|
169
|
+
const failStartup = (reason) => {
|
|
170
|
+
if (startupError)
|
|
171
|
+
return;
|
|
172
|
+
startupError = new Error(reason);
|
|
173
|
+
destroySession(startupError);
|
|
174
|
+
};
|
|
175
|
+
const connectOptions = {
|
|
176
|
+
alpn: ALPN,
|
|
177
|
+
servername: parsed.servername,
|
|
178
|
+
enableEarlyData: false,
|
|
179
|
+
verifyPeer: options.allowUnauthorized ? 'manual' : 'strict',
|
|
180
|
+
rejectUnauthorized: !options.allowUnauthorized,
|
|
181
|
+
...(options.ca !== undefined ? { ca: options.ca } : {}),
|
|
182
|
+
handshakeTimeout: handshakeTimeoutMs,
|
|
183
|
+
transportParams: { maxDatagramFrameSize },
|
|
184
|
+
onstream: (stream) => {
|
|
185
|
+
if (stream.early) {
|
|
186
|
+
failStartup('native QUIC delivered a 0-RTT stream while early data was disabled');
|
|
187
|
+
rejectNativeStream(stream, 1n);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (!routeNativeStream(stream, unidirectional, bidirectional)) {
|
|
191
|
+
failStartup('native QUIC incoming stream queue overflowed or had no direction');
|
|
192
|
+
rejectNativeStream(stream, 1n);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
ondatagram: (datagram, early) => {
|
|
196
|
+
if (early) {
|
|
197
|
+
failStartup('native QUIC delivered a 0-RTT datagram while early data was disabled');
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (!datagrams.push(datagram.slice()))
|
|
201
|
+
failStartup('native QUIC incoming datagram queue overflowed');
|
|
202
|
+
},
|
|
203
|
+
onerror: (error) => { observedSessionError = error; },
|
|
204
|
+
};
|
|
205
|
+
try {
|
|
206
|
+
session = await runtime.connect(parsed.address, connectOptions);
|
|
207
|
+
// A failed handshake can reject `closed` before `opened` rejects. Keep that
|
|
208
|
+
// backend promise observed and retain its diagnostic; callers receive the
|
|
209
|
+
// more specific backend failure rather than `opened`'s generic aftermath.
|
|
210
|
+
void session.closed.catch((error) => { closedFailure = error; });
|
|
211
|
+
const pendingFailure = startupError;
|
|
212
|
+
if (pendingFailure) {
|
|
213
|
+
destroySession(pendingFailure);
|
|
214
|
+
throw pendingFailure;
|
|
215
|
+
}
|
|
216
|
+
const opened = await session.opened;
|
|
217
|
+
if (opened.protocol !== ALPN) {
|
|
218
|
+
throw new Error(`native QUIC negotiated ALPN ${JSON.stringify(opened.protocol)}; expected ${JSON.stringify(ALPN)}`);
|
|
219
|
+
}
|
|
220
|
+
if (opened.earlyDataAttempted || opened.earlyDataAccepted) {
|
|
221
|
+
throw new Error('native QUIC attempted or accepted 0-RTT despite early data being disabled');
|
|
222
|
+
}
|
|
223
|
+
if (!options.allowUnauthorized
|
|
224
|
+
&& opened.validationErrorCode !== undefined
|
|
225
|
+
&& opened.validationErrorCode !== 0
|
|
226
|
+
&& opened.validationErrorCode !== '0') {
|
|
227
|
+
const detail = opened.validationErrorReason ?? String(opened.validationErrorCode);
|
|
228
|
+
throw new Error(`native QUIC certificate validation failed: ${detail}`);
|
|
229
|
+
}
|
|
230
|
+
if (!Number.isSafeInteger(session.maxDatagramSize) || session.maxDatagramSize <= 0) {
|
|
231
|
+
throw new Error('peer did not negotiate QUIC DATAGRAM support');
|
|
232
|
+
}
|
|
233
|
+
if (startupError)
|
|
234
|
+
throw startupError;
|
|
235
|
+
return new NodeQuicTransport(session, parsed.setup, unidirectional, bidirectional, datagrams, () => observedSessionError);
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
const reported = observedSessionError ?? closedFailure ?? error;
|
|
239
|
+
const failure = reported instanceof Error ? reported : new Error(String(reported));
|
|
240
|
+
destroySession(failure);
|
|
241
|
+
unidirectional.error(failure);
|
|
242
|
+
bidirectional.error(failure);
|
|
243
|
+
datagrams.error(failure);
|
|
244
|
+
throw failure;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function rejectNativeStream(stream, code) {
|
|
248
|
+
try {
|
|
249
|
+
stream.stopSending(code);
|
|
250
|
+
}
|
|
251
|
+
catch { /* receive side already closed */ }
|
|
252
|
+
try {
|
|
253
|
+
stream.resetStream(code);
|
|
254
|
+
}
|
|
255
|
+
catch { /* no writable side or already closed */ }
|
|
256
|
+
}
|
|
257
|
+
function positiveInteger(value, name) {
|
|
258
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
259
|
+
throw new RangeError(`${name} must be a positive safe integer`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function validateUriComponent(value, name, allowSlashAndQuestion) {
|
|
263
|
+
const pattern = allowSlashAndQuestion
|
|
264
|
+
? /^[A-Za-z0-9\-._~!$&'()*+,;=:@%/?]*$/
|
|
265
|
+
: /^(\/[A-Za-z0-9\-._~!$&'()*+,;=:@%]*)*$/;
|
|
266
|
+
if (!pattern.test(value) || !hasValidPercentEncoding(value)) {
|
|
267
|
+
throw new TypeError(`native MoQT URI has an invalid ${name}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function hasValidPercentEncoding(value) {
|
|
271
|
+
return !value.replace(/%[0-9A-Fa-f]{2}/g, '').includes('%');
|
|
272
|
+
}
|
|
273
|
+
function isValidAuthority(value) {
|
|
274
|
+
const regName = "[A-Za-z0-9._~!$&'()*+,;=%-]+";
|
|
275
|
+
const ipLiteral = "\\[[A-Za-z0-9._~!$&'()*+,;=:%-]+\\]";
|
|
276
|
+
return new RegExp(`^(?:${regName}|${ipLiteral})(?::[0-9]*)?$`).test(value);
|
|
277
|
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;AAED,SAAS,uBAAuB,CAAC,KAAa;IAC5C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,OAAO,GAAG,8BAA8B,CAAC;IAC/C,MAAM,SAAS,GAAG,qCAAqC,CAAC;IACxD,OAAO,IAAI,MAAM,CAAC,OAAO,OAAO,IAAI,SAAS,gBAAgB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experimental native QUIC binding for Node.js.
|
|
3
|
+
*
|
|
4
|
+
* This package requires Node's experimental `node:quic` module and currently
|
|
5
|
+
* supports MOQT draft 18 only. Browser applications should continue to use
|
|
6
|
+
* `@moqt/webtransport` with a WebTransport implementation.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export { connectQuic, parseMoqtUri } from './connect.js';
|
|
11
|
+
export type { ParsedMoqtUri, QuicConnectOptions } from './connect.js';
|
|
12
|
+
export type { MoqtQuicTransport } from './transport.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACtE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experimental native QUIC binding for Node.js.
|
|
3
|
+
*
|
|
4
|
+
* This package requires Node's experimental `node:quic` module and currently
|
|
5
|
+
* supports MOQT draft 18 only. Browser applications should continue to use
|
|
6
|
+
* `@moqt/webtransport` with a WebTransport implementation.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export { connectQuic, parseMoqtUri } from './connect.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/native.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Internal structural types for Node's experimental `node:quic` API. */
|
|
2
|
+
export interface NativeQuicOpenedInfo {
|
|
3
|
+
readonly protocol: string;
|
|
4
|
+
readonly earlyDataAttempted: boolean;
|
|
5
|
+
readonly earlyDataAccepted: boolean;
|
|
6
|
+
readonly validationErrorReason?: string;
|
|
7
|
+
readonly validationErrorCode?: number | string;
|
|
8
|
+
}
|
|
9
|
+
export interface NativeQuicWriter {
|
|
10
|
+
readonly canWrite?: boolean | null;
|
|
11
|
+
write(chunk: Uint8Array): Promise<unknown>;
|
|
12
|
+
end(): Promise<unknown>;
|
|
13
|
+
fail(reason?: unknown): void;
|
|
14
|
+
}
|
|
15
|
+
export interface NativeQuicStream extends AsyncIterable<Uint8Array[]> {
|
|
16
|
+
readonly direction: 'bidi' | 'uni' | null;
|
|
17
|
+
readonly early?: boolean;
|
|
18
|
+
readonly writer: NativeQuicWriter;
|
|
19
|
+
readonly closed: Promise<void>;
|
|
20
|
+
onerror?: (error: unknown) => void;
|
|
21
|
+
onreset?: (error: unknown) => void;
|
|
22
|
+
onstopsending?: (error: unknown) => void;
|
|
23
|
+
resetStream(code?: bigint | number): void;
|
|
24
|
+
stopSending(code?: bigint | number): void;
|
|
25
|
+
}
|
|
26
|
+
export interface NativeQuicCloseOptions {
|
|
27
|
+
readonly code?: bigint | number;
|
|
28
|
+
readonly type?: 'transport' | 'application';
|
|
29
|
+
readonly reason?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface NativeQuicSession {
|
|
32
|
+
readonly opened: Promise<NativeQuicOpenedInfo>;
|
|
33
|
+
readonly closed: Promise<void>;
|
|
34
|
+
readonly maxDatagramSize: number;
|
|
35
|
+
createBidirectionalStream(): Promise<NativeQuicStream>;
|
|
36
|
+
createUnidirectionalStream(): Promise<NativeQuicStream>;
|
|
37
|
+
sendDatagram(data: Uint8Array): Promise<bigint>;
|
|
38
|
+
close(options?: NativeQuicCloseOptions): Promise<void>;
|
|
39
|
+
destroy(error?: unknown, options?: NativeQuicCloseOptions): void;
|
|
40
|
+
}
|
|
41
|
+
export interface NativeQuicConnectOptions {
|
|
42
|
+
readonly endpoint?: {
|
|
43
|
+
readonly address: string;
|
|
44
|
+
};
|
|
45
|
+
readonly reuseEndpoint?: boolean;
|
|
46
|
+
readonly alpn: string;
|
|
47
|
+
readonly servername: string;
|
|
48
|
+
readonly enableEarlyData: boolean;
|
|
49
|
+
readonly verifyPeer: 'strict' | 'auto' | 'manual';
|
|
50
|
+
readonly rejectUnauthorized: boolean;
|
|
51
|
+
readonly ca?: ArrayBuffer | ArrayBufferView | readonly (ArrayBuffer | ArrayBufferView)[];
|
|
52
|
+
readonly handshakeTimeout?: number;
|
|
53
|
+
readonly transportParams: {
|
|
54
|
+
readonly maxDatagramFrameSize: number;
|
|
55
|
+
};
|
|
56
|
+
readonly onstream: (stream: NativeQuicStream) => void;
|
|
57
|
+
readonly ondatagram: (datagram: Uint8Array, early: boolean) => void;
|
|
58
|
+
readonly onerror: (error: unknown) => void;
|
|
59
|
+
}
|
|
60
|
+
export interface NativeQuicRuntime {
|
|
61
|
+
connect(address: string, options: NativeQuicConnectOptions): Promise<NativeQuicSession>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=native.d.ts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C,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,EAAE,WAAW,GAAG,eAAe,GAAG,SAAS,CAAC,WAAW,GAAG,eAAe,CAAC,EAAE,CAAC;IACzF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,EAAE;QACxB,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;KACvC,CAAC;IACF,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACtD,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpE,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACzF"}
|
package/dist/native.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA,yEAAyE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { WebTransportBidirectionalStream, WebTransportCloseInfo, WebTransportLike } from '@moqt/webtransport';
|
|
2
|
+
import type { NativeQuicSession, NativeQuicStream } from './native.js';
|
|
3
|
+
interface MoqtSetupRouting {
|
|
4
|
+
readonly authority: string;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
}
|
|
7
|
+
/** Native QUIC transport plus the routing fields required in MOQT SETUP. */
|
|
8
|
+
export interface MoqtQuicTransport extends WebTransportLike {
|
|
9
|
+
readonly kind: 'quic';
|
|
10
|
+
readonly protocol: 'moqt-18';
|
|
11
|
+
readonly maxDatagramSize: number;
|
|
12
|
+
readonly setupOptions: MoqtSetupRouting;
|
|
13
|
+
}
|
|
14
|
+
/** A small bounded bridge from synchronous Node callbacks to WHATWG streams. */
|
|
15
|
+
export declare class BoundedReadableQueue<T> {
|
|
16
|
+
private readonly limit;
|
|
17
|
+
private readonly onCancel?;
|
|
18
|
+
private readonly onDiscard?;
|
|
19
|
+
readonly readable: ReadableStream<T>;
|
|
20
|
+
private readonly pending;
|
|
21
|
+
private controller;
|
|
22
|
+
private pullWaiting;
|
|
23
|
+
private terminal;
|
|
24
|
+
constructor(limit?: number, onCancel?: ((reason: unknown) => void | Promise<void>) | undefined, onDiscard?: ((value: T, reason: unknown) => void | Promise<void>) | undefined);
|
|
25
|
+
push(value: T): boolean;
|
|
26
|
+
close(discardReason?: unknown): void;
|
|
27
|
+
error(reason: unknown, discardReason?: unknown): void;
|
|
28
|
+
private discardPending;
|
|
29
|
+
}
|
|
30
|
+
/** Web-Streams facade over one Node QUIC session. */
|
|
31
|
+
export declare class NodeQuicTransport implements MoqtQuicTransport {
|
|
32
|
+
private readonly session;
|
|
33
|
+
readonly setupOptions: MoqtSetupRouting;
|
|
34
|
+
private readonly incomingUni;
|
|
35
|
+
private readonly incomingBidi;
|
|
36
|
+
private readonly incomingDatagrams;
|
|
37
|
+
readonly kind: "quic";
|
|
38
|
+
readonly protocol: "moqt-18";
|
|
39
|
+
readonly maxDatagramSize: number;
|
|
40
|
+
readonly incomingUnidirectionalStreams: ReadableStream<ReadableStream<Uint8Array>>;
|
|
41
|
+
readonly incomingBidirectionalStreams: ReadableStream<WebTransportBidirectionalStream>;
|
|
42
|
+
readonly datagrams: {
|
|
43
|
+
readonly readable: ReadableStream<Uint8Array>;
|
|
44
|
+
readonly writable: WritableStream<Uint8Array>;
|
|
45
|
+
};
|
|
46
|
+
readonly closed: Promise<WebTransportCloseInfo>;
|
|
47
|
+
private localCloseInfo;
|
|
48
|
+
private closeStarted;
|
|
49
|
+
constructor(session: NativeQuicSession, setupOptions: MoqtSetupRouting, incomingUni: BoundedReadableQueue<ReadableStream<Uint8Array>>, incomingBidi: BoundedReadableQueue<WebTransportBidirectionalStream>, incomingDatagrams: BoundedReadableQueue<Uint8Array>, sessionError: () => unknown);
|
|
50
|
+
createBidirectionalStream(): Promise<WebTransportBidirectionalStream>;
|
|
51
|
+
createUnidirectionalStream(): Promise<WritableStream<Uint8Array>>;
|
|
52
|
+
close(info?: WebTransportCloseInfo): void;
|
|
53
|
+
private closeIncoming;
|
|
54
|
+
private errorIncoming;
|
|
55
|
+
}
|
|
56
|
+
export declare function routeNativeStream(stream: NativeQuicStream, incomingUni: BoundedReadableQueue<ReadableStream<Uint8Array>>, incomingBidi: BoundedReadableQueue<WebTransportBidirectionalStream>): boolean;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAYvE,UAAU,gBAAgB;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,4EAA4E;AAC5E,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAAC;CACzC;AAED,gFAAgF;AAChF,qBAAa,oBAAoB,CAAC,CAAC;IAQ/B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B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;QAClB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;QAC9C,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;KAC/C,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAChD,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,YAAY,CAAS;gBAGV,OAAO,EAAE,iBAAiB,EAClC,YAAY,EAAE,gBAAgB,EACtB,WAAW,EAAE,oBAAoB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAC7D,YAAY,EAAE,oBAAoB,CAAC,+BAA+B,CAAC,EACnE,iBAAiB,EAAE,oBAAoB,CAAC,UAAU,CAAC,EACpE,YAAY,EAAE,MAAM,OAAO;IA4CvB,yBAAyB,IAAI,OAAO,CAAC,+BAA+B,CAAC;IASrE,0BAA0B,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IASvE,KAAK,CAAC,IAAI,GAAE,qBAA0B,GAAG,IAAI;IAS7C,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,aAAa;CAKtB;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,oBAAoB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAC7D,YAAY,EAAE,oBAAoB,CAAC,+BAA+B,CAAC,GAClE,OAAO,CAIT"}
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
const DEFAULT_QUEUE_LIMIT = 256;
|
|
2
|
+
const DRAINABLE_PROTOCOL = Symbol.for('Stream.drainableProtocol');
|
|
3
|
+
const STREAM_INTERNAL_ERROR = 0n;
|
|
4
|
+
const SESSION_INTERNAL_ERROR = 1n;
|
|
5
|
+
const STREAM_RESET_CODES = new Set([0n, 1n, 2n, 3n, 4n, 5n, 6n, 7n, 9n, 0x12n]);
|
|
6
|
+
const SESSION_ERROR_CODES = new Set([
|
|
7
|
+
0n, 1n, 2n, 3n, 4n, 5n, 6n, 8n, 9n,
|
|
8
|
+
0x10n, 0x11n, 0x12n, 0x13n, 0x14n, 0x15n, 0x16n, 0x17n, 0x18n, 0x19n, 0x1an,
|
|
9
|
+
]);
|
|
10
|
+
/** A small bounded bridge from synchronous Node callbacks to WHATWG streams. */
|
|
11
|
+
export class BoundedReadableQueue {
|
|
12
|
+
limit;
|
|
13
|
+
onCancel;
|
|
14
|
+
onDiscard;
|
|
15
|
+
readable;
|
|
16
|
+
pending = [];
|
|
17
|
+
controller = null;
|
|
18
|
+
pullWaiting = false;
|
|
19
|
+
terminal = false;
|
|
20
|
+
constructor(limit = DEFAULT_QUEUE_LIMIT, onCancel, onDiscard) {
|
|
21
|
+
this.limit = limit;
|
|
22
|
+
this.onCancel = onCancel;
|
|
23
|
+
this.onDiscard = onDiscard;
|
|
24
|
+
if (!Number.isSafeInteger(limit) || limit <= 0) {
|
|
25
|
+
throw new RangeError('queue limit must be a positive safe integer');
|
|
26
|
+
}
|
|
27
|
+
this.readable = new ReadableStream({
|
|
28
|
+
start: (controller) => { this.controller = controller; },
|
|
29
|
+
pull: (controller) => {
|
|
30
|
+
if (this.pending.length > 0) {
|
|
31
|
+
controller.enqueue(this.pending.shift());
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.pullWaiting = true;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
cancel: async (reason) => {
|
|
38
|
+
this.terminal = true;
|
|
39
|
+
this.pullWaiting = false;
|
|
40
|
+
await this.discardPending(reason);
|
|
41
|
+
await this.onCancel?.(reason);
|
|
42
|
+
},
|
|
43
|
+
}, { highWaterMark: 0 });
|
|
44
|
+
}
|
|
45
|
+
push(value) {
|
|
46
|
+
if (this.terminal)
|
|
47
|
+
return false;
|
|
48
|
+
if (this.pending.length >= this.limit)
|
|
49
|
+
return false;
|
|
50
|
+
if (this.pullWaiting && this.controller) {
|
|
51
|
+
this.pullWaiting = false;
|
|
52
|
+
this.controller.enqueue(value);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
this.pending.push(value);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
close(discardReason = new Error('queue closed')) {
|
|
59
|
+
if (this.terminal)
|
|
60
|
+
return;
|
|
61
|
+
this.terminal = true;
|
|
62
|
+
this.pullWaiting = false;
|
|
63
|
+
void this.discardPending(discardReason);
|
|
64
|
+
this.controller?.close();
|
|
65
|
+
}
|
|
66
|
+
error(reason, discardReason = reason) {
|
|
67
|
+
if (this.terminal)
|
|
68
|
+
return;
|
|
69
|
+
this.terminal = true;
|
|
70
|
+
this.pullWaiting = false;
|
|
71
|
+
void this.discardPending(discardReason);
|
|
72
|
+
this.controller?.error(reason);
|
|
73
|
+
}
|
|
74
|
+
async discardPending(reason) {
|
|
75
|
+
const pending = this.pending.splice(0);
|
|
76
|
+
if (!this.onDiscard)
|
|
77
|
+
return;
|
|
78
|
+
await Promise.allSettled(pending.map((value) => this.onDiscard(value, reason)));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Web-Streams facade over one Node QUIC session. */
|
|
82
|
+
export class NodeQuicTransport {
|
|
83
|
+
session;
|
|
84
|
+
setupOptions;
|
|
85
|
+
incomingUni;
|
|
86
|
+
incomingBidi;
|
|
87
|
+
incomingDatagrams;
|
|
88
|
+
kind = 'quic';
|
|
89
|
+
protocol = 'moqt-18';
|
|
90
|
+
maxDatagramSize;
|
|
91
|
+
incomingUnidirectionalStreams;
|
|
92
|
+
incomingBidirectionalStreams;
|
|
93
|
+
datagrams;
|
|
94
|
+
closed;
|
|
95
|
+
localCloseInfo = null;
|
|
96
|
+
closeStarted = false;
|
|
97
|
+
constructor(session, setupOptions, incomingUni, incomingBidi, incomingDatagrams, sessionError) {
|
|
98
|
+
this.session = session;
|
|
99
|
+
this.setupOptions = setupOptions;
|
|
100
|
+
this.incomingUni = incomingUni;
|
|
101
|
+
this.incomingBidi = incomingBidi;
|
|
102
|
+
this.incomingDatagrams = incomingDatagrams;
|
|
103
|
+
this.maxDatagramSize = session.maxDatagramSize;
|
|
104
|
+
this.incomingUnidirectionalStreams = incomingUni.readable;
|
|
105
|
+
this.incomingBidirectionalStreams = incomingBidi.readable;
|
|
106
|
+
let datagramController;
|
|
107
|
+
const datagramWritable = new WritableStream({
|
|
108
|
+
start: (controller) => { datagramController = controller; },
|
|
109
|
+
write: async (data) => {
|
|
110
|
+
if (data.byteLength === 0 || data.byteLength > this.maxDatagramSize) {
|
|
111
|
+
throw new RangeError(`QUIC datagram length ${data.byteLength} exceeds negotiated limit ${this.maxDatagramSize}`);
|
|
112
|
+
}
|
|
113
|
+
const id = await session.sendDatagram(data);
|
|
114
|
+
if (id === 0n)
|
|
115
|
+
throw new Error('native QUIC backend refused the datagram');
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
this.datagrams = {
|
|
119
|
+
readable: incomingDatagrams.readable,
|
|
120
|
+
writable: datagramWritable,
|
|
121
|
+
};
|
|
122
|
+
void session.closed.then(() => datagramController.error(new Error('native QUIC session closed')), (error) => datagramController.error(asError(error, 'native QUIC session failed')));
|
|
123
|
+
this.closed = session.closed.then(() => this.localCloseInfo ?? { closeCode: 0, reason: '' }, (error) => {
|
|
124
|
+
const failure = sessionError() ?? error;
|
|
125
|
+
const application = applicationCloseInfo(failure);
|
|
126
|
+
if (application)
|
|
127
|
+
return application;
|
|
128
|
+
throw failure;
|
|
129
|
+
});
|
|
130
|
+
// Consumers still observe rejection through `closed`; this attached
|
|
131
|
+
// branch only prevents a race with an error close before they attach.
|
|
132
|
+
void this.closed.catch(() => { });
|
|
133
|
+
void session.closed.then(() => this.closeIncoming(), (error) => this.errorIncoming(sessionError() ?? error));
|
|
134
|
+
}
|
|
135
|
+
async createBidirectionalStream() {
|
|
136
|
+
const stream = await this.session.createBidirectionalStream();
|
|
137
|
+
if (stream.direction !== 'bidi') {
|
|
138
|
+
stream.resetStream(1n);
|
|
139
|
+
throw new Error('native QUIC backend returned a non-bidirectional stream');
|
|
140
|
+
}
|
|
141
|
+
return wrapBidirectional(stream);
|
|
142
|
+
}
|
|
143
|
+
async createUnidirectionalStream() {
|
|
144
|
+
const stream = await this.session.createUnidirectionalStream();
|
|
145
|
+
if (stream.direction !== 'uni') {
|
|
146
|
+
stream.resetStream(1n);
|
|
147
|
+
throw new Error('native QUIC backend returned a non-unidirectional stream');
|
|
148
|
+
}
|
|
149
|
+
return wrapWritable(stream);
|
|
150
|
+
}
|
|
151
|
+
close(info = {}) {
|
|
152
|
+
if (this.closeStarted)
|
|
153
|
+
return;
|
|
154
|
+
this.closeStarted = true;
|
|
155
|
+
const closeCode = info.closeCode ?? 0;
|
|
156
|
+
const reason = info.reason ?? '';
|
|
157
|
+
this.localCloseInfo = { closeCode, reason };
|
|
158
|
+
this.session.destroy(undefined, { code: closeCode, type: 'application', reason });
|
|
159
|
+
}
|
|
160
|
+
closeIncoming() {
|
|
161
|
+
this.incomingUni.close(0x3n);
|
|
162
|
+
this.incomingBidi.close(0x3n);
|
|
163
|
+
this.incomingDatagrams.close();
|
|
164
|
+
}
|
|
165
|
+
errorIncoming(error) {
|
|
166
|
+
this.incomingUni.error(error, 0x0n);
|
|
167
|
+
this.incomingBidi.error(error, 0x0n);
|
|
168
|
+
this.incomingDatagrams.error(error);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export function routeNativeStream(stream, incomingUni, incomingBidi) {
|
|
172
|
+
if (stream.direction === 'uni')
|
|
173
|
+
return incomingUni.push(wrapReadable(stream));
|
|
174
|
+
if (stream.direction === 'bidi')
|
|
175
|
+
return incomingBidi.push(wrapBidirectional(stream));
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
function wrapBidirectional(stream) {
|
|
179
|
+
return { readable: wrapReadable(stream), writable: wrapWritable(stream) };
|
|
180
|
+
}
|
|
181
|
+
function wrapReadable(stream) {
|
|
182
|
+
let iterator = null;
|
|
183
|
+
const queued = [];
|
|
184
|
+
let resetError;
|
|
185
|
+
stream.onreset = (error) => { resetError = error; };
|
|
186
|
+
return new ReadableStream({
|
|
187
|
+
async pull(controller) {
|
|
188
|
+
if (queued.length > 0) {
|
|
189
|
+
controller.enqueue(queued.shift());
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
iterator ??= stream[Symbol.asyncIterator]();
|
|
194
|
+
const { value, done } = await iterator.next();
|
|
195
|
+
if (done) {
|
|
196
|
+
if (resetError !== undefined) {
|
|
197
|
+
controller.error(normalizeStreamError(resetError));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Node can expose a reset-only incoming unidirectional stream as
|
|
201
|
+
// iterator EOF while preserving the peer code on `closed`. Unlike a
|
|
202
|
+
// bidirectional stream, a receive-only stream has no local send half
|
|
203
|
+
// that could keep `closed` pending after a genuine peer FIN.
|
|
204
|
+
if (stream.direction === 'uni') {
|
|
205
|
+
try {
|
|
206
|
+
await stream.closed;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
controller.error(normalizeStreamError(resetError ?? error));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
controller.close();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
for (const chunk of value)
|
|
217
|
+
queued.push(chunk);
|
|
218
|
+
if (queued.length > 0)
|
|
219
|
+
controller.enqueue(queued.shift());
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
controller.error(normalizeStreamError(resetError ?? error));
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
async cancel(reason) {
|
|
226
|
+
try {
|
|
227
|
+
stream.stopSending(applicationCode(reason));
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
await iterator?.return?.();
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function wrapWritable(stream) {
|
|
236
|
+
let stopError;
|
|
237
|
+
let locallyTerminal = false;
|
|
238
|
+
let controller;
|
|
239
|
+
const writable = new WritableStream({
|
|
240
|
+
start(value) {
|
|
241
|
+
controller = value;
|
|
242
|
+
},
|
|
243
|
+
async write(chunk) {
|
|
244
|
+
try {
|
|
245
|
+
await writeWithBackpressure(stream.writer, chunk, controller.signal);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
throw normalizeWriteError(stopError ?? error);
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
async close() {
|
|
252
|
+
locallyTerminal = true;
|
|
253
|
+
try {
|
|
254
|
+
await stream.writer.end();
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
throw normalizeWriteError(stopError ?? error);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
abort(reason) {
|
|
261
|
+
locallyTerminal = true;
|
|
262
|
+
stream.resetStream(applicationCode(reason));
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
stream.onstopsending = (error) => {
|
|
266
|
+
locallyTerminal = true;
|
|
267
|
+
const normalized = normalizeWriteError(error);
|
|
268
|
+
stopError = normalized;
|
|
269
|
+
controller.error(normalized);
|
|
270
|
+
try {
|
|
271
|
+
stream.resetStream(applicationCode(normalized));
|
|
272
|
+
}
|
|
273
|
+
catch { /* already closed */ }
|
|
274
|
+
};
|
|
275
|
+
void stream.closed.then(() => {
|
|
276
|
+
if (!locallyTerminal)
|
|
277
|
+
controller.error(new Error('native QUIC stream closed'));
|
|
278
|
+
}, (error) => {
|
|
279
|
+
if (!locallyTerminal)
|
|
280
|
+
controller.error(normalizeWriteError(stopError ?? error));
|
|
281
|
+
});
|
|
282
|
+
return writable;
|
|
283
|
+
}
|
|
284
|
+
/** Wait for Node's native writer budget instead of treating flow control as failure. */
|
|
285
|
+
async function writeWithBackpressure(writer, chunk, signal) {
|
|
286
|
+
// Node 26.8.1 throws from write() when the native buffer is full. Its
|
|
287
|
+
// stream/iter writer exposes the corresponding drain promise on this symbol.
|
|
288
|
+
while (writer.canWrite === false) {
|
|
289
|
+
const drain = writer[DRAINABLE_PROTOCOL];
|
|
290
|
+
if (typeof drain !== 'function') {
|
|
291
|
+
throw new Error('native QUIC writer is flow-controlled but exposes no drain protocol');
|
|
292
|
+
}
|
|
293
|
+
const pending = drain.call(writer);
|
|
294
|
+
if (pending) {
|
|
295
|
+
await raceAbort(pending, signal);
|
|
296
|
+
}
|
|
297
|
+
else if (writer.canWrite === null) {
|
|
298
|
+
throw new Error('native QUIC writer closed while waiting for flow control');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
await raceAbort(writer.write(chunk), signal);
|
|
302
|
+
}
|
|
303
|
+
async function raceAbort(operation, signal) {
|
|
304
|
+
if (signal.aborted)
|
|
305
|
+
throw signal.reason;
|
|
306
|
+
let rejectAbort;
|
|
307
|
+
const aborted = new Promise((_resolve, reject) => { rejectAbort = reject; });
|
|
308
|
+
const onAbort = () => rejectAbort(signal.reason);
|
|
309
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
310
|
+
try {
|
|
311
|
+
return await Promise.race([operation, aborted]);
|
|
312
|
+
}
|
|
313
|
+
finally {
|
|
314
|
+
signal.removeEventListener('abort', onAbort);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function applicationCode(reason) {
|
|
318
|
+
return extractApplicationCode(reason) ?? 0n;
|
|
319
|
+
}
|
|
320
|
+
function extractApplicationCode(reason) {
|
|
321
|
+
if (typeof reason === 'bigint' && reason >= 0n)
|
|
322
|
+
return reason;
|
|
323
|
+
if (typeof reason === 'number' && Number.isSafeInteger(reason) && reason >= 0)
|
|
324
|
+
return BigInt(reason);
|
|
325
|
+
if (reason && typeof reason === 'object') {
|
|
326
|
+
const object = reason;
|
|
327
|
+
return extractApplicationCode(object.streamErrorCode ?? object.errorCode);
|
|
328
|
+
}
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
function normalizeStreamError(error) {
|
|
332
|
+
const code = extractQuicApplicationCode(error);
|
|
333
|
+
if (code !== undefined) {
|
|
334
|
+
// draft-18 §14: unknown error codes are handled as INTERNAL_ERROR in
|
|
335
|
+
// their context. Preserve the native bigint separately for diagnostics.
|
|
336
|
+
const mapped = STREAM_RESET_CODES.has(code) ? code : STREAM_INTERNAL_ERROR;
|
|
337
|
+
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
338
|
+
try {
|
|
339
|
+
Object.defineProperties(normalized, {
|
|
340
|
+
streamErrorCode: { value: Number(mapped), configurable: true },
|
|
341
|
+
quicErrorCode: { value: code, configurable: true },
|
|
342
|
+
});
|
|
343
|
+
return normalized;
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
const copy = new Error(normalized.message, { cause: normalized });
|
|
347
|
+
copy.name = normalized.name;
|
|
348
|
+
Object.defineProperties(copy, {
|
|
349
|
+
streamErrorCode: { value: Number(mapped), configurable: true },
|
|
350
|
+
quicErrorCode: { value: code, configurable: true },
|
|
351
|
+
});
|
|
352
|
+
return copy;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return error;
|
|
356
|
+
}
|
|
357
|
+
function extractQuicApplicationCode(error) {
|
|
358
|
+
if (typeof error === 'bigint' || typeof error === 'number') {
|
|
359
|
+
return extractApplicationCode(error);
|
|
360
|
+
}
|
|
361
|
+
if (!error || typeof error !== 'object')
|
|
362
|
+
return undefined;
|
|
363
|
+
const candidate = error;
|
|
364
|
+
if (candidate.quicErrorCode !== undefined) {
|
|
365
|
+
return extractApplicationCode(candidate.quicErrorCode);
|
|
366
|
+
}
|
|
367
|
+
if (candidate.streamErrorCode !== undefined) {
|
|
368
|
+
return extractApplicationCode(candidate.streamErrorCode);
|
|
369
|
+
}
|
|
370
|
+
if (candidate.type === 'application') {
|
|
371
|
+
return extractApplicationCode(candidate.errorCode);
|
|
372
|
+
}
|
|
373
|
+
return undefined;
|
|
374
|
+
}
|
|
375
|
+
function normalizeWriteError(error) {
|
|
376
|
+
const normalized = normalizeStreamError(error);
|
|
377
|
+
return normalized instanceof Error ? normalized : new Error(String(normalized));
|
|
378
|
+
}
|
|
379
|
+
function asError(error, fallback) {
|
|
380
|
+
return error instanceof Error ? error : new Error(error === undefined ? fallback : String(error));
|
|
381
|
+
}
|
|
382
|
+
function applicationCloseInfo(error) {
|
|
383
|
+
if (!error || typeof error !== 'object')
|
|
384
|
+
return null;
|
|
385
|
+
const candidate = error;
|
|
386
|
+
if (candidate.type !== 'application')
|
|
387
|
+
return null;
|
|
388
|
+
const code = extractApplicationCode(candidate.errorCode);
|
|
389
|
+
if (code === undefined)
|
|
390
|
+
return null;
|
|
391
|
+
const reason = typeof candidate.reason === 'string'
|
|
392
|
+
? candidate.reason
|
|
393
|
+
: typeof candidate.message === 'string' ? candidate.message : '';
|
|
394
|
+
if (!SESSION_ERROR_CODES.has(code)) {
|
|
395
|
+
return {
|
|
396
|
+
closeCode: Number(SESSION_INTERNAL_ERROR),
|
|
397
|
+
reason: `unknown session error code ${code}; treated as INTERNAL_ERROR${reason ? `: ${reason}` : ''}`,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
closeCode: Number(code),
|
|
402
|
+
reason,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAOA,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAClE,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,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L,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC;QACvB,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@moqt/quic",
|
|
3
|
+
"version": "0.5.7",
|
|
4
|
+
"description": "Experimental Node.js native QUIC binding for Media over QUIC Transport (MoQT).",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "OpenMOQ (https://github.com/openmoq)",
|
|
7
|
+
"contributors": [
|
|
8
|
+
"Raymond Lucke <ray@raylucke.com>"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"moq",
|
|
24
|
+
"media-over-quic",
|
|
25
|
+
"moqt",
|
|
26
|
+
"quic",
|
|
27
|
+
"node"
|
|
28
|
+
],
|
|
29
|
+
"homepage": "https://github.com/openmoq/moq-playa/tree/main/packages/quic#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/openmoq/moq-playa/issues"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/openmoq/moq-playa.git",
|
|
36
|
+
"directory": "packages/quic"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@moqt/webtransport": "0.5.7"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=26.8.1"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc"
|
|
49
|
+
}
|
|
50
|
+
}
|