@moq/net 0.3.5 → 0.4.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.
- package/announce.d.ts +7 -0
- package/announce.d.ts.map +1 -0
- package/announce.js +8 -0
- package/announce.js.map +1 -0
- package/announced.d.ts +35 -91
- package/announced.d.ts.map +1 -1
- package/announced.js +21 -156
- package/announced.js.map +1 -1
- package/bandwidth.d.ts +163 -0
- package/bandwidth.d.ts.map +1 -0
- package/bandwidth.js +304 -0
- package/bandwidth.js.map +1 -0
- package/bandwidth_api.d.ts +7 -0
- package/bandwidth_api.d.ts.map +1 -0
- package/bandwidth_api.js +8 -0
- package/bandwidth_api.js.map +1 -0
- package/broadcast.d.ts +20 -28
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +55 -38
- package/broadcast.js.map +1 -1
- package/connection/accept.d.ts +16 -1
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +39 -24
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +9 -7
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +30 -6
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +85 -45
- package/connection/connect.js.map +1 -1
- package/connection/established.d.ts +16 -21
- package/connection/established.d.ts.map +1 -1
- package/connection/established.js.map +1 -1
- package/connection/forward.d.ts +2 -0
- package/connection/forward.d.ts.map +1 -0
- package/connection/forward.js +159 -0
- package/connection/forward.js.map +1 -0
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +2 -2
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +5 -5
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +4 -5
- package/connection/index.js.map +1 -1
- package/connection/pool.d.ts +188 -0
- package/connection/pool.d.ts.map +1 -0
- package/connection/pool.js +351 -0
- package/connection/pool.js.map +1 -0
- package/connection/reload.d.ts +14 -93
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +216 -80
- package/connection/reload.js.map +1 -1
- package/connection/stats.d.ts +3 -26
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js.map +1 -1
- package/connection/transport.d.ts +0 -7
- package/connection/transport.d.ts.map +1 -1
- package/consume.d.ts +1 -43
- package/consume.d.ts.map +1 -1
- package/consume.js +1 -1
- package/consume.js.map +1 -1
- package/error.d.ts +180 -29
- package/error.d.ts.map +1 -1
- package/error.js +310 -16
- package/error.js.map +1 -1
- package/errors.d.ts +7 -0
- package/errors.d.ts.map +1 -0
- package/errors.js +8 -0
- package/errors.js.map +1 -0
- package/group.d.ts +9 -43
- package/group.d.ts.map +1 -1
- package/group.js +283 -69
- package/group.js.map +1 -1
- package/hop.d.ts +107 -0
- package/hop.d.ts.map +1 -0
- package/hop.js +103 -0
- package/hop.js.map +1 -0
- package/ietf/aliases.d.ts +1 -78
- package/ietf/aliases.d.ts.map +1 -1
- package/ietf/cluster.d.ts +6 -120
- package/ietf/cluster.d.ts.map +1 -1
- package/ietf/cluster.js +81 -41
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +6 -72
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +11 -47
- package/ietf/connection.js.map +1 -1
- package/ietf/error.d.ts +11 -0
- package/ietf/error.d.ts.map +1 -0
- package/ietf/error.js +168 -0
- package/ietf/error.js.map +1 -0
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +6 -1
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -5
- package/ietf/goaway.js.map +1 -1
- package/ietf/parameters.d.ts +2 -2
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +15 -17
- package/ietf/parameters.js.map +1 -1
- package/ietf/publish_namespace.d.ts +25 -0
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +63 -0
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.d.ts +1 -82
- package/ietf/publisher.d.ts.map +1 -1
- package/ietf/publisher.js +203 -136
- package/ietf/publisher.js.map +1 -1
- package/ietf/solicit.d.ts +1 -40
- package/ietf/solicit.d.ts.map +1 -1
- package/ietf/subscribe.d.ts +1 -5
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +8 -9
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscriber.d.ts +1 -65
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +154 -73
- package/ietf/subscriber.js.map +1 -1
- package/ietf/version.d.ts +12 -1
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +13 -0
- package/ietf/version.js.map +1 -1
- package/index.d.ts +11 -6
- package/index.d.ts.map +1 -1
- package/index.js +10 -5
- package/index.js.map +1 -1
- package/internal.d.ts +97 -1
- package/internal.d.ts.map +1 -1
- package/internal.js +65 -0
- package/internal.js.map +1 -1
- package/lite/announce.d.ts +15 -9
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +47 -20
- package/lite/announce.js.map +1 -1
- package/lite/connection.d.ts +9 -59
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +20 -32
- package/lite/connection.js.map +1 -1
- package/lite/fetch.d.ts +15 -1
- package/lite/fetch.d.ts.map +1 -1
- package/lite/fetch.js +39 -7
- package/lite/fetch.js.map +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +7 -1
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +18 -4
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +31 -10
- package/lite/group.js.map +1 -1
- package/lite/priority.d.ts +1 -61
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +4 -5
- package/lite/priority.js.map +1 -1
- package/lite/publisher.d.ts +1 -69
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +507 -200
- package/lite/publisher.js.map +1 -1
- package/lite/setup.d.ts +7 -7
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +13 -13
- package/lite/setup.js.map +1 -1
- package/lite/subscribe.d.ts +61 -13
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +186 -44
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +8 -57
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +179 -117
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +4 -10
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +34 -29
- package/lite/track.js.map +1 -1
- package/lite/version.d.ts +31 -6
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +71 -11
- package/lite/version.js.map +1 -1
- package/origin.d.ts +229 -29
- package/origin.d.ts.map +1 -1
- package/origin.js +1087 -37
- package/origin.js.map +1 -1
- package/package.json +3 -2
- package/path.d.ts +25 -7
- package/path.d.ts.map +1 -1
- package/path.js +5 -3
- package/path.js.map +1 -1
- package/stream.d.ts.map +1 -1
- package/stream.js +23 -14
- package/stream.js.map +1 -1
- package/time.d.ts +15 -2
- package/time.d.ts.map +1 -1
- package/time.js +28 -9
- package/time.js.map +1 -1
- package/track.d.ts +166 -83
- package/track.d.ts.map +1 -1
- package/track.js +617 -187
- package/track.js.map +1 -1
- package/wire.d.ts +67 -0
- package/wire.d.ts.map +1 -0
- package/wire.js +32 -0
- package/wire.js.map +1 -0
- package/zod.d.ts +1 -1
- package/zod.d.ts.map +1 -1
- package/zod.js.map +1 -1
- package/mock.d.ts +0 -66
- package/mock.d.ts.map +0 -1
- package/mock.js +0 -243
- package/mock.js.map +0 -1
package/connection/connect.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/* @ts-self-types="./connect.d.ts" */
|
|
2
2
|
import Session from "@moq/qmux";
|
|
3
|
+
import { error, fromClose } from "../error.js";
|
|
3
4
|
import * as Ietf from "../ietf/index.js";
|
|
4
5
|
import * as Lite from "../lite/index.js";
|
|
5
6
|
import { Stream } from "../stream.js";
|
|
7
|
+
import * as Time from "../time.js";
|
|
6
8
|
import * as Hex from "../util/hex.js";
|
|
7
9
|
import { dev, redact } from "../util/log.js";
|
|
8
10
|
import { isWebTransportSupported } from "./browser.js";
|
|
11
|
+
import { forwardAnnounced } from "./forward.js";
|
|
9
12
|
import { exchangeSetup } from "./handshake.js";
|
|
10
13
|
// Default head start for WebTransport before attempting the WebSocket fallback.
|
|
11
|
-
const DEFAULT_WEBSOCKET_DELAY_MS = 500;
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
const NO_DISCOVERY_HOSTS = ["mediaoverquic.com"];
|
|
16
|
-
/** Whether the relay at `url` is expected to support broadcast discovery. */
|
|
17
|
-
function defaultDiscovery(url) {
|
|
18
|
-
return !NO_DISCOVERY_HOSTS.some((host) => url.hostname.endsWith(host));
|
|
19
|
-
}
|
|
14
|
+
const DEFAULT_WEBSOCKET_DELAY_MS = Time.Milli(500);
|
|
15
|
+
// RESET_STREAM and CONNECTION_CLOSE are separate transport notifications. Give the latter
|
|
16
|
+
// time to surface its authoritative code without letting a reset-only peer stall SETUP forever.
|
|
17
|
+
const SETUP_CLOSE_GRACE_MS = 100;
|
|
20
18
|
// Save if WebSocket won the last race, so we won't give QUIC a head start next time.
|
|
21
19
|
const websocketWon = new Set();
|
|
22
20
|
/** The default connect signal: never aborts. */
|
|
@@ -26,10 +24,10 @@ const NEVER_ABORTED = new AbortController().signal;
|
|
|
26
24
|
*
|
|
27
25
|
* @param url - The URL of the server to connect to
|
|
28
26
|
* @param props - Connection options
|
|
29
|
-
* @returns A promise that resolves to
|
|
27
|
+
* @returns A promise that resolves to an established session
|
|
30
28
|
*/
|
|
31
|
-
export async function connect(url, props) {
|
|
32
|
-
const signal = props
|
|
29
|
+
export async function connect({ url, ...props }) {
|
|
30
|
+
const signal = props.signal ?? NEVER_ABORTED;
|
|
33
31
|
signal.throwIfAborted();
|
|
34
32
|
// Resolves on abort so every in-flight transport tears itself down.
|
|
35
33
|
const { promise: abort, resolve } = Promise.withResolvers();
|
|
@@ -39,8 +37,11 @@ export async function connect(url, props) {
|
|
|
39
37
|
try {
|
|
40
38
|
// A `pending` rejection propagates unless the abort beat it to the finish line.
|
|
41
39
|
const connection = await Promise.race([pending, abort.then(() => undefined)]);
|
|
42
|
-
if (connection && !signal.aborted)
|
|
40
|
+
if (connection && !signal.aborted) {
|
|
41
|
+
if (props.consume)
|
|
42
|
+
forwardAnnounced(connection, props.consume);
|
|
43
43
|
return connection;
|
|
44
|
+
}
|
|
44
45
|
// Close a connection that settles after the abort.
|
|
45
46
|
pending.then((conn) => conn.close()).catch(() => { });
|
|
46
47
|
throw signal.reason;
|
|
@@ -50,21 +51,24 @@ export async function connect(url, props) {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
async function connectInner(url, props, abort) {
|
|
53
|
-
const
|
|
54
|
-
|
|
54
|
+
const wiring = {
|
|
55
|
+
discovery: props.discovery ?? true,
|
|
56
|
+
publish: props.publish,
|
|
57
|
+
};
|
|
58
|
+
if (props.transport) {
|
|
55
59
|
const transport = props.transport;
|
|
56
60
|
void abort.then(() => transport.close());
|
|
57
|
-
return connectTransport(url, transport,
|
|
61
|
+
return connectTransport(url, transport, wiring);
|
|
58
62
|
}
|
|
59
63
|
// Stop transports after one connects or the caller aborts.
|
|
60
64
|
const { promise: raced, resolve: done } = Promise.withResolvers();
|
|
61
65
|
const cancel = Promise.race([raced, abort]);
|
|
62
|
-
const webtransport = isWebTransportSupported() ? connectWebTransport(url, cancel, props
|
|
66
|
+
const webtransport = isWebTransportSupported() ? connectWebTransport(url, cancel, props.webtransport) : undefined;
|
|
63
67
|
// Give QUIC a head start to connect before trying WebSocket, unless WebSocket has won in the past.
|
|
64
68
|
// NOTE that QUIC should be faster because it involves 1/2 fewer RTTs.
|
|
65
|
-
const headstart = !webtransport || websocketWon.has(url.toString()) ? 0 : (props
|
|
66
|
-
const websocket = props
|
|
67
|
-
? connectWebSocket(props
|
|
69
|
+
const headstart = !webtransport || websocketWon.has(url.toString()) ? 0 : (props.websocket?.delay ?? DEFAULT_WEBSOCKET_DELAY_MS);
|
|
70
|
+
const websocket = props.websocket?.enabled !== false
|
|
71
|
+
? connectWebSocket(props.websocket?.url ?? url, headstart, cancel)
|
|
68
72
|
: undefined;
|
|
69
73
|
if (!websocket && !webtransport) {
|
|
70
74
|
throw new Error("no transport available; WebTransport not supported and WebSocket is disabled");
|
|
@@ -93,9 +97,37 @@ async function connectInner(url, props, abort) {
|
|
|
93
97
|
console.debug(redact(url), "connected via WebTransport");
|
|
94
98
|
}
|
|
95
99
|
// The remaining setup is identical whether the transport was raced or supplied.
|
|
96
|
-
return await connectTransport(url, session,
|
|
100
|
+
return await connectTransport(url, session, wiring);
|
|
101
|
+
}
|
|
102
|
+
async function connectTransport(url, session, wiring) {
|
|
103
|
+
const closed = session.closed.then(fromClose, error);
|
|
104
|
+
const terminal = closed.then((cause) => {
|
|
105
|
+
throw cause ?? new Error("session closed during SETUP");
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
return await Promise.race([terminal, negotiate(url, session, wiring)]);
|
|
109
|
+
}
|
|
110
|
+
catch (cause) {
|
|
111
|
+
// A session shutdown can reject its SETUP stream before `closed` publishes the
|
|
112
|
+
// peer's close code. Wait briefly without closing locally, since a local clean close
|
|
113
|
+
// could overwrite that code. A reset-only peer is cleaned up after the grace period.
|
|
114
|
+
const pending = Symbol("session close pending");
|
|
115
|
+
const final = await Promise.race([
|
|
116
|
+
closed,
|
|
117
|
+
new Promise((resolve) => setTimeout(() => resolve(pending), SETUP_CLOSE_GRACE_MS)),
|
|
118
|
+
]);
|
|
119
|
+
if (final !== pending) {
|
|
120
|
+
if (final)
|
|
121
|
+
throw final;
|
|
122
|
+
throw cause;
|
|
123
|
+
}
|
|
124
|
+
session.close();
|
|
125
|
+
throw cause;
|
|
126
|
+
}
|
|
97
127
|
}
|
|
98
|
-
|
|
128
|
+
// Negotiate the MoQ protocol over an established transport. The caller races this against
|
|
129
|
+
// the session closing so a close code is not lost behind a failed or stalled SETUP stream.
|
|
130
|
+
async function negotiate(url, session, wiring) {
|
|
99
131
|
// qmux Session exposes the negotiated protocol directly (as "" when there is none);
|
|
100
132
|
// native WebTransport doesn't have a standard .protocol property yet.
|
|
101
133
|
const protocol = session.protocol || undefined;
|
|
@@ -103,17 +135,21 @@ async function connectTransport(url, session, discovery) {
|
|
|
103
135
|
console.debug(redact(url), "negotiated ALPN:", protocol ?? "(none)");
|
|
104
136
|
// Choose setup encoding based on negotiated WebTransport protocol (if any).
|
|
105
137
|
let setupVersion;
|
|
106
|
-
const modernVersion = protocol === Ietf.ALPN.
|
|
107
|
-
? Ietf.Version.
|
|
108
|
-
: protocol === Ietf.ALPN.
|
|
109
|
-
? Ietf.Version.
|
|
110
|
-
: protocol === Ietf.ALPN.
|
|
111
|
-
? Ietf.Version.
|
|
112
|
-
: protocol === Ietf.ALPN.
|
|
113
|
-
? Ietf.Version.
|
|
114
|
-
:
|
|
138
|
+
const modernVersion = protocol === Ietf.ALPN.DRAFT_22
|
|
139
|
+
? Ietf.Version.DRAFT_22
|
|
140
|
+
: protocol === Ietf.ALPN.DRAFT_21
|
|
141
|
+
? Ietf.Version.DRAFT_21
|
|
142
|
+
: protocol === Ietf.ALPN.DRAFT_20
|
|
143
|
+
? Ietf.Version.DRAFT_20
|
|
144
|
+
: protocol === Ietf.ALPN.DRAFT_19
|
|
145
|
+
? Ietf.Version.DRAFT_19
|
|
146
|
+
: protocol === Ietf.ALPN.DRAFT_18
|
|
147
|
+
? Ietf.Version.DRAFT_18
|
|
148
|
+
: protocol === Ietf.ALPN.DRAFT_17
|
|
149
|
+
? Ietf.Version.DRAFT_17
|
|
150
|
+
: undefined;
|
|
115
151
|
if (modernVersion !== undefined) {
|
|
116
|
-
return await handshakeAlpn(url, session, modernVersion,
|
|
152
|
+
return await handshakeAlpn(url, session, modernVersion, wiring);
|
|
117
153
|
}
|
|
118
154
|
else if (protocol === Ietf.ALPN.DRAFT_16) {
|
|
119
155
|
setupVersion = Ietf.Version.DRAFT_16;
|
|
@@ -121,17 +157,17 @@ async function connectTransport(url, session, discovery) {
|
|
|
121
157
|
else if (protocol === Ietf.ALPN.DRAFT_15) {
|
|
122
158
|
setupVersion = Ietf.Version.DRAFT_15;
|
|
123
159
|
}
|
|
124
|
-
else if (protocol === Lite.
|
|
125
|
-
return new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_06,
|
|
160
|
+
else if (protocol === Lite.ALPN_06) {
|
|
161
|
+
return new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_06, ...wiring });
|
|
126
162
|
}
|
|
127
163
|
else if (protocol === Lite.ALPN_05) {
|
|
128
|
-
return new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_05,
|
|
164
|
+
return new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_05, ...wiring });
|
|
129
165
|
}
|
|
130
166
|
else if (protocol === Lite.ALPN_04) {
|
|
131
|
-
return new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_04,
|
|
167
|
+
return new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_04, ...wiring });
|
|
132
168
|
}
|
|
133
169
|
else if (protocol === Lite.ALPN_03) {
|
|
134
|
-
return new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_03,
|
|
170
|
+
return new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_03, ...wiring });
|
|
135
171
|
}
|
|
136
172
|
else if (protocol === Lite.ALPN || protocol === "" || protocol === undefined) {
|
|
137
173
|
setupVersion = Ietf.Version.DRAFT_14;
|
|
@@ -166,13 +202,13 @@ async function connectTransport(url, session, discovery) {
|
|
|
166
202
|
quic: session,
|
|
167
203
|
version: server.version,
|
|
168
204
|
session: stream,
|
|
169
|
-
|
|
205
|
+
...wiring,
|
|
170
206
|
});
|
|
171
207
|
}
|
|
172
208
|
else if (Object.values(Ietf.Version).includes(server.version)) {
|
|
173
209
|
const maxRequestId = server.parameters.getVarint(Ietf.SetupOption.MaxRequestId) ?? 0n;
|
|
174
210
|
return new Ietf.Connection({
|
|
175
|
-
|
|
211
|
+
...wiring,
|
|
176
212
|
client: true,
|
|
177
213
|
url,
|
|
178
214
|
quic: session,
|
|
@@ -190,10 +226,10 @@ async function connectTransport(url, session, discovery) {
|
|
|
190
226
|
* Draft-17+ client handshake. ALPN already pinned the version; SETUP is
|
|
191
227
|
* exchanged over a pair of uni streams using stream type 0x2F00.
|
|
192
228
|
*/
|
|
193
|
-
async function handshakeAlpn(url, session, version,
|
|
229
|
+
async function handshakeAlpn(url, session, version, wiring) {
|
|
194
230
|
const { control, solicit, cluster } = await exchangeSetup(session, version, "moq-lite-js");
|
|
195
231
|
return new Ietf.Connection({
|
|
196
|
-
|
|
232
|
+
...wiring,
|
|
197
233
|
client: true,
|
|
198
234
|
url,
|
|
199
235
|
quic: session,
|
|
@@ -248,12 +284,13 @@ async function connectWebTransport(url, cancel, options) {
|
|
|
248
284
|
allowPooling: false,
|
|
249
285
|
congestionControl: "low-latency",
|
|
250
286
|
protocols: [
|
|
251
|
-
|
|
252
|
-
// not advertised by default (connect.ts still accepts it if a server negotiates it).
|
|
287
|
+
Lite.ALPN_06,
|
|
253
288
|
Lite.ALPN_05,
|
|
254
289
|
Lite.ALPN_04,
|
|
255
290
|
Lite.ALPN_03,
|
|
256
291
|
Lite.ALPN,
|
|
292
|
+
Ietf.ALPN.DRAFT_22,
|
|
293
|
+
Ietf.ALPN.DRAFT_21,
|
|
257
294
|
Ietf.ALPN.DRAFT_20,
|
|
258
295
|
Ietf.ALPN.DRAFT_19,
|
|
259
296
|
Ietf.ALPN.DRAFT_18,
|
|
@@ -312,18 +349,21 @@ async function connectWebSocket(url, delay, cancel) {
|
|
|
312
349
|
const active = await Promise.race([cancel, timer.then(() => true)]);
|
|
313
350
|
if (!active)
|
|
314
351
|
return undefined;
|
|
315
|
-
//
|
|
352
|
+
// moq-transport-18 and newer are pinned to qmux-01. Every other ALPN we
|
|
316
353
|
// support is currently negotiated as `qmux-00.{alpn}` on the wire, but we
|
|
317
354
|
// don't want to lock that in: set the value to `null` so the polyfill
|
|
318
355
|
// advertises every QMux draft it knows about and the server picks one.
|
|
319
356
|
// Insertion order is the negotiation preference on the wire.
|
|
320
357
|
const versions = {
|
|
321
|
-
|
|
358
|
+
[Lite.ALPN_06]: null,
|
|
322
359
|
[Lite.ALPN_05]: null,
|
|
323
360
|
[Lite.ALPN_04]: null,
|
|
324
361
|
[Lite.ALPN_03]: null,
|
|
325
362
|
[Lite.ALPN]: null,
|
|
363
|
+
[Ietf.ALPN.DRAFT_22]: "qmux-01",
|
|
364
|
+
[Ietf.ALPN.DRAFT_21]: "qmux-01",
|
|
326
365
|
[Ietf.ALPN.DRAFT_20]: "qmux-01",
|
|
366
|
+
[Ietf.ALPN.DRAFT_19]: "qmux-01",
|
|
327
367
|
[Ietf.ALPN.DRAFT_18]: "qmux-01",
|
|
328
368
|
[Ietf.ALPN.DRAFT_17]: null,
|
|
329
369
|
[Ietf.ALPN.DRAFT_16]: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/connection/connect.ts"],"names":[],"mappings":"AAAA,OAAO,OAAwC,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,gFAAgF;AAChF,MAAM,0BAA0B,GAAG,GAAG,CAAC;AA4EvC,gGAAgG;AAChG,8FAA8F;AAC9F,kEAAkE;AAClE,MAAM,kBAAkB,GAAG,CAAC,mBAAmB,CAAC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index.ts\";\nimport { Stream } from \"../stream.ts\";\nimport * as Hex from \"../util/hex.ts\";\nimport { dev, redact } from \"../util/log.ts\";\nimport { isWebTransportSupported } from \"./browser.ts\";\nimport type { Established } from \"./established.ts\";\nimport { exchangeSetup } from \"./handshake.ts\";\n\n// Default head start for WebTransport before attempting the WebSocket fallback.\nconst DEFAULT_WEBSOCKET_DELAY_MS = 500;\n\n/** Tuning for the WebSocket fallback used when WebTransport is unavailable or loses the connect race. */\nexport interface WebSocketOptions {\n\t/** Enable the WebSocket fallback. Defaults to `true`. */\n\tenabled?: boolean;\n\n\t/** Use a different URL than WebTransport. By default, `https` maps to `wss` and `http` to `ws`. */\n\turl?: URL;\n\n\t/**\n\t * The delay in milliseconds before attempting the WebSocket fallback (default: 500).\n\t * If WebSocket won the previous race for a given URL, this is 0.\n\t */\n\tdelay?: DOMHighResTimeStamp;\n}\n\n/**\n * A server certificate hash used to pin a self-signed server, one entry of\n * `serverCertificateHashes`. Unlike the DOM type, `value` also accepts a hex string (the\n * format moq servers report via their certificate fingerprints), decoded automatically.\n */\nexport interface CertificateHash {\n\t/** The hash algorithm. Defaults to `sha-256` (the only supported value). */\n\talgorithm?: \"sha-256\";\n\t/** The certificate hash: raw bytes or a hex string. */\n\tvalue: BufferSource | string;\n}\n\n/** WebTransport options extended with friendlier certificate pinning (hex hashes or a raw certificate). */\nexport interface WebTransportProps extends Omit<WebTransportOptions, \"serverCertificateHashes\"> {\n\t/**\n\t * Pin the server to one or more certificate hashes. Each `value` may be raw\n\t * bytes or a hex string; the algorithm defaults to `sha-256`.\n\t */\n\tserverCertificateHashes?: CertificateHash[];\n\n\t/**\n\t * Pin the server by supplying its certificate directly; the SHA-256 hash is\n\t * computed for you. Accepts a PEM string or raw DER bytes. Use this when you\n\t * have the certificate but not its precomputed fingerprint.\n\t */\n\tserverCertificate?: string | BufferSource;\n}\n\n/** Options for {@link connect}. */\nexport interface ConnectProps {\n\t/** WebTransport options. */\n\twebtransport?: WebTransportProps;\n\n\t/** WebSocket (fallback) options. */\n\twebsocket?: WebSocketOptions;\n\n\t/**\n\t * Use a pre-existing WebTransport session instead of connecting; skips the\n\t * WebTransport/WebSocket race. The publisher acquires the session's datagram\n\t * writer lock (`datagrams.writable.getWriter()`) for the session's lifetime,\n\t * so the caller must not hold it. Aborting via {@link ConnectProps.signal}\n\t * closes this session, so don't share one you intend to reuse afterwards.\n\t */\n\ttransport?: WebTransport;\n\n\t/**\n\t * Whether the relay supports broadcast discovery; see {@link Established.discovery}.\n\t * Defaults to true, except for relays known to lack it.\n\t */\n\tdiscovery?: boolean;\n\n\t/**\n\t * Aborts the connection attempt with the signal's reason. An already-aborted\n\t * signal rejects before anything opens, and aborting after the connection is\n\t * established has no effect. Use `AbortSignal.timeout(ms)` for a deadline.\n\t */\n\tsignal?: AbortSignal;\n}\n\n// Relays that don't implement broadcast discovery (SUBSCRIBE_NAMESPACE), so `announced()` would\n// never yield and a consumer waiting on an announcement would hang forever. Override with the\n// `discovery` option. Drop a host once its relay ships discovery.\nconst NO_DISCOVERY_HOSTS = [\"mediaoverquic.com\"];\n\n/** Whether the relay at `url` is expected to support broadcast discovery. */\nfunction defaultDiscovery(url: URL): boolean {\n\treturn !NO_DISCOVERY_HOSTS.some((host) => url.hostname.endsWith(host));\n}\n\n// Save if WebSocket won the last race, so we won't give QUIC a head start next time.\nconst websocketWon = new Set<string>();\n\n/** The default connect signal: never aborts. */\nconst NEVER_ABORTED = new AbortController().signal;\n\n/**\n * Establishes a connection to a MOQ server.\n *\n * @param url - The URL of the server to connect to\n * @param props - Connection options\n * @returns A promise that resolves to a Connection instance\n */\nexport async function connect(url: URL, props?: ConnectProps): Promise<Established> {\n\tconst signal = props?.signal ?? NEVER_ABORTED;\n\tsignal.throwIfAborted();\n\n\t// Resolves on abort so every in-flight transport tears itself down.\n\tconst { promise: abort, resolve } = Promise.withResolvers<void>();\n\tconst onAbort = () => resolve();\n\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\n\tconst pending = connectInner(url, props, abort);\n\ttry {\n\t\t// A `pending` rejection propagates unless the abort beat it to the finish line.\n\t\tconst connection = await Promise.race([pending, abort.then(() => undefined)]);\n\t\tif (connection && !signal.aborted) return connection;\n\n\t\t// Close a connection that settles after the abort.\n\t\tpending.then((conn) => conn.close()).catch(() => {});\n\t\tthrow signal.reason;\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nasync function connectInner(url: URL, props: ConnectProps | undefined, abort: Promise<void>): Promise<Established> {\n\tconst discovery = props?.discovery ?? defaultDiscovery(url);\n\n\tif (props?.transport) {\n\t\tconst transport = props.transport;\n\t\tvoid abort.then(() => transport.close());\n\t\treturn connectTransport(url, transport, discovery);\n\t}\n\n\t// Stop transports after one connects or the caller aborts.\n\tconst { promise: raced, resolve: done } = Promise.withResolvers<void>();\n\tconst cancel = Promise.race([raced, abort]);\n\n\tconst webtransport = isWebTransportSupported() ? connectWebTransport(url, cancel, props?.webtransport) : undefined;\n\n\t// Give QUIC a head start to connect before trying WebSocket, unless WebSocket has won in the past.\n\t// NOTE that QUIC should be faster because it involves 1/2 fewer RTTs.\n\tconst headstart =\n\t\t!webtransport || websocketWon.has(url.toString()) ? 0 : (props?.websocket?.delay ?? DEFAULT_WEBSOCKET_DELAY_MS);\n\tconst websocket =\n\t\tprops?.websocket?.enabled !== false\n\t\t\t? connectWebSocket(props?.websocket?.url ?? url, headstart, cancel)\n\t\t\t: undefined;\n\n\tif (!websocket && !webtransport) {\n\t\tthrow new Error(\"no transport available; WebTransport not supported and WebSocket is disabled\");\n\t}\n\n\t// Race the available transports, using `.any` to ignore if one participant has an error.\n\t// `webtransport`/`websocket` are `Promise | undefined`, so test existence explicitly: a\n\t// promise is always truthy, so bare truthiness here would be a misused-promise.\n\tconst session = await Promise.any(\n\t\twebtransport !== undefined\n\t\t\t? websocket !== undefined\n\t\t\t\t? [websocket, webtransport]\n\t\t\t\t: [webtransport]\n\t\t\t: [websocket],\n\t);\n\tdone();\n\n\tif (!session) throw new Error(\"no transport available\");\n\n\t// Abort the setup handshake without leaking the selected transport.\n\tvoid abort.then(() => session.close());\n\n\t// Save if WebSocket won the last race, so we won't give QUIC a head start next time.\n\tif (session instanceof Session) {\n\t\t// Still a warning, not a debug line: losing the race means we fell back off QUIC.\n\t\tif (dev()) console.warn(redact(url), \"connected via WebSocket\");\n\t\twebsocketWon.add(url.toString());\n\t} else if (dev()) {\n\t\tconsole.debug(redact(url), \"connected via WebTransport\");\n\t}\n\n\t// The remaining setup is identical whether the transport was raced or supplied.\n\treturn await connectTransport(url, session as WebTransport, discovery);\n}\n\nasync function connectTransport(url: URL, session: WebTransport, discovery: boolean): Promise<Established> {\n\t// qmux Session exposes the negotiated protocol directly (as \"\" when there is none);\n\t// native WebTransport doesn't have a standard .protocol property yet.\n\tconst protocol: string | undefined = (session as { protocol?: string }).protocol || undefined;\n\tif (dev()) console.debug(redact(url), \"negotiated ALPN:\", protocol ?? \"(none)\");\n\n\t// Choose setup encoding based on negotiated WebTransport protocol (if any).\n\tlet setupVersion: Ietf.Version;\n\tconst modernVersion =\n\t\tprotocol === Ietf.ALPN.DRAFT_20\n\t\t\t? Ietf.Version.DRAFT_20\n\t\t\t: protocol === Ietf.ALPN.DRAFT_19\n\t\t\t\t? Ietf.Version.DRAFT_19\n\t\t\t\t: protocol === Ietf.ALPN.DRAFT_18\n\t\t\t\t\t? Ietf.Version.DRAFT_18\n\t\t\t\t\t: protocol === Ietf.ALPN.DRAFT_17\n\t\t\t\t\t\t? Ietf.Version.DRAFT_17\n\t\t\t\t\t\t: undefined;\n\tif (modernVersion !== undefined) {\n\t\treturn await handshakeAlpn(url, session, modernVersion, discovery);\n\t} else if (protocol === Ietf.ALPN.DRAFT_16) {\n\t\tsetupVersion = Ietf.Version.DRAFT_16;\n\t} else if (protocol === Ietf.ALPN.DRAFT_15) {\n\t\tsetupVersion = Ietf.Version.DRAFT_15;\n\t} else if (protocol === Lite.ALPN_06_WIP) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_06, discovery });\n\t} else if (protocol === Lite.ALPN_05) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_05, discovery });\n\t} else if (protocol === Lite.ALPN_04) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_04, discovery });\n\t} else if (protocol === Lite.ALPN_03) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_03, discovery });\n\t} else if (protocol === Lite.ALPN || protocol === \"\" || protocol === undefined) {\n\t\tsetupVersion = Ietf.Version.DRAFT_14;\n\t} else {\n\t\tthrow new Error(`unsupported WebTransport protocol: ${protocol}`);\n\t}\n\n\tconst stream = await Stream.open(session);\n\tawait stream.writer.u53(Lite.StreamId.ClientCompat);\n\n\tconst encoder = new TextEncoder();\n\n\tconst params = new Ietf.SetupOptions();\n\tparams.setVarint(Ietf.SetupOption.MaxRequestId, 42069n);\n\tparams.setBytes(Ietf.SetupOption.Implementation, encoder.encode(\"moq-lite-js\"));\n\tIetf.solicitIntoSetup(params);\n\n\tconst client = new Ietf.ClientSetup({\n\t\tversions:\n\t\t\tsetupVersion === Ietf.Version.DRAFT_16\n\t\t\t\t? [Ietf.Version.DRAFT_16]\n\t\t\t\t: setupVersion === Ietf.Version.DRAFT_15\n\t\t\t\t\t? [Ietf.Version.DRAFT_15]\n\t\t\t\t\t: [Lite.Version.DRAFT_02, Lite.Version.DRAFT_01, Ietf.Version.DRAFT_14],\n\t\tparameters: params,\n\t});\n\tawait client.encode(stream.writer, setupVersion);\n\n\tconst serverCompat = await stream.reader.u53();\n\tif (serverCompat !== Lite.StreamId.ServerCompat) {\n\t\tthrow new Error(`unsupported server message type: ${serverCompat.toString()}`);\n\t}\n\n\tconst server = await Ietf.ServerSetup.decode(stream.reader, setupVersion);\n\n\tif (Object.values(Lite.Version).includes(server.version as Lite.Version)) {\n\t\treturn new Lite.Connection({\n\t\t\turl,\n\t\t\tquic: session,\n\t\t\tversion: server.version as Lite.Version,\n\t\t\tsession: stream,\n\t\t\tdiscovery,\n\t\t});\n\t} else if (Object.values(Ietf.Version).includes(server.version as Ietf.Version)) {\n\t\tconst maxRequestId = server.parameters.getVarint(Ietf.SetupOption.MaxRequestId) ?? 0n;\n\t\treturn new Ietf.Connection({\n\t\t\tdiscovery,\n\t\t\tclient: true,\n\t\t\turl,\n\t\t\tquic: session,\n\t\t\tcontrol: stream,\n\t\t\tmaxRequestId,\n\t\t\tversion: server.version as Ietf.IetfVersion,\n\t\t\tsolicit: Ietf.solicitFromSetup(server.parameters),\n\t\t});\n\t} else {\n\t\tthrow new Error(`unsupported server version: ${server.version.toString()}`);\n\t}\n}\n\n/**\n * Draft-17+ client handshake. ALPN already pinned the version; SETUP is\n * exchanged over a pair of uni streams using stream type 0x2F00.\n */\nasync function handshakeAlpn(\n\turl: URL,\n\tsession: WebTransport,\n\tversion: Ietf.IetfVersion,\n\tdiscovery: boolean,\n): Promise<Established> {\n\tconst { control, solicit, cluster } = await exchangeSetup(session, version, \"moq-lite-js\");\n\n\treturn new Ietf.Connection({\n\t\tdiscovery,\n\t\tclient: true,\n\t\turl,\n\t\tquic: session,\n\t\tcontrol,\n\t\tsolicit,\n\t\tcluster,\n\t\t// v17+ uses NativeSession which manages its own request IDs; maxRequestId is unused.\n\t\tmaxRequestId: 0n,\n\t\tversion,\n\t});\n}\n\n// One entry of the DOM `serverCertificateHashes`, derived without naming the lib type.\ntype WebTransportHash = NonNullable<WebTransportOptions[\"serverCertificateHashes\"]>[number];\n\n// Strip PEM armor and base64-decode to the raw DER bytes.\nfunction pemToDer(pem: string): Uint8Array<ArrayBuffer> {\n\tconst match = pem.match(/-----BEGIN CERTIFICATE-----([\\s\\S]+?)-----END CERTIFICATE-----/);\n\tif (!match) {\n\t\tthrow new Error(\"invalid PEM certificate: missing -----BEGIN/END CERTIFICATE----- armor\");\n\t}\n\n\tconst binary = atob(match[1].replace(/\\s+/g, \"\"));\n\tconst der = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tder[i] = binary.charCodeAt(i);\n\t}\n\treturn der;\n}\n\n/**\n * Compute the SHA-256 hash of a certificate, the value `serverCertificateHashes`\n * pins. Accepts a PEM string or raw DER bytes. Matches the hex fingerprints a moq\n * server reports, so `Hex.fromBytes(await certificateHash(pem))` round-trips.\n */\nexport async function certificateHash(cert: string | BufferSource): Promise<Uint8Array<ArrayBuffer>> {\n\tconst der = typeof cert === \"string\" ? pemToDer(cert) : cert;\n\tconst digest = await crypto.subtle.digest(\"SHA-256\", der);\n\treturn new Uint8Array(digest);\n}\n\n// Normalize our friendlier pinning options into the DOM `serverCertificateHashes`.\nasync function resolveCertificateHashes(options?: WebTransportProps): Promise<WebTransportHash[] | undefined> {\n\tconst hashes: WebTransportHash[] = [];\n\n\tfor (const hash of options?.serverCertificateHashes ?? []) {\n\t\tconst value = typeof hash.value === \"string\" ? Hex.toBytes(hash.value) : hash.value;\n\t\thashes.push({ algorithm: hash.algorithm ?? \"sha-256\", value });\n\t}\n\n\tif (options?.serverCertificate !== undefined) {\n\t\thashes.push({ algorithm: \"sha-256\", value: await certificateHash(options.serverCertificate) });\n\t}\n\n\treturn hashes.length > 0 ? hashes : undefined;\n}\n\nasync function connectWebTransport(\n\turl: URL,\n\tcancel: Promise<void>,\n\toptions?: WebTransportProps,\n): Promise<WebTransport | undefined> {\n\tlet finalUrl = url;\n\n\t// Our custom pinning fields are normalized separately; the rest are DOM options.\n\tconst { serverCertificate: _cert, serverCertificateHashes: _hashes, ...webtransport } = options ?? {};\n\n\tconst finalOptions: WebTransportOptions = {\n\t\tallowPooling: false,\n\t\tcongestionControl: \"low-latency\",\n\t\tprotocols: [\n\t\t\t// Lite.ALPN_06_WIP is intentionally omitted: lite-06 is work-in-progress and\n\t\t\t// not advertised by default (connect.ts still accepts it if a server negotiates it).\n\t\t\tLite.ALPN_05,\n\t\t\tLite.ALPN_04,\n\t\t\tLite.ALPN_03,\n\t\t\tLite.ALPN,\n\t\t\tIetf.ALPN.DRAFT_20,\n\t\t\tIetf.ALPN.DRAFT_19,\n\t\t\tIetf.ALPN.DRAFT_18,\n\t\t\tIetf.ALPN.DRAFT_17,\n\t\t\tIetf.ALPN.DRAFT_16,\n\t\t\tIetf.ALPN.DRAFT_15,\n\t\t],\n\t\t...webtransport,\n\t};\n\n\t// Accumulate caller-provided pins first, then append anything we fetch below,\n\t// so a fetched fingerprint never clobbers hashes passed in via options.\n\tconst hashes = (await resolveCertificateHashes(options)) ?? [];\n\n\t// Only perform certificate fetch and URL rewrite when polyfill is not needed\n\t// This is needed because WebTransport is a butt to work with in local development.\n\tif (url.protocol === \"http:\") {\n\t\tconst fingerprintUrl = new URL(url);\n\t\tfingerprintUrl.pathname = \"/certificate.sha256\";\n\t\t// The certificate endpoint is unauthenticated, so don't hand it the token.\n\t\tfingerprintUrl.search = \"\";\n\n\t\t// Dev-only path: http:// can't be a real WebTransport origin, so we fetch the\n\t\t// self-signed cert's hash over plain HTTP and pin it. Production uses https://\n\t\t// and never reaches here. Keep this at debug so it doesn't read as a problem.\n\t\tif (dev()) {\n\t\t\tconsole.debug(\n\t\t\t\tredact(fingerprintUrl),\n\t\t\t\t\"performing an insecure fingerprint fetch; use https:// in production\",\n\t\t\t);\n\t\t}\n\n\t\t// Fetch the fingerprint from the server.\n\t\t// TODO cancel the request if the effect is cancelled.\n\t\tconst fingerprint = await Promise.race([fetch(fingerprintUrl), cancel]);\n\t\tif (!fingerprint) return undefined;\n\n\t\tconst fingerprintText = await Promise.race([fingerprint.text(), cancel]);\n\t\tif (fingerprintText === undefined) return undefined;\n\n\t\thashes.push({ algorithm: \"sha-256\", value: Hex.toBytes(fingerprintText) });\n\n\t\tfinalUrl = new URL(url);\n\t\tfinalUrl.protocol = \"https:\";\n\t}\n\n\tif (hashes.length > 0) {\n\t\tfinalOptions.serverCertificateHashes = hashes;\n\t}\n\n\tconst quic = new WebTransport(finalUrl, finalOptions);\n\n\t// Both .ready and .closed reject on failure; catch .closed to avoid an unhandled rejection.\n\tquic.closed.catch(() => {});\n\n\t// Wait for the WebTransport to connect, or for the cancel promise to resolve.\n\t// Close the connection if we lost the race.\n\tconst loaded = await Promise.race([quic.ready.then(() => true), cancel]);\n\tif (!loaded) {\n\t\tquic.close();\n\t\treturn undefined;\n\t}\n\n\treturn quic;\n}\n\n// TODO accept arguments to control the port/path used.\nasync function connectWebSocket(url: URL, delay: number, cancel: Promise<void>): Promise<Session | undefined> {\n\tconst timer = new Promise<void>((resolve) => setTimeout(resolve, delay));\n\n\tconst active = await Promise.race([cancel, timer.then(() => true)]);\n\tif (!active) return undefined;\n\n\t// Only moq-transport-18 is pinned to qmux-01 today. Every other ALPN we\n\t// support is currently negotiated as `qmux-00.{alpn}` on the wire, but we\n\t// don't want to lock that in: set the value to `null` so the polyfill\n\t// advertises every QMux draft it knows about and the server picks one.\n\t// Insertion order is the negotiation preference on the wire.\n\tconst versions = {\n\t\t// Lite.ALPN_06_WIP omitted on purpose: lite-06 is work-in-progress, not advertised by default.\n\t\t[Lite.ALPN_05]: null,\n\t\t[Lite.ALPN_04]: null,\n\t\t[Lite.ALPN_03]: null,\n\t\t[Lite.ALPN]: null,\n\t\t[Ietf.ALPN.DRAFT_20]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_18]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_17]: null,\n\t\t[Ietf.ALPN.DRAFT_16]: null,\n\t\t[Ietf.ALPN.DRAFT_15]: null,\n\t} as const satisfies Record<string, QmuxVersion | QmuxVersion[] | null>;\n\n\t// The default (`requireProtocol: false`) also advertises bare `qmux-01`,\n\t// `qmux-00`, and `webtransport` so we still interop with relays that only\n\t// know a wire-format version (today's moq-relay only accepts bare\n\t// `webtransport`).\n\tconst quic = new Session(url, {\n\t\tprotocols: Object.keys(versions),\n\t\tversions,\n\t});\n\n\t// Wait for the WebSocket to connect, or for the cancel promise to resolve.\n\t// `ready` rejects on a refused/failed connection, so a throw here is the caller's\n\t// cue to retry; a lost cancel race instead resolves and we close the loser.\n\tconst loaded = await Promise.race([quic.ready.then(() => true), cancel]);\n\tif (!loaded) {\n\t\tquic.close();\n\t\treturn undefined;\n\t}\n\n\treturn quic;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/connection/connect.ts"],"names":[],"mappings":"AAAA,OAAO,OAAwC,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,gFAAgF;AAChF,MAAM,0BAA0B,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAEnD,0FAA0F;AAC1F,gGAAgG;AAChG,MAAM,oBAAoB,GAAG,GAAG,CAAC;AA2GjC,qFAAqF;AACrF,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;AAEvC,gDAAgD;AAChD,MAAM,aAAa,GAAG,IAAI,eAAe,EAAE,CAAC,MAAM,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAgB;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,aAAa,CAAC;IAC7C,MAAM,CAAC,cAAc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.ts\";\nimport * as Ietf from \"../ietf/index.ts\";\nimport * as Lite from \"../lite/index.ts\";\nimport type { Consumer as OriginConsumer, Producer as OriginProducer } from \"../origin.ts\";\nimport { Stream } from \"../stream.ts\";\nimport * as Time from \"../time.ts\";\nimport * as Hex from \"../util/hex.ts\";\nimport { dev, redact } from \"../util/log.ts\";\nimport { isWebTransportSupported } from \"./browser.ts\";\nimport type { Established } from \"./established.ts\";\nimport { forwardAnnounced } from \"./forward.ts\";\nimport { exchangeSetup } from \"./handshake.ts\";\n\n// Default head start for WebTransport before attempting the WebSocket fallback.\nconst DEFAULT_WEBSOCKET_DELAY_MS = Time.Milli(500);\n\n// RESET_STREAM and CONNECTION_CLOSE are separate transport notifications. Give the latter\n// time to surface its authoritative code without letting a reset-only peer stall SETUP forever.\nconst SETUP_CLOSE_GRACE_MS = 100;\n\n/** Tuning for the WebSocket fallback used when WebTransport is unavailable or loses the connect race. */\nexport interface WebSocketProps {\n\t/** Enable the WebSocket fallback. Defaults to `true`. */\n\tenabled?: boolean;\n\n\t/** Use a different URL than WebTransport. By default, `https` maps to `wss` and `http` to `ws`. */\n\turl?: URL;\n\n\t/**\n\t * The delay in milliseconds before attempting the WebSocket fallback (default: 500).\n\t * If WebSocket won the previous race for a given URL, this is 0.\n\t */\n\tdelay?: Time.Milli;\n}\n\n/**\n * A server certificate hash used to pin a self-signed server, one entry of\n * `serverCertificateHashes`. Unlike the DOM type, `value` also accepts a hex string (the\n * format moq servers report via their certificate fingerprints), decoded automatically.\n */\nexport interface CertificateHash {\n\t/** The hash algorithm. Defaults to `sha-256` (the only supported value). */\n\talgorithm?: \"sha-256\";\n\t/** The certificate hash: raw bytes or a hex string. */\n\tvalue: BufferSource | string;\n}\n\n/** WebTransport options extended with friendlier certificate pinning (hex hashes or a raw certificate). */\nexport interface WebTransportProps extends Omit<WebTransportOptions, \"serverCertificateHashes\"> {\n\t/**\n\t * Pin the server to one or more certificate hashes. Each `value` may be raw\n\t * bytes or a hex string; the algorithm defaults to `sha-256`.\n\t */\n\tserverCertificateHashes?: CertificateHash[];\n\n\t/**\n\t * Pin the server by supplying its certificate directly; the SHA-256 hash is\n\t * computed for you. Accepts a PEM string or raw DER bytes. Use this when you\n\t * have the certificate but not its precomputed fingerprint.\n\t */\n\tserverCertificate?: string | BufferSource;\n}\n\n/** Options for {@link connect}. */\nexport interface ConnectProps {\n\t/** The relay URL. */\n\turl: URL;\n\n\t/** WebTransport options. */\n\twebtransport?: WebTransportProps;\n\n\t/** WebSocket (fallback) options. */\n\twebsocket?: WebSocketProps;\n\n\t/**\n\t * Use a pre-existing WebTransport session instead of connecting; skips the\n\t * WebTransport/WebSocket race. The publisher acquires the session's datagram\n\t * writer lock (`datagrams.writable.getWriter()`) for the session's lifetime,\n\t * so the caller must not hold it. Aborting via {@link ConnectProps.signal}\n\t * closes this session, so don't share one you intend to reuse afterwards.\n\t */\n\ttransport?: WebTransport;\n\n\t/**\n\t * Whether the relay supports broadcast discovery; see {@link Established.discovery}.\n\t * Defaults to true.\n\t */\n\tdiscovery?: boolean;\n\n\t/**\n\t * The origin whose broadcasts the session announces and serves to the peer. Omit to\n\t * publish nothing.\n\t *\n\t * The origin is borrowed, not owned: closing the session leaves its broadcasts alone,\n\t * and the same origin can back several sessions (or successive reconnects), each\n\t * announcing the table for as long as it lasts.\n\t */\n\tpublish?: OriginConsumer;\n\n\t/**\n\t * The origin the session feeds with the peer's announced broadcasts. Omit to discover\n\t * nothing.\n\t *\n\t * Everything the peer announces appears in the origin's table for the session's\n\t * lifetime, consumable by path; the entries retract when the session dies. Pass the\n\t * producer behind {@link ConnectProps.publish} to route both directions through one\n\t * origin: a locally published path is then served back to local consumers directly, and\n\t * the session still never announces the peer's own broadcasts back to it.\n\t */\n\tconsume?: OriginProducer;\n\n\t/**\n\t * Aborts the connection attempt with the signal's reason. An already-aborted\n\t * signal rejects before anything opens, and aborting after the connection is\n\t * established has no effect. Use `AbortSignal.timeout(ms)` for a deadline.\n\t */\n\tsignal?: AbortSignal;\n}\n\n/** The per-session wiring shared by every negotiated protocol path. */\ntype SessionProps = {\n\tdiscovery: boolean;\n\tpublish?: OriginConsumer;\n};\n\n// Save if WebSocket won the last race, so we won't give QUIC a head start next time.\nconst websocketWon = new Set<string>();\n\n/** The default connect signal: never aborts. */\nconst NEVER_ABORTED = new AbortController().signal;\n\n/**\n * Establishes a connection to a MOQ server.\n *\n * @param url - The URL of the server to connect to\n * @param props - Connection options\n * @returns A promise that resolves to an established session\n */\nexport async function connect({ url, ...props }: ConnectProps): Promise<Established> {\n\tconst signal = props.signal ?? NEVER_ABORTED;\n\tsignal.throwIfAborted();\n\n\t// Resolves on abort so every in-flight transport tears itself down.\n\tconst { promise: abort, resolve } = Promise.withResolvers<void>();\n\tconst onAbort = () => resolve();\n\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\n\tconst pending = connectInner(url, props, abort);\n\ttry {\n\t\t// A `pending` rejection propagates unless the abort beat it to the finish line.\n\t\tconst connection = await Promise.race([pending, abort.then(() => undefined)]);\n\t\tif (connection && !signal.aborted) {\n\t\t\tif (props.consume) forwardAnnounced(connection, props.consume);\n\t\t\treturn connection;\n\t\t}\n\n\t\t// Close a connection that settles after the abort.\n\t\tpending.then((conn) => conn.close()).catch(() => {});\n\t\tthrow signal.reason;\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nasync function connectInner(url: URL, props: Omit<ConnectProps, \"url\">, abort: Promise<void>): Promise<Established> {\n\tconst wiring: SessionProps = {\n\t\tdiscovery: props.discovery ?? true,\n\t\tpublish: props.publish,\n\t};\n\n\tif (props.transport) {\n\t\tconst transport = props.transport;\n\t\tvoid abort.then(() => transport.close());\n\t\treturn connectTransport(url, transport, wiring);\n\t}\n\n\t// Stop transports after one connects or the caller aborts.\n\tconst { promise: raced, resolve: done } = Promise.withResolvers<void>();\n\tconst cancel = Promise.race([raced, abort]);\n\n\tconst webtransport = isWebTransportSupported() ? connectWebTransport(url, cancel, props.webtransport) : undefined;\n\n\t// Give QUIC a head start to connect before trying WebSocket, unless WebSocket has won in the past.\n\t// NOTE that QUIC should be faster because it involves 1/2 fewer RTTs.\n\tconst headstart =\n\t\t!webtransport || websocketWon.has(url.toString()) ? 0 : (props.websocket?.delay ?? DEFAULT_WEBSOCKET_DELAY_MS);\n\tconst websocket =\n\t\tprops.websocket?.enabled !== false\n\t\t\t? connectWebSocket(props.websocket?.url ?? url, headstart, cancel)\n\t\t\t: undefined;\n\n\tif (!websocket && !webtransport) {\n\t\tthrow new Error(\"no transport available; WebTransport not supported and WebSocket is disabled\");\n\t}\n\n\t// Race the available transports, using `.any` to ignore if one participant has an error.\n\t// `webtransport`/`websocket` are `Promise | undefined`, so test existence explicitly: a\n\t// promise is always truthy, so bare truthiness here would be a misused-promise.\n\tconst session = await Promise.any(\n\t\twebtransport !== undefined\n\t\t\t? websocket !== undefined\n\t\t\t\t? [websocket, webtransport]\n\t\t\t\t: [webtransport]\n\t\t\t: [websocket],\n\t);\n\tdone();\n\n\tif (!session) throw new Error(\"no transport available\");\n\n\t// Abort the setup handshake without leaking the selected transport.\n\tvoid abort.then(() => session.close());\n\n\t// Save if WebSocket won the last race, so we won't give QUIC a head start next time.\n\tif (session instanceof Session) {\n\t\t// Still a warning, not a debug line: losing the race means we fell back off QUIC.\n\t\tif (dev()) console.warn(redact(url), \"connected via WebSocket\");\n\t\twebsocketWon.add(url.toString());\n\t} else if (dev()) {\n\t\tconsole.debug(redact(url), \"connected via WebTransport\");\n\t}\n\n\t// The remaining setup is identical whether the transport was raced or supplied.\n\treturn await connectTransport(url, session as WebTransport, wiring);\n}\n\nasync function connectTransport(url: URL, session: WebTransport, wiring: SessionProps): Promise<Established> {\n\tconst closed = session.closed.then(fromClose, error);\n\tconst terminal = closed.then((cause) => {\n\t\tthrow cause ?? new Error(\"session closed during SETUP\");\n\t});\n\n\ttry {\n\t\treturn await Promise.race([terminal, negotiate(url, session, wiring)]);\n\t} catch (cause) {\n\t\t// A session shutdown can reject its SETUP stream before `closed` publishes the\n\t\t// peer's close code. Wait briefly without closing locally, since a local clean close\n\t\t// could overwrite that code. A reset-only peer is cleaned up after the grace period.\n\t\tconst pending = Symbol(\"session close pending\");\n\t\tconst final = await Promise.race([\n\t\t\tclosed,\n\t\t\tnew Promise<typeof pending>((resolve) => setTimeout(() => resolve(pending), SETUP_CLOSE_GRACE_MS)),\n\t\t]);\n\t\tif (final !== pending) {\n\t\t\tif (final) throw final;\n\t\t\tthrow cause;\n\t\t}\n\n\t\tsession.close();\n\t\tthrow cause;\n\t}\n}\n\n// Negotiate the MoQ protocol over an established transport. The caller races this against\n// the session closing so a close code is not lost behind a failed or stalled SETUP stream.\nasync function negotiate(url: URL, session: WebTransport, wiring: SessionProps): Promise<Established> {\n\t// qmux Session exposes the negotiated protocol directly (as \"\" when there is none);\n\t// native WebTransport doesn't have a standard .protocol property yet.\n\tconst protocol: string | undefined = (session as { protocol?: string }).protocol || undefined;\n\tif (dev()) console.debug(redact(url), \"negotiated ALPN:\", protocol ?? \"(none)\");\n\n\t// Choose setup encoding based on negotiated WebTransport protocol (if any).\n\tlet setupVersion: Ietf.Version;\n\tconst modernVersion =\n\t\tprotocol === Ietf.ALPN.DRAFT_22\n\t\t\t? Ietf.Version.DRAFT_22\n\t\t\t: protocol === Ietf.ALPN.DRAFT_21\n\t\t\t\t? Ietf.Version.DRAFT_21\n\t\t\t\t: protocol === Ietf.ALPN.DRAFT_20\n\t\t\t\t\t? Ietf.Version.DRAFT_20\n\t\t\t\t\t: protocol === Ietf.ALPN.DRAFT_19\n\t\t\t\t\t\t? Ietf.Version.DRAFT_19\n\t\t\t\t\t\t: protocol === Ietf.ALPN.DRAFT_18\n\t\t\t\t\t\t\t? Ietf.Version.DRAFT_18\n\t\t\t\t\t\t\t: protocol === Ietf.ALPN.DRAFT_17\n\t\t\t\t\t\t\t\t? Ietf.Version.DRAFT_17\n\t\t\t\t\t\t\t\t: undefined;\n\tif (modernVersion !== undefined) {\n\t\treturn await handshakeAlpn(url, session, modernVersion, wiring);\n\t} else if (protocol === Ietf.ALPN.DRAFT_16) {\n\t\tsetupVersion = Ietf.Version.DRAFT_16;\n\t} else if (protocol === Ietf.ALPN.DRAFT_15) {\n\t\tsetupVersion = Ietf.Version.DRAFT_15;\n\t} else if (protocol === Lite.ALPN_06) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_06, ...wiring });\n\t} else if (protocol === Lite.ALPN_05) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_05, ...wiring });\n\t} else if (protocol === Lite.ALPN_04) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_04, ...wiring });\n\t} else if (protocol === Lite.ALPN_03) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_03, ...wiring });\n\t} else if (protocol === Lite.ALPN || protocol === \"\" || protocol === undefined) {\n\t\tsetupVersion = Ietf.Version.DRAFT_14;\n\t} else {\n\t\tthrow new Error(`unsupported WebTransport protocol: ${protocol}`);\n\t}\n\n\tconst stream = await Stream.open(session);\n\tawait stream.writer.u53(Lite.StreamId.ClientCompat);\n\n\tconst encoder = new TextEncoder();\n\n\tconst params = new Ietf.SetupOptions();\n\tparams.setVarint(Ietf.SetupOption.MaxRequestId, 42069n);\n\tparams.setBytes(Ietf.SetupOption.Implementation, encoder.encode(\"moq-lite-js\"));\n\tIetf.solicitIntoSetup(params);\n\n\tconst client = new Ietf.ClientSetup({\n\t\tversions:\n\t\t\tsetupVersion === Ietf.Version.DRAFT_16\n\t\t\t\t? [Ietf.Version.DRAFT_16]\n\t\t\t\t: setupVersion === Ietf.Version.DRAFT_15\n\t\t\t\t\t? [Ietf.Version.DRAFT_15]\n\t\t\t\t\t: [Lite.Version.DRAFT_02, Lite.Version.DRAFT_01, Ietf.Version.DRAFT_14],\n\t\tparameters: params,\n\t});\n\tawait client.encode(stream.writer, setupVersion);\n\n\tconst serverCompat = await stream.reader.u53();\n\tif (serverCompat !== Lite.StreamId.ServerCompat) {\n\t\tthrow new Error(`unsupported server message type: ${serverCompat.toString()}`);\n\t}\n\n\tconst server = await Ietf.ServerSetup.decode(stream.reader, setupVersion);\n\n\tif (Object.values(Lite.Version).includes(server.version as Lite.Version)) {\n\t\treturn new Lite.Connection({\n\t\t\turl,\n\t\t\tquic: session,\n\t\t\tversion: server.version as Lite.Version,\n\t\t\tsession: stream,\n\t\t\t...wiring,\n\t\t});\n\t} else if (Object.values(Ietf.Version).includes(server.version as Ietf.Version)) {\n\t\tconst maxRequestId = server.parameters.getVarint(Ietf.SetupOption.MaxRequestId) ?? 0n;\n\t\treturn new Ietf.Connection({\n\t\t\t...wiring,\n\t\t\tclient: true,\n\t\t\turl,\n\t\t\tquic: session,\n\t\t\tcontrol: stream,\n\t\t\tmaxRequestId,\n\t\t\tversion: server.version as Ietf.IetfVersion,\n\t\t\tsolicit: Ietf.solicitFromSetup(server.parameters),\n\t\t});\n\t} else {\n\t\tthrow new Error(`unsupported server version: ${server.version.toString()}`);\n\t}\n}\n\n/**\n * Draft-17+ client handshake. ALPN already pinned the version; SETUP is\n * exchanged over a pair of uni streams using stream type 0x2F00.\n */\nasync function handshakeAlpn(\n\turl: URL,\n\tsession: WebTransport,\n\tversion: Ietf.IetfVersion,\n\twiring: SessionProps,\n): Promise<Established> {\n\tconst { control, solicit, cluster } = await exchangeSetup(session, version, \"moq-lite-js\");\n\n\treturn new Ietf.Connection({\n\t\t...wiring,\n\t\tclient: true,\n\t\turl,\n\t\tquic: session,\n\t\tcontrol,\n\t\tsolicit,\n\t\tcluster,\n\t\t// v17+ uses NativeSession which manages its own request IDs; maxRequestId is unused.\n\t\tmaxRequestId: 0n,\n\t\tversion,\n\t});\n}\n\n// One entry of the DOM `serverCertificateHashes`, derived without naming the lib type.\ntype WebTransportHash = NonNullable<WebTransportOptions[\"serverCertificateHashes\"]>[number];\n\n// Strip PEM armor and base64-decode to the raw DER bytes.\nfunction pemToDer(pem: string): Uint8Array<ArrayBuffer> {\n\tconst match = pem.match(/-----BEGIN CERTIFICATE-----([\\s\\S]+?)-----END CERTIFICATE-----/);\n\tif (!match) {\n\t\tthrow new Error(\"invalid PEM certificate: missing -----BEGIN/END CERTIFICATE----- armor\");\n\t}\n\n\tconst binary = atob(match[1].replace(/\\s+/g, \"\"));\n\tconst der = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tder[i] = binary.charCodeAt(i);\n\t}\n\treturn der;\n}\n\n/**\n * Compute the SHA-256 hash of a certificate, the value `serverCertificateHashes`\n * pins. Accepts a PEM string or raw DER bytes. Matches the hex fingerprints a moq\n * server reports, so `Hex.fromBytes(await certificateHash(pem))` round-trips.\n */\nexport async function certificateHash(cert: string | BufferSource): Promise<Uint8Array<ArrayBuffer>> {\n\tconst der = typeof cert === \"string\" ? pemToDer(cert) : cert;\n\tconst digest = await crypto.subtle.digest(\"SHA-256\", der);\n\treturn new Uint8Array(digest);\n}\n\n// Normalize our friendlier pinning options into the DOM `serverCertificateHashes`.\nasync function resolveCertificateHashes(options?: WebTransportProps): Promise<WebTransportHash[] | undefined> {\n\tconst hashes: WebTransportHash[] = [];\n\n\tfor (const hash of options?.serverCertificateHashes ?? []) {\n\t\tconst value = typeof hash.value === \"string\" ? Hex.toBytes(hash.value) : hash.value;\n\t\thashes.push({ algorithm: hash.algorithm ?? \"sha-256\", value });\n\t}\n\n\tif (options?.serverCertificate !== undefined) {\n\t\thashes.push({ algorithm: \"sha-256\", value: await certificateHash(options.serverCertificate) });\n\t}\n\n\treturn hashes.length > 0 ? hashes : undefined;\n}\n\nasync function connectWebTransport(\n\turl: URL,\n\tcancel: Promise<void>,\n\toptions?: WebTransportProps,\n): Promise<WebTransport | undefined> {\n\tlet finalUrl = url;\n\n\t// Our custom pinning fields are normalized separately; the rest are DOM options.\n\tconst { serverCertificate: _cert, serverCertificateHashes: _hashes, ...webtransport } = options ?? {};\n\n\tconst finalOptions: WebTransportOptions = {\n\t\tallowPooling: false,\n\t\tcongestionControl: \"low-latency\",\n\t\tprotocols: [\n\t\t\tLite.ALPN_06,\n\t\t\tLite.ALPN_05,\n\t\t\tLite.ALPN_04,\n\t\t\tLite.ALPN_03,\n\t\t\tLite.ALPN,\n\t\t\tIetf.ALPN.DRAFT_22,\n\t\t\tIetf.ALPN.DRAFT_21,\n\t\t\tIetf.ALPN.DRAFT_20,\n\t\t\tIetf.ALPN.DRAFT_19,\n\t\t\tIetf.ALPN.DRAFT_18,\n\t\t\tIetf.ALPN.DRAFT_17,\n\t\t\tIetf.ALPN.DRAFT_16,\n\t\t\tIetf.ALPN.DRAFT_15,\n\t\t],\n\t\t...webtransport,\n\t};\n\n\t// Accumulate caller-provided pins first, then append anything we fetch below,\n\t// so a fetched fingerprint never clobbers hashes passed in via options.\n\tconst hashes = (await resolveCertificateHashes(options)) ?? [];\n\n\t// Only perform certificate fetch and URL rewrite when polyfill is not needed\n\t// This is needed because WebTransport is a butt to work with in local development.\n\tif (url.protocol === \"http:\") {\n\t\tconst fingerprintUrl = new URL(url);\n\t\tfingerprintUrl.pathname = \"/certificate.sha256\";\n\t\t// The certificate endpoint is unauthenticated, so don't hand it the token.\n\t\tfingerprintUrl.search = \"\";\n\n\t\t// Dev-only path: http:// can't be a real WebTransport origin, so we fetch the\n\t\t// self-signed cert's hash over plain HTTP and pin it. Production uses https://\n\t\t// and never reaches here. Keep this at debug so it doesn't read as a problem.\n\t\tif (dev()) {\n\t\t\tconsole.debug(\n\t\t\t\tredact(fingerprintUrl),\n\t\t\t\t\"performing an insecure fingerprint fetch; use https:// in production\",\n\t\t\t);\n\t\t}\n\n\t\t// Fetch the fingerprint from the server.\n\t\t// TODO cancel the request if the effect is cancelled.\n\t\tconst fingerprint = await Promise.race([fetch(fingerprintUrl), cancel]);\n\t\tif (!fingerprint) return undefined;\n\n\t\tconst fingerprintText = await Promise.race([fingerprint.text(), cancel]);\n\t\tif (fingerprintText === undefined) return undefined;\n\n\t\thashes.push({ algorithm: \"sha-256\", value: Hex.toBytes(fingerprintText) });\n\n\t\tfinalUrl = new URL(url);\n\t\tfinalUrl.protocol = \"https:\";\n\t}\n\n\tif (hashes.length > 0) {\n\t\tfinalOptions.serverCertificateHashes = hashes;\n\t}\n\n\tconst quic = new WebTransport(finalUrl, finalOptions);\n\n\t// Both .ready and .closed reject on failure; catch .closed to avoid an unhandled rejection.\n\tquic.closed.catch(() => {});\n\n\t// Wait for the WebTransport to connect, or for the cancel promise to resolve.\n\t// Close the connection if we lost the race.\n\tconst loaded = await Promise.race([quic.ready.then(() => true), cancel]);\n\tif (!loaded) {\n\t\tquic.close();\n\t\treturn undefined;\n\t}\n\n\treturn quic;\n}\n\n// TODO accept arguments to control the port/path used.\nasync function connectWebSocket(url: URL, delay: number, cancel: Promise<void>): Promise<Session | undefined> {\n\tconst timer = new Promise<void>((resolve) => setTimeout(resolve, delay));\n\n\tconst active = await Promise.race([cancel, timer.then(() => true)]);\n\tif (!active) return undefined;\n\n\t// moq-transport-18 and newer are pinned to qmux-01. Every other ALPN we\n\t// support is currently negotiated as `qmux-00.{alpn}` on the wire, but we\n\t// don't want to lock that in: set the value to `null` so the polyfill\n\t// advertises every QMux draft it knows about and the server picks one.\n\t// Insertion order is the negotiation preference on the wire.\n\tconst versions = {\n\t\t[Lite.ALPN_06]: null,\n\t\t[Lite.ALPN_05]: null,\n\t\t[Lite.ALPN_04]: null,\n\t\t[Lite.ALPN_03]: null,\n\t\t[Lite.ALPN]: null,\n\t\t[Ietf.ALPN.DRAFT_22]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_21]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_20]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_19]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_18]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_17]: null,\n\t\t[Ietf.ALPN.DRAFT_16]: null,\n\t\t[Ietf.ALPN.DRAFT_15]: null,\n\t} as const satisfies Record<string, QmuxVersion | QmuxVersion[] | null>;\n\n\t// The default (`requireProtocol: false`) also advertises bare `qmux-01`,\n\t// `qmux-00`, and `webtransport` so we still interop with relays that only\n\t// know a wire-format version (today's moq-relay only accepts bare\n\t// `webtransport`).\n\tconst quic = new Session(url, {\n\t\tprotocols: Object.keys(versions),\n\t\tversions,\n\t});\n\n\t// Wait for the WebSocket to connect, or for the cancel promise to resolve.\n\t// `ready` rejects on a refused/failed connection, so a throw here is the caller's\n\t// cue to retry; a lost cancel race instead resolves and we close the loser.\n\tconst loaded = await Promise.race([quic.ready.then(() => true), cancel]);\n\tif (!loaded) {\n\t\tquic.close();\n\t\treturn undefined;\n\t}\n\n\treturn quic;\n}\n"]}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { Getter } from "@moq/signals";
|
|
2
2
|
import type * as announce from "../announced";
|
|
3
|
-
import type * as broadcast from "../broadcast";
|
|
4
3
|
import type * as Path from "../path";
|
|
5
4
|
import type { Probe, Stats } from "./stats";
|
|
6
5
|
import type { Transport } from "./transport";
|
|
7
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* An established MoQ session, implemented by both the moq-lite and moq-ietf protocols.
|
|
8
|
+
*
|
|
9
|
+
* Publishing goes through an origin, not the session: pass an `Origin.Consumer` as the
|
|
10
|
+
* `publish` connect option and the session announces and serves that origin's broadcasts.
|
|
11
|
+
*/
|
|
8
12
|
export interface Established {
|
|
9
13
|
/** URL of the connected server. */
|
|
10
14
|
readonly url: URL;
|
|
@@ -23,25 +27,12 @@ export interface Established {
|
|
|
23
27
|
* rather than wait for an announcement. Set via `discovery` on the connect options.
|
|
24
28
|
*/
|
|
25
29
|
readonly discovery: boolean;
|
|
26
|
-
/** Subscribe to broadcast announcements under an optional path prefix, returning paths relative to that prefix. */
|
|
27
|
-
announced(prefix?: Path.Valid): announce.Consumer;
|
|
28
|
-
/** Publish a broadcast at the given path. */
|
|
29
|
-
publish(path: Path.Valid, broadcast: broadcast.Producer): void;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* {@link announcedBroadcast} instead when the broadcast may not be online yet.
|
|
35
|
-
*/
|
|
36
|
-
consume(path: Path.Valid): broadcast.Consumer;
|
|
37
|
-
/**
|
|
38
|
-
* A reactive handle to the broadcast at the given path, live only while it is announced.
|
|
39
|
-
*
|
|
40
|
-
* The announcement-gated counterpart to {@link consume}: it waits for the broadcast to come
|
|
41
|
-
* online instead of resetting, and drops back to `undefined` when it goes away. See
|
|
42
|
-
* {@link announce.Broadcast}. Close the handle when done.
|
|
31
|
+
* Subscribe to broadcast announcements matching `scope`, any pattern (`foo/**`
|
|
32
|
+
* for a subtree, `room/* /chat` for each room's chat, default `**`). Paths are
|
|
33
|
+
* relative to the session; captures report what the scope's wildcards stood for.
|
|
43
34
|
*/
|
|
44
|
-
|
|
35
|
+
announced(scope?: Path.Pattern): announce.Consumer;
|
|
45
36
|
/**
|
|
46
37
|
* Snapshot the transport's counters, querying it fresh on each call.
|
|
47
38
|
*
|
|
@@ -51,7 +42,11 @@ export interface Established {
|
|
|
51
42
|
stats(): Promise<Stats>;
|
|
52
43
|
/** Close the session. */
|
|
53
44
|
close(): void;
|
|
54
|
-
/**
|
|
55
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Resolves when the session closes: `null` for a clean close, an `Error.Session` when the
|
|
47
|
+
* peer closed with a code (e.g. `SessionCode.Unauthorized` for an auth rejection), or the
|
|
48
|
+
* transport's own failure. Never rejects.
|
|
49
|
+
*/
|
|
50
|
+
closed: Promise<Error | null>;
|
|
56
51
|
}
|
|
57
52
|
//# sourceMappingURL=established.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"established.d.ts","sourceRoot":"","sources":["../../src/connection/established.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"established.d.ts","sourceRoot":"","sources":["../../src/connection/established.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAElB,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAEnD;;;;;OAKG;IACH,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAExB,yBAAyB;IACzB,KAAK,IAAI,IAAI,CAAC;IAEd;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"established.js","sourceRoot":"","sources":["../../src/connection/established.ts"],"names":[],"mappings":"","sourcesContent":["import type { Getter } from \"@moq/signals\";\nimport type * as announce from \"../announced.ts\";\nimport type * as
|
|
1
|
+
{"version":3,"file":"established.js","sourceRoot":"","sources":["../../src/connection/established.ts"],"names":[],"mappings":"","sourcesContent":["import type { Getter } from \"@moq/signals\";\nimport type * as announce from \"../announced.ts\";\nimport type * as Path from \"../path.ts\";\nimport type { Probe, Stats } from \"./stats.ts\";\nimport type { Transport } from \"./transport.ts\";\n\n/**\n * An established MoQ session, implemented by both the moq-lite and moq-ietf protocols.\n *\n * Publishing goes through an origin, not the session: pass an `Origin.Consumer` as the\n * `publish` connect option and the session announces and serves that origin's broadcasts.\n */\nexport interface Established {\n\t/** URL of the connected server. */\n\treadonly url: URL;\n\n\t/** Negotiated wire protocol version. */\n\treadonly version: string;\n\n\t/** The wire transport this session runs over. */\n\treadonly transport: Transport;\n\n\t/**\n\t * Estimates measured by the peer, updated as PROBE messages arrive. Stays empty on\n\t * versions without PROBE. See {@link Stats} for what the local transport counts.\n\t */\n\treadonly probe: Getter<Probe>;\n\n\t/**\n\t * Whether the relay supports broadcast discovery: announcing which broadcasts exist under a\n\t * prefix. When false, {@link announced} never yields, so a consumer must subscribe blind\n\t * rather than wait for an announcement. Set via `discovery` on the connect options.\n\t */\n\treadonly discovery: boolean;\n\n\t/**\n\t * Subscribe to broadcast announcements matching `scope`, any pattern (`foo/**`\n\t * for a subtree, `room/* /chat` for each room's chat, default `**`). Paths are\n\t * relative to the session; captures report what the scope's wildcards stood for.\n\t */\n\tannounced(scope?: Path.Pattern): announce.Consumer;\n\n\t/**\n\t * Snapshot the transport's counters, querying it fresh on each call.\n\t *\n\t * Resolves to an empty snapshot on a transport without `getStats()`. Sample it on\n\t * whatever schedule you need rather than expecting the library to poll for you.\n\t */\n\tstats(): Promise<Stats>;\n\n\t/** Close the session. */\n\tclose(): void;\n\n\t/**\n\t * Resolves when the session closes: `null` for a clean close, an `Error.Session` when the\n\t * peer closed with a code (e.g. `SessionCode.Unauthorized` for an auth rejection), or the\n\t * transport's own failure. Never rejects.\n\t */\n\tclosed: Promise<Error | null>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward.d.ts","sourceRoot":"","sources":["../../src/connection/forward.ts"],"names":[],"mappings":""}
|