@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/lite/connection.js
CHANGED
|
@@ -1,37 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
import { Once, Signal } from "@moq/signals";
|
|
3
|
-
import
|
|
1
|
+
import { Duration } from "@moq/clock";
|
|
2
|
+
import { Effect, Once, Signal } from "@moq/signals";
|
|
3
|
+
import * as announce from "../announced.js";
|
|
4
|
+
import { AuthSession } from "../auth_session.js";
|
|
5
|
+
import { detect, statsOf, transportStats } from "../connection/stats.js";
|
|
4
6
|
import { transportOf } from "../connection/transport.js";
|
|
5
|
-
import { closeError, error, fromClose, ProtocolViolation, StreamCode, StreamError, sessionCause } from "../error.js";
|
|
7
|
+
import { closeError, closeReason, error, fromClose, ProtocolViolation, peerEnded, SessionCode, StreamCode, StreamError, sessionCause, } from "../error.js";
|
|
6
8
|
import { randomHop } from "../hop.js";
|
|
9
|
+
import { IMPLEMENTATION } from "../implementation.js";
|
|
10
|
+
import { lines } from "../open.js";
|
|
11
|
+
import * as Path from "../path.js";
|
|
7
12
|
import { Readers, Stream, Writer } from "../stream.js";
|
|
13
|
+
import { Observed } from "../util/observed.js";
|
|
14
|
+
import { withTimeout } from "../util/timeout.js";
|
|
8
15
|
import { registerWire } from "../wire.js";
|
|
9
|
-
import { AnnounceRequest } from "./announce.js";
|
|
10
|
-
import {
|
|
16
|
+
import { AnnounceRequest, decodeAnnounceBroadcastMaybe } from "./announce.js";
|
|
17
|
+
import { AnnounceStream } from "./announce_stream.js";
|
|
18
|
+
import { LiteAuthWire } from "./auth.js";
|
|
19
|
+
import { Datagrams } from "./datagram.js";
|
|
20
|
+
import { closeViolation } from "./error.js";
|
|
11
21
|
import { Goaway } from "./goaway.js";
|
|
12
22
|
import { Group } from "./group.js";
|
|
23
|
+
import { probeBitrate } from "./probe.js";
|
|
13
24
|
import { Publisher } from "./publisher.js";
|
|
14
25
|
import { SessionInfo } from "./session.js";
|
|
15
|
-
import { ProbeLevel, Setup } from "./setup.js";
|
|
26
|
+
import { hasClientParameters, ProbeLevel, Setup } from "./setup.js";
|
|
16
27
|
import { DataType, StreamId } from "./stream.js";
|
|
17
28
|
import { Subscribe } from "./subscribe.js";
|
|
18
29
|
import { Subscriber } from "./subscriber.js";
|
|
19
30
|
import { Track as TrackMessage } from "./track.js";
|
|
20
|
-
import {
|
|
31
|
+
import { Tracks as TracksMessage } from "./tracks.js";
|
|
32
|
+
import { hasAuth, hasDatagrams, hasDatagramTracks, hasGoaway, hasProbeRtt, hasRoutes, hasSetupStream, hasTrackStream, hasTracks, Version, versionName, } from "./version.js";
|
|
21
33
|
/**
|
|
22
34
|
* Represents a connection to a MoQ server.
|
|
23
35
|
*
|
|
24
|
-
* @
|
|
36
|
+
* @internal
|
|
25
37
|
*/
|
|
26
38
|
export class Connection {
|
|
39
|
+
#phase = { kind: "open" };
|
|
27
40
|
// The URL of the connection.
|
|
28
41
|
url;
|
|
29
42
|
// The version of the connection as a human-readable string.
|
|
30
43
|
version;
|
|
31
44
|
// The wire transport this session runs over.
|
|
32
45
|
transport;
|
|
33
|
-
/** Whether the relay supports broadcast discovery; see {@link Established.discovery}. */
|
|
34
|
-
discovery;
|
|
35
46
|
// The version used for encoding/decoding.
|
|
36
47
|
#version;
|
|
37
48
|
// The established WebTransport session.
|
|
@@ -42,41 +53,59 @@ export class Connection {
|
|
|
42
53
|
#publisher;
|
|
43
54
|
// Module for distributing tracks.
|
|
44
55
|
#subscriber;
|
|
45
|
-
|
|
56
|
+
// The received unidirectional streams still being read, which a closing session drains.
|
|
57
|
+
#unis = new Set();
|
|
58
|
+
/** The peer's PROBE estimates; see {@link Session.probe}. */
|
|
46
59
|
probe;
|
|
47
|
-
/**
|
|
48
|
-
|
|
60
|
+
/** The peer's liveness, on a transport that probes it; see {@link Session.liveness}. */
|
|
61
|
+
liveness;
|
|
62
|
+
// Our tokens and grants, and the answers to the peer's; see {@link Session.auth}.
|
|
63
|
+
#auth;
|
|
64
|
+
/** This side's Hop ID, shared by Publisher (for outbound hop chains) and Subscriber (to drop
|
|
65
|
+
* what crossed us). Random per connection, except a lite-07 publisher's, which is its origin's. */
|
|
49
66
|
hop;
|
|
50
67
|
// The peer's SETUP, recorded once its Setup stream is read (lite-05+). Streams whose
|
|
51
68
|
// encoding depends on a negotiated capability (e.g. PROBE) wait on this. undefined
|
|
52
69
|
// until the peer's SETUP arrives; stays undefined forever on older drafts.
|
|
53
70
|
#peerSetup = new Signal(undefined);
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
#
|
|
71
|
+
#setupSeen = false;
|
|
72
|
+
// Lite-07: the peer opened its one Announce Stream.
|
|
73
|
+
#announceSeen = false;
|
|
74
|
+
// The transport closed, so a stream breaking says nothing about the peer.
|
|
75
|
+
#transportClosed = false;
|
|
57
76
|
// Written by the Subscriber as PROBE messages arrive.
|
|
58
|
-
#probe = new
|
|
77
|
+
#probe = new Observed({});
|
|
78
|
+
// Whether we dialed; see {@link ConnectionProps.client}.
|
|
79
|
+
#client;
|
|
80
|
+
// See {@link ConnectionProps.token}.
|
|
81
|
+
#token;
|
|
82
|
+
// What our SETUP advertises; see {@link ConnectionProps.implementation}.
|
|
83
|
+
#implementation;
|
|
84
|
+
// See {@link ConnectionProps.probeTarget}.
|
|
85
|
+
#probeTarget;
|
|
86
|
+
// See {@link ConnectionProps.cost}.
|
|
87
|
+
#cost;
|
|
88
|
+
#peerImplementation = Promise.withResolvers();
|
|
89
|
+
/** The implementation the peer advertised; see {@link Session.peerImplementation}. */
|
|
90
|
+
peerImplementation = this.#peerImplementation.promise;
|
|
59
91
|
// The peer's GOAWAY. Lite carries no deadline, so only the URI is set.
|
|
60
92
|
#goaway = new Once();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* peer's authorization grants the direction it intends to use.
|
|
64
|
-
*
|
|
65
|
-
* `undefined` until the peer's SETUP arrives, and forever on pre-lite-05 versions, which
|
|
66
|
-
* carry no in-band role. {@link Role.Both} is the absence of the parameter, so it is what
|
|
67
|
-
* a peer reports when it declines to declare a direction, sends a value we don't
|
|
68
|
-
* recognize, or is a server (which never sends one).
|
|
69
|
-
*/
|
|
70
|
-
get peerRole() {
|
|
71
|
-
return this.#peerRole;
|
|
72
|
-
}
|
|
93
|
+
// How the session ended: `fromClose` of the transport's close, settled after auth lets go of it.
|
|
94
|
+
#closed = new Once();
|
|
73
95
|
/**
|
|
74
96
|
* Creates a new Connection instance.
|
|
75
97
|
*
|
|
76
98
|
* @internal
|
|
77
99
|
*/
|
|
78
|
-
constructor({ url, quic, version, session,
|
|
100
|
+
constructor({ url, quic, version, session, publish, handle, client = true, token, implementation = IMPLEMENTATION, probeTarget, liveness, cost, priority = 0, }) {
|
|
101
|
+
this.liveness = liveness;
|
|
102
|
+
// A free link would leave a route as cheap as the one it came from, so lite-07 refuses one.
|
|
103
|
+
if (cost === 0n && hasRoutes(version))
|
|
104
|
+
throw new RangeError("a moq-lite-07 link cannot cost 0");
|
|
105
|
+
this.#cost = cost;
|
|
79
106
|
this.url = url;
|
|
107
|
+
// Older versions carry the credential in the URL instead.
|
|
108
|
+
this.#token = client && hasAuth(version) ? token : undefined;
|
|
80
109
|
this.#quic = quic;
|
|
81
110
|
this.#session = session;
|
|
82
111
|
// The session stream was opened at the SETUP exchange's version; the rest of it speaks this one.
|
|
@@ -87,20 +116,131 @@ export class Connection {
|
|
|
87
116
|
this.version = versionName(version);
|
|
88
117
|
this.#version = version;
|
|
89
118
|
this.transport = transportOf(quic);
|
|
90
|
-
this
|
|
119
|
+
detect(this, quic);
|
|
91
120
|
this.probe = this.#probe;
|
|
121
|
+
// Opens waiting for credit make room after about this RTT when the transport has none.
|
|
122
|
+
lines(quic).probe = this.#probe;
|
|
92
123
|
this.hop = randomHop();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
124
|
+
// What the peer's connection credential earns by default: publishing anything to us,
|
|
125
|
+
// since we consume on demand, and subscribing to whatever we publish.
|
|
126
|
+
this.#auth = new AuthSession({
|
|
127
|
+
wire: hasAuth(version) ? new LiteAuthWire(quic, version) : undefined,
|
|
128
|
+
peerGrant: {
|
|
129
|
+
publish: Path.Prefixes.all(),
|
|
130
|
+
subscribe: publish ? Path.Prefixes.all() : new Path.Prefixes(),
|
|
131
|
+
},
|
|
132
|
+
handle,
|
|
133
|
+
draining: () => this.#goaway.peek() !== undefined || this.#phase.kind !== "open",
|
|
134
|
+
// Without AUTH, the server checks a client's credential before its SETUP, which the client reads after going live.
|
|
135
|
+
awaiting: client && hasSetupStream(version) && !hasAuth(version),
|
|
136
|
+
// Lite-03/04 have neither, so the peer refuses the credential only by closing the
|
|
137
|
+
// session. Lite-01/02 answered in the negotiation SETUP already read.
|
|
138
|
+
silent: client && (version === Version.DRAFT_03 || version === Version.DRAFT_04),
|
|
139
|
+
});
|
|
140
|
+
// Left before anything observes the close, so a successor on the same handle never
|
|
141
|
+
// finds this session still active.
|
|
142
|
+
const leave = () => {
|
|
143
|
+
this.#transportClosed = true;
|
|
144
|
+
this.#auth.close();
|
|
145
|
+
};
|
|
146
|
+
void quic.closed.then(leave, leave);
|
|
147
|
+
void quic.closed.then((info) => this.#closed.set(fromClose(info)), (err) => this.#closed.set(error(err)));
|
|
148
|
+
// Lite-07: a send on this endpoint's Announce Stream failed while the session lives. On
|
|
149
|
+
// native WebTransport, a peer that stopped it with no code of its own is leaving, as a
|
|
150
|
+
// server closing the session stops it before its close arrives: the peer's routes end, and
|
|
151
|
+
// the session's close says why. Otherwise what this endpoint said is lost and the session
|
|
152
|
+
// cannot go on, as rs/moq-net closes it.
|
|
153
|
+
if (hasRoutes(version)) {
|
|
154
|
+
void AnnounceStream.of(quic, version).broken.then((err) => {
|
|
155
|
+
if (this.#transportClosed || this.#phase.kind === "closed")
|
|
156
|
+
return;
|
|
157
|
+
if (peerEnded(quic, err))
|
|
158
|
+
return this.#subscriber.announceFinished();
|
|
159
|
+
// Not a clean close: the peer learns that what this endpoint said was lost.
|
|
160
|
+
quic.close({ closeCode: SessionCode.Internal, reason: closeReason("announce stream failed") });
|
|
161
|
+
this.#fail(error(err));
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
this.#auth.violated.subscribe((err) => {
|
|
165
|
+
if (!err)
|
|
166
|
+
return;
|
|
167
|
+
closeViolation(this.#quic, err);
|
|
168
|
+
this.#fail(err);
|
|
169
|
+
});
|
|
170
|
+
this.#publisher = new Publisher(this.#quic, this.#version, this.hop, publish, {
|
|
171
|
+
grant: this.#auth.scope,
|
|
172
|
+
ready: this.#auth.setupAnswered(),
|
|
173
|
+
});
|
|
174
|
+
this.#subscriber = new Subscriber(this.#quic, this.#version, this.hop, this.#probe, this.#peerSetup, this.#goaway, this.#auth.scope, undefined, this.#auth, { cost, priority });
|
|
175
|
+
this.#client = client;
|
|
176
|
+
this.#implementation = implementation;
|
|
177
|
+
this.#probeTarget = probeTarget;
|
|
178
|
+
// Only the lite-05+ Setup Stream carries it.
|
|
179
|
+
if (!hasSetupStream(version))
|
|
180
|
+
this.#peerImplementation.resolve(undefined);
|
|
181
|
+
registerWire(this, {
|
|
182
|
+
consume: (path, identity) => this.#subscriber.consume(path, identity),
|
|
183
|
+
exclusive: false,
|
|
184
|
+
leave: () => this.#leave(),
|
|
185
|
+
auth: this.#auth,
|
|
186
|
+
});
|
|
96
187
|
void this.#run();
|
|
97
188
|
}
|
|
189
|
+
#leave() {
|
|
190
|
+
if (this.#phase.kind !== "open")
|
|
191
|
+
return;
|
|
192
|
+
this.#phase = { kind: "leaving" };
|
|
193
|
+
if (!hasGoaway(this.#version))
|
|
194
|
+
return;
|
|
195
|
+
const version = this.#version;
|
|
196
|
+
const send = async () => {
|
|
197
|
+
const stream = await Stream.open(this.#quic, { version });
|
|
198
|
+
await stream.writer.u53(StreamId.Goaway);
|
|
199
|
+
await new Goaway("").encode(stream.writer, version);
|
|
200
|
+
stream.writer.close();
|
|
201
|
+
};
|
|
202
|
+
// A session closing first has nothing left to tell.
|
|
203
|
+
send().catch((err) => console.debug("failed to send GOAWAY:", err));
|
|
204
|
+
}
|
|
205
|
+
/** Our tokens and grants; see {@link Session.auth}. */
|
|
206
|
+
get auth() {
|
|
207
|
+
return this.#auth.handle;
|
|
208
|
+
}
|
|
98
209
|
/**
|
|
99
|
-
*
|
|
210
|
+
* Withdraw announcements and finish the requests this session serves, waiting up to one
|
|
211
|
+
* second for delivery before closing.
|
|
212
|
+
*
|
|
213
|
+
* A served subscription first delivers its remaining group streams, and from lite-05 also
|
|
214
|
+
* waits for the subscriber's FIN, which says it read the tail. A live track never ends on
|
|
215
|
+
* its own, so it holds the close until the deadline.
|
|
100
216
|
*/
|
|
101
217
|
close() {
|
|
218
|
+
switch (this.#phase.kind) {
|
|
219
|
+
case "open":
|
|
220
|
+
case "leaving": {
|
|
221
|
+
// Leaving finishes our Announce Stream, which asks the peer for nothing more.
|
|
222
|
+
this.#subscriber.announceSilenced();
|
|
223
|
+
const done = withTimeout(this.#publisher.drain(), Duration.millis(1000), "session close timed out").finally(() => this.abort());
|
|
224
|
+
this.#phase = { kind: "closing", done };
|
|
225
|
+
return done;
|
|
226
|
+
}
|
|
227
|
+
case "closing":
|
|
228
|
+
return this.#phase.done;
|
|
229
|
+
case "closed":
|
|
230
|
+
return Promise.resolve();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** End the session immediately without waiting for delivery. */
|
|
234
|
+
abort() {
|
|
235
|
+
if (this.#phase.kind === "closed")
|
|
236
|
+
return;
|
|
237
|
+
this.#phase = { kind: "closed" };
|
|
238
|
+
this.#auth.close();
|
|
102
239
|
this.#publisher.close();
|
|
103
|
-
|
|
240
|
+
// Received tracks end in #run once what already arrived drains, as on the peer's close.
|
|
241
|
+
this.#closeTransport();
|
|
242
|
+
}
|
|
243
|
+
#closeTransport() {
|
|
104
244
|
try {
|
|
105
245
|
// TODO: For whatever reason, this try/catch doesn't seem to work..?
|
|
106
246
|
this.#quic.close();
|
|
@@ -109,12 +249,27 @@ export class Connection {
|
|
|
109
249
|
// ignore
|
|
110
250
|
}
|
|
111
251
|
}
|
|
252
|
+
// End the received tracks with the session's end, then tear down the rest.
|
|
253
|
+
#fail(err) {
|
|
254
|
+
this.#subscriber.close(err);
|
|
255
|
+
this.abort();
|
|
256
|
+
}
|
|
112
257
|
async #run() {
|
|
113
|
-
const
|
|
258
|
+
const unis = this.#runUnis();
|
|
259
|
+
const tasks = [this.#runSession(), this.#runBidis(), unis];
|
|
114
260
|
if (hasSetupStream(this.#version)) {
|
|
115
261
|
tasks.push(this.#sendSetup());
|
|
116
262
|
}
|
|
117
|
-
|
|
263
|
+
const probes = new Effect((effect) => {
|
|
264
|
+
if (!effect.get(this.#probe.wanted))
|
|
265
|
+
return;
|
|
266
|
+
effect.spawn(() => this.#subscriber.runProbe(effect.abort, this.#probeTarget));
|
|
267
|
+
});
|
|
268
|
+
// Fail loud on a publication our grant never covers, once the peer has answered the
|
|
269
|
+
// credential we presented at setup.
|
|
270
|
+
if (this.#client && hasAuth(this.#version)) {
|
|
271
|
+
tasks.push(this.#publisher.runEnforce(this.#auth.setupAnswered(), this.#auth));
|
|
272
|
+
}
|
|
118
273
|
// Route incoming QUIC datagrams into their subscriptions (lite-05+; runDatagrams
|
|
119
274
|
// no-ops on a transport that doesn't carry them).
|
|
120
275
|
if (hasDatagrams(this.#version)) {
|
|
@@ -122,7 +277,9 @@ export class Connection {
|
|
|
122
277
|
}
|
|
123
278
|
let fatal;
|
|
124
279
|
try {
|
|
125
|
-
|
|
280
|
+
// An application close rejects QMux's pending accepts with a teardown error.
|
|
281
|
+
// The transport's close result owns that termination, rather than the task failure.
|
|
282
|
+
await Promise.race([Promise.all(tasks), this.#quic.closed]);
|
|
126
283
|
}
|
|
127
284
|
catch (err) {
|
|
128
285
|
console.error("fatal error running connection", err);
|
|
@@ -130,14 +287,30 @@ export class Connection {
|
|
|
130
287
|
fatal = await sessionCause(this.#quic, err);
|
|
131
288
|
}
|
|
132
289
|
finally {
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
this.#
|
|
136
|
-
this
|
|
290
|
+
probes.close();
|
|
291
|
+
// A session that ends before the peer's SETUP never learns its implementation.
|
|
292
|
+
this.#peerImplementation.resolve(undefined);
|
|
293
|
+
const err = fatal ?? (await closeError(this.#quic));
|
|
294
|
+
// A failed task can end the session over a live transport. Closing it first ends
|
|
295
|
+
// every read the drain waits on.
|
|
296
|
+
this.#closeTransport();
|
|
297
|
+
// The peer's close can overtake the group streams and SUBSCRIBE FIN it sent first.
|
|
298
|
+
// Read what already arrived, so a track its publisher ended finishes rather than aborts.
|
|
299
|
+
// Accepting yields to the host, so take the streams still queued before draining.
|
|
300
|
+
await unis.catch(() => { });
|
|
301
|
+
await Promise.all([...this.#unis, this.#subscriber.drain()]);
|
|
302
|
+
// The session ended under every track it was receiving, so they end with its
|
|
303
|
+
// error: a clean close from either side reads as a cancelled session.
|
|
304
|
+
this.#fail(err);
|
|
137
305
|
}
|
|
138
306
|
}
|
|
139
|
-
announced
|
|
140
|
-
|
|
307
|
+
/** The paths announced at or beneath `prefix`, each present or absent; see {@link Session.announced}. */
|
|
308
|
+
announced(prefix, options) {
|
|
309
|
+
return announce.list(this.#subscriber.routes(prefix, options));
|
|
310
|
+
}
|
|
311
|
+
/** Every route change at or beneath `prefix`, for code that forwards routes. @internal */
|
|
312
|
+
routes(prefix, options) {
|
|
313
|
+
return this.#subscriber.routes(prefix, options);
|
|
141
314
|
}
|
|
142
315
|
async #runSession() {
|
|
143
316
|
if (!this.#session) {
|
|
@@ -159,15 +332,22 @@ export class Connection {
|
|
|
159
332
|
// path and leave routing to the URL. The probe level reflects what this transport
|
|
160
333
|
// can actually measure; we never pad, so we never advertise Increase.
|
|
161
334
|
// Role stays Both: the publish origin starts empty and fills later, and consume is
|
|
162
|
-
// called after this point, so there is nothing to narrow yet.
|
|
163
|
-
// our session identity so the peer can filter
|
|
164
|
-
//
|
|
335
|
+
// called after this point, so there is nothing to narrow yet. Before lite-07 the hop
|
|
336
|
+
// declares our session identity so the peer can filter reflected announcements
|
|
337
|
+
// (lite-06 removed ANNOUNCE_REQUEST's exclude_hop for it). Lite-07 sends none: only a node
|
|
338
|
+
// that forwards declares a Node ID.
|
|
165
339
|
async #sendSetup() {
|
|
166
340
|
const writer = await Writer.open(this.#quic, { version: this.#version });
|
|
167
341
|
try {
|
|
168
342
|
await writer.u53(DataType.Setup);
|
|
169
343
|
const probe = await probeLevel(this.#quic, this.#version);
|
|
170
|
-
await new Setup({
|
|
344
|
+
await new Setup({
|
|
345
|
+
probe,
|
|
346
|
+
cost: this.#cost,
|
|
347
|
+
hop: this.hop,
|
|
348
|
+
token: this.#token,
|
|
349
|
+
implementation: this.#implementation,
|
|
350
|
+
}).encode(writer, this.#version);
|
|
171
351
|
writer.close();
|
|
172
352
|
}
|
|
173
353
|
catch (err) {
|
|
@@ -183,11 +363,12 @@ export class Connection {
|
|
|
183
363
|
this.#runBidi(stream)
|
|
184
364
|
.catch((err) => {
|
|
185
365
|
stream.writer.reset(err);
|
|
366
|
+
stream.reader.stop(err);
|
|
186
367
|
// A protocol violation on one stream is the peer breaking the session.
|
|
187
|
-
// Resetting that stream
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
this
|
|
368
|
+
// Resetting that stream would leave it free to repeat malformed input.
|
|
369
|
+
const violation = closeViolation(this.#quic, err);
|
|
370
|
+
if (violation)
|
|
371
|
+
this.#fail(violation);
|
|
191
372
|
})
|
|
192
373
|
.finally(() => {
|
|
193
374
|
stream.writer.close();
|
|
@@ -196,37 +377,68 @@ export class Connection {
|
|
|
196
377
|
}
|
|
197
378
|
async #runBidi(stream) {
|
|
198
379
|
const typ = await stream.reader.u53();
|
|
380
|
+
// A type this version does not know, including one it predates, is an extension stream
|
|
381
|
+
// opened without negotiating it: NOT_SUPPORTED resets the stream and keeps the session.
|
|
199
382
|
if (typ === StreamId.Session) {
|
|
200
|
-
throw new
|
|
383
|
+
throw new ProtocolViolation("duplicate session stream");
|
|
201
384
|
}
|
|
202
|
-
else if (typ === StreamId.Announce) {
|
|
385
|
+
else if (typ === StreamId.Announce && !hasRoutes(this.#version)) {
|
|
386
|
+
// Lite-07 asks on its Announce Stream instead, and knows no such stream type.
|
|
203
387
|
const msg = await AnnounceRequest.decode(stream.reader, this.#version);
|
|
204
388
|
await this.#publisher.runAnnounce(msg, stream);
|
|
205
389
|
}
|
|
206
390
|
else if (typ === StreamId.Subscribe) {
|
|
207
|
-
|
|
208
|
-
await this.#publisher.
|
|
391
|
+
// Owed from dispatch, so a close that lands mid-decode still waits for the request.
|
|
392
|
+
await this.#publisher.owe((async () => {
|
|
393
|
+
const msg = await Subscribe.decode(stream.reader, this.#version);
|
|
394
|
+
await this.#publisher.runSubscribe(msg, stream);
|
|
395
|
+
})());
|
|
209
396
|
}
|
|
210
|
-
else if (typ === StreamId.
|
|
211
|
-
|
|
212
|
-
|
|
397
|
+
else if (typ === StreamId.Datagrams) {
|
|
398
|
+
if (!hasDatagramTracks(this.#version))
|
|
399
|
+
throw unsupported("DATAGRAMS");
|
|
400
|
+
await this.#publisher.owe((async () => {
|
|
401
|
+
const msg = await Datagrams.decode(stream.reader, this.#version);
|
|
402
|
+
await this.#publisher.runDatagrams(msg, stream);
|
|
403
|
+
})());
|
|
213
404
|
}
|
|
214
405
|
else if (typ === StreamId.Track) {
|
|
215
|
-
|
|
216
|
-
|
|
406
|
+
if (!hasTrackStream(this.#version))
|
|
407
|
+
throw unsupported("TRACK");
|
|
408
|
+
await this.#publisher.owe((async () => {
|
|
409
|
+
const msg = await TrackMessage.decode(stream.reader, this.#version);
|
|
410
|
+
await this.#publisher.runTrackInfo(msg, stream);
|
|
411
|
+
})());
|
|
412
|
+
}
|
|
413
|
+
else if (typ === StreamId.Tracks) {
|
|
414
|
+
if (!hasTracks(this.#version))
|
|
415
|
+
throw unsupported("TRACKS");
|
|
416
|
+
const msg = await TracksMessage.decode(stream.reader, this.#version);
|
|
417
|
+
await this.#publisher.runTracks(msg, stream);
|
|
217
418
|
}
|
|
218
419
|
else if (typ === StreamId.Probe) {
|
|
420
|
+
if (this.#version === Version.DRAFT_01 || this.#version === Version.DRAFT_02)
|
|
421
|
+
throw unsupported("PROBE");
|
|
219
422
|
await this.#publisher.runProbe(stream);
|
|
220
423
|
}
|
|
424
|
+
else if (typ === StreamId.Auth) {
|
|
425
|
+
if (!hasAuth(this.#version))
|
|
426
|
+
throw unsupported("AUTH");
|
|
427
|
+
await this.#auth.serve(stream);
|
|
428
|
+
}
|
|
221
429
|
else if (typ === StreamId.Goaway) {
|
|
430
|
+
if (!hasGoaway(this.#version))
|
|
431
|
+
throw unsupported("GOAWAY");
|
|
222
432
|
const msg = await Goaway.decode(stream.reader, this.#version);
|
|
223
433
|
// A peer sends at most one; a second is a protocol violation.
|
|
224
434
|
if (this.#goaway.peek() !== undefined)
|
|
225
435
|
throw new ProtocolViolation("duplicate GOAWAY");
|
|
436
|
+
if (!this.#client && msg.uri !== "")
|
|
437
|
+
throw new ProtocolViolation("client GOAWAY URI must be empty");
|
|
226
438
|
this.#goaway.set({ uri: msg.uri });
|
|
227
439
|
}
|
|
228
440
|
else {
|
|
229
|
-
throw
|
|
441
|
+
throw unsupported(`stream type ${typ.toString()}`);
|
|
230
442
|
}
|
|
231
443
|
}
|
|
232
444
|
async #runUnis() {
|
|
@@ -235,13 +447,19 @@ export class Connection {
|
|
|
235
447
|
const stream = await readers.next();
|
|
236
448
|
if (!stream)
|
|
237
449
|
break;
|
|
238
|
-
this.#runUni(stream)
|
|
450
|
+
const task = this.#runUni(stream)
|
|
239
451
|
.then(() => {
|
|
240
|
-
stream.stop(
|
|
452
|
+
stream.stop(StreamCode.Cancel);
|
|
241
453
|
})
|
|
242
454
|
.catch((err) => {
|
|
243
455
|
stream.stop(err);
|
|
244
|
-
|
|
456
|
+
if (err instanceof ProtocolViolation) {
|
|
457
|
+
closeViolation(this.#quic, err);
|
|
458
|
+
this.#fail(err);
|
|
459
|
+
}
|
|
460
|
+
})
|
|
461
|
+
.finally(() => this.#unis.delete(task));
|
|
462
|
+
this.#unis.add(task);
|
|
245
463
|
}
|
|
246
464
|
}
|
|
247
465
|
async #runUni(stream) {
|
|
@@ -250,26 +468,90 @@ export class Connection {
|
|
|
250
468
|
const msg = await Group.decode(stream, this.#version);
|
|
251
469
|
await this.#subscriber.runGroup(msg, stream);
|
|
252
470
|
}
|
|
471
|
+
else if (typ === DataType.Announce && hasRoutes(this.#version)) {
|
|
472
|
+
// Claim the stream before reading it, so two that say nothing yet are duplicates too.
|
|
473
|
+
if (this.#announceSeen)
|
|
474
|
+
throw new ProtocolViolation("duplicate Announce Stream");
|
|
475
|
+
this.#announceSeen = true;
|
|
476
|
+
await this.#runAnnounce(stream);
|
|
477
|
+
}
|
|
253
478
|
else if (typ === DataType.Setup) {
|
|
479
|
+
// Claim the stream before decoding, so two incomplete SETUPs are duplicates too.
|
|
480
|
+
if (this.#setupSeen)
|
|
481
|
+
throw new ProtocolViolation("duplicate SETUP");
|
|
482
|
+
this.#setupSeen = true;
|
|
254
483
|
// The peer sends exactly one SETUP, then FINs. Record it so capability-gated
|
|
255
|
-
// streams (e.g. PROBE) can react
|
|
256
|
-
|
|
484
|
+
// streams (e.g. PROBE) can react.
|
|
485
|
+
// The slot is claimed, so no other SETUP can arrive and the streams waiting on it
|
|
486
|
+
// would hang. The session cannot continue.
|
|
487
|
+
const setup = await Setup.decode(stream, this.#version).catch((err) => {
|
|
488
|
+
throw new ProtocolViolation("invalid SETUP", { cause: err });
|
|
489
|
+
});
|
|
490
|
+
if (this.#client && hasClientParameters(setup))
|
|
491
|
+
throw new ProtocolViolation("server SETUP contains Path, Role, or Token");
|
|
492
|
+
if (!this.#client && setup.path !== undefined)
|
|
493
|
+
throw new ProtocolViolation("Path on a URI-carrying binding");
|
|
257
494
|
this.#peerSetup.set(setup);
|
|
258
|
-
this.#
|
|
495
|
+
this.#auth.accept();
|
|
496
|
+
this.#peerImplementation.resolve(setup.implementation);
|
|
259
497
|
}
|
|
260
498
|
else {
|
|
261
499
|
throw new Error(`unknown stream type: ${typ.toString()}`);
|
|
262
500
|
}
|
|
263
501
|
}
|
|
264
|
-
|
|
502
|
+
// Lite-07: everything the peer says about discovery and routing, in order, until it leaves.
|
|
503
|
+
// The peer leaves by finishing the stream, or, on native WebTransport, resetting it with no
|
|
504
|
+
// code of its own.
|
|
505
|
+
async #runAnnounce(stream) {
|
|
506
|
+
for (;;) {
|
|
507
|
+
let msg;
|
|
508
|
+
try {
|
|
509
|
+
msg = await decodeAnnounceBroadcastMaybe(stream, this.#version);
|
|
510
|
+
}
|
|
511
|
+
catch (err) {
|
|
512
|
+
// An ending session's own end says why. On native WebTransport, a peer that reset the
|
|
513
|
+
// stream with no code of its own, even mid-message, is leaving: a server closing the
|
|
514
|
+
// session resets it before its close arrives, with a code Chrome reports as an
|
|
515
|
+
// application's 0. Any other reset, a message cut short, or one that does not decode
|
|
516
|
+
// lost what the peer said.
|
|
517
|
+
if (this.#transportClosed || this.#phase.kind === "closed")
|
|
518
|
+
throw err;
|
|
519
|
+
if (peerEnded(this.#quic, err))
|
|
520
|
+
break;
|
|
521
|
+
throw new ProtocolViolation("Announce Stream broke", { cause: err });
|
|
522
|
+
}
|
|
523
|
+
if (!msg)
|
|
524
|
+
break;
|
|
525
|
+
// Nothing comes between the ANNOUNCE_REQUESTs of one edit.
|
|
526
|
+
if (msg.status !== "request" && this.#publisher.continuing())
|
|
527
|
+
throw new ProtocolViolation("a message inside an edit");
|
|
528
|
+
await this.#subscriber.announce(msg);
|
|
529
|
+
if (msg.status === "request")
|
|
530
|
+
this.#publisher.request(msg.more, msg.remove, msg.add);
|
|
531
|
+
}
|
|
532
|
+
// The peer is leaving: its routes end, and what it asked for is still answered.
|
|
533
|
+
this.#subscriber.announceFinished();
|
|
534
|
+
}
|
|
535
|
+
/** Snapshot the transport's counters; see {@link Session.stats}. */
|
|
265
536
|
async stats() {
|
|
266
|
-
|
|
537
|
+
const stats = await transportStats(this.#quic);
|
|
538
|
+
if (hasDatagrams(this.#version))
|
|
539
|
+
stats.datagramsUnrouted = this.#subscriber.datagramsUnrouted;
|
|
540
|
+
return stats;
|
|
267
541
|
}
|
|
268
|
-
/**
|
|
542
|
+
/** Settles with the peer's GOAWAY; see {@link Session.draining}. */
|
|
543
|
+
get draining() {
|
|
544
|
+
return this.#goaway;
|
|
545
|
+
}
|
|
546
|
+
/** Settles when the session closes, decoding the peer's close code; see {@link Session.closed}. */
|
|
269
547
|
get closed() {
|
|
270
|
-
return this.#
|
|
548
|
+
return this.#closed;
|
|
271
549
|
}
|
|
272
550
|
}
|
|
551
|
+
// Refuses a bidirectional stream of a type this version does not serve.
|
|
552
|
+
function unsupported(what) {
|
|
553
|
+
return new StreamError(StreamCode.NotSupported, { message: `${what} is not supported on this version` });
|
|
554
|
+
}
|
|
273
555
|
/**
|
|
274
556
|
* The probe level to advertise in SETUP, from what the transport can measure.
|
|
275
557
|
*
|
|
@@ -286,18 +568,18 @@ export class Connection {
|
|
|
286
568
|
* @internal
|
|
287
569
|
*/
|
|
288
570
|
export async function probeLevel(quic, version) {
|
|
289
|
-
const getStats = quic
|
|
290
|
-
if (
|
|
571
|
+
const getStats = statsOf(quic);
|
|
572
|
+
if (!getStats)
|
|
291
573
|
return ProbeLevel.None;
|
|
292
574
|
// A transport that can't answer tells us nothing, which is itself an answer.
|
|
293
575
|
let stats;
|
|
294
576
|
try {
|
|
295
|
-
stats = await getStats
|
|
577
|
+
stats = await getStats();
|
|
296
578
|
}
|
|
297
579
|
catch {
|
|
298
580
|
return ProbeLevel.None;
|
|
299
581
|
}
|
|
300
582
|
const rtt = hasProbeRtt(version) ? stats.smoothedRtt : undefined;
|
|
301
|
-
return stats.estimatedSendRate
|
|
583
|
+
return probeBitrate(stats.estimatedSendRate) !== undefined || rtt != null ? ProbeLevel.Report : ProbeLevel.None;
|
|
302
584
|
}
|
|
303
585
|
//# sourceMappingURL=connection.js.map
|