@moq/net 0.4.8 → 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 -1
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -31
- 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 -138
- 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 -1
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +62 -36
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -172
- 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 +20 -12
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -129
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -19
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +119 -23
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -216
- 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 -80
- 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 -108
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +32 -6
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -20
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +3 -6
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -2
- 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 +137 -58
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -117
- 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 -233
- 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 -8
- 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 -4
- 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 -46
- 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 -1
- 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 -37
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -2
- 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 -307
- 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 -64
- 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 -35
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -62
- 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 -143
- 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 -100
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +91 -35
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -93
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +20 -30
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -171
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +11 -9
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -35
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -1
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +2 -14
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -14
- 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 -40
- 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 +17 -3
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -26
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +194 -32
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -178
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +22 -42
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -472
- 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 -4
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +5 -4
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -48
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +22 -30
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -139
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +46 -69
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -184
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -600
- 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 +3 -27
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -78
- 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 -16
- 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 +4 -29
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -117
- 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 -14
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +48 -41
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -239
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +13 -76
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -201
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -536
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -27
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +25 -22
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -61
- 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 -48
- 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 +25 -10
- package/index.d.ts.map +1 -1
- package/index.js +19 -6
- package/index.js.map +1 -1
- package/internal.d.ts +1512 -64
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -79
- 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 +124 -63
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -158
- 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 -77
- 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 -9
- 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 +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -13
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +64 -13
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -30
- 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 +2 -1
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -1
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +9 -1
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -44
- 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 -105
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -0
- 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 -437
- 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 +1 -27
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -99
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +29 -2
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -21
- 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 -1
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +475 -75
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -142
- 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 -515
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +24 -9
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -37
- 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 -33
- 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 +392 -140
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -686
- 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 -57
- 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 +75 -37
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -92
- 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 -97
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -91
- 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 +577 -245
- package/track.d.ts.map +1 -1
- package/track.js +7306 -771
- 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 -1
- 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 -4
- 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 -9
- 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/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -1
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -1
- 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 -28
- 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 +145 -30
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -0
- 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 -2
- 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 -699
- 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 -43
- 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 -78
- 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 -16
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -18
- package/zod.js.map +0 -1
package/ietf/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/ietf/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAIzD,OAAO,EAA0B,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAkB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAA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AC,yCAAyC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;oBAC7E,OAAO;gBACR,CAAC;gBAED,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC/D,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,SAAS;oBAAE,MAAM,IAAI,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;gBACvF,gEAAgE;gBAChE,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,GAAG,CAAC,aAAa,KAAK,EAAE,EAAE,CAAC;oBAC/C,MAAM,IAAI,iBAAiB,CAAC,wCAAwC,CAAC,CAAC;gBACvE,CAAC;gBACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;IACF,CAAC;IAED,wGAAwG;IACxG,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAY,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;CACD","sourcesContent":["import { type Getter, Once, Signal } from \"@moq/signals\";\nimport type * as announce from \"../announced.ts\";\nimport type { Established } from \"../connection/established.ts\";\nimport type { Drain } from \"../connection/goaway.ts\";\nimport { type Probe, type Stats, transportStats } from \"../connection/stats.ts\";\nimport { type Transport, transportOf } from \"../connection/transport.ts\";\nimport { error, fromClose, ProtocolViolation, SessionCode, StreamCode, StreamError } from \"../error.ts\";\nimport type { Consumer as OriginConsumer } from \"../origin.ts\";\nimport type * as Path from \"../path.ts\";\nimport { type Reader, Readers, type Stream } from \"../stream.ts\";\nimport { registerWire } from \"../wire.ts\";\nimport { ControlStreamAdapter, NativeSession, type Session } from \"./adapter.ts\";\nimport * as Cluster from \"./cluster.ts\";\nimport { Fetch, FetchHeader } from \"./fetch.ts\";\nimport { GoAway } from \"./goaway.ts\";\nimport { Group } from \"./object.ts\";\nimport { Publish } from \"./publish.ts\";\nimport { PublishNamespace } from \"./publish_namespace.ts\";\nimport { Publisher } from \"./publisher.ts\";\nimport { Subscribe, SubscribeUpdate } from \"./subscribe.ts\";\nimport { SUBSCRIBE_TRACKS_ID, SubscribeNamespace, SubscribeNamespaceLegacy } from \"./subscribe_namespace.ts\";\nimport { Subscriber } from \"./subscriber.ts\";\nimport { TrackStatusRequest } from \"./track.ts\";\nimport { type IetfVersion, Version, versionName } from \"./version.ts\";\n\n// The PADDING stream type (draft-18+): bytes a peer sends to probe for bandwidth.\nconst PADDING = 0x132b3e28n;\n\n/**\n * Represents a connection to a MoQ server using moq-transport protocol.\n *\n * @public\n */\nexport class Connection implements Established {\n\t// The URL of the connection.\n\treadonly url: URL;\n\n\t// The negotiated protocol version.\n\treadonly version: string;\n\n\t// The wire transport this session runs over.\n\treadonly transport: Transport;\n\n\t/** Whether the relay supports broadcast discovery; see {@link Established.discovery}. */\n\treadonly discovery: boolean;\n\n\t/** moq-transport has no PROBE, so this stays empty; see {@link Established.probe}. */\n\treadonly probe: Getter<Probe> = new Signal<Probe>({});\n\n\t// The established WebTransport session.\n\t#quic: WebTransport;\n\n\t// Whether this side opened the session. Only a server may name a redirect.\n\t#client: boolean;\n\n\t// Session abstraction: adapter for v14-v16, native for v17.\n\t#session: Session;\n\n\t// Module for contributing tracks.\n\t#publisher: Publisher;\n\n\t// Module for distributing tracks.\n\t#subscriber: Subscriber;\n\n\t// What the peer declared about being solicited; see {@link Ietf.solicitFromSetup}.\n\t#solicit: boolean | undefined;\n\n\t// The Hop IDs this session declared; see {@link Cluster}.\n\t#cluster?: Cluster.Hops;\n\n\t// The peer's GOAWAY: read here on v17+, by the control stream adapter before that.\n\t#goaway: Once<Drain>;\n\n\t// Just to avoid logging when `close()` is called.\n\t#closed = false;\n\n\t/**\n\t * Creates a new Connection instance.\n\t * @param url - The URL of the connection\n\t * @param quic - The WebTransport session\n\t * @param control - The control/setup stream\n\t * @param maxRequestId - The initial max request ID\n\t * @param version - The negotiated protocol version\n\t * @param solicit - What the peer's SETUP declared (undefined when it declared nothing)\n\t * @param cluster - The Hop IDs the SETUP exchange settled, on the versions that negotiate them\n\t * @param early - Uni streams that arrived before the peer's SETUP\n\t *\n\t * @internal\n\t */\n\tconstructor({\n\t\turl,\n\t\tquic,\n\t\tcontrol,\n\t\tmaxRequestId,\n\t\tversion,\n\t\tclient,\n\t\tdiscovery = true,\n\t\tpublish,\n\t\tsolicit,\n\t\thidden = false,\n\t\tcluster,\n\t\tearly = [],\n\t}: {\n\t\turl: URL;\n\t\tquic: WebTransport;\n\t\tcontrol: Stream;\n\t\tmaxRequestId: bigint;\n\t\tversion: IetfVersion;\n\t\t/** Whether this peer initiated the session, selecting the even request-ID space. */\n\t\tclient: boolean;\n\t\tdiscovery?: boolean;\n\t\t/** The origin whose broadcasts are served to the peer. Omit to publish nothing. */\n\t\tpublish?: OriginConsumer;\n\t\t/**\n\t\t * What the peer declared about being solicited. `undefined` means it declared\n\t\t * nothing, which is the one case where announcing at us unasked is not a bug.\n\t\t */\n\t\tsolicit?: boolean;\n\t\t/** Whether the peer understands the HIDDEN parameter (MoQ Hidden). */\n\t\thidden?: boolean;\n\t\t/**\n\t\t * The Hop IDs this session declared (MoQ Cluster). `undefined` on a version that\n\t\t * cannot negotiate the extension, as is a `peer` the peer never declared.\n\t\t */\n\t\tcluster?: Cluster.Hops;\n\t\t/** Uni streams that arrived before the peer's SETUP, type unread (v17+). */\n\t\tearly?: Reader[];\n\t}) {\n\t\tthis.url = url;\n\t\tthis.discovery = discovery;\n\t\tthis.version = versionName(version);\n\t\tthis.transport = transportOf(quic);\n\t\tthis.#quic = quic;\n\t\tthis.#client = client;\n\n\t\t// Two-path dispatch: v14-v16 uses adapter, v17+ uses native bidi streams\n\t\tif (version >= Version.DRAFT_17) {\n\t\t\tthis.#session = new NativeSession(quic, version, client);\n\t\t\tthis.#goaway = new Once();\n\t\t\t// v17+: control/setup stream only carries GoAway\n\t\t\tvoid this.#runGoAway(control, version);\n\t\t} else {\n\t\t\tconst adapter = new ControlStreamAdapter(quic, control, version, maxRequestId, client);\n\t\t\tthis.#session = adapter;\n\t\t\tthis.#goaway = adapter.goaway;\n\t\t\t// Start the adapter read loop (routes control messages to virtual streams)\n\t\t\tvoid adapter.run().catch((err: unknown) => {\n\t\t\t\tif (!this.#closed) console.error(\"adapter error\", err);\n\t\t\t\tthis.#close();\n\t\t\t});\n\t\t}\n\n\t\tthis.#publisher = new Publisher({\n\t\t\tquic: this.#quic,\n\t\t\tsession: this.#session,\n\t\t\tpublish,\n\t\t\trequiresSolicitation: solicit ?? false,\n\t\t\thidden,\n\t\t\tcluster,\n\t\t});\n\t\tthis.#solicit = solicit;\n\t\tthis.#cluster = cluster;\n\t\tthis.#subscriber = new Subscriber({ session: this.#session, quic, cluster, hidden });\n\t\tregisterWire(this, { consume: (path) => this.#subscriber.consume(path), goaway: this.#goaway });\n\n\t\tvoid this.#run(early);\n\t}\n\n\t/** Snapshot the transport's counters; see {@link Established.stats}. */\n\tasync stats(): Promise<Stats> {\n\t\treturn transportStats(this.#quic);\n\t}\n\n\t/**\n\t * Closes the connection.\n\t */\n\tclose() {\n\t\tif (this.#closed) return;\n\t\tthis.#subscriber.close();\n\t\tthis.#close();\n\t}\n\n\t// Close with the session code the peer should see, a clean close by default.\n\t#close(info?: WebTransportCloseInfo) {\n\t\tif (this.#closed) return;\n\n\t\tthis.#closed = true;\n\n\t\t// Before the session, whose own close would send a clean code first.\n\t\ttry {\n\t\t\tthis.#quic.close(info);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\tthis.#session.close();\n\t}\n\n\t// The peer broke the protocol, so losing the stream is not enough: nothing stops it\n\t// repeating the violation on the next one.\n\t#violated(err: ProtocolViolation) {\n\t\tthis.#close({ closeCode: SessionCode.ProtocolViolation, reason: err.message });\n\t}\n\n\tasync #run(early: Reader[]): Promise<void> {\n\t\ttry {\n\t\t\tawait Promise.all([this.#runBidis(), this.#runUnis(early), this.#publisher.runPublishNamespaces()]);\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"fatal error running connection\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#close();\n\t\t}\n\t}\n\n\t/** Gets an announced reader for `scope`; see {@link Established.announced}. */\n\tannounced(scope?: Path.Pattern, options?: announce.Options): announce.Consumer {\n\t\treturn this.#subscriber.announced(scope, options);\n\t}\n\n\t/**\n\t * Accepts bidi streams (virtual for v14-v16, real for v17) and dispatches.\n\t */\n\tasync #runBidis() {\n\t\tfor (;;) {\n\t\t\tconst stream = await this.#session.acceptBi();\n\t\t\tif (!stream) break;\n\n\t\t\tvoid this.#runBidi(stream).catch((err: unknown) => {\n\t\t\t\tconsole.error(\"error processing bidi stream\", err);\n\t\t\t\tstream.abort(new Error(\"bidi stream error\"));\n\t\t\t\tif (err instanceof ProtocolViolation) this.#violated(err);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Unified bidi stream dispatch. Reads typeId and routes to handler.\n\t * Matches the lite module's runBidi pattern.\n\t */\n\tasync #runBidi(stream: Stream) {\n\t\tconst typeId = await stream.reader.u53();\n\n\t\tswitch (typeId) {\n\t\t\t// Draft-18 SUBSCRIBE_NAMESPACE (0x50) and the legacy 0x11 message decode\n\t\t\t// to the same request_id + namespace; the legacy options field is ignored.\n\t\t\tcase SubscribeNamespace.id: {\n\t\t\t\tconst msg = await SubscribeNamespace.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeNamespaceLegacy.id: {\n\t\t\t\tconst legacy = await SubscribeNamespaceLegacy.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = new SubscribeNamespace({\n\t\t\t\t\trequestId: legacy.requestId,\n\t\t\t\t\tnamespace: legacy.namespace,\n\t\t\t\t\thidden: legacy.hidden,\n\t\t\t\t});\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeUpdate.id: {\n\t\t\t\t// REQUEST_UPDATE (0x02) is a follow-up, not a valid initial message\n\t\t\t\tthrow new ProtocolViolation(\"unexpected REQUEST_UPDATE as initial message\");\n\t\t\t}\n\t\t\t// Publisher handles incoming requests\n\t\t\tcase Subscribe.id: {\n\t\t\t\tconst msg = await Subscribe.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribe(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SUBSCRIBE_TRACKS_ID: {\n\t\t\t\t// 0x51 is only a message from draft-18 on.\n\t\t\t\tif (this.#session.version < Version.DRAFT_18) {\n\t\t\t\t\tthrow new ProtocolViolation(\"SUBSCRIBE_TRACKS before draft-18\");\n\t\t\t\t}\n\t\t\t\tawait this.#publisher.runSubscribeTracks(stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TrackStatusRequest.id: {\n\t\t\t\tconst msg = await TrackStatusRequest.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runTrackStatusRequest(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Fetch.id: {\n\t\t\t\tconst msg = await Fetch.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runFetch(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Subscriber handles incoming notifications\n\t\t\tcase PublishNamespace.id: {\n\t\t\t\tconst msg = await PublishNamespace.decode(\n\t\t\t\t\tstream.reader,\n\t\t\t\t\tthis.#session.version,\n\t\t\t\t\tCluster.negotiated(this.#cluster),\n\t\t\t\t);\n\n\t\t\t\t// We always declare that advertisements to us must be solicited (MoQ\n\t\t\t\t// Solicit), and writing the option at all proves the peer implements the\n\t\t\t\t// extension, whichever value it chose. It also cannot have advertised\n\t\t\t\t// before reading our SETUP, since our SETUP is what says whether\n\t\t\t\t// advertising unasked is allowed. So this is a bug in the peer, and a\n\t\t\t\t// silent one on both sides if we tolerate it.\n\t\t\t\t//\n\t\t\t\t// Draft-14/15 are exempt: they have no inline NAMESPACE, so a\n\t\t\t\t// PUBLISH_NAMESPACE request is also how a peer answers our\n\t\t\t\t// SUBSCRIBE_NAMESPACE there, and the message alone does not say which.\n\t\t\t\tconst legacy = this.#session.version === Version.DRAFT_14 || this.#session.version === Version.DRAFT_15;\n\t\t\t\tif (this.#solicit !== undefined && !legacy) {\n\t\t\t\t\tthrow new ProtocolViolation(\n\t\t\t\t\t\t`unsolicited publish_namespace from a peer that implements MoQ Solicit: broadcast=${msg.trackNamespace}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tawait this.#subscriber.runPublishNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Publish.id: {\n\t\t\t\tconst msg = await Publish.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#subscriber.runPublish(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn(`unexpected bidi stream type: 0x${typeId.toString(16)}`);\n\t\t\t\tstream.abort(new Error(\"unexpected stream type\"));\n\t\t}\n\t}\n\n\t/**\n\t * Handles unidirectional streams for media delivery (groups).\n\t */\n\tasync #runUnis(early: Reader[]) {\n\t\t// Streams that beat the SETUP go first, in arrival order.\n\t\tfor (const stream of early) this.#spawnUni(stream);\n\n\t\tconst readers = new Readers(this.#quic, this.#session.version);\n\t\tfor (;;) {\n\t\t\tconst stream = await readers.next();\n\t\t\tif (!stream) break;\n\t\t\tthis.#spawnUni(stream);\n\t\t}\n\t}\n\n\t#spawnUni(stream: Reader) {\n\t\tthis.#runUni(stream)\n\t\t\t.then(() => {\n\t\t\t\tstream.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t\t\t})\n\t\t\t.catch((err: unknown) => {\n\t\t\t\tconsole.error(\"error processing object stream\", err);\n\t\t\t\tstream.stop(err);\n\n\t\t\t\t// An unknown or invalid stream type MUST close the session, not just the stream.\n\t\t\t\tif (err instanceof ProtocolViolation) this.#violated(err);\n\t\t\t});\n\t}\n\n\tasync #runUni(stream: Reader) {\n\t\tconst version = this.#session.version;\n\t\t// Full width, so an unknown type past 2^53 is still classified rather than thrown.\n\t\tconst type = await stream.u62();\n\n\t\t// SUBGROUP_HEADER types match 0b0XX1XXXX; Group.decode validates the bits per draft.\n\t\tif (type <= 0xffn && (type & 0x90n) === 0x10n) {\n\t\t\tconst header = await Group.decode(stream, version, Number(type));\n\t\t\tawait this.#subscriber.handleGroup(header, stream);\n\t\t\treturn;\n\t\t}\n\n\t\t// The receiver MUST discard padding. We read it to the end rather than cancel,\n\t\t// so a peer probing for bandwidth gets the throughput it is measuring.\n\t\tif (type === PADDING && version >= Version.DRAFT_18) {\n\t\t\tawait stream.discard();\n\t\t\treturn;\n\t\t}\n\n\t\t// We never FETCH, so a fetch response answers nothing of ours.\n\t\tif (type === BigInt(FetchHeader.type)) throw new Error(\"unexpected fetch stream\");\n\n\t\t// Anything else is unknown, and a second SETUP is a violation too.\n\t\tthrow new ProtocolViolation(`unknown uni stream type: 0x${type.toString(16)}`);\n\t}\n\n\t/**\n\t * v17+ only: reads GoAway from the setup/control stream.\n\t *\n\t * The session keeps serving after a GOAWAY so its groups in flight can finish while the\n\t * caller migrates; only the stream ending, or a second GOAWAY, closes it here.\n\t */\n\tasync #runGoAway(controlStream: Stream, version: IetfVersion) {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst done = await controlStream.reader.done();\n\t\t\t\tif (done) return;\n\n\t\t\t\tconst typeId = await controlStream.reader.u53();\n\t\t\t\tif (typeId !== GoAway.id) {\n\t\t\t\t\tconsole.warn(`unexpected message on setup stream: 0x${typeId.toString(16)}`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst msg = await GoAway.decode(controlStream.reader, version);\n\t\t\t\tif (this.#goaway.peek() !== undefined) throw new ProtocolViolation(\"duplicate GOAWAY\");\n\t\t\t\t// A client may leave, but only the server may name where to go.\n\t\t\t\tif (!this.#client && msg.newSessionUri !== \"\") {\n\t\t\t\t\tthrow new ProtocolViolation(\"client GOAWAY must not name a redirect\");\n\t\t\t\t}\n\t\t\t\tthis.#goaway.set(msg.drain());\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"error reading setup stream\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#close();\n\t\t}\n\t}\n\n\t/** Resolves when the session closes, decoding the peer's close code; see {@link Established.closed}. */\n\tget closed(): Promise<Error | null> {\n\t\treturn this.#quic.closed.then(fromClose, (err: unknown) => error(err));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/ietf/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAgC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,OAAO,EAAE,MAAM,EAA0B,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAkB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,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AAQ;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,mGAAmG;IACnG,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;CACD","sourcesContent":["import { Duration } from \"@moq/clock\";\nimport { type GetPromise, type Getter, Once, race, Signal } from \"@moq/signals\";\nimport * as announce from \"../announced.ts\";\nimport type * as Auth from \"../auth.ts\";\nimport { AuthSession } from \"../auth_session.ts\";\nimport type { Goaway } from \"../connection/goaway.ts\";\nimport type { Liveness } from \"../connection/liveness.ts\";\nimport type { Session } from \"../connection/session.ts\";\nimport { detect, type Probe, type Stats, transportStats } from \"../connection/stats.ts\";\nimport { type Transport, transportOf } from \"../connection/transport.ts\";\nimport { closeReason, error, fromClose, ProtocolViolation, StreamCode, StreamError, sessionClosed } from \"../error.ts\";\nimport { Cost } from \"../hop.ts\";\nimport type { Consumer as OriginConsumer } from \"../origin.ts\";\nimport * as Path from \"../path.ts\";\nimport { type Reader, Readers, type Stream } from \"../stream.ts\";\nimport { withTimeout } from \"../util/timeout.ts\";\nimport { registerWire } from \"../wire.ts\";\nimport * as Cluster from \"./cluster.ts\";\nimport { IetfSessionCode, type RequestKind } from \"./error.ts\";\nimport { Fetch, FetchHeader } from \"./fetch.ts\";\nimport { GoAway } from \"./goaway.ts\";\nimport * as Message from \"./message.ts\";\nimport { Group } from \"./object.ts\";\nimport { Publish } from \"./publish.ts\";\nimport { PublishNamespace } from \"./publish_namespace.ts\";\nimport { Publisher } from \"./publisher.ts\";\nimport { malformed, refuse } from \"./request_stream.ts\";\nimport { NativeSession } from \"./session.ts\";\nimport { Subscribe, SubscribeUpdate } from \"./subscribe.ts\";\nimport { SUBSCRIBE_TRACKS_ID, SubscribeNamespace } from \"./subscribe_namespace.ts\";\nimport { Subscriber } from \"./subscriber.ts\";\nimport { MalformedAuthToken } from \"./token.ts\";\nimport { TrackStatusRequest } from \"./track.ts\";\nimport { type IetfVersion, Version, versionName } from \"./version.ts\";\n\n// The PADDING stream type (draft-18+): bytes a peer sends to probe for bandwidth.\nconst PADDING = 0x132b3e28n;\n\n// A handler owns its request stream, and ending the request (closing the session over a\n// violation) is its job: closing again here could only send a competing code.\nfunction handed(task: Promise<void>): Promise<void> {\n\treturn task.catch((err: unknown) => console.error(\"error processing bidi stream\", err));\n}\n\n/** Where a session is: open, delivering what it owes before it closes, or closed. */\n/** `leaving` is open but draining at this side's own request; see the wire view's `leave`. */\ntype Phase = { kind: \"open\" } | { kind: \"leaving\" } | { kind: \"closing\"; done: Promise<void> } | { kind: \"closed\" };\n\n/**\n * Represents a connection to a MoQ server using moq-transport protocol.\n *\n * @internal\n */\nexport class Connection implements Session {\n\t#phase: Phase = { kind: \"open\" };\n\t// The URL of the connection.\n\treadonly url: URL;\n\n\t// The negotiated protocol version.\n\treadonly version: string;\n\n\t// The wire transport this session runs over.\n\treadonly transport: Transport;\n\n\t/** moq-transport has no PROBE, so this stays empty; see {@link Session.probe}. */\n\treadonly probe: Getter<Probe> = new Signal<Probe>({});\n\n\t/** The peer's liveness, on a transport that probes it; see {@link Session.liveness}. */\n\treadonly liveness: Getter<Liveness> | undefined;\n\n\t/** Our tokens, which requests carry; see {@link Session.auth}. */\n\tget auth(): Auth.Handle {\n\t\treturn this.#auth.handle;\n\t}\n\n\t// Our tokens, for the requests that carry them.\n\t#auth: AuthSession;\n\n\t// The established WebTransport session.\n\t#quic: WebTransport;\n\n\t// Whether this side opened the session. Only a server may name a redirect, and only\n\t// the dialing side fails loud on a publication its grant does not cover.\n\t#client: boolean;\n\n\t// Opens request streams and allocates request IDs.\n\t#session: NativeSession;\n\n\t// Module for contributing tracks.\n\t#publisher: Publisher;\n\n\t// Module for distributing tracks.\n\t#subscriber: Subscriber;\n\n\t// The Hop IDs this session declared; see {@link Cluster}.\n\t#cluster?: Cluster.Hops;\n\n\t// The peer's GOAWAY, read off its SETUP stream.\n\t#goaway = new Once<Goaway>();\n\n\t// How the session ended: `fromClose` of the transport's close, settled after auth lets go of it.\n\t#closed = new Once<Error | null>();\n\n\t/** The implementation the peer advertised; see {@link Session.peerImplementation}. */\n\treadonly peerImplementation: Promise<string | undefined>;\n\n\t/**\n\t * Creates a new Connection instance.\n\t * @param url - The URL of the connection\n\t * @param quic - The WebTransport session\n\t * @param control - The SETUP stream, which then carries GOAWAY\n\t * @param version - The negotiated protocol version\n\t * @param solicit - What the peer's SETUP declared (undefined when it declared nothing)\n\t * @param cluster - The Hop IDs the SETUP exchange settled, on the versions that negotiate them\n\t * @param early - Uni streams that arrived before the peer's SETUP\n\t *\n\t * @internal\n\t */\n\tconstructor({\n\t\turl,\n\t\tquic,\n\t\tcontrol,\n\t\tversion,\n\t\tclient,\n\t\tpublish,\n\t\tsolicit,\n\t\thidden = false,\n\t\tactiveCount = false,\n\t\tcluster,\n\t\thandle,\n\t\tearly = [],\n\t\tpeerImplementation,\n\t\tliveness,\n\t\tlinkCost,\n\t\tpriority = 0,\n\t}: {\n\t\turl: URL;\n\t\tquic: WebTransport;\n\t\tcontrol: Stream;\n\t\tversion: IetfVersion;\n\t\t/** Whether this peer initiated the session, selecting the even request-ID space. */\n\t\tclient: boolean;\n\t\t/** The origin whose broadcasts are served to the peer. Omit to publish nothing. */\n\t\tpublish?: OriginConsumer;\n\t\t/** What the peer declared about being solicited. `undefined` means it declared nothing. */\n\t\tsolicit?: boolean;\n\t\t/** Whether the peer understands the HIDDEN parameter (MoQ Hidden). */\n\t\thidden?: boolean;\n\t\t/** Whether both SETUPs declared MoQ Active Count. */\n\t\tactiveCount?: boolean;\n\t\t/**\n\t\t * The Hop IDs this session declared (MoQ Cluster). `undefined` on a version that\n\t\t * cannot negotiate the extension, as is a `peer` the peer never declared.\n\t\t */\n\t\tcluster?: Cluster.Hops;\n\t\t/** The auth handle to build the session on, or undefined for one of its own. */\n\t\thandle?: Auth.Handle;\n\t\t/** Uni streams that arrived before the peer's SETUP, type unread. */\n\t\tearly?: Reader[];\n\t\t/** The implementation the peer's SETUP advertised, read before the session starts. */\n\t\tpeerImplementation?: string;\n\t\t/** The peer's liveness, on a transport that probes it; see {@link Session.liveness}. */\n\t\tliveness?: Getter<Liveness>;\n\t\t/** What crossing this link costs, which the SETUP exchange settled. Defaults to free. */\n\t\tlinkCost?: Cost;\n\t\t/** This link's rank, which every route the peer sends carries. Defaults to 0. */\n\t\tpriority?: number;\n\t}) {\n\t\tthis.liveness = liveness;\n\t\tthis.url = url;\n\t\tthis.version = versionName(version);\n\t\tthis.transport = transportOf(quic);\n\t\tdetect(this, quic);\n\t\tthis.#quic = quic;\n\t\tthis.#client = client;\n\t\tthis.peerImplementation = Promise.resolve(peerImplementation);\n\n\t\tthis.#session = new NativeSession(quic, version, client);\n\t\t// The SETUP stream only carries GOAWAY from here on.\n\t\tvoid this.#runGoAway(control, version);\n\n\t\t// What the peer's connection credential earns by default: publishing anything to us,\n\t\t// since we consume on demand, and subscribing to whatever we publish.\n\t\tthis.#auth = new AuthSession({\n\t\t\trequests: true,\n\t\t\tpeerGrant: {\n\t\t\t\tpublish: Path.Prefixes.all(),\n\t\t\t\tsubscribe: publish ? Path.Prefixes.all() : new Path.Prefixes(),\n\t\t\t},\n\t\t\thandle,\n\t\t\tdraining: () => this.#goaway.peek() !== undefined || this.#phase.kind !== \"open\",\n\t\t});\n\t\t// Left before anything observes the close, so a successor on the same handle never\n\t\t// finds this session still active.\n\t\tconst leave = () => this.#auth.close();\n\t\tvoid quic.closed.then(leave, leave);\n\t\tvoid quic.closed.then(\n\t\t\t(info) => this.#closed.set(fromClose(info)),\n\t\t\t(err: unknown) => this.#closed.set(error(err)),\n\t\t);\n\t\tthis.#client = client;\n\n\t\tthis.#auth.violated.subscribe((err) => {\n\t\t\tif (err) this.#violated(err);\n\t\t});\n\n\t\tthis.#publisher = new Publisher({\n\t\t\tquic: this.#quic,\n\t\t\tsession: this.#session,\n\t\t\tpublish,\n\t\t\trequiresSolicitation: solicit ?? false,\n\t\t\thidden,\n\t\t\tactiveCount,\n\t\t\tcluster,\n\t\t\tgrant: this.#auth.scope,\n\t\t\tauth: this.#auth,\n\t\t});\n\t\tthis.#cluster = cluster;\n\t\tthis.#subscriber = new Subscriber({\n\t\t\tsession: this.#session,\n\t\t\tquic,\n\t\t\tcluster,\n\t\t\thidden,\n\t\t\tactiveCount,\n\t\t\tgoaway: this.#goaway,\n\t\t\tgrant: this.#auth.scope,\n\t\t\tauth: this.#auth,\n\t\t\tlink: { cost: linkCost ?? Cost.zero, priority },\n\t\t});\n\t\tregisterWire(this, {\n\t\t\tconsume: (path) => this.#subscriber.consume(path),\n\t\t\t// The drafts refuse overlapping SUBSCRIBE_NAMESPACEs (PREFIX_OVERLAP). A peer that\n\t\t\t// declared MoQ Solicit is ours and holds both; any other may enforce it.\n\t\t\texclusive: solicit === undefined,\n\t\t\t// Drained locally only: this compatibility layer sends no client GOAWAY.\n\t\t\tleave: () => {\n\t\t\t\tif (this.#phase.kind === \"open\") this.#phase = { kind: \"leaving\" };\n\t\t\t},\n\t\t\tauth: this.#auth,\n\t\t});\n\n\t\tvoid this.#run(early);\n\t}\n\n\t/** Snapshot the transport's counters; see {@link Session.stats}. */\n\tasync stats(): Promise<Stats> {\n\t\treturn transportStats(this.#quic);\n\t}\n\n\t/** Withdraw announcements and wait up to one second for delivery before closing. */\n\tclose(): Promise<void> {\n\t\tswitch (this.#phase.kind) {\n\t\t\tcase \"open\":\n\t\t\tcase \"leaving\": {\n\t\t\t\tconst done = withTimeout(\n\t\t\t\t\tthis.#publisher.withdraw(),\n\t\t\t\t\tDuration.secs(1),\n\t\t\t\t\t\"session close timed out\",\n\t\t\t\t).finally(() => this.abort());\n\t\t\t\tthis.#phase = { kind: \"closing\", done };\n\t\t\t\treturn done;\n\t\t\t}\n\t\t\tcase \"closing\":\n\t\t\t\treturn this.#phase.done;\n\t\t\tcase \"closed\":\n\t\t\t\treturn Promise.resolve();\n\t\t}\n\t}\n\n\t/** End the session immediately without waiting for delivery. */\n\tabort(): void {\n\t\tthis.#close();\n\t}\n\n\t// Close with the session code the peer should see, a clean close by default.\n\t#close(info?: WebTransportCloseInfo) {\n\t\tif (this.#phase.kind === \"closed\") return;\n\t\tthis.#phase = { kind: \"closed\" };\n\n\t\tthis.#publisher.close();\n\t\tthis.#auth.close();\n\n\t\t// Before the session, whose own close would send a clean code first.\n\t\ttry {\n\t\t\tthis.#quic.close(info);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\tthis.#session.close();\n\t}\n\n\t// The peer broke the protocol, so losing the stream is not enough: nothing stops it\n\t// repeating the violation on the next one.\n\t#violated(err: ProtocolViolation) {\n\t\tthis.#close({ closeCode: err.code, reason: closeReason(err.message) });\n\t}\n\n\tasync #run(early: Reader[]): Promise<void> {\n\t\ttry {\n\t\t\t// All run together. runPublishNamespaces is a no-op when the peer asked to be\n\t\t\t// solicited; otherwise it pushes PUBLISH_NAMESPACE. A SUBSCRIBE_NAMESPACE stream\n\t\t\t// is filled either way. A NAMESPACE is discovery,\n\t\t\t// not a second route.\n\t\t\tconst tasks = [\n\t\t\t\tthis.#runBidis(),\n\t\t\t\tthis.#runUnis(early),\n\t\t\t\tthis.#runDatagrams(),\n\t\t\t\tthis.#publisher.runPublishNamespaces(),\n\t\t\t];\n\t\t\t// Fail loud on a publication our grant never covers, once the peer has answered the\n\t\t\t// credential we presented at setup.\n\t\t\tif (this.#client) tasks.push(this.#publisher.runEnforce(this.#auth.setupAnswered(), this.#auth));\n\t\t\tawait Promise.all(tasks);\n\t\t} catch (err) {\n\t\t\tif (this.#phase.kind !== \"closed\") {\n\t\t\t\tconsole.error(\"fatal error running connection\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\t// A graceful close owns the teardown while it drains. runPublishNamespaces is\n\t\t\t// a tracked withdrawal, so a failure in it ends this driver while close() is\n\t\t\t// still waiting on the sibling loops; closing here would drop their\n\t\t\t// withdrawals. close() aborts once its barrier settles or the deadline hits.\n\t\t\tif (this.#phase.kind !== \"closing\") this.#close();\n\t\t}\n\t}\n\n\t/** The paths announced at or beneath `prefix`, each present or absent; see {@link Session.announced}. */\n\tannounced(prefix?: Path.Valid, options?: announce.Options): announce.Consumer {\n\t\treturn announce.list(this.#subscriber.routes(prefix, options));\n\t}\n\n\t/** Every route change at or beneath `prefix`, for code that forwards routes. @internal */\n\troutes(prefix?: Path.Valid, options?: announce.Options): announce.Routes {\n\t\treturn this.#subscriber.routes(prefix, options);\n\t}\n\n\t/** Accepts request streams and dispatches them. */\n\tasync #runBidis() {\n\t\tfor (;;) {\n\t\t\tconst stream = await this.#session.acceptBi();\n\t\t\tif (!stream) break;\n\n\t\t\tvoid this.#runBidi(stream).catch((err: unknown) => {\n\t\t\t\tconsole.error(\"error processing bidi stream\", err);\n\t\t\t\tstream.abort(new Error(\"bidi stream error\"));\n\t\t\t\tif (err instanceof ProtocolViolation) this.#violated(err);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Unified bidi stream dispatch. Reads typeId and routes to handler.\n\t * Matches the lite module's runBidi pattern.\n\t */\n\tasync #runBidi(stream: Stream) {\n\t\t// Full width, so unknown types above 2^53 still reach protocol classification.\n\t\tconst typeId = await stream.reader.u62();\n\n\t\tswitch (typeId) {\n\t\t\tcase BigInt(SubscribeNamespace.id): {\n\t\t\t\tconst decoded = SubscribeNamespace.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = await this.#request(stream, \"subscribe_namespace\", decoded);\n\t\t\t\tif (msg) await handed(this.#publisher.runSubscribeNamespace(msg, stream));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase BigInt(SubscribeUpdate.id): {\n\t\t\t\t// REQUEST_UPDATE (0x02) is a follow-up, not a valid initial message\n\t\t\t\tthrow new ProtocolViolation(\"unexpected REQUEST_UPDATE as initial message\");\n\t\t\t}\n\t\t\t// Publisher handles incoming requests\n\t\t\tcase BigInt(Subscribe.id): {\n\t\t\t\tconst decoded = Subscribe.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = await this.#request(stream, \"subscribe\", decoded);\n\t\t\t\tif (msg) await handed(this.#publisher.runSubscribe(msg, stream));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase BigInt(SUBSCRIBE_TRACKS_ID): {\n\t\t\t\t// We list no tracks by PUBLISH, so each listing is refused on its own. Only its\n\t\t\t\t// Request ID is read; the rest of the body goes unread.\n\t\t\t\tconst requestId = await Message.decode(stream.reader, async (body) => {\n\t\t\t\t\tconst id = await body.u62();\n\t\t\t\t\tawait body.discard();\n\t\t\t\t\treturn id;\n\t\t\t\t}).catch((err: unknown) => {\n\t\t\t\t\tthrow malformed(err, \"subscribe_tracks\");\n\t\t\t\t});\n\t\t\t\tthis.#spend(requestId);\n\t\t\t\tawait handed(\n\t\t\t\t\tthis.#refuseUnsupported(stream, \"subscribe_namespace\", \"SUBSCRIBE_TRACKS is not supported\"),\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase BigInt(TrackStatusRequest.id): {\n\t\t\t\tconst decoded = TrackStatusRequest.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = await this.#request(stream, \"track_status\", decoded);\n\t\t\t\tif (msg) await handed(this.#publisher.runTrackStatusRequest(msg, stream));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase BigInt(Fetch.id): {\n\t\t\t\tconst decoded = Fetch.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = await this.#request(stream, \"fetch\", decoded);\n\t\t\t\t// Only a relay answers a FETCH, from its cache.\n\t\t\t\tif (msg) await handed(this.#refuseUnsupported(stream, \"fetch\", \"FETCH is not supported\"));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Subscriber handles incoming notifications\n\t\t\tcase BigInt(PublishNamespace.id): {\n\t\t\t\tconst decoded = PublishNamespace.decode(stream.reader, this.#session.version, {\n\t\t\t\t\tcluster: Cluster.negotiated(this.#cluster),\n\t\t\t\t});\n\t\t\t\tconst msg = await this.#request(stream, \"publish_namespace\", decoded);\n\t\t\t\tif (!msg) break;\n\t\t\t\tawait handed(this.#subscriber.runPublishNamespace(msg, stream));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase BigInt(Publish.id): {\n\t\t\t\tconst decoded = Publish.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = await this.#request(stream, \"publish\", decoded);\n\t\t\t\tif (msg) await handed(this.#subscriber.runPublish(msg, stream));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new ProtocolViolation(`unknown bidi stream type: 0x${typeId.toString(16)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Finish decoding a request, refusing it instead when its AUTHORIZATION TOKENs repeat.\n\t * Section 8.9 rejects that message rather than the session, unlike any other decode error.\n\t *\n\t * @returns undefined once refused.\n\t */\n\tasync #request<T extends { requestId: bigint }>(\n\t\tstream: Stream,\n\t\tkind: RequestKind,\n\t\tdecoded: Promise<T>,\n\t): Promise<T | undefined> {\n\t\tlet msg: T;\n\t\ttry {\n\t\t\tmsg = await decoded;\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof MalformedAuthToken) || err.requestId === undefined) throw malformed(err, kind);\n\t\t\tthis.#spend(err.requestId);\n\t\t\tawait this.#refuseToken(stream, kind);\n\t\t\treturn undefined;\n\t\t}\n\t\tthis.#spend(msg.requestId);\n\t\treturn msg;\n\t}\n\n\t/** Spend a request's ID, closing the session if it was already used. */\n\t#spend(requestId: bigint) {\n\t\tthis.#session.checkRequestId(requestId);\n\t}\n\n\t/** Refuse a request we never serve NOT_SUPPORTED, ending its stream. */\n\tasync #refuseUnsupported(stream: Stream, kind: RequestKind, reasonPhrase: string) {\n\t\tawait refuse(stream, this.#session.version, kind, { condition: \"not_supported\", reasonPhrase });\n\t}\n\n\t/** Refuse a request MALFORMED_AUTH_TOKEN, ending its stream. Mirrors Rust's `token::reject`. */\n\tasync #refuseToken(stream: Stream, kind: RequestKind) {\n\t\tawait refuse(stream, this.#session.version, kind, {\n\t\t\tcondition: \"malformed_auth_token\",\n\t\t\treasonPhrase: \"repeated AUTHORIZATION TOKEN\",\n\t\t});\n\t}\n\n\t// A malformed OBJECT_DATAGRAM is the peer breaking the protocol, like an invalid stream type.\n\tasync #runDatagrams() {\n\t\ttry {\n\t\t\tawait this.#subscriber.runDatagrams();\n\t\t} catch (err: unknown) {\n\t\t\tif (!(err instanceof ProtocolViolation)) throw err;\n\t\t\tconsole.warn(\"malformed datagram\", err);\n\t\t\tthis.#violated(err);\n\t\t}\n\t}\n\n\t/**\n\t * Handles unidirectional streams for media delivery (groups).\n\t */\n\tasync #runUnis(early: Reader[]) {\n\t\t// Streams that beat the SETUP go first, in arrival order.\n\t\tfor (const stream of early) this.#spawnUni(stream);\n\n\t\tconst readers = new Readers(this.#quic, this.#session.version);\n\t\tfor (;;) {\n\t\t\tconst stream = await readers.next();\n\t\t\tif (!stream) break;\n\t\t\tthis.#spawnUni(stream);\n\t\t}\n\t}\n\n\t#spawnUni(stream: Reader) {\n\t\tthis.#runUni(stream)\n\t\t\t.then(() => {\n\t\t\t\tstream.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t\t\t})\n\t\t\t.catch((err: unknown) => {\n\t\t\t\t// A peer resetting a stream it no longer wants to send is routine, not an error;\n\t\t\t\t// only a violation is, and that one closes the session with its code.\n\t\t\t\tstream.stop(err);\n\n\t\t\t\t// An unknown or invalid stream type MUST close the session, not just the stream.\n\t\t\t\tif (err instanceof ProtocolViolation) this.#violated(err);\n\t\t\t});\n\t}\n\n\tasync #runUni(stream: Reader) {\n\t\tconst version = this.#session.version;\n\t\t// Full width, so an unknown type past 2^53 is still classified rather than thrown.\n\t\tconst type = await stream.u62();\n\n\t\t// SUBGROUP_HEADER types match 0b0XX1XXXX; Group.decode validates the bits per draft.\n\t\tif (type <= 0xffn && (type & 0x90n) === 0x10n) {\n\t\t\tconst header = await Group.decode(stream, version, Number(type));\n\t\t\tawait this.#subscriber.handleGroup(header, stream);\n\t\t\treturn;\n\t\t}\n\n\t\t// The receiver MUST discard padding. We read it to the end rather than cancel,\n\t\t// so a peer probing for bandwidth gets the throughput it is measuring.\n\t\tif (type === PADDING) {\n\t\t\tawait stream.discard();\n\t\t\treturn;\n\t\t}\n\n\t\t// The head of a join, answering our draft-18 joining FETCH or draft-22 fill.\n\t\tif (type === BigInt(FetchHeader.type)) {\n\t\t\tawait this.#subscriber.handleFetch(stream);\n\t\t\treturn;\n\t\t}\n\n\t\t// Anything else is unknown, and a second SETUP is a violation too.\n\t\tthrow new ProtocolViolation(`unknown uni stream type: 0x${type.toString(16)}`);\n\t}\n\n\t/**\n\t * Reads GOAWAY from the SETUP stream.\n\t *\n\t * The session keeps serving after a GOAWAY so its groups in flight can finish while the\n\t * caller migrates; only the stream ending, or a second GOAWAY, closes it here.\n\t */\n\tasync #runGoAway(controlStream: Stream, version: IetfVersion) {\n\t\ttry {\n\t\t\tconst read = async () => {\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst done = await controlStream.reader.done();\n\t\t\t\t\tif (done) throw new ProtocolViolation(\"control stream closed\");\n\n\t\t\t\t\tconst msg = await this.#readGoAway(controlStream, version).catch((err: unknown) => {\n\t\t\t\t\t\tthrow malformed(err, \"setup stream message\");\n\t\t\t\t\t});\n\t\t\t\t\tif (this.#goaway.peek() !== undefined) throw new ProtocolViolation(\"duplicate GOAWAY\");\n\t\t\t\t\t// A client may leave, but only the server may name where to go.\n\t\t\t\t\tif (!this.#client && msg.newSessionUri !== \"\") {\n\t\t\t\t\t\tthrow new ProtocolViolation(\"client GOAWAY must not name a redirect\");\n\t\t\t\t\t}\n\t\t\t\t\t// Draft-18's Request ID names our IDs: even when we are the client, odd for a server.\n\t\t\t\t\t// It is required here, on the control stream.\n\t\t\t\t\tif (version === Version.DRAFT_18 && msg.requestId === undefined) {\n\t\t\t\t\t\tthrow new ProtocolViolation(\"draft-18 GOAWAY on the control stream lacks a Request ID\");\n\t\t\t\t\t}\n\t\t\t\t\tif (msg.requestId !== undefined && msg.requestId % 2n !== (this.#client ? 0n : 1n)) {\n\t\t\t\t\t\tthrow new ProtocolViolation(\"GOAWAY Request ID has the wrong parity\", {\n\t\t\t\t\t\t\tcode: IetfSessionCode.InvalidRequestId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\t// Reject bytes already behind GOAWAY before a caller can close on the drain.\n\t\t\t\t\tif (controlStream.reader.tryDecode((c) => c.u8()) !== undefined)\n\t\t\t\t\t\tthrow new ProtocolViolation(\"message after control stream GOAWAY\");\n\t\t\t\t\tthis.#goaway.set(msg.drain());\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst stopped = controlStream.writer.closed.then(() => {\n\t\t\t\tthrow new ProtocolViolation(\"control stream stopped\");\n\t\t\t});\n\t\t\tawait race([read(), stopped]);\n\t\t} catch (err) {\n\t\t\tif (this.#phase.kind !== \"closed\" && !sessionClosed(err))\n\t\t\t\tthis.#violated(\n\t\t\t\t\terr instanceof ProtocolViolation\n\t\t\t\t\t\t? err\n\t\t\t\t\t\t: new ProtocolViolation(\"control stream failed\", { cause: err }),\n\t\t\t\t);\n\t\t} finally {\n\t\t\tthis.#close();\n\t\t}\n\t}\n\n\t// The setup stream carries nothing but GOAWAY after SETUP.\n\tasync #readGoAway(controlStream: Stream, version: IetfVersion): Promise<GoAway> {\n\t\tconst typeId = await controlStream.reader.u53();\n\t\tif (typeId !== GoAway.id) {\n\t\t\tthrow new ProtocolViolation(`unexpected message on setup stream: 0x${typeId.toString(16)}`);\n\t\t}\n\t\treturn GoAway.decode(controlStream.reader, version);\n\t}\n\n\t/** Settles with the peer's GOAWAY; see {@link Session.draining}. */\n\tget draining(): GetPromise<Goaway> {\n\t\treturn this.#goaway;\n\t}\n\n\t/** Settles when the session closes, decoding the peer's close code; see {@link Session.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#closed;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OBJECT_DATAGRAM: one Object carried in a QUIC datagram (draft-14 section 10.3.1 through
|
|
3
|
+
* draft-22 section 11.2.1).
|
|
4
|
+
*
|
|
5
|
+
* The model counterpart is {@link Datagram}, a single-frame group, so only an Object at ID 0
|
|
6
|
+
* maps onto it. The Type is a set of flags on every draft; draft-14 lacks the
|
|
7
|
+
* DEFAULT_PRIORITY bit and a status with an omitted Object ID. Mirrors the Rust
|
|
8
|
+
* `ietf::ObjectDatagram`.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { Datagram } from "../datagram.ts";
|
|
13
|
+
import type { IetfVersion } from "./version.ts";
|
|
14
|
+
/** What follows an OBJECT_DATAGRAM's header: the payload, or the status of an Object without one. */
|
|
15
|
+
export type DatagramBody = {
|
|
16
|
+
payload: Uint8Array;
|
|
17
|
+
} | {
|
|
18
|
+
status: number;
|
|
19
|
+
};
|
|
20
|
+
/** A decoded OBJECT_DATAGRAM. */
|
|
21
|
+
export declare class ObjectDatagram {
|
|
22
|
+
trackAlias: bigint;
|
|
23
|
+
groupId: bigint;
|
|
24
|
+
/** The Object ID, or `undefined` when the ZERO_OBJECT_ID bit omits it (Object 0). */
|
|
25
|
+
objectId?: bigint;
|
|
26
|
+
/** The Publisher Priority, or `undefined` to inherit the subscription's. */
|
|
27
|
+
publisherPriority?: number;
|
|
28
|
+
/** No Object past this one exists in the group. */
|
|
29
|
+
endOfGroup: boolean;
|
|
30
|
+
/** The Object Properties block without its length prefix. */
|
|
31
|
+
properties?: Uint8Array;
|
|
32
|
+
body: DatagramBody;
|
|
33
|
+
constructor(props: {
|
|
34
|
+
trackAlias: bigint;
|
|
35
|
+
groupId: bigint;
|
|
36
|
+
objectId?: bigint;
|
|
37
|
+
publisherPriority?: number;
|
|
38
|
+
endOfGroup: boolean;
|
|
39
|
+
properties?: Uint8Array;
|
|
40
|
+
body: DatagramBody;
|
|
41
|
+
});
|
|
42
|
+
/** Encode one QUIC datagram's bytes. Throws on a combination this draft cannot carry. */
|
|
43
|
+
encode(version: IetfVersion): Uint8Array;
|
|
44
|
+
/**
|
|
45
|
+
* Decode one QUIC datagram's bytes. Anything malformed is the peer breaking the protocol,
|
|
46
|
+
* so every failure is a {@link ProtocolViolation}.
|
|
47
|
+
*/
|
|
48
|
+
static decode(data: Uint8Array, version: IetfVersion): Promise<ObjectDatagram>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Encode a datagram the way a publisher sends it: Object 0 of a group that has no other, so it
|
|
52
|
+
* ends its group, without properties. The Group ID is `wire`, the key the datagram carried on a
|
|
53
|
+
* legacy hop, else its timestamp's value, as a group is keyed by its start.
|
|
54
|
+
*/
|
|
55
|
+
export declare function encodeDatagram(datagram: Datagram, options: {
|
|
56
|
+
trackAlias: bigint;
|
|
57
|
+
publisherPriority: number;
|
|
58
|
+
wire?: bigint;
|
|
59
|
+
}, version: IetfVersion): Promise<Uint8Array>;
|
|
60
|
+
//# sourceMappingURL=datagram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datagram.d.ts","sourceRoot":"","sources":["../../src/ietf/datagram.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAiBhD,qGAAqG;AACrG,MAAM,MAAM,YAAY,GAAG;IAAE,OAAO,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,iCAAiC;AACjC,qBAAa,cAAc;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mDAAmD;IACnD,UAAU,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,IAAI,EAAE,YAAY,CAAC;IAEnB,YAAY,KAAK,EAAE;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,UAAU,EAAE,OAAO,CAAC;QACpB,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,IAAI,EAAE,YAAY,CAAC;KACnB,EAQA;IAED,yFAAyF;IACzF,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAmCvC;IAED;;;OAGG;IACH,OAAa,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAOnF;CACD;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CACnC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACzE,OAAO,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,CAAC,CAQrB"}
|
package/ietf/datagram.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { error, ProtocolViolation, reason } from "../error.js";
|
|
2
|
+
import { encodeVarint, Reader } from "../stream.js";
|
|
3
|
+
// The bits of an OBJECT_DATAGRAM Type.
|
|
4
|
+
const PROPERTIES = 0x01;
|
|
5
|
+
const END_OF_GROUP = 0x02;
|
|
6
|
+
const ZERO_OBJECT_ID = 0x04;
|
|
7
|
+
const DEFAULT_PRIORITY = 0x08;
|
|
8
|
+
const STATUS = 0x20;
|
|
9
|
+
// Every defined bit. Anything else, including the reserved 0x10, is invalid.
|
|
10
|
+
const ALL = PROPERTIES | END_OF_GROUP | ZERO_OBJECT_ID | DEFAULT_PRIORITY | STATUS;
|
|
11
|
+
/** Whether `kind` is a Type this draft defines. */
|
|
12
|
+
function valid(kind) {
|
|
13
|
+
// A status cannot also end the group.
|
|
14
|
+
return (kind & ~ALL) === 0 && !((kind & STATUS) !== 0 && (kind & END_OF_GROUP) !== 0);
|
|
15
|
+
}
|
|
16
|
+
/** A decoded OBJECT_DATAGRAM. */
|
|
17
|
+
export class ObjectDatagram {
|
|
18
|
+
trackAlias;
|
|
19
|
+
groupId;
|
|
20
|
+
/** The Object ID, or `undefined` when the ZERO_OBJECT_ID bit omits it (Object 0). */
|
|
21
|
+
objectId;
|
|
22
|
+
/** The Publisher Priority, or `undefined` to inherit the subscription's. */
|
|
23
|
+
publisherPriority;
|
|
24
|
+
/** No Object past this one exists in the group. */
|
|
25
|
+
endOfGroup;
|
|
26
|
+
/** The Object Properties block without its length prefix. */
|
|
27
|
+
properties;
|
|
28
|
+
body;
|
|
29
|
+
constructor(props) {
|
|
30
|
+
this.trackAlias = props.trackAlias;
|
|
31
|
+
this.groupId = props.groupId;
|
|
32
|
+
this.objectId = props.objectId;
|
|
33
|
+
this.publisherPriority = props.publisherPriority;
|
|
34
|
+
this.endOfGroup = props.endOfGroup;
|
|
35
|
+
this.properties = props.properties;
|
|
36
|
+
this.body = props.body;
|
|
37
|
+
}
|
|
38
|
+
/** Encode one QUIC datagram's bytes. Throws on a combination this draft cannot carry. */
|
|
39
|
+
encode(version) {
|
|
40
|
+
let kind = 0;
|
|
41
|
+
if (this.properties !== undefined)
|
|
42
|
+
kind |= PROPERTIES;
|
|
43
|
+
if (this.endOfGroup)
|
|
44
|
+
kind |= END_OF_GROUP;
|
|
45
|
+
if (this.objectId === undefined)
|
|
46
|
+
kind |= ZERO_OBJECT_ID;
|
|
47
|
+
if (this.publisherPriority === undefined)
|
|
48
|
+
kind |= DEFAULT_PRIORITY;
|
|
49
|
+
if ("status" in this.body)
|
|
50
|
+
kind |= STATUS;
|
|
51
|
+
if (!valid(kind))
|
|
52
|
+
throw new Error(`OBJECT_DATAGRAM type 0x${kind.toString(16)} is invalid`);
|
|
53
|
+
const parts = [encodeVarint(kind, version), encodeVarint(this.trackAlias, version)];
|
|
54
|
+
parts.push(encodeVarint(this.groupId, version));
|
|
55
|
+
if (this.objectId !== undefined)
|
|
56
|
+
parts.push(encodeVarint(this.objectId, version));
|
|
57
|
+
if (this.publisherPriority !== undefined)
|
|
58
|
+
parts.push(Uint8Array.of(this.publisherPriority));
|
|
59
|
+
if (this.properties !== undefined) {
|
|
60
|
+
// A present but empty block is a protocol violation for the peer.
|
|
61
|
+
if (this.properties.byteLength === 0)
|
|
62
|
+
throw new Error("OBJECT_DATAGRAM properties are empty");
|
|
63
|
+
parts.push(encodeVarint(this.properties.byteLength, version), this.properties);
|
|
64
|
+
}
|
|
65
|
+
if ("status" in this.body) {
|
|
66
|
+
if (this.body.status !== 0 && this.properties !== undefined) {
|
|
67
|
+
throw new Error("only a Normal OBJECT_DATAGRAM may carry properties");
|
|
68
|
+
}
|
|
69
|
+
parts.push(encodeVarint(this.body.status, version));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Runs to the datagram boundary: written raw, no length prefix.
|
|
73
|
+
parts.push(this.body.payload);
|
|
74
|
+
}
|
|
75
|
+
const out = new Uint8Array(parts.reduce((total, part) => total + part.byteLength, 0));
|
|
76
|
+
let offset = 0;
|
|
77
|
+
for (const part of parts) {
|
|
78
|
+
out.set(part, offset);
|
|
79
|
+
offset += part.byteLength;
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Decode one QUIC datagram's bytes. Anything malformed is the peer breaking the protocol,
|
|
85
|
+
* so every failure is a {@link ProtocolViolation}.
|
|
86
|
+
*/
|
|
87
|
+
static async decode(data, version) {
|
|
88
|
+
try {
|
|
89
|
+
return await new Reader(undefined, data, version).decode(decodeFields);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
if (err instanceof ProtocolViolation)
|
|
93
|
+
throw err;
|
|
94
|
+
throw new ProtocolViolation(`malformed OBJECT_DATAGRAM: ${reason(error(err))}`, { cause: err });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Encode a datagram the way a publisher sends it: Object 0 of a group that has no other, so it
|
|
100
|
+
* ends its group, without properties. The Group ID is `wire`, the key the datagram carried on a
|
|
101
|
+
* legacy hop, else its timestamp's value, as a group is keyed by its start.
|
|
102
|
+
*/
|
|
103
|
+
export async function encodeDatagram(datagram, options, version) {
|
|
104
|
+
return new ObjectDatagram({
|
|
105
|
+
trackAlias: options.trackAlias,
|
|
106
|
+
groupId: options.wire ?? BigInt(datagram.timestamp.value),
|
|
107
|
+
publisherPriority: options.publisherPriority,
|
|
108
|
+
endOfGroup: true,
|
|
109
|
+
body: { payload: datagram.payload },
|
|
110
|
+
}).encode(version);
|
|
111
|
+
}
|
|
112
|
+
function decodeFields(c) {
|
|
113
|
+
// Full width, so an out-of-range Type is refused rather than overflowing.
|
|
114
|
+
const raw = c.u62();
|
|
115
|
+
const kind = raw <= 0xffn ? Number(raw) : -1;
|
|
116
|
+
if (kind < 0 || !valid(kind)) {
|
|
117
|
+
throw new ProtocolViolation(`invalid OBJECT_DATAGRAM type 0x${raw.toString(16)}`);
|
|
118
|
+
}
|
|
119
|
+
const trackAlias = c.u62();
|
|
120
|
+
const groupId = c.u62();
|
|
121
|
+
const objectId = kind & ZERO_OBJECT_ID ? undefined : c.u62();
|
|
122
|
+
const publisherPriority = kind & DEFAULT_PRIORITY ? undefined : c.u8();
|
|
123
|
+
let properties;
|
|
124
|
+
if (kind & PROPERTIES) {
|
|
125
|
+
properties = c.read(c.u53());
|
|
126
|
+
if (properties.byteLength === 0)
|
|
127
|
+
throw new ProtocolViolation("OBJECT_DATAGRAM properties are empty");
|
|
128
|
+
}
|
|
129
|
+
let body;
|
|
130
|
+
if (kind & STATUS) {
|
|
131
|
+
const status = c.u53();
|
|
132
|
+
if (status !== 0 && properties !== undefined) {
|
|
133
|
+
throw new ProtocolViolation("only a Normal OBJECT_DATAGRAM may carry properties");
|
|
134
|
+
}
|
|
135
|
+
if (c.remaining > 0)
|
|
136
|
+
throw new ProtocolViolation(`OBJECT_DATAGRAM has ${c.remaining} trailing bytes`);
|
|
137
|
+
body = { status };
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
body = { payload: c.read(c.remaining) };
|
|
141
|
+
}
|
|
142
|
+
return new ObjectDatagram({
|
|
143
|
+
trackAlias,
|
|
144
|
+
groupId,
|
|
145
|
+
objectId,
|
|
146
|
+
publisherPriority,
|
|
147
|
+
endOfGroup: (kind & END_OF_GROUP) !== 0,
|
|
148
|
+
properties,
|
|
149
|
+
body,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=datagram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datagram.js","sourceRoot":"","sources":["../../src/ietf/datagram.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAe,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGjE,uCAAuC;AACvC,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,MAAM,GAAG,IAAI,CAAC;AACpB,6EAA6E;AAC7E,MAAM,GAAG,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,GAAG,gBAAgB,GAAG,MAAM,CAAC;AAEnF,mDAAmD;AACnD,SAAS,KAAK,CAAC,IAAY;IAC1B,sCAAsC;IACtC,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG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AAC,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,MAAM,KAAK,CAAC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9C,MAAM,IAAI,iBAAiB,CAAC,oDAAoD,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC;YAAE,MAAM,IAAI,iBAAiB,CAAC,uBAAuB,CAAC,CAAC,SAAS,iBAAiB,CAAC,CAAC;QACtG,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC;IACnB,CAAC;SAAM,CAAC;QACP,IAAI,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;IACzC,CAAC;IAED,OAAO,IAAI,cAAc,CAAC;QACzB,UAAU;QACV,OAAO;QACP,QAAQ;QACR,iBAAiB;QACjB,UAAU,EAAE,CAAC,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC;QACvC,UAAU;QACV,IAAI;KACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * OBJECT_DATAGRAM: one Object carried in a QUIC datagram (draft-14 section 10.3.1 through\n * draft-22 section 11.2.1).\n *\n * The model counterpart is {@link Datagram}, a single-frame group, so only an Object at ID 0\n * maps onto it. The Type is a set of flags on every draft; draft-14 lacks the\n * DEFAULT_PRIORITY bit and a status with an omitted Object ID. Mirrors the Rust\n * `ietf::ObjectDatagram`.\n *\n * @module\n */\nimport type { Datagram } from \"../datagram.ts\";\nimport { error, ProtocolViolation, reason } from \"../error.ts\";\nimport { type Cursor, encodeVarint, Reader } from \"../stream.ts\";\nimport type { IetfVersion } from \"./version.ts\";\n\n// The bits of an OBJECT_DATAGRAM Type.\nconst PROPERTIES = 0x01;\nconst END_OF_GROUP = 0x02;\nconst ZERO_OBJECT_ID = 0x04;\nconst DEFAULT_PRIORITY = 0x08;\nconst STATUS = 0x20;\n// Every defined bit. Anything else, including the reserved 0x10, is invalid.\nconst ALL = PROPERTIES | END_OF_GROUP | ZERO_OBJECT_ID | DEFAULT_PRIORITY | STATUS;\n\n/** Whether `kind` is a Type this draft defines. */\nfunction valid(kind: number): boolean {\n\t// A status cannot also end the group.\n\treturn (kind & ~ALL) === 0 && !((kind & STATUS) !== 0 && (kind & END_OF_GROUP) !== 0);\n}\n\n/** What follows an OBJECT_DATAGRAM's header: the payload, or the status of an Object without one. */\nexport type DatagramBody = { payload: Uint8Array } | { status: number };\n\n/** A decoded OBJECT_DATAGRAM. */\nexport class ObjectDatagram {\n\ttrackAlias: bigint;\n\tgroupId: bigint;\n\t/** The Object ID, or `undefined` when the ZERO_OBJECT_ID bit omits it (Object 0). */\n\tobjectId?: bigint;\n\t/** The Publisher Priority, or `undefined` to inherit the subscription's. */\n\tpublisherPriority?: number;\n\t/** No Object past this one exists in the group. */\n\tendOfGroup: boolean;\n\t/** The Object Properties block without its length prefix. */\n\tproperties?: Uint8Array;\n\tbody: DatagramBody;\n\n\tconstructor(props: {\n\t\ttrackAlias: bigint;\n\t\tgroupId: bigint;\n\t\tobjectId?: bigint;\n\t\tpublisherPriority?: number;\n\t\tendOfGroup: boolean;\n\t\tproperties?: Uint8Array;\n\t\tbody: DatagramBody;\n\t}) {\n\t\tthis.trackAlias = props.trackAlias;\n\t\tthis.groupId = props.groupId;\n\t\tthis.objectId = props.objectId;\n\t\tthis.publisherPriority = props.publisherPriority;\n\t\tthis.endOfGroup = props.endOfGroup;\n\t\tthis.properties = props.properties;\n\t\tthis.body = props.body;\n\t}\n\n\t/** Encode one QUIC datagram's bytes. Throws on a combination this draft cannot carry. */\n\tencode(version: IetfVersion): Uint8Array {\n\t\tlet kind = 0;\n\t\tif (this.properties !== undefined) kind |= PROPERTIES;\n\t\tif (this.endOfGroup) kind |= END_OF_GROUP;\n\t\tif (this.objectId === undefined) kind |= ZERO_OBJECT_ID;\n\t\tif (this.publisherPriority === undefined) kind |= DEFAULT_PRIORITY;\n\t\tif (\"status\" in this.body) kind |= STATUS;\n\t\tif (!valid(kind)) throw new Error(`OBJECT_DATAGRAM type 0x${kind.toString(16)} is invalid`);\n\n\t\tconst parts = [encodeVarint(kind, version), encodeVarint(this.trackAlias, version)];\n\t\tparts.push(encodeVarint(this.groupId, version));\n\t\tif (this.objectId !== undefined) parts.push(encodeVarint(this.objectId, version));\n\t\tif (this.publisherPriority !== undefined) parts.push(Uint8Array.of(this.publisherPriority));\n\t\tif (this.properties !== undefined) {\n\t\t\t// A present but empty block is a protocol violation for the peer.\n\t\t\tif (this.properties.byteLength === 0) throw new Error(\"OBJECT_DATAGRAM properties are empty\");\n\t\t\tparts.push(encodeVarint(this.properties.byteLength, version), this.properties);\n\t\t}\n\t\tif (\"status\" in this.body) {\n\t\t\tif (this.body.status !== 0 && this.properties !== undefined) {\n\t\t\t\tthrow new Error(\"only a Normal OBJECT_DATAGRAM may carry properties\");\n\t\t\t}\n\t\t\tparts.push(encodeVarint(this.body.status, version));\n\t\t} else {\n\t\t\t// Runs to the datagram boundary: written raw, no length prefix.\n\t\t\tparts.push(this.body.payload);\n\t\t}\n\n\t\tconst out = new Uint8Array(parts.reduce((total, part) => total + part.byteLength, 0));\n\t\tlet offset = 0;\n\t\tfor (const part of parts) {\n\t\t\tout.set(part, offset);\n\t\t\toffset += part.byteLength;\n\t\t}\n\t\treturn out;\n\t}\n\n\t/**\n\t * Decode one QUIC datagram's bytes. Anything malformed is the peer breaking the protocol,\n\t * so every failure is a {@link ProtocolViolation}.\n\t */\n\tstatic async decode(data: Uint8Array, version: IetfVersion): Promise<ObjectDatagram> {\n\t\ttry {\n\t\t\treturn await new Reader(undefined, data, version).decode(decodeFields);\n\t\t} catch (err: unknown) {\n\t\t\tif (err instanceof ProtocolViolation) throw err;\n\t\t\tthrow new ProtocolViolation(`malformed OBJECT_DATAGRAM: ${reason(error(err))}`, { cause: err });\n\t\t}\n\t}\n}\n\n/**\n * Encode a datagram the way a publisher sends it: Object 0 of a group that has no other, so it\n * ends its group, without properties. The Group ID is `wire`, the key the datagram carried on a\n * legacy hop, else its timestamp's value, as a group is keyed by its start.\n */\nexport async function encodeDatagram(\n\tdatagram: Datagram,\n\toptions: { trackAlias: bigint; publisherPriority: number; wire?: bigint },\n\tversion: IetfVersion,\n): Promise<Uint8Array> {\n\treturn new ObjectDatagram({\n\t\ttrackAlias: options.trackAlias,\n\t\tgroupId: options.wire ?? BigInt(datagram.timestamp.value),\n\t\tpublisherPriority: options.publisherPriority,\n\t\tendOfGroup: true,\n\t\tbody: { payload: datagram.payload },\n\t}).encode(version);\n}\n\nfunction decodeFields(c: Cursor): ObjectDatagram {\n\t// Full width, so an out-of-range Type is refused rather than overflowing.\n\tconst raw = c.u62();\n\tconst kind = raw <= 0xffn ? Number(raw) : -1;\n\tif (kind < 0 || !valid(kind)) {\n\t\tthrow new ProtocolViolation(`invalid OBJECT_DATAGRAM type 0x${raw.toString(16)}`);\n\t}\n\n\tconst trackAlias = c.u62();\n\tconst groupId = c.u62();\n\tconst objectId = kind & ZERO_OBJECT_ID ? undefined : c.u62();\n\tconst publisherPriority = kind & DEFAULT_PRIORITY ? undefined : c.u8();\n\tlet properties: Uint8Array | undefined;\n\tif (kind & PROPERTIES) {\n\t\tproperties = c.read(c.u53());\n\t\tif (properties.byteLength === 0) throw new ProtocolViolation(\"OBJECT_DATAGRAM properties are empty\");\n\t}\n\n\tlet body: DatagramBody;\n\tif (kind & STATUS) {\n\t\tconst status = c.u53();\n\t\tif (status !== 0 && properties !== undefined) {\n\t\t\tthrow new ProtocolViolation(\"only a Normal OBJECT_DATAGRAM may carry properties\");\n\t\t}\n\t\tif (c.remaining > 0) throw new ProtocolViolation(`OBJECT_DATAGRAM has ${c.remaining} trailing bytes`);\n\t\tbody = { status };\n\t} else {\n\t\tbody = { payload: c.read(c.remaining) };\n\t}\n\n\treturn new ObjectDatagram({\n\t\ttrackAlias,\n\t\tgroupId,\n\t\tobjectId,\n\t\tpublisherPriority,\n\t\tendOfGroup: (kind & END_OF_GROUP) !== 0,\n\t\tproperties,\n\t\tbody,\n\t});\n}\n"]}
|
package/ietf/error.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The moq-transport error code registries, per negotiated draft.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Draft-22 added INVALID_FILTER and removed INVALID_JOINING_REQUEST_ID; the rest
|
|
5
|
+
* holds from draft-18 on. Mirrors the Rust `moq_net::ietf::error` module, and the two have
|
|
6
|
+
* to agree value for value.
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|