@moq/net 0.4.7 → 0.22.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/README.md +7 -1
- package/announce.d.ts +1 -1
- package/announce.d.ts.map +1 -1
- package/announce.js +1 -2
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -32
- package/announced.js.map +1 -1
- package/announced.test-util.d.ts +2 -0
- package/announced.test-util.d.ts.map +1 -0
- package/announced.test-util.js +27 -0
- package/announced.test-util.js.map +1 -0
- package/auth.d.ts +64 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +20 -0
- package/auth.js.map +1 -0
- package/auth_gate.d.ts +2 -0
- package/auth_gate.d.ts.map +1 -0
- package/auth_gate.js +24 -0
- package/auth_gate.js.map +1 -0
- package/auth_session.d.ts +49 -0
- package/auth_session.d.ts.map +1 -0
- package/auth_session.js +1097 -0
- package/auth_session.js.map +1 -0
- package/bandwidth.d.ts +129 -25
- package/bandwidth.d.ts.map +1 -1
- package/bandwidth.js +410 -139
- package/bandwidth.js.map +1 -1
- package/bandwidth_api.d.ts +1 -1
- package/bandwidth_api.d.ts.map +1 -1
- package/bandwidth_api.js +1 -2
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +64 -38
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -173
- package/broadcast.js.map +1 -1
- package/cache.d.ts +103 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +254 -0
- package/cache.js.map +1 -0
- package/claim.test-util.d.ts +5 -0
- package/claim.test-util.d.ts.map +1 -0
- package/claim.test-util.js +13 -0
- package/claim.test-util.js.map +1 -0
- package/connection/accept.d.ts +21 -13
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -130
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -20
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +120 -24
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -217
- package/connection/connect.js.map +1 -1
- package/connection/dials.d.ts +45 -0
- package/connection/dials.d.ts.map +1 -0
- package/connection/dials.js +109 -0
- package/connection/dials.js.map +1 -0
- package/connection/endpoint.d.ts +60 -0
- package/connection/endpoint.d.ts.map +1 -0
- package/connection/endpoint.js +114 -0
- package/connection/endpoint.js.map +1 -0
- package/connection/forward.d.ts +7 -1
- package/connection/forward.d.ts.map +1 -1
- package/connection/forward.js +265 -81
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +16 -9
- package/connection/goaway.d.ts.map +1 -1
- package/connection/goaway.js +22 -95
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +34 -8
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -21
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +4 -7
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -3
- package/connection/index.js.map +1 -1
- package/connection/liveness.d.ts +14 -0
- package/connection/liveness.d.ts.map +1 -0
- package/connection/liveness.js +30 -0
- package/connection/liveness.js.map +1 -0
- package/connection/pool.d.ts +142 -63
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -118
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts +60 -12
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +859 -234
- package/connection/reload.js.map +1 -1
- package/connection/session.d.ts +91 -0
- package/connection/session.d.ts.map +1 -0
- package/connection/session.js +2 -0
- package/connection/session.js.map +1 -0
- package/connection/stats.d.ts +20 -11
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js +64 -9
- package/connection/stats.js.map +1 -1
- package/connection/ticker.d.ts +4 -0
- package/connection/ticker.d.ts.map +1 -0
- package/connection/ticker.js +66 -0
- package/connection/ticker.js.map +1 -0
- package/connection/tokens.d.ts +2 -0
- package/connection/tokens.d.ts.map +1 -0
- package/connection/tokens.js +404 -0
- package/connection/tokens.js.map +1 -0
- package/connection/transport.d.ts.map +1 -1
- package/connection/transport.js +4 -5
- package/connection/transport.js.map +1 -1
- package/connection/withdrawal.d.ts +2 -0
- package/connection/withdrawal.d.ts.map +1 -0
- package/connection/withdrawal.js +23 -0
- package/connection/withdrawal.js.map +1 -0
- package/consume.js +213 -47
- package/consume.js.map +1 -1
- package/cover.d.ts +59 -0
- package/cover.d.ts.map +1 -0
- package/cover.js +375 -0
- package/cover.js.map +1 -0
- package/datagram.d.ts +70 -11
- package/datagram.d.ts.map +1 -1
- package/datagram.js +317 -2
- package/datagram.js.map +1 -1
- package/datagram_stream.d.ts +18 -0
- package/datagram_stream.d.ts.map +1 -0
- package/datagram_stream.js +67 -0
- package/datagram_stream.js.map +1 -0
- package/defined.test-util.d.ts +2 -0
- package/defined.test-util.d.ts.map +1 -0
- package/defined.test-util.js +7 -0
- package/defined.test-util.js.map +1 -0
- package/delivered.d.ts +75 -0
- package/delivered.d.ts.map +1 -0
- package/delivered.js +228 -0
- package/delivered.js.map +1 -0
- package/demand.d.ts +173 -0
- package/demand.d.ts.map +1 -0
- package/demand.js +582 -0
- package/demand.js.map +1 -0
- package/drops.d.ts +93 -0
- package/drops.d.ts.map +1 -0
- package/drops.js +283 -0
- package/drops.js.map +1 -0
- package/error.d.ts +120 -21
- package/error.d.ts.map +1 -1
- package/error.js +230 -38
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -3
- package/errors.js.map +1 -1
- package/fill.d.ts +174 -0
- package/fill.d.ts.map +1 -0
- package/fill.js +760 -0
- package/fill.js.map +1 -0
- package/flate/decoder.d.ts +2 -0
- package/flate/decoder.d.ts.map +1 -0
- package/flate/decoder.js +63 -0
- package/flate/decoder.js.map +1 -0
- package/flate/encoder.d.ts +2 -0
- package/flate/encoder.d.ts.map +1 -0
- package/flate/encoder.js +64 -0
- package/flate/encoder.js.map +1 -0
- package/flate/group.d.ts +34 -0
- package/flate/group.d.ts.map +1 -0
- package/flate/group.js +140 -0
- package/flate/group.js.map +1 -0
- package/frame.d.ts +80 -0
- package/frame.d.ts.map +1 -0
- package/frame.js +296 -0
- package/frame.js.map +1 -0
- package/frame.test-util.d.ts +5 -0
- package/frame.test-util.d.ts.map +1 -0
- package/frame.test-util.js +9 -0
- package/frame.test-util.js.map +1 -0
- package/group.d.ts +108 -45
- package/group.d.ts.map +1 -1
- package/group.js +1616 -308
- package/group.js.map +1 -1
- package/group_api.d.ts +7 -0
- package/group_api.d.ts.map +1 -0
- package/group_api.js +7 -0
- package/group_api.js.map +1 -0
- package/hop.d.ts +62 -76
- package/hop.d.ts.map +1 -1
- package/hop.js +92 -65
- package/hop.js.map +1 -1
- package/identity.d.ts +39 -0
- package/identity.d.ts.map +1 -0
- package/identity.js +47 -0
- package/identity.js.map +1 -0
- package/ietf/active_count.d.ts +2 -0
- package/ietf/active_count.d.ts.map +1 -0
- package/ietf/active_count.js +30 -0
- package/ietf/active_count.js.map +1 -0
- package/ietf/aliases.js +69 -36
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -55
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +1 -31
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +305 -144
- package/ietf/connection.js.map +1 -1
- package/ietf/datagram.d.ts +60 -0
- package/ietf/datagram.d.ts.map +1 -0
- package/ietf/datagram.js +152 -0
- package/ietf/datagram.js.map +1 -0
- package/ietf/error.d.ts +3 -3
- package/ietf/error.js +82 -101
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +93 -37
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -94
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +21 -31
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -172
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +12 -10
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -36
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -2
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +8 -20
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -15
- package/ietf/index.js.map +1 -1
- package/ietf/join.d.ts +7 -0
- package/ietf/join.d.ts.map +1 -0
- package/ietf/join.js +234 -0
- package/ietf/join.js.map +1 -0
- package/ietf/message.d.ts +18 -2
- package/ietf/message.d.ts.map +1 -1
- package/ietf/message.js +60 -41
- package/ietf/message.js.map +1 -1
- package/ietf/message.test-util.d.ts +6 -0
- package/ietf/message.test-util.d.ts.map +1 -0
- package/ietf/message.test-util.js +13 -0
- package/ietf/message.test-util.js.map +1 -0
- package/ietf/namespace.d.ts +19 -5
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -27
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +195 -33
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -179
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +25 -45
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -473
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +17 -2
- package/ietf/priority.d.ts.map +1 -1
- package/ietf/priority.js +19 -5
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +6 -5
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -49
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +25 -33
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -140
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +49 -72
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -185
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -601
- package/ietf/publisher.js.map +1 -1
- package/ietf/range.d.ts +2 -0
- package/ietf/range.d.ts.map +1 -0
- package/ietf/range.js +222 -0
- package/ietf/range.js.map +1 -0
- package/ietf/request.d.ts +6 -30
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -79
- package/ietf/request.js.map +1 -1
- package/ietf/request_stream.d.ts +1 -6
- package/ietf/request_stream.d.ts.map +1 -1
- package/ietf/request_stream.js +306 -17
- package/ietf/request_stream.js.map +1 -1
- package/ietf/session.d.ts +41 -0
- package/ietf/session.d.ts.map +1 -0
- package/ietf/session.js +65 -0
- package/ietf/session.js.map +1 -0
- package/ietf/setup.d.ts +5 -30
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -118
- package/ietf/setup.js.map +1 -1
- package/ietf/setup_options.d.ts +31 -0
- package/ietf/setup_options.d.ts.map +1 -0
- package/ietf/setup_options.js +138 -0
- package/ietf/setup_options.js.map +1 -0
- package/ietf/solicit.js +4 -15
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +52 -45
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -240
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +16 -79
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -202
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -537
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -28
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +27 -24
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -62
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +13 -42
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +22 -49
- package/ietf/version.js.map +1 -1
- package/implementation.d.ts +2 -0
- package/implementation.d.ts.map +1 -0
- package/implementation.js +5 -0
- package/implementation.js.map +1 -0
- package/index.d.ts +34 -19
- package/index.d.ts.map +1 -1
- package/index.js +19 -7
- package/index.js.map +1 -1
- package/internal.d.ts +1515 -67
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -80
- package/internal.js.map +1 -1
- package/ledger.d.ts +23 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +247 -0
- package/ledger.js.map +1 -0
- package/listing.d.ts +132 -0
- package/listing.d.ts.map +1 -0
- package/listing.js +486 -0
- package/listing.js.map +1 -0
- package/lite/announce.d.ts +127 -66
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -159
- package/lite/announce.js.map +1 -1
- package/lite/announce_stream.d.ts +2 -0
- package/lite/announce_stream.d.ts.map +1 -0
- package/lite/announce_stream.js +92 -0
- package/lite/announce_stream.js.map +1 -0
- package/lite/answer.d.ts +22 -0
- package/lite/answer.d.ts.map +1 -0
- package/lite/answer.js +301 -0
- package/lite/answer.js.map +1 -0
- package/lite/auth.d.ts +45 -0
- package/lite/auth.d.ts.map +1 -0
- package/lite/auth.js +204 -0
- package/lite/auth.js.map +1 -0
- package/lite/compat.d.ts +31 -0
- package/lite/compat.d.ts.map +1 -0
- package/lite/compat.js +86 -0
- package/lite/compat.js.map +1 -0
- package/lite/connection.d.ts +1 -45
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +360 -78
- package/lite/connection.js.map +1 -1
- package/lite/datagram-end.d.ts +26 -0
- package/lite/datagram-end.d.ts.map +1 -0
- package/lite/datagram-end.js +30 -0
- package/lite/datagram-end.js.map +1 -0
- package/lite/datagram.d.ts +73 -8
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +144 -10
- package/lite/datagram.js.map +1 -1
- package/lite/duration.d.ts +6 -0
- package/lite/duration.d.ts.map +1 -0
- package/lite/duration.js +14 -0
- package/lite/duration.js.map +1 -0
- package/lite/error.d.ts +9 -0
- package/lite/error.d.ts.map +1 -0
- package/lite/error.js +24 -0
- package/lite/error.js.map +1 -0
- package/lite/fills.d.ts +162 -0
- package/lite/fills.d.ts.map +1 -0
- package/lite/fills.js +486 -0
- package/lite/fills.js.map +1 -0
- package/lite/fit.d.ts +49 -0
- package/lite/fit.d.ts.map +1 -0
- package/lite/fit.js +305 -0
- package/lite/fit.js.map +1 -0
- package/lite/goaway.d.ts +2 -2
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -14
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +67 -16
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -31
- package/lite/group.js.map +1 -1
- package/lite/identity.d.ts +25 -0
- package/lite/identity.d.ts.map +1 -0
- package/lite/identity.js +79 -0
- package/lite/identity.js.map +1 -0
- package/lite/index.d.ts +14 -13
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -2
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +10 -2
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -45
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +9 -2
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +11 -106
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts +2 -2
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -1
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +10 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +2548 -438
- package/lite/publisher.js.map +1 -1
- package/lite/routed.d.ts +59 -0
- package/lite/routed.d.ts.map +1 -0
- package/lite/routed.js +564 -0
- package/lite/routed.js.map +1 -0
- package/lite/session.d.ts +2 -28
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -100
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +32 -5
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -22
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +5 -11
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +5 -2
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +478 -78
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -143
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +7 -44
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +3290 -516
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +27 -12
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -38
- package/lite/track.js.map +1 -1
- package/lite/tracks.d.ts +55 -0
- package/lite/tracks.d.ts.map +1 -0
- package/lite/tracks.js +114 -0
- package/lite/tracks.js.map +1 -0
- package/lite/version.d.ts +132 -24
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +378 -34
- package/lite/version.js.map +1 -1
- package/meta.d.ts +77 -0
- package/meta.d.ts.map +1 -0
- package/meta.js +130 -0
- package/meta.js.map +1 -0
- package/meta_api.d.ts +7 -0
- package/meta_api.d.ts.map +1 -0
- package/meta_api.js +7 -0
- package/meta_api.js.map +1 -0
- package/mint.d.ts +28 -0
- package/mint.d.ts.map +1 -0
- package/mint.js +66 -0
- package/mint.js.map +1 -0
- package/open.d.ts +63 -0
- package/open.d.ts.map +1 -0
- package/open.js +250 -0
- package/open.js.map +1 -0
- package/origin.d.ts +394 -142
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -687
- package/origin.js.map +1 -1
- package/package.json +8 -13
- package/path.d.ts +51 -51
- package/path.d.ts.map +1 -1
- package/path.js +210 -58
- package/path.js.map +1 -1
- package/payload.d.ts +33 -0
- package/payload.d.ts.map +1 -0
- package/payload.js +65 -0
- package/payload.js.map +1 -0
- package/prefix.d.ts +152 -0
- package/prefix.d.ts.map +1 -0
- package/prefix.js +349 -0
- package/prefix.js.map +1 -0
- package/priority.d.ts +8 -0
- package/priority.d.ts.map +1 -0
- package/priority.js +185 -0
- package/priority.js.map +1 -0
- package/queue.d.ts +2 -0
- package/queue.d.ts.map +1 -0
- package/queue.js +46 -0
- package/queue.js.map +1 -0
- package/ranges.d.ts +36 -0
- package/ranges.d.ts.map +1 -0
- package/ranges.js +312 -0
- package/ranges.js.map +1 -0
- package/rescale.d.ts +24 -0
- package/rescale.d.ts.map +1 -0
- package/rescale.js +39 -0
- package/rescale.js.map +1 -0
- package/resume.d.ts +55 -0
- package/resume.d.ts.map +1 -0
- package/resume.js +4173 -0
- package/resume.js.map +1 -0
- package/resume.test-util.d.ts +2 -0
- package/resume.test-util.d.ts.map +1 -0
- package/resume.test-util.js +25 -0
- package/resume.test-util.js.map +1 -0
- package/skips.d.ts +48 -0
- package/skips.d.ts.map +1 -0
- package/skips.js +182 -0
- package/skips.js.map +1 -0
- package/stream.d.ts +78 -40
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -93
- package/stream.js.map +1 -1
- package/subscription.test-util.d.ts +2 -0
- package/subscription.test-util.d.ts.map +1 -0
- package/subscription.test-util.js +49 -0
- package/subscription.test-util.js.map +1 -0
- package/tail.d.ts +23 -14
- package/tail.d.ts.map +1 -1
- package/tail.js +224 -98
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -92
- package/time.js.map +1 -1
- package/timed.d.ts +21 -0
- package/timed.d.ts.map +1 -0
- package/timed.js +2 -0
- package/timed.js.map +1 -0
- package/track.d.ts +578 -246
- package/track.d.ts.map +1 -1
- package/track.js +7306 -772
- package/track.js.map +1 -1
- package/track_api.d.ts +7 -0
- package/track_api.d.ts.map +1 -0
- package/track_api.js +7 -0
- package/track_api.js.map +1 -0
- package/util/abort.d.ts +1 -0
- package/util/abort.d.ts.map +1 -1
- package/util/abort.js +23 -2
- package/util/abort.js.map +1 -1
- package/util/announce.d.ts +4 -0
- package/util/announce.d.ts.map +1 -0
- package/util/announce.js +11 -0
- package/util/announce.js.map +1 -0
- package/util/bigint.d.ts +3 -0
- package/util/bigint.d.ts.map +1 -0
- package/util/bigint.js +8 -0
- package/util/bigint.js.map +1 -0
- package/util/change.d.ts +12 -0
- package/util/change.d.ts.map +1 -0
- package/util/change.js +18 -0
- package/util/change.js.map +1 -0
- package/util/deadline.d.ts +2 -0
- package/util/deadline.d.ts.map +1 -0
- package/util/deadline.js +108 -0
- package/util/deadline.js.map +1 -0
- package/util/decode_error.d.ts +3 -0
- package/util/decode_error.d.ts.map +1 -0
- package/util/decode_error.js +11 -0
- package/util/decode_error.js.map +1 -0
- package/util/demand.d.ts +8 -0
- package/util/demand.d.ts.map +1 -0
- package/util/demand.js +24 -0
- package/util/demand.js.map +1 -0
- package/util/given_up.d.ts +2 -0
- package/util/given_up.d.ts.map +1 -0
- package/util/given_up.js +101 -0
- package/util/given_up.js.map +1 -0
- package/util/hex.d.ts +6 -0
- package/util/hex.d.ts.map +1 -1
- package/util/hex.js +19 -5
- package/util/hex.js.map +1 -1
- package/util/key.d.ts +15 -0
- package/util/key.d.ts.map +1 -0
- package/util/key.js +38 -0
- package/util/key.js.map +1 -0
- package/util/limits.d.ts +2 -0
- package/util/limits.d.ts.map +1 -0
- package/util/limits.js +76 -0
- package/util/limits.js.map +1 -0
- package/util/observed.d.ts +23 -0
- package/util/observed.d.ts.map +1 -0
- package/util/observed.js +122 -0
- package/util/observed.js.map +1 -0
- package/util/sorted.d.ts +2 -0
- package/util/sorted.d.ts.map +1 -0
- package/util/sorted.js +149 -0
- package/util/sorted.js.map +1 -0
- package/util/timeout.d.ts +2 -1
- package/util/timeout.d.ts.map +1 -1
- package/util/timeout.js +13 -10
- package/util/timeout.js.map +1 -1
- package/util/timer.d.ts +2 -0
- package/util/timer.d.ts.map +1 -0
- package/util/timer.js +19 -0
- package/util/timer.js.map +1 -0
- package/util/u64.js +0 -1
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -2
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -2
- package/util/varint.js.map +1 -1
- package/util/watch.d.ts +8 -0
- package/util/watch.d.ts.map +1 -0
- package/util/watch.js +38 -0
- package/util/watch.js.map +1 -0
- package/util/yield.d.ts +2 -0
- package/util/yield.d.ts.map +1 -0
- package/util/yield.js +31 -0
- package/util/yield.js.map +1 -0
- package/varint.d.ts +0 -29
- package/varint.d.ts.map +1 -1
- package/varint.js +7 -29
- package/varint.js.map +1 -1
- package/varint_api.d.ts +7 -0
- package/varint_api.d.ts.map +1 -0
- package/varint_api.js +7 -0
- package/varint_api.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/window.d.ts +570 -0
- package/window.d.ts.map +1 -0
- package/window.js +1677 -0
- package/window.js.map +1 -0
- package/wire.d.ts +150 -35
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -1
- package/wire.js.map +1 -1
- package/connection/established.d.ts +0 -53
- package/connection/established.d.ts.map +0 -1
- package/connection/established.js +0 -3
- package/connection/established.js.map +0 -1
- package/ietf/adapter.d.ts +0 -75
- package/ietf/adapter.d.ts.map +0 -1
- package/ietf/adapter.js +0 -700
- package/ietf/adapter.js.map +0 -1
- package/lite/datagram_stream.d.ts +0 -8
- package/lite/datagram_stream.d.ts.map +0 -1
- package/lite/datagram_stream.js +0 -44
- package/lite/datagram_stream.js.map +0 -1
- package/lite/fetch.d.ts +0 -28
- package/lite/fetch.d.ts.map +0 -1
- package/lite/fetch.js +0 -79
- package/lite/fetch.js.map +0 -1
- package/util/log.d.ts +0 -5
- package/util/log.d.ts.map +0 -1
- package/util/log.js +0 -17
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -19
- package/zod.js.map +0 -1
package/connection/accept.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { Duration } from "@moq/clock";
|
|
2
|
+
import type { Cost } from "../hop.ts";
|
|
3
|
+
import type { Consumer as OriginConsumer, Producer as OriginProducer } from "../origin.ts";
|
|
4
|
+
import type { Session } from "./session.ts";
|
|
5
|
+
/** Options for {@link Connection.accept}. */
|
|
4
6
|
export interface AcceptProps {
|
|
5
7
|
/** The accepted transport. */
|
|
6
8
|
transport: WebTransport;
|
|
7
9
|
/** The request URL associated with the transport. */
|
|
8
10
|
url: URL;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
+
/** Bound SETUP (default: 30 s; `null` waits until aborted). Throws ConnectTimeout. */
|
|
12
|
+
timeout?: Duration | null;
|
|
13
|
+
/** Abort the handshake and release the transport; ignored after acceptance completes. */
|
|
14
|
+
signal?: AbortSignal;
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
16
|
+
* The versions to accept, spelled like `ConnectProps.versions`; default: every supported
|
|
17
|
+
* version. A session negotiating any other is refused.
|
|
14
18
|
*/
|
|
15
|
-
|
|
19
|
+
versions?: readonly string[];
|
|
16
20
|
/**
|
|
17
21
|
* The origin whose broadcasts the session announces and serves to the peer. Omit to
|
|
18
22
|
* publish nothing. Borrowed, not owned: closing the session leaves its broadcasts alone.
|
|
@@ -23,14 +27,18 @@ export interface AcceptProps {
|
|
|
23
27
|
* nothing. The entries retract when the session dies; see the `consume` connect option.
|
|
24
28
|
*/
|
|
25
29
|
consume?: OriginProducer;
|
|
30
|
+
/**
|
|
31
|
+
* Price this link; see the `cost` connect option. Wins over the price the client declares, so
|
|
32
|
+
* a server can price a peer it recognizes.
|
|
33
|
+
*/
|
|
34
|
+
cost?: Cost;
|
|
35
|
+
/** The implementation this side advertises in SETUP; see the `implementation` connect option. */
|
|
36
|
+
implementation?: string;
|
|
26
37
|
}
|
|
27
38
|
/**
|
|
28
39
|
* Server-side handshake: accepts a transport and performs the server half of the SETUP exchange.
|
|
29
40
|
*
|
|
30
|
-
* @
|
|
31
|
-
* @param url - The URL of the connection
|
|
32
|
-
* @param props - Optional configuration
|
|
33
|
-
* @returns A promise that resolves to a Connection instance
|
|
41
|
+
* @returns A promise that resolves to an established session
|
|
34
42
|
*/
|
|
35
|
-
export declare function accept({ transport, url, ...props }: AcceptProps): Promise<
|
|
43
|
+
export declare function accept({ transport, url, ...props }: AcceptProps): Promise<Session>;
|
|
36
44
|
//# sourceMappingURL=accept.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../src/connection/accept.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../src/connection/accept.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAItC,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ3F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC3B,8BAA8B;IAC9B,SAAS,EAAE,YAAY,CAAC;IACxB,qDAAqD;IACrD,GAAG,EAAE,GAAG,CAAC;IAET,sFAAsF;IACtF,OAAO,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,yFAAyF;IACzF,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAE7B;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,iGAAiG;IACjG,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAaD;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAqCxF"}
|
package/connection/accept.js
CHANGED
|
@@ -1,56 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
import { race } from "@moq/signals";
|
|
2
|
+
import { ConnectTimeout, closeReason, error, fromClose, ProtocolViolation } from "../error.js";
|
|
2
3
|
import * as Ietf from "../ietf/index.js";
|
|
4
|
+
import { IMPLEMENTATION } from "../implementation.js";
|
|
3
5
|
import * as Lite from "../lite/index.js";
|
|
4
6
|
import { Stream } from "../stream.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
+
import { untilAborted } from "../util/abort.js";
|
|
8
|
+
import { after } from "../util/timer.js";
|
|
9
|
+
import { acceptable } from "./connect.js";
|
|
10
|
+
import { DISCOVERY_REMOVED, forwardAnnounced } from "./forward.js";
|
|
11
|
+
import { checkCost, connectTimeout, exchangeSetup, handsOff, link } from "./handshake.js";
|
|
12
|
+
import * as Liveness from "./liveness.js";
|
|
7
13
|
/**
|
|
8
14
|
* Server-side handshake: accepts a transport and performs the server half of the SETUP exchange.
|
|
9
15
|
*
|
|
10
|
-
* @
|
|
11
|
-
* @param url - The URL of the connection
|
|
12
|
-
* @param props - Optional configuration
|
|
13
|
-
* @returns A promise that resolves to a Connection instance
|
|
16
|
+
* @returns A promise that resolves to an established session
|
|
14
17
|
*/
|
|
15
18
|
export async function accept({ transport, url, ...props }) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
if ("discovery" in props)
|
|
20
|
+
throw new TypeError(DISCOVERY_REMOVED);
|
|
21
|
+
props.signal?.throwIfAborted();
|
|
22
|
+
checkCost(props.cost);
|
|
23
|
+
const limit = connectTimeout(props.timeout);
|
|
24
|
+
const deadline = new AbortController();
|
|
25
|
+
const signal = props.signal ? AbortSignal.any([props.signal, deadline.signal]) : deadline.signal;
|
|
26
|
+
const disarm = limit === null ? () => { } : after(limit, () => deadline.abort(new ConnectTimeout(limit)));
|
|
27
|
+
const pending = acceptInner(transport, url, props);
|
|
28
|
+
// As on connect, a dead transport must end a SETUP whose peer sends nothing more.
|
|
29
|
+
const terminal = transport.closed.then(fromClose, error).then((cause) => {
|
|
30
|
+
throw cause ?? new Error("session closed during SETUP");
|
|
31
|
+
});
|
|
32
|
+
try {
|
|
33
|
+
const connection = await untilAborted(race([pending, terminal]), signal);
|
|
34
|
+
if (signal.aborted)
|
|
35
|
+
throw signal.reason;
|
|
36
|
+
if (props.consume)
|
|
37
|
+
forwardAnnounced(connection, props.consume);
|
|
38
|
+
return connection;
|
|
39
|
+
}
|
|
40
|
+
catch (failure) {
|
|
41
|
+
try {
|
|
42
|
+
transport.close(failure instanceof ProtocolViolation
|
|
43
|
+
? { closeCode: failure.code, reason: closeReason(failure.message) }
|
|
44
|
+
: undefined);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
/* Already closed. */
|
|
48
|
+
}
|
|
49
|
+
// A handshake that resolves after cancellation must release its connection too.
|
|
50
|
+
void pending.then((connection) => connection.abort(), () => { });
|
|
51
|
+
throw props.signal?.aborted ? props.signal.reason : failure;
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
disarm();
|
|
55
|
+
}
|
|
20
56
|
}
|
|
21
57
|
async function acceptInner(transport, url, props) {
|
|
58
|
+
// Before reading the protocol, which a qmux session settles by the time its parameters arrive.
|
|
59
|
+
const liveness = await Liveness.watch(transport);
|
|
22
60
|
// The DOM lib has no `protocol` property yet. It is "" when none was negotiated, and
|
|
23
61
|
// undefined in a browser that predates subprotocols (Firefox before 155).
|
|
24
62
|
const protocol = transport.protocol;
|
|
63
|
+
const accepted = acceptable(props.versions);
|
|
64
|
+
const pinned = protocol !== Lite.ALPN && protocol !== "" && protocol !== undefined;
|
|
65
|
+
if (accepted && pinned && !accepted.alpns.includes(protocol)) {
|
|
66
|
+
throw new Error(`unaccepted WebTransport protocol: ${protocol}`);
|
|
67
|
+
}
|
|
25
68
|
const wiring = {
|
|
26
|
-
discovery: props.discovery ?? true,
|
|
27
69
|
publish: props.publish,
|
|
70
|
+
client: false,
|
|
71
|
+
implementation: props.implementation ?? IMPLEMENTATION,
|
|
72
|
+
liveness,
|
|
73
|
+
...link(props),
|
|
28
74
|
};
|
|
75
|
+
if (protocol === Ietf.ALPN.DRAFT_23) {
|
|
76
|
+
return acceptAlpn(transport, url, Ietf.Version.DRAFT_23, wiring);
|
|
77
|
+
}
|
|
29
78
|
if (protocol === Ietf.ALPN.DRAFT_22) {
|
|
30
79
|
return acceptAlpn(transport, url, Ietf.Version.DRAFT_22, wiring);
|
|
31
80
|
}
|
|
32
|
-
if (protocol === Ietf.ALPN.DRAFT_21) {
|
|
33
|
-
return acceptAlpn(transport, url, Ietf.Version.DRAFT_21, wiring);
|
|
34
|
-
}
|
|
35
81
|
if (protocol === Ietf.ALPN.DRAFT_20) {
|
|
36
82
|
return acceptAlpn(transport, url, Ietf.Version.DRAFT_20, wiring);
|
|
37
83
|
}
|
|
38
|
-
if (protocol === Ietf.ALPN.
|
|
39
|
-
return acceptAlpn(transport, url, Ietf.Version.DRAFT_19, wiring);
|
|
40
|
-
}
|
|
41
|
-
else if (protocol === Ietf.ALPN.DRAFT_18) {
|
|
84
|
+
if (protocol === Ietf.ALPN.DRAFT_18) {
|
|
42
85
|
return acceptAlpn(transport, url, Ietf.Version.DRAFT_18, wiring);
|
|
43
86
|
}
|
|
44
|
-
else if (protocol ===
|
|
45
|
-
return acceptAlpn(transport, url, Ietf.Version.DRAFT_17, wiring);
|
|
46
|
-
}
|
|
47
|
-
else if (protocol === Ietf.ALPN.DRAFT_16) {
|
|
48
|
-
return acceptSetup(transport, url, Ietf.Version.DRAFT_16, wiring);
|
|
49
|
-
}
|
|
50
|
-
else if (protocol === Ietf.ALPN.DRAFT_15) {
|
|
51
|
-
return acceptSetup(transport, url, Ietf.Version.DRAFT_15, wiring);
|
|
52
|
-
}
|
|
53
|
-
else if (protocol === Lite.ALPN_07_WIP) {
|
|
87
|
+
else if (protocol === Lite.ALPN_07) {
|
|
54
88
|
return new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_07, ...wiring });
|
|
55
89
|
}
|
|
56
90
|
else if (protocol === Lite.ALPN_06) {
|
|
@@ -66,126 +100,59 @@ async function acceptInner(transport, url, props) {
|
|
|
66
100
|
return new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_03, ...wiring });
|
|
67
101
|
}
|
|
68
102
|
else if (protocol === Lite.ALPN || protocol === "" || protocol === undefined) {
|
|
69
|
-
return acceptNegotiated(transport, url, wiring,
|
|
103
|
+
return acceptNegotiated(transport, url, wiring, accepted?.setup);
|
|
70
104
|
}
|
|
71
105
|
else {
|
|
72
106
|
throw new Error(`unsupported WebTransport protocol: ${protocol}`);
|
|
73
107
|
}
|
|
74
108
|
}
|
|
75
109
|
/**
|
|
76
|
-
*
|
|
110
|
+
* Moq-transport accept: ALPN already pinned the version. SETUP is exchanged over
|
|
77
111
|
* a pair of uni streams using stream type 0x2F00.
|
|
78
112
|
*/
|
|
79
113
|
async function acceptAlpn(transport, url, version, wiring) {
|
|
80
|
-
|
|
81
|
-
|
|
114
|
+
// Spread whole, so every negotiated flag reaches the connection.
|
|
115
|
+
// The IETF session code loads on demand, since most sessions negotiate lite; the ALPN already
|
|
116
|
+
// committed to IETF, so fetch it alongside SETUP.
|
|
117
|
+
const [setup, { Connection }] = await Promise.all([
|
|
118
|
+
exchangeSetup(transport, version, wiring.implementation, wiring),
|
|
119
|
+
import("../ietf/connection.js"),
|
|
120
|
+
]);
|
|
121
|
+
return new Connection({
|
|
82
122
|
...wiring,
|
|
83
123
|
client: false,
|
|
84
124
|
url,
|
|
85
125
|
quic: transport,
|
|
86
|
-
|
|
87
|
-
early,
|
|
88
|
-
solicit,
|
|
89
|
-
hidden,
|
|
90
|
-
cluster,
|
|
91
|
-
// v17+ uses NativeSession which manages its own request IDs; maxRequestId is unused.
|
|
92
|
-
maxRequestId: 0n,
|
|
126
|
+
...setup,
|
|
93
127
|
version,
|
|
94
128
|
});
|
|
95
129
|
}
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
async function acceptSetup(transport, url, version, wiring) {
|
|
101
|
-
// Accept bidi, read ClientSetup, write ServerSetup
|
|
102
|
-
const stream = await Stream.accept(transport, version);
|
|
130
|
+
/** `moql`, or no subprotocol: negotiate moq-lite in SETUP. */
|
|
131
|
+
async function acceptNegotiated(transport, url, wiring, accepted) {
|
|
132
|
+
// The SETUP keeps lite-02's framing whichever version it offers.
|
|
133
|
+
const stream = await Stream.accept(transport, Lite.Version.DRAFT_02);
|
|
103
134
|
if (!stream)
|
|
104
135
|
throw new Error("no incoming bidi stream for SETUP");
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
params.setVarint(Ietf.SetupOption.MaxRequestId, 42069n);
|
|
114
|
-
params.setBytes(Ietf.SetupOption.Implementation, encoder.encode("moq-lite-js"));
|
|
115
|
-
Ietf.solicitIntoSetup(params);
|
|
116
|
-
Ietf.hiddenIntoSetup(params);
|
|
117
|
-
const server = new Ietf.ServerSetup({ version, parameters: params });
|
|
118
|
-
await server.encode(stream.writer, version);
|
|
119
|
-
const maxRequestId = 42069n;
|
|
120
|
-
return new Ietf.Connection({
|
|
121
|
-
...wiring,
|
|
122
|
-
client: false,
|
|
123
|
-
url,
|
|
124
|
-
quic: transport,
|
|
125
|
-
control: stream,
|
|
126
|
-
maxRequestId,
|
|
127
|
-
version,
|
|
128
|
-
solicit: Ietf.solicitFromSetup(client.parameters),
|
|
129
|
-
hidden: Ietf.hiddenFromSetup(client.parameters),
|
|
130
|
-
});
|
|
136
|
+
const client = await Lite.ClientSetup.decode(stream.reader);
|
|
137
|
+
const selected = select(client, accepted);
|
|
138
|
+
await new Lite.ServerSetup(selected).encode(stream.writer);
|
|
139
|
+
if (handsOff(selected)) {
|
|
140
|
+
stream.close();
|
|
141
|
+
return new Lite.Connection({ url, quic: transport, version: selected, ...wiring });
|
|
142
|
+
}
|
|
143
|
+
return new Lite.Connection({ url, quic: transport, version: selected, session: stream, ...wiring });
|
|
131
144
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// Pick the requested version, or first matching version from client's list
|
|
143
|
-
const allVersions = [...Object.values(Lite.Version), ...Object.values(Ietf.Version)];
|
|
144
|
-
let selectedVersion;
|
|
145
|
-
if (version !== undefined) {
|
|
146
|
-
selectedVersion = version;
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const match = client.versions.find((v) => allVersions.includes(v));
|
|
150
|
-
if (match === undefined) {
|
|
151
|
-
throw new Error(`no common version found; client offered: ${client.versions.map((v) => v.toString(16)).join(", ")}`);
|
|
152
|
-
}
|
|
153
|
-
selectedVersion = match;
|
|
154
|
-
}
|
|
155
|
-
await stream.writer.u53(Lite.StreamId.ServerCompat);
|
|
156
|
-
const encoder = new TextEncoder();
|
|
157
|
-
const params = new Ietf.SetupOptions();
|
|
158
|
-
params.setVarint(Ietf.SetupOption.MaxRequestId, 42069n);
|
|
159
|
-
params.setBytes(Ietf.SetupOption.Implementation, encoder.encode("moq-lite-js"));
|
|
160
|
-
Ietf.solicitIntoSetup(params);
|
|
161
|
-
Ietf.hiddenIntoSetup(params);
|
|
162
|
-
const server = new Ietf.ServerSetup({ version: selectedVersion, parameters: params });
|
|
163
|
-
await server.encode(stream.writer, setupVersion);
|
|
164
|
-
if (Object.values(Lite.Version).includes(selectedVersion)) {
|
|
165
|
-
return new Lite.Connection({
|
|
166
|
-
url,
|
|
167
|
-
quic: transport,
|
|
168
|
-
version: selectedVersion,
|
|
169
|
-
session: stream,
|
|
170
|
-
...wiring,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
else if (Object.values(Ietf.Version).includes(selectedVersion)) {
|
|
174
|
-
const maxRequestId = client.parameters.getVarint(Ietf.SetupOption.MaxRequestId) ?? 0n;
|
|
175
|
-
return new Ietf.Connection({
|
|
176
|
-
...wiring,
|
|
177
|
-
client: false,
|
|
178
|
-
url,
|
|
179
|
-
quic: transport,
|
|
180
|
-
control: stream,
|
|
181
|
-
maxRequestId,
|
|
182
|
-
version: selectedVersion,
|
|
183
|
-
solicit: Ietf.solicitFromSetup(client.parameters),
|
|
184
|
-
hidden: Ietf.hiddenFromSetup(client.parameters),
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
throw new Error(`unsupported version: ${selectedVersion.toString(16)}`);
|
|
145
|
+
/**
|
|
146
|
+
* The moq-lite version a server answers a `moql` SETUP with: the client's first that `accepted`
|
|
147
|
+
* holds (default: any negotiable). Mirrors `setup::Client::select` in moq-net.
|
|
148
|
+
*
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
export function select(client, accepted) {
|
|
152
|
+
const selected = client.versions.find((v) => accepted === undefined ? Lite.isNegotiated(v) : accepted.includes(v));
|
|
153
|
+
if (selected === undefined || !Lite.isNegotiated(selected)) {
|
|
154
|
+
throw new Error(`no common version found; client offered: ${client.versions.map((v) => v.toString(16)).join(", ")}`);
|
|
189
155
|
}
|
|
156
|
+
return selected;
|
|
190
157
|
}
|
|
191
158
|
//# sourceMappingURL=accept.js.map
|
package/connection/accept.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../src/connection/accept.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAqC/C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,KAAK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C;AACF,CAAC","sourcesContent":["import * 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 type { Established } from \"./established.ts\";\nimport { forwardAnnounced } from \"./forward.ts\";\nimport { exchangeSetup } from \"./handshake.ts\";\n\n/** Options for {@link accept}. */\nexport interface AcceptProps {\n\t/** The accepted transport. */\n\ttransport: WebTransport;\n\t/** The request URL associated with the transport. */\n\turl: URL;\n\n\t/** Version to select during SETUP negotiation (for non-ALPN paths). */\n\tversion?: number;\n\n\t/**\n\t * Whether this server 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. Borrowed, not owned: closing the session leaves its broadcasts alone.\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. The entries retract when the session dies; see the `consume` connect option.\n\t */\n\tconsume?: OriginProducer;\n}\n\n/** The per-session wiring shared by every negotiated protocol path. */\ntype SessionProps = {\n\tdiscovery: boolean;\n\tpublish?: OriginConsumer;\n};\n\n/**\n * Server-side handshake: accepts a transport and performs the server half of the SETUP exchange.\n *\n * @param transport - The WebTransport session to accept\n * @param url - The URL of the connection\n * @param props - Optional configuration\n * @returns A promise that resolves to a Connection instance\n */\nexport async function accept({ transport, url, ...props }: AcceptProps): Promise<Established> {\n\tconst connection = await acceptInner(transport, url, props);\n\tif (props.consume) forwardAnnounced(connection, props.consume);\n\treturn connection;\n}\n\nasync function acceptInner(\n\ttransport: WebTransport,\n\turl: URL,\n\tprops: Omit<AcceptProps, \"transport\" | \"url\">,\n): Promise<Established> {\n\t// The DOM lib has no `protocol` property yet. It is \"\" when none was negotiated, and\n\t// undefined in a browser that predates subprotocols (Firefox before 155).\n\tconst protocol = (transport as { protocol?: string }).protocol;\n\n\tconst wiring: SessionProps = {\n\t\tdiscovery: props.discovery ?? true,\n\t\tpublish: props.publish,\n\t};\n\n\tif (protocol === Ietf.ALPN.DRAFT_22) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_22, wiring);\n\t}\n\tif (protocol === Ietf.ALPN.DRAFT_21) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_21, wiring);\n\t}\n\tif (protocol === Ietf.ALPN.DRAFT_20) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_20, wiring);\n\t}\n\tif (protocol === Ietf.ALPN.DRAFT_19) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_19, wiring);\n\t} else if (protocol === Ietf.ALPN.DRAFT_18) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_18, wiring);\n\t} else if (protocol === Ietf.ALPN.DRAFT_17) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_17, wiring);\n\t} else if (protocol === Ietf.ALPN.DRAFT_16) {\n\t\treturn acceptSetup(transport, url, Ietf.Version.DRAFT_16, wiring);\n\t} else if (protocol === Ietf.ALPN.DRAFT_15) {\n\t\treturn acceptSetup(transport, url, Ietf.Version.DRAFT_15, wiring);\n\t} else if (protocol === Lite.ALPN_07_WIP) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_07, ...wiring });\n\t} else if (protocol === Lite.ALPN_06) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_06, ...wiring });\n\t} else if (protocol === Lite.ALPN_05) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_05, ...wiring });\n\t} else if (protocol === Lite.ALPN_04) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_04, ...wiring });\n\t} else if (protocol === Lite.ALPN_03) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_03, ...wiring });\n\t} else if (protocol === Lite.ALPN || protocol === \"\" || protocol === undefined) {\n\t\treturn acceptNegotiated(transport, url, wiring, props.version);\n\t} else {\n\t\tthrow new Error(`unsupported WebTransport protocol: ${protocol}`);\n\t}\n}\n\n/**\n * Draft-17+ accept: ALPN already pinned the version. SETUP is exchanged over\n * a pair of uni streams using stream type 0x2F00.\n */\nasync function acceptAlpn(\n\ttransport: WebTransport,\n\turl: URL,\n\tversion: Ietf.IetfVersion,\n\twiring: SessionProps,\n): Promise<Established> {\n\tconst { control, early, solicit, hidden, cluster } = await exchangeSetup(transport, version, \"moq-lite-js\");\n\n\treturn new Ietf.Connection({\n\t\t...wiring,\n\t\tclient: false,\n\t\turl,\n\t\tquic: transport,\n\t\tcontrol,\n\t\tearly,\n\t\tsolicit,\n\t\thidden,\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/**\n * Legacy accept (draft-15/16): ALPN pinned the version, but the SETUP message\n * is still exchanged over a bidi stream wrapped in the moq-lite compat envelope.\n */\nasync function acceptSetup(\n\ttransport: WebTransport,\n\turl: URL,\n\tversion: Ietf.IetfVersion,\n\twiring: SessionProps,\n): Promise<Established> {\n\t// Accept bidi, read ClientSetup, write ServerSetup\n\tconst stream = await Stream.accept(transport, version);\n\tif (!stream) throw new Error(\"no incoming bidi stream for SETUP\");\n\n\tconst clientCompat = await stream.reader.u53();\n\tif (clientCompat !== Lite.StreamId.ClientCompat) {\n\t\tthrow new Error(`unexpected client message type: 0x${clientCompat.toString(16)}`);\n\t}\n\n\tconst client = await Ietf.ClientSetup.decode(stream.reader, version);\n\n\tawait stream.writer.u53(Lite.StreamId.ServerCompat);\n\n\tconst encoder = new TextEncoder();\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\tIetf.hiddenIntoSetup(params);\n\n\tconst server = new Ietf.ServerSetup({ version, parameters: params });\n\tawait server.encode(stream.writer, version);\n\n\tconst maxRequestId = 42069n;\n\n\treturn new Ietf.Connection({\n\t\t...wiring,\n\t\tclient: false,\n\t\turl,\n\t\tquic: transport,\n\t\tcontrol: stream,\n\t\tmaxRequestId,\n\t\tversion,\n\t\tsolicit: Ietf.solicitFromSetup(client.parameters),\n\t\thidden: Ietf.hiddenFromSetup(client.parameters),\n\t});\n}\n\nasync function acceptNegotiated(\n\ttransport: WebTransport,\n\turl: URL,\n\twiring: SessionProps,\n\tversion?: number,\n): Promise<Established> {\n\tconst setupVersion = Ietf.Version.DRAFT_14;\n\n\tconst stream = await Stream.accept(transport, setupVersion);\n\tif (!stream) throw new Error(\"no incoming bidi stream for SETUP\");\n\n\tconst clientCompat = await stream.reader.u53();\n\tif (clientCompat !== Lite.StreamId.ClientCompat) {\n\t\tthrow new Error(`unexpected client message type: 0x${clientCompat.toString(16)}`);\n\t}\n\n\tconst client = await Ietf.ClientSetup.decode(stream.reader, setupVersion);\n\n\t// Pick the requested version, or first matching version from client's list\n\tconst allVersions = [...Object.values(Lite.Version), ...Object.values(Ietf.Version)] as number[];\n\tlet selectedVersion: number;\n\tif (version !== undefined) {\n\t\tselectedVersion = version;\n\t} else {\n\t\tconst match = client.versions.find((v) => allVersions.includes(v));\n\t\tif (match === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`no common version found; client offered: ${client.versions.map((v) => v.toString(16)).join(\", \")}`,\n\t\t\t);\n\t\t}\n\t\tselectedVersion = match;\n\t}\n\n\tawait stream.writer.u53(Lite.StreamId.ServerCompat);\n\n\tconst encoder = new TextEncoder();\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\tIetf.hiddenIntoSetup(params);\n\n\tconst server = new Ietf.ServerSetup({ version: selectedVersion, parameters: params });\n\tawait server.encode(stream.writer, setupVersion);\n\n\tif (Object.values(Lite.Version).includes(selectedVersion as Lite.Version)) {\n\t\treturn new Lite.Connection({\n\t\t\turl,\n\t\t\tquic: transport,\n\t\t\tversion: selectedVersion 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(selectedVersion as Ietf.Version)) {\n\t\tconst maxRequestId = client.parameters.getVarint(Ietf.SetupOption.MaxRequestId) ?? 0n;\n\t\treturn new Ietf.Connection({\n\t\t\t...wiring,\n\t\t\tclient: false,\n\t\t\turl,\n\t\t\tquic: transport,\n\t\t\tcontrol: stream,\n\t\t\tmaxRequestId,\n\t\t\tversion: selectedVersion as Ietf.IetfVersion,\n\t\t\tsolicit: Ietf.solicitFromSetup(client.parameters),\n\t\t\thidden: Ietf.hiddenFromSetup(client.parameters),\n\t\t});\n\t} else {\n\t\tthrow new Error(`unsupported version: ${selectedVersion.toString(16)}`);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../src/connection/accept.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,IAAI,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM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OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import type { Duration } from \"@moq/clock\";\nimport { type Getter, race } from \"@moq/signals\";\nimport { ConnectTimeout, closeReason, error, fromClose, ProtocolViolation } from \"../error.ts\";\nimport type { Cost } from \"../hop.ts\";\nimport * as Ietf from \"../ietf/index.ts\";\nimport { IMPLEMENTATION } from \"../implementation.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 { untilAborted } from \"../util/abort.ts\";\nimport { after } from \"../util/timer.ts\";\nimport { acceptable } from \"./connect.ts\";\nimport { DISCOVERY_REMOVED, forwardAnnounced } from \"./forward.ts\";\nimport { checkCost, connectTimeout, exchangeSetup, handsOff, type Link, link } from \"./handshake.ts\";\nimport * as Liveness from \"./liveness.ts\";\nimport type { Session } from \"./session.ts\";\n\n/** Options for {@link Connection.accept}. */\nexport interface AcceptProps {\n\t/** The accepted transport. */\n\ttransport: WebTransport;\n\t/** The request URL associated with the transport. */\n\turl: URL;\n\n\t/** Bound SETUP (default: 30 s; `null` waits until aborted). Throws ConnectTimeout. */\n\ttimeout?: Duration | null;\n\t/** Abort the handshake and release the transport; ignored after acceptance completes. */\n\tsignal?: AbortSignal;\n\n\t/**\n\t * The versions to accept, spelled like `ConnectProps.versions`; default: every supported\n\t * version. A session negotiating any other is refused.\n\t */\n\tversions?: readonly string[];\n\n\t/**\n\t * The origin whose broadcasts the session announces and serves to the peer. Omit to\n\t * publish nothing. Borrowed, not owned: closing the session leaves its broadcasts alone.\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. The entries retract when the session dies; see the `consume` connect option.\n\t */\n\tconsume?: OriginProducer;\n\n\t/**\n\t * Price this link; see the `cost` connect option. Wins over the price the client declares, so\n\t * a server can price a peer it recognizes.\n\t */\n\tcost?: Cost;\n\n\t/** The implementation this side advertises in SETUP; see the `implementation` connect option. */\n\timplementation?: string;\n}\n\n/** The per-session wiring shared by every negotiated protocol path. */\ntype SessionProps = {\n\tpublish?: OriginConsumer;\n\t/** Whether this side dialed; only the dialing side aborts on a publication its grant does not cover. */\n\tclient: boolean;\n\t/** The implementation this side advertises in SETUP; empty sends nothing. */\n\timplementation: string;\n\t/** The peer's liveness, on a transport that probes it. */\n\tliveness?: Getter<Liveness.Liveness>;\n} & Link;\n\n/**\n * Server-side handshake: accepts a transport and performs the server half of the SETUP exchange.\n *\n * @returns A promise that resolves to an established session\n */\nexport async function accept({ transport, url, ...props }: AcceptProps): Promise<Session> {\n\tif (\"discovery\" in props) throw new TypeError(DISCOVERY_REMOVED);\n\tprops.signal?.throwIfAborted();\n\tcheckCost(props.cost);\n\tconst limit = connectTimeout(props.timeout);\n\tconst deadline = new AbortController();\n\tconst signal = props.signal ? AbortSignal.any([props.signal, deadline.signal]) : deadline.signal;\n\tconst disarm = limit === null ? () => {} : after(limit, () => deadline.abort(new ConnectTimeout(limit)));\n\tconst pending = acceptInner(transport, url, props);\n\t// As on connect, a dead transport must end a SETUP whose peer sends nothing more.\n\tconst terminal = transport.closed.then(fromClose, error).then((cause) => {\n\t\tthrow cause ?? new Error(\"session closed during SETUP\");\n\t});\n\ttry {\n\t\tconst connection = await untilAborted(race([pending, terminal]), signal);\n\t\tif (signal.aborted) throw signal.reason;\n\t\tif (props.consume) forwardAnnounced(connection, props.consume);\n\t\treturn connection;\n\t} catch (failure) {\n\t\ttry {\n\t\t\ttransport.close(\n\t\t\t\tfailure instanceof ProtocolViolation\n\t\t\t\t\t? { closeCode: failure.code, reason: closeReason(failure.message) }\n\t\t\t\t\t: undefined,\n\t\t\t);\n\t\t} catch {\n\t\t\t/* Already closed. */\n\t\t}\n\t\t// A handshake that resolves after cancellation must release its connection too.\n\t\tvoid pending.then(\n\t\t\t(connection) => connection.abort(),\n\t\t\t() => {},\n\t\t);\n\t\tthrow props.signal?.aborted ? props.signal.reason : failure;\n\t} finally {\n\t\tdisarm();\n\t}\n}\n\nasync function acceptInner(\n\ttransport: WebTransport,\n\turl: URL,\n\tprops: Omit<AcceptProps, \"transport\" | \"url\">,\n): Promise<Session> {\n\t// Before reading the protocol, which a qmux session settles by the time its parameters arrive.\n\tconst liveness = await Liveness.watch(transport);\n\t// The DOM lib has no `protocol` property yet. It is \"\" when none was negotiated, and\n\t// undefined in a browser that predates subprotocols (Firefox before 155).\n\tconst protocol = (transport as { protocol?: string }).protocol;\n\n\tconst accepted = acceptable(props.versions);\n\tconst pinned = protocol !== Lite.ALPN && protocol !== \"\" && protocol !== undefined;\n\tif (accepted && pinned && !accepted.alpns.includes(protocol)) {\n\t\tthrow new Error(`unaccepted WebTransport protocol: ${protocol}`);\n\t}\n\n\tconst wiring: SessionProps = {\n\t\tpublish: props.publish,\n\t\tclient: false,\n\t\timplementation: props.implementation ?? IMPLEMENTATION,\n\t\tliveness,\n\t\t...link(props),\n\t};\n\n\tif (protocol === Ietf.ALPN.DRAFT_23) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_23, wiring);\n\t}\n\tif (protocol === Ietf.ALPN.DRAFT_22) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_22, wiring);\n\t}\n\tif (protocol === Ietf.ALPN.DRAFT_20) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_20, wiring);\n\t}\n\tif (protocol === Ietf.ALPN.DRAFT_18) {\n\t\treturn acceptAlpn(transport, url, Ietf.Version.DRAFT_18, wiring);\n\t} else if (protocol === Lite.ALPN_07) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_07, ...wiring });\n\t} else if (protocol === Lite.ALPN_06) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_06, ...wiring });\n\t} else if (protocol === Lite.ALPN_05) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_05, ...wiring });\n\t} else if (protocol === Lite.ALPN_04) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_04, ...wiring });\n\t} else if (protocol === Lite.ALPN_03) {\n\t\treturn new Lite.Connection({ url, quic: transport, version: Lite.Version.DRAFT_03, ...wiring });\n\t} else if (protocol === Lite.ALPN || protocol === \"\" || protocol === undefined) {\n\t\treturn acceptNegotiated(transport, url, wiring, accepted?.setup);\n\t} else {\n\t\tthrow new Error(`unsupported WebTransport protocol: ${protocol}`);\n\t}\n}\n\n/**\n * Moq-transport accept: ALPN already pinned the version. SETUP is exchanged over\n * a pair of uni streams using stream type 0x2F00.\n */\nasync function acceptAlpn(\n\ttransport: WebTransport,\n\turl: URL,\n\tversion: Ietf.IetfVersion,\n\twiring: SessionProps,\n): Promise<Session> {\n\t// Spread whole, so every negotiated flag reaches the connection.\n\t// The IETF session code loads on demand, since most sessions negotiate lite; the ALPN already\n\t// committed to IETF, so fetch it alongside SETUP.\n\tconst [setup, { Connection }] = await Promise.all([\n\t\texchangeSetup(transport, version, wiring.implementation, wiring),\n\t\timport(\"../ietf/connection.ts\"),\n\t]);\n\n\treturn new Connection({\n\t\t...wiring,\n\t\tclient: false,\n\t\turl,\n\t\tquic: transport,\n\t\t...setup,\n\t\tversion,\n\t});\n}\n\n/** `moql`, or no subprotocol: negotiate moq-lite in SETUP. */\nasync function acceptNegotiated(\n\ttransport: WebTransport,\n\turl: URL,\n\twiring: SessionProps,\n\taccepted?: readonly number[],\n): Promise<Session> {\n\t// The SETUP keeps lite-02's framing whichever version it offers.\n\tconst stream = await Stream.accept(transport, Lite.Version.DRAFT_02);\n\tif (!stream) throw new Error(\"no incoming bidi stream for SETUP\");\n\n\tconst client = await Lite.ClientSetup.decode(stream.reader);\n\tconst selected = select(client, accepted);\n\n\tawait new Lite.ServerSetup(selected).encode(stream.writer);\n\tif (handsOff(selected)) {\n\t\tstream.close();\n\t\treturn new Lite.Connection({ url, quic: transport, version: selected, ...wiring });\n\t}\n\treturn new Lite.Connection({ url, quic: transport, version: selected, session: stream, ...wiring });\n}\n\n/**\n * The moq-lite version a server answers a `moql` SETUP with: the client's first that `accepted`\n * holds (default: any negotiable). Mirrors `setup::Client::select` in moq-net.\n *\n * @internal\n */\nexport function select(client: Lite.ClientSetup, accepted?: readonly number[]): Lite.Version {\n\tconst selected = client.versions.find((v) =>\n\t\taccepted === undefined ? Lite.isNegotiated(v) : accepted.includes(v),\n\t);\n\tif (selected === undefined || !Lite.isNegotiated(selected)) {\n\t\tthrow new Error(\n\t\t\t`no common version found; client offered: ${client.versions.map((v) => v.toString(16)).join(\", \")}`,\n\t\t);\n\t}\n\treturn selected;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/connection/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/connection/browser.ts"],"names":[],"mappings":"AAiBA,qFAAqF;AACrF,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAO3E;AAUD,kEAAkE;AAClE,wBAAgB,uBAAuB,IAAI,OAAO,CAIjD"}
|
package/connection/browser.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** The browser versions needed by transport capability gates. @internal */
|
|
2
|
+
export function parseUserAgent(userAgent) {
|
|
3
|
+
const ios = /(?:iPhone|iPad|iPod)/.test(userAgent) || /Macintosh.*Mobile\//.test(userAgent);
|
|
4
|
+
const chromium = /(?:Chrome|Chromium|Edg|OPR)\//.test(userAgent);
|
|
5
|
+
return {
|
|
6
|
+
webkit: /AppleWebKit\//.test(userAgent) && !chromium,
|
|
7
|
+
ios: ios
|
|
8
|
+
? (/(?:CPU (?:iPhone )?OS|iPhone OS) ([\d_]+)/.exec(userAgent)?.[1]?.replaceAll("_", ".") ?? "unknown")
|
|
9
|
+
: undefined,
|
|
10
|
+
safari: /Safari\//.test(userAgent) && !chromium && !/(?:CriOS|FxiOS|EdgiOS)\//.test(userAgent)
|
|
11
|
+
? /Version\/([\d.]+)/.exec(userAgent)?.[1]
|
|
12
|
+
: undefined,
|
|
13
|
+
firefox: /Firefox\/(\d+)/.exec(userAgent)?.[1],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
3
16
|
/** Returns whether a browser user agent has a usable WebTransport implementation. */
|
|
4
17
|
export function isWebTransportUserAgentSupported(userAgent) {
|
|
5
|
-
const browser =
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
// on one session (moq-dev/moq#2388); one stream per group reaches that in
|
|
10
|
-
// about two minutes. Chrome, Firefox and Edge on iOS are WebKit under the
|
|
11
|
-
// hood, and iPadOS Safari reports macOS, so gate on the engine and the OS.
|
|
12
|
-
if (browser.getEngine().name === "WebKit" || browser.getOS().name === "iOS")
|
|
18
|
+
const browser = parseUserAgent(userAgent);
|
|
19
|
+
// WebKit stalls long sessions (bugs.webkit.org/show_bug.cgi?id=319818).
|
|
20
|
+
// iOS browsers use WebKit too, including iPadOS Safari's desktop user agent.
|
|
21
|
+
if (browser.webkit || browser.ios)
|
|
13
22
|
return false;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return supported;
|
|
23
|
+
// Firefox fixed its two concurrent incoming stream limit in version 153.
|
|
24
|
+
return browser.firefox === undefined || Number(browser.firefox) >= 153;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether a dial with these options would race WebTransport: the runtime supports it and the
|
|
28
|
+
* caller left it enabled. @internal
|
|
29
|
+
*/
|
|
30
|
+
export function webTransportDialed(options) {
|
|
31
|
+
return options?.enabled !== false && isWebTransportSupported();
|
|
24
32
|
}
|
|
25
33
|
/** Returns whether this runtime can connect with WebTransport. */
|
|
26
34
|
export function isWebTransportSupported() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/connection/browser.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/connection/browser.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC/C,MAAM,GAAG,GAAG,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5F,MAAM,QAAQ,GAAG,+BAA+B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjE,OAAO;QACN,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ;QACpD,GAAG,EAAE,GAAG;YACP,CAAC,CAAC,CAAC,2CAA2C,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,SAAS,CAAC;YACvG,CAAC,CAAC,SAAS;QACZ,MAAM,EACL,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC;YACrF,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC,SAAS;QACb,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;KAC9C,CAAC;AACH,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,gCAAgC,CAAC,SAAiB;IACjE,MAAM,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC1C,wEAAwE;IACxE,6EAA6E;IAC7E,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IAChD,yEAAyE;IACzE,OAAO,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC;AACxE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA+B;IACjE,OAAO,OAAO,EAAE,OAAO,KAAK,KAAK,IAAI,uBAAuB,EAAE,CAAC;AAChE,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,uBAAuB;IACtC,IAAI,OAAO,UAAU,CAAC,YAAY,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IACjE,IAAI,OAAO,SAAS,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAClD,OAAO,gCAAgC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/** The browser versions needed by transport capability gates. @internal */\nexport function parseUserAgent(userAgent: string) {\n\tconst ios = /(?:iPhone|iPad|iPod)/.test(userAgent) || /Macintosh.*Mobile\\//.test(userAgent);\n\tconst chromium = /(?:Chrome|Chromium|Edg|OPR)\\//.test(userAgent);\n\treturn {\n\t\twebkit: /AppleWebKit\\//.test(userAgent) && !chromium,\n\t\tios: ios\n\t\t\t? (/(?:CPU (?:iPhone )?OS|iPhone OS) ([\\d_]+)/.exec(userAgent)?.[1]?.replaceAll(\"_\", \".\") ?? \"unknown\")\n\t\t\t: undefined,\n\t\tsafari:\n\t\t\t/Safari\\//.test(userAgent) && !chromium && !/(?:CriOS|FxiOS|EdgiOS)\\//.test(userAgent)\n\t\t\t\t? /Version\\/([\\d.]+)/.exec(userAgent)?.[1]\n\t\t\t\t: undefined,\n\t\tfirefox: /Firefox\\/(\\d+)/.exec(userAgent)?.[1],\n\t};\n}\n\n/** Returns whether a browser user agent has a usable WebTransport implementation. */\nexport function isWebTransportUserAgentSupported(userAgent: string): boolean {\n\tconst browser = parseUserAgent(userAgent);\n\t// WebKit stalls long sessions (bugs.webkit.org/show_bug.cgi?id=319818).\n\t// iOS browsers use WebKit too, including iPadOS Safari's desktop user agent.\n\tif (browser.webkit || browser.ios) return false;\n\t// Firefox fixed its two concurrent incoming stream limit in version 153.\n\treturn browser.firefox === undefined || Number(browser.firefox) >= 153;\n}\n\n/**\n * Whether a dial with these options would race WebTransport: the runtime supports it and the\n * caller left it enabled. @internal\n */\nexport function webTransportDialed(options?: { enabled?: boolean }): boolean {\n\treturn options?.enabled !== false && isWebTransportSupported();\n}\n\n/** Returns whether this runtime can connect with WebTransport. */\nexport function isWebTransportSupported(): boolean {\n\tif (typeof globalThis.WebTransport === \"undefined\") return false;\n\tif (typeof navigator === \"undefined\") return true;\n\treturn isWebTransportUserAgentSupported(navigator.userAgent);\n}\n"]}
|