@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/ietf/connection.js
CHANGED
|
@@ -1,65 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
import { Once, Signal } from "@moq/signals";
|
|
3
|
-
import
|
|
1
|
+
import { Duration } from "@moq/clock";
|
|
2
|
+
import { Once, race, Signal } from "@moq/signals";
|
|
3
|
+
import * as announce from "../announced.js";
|
|
4
|
+
import { AuthSession } from "../auth_session.js";
|
|
5
|
+
import { detect, transportStats } from "../connection/stats.js";
|
|
4
6
|
import { transportOf } from "../connection/transport.js";
|
|
5
|
-
import { error, fromClose, ProtocolViolation,
|
|
7
|
+
import { closeReason, error, fromClose, ProtocolViolation, StreamCode, StreamError, sessionClosed } from "../error.js";
|
|
8
|
+
import { Cost } from "../hop.js";
|
|
9
|
+
import * as Path from "../path.js";
|
|
6
10
|
import { Readers } from "../stream.js";
|
|
11
|
+
import { withTimeout } from "../util/timeout.js";
|
|
7
12
|
import { registerWire } from "../wire.js";
|
|
8
|
-
import { ControlStreamAdapter, NativeSession } from "./adapter.js";
|
|
9
13
|
import * as Cluster from "./cluster.js";
|
|
14
|
+
import { IetfSessionCode } from "./error.js";
|
|
10
15
|
import { Fetch, FetchHeader } from "./fetch.js";
|
|
11
16
|
import { GoAway } from "./goaway.js";
|
|
17
|
+
import * as Message from "./message.js";
|
|
12
18
|
import { Group } from "./object.js";
|
|
13
19
|
import { Publish } from "./publish.js";
|
|
14
20
|
import { PublishNamespace } from "./publish_namespace.js";
|
|
15
21
|
import { Publisher } from "./publisher.js";
|
|
22
|
+
import { malformed, refuse } from "./request_stream.js";
|
|
23
|
+
import { NativeSession } from "./session.js";
|
|
16
24
|
import { Subscribe, SubscribeUpdate } from "./subscribe.js";
|
|
17
|
-
import { SUBSCRIBE_TRACKS_ID, SubscribeNamespace
|
|
25
|
+
import { SUBSCRIBE_TRACKS_ID, SubscribeNamespace } from "./subscribe_namespace.js";
|
|
18
26
|
import { Subscriber } from "./subscriber.js";
|
|
27
|
+
import { MalformedAuthToken } from "./token.js";
|
|
19
28
|
import { TrackStatusRequest } from "./track.js";
|
|
20
29
|
import { Version, versionName } from "./version.js";
|
|
21
30
|
// The PADDING stream type (draft-18+): bytes a peer sends to probe for bandwidth.
|
|
22
31
|
const PADDING = 0x132b3e28n;
|
|
32
|
+
// A handler owns its request stream, and ending the request (closing the session over a
|
|
33
|
+
// violation) is its job: closing again here could only send a competing code.
|
|
34
|
+
function handed(task) {
|
|
35
|
+
return task.catch((err) => console.error("error processing bidi stream", err));
|
|
36
|
+
}
|
|
23
37
|
/**
|
|
24
38
|
* Represents a connection to a MoQ server using moq-transport protocol.
|
|
25
39
|
*
|
|
26
|
-
* @
|
|
40
|
+
* @internal
|
|
27
41
|
*/
|
|
28
42
|
export class Connection {
|
|
43
|
+
#phase = { kind: "open" };
|
|
29
44
|
// The URL of the connection.
|
|
30
45
|
url;
|
|
31
46
|
// The negotiated protocol version.
|
|
32
47
|
version;
|
|
33
48
|
// The wire transport this session runs over.
|
|
34
49
|
transport;
|
|
35
|
-
/**
|
|
36
|
-
discovery;
|
|
37
|
-
/** moq-transport has no PROBE, so this stays empty; see {@link Established.probe}. */
|
|
50
|
+
/** moq-transport has no PROBE, so this stays empty; see {@link Session.probe}. */
|
|
38
51
|
probe = new Signal({});
|
|
52
|
+
/** The peer's liveness, on a transport that probes it; see {@link Session.liveness}. */
|
|
53
|
+
liveness;
|
|
54
|
+
/** Our tokens, which requests carry; see {@link Session.auth}. */
|
|
55
|
+
get auth() {
|
|
56
|
+
return this.#auth.handle;
|
|
57
|
+
}
|
|
58
|
+
// Our tokens, for the requests that carry them.
|
|
59
|
+
#auth;
|
|
39
60
|
// The established WebTransport session.
|
|
40
61
|
#quic;
|
|
41
|
-
// Whether this side opened the session. Only a server may name a redirect
|
|
62
|
+
// Whether this side opened the session. Only a server may name a redirect, and only
|
|
63
|
+
// the dialing side fails loud on a publication its grant does not cover.
|
|
42
64
|
#client;
|
|
43
|
-
//
|
|
65
|
+
// Opens request streams and allocates request IDs.
|
|
44
66
|
#session;
|
|
45
67
|
// Module for contributing tracks.
|
|
46
68
|
#publisher;
|
|
47
69
|
// Module for distributing tracks.
|
|
48
70
|
#subscriber;
|
|
49
|
-
// What the peer declared about being solicited; see {@link Ietf.solicitFromSetup}.
|
|
50
|
-
#solicit;
|
|
51
71
|
// The Hop IDs this session declared; see {@link Cluster}.
|
|
52
72
|
#cluster;
|
|
53
|
-
// The peer's GOAWAY
|
|
54
|
-
#goaway;
|
|
55
|
-
//
|
|
56
|
-
#closed =
|
|
73
|
+
// The peer's GOAWAY, read off its SETUP stream.
|
|
74
|
+
#goaway = new Once();
|
|
75
|
+
// How the session ended: `fromClose` of the transport's close, settled after auth lets go of it.
|
|
76
|
+
#closed = new Once();
|
|
77
|
+
/** The implementation the peer advertised; see {@link Session.peerImplementation}. */
|
|
78
|
+
peerImplementation;
|
|
57
79
|
/**
|
|
58
80
|
* Creates a new Connection instance.
|
|
59
81
|
* @param url - The URL of the connection
|
|
60
82
|
* @param quic - The WebTransport session
|
|
61
|
-
* @param control - The
|
|
62
|
-
* @param maxRequestId - The initial max request ID
|
|
83
|
+
* @param control - The SETUP stream, which then carries GOAWAY
|
|
63
84
|
* @param version - The negotiated protocol version
|
|
64
85
|
* @param solicit - What the peer's SETUP declared (undefined when it declared nothing)
|
|
65
86
|
* @param cluster - The Hop IDs the SETUP exchange settled, on the versions that negotiate them
|
|
@@ -67,63 +88,106 @@ export class Connection {
|
|
|
67
88
|
*
|
|
68
89
|
* @internal
|
|
69
90
|
*/
|
|
70
|
-
constructor({ url, quic, control,
|
|
91
|
+
constructor({ url, quic, control, version, client, publish, solicit, hidden = false, activeCount = false, cluster, handle, early = [], peerImplementation, liveness, linkCost, priority = 0, }) {
|
|
92
|
+
this.liveness = liveness;
|
|
71
93
|
this.url = url;
|
|
72
|
-
this.discovery = discovery;
|
|
73
94
|
this.version = versionName(version);
|
|
74
95
|
this.transport = transportOf(quic);
|
|
96
|
+
detect(this, quic);
|
|
75
97
|
this.#quic = quic;
|
|
76
98
|
this.#client = client;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
this.peerImplementation = Promise.resolve(peerImplementation);
|
|
100
|
+
this.#session = new NativeSession(quic, version, client);
|
|
101
|
+
// The SETUP stream only carries GOAWAY from here on.
|
|
102
|
+
void this.#runGoAway(control, version);
|
|
103
|
+
// What the peer's connection credential earns by default: publishing anything to us,
|
|
104
|
+
// since we consume on demand, and subscribing to whatever we publish.
|
|
105
|
+
this.#auth = new AuthSession({
|
|
106
|
+
requests: true,
|
|
107
|
+
peerGrant: {
|
|
108
|
+
publish: Path.Prefixes.all(),
|
|
109
|
+
subscribe: publish ? Path.Prefixes.all() : new Path.Prefixes(),
|
|
110
|
+
},
|
|
111
|
+
handle,
|
|
112
|
+
draining: () => this.#goaway.peek() !== undefined || this.#phase.kind !== "open",
|
|
113
|
+
});
|
|
114
|
+
// Left before anything observes the close, so a successor on the same handle never
|
|
115
|
+
// finds this session still active.
|
|
116
|
+
const leave = () => this.#auth.close();
|
|
117
|
+
void quic.closed.then(leave, leave);
|
|
118
|
+
void quic.closed.then((info) => this.#closed.set(fromClose(info)), (err) => this.#closed.set(error(err)));
|
|
119
|
+
this.#client = client;
|
|
120
|
+
this.#auth.violated.subscribe((err) => {
|
|
121
|
+
if (err)
|
|
122
|
+
this.#violated(err);
|
|
123
|
+
});
|
|
95
124
|
this.#publisher = new Publisher({
|
|
96
125
|
quic: this.#quic,
|
|
97
126
|
session: this.#session,
|
|
98
127
|
publish,
|
|
99
128
|
requiresSolicitation: solicit ?? false,
|
|
100
129
|
hidden,
|
|
130
|
+
activeCount,
|
|
101
131
|
cluster,
|
|
132
|
+
grant: this.#auth.scope,
|
|
133
|
+
auth: this.#auth,
|
|
102
134
|
});
|
|
103
|
-
this.#solicit = solicit;
|
|
104
135
|
this.#cluster = cluster;
|
|
105
|
-
this.#subscriber = new Subscriber({
|
|
106
|
-
|
|
136
|
+
this.#subscriber = new Subscriber({
|
|
137
|
+
session: this.#session,
|
|
138
|
+
quic,
|
|
139
|
+
cluster,
|
|
140
|
+
hidden,
|
|
141
|
+
activeCount,
|
|
142
|
+
goaway: this.#goaway,
|
|
143
|
+
grant: this.#auth.scope,
|
|
144
|
+
auth: this.#auth,
|
|
145
|
+
link: { cost: linkCost ?? Cost.zero, priority },
|
|
146
|
+
});
|
|
147
|
+
registerWire(this, {
|
|
148
|
+
consume: (path) => this.#subscriber.consume(path),
|
|
149
|
+
// The drafts refuse overlapping SUBSCRIBE_NAMESPACEs (PREFIX_OVERLAP). A peer that
|
|
150
|
+
// declared MoQ Solicit is ours and holds both; any other may enforce it.
|
|
151
|
+
exclusive: solicit === undefined,
|
|
152
|
+
// Drained locally only: this compatibility layer sends no client GOAWAY.
|
|
153
|
+
leave: () => {
|
|
154
|
+
if (this.#phase.kind === "open")
|
|
155
|
+
this.#phase = { kind: "leaving" };
|
|
156
|
+
},
|
|
157
|
+
auth: this.#auth,
|
|
158
|
+
});
|
|
107
159
|
void this.#run(early);
|
|
108
160
|
}
|
|
109
|
-
/** Snapshot the transport's counters; see {@link
|
|
161
|
+
/** Snapshot the transport's counters; see {@link Session.stats}. */
|
|
110
162
|
async stats() {
|
|
111
163
|
return transportStats(this.#quic);
|
|
112
164
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Closes the connection.
|
|
115
|
-
*/
|
|
165
|
+
/** Withdraw announcements and wait up to one second for delivery before closing. */
|
|
116
166
|
close() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
167
|
+
switch (this.#phase.kind) {
|
|
168
|
+
case "open":
|
|
169
|
+
case "leaving": {
|
|
170
|
+
const done = withTimeout(this.#publisher.withdraw(), Duration.secs(1), "session close timed out").finally(() => this.abort());
|
|
171
|
+
this.#phase = { kind: "closing", done };
|
|
172
|
+
return done;
|
|
173
|
+
}
|
|
174
|
+
case "closing":
|
|
175
|
+
return this.#phase.done;
|
|
176
|
+
case "closed":
|
|
177
|
+
return Promise.resolve();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/** End the session immediately without waiting for delivery. */
|
|
181
|
+
abort() {
|
|
120
182
|
this.#close();
|
|
121
183
|
}
|
|
122
184
|
// Close with the session code the peer should see, a clean close by default.
|
|
123
185
|
#close(info) {
|
|
124
|
-
if (this.#closed)
|
|
186
|
+
if (this.#phase.kind === "closed")
|
|
125
187
|
return;
|
|
126
|
-
this.#
|
|
188
|
+
this.#phase = { kind: "closed" };
|
|
189
|
+
this.#publisher.close();
|
|
190
|
+
this.#auth.close();
|
|
127
191
|
// Before the session, whose own close would send a clean code first.
|
|
128
192
|
try {
|
|
129
193
|
this.#quic.close(info);
|
|
@@ -136,28 +200,49 @@ export class Connection {
|
|
|
136
200
|
// The peer broke the protocol, so losing the stream is not enough: nothing stops it
|
|
137
201
|
// repeating the violation on the next one.
|
|
138
202
|
#violated(err) {
|
|
139
|
-
this.#close({ closeCode:
|
|
203
|
+
this.#close({ closeCode: err.code, reason: closeReason(err.message) });
|
|
140
204
|
}
|
|
141
205
|
async #run(early) {
|
|
142
206
|
try {
|
|
143
|
-
|
|
207
|
+
// All run together. runPublishNamespaces is a no-op when the peer asked to be
|
|
208
|
+
// solicited; otherwise it pushes PUBLISH_NAMESPACE. A SUBSCRIBE_NAMESPACE stream
|
|
209
|
+
// is filled either way. A NAMESPACE is discovery,
|
|
210
|
+
// not a second route.
|
|
211
|
+
const tasks = [
|
|
212
|
+
this.#runBidis(),
|
|
213
|
+
this.#runUnis(early),
|
|
214
|
+
this.#runDatagrams(),
|
|
215
|
+
this.#publisher.runPublishNamespaces(),
|
|
216
|
+
];
|
|
217
|
+
// Fail loud on a publication our grant never covers, once the peer has answered the
|
|
218
|
+
// credential we presented at setup.
|
|
219
|
+
if (this.#client)
|
|
220
|
+
tasks.push(this.#publisher.runEnforce(this.#auth.setupAnswered(), this.#auth));
|
|
221
|
+
await Promise.all(tasks);
|
|
144
222
|
}
|
|
145
223
|
catch (err) {
|
|
146
|
-
if (
|
|
224
|
+
if (this.#phase.kind !== "closed") {
|
|
147
225
|
console.error("fatal error running connection", err);
|
|
148
226
|
}
|
|
149
227
|
}
|
|
150
228
|
finally {
|
|
151
|
-
|
|
229
|
+
// A graceful close owns the teardown while it drains. runPublishNamespaces is
|
|
230
|
+
// a tracked withdrawal, so a failure in it ends this driver while close() is
|
|
231
|
+
// still waiting on the sibling loops; closing here would drop their
|
|
232
|
+
// withdrawals. close() aborts once its barrier settles or the deadline hits.
|
|
233
|
+
if (this.#phase.kind !== "closing")
|
|
234
|
+
this.#close();
|
|
152
235
|
}
|
|
153
236
|
}
|
|
154
|
-
/**
|
|
155
|
-
announced(
|
|
156
|
-
return this.#subscriber.
|
|
237
|
+
/** The paths announced at or beneath `prefix`, each present or absent; see {@link Session.announced}. */
|
|
238
|
+
announced(prefix, options) {
|
|
239
|
+
return announce.list(this.#subscriber.routes(prefix, options));
|
|
157
240
|
}
|
|
158
|
-
/**
|
|
159
|
-
|
|
160
|
-
|
|
241
|
+
/** Every route change at or beneath `prefix`, for code that forwards routes. @internal */
|
|
242
|
+
routes(prefix, options) {
|
|
243
|
+
return this.#subscriber.routes(prefix, options);
|
|
244
|
+
}
|
|
245
|
+
/** Accepts request streams and dispatches them. */
|
|
161
246
|
async #runBidis() {
|
|
162
247
|
for (;;) {
|
|
163
248
|
const stream = await this.#session.acceptBi();
|
|
@@ -176,81 +261,125 @@ export class Connection {
|
|
|
176
261
|
* Matches the lite module's runBidi pattern.
|
|
177
262
|
*/
|
|
178
263
|
async #runBidi(stream) {
|
|
179
|
-
|
|
264
|
+
// Full width, so unknown types above 2^53 still reach protocol classification.
|
|
265
|
+
const typeId = await stream.reader.u62();
|
|
180
266
|
switch (typeId) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
267
|
+
case BigInt(SubscribeNamespace.id): {
|
|
268
|
+
const decoded = SubscribeNamespace.decode(stream.reader, this.#session.version);
|
|
269
|
+
const msg = await this.#request(stream, "subscribe_namespace", decoded);
|
|
270
|
+
if (msg)
|
|
271
|
+
await handed(this.#publisher.runSubscribeNamespace(msg, stream));
|
|
186
272
|
break;
|
|
187
273
|
}
|
|
188
|
-
case
|
|
189
|
-
const legacy = await SubscribeNamespaceLegacy.decode(stream.reader, this.#session.version);
|
|
190
|
-
const msg = new SubscribeNamespace({
|
|
191
|
-
requestId: legacy.requestId,
|
|
192
|
-
namespace: legacy.namespace,
|
|
193
|
-
hidden: legacy.hidden,
|
|
194
|
-
});
|
|
195
|
-
await this.#publisher.runSubscribeNamespace(msg, stream);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
case SubscribeUpdate.id: {
|
|
274
|
+
case BigInt(SubscribeUpdate.id): {
|
|
199
275
|
// REQUEST_UPDATE (0x02) is a follow-up, not a valid initial message
|
|
200
276
|
throw new ProtocolViolation("unexpected REQUEST_UPDATE as initial message");
|
|
201
277
|
}
|
|
202
278
|
// Publisher handles incoming requests
|
|
203
|
-
case Subscribe.id: {
|
|
204
|
-
const
|
|
205
|
-
await this.#
|
|
279
|
+
case BigInt(Subscribe.id): {
|
|
280
|
+
const decoded = Subscribe.decode(stream.reader, this.#session.version);
|
|
281
|
+
const msg = await this.#request(stream, "subscribe", decoded);
|
|
282
|
+
if (msg)
|
|
283
|
+
await handed(this.#publisher.runSubscribe(msg, stream));
|
|
206
284
|
break;
|
|
207
285
|
}
|
|
208
|
-
case SUBSCRIBE_TRACKS_ID: {
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
286
|
+
case BigInt(SUBSCRIBE_TRACKS_ID): {
|
|
287
|
+
// We list no tracks by PUBLISH, so each listing is refused on its own. Only its
|
|
288
|
+
// Request ID is read; the rest of the body goes unread.
|
|
289
|
+
const requestId = await Message.decode(stream.reader, async (body) => {
|
|
290
|
+
const id = await body.u62();
|
|
291
|
+
await body.discard();
|
|
292
|
+
return id;
|
|
293
|
+
}).catch((err) => {
|
|
294
|
+
throw malformed(err, "subscribe_tracks");
|
|
295
|
+
});
|
|
296
|
+
this.#spend(requestId);
|
|
297
|
+
await handed(this.#refuseUnsupported(stream, "subscribe_namespace", "SUBSCRIBE_TRACKS is not supported"));
|
|
214
298
|
break;
|
|
215
299
|
}
|
|
216
|
-
case TrackStatusRequest.id: {
|
|
217
|
-
const
|
|
218
|
-
await this.#
|
|
300
|
+
case BigInt(TrackStatusRequest.id): {
|
|
301
|
+
const decoded = TrackStatusRequest.decode(stream.reader, this.#session.version);
|
|
302
|
+
const msg = await this.#request(stream, "track_status", decoded);
|
|
303
|
+
if (msg)
|
|
304
|
+
await handed(this.#publisher.runTrackStatusRequest(msg, stream));
|
|
219
305
|
break;
|
|
220
306
|
}
|
|
221
|
-
case Fetch.id: {
|
|
222
|
-
const
|
|
223
|
-
await this.#
|
|
307
|
+
case BigInt(Fetch.id): {
|
|
308
|
+
const decoded = Fetch.decode(stream.reader, this.#session.version);
|
|
309
|
+
const msg = await this.#request(stream, "fetch", decoded);
|
|
310
|
+
// Only a relay answers a FETCH, from its cache.
|
|
311
|
+
if (msg)
|
|
312
|
+
await handed(this.#refuseUnsupported(stream, "fetch", "FETCH is not supported"));
|
|
224
313
|
break;
|
|
225
314
|
}
|
|
226
315
|
// Subscriber handles incoming notifications
|
|
227
|
-
case PublishNamespace.id: {
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
//
|
|
236
|
-
// Draft-14/15 are exempt: they have no inline NAMESPACE, so a
|
|
237
|
-
// PUBLISH_NAMESPACE request is also how a peer answers our
|
|
238
|
-
// SUBSCRIBE_NAMESPACE there, and the message alone does not say which.
|
|
239
|
-
const legacy = this.#session.version === Version.DRAFT_14 || this.#session.version === Version.DRAFT_15;
|
|
240
|
-
if (this.#solicit !== undefined && !legacy) {
|
|
241
|
-
throw new ProtocolViolation(`unsolicited publish_namespace from a peer that implements MoQ Solicit: broadcast=${msg.trackNamespace}`);
|
|
242
|
-
}
|
|
243
|
-
await this.#subscriber.runPublishNamespace(msg, stream);
|
|
316
|
+
case BigInt(PublishNamespace.id): {
|
|
317
|
+
const decoded = PublishNamespace.decode(stream.reader, this.#session.version, {
|
|
318
|
+
cluster: Cluster.negotiated(this.#cluster),
|
|
319
|
+
});
|
|
320
|
+
const msg = await this.#request(stream, "publish_namespace", decoded);
|
|
321
|
+
if (!msg)
|
|
322
|
+
break;
|
|
323
|
+
await handed(this.#subscriber.runPublishNamespace(msg, stream));
|
|
244
324
|
break;
|
|
245
325
|
}
|
|
246
|
-
case Publish.id: {
|
|
247
|
-
const
|
|
248
|
-
await this.#
|
|
326
|
+
case BigInt(Publish.id): {
|
|
327
|
+
const decoded = Publish.decode(stream.reader, this.#session.version);
|
|
328
|
+
const msg = await this.#request(stream, "publish", decoded);
|
|
329
|
+
if (msg)
|
|
330
|
+
await handed(this.#subscriber.runPublish(msg, stream));
|
|
249
331
|
break;
|
|
250
332
|
}
|
|
251
333
|
default:
|
|
252
|
-
|
|
253
|
-
|
|
334
|
+
throw new ProtocolViolation(`unknown bidi stream type: 0x${typeId.toString(16)}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Finish decoding a request, refusing it instead when its AUTHORIZATION TOKENs repeat.
|
|
339
|
+
* Section 8.9 rejects that message rather than the session, unlike any other decode error.
|
|
340
|
+
*
|
|
341
|
+
* @returns undefined once refused.
|
|
342
|
+
*/
|
|
343
|
+
async #request(stream, kind, decoded) {
|
|
344
|
+
let msg;
|
|
345
|
+
try {
|
|
346
|
+
msg = await decoded;
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
if (!(err instanceof MalformedAuthToken) || err.requestId === undefined)
|
|
350
|
+
throw malformed(err, kind);
|
|
351
|
+
this.#spend(err.requestId);
|
|
352
|
+
await this.#refuseToken(stream, kind);
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
this.#spend(msg.requestId);
|
|
356
|
+
return msg;
|
|
357
|
+
}
|
|
358
|
+
/** Spend a request's ID, closing the session if it was already used. */
|
|
359
|
+
#spend(requestId) {
|
|
360
|
+
this.#session.checkRequestId(requestId);
|
|
361
|
+
}
|
|
362
|
+
/** Refuse a request we never serve NOT_SUPPORTED, ending its stream. */
|
|
363
|
+
async #refuseUnsupported(stream, kind, reasonPhrase) {
|
|
364
|
+
await refuse(stream, this.#session.version, kind, { condition: "not_supported", reasonPhrase });
|
|
365
|
+
}
|
|
366
|
+
/** Refuse a request MALFORMED_AUTH_TOKEN, ending its stream. Mirrors Rust's `token::reject`. */
|
|
367
|
+
async #refuseToken(stream, kind) {
|
|
368
|
+
await refuse(stream, this.#session.version, kind, {
|
|
369
|
+
condition: "malformed_auth_token",
|
|
370
|
+
reasonPhrase: "repeated AUTHORIZATION TOKEN",
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
// A malformed OBJECT_DATAGRAM is the peer breaking the protocol, like an invalid stream type.
|
|
374
|
+
async #runDatagrams() {
|
|
375
|
+
try {
|
|
376
|
+
await this.#subscriber.runDatagrams();
|
|
377
|
+
}
|
|
378
|
+
catch (err) {
|
|
379
|
+
if (!(err instanceof ProtocolViolation))
|
|
380
|
+
throw err;
|
|
381
|
+
console.warn("malformed datagram", err);
|
|
382
|
+
this.#violated(err);
|
|
254
383
|
}
|
|
255
384
|
}
|
|
256
385
|
/**
|
|
@@ -274,7 +403,8 @@ export class Connection {
|
|
|
274
403
|
stream.stop(new StreamError(StreamCode.Cancel, { message: "cancel" }));
|
|
275
404
|
})
|
|
276
405
|
.catch((err) => {
|
|
277
|
-
|
|
406
|
+
// A peer resetting a stream it no longer wants to send is routine, not an error;
|
|
407
|
+
// only a violation is, and that one closes the session with its code.
|
|
278
408
|
stream.stop(err);
|
|
279
409
|
// An unknown or invalid stream type MUST close the session, not just the stream.
|
|
280
410
|
if (err instanceof ProtocolViolation)
|
|
@@ -293,55 +423,86 @@ export class Connection {
|
|
|
293
423
|
}
|
|
294
424
|
// The receiver MUST discard padding. We read it to the end rather than cancel,
|
|
295
425
|
// so a peer probing for bandwidth gets the throughput it is measuring.
|
|
296
|
-
if (type === PADDING
|
|
426
|
+
if (type === PADDING) {
|
|
297
427
|
await stream.discard();
|
|
298
428
|
return;
|
|
299
429
|
}
|
|
300
|
-
//
|
|
301
|
-
if (type === BigInt(FetchHeader.type))
|
|
302
|
-
|
|
430
|
+
// The head of a join, answering our draft-18 joining FETCH or draft-22 fill.
|
|
431
|
+
if (type === BigInt(FetchHeader.type)) {
|
|
432
|
+
await this.#subscriber.handleFetch(stream);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
303
435
|
// Anything else is unknown, and a second SETUP is a violation too.
|
|
304
436
|
throw new ProtocolViolation(`unknown uni stream type: 0x${type.toString(16)}`);
|
|
305
437
|
}
|
|
306
438
|
/**
|
|
307
|
-
*
|
|
439
|
+
* Reads GOAWAY from the SETUP stream.
|
|
308
440
|
*
|
|
309
441
|
* The session keeps serving after a GOAWAY so its groups in flight can finish while the
|
|
310
442
|
* caller migrates; only the stream ending, or a second GOAWAY, closes it here.
|
|
311
443
|
*/
|
|
312
444
|
async #runGoAway(controlStream, version) {
|
|
313
445
|
try {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
446
|
+
const read = async () => {
|
|
447
|
+
for (;;) {
|
|
448
|
+
const done = await controlStream.reader.done();
|
|
449
|
+
if (done)
|
|
450
|
+
throw new ProtocolViolation("control stream closed");
|
|
451
|
+
const msg = await this.#readGoAway(controlStream, version).catch((err) => {
|
|
452
|
+
throw malformed(err, "setup stream message");
|
|
453
|
+
});
|
|
454
|
+
if (this.#goaway.peek() !== undefined)
|
|
455
|
+
throw new ProtocolViolation("duplicate GOAWAY");
|
|
456
|
+
// A client may leave, but only the server may name where to go.
|
|
457
|
+
if (!this.#client && msg.newSessionUri !== "") {
|
|
458
|
+
throw new ProtocolViolation("client GOAWAY must not name a redirect");
|
|
459
|
+
}
|
|
460
|
+
// Draft-18's Request ID names our IDs: even when we are the client, odd for a server.
|
|
461
|
+
// It is required here, on the control stream.
|
|
462
|
+
if (version === Version.DRAFT_18 && msg.requestId === undefined) {
|
|
463
|
+
throw new ProtocolViolation("draft-18 GOAWAY on the control stream lacks a Request ID");
|
|
464
|
+
}
|
|
465
|
+
if (msg.requestId !== undefined && msg.requestId % 2n !== (this.#client ? 0n : 1n)) {
|
|
466
|
+
throw new ProtocolViolation("GOAWAY Request ID has the wrong parity", {
|
|
467
|
+
code: IetfSessionCode.InvalidRequestId,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
// Reject bytes already behind GOAWAY before a caller can close on the drain.
|
|
471
|
+
if (controlStream.reader.tryDecode((c) => c.u8()) !== undefined)
|
|
472
|
+
throw new ProtocolViolation("message after control stream GOAWAY");
|
|
473
|
+
this.#goaway.set(msg.drain());
|
|
322
474
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
throw new ProtocolViolation("client GOAWAY must not name a redirect");
|
|
329
|
-
}
|
|
330
|
-
this.#goaway.set(msg.drain());
|
|
331
|
-
}
|
|
475
|
+
};
|
|
476
|
+
const stopped = controlStream.writer.closed.then(() => {
|
|
477
|
+
throw new ProtocolViolation("control stream stopped");
|
|
478
|
+
});
|
|
479
|
+
await race([read(), stopped]);
|
|
332
480
|
}
|
|
333
481
|
catch (err) {
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
|
|
482
|
+
if (this.#phase.kind !== "closed" && !sessionClosed(err))
|
|
483
|
+
this.#violated(err instanceof ProtocolViolation
|
|
484
|
+
? err
|
|
485
|
+
: new ProtocolViolation("control stream failed", { cause: err }));
|
|
337
486
|
}
|
|
338
487
|
finally {
|
|
339
488
|
this.#close();
|
|
340
489
|
}
|
|
341
490
|
}
|
|
342
|
-
|
|
491
|
+
// The setup stream carries nothing but GOAWAY after SETUP.
|
|
492
|
+
async #readGoAway(controlStream, version) {
|
|
493
|
+
const typeId = await controlStream.reader.u53();
|
|
494
|
+
if (typeId !== GoAway.id) {
|
|
495
|
+
throw new ProtocolViolation(`unexpected message on setup stream: 0x${typeId.toString(16)}`);
|
|
496
|
+
}
|
|
497
|
+
return GoAway.decode(controlStream.reader, version);
|
|
498
|
+
}
|
|
499
|
+
/** Settles with the peer's GOAWAY; see {@link Session.draining}. */
|
|
500
|
+
get draining() {
|
|
501
|
+
return this.#goaway;
|
|
502
|
+
}
|
|
503
|
+
/** Settles when the session closes, decoding the peer's close code; see {@link Session.closed}. */
|
|
343
504
|
get closed() {
|
|
344
|
-
return this.#
|
|
505
|
+
return this.#closed;
|
|
345
506
|
}
|
|
346
507
|
}
|
|
347
508
|
//# sourceMappingURL=connection.js.map
|