@moq/net 0.4.7 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/announce.d.ts +1 -1
- package/announce.d.ts.map +1 -1
- package/announce.js +1 -2
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -32
- package/announced.js.map +1 -1
- package/announced.test-util.d.ts +2 -0
- package/announced.test-util.d.ts.map +1 -0
- package/announced.test-util.js +27 -0
- package/announced.test-util.js.map +1 -0
- package/auth.d.ts +64 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +20 -0
- package/auth.js.map +1 -0
- package/auth_gate.d.ts +2 -0
- package/auth_gate.d.ts.map +1 -0
- package/auth_gate.js +24 -0
- package/auth_gate.js.map +1 -0
- package/auth_session.d.ts +49 -0
- package/auth_session.d.ts.map +1 -0
- package/auth_session.js +1097 -0
- package/auth_session.js.map +1 -0
- package/bandwidth.d.ts +129 -25
- package/bandwidth.d.ts.map +1 -1
- package/bandwidth.js +410 -139
- package/bandwidth.js.map +1 -1
- package/bandwidth_api.d.ts +1 -1
- package/bandwidth_api.d.ts.map +1 -1
- package/bandwidth_api.js +1 -2
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +64 -38
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -173
- package/broadcast.js.map +1 -1
- package/cache.d.ts +103 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +254 -0
- package/cache.js.map +1 -0
- package/claim.test-util.d.ts +5 -0
- package/claim.test-util.d.ts.map +1 -0
- package/claim.test-util.js +13 -0
- package/claim.test-util.js.map +1 -0
- package/connection/accept.d.ts +21 -13
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -130
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -20
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +120 -24
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -217
- package/connection/connect.js.map +1 -1
- package/connection/dials.d.ts +45 -0
- package/connection/dials.d.ts.map +1 -0
- package/connection/dials.js +109 -0
- package/connection/dials.js.map +1 -0
- package/connection/endpoint.d.ts +60 -0
- package/connection/endpoint.d.ts.map +1 -0
- package/connection/endpoint.js +114 -0
- package/connection/endpoint.js.map +1 -0
- package/connection/forward.d.ts +7 -1
- package/connection/forward.d.ts.map +1 -1
- package/connection/forward.js +265 -81
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +16 -9
- package/connection/goaway.d.ts.map +1 -1
- package/connection/goaway.js +22 -95
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +34 -8
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -21
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +4 -7
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -3
- package/connection/index.js.map +1 -1
- package/connection/liveness.d.ts +14 -0
- package/connection/liveness.d.ts.map +1 -0
- package/connection/liveness.js +30 -0
- package/connection/liveness.js.map +1 -0
- package/connection/pool.d.ts +142 -63
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -118
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts +60 -12
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +859 -234
- package/connection/reload.js.map +1 -1
- package/connection/session.d.ts +91 -0
- package/connection/session.d.ts.map +1 -0
- package/connection/session.js +2 -0
- package/connection/session.js.map +1 -0
- package/connection/stats.d.ts +20 -11
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js +64 -9
- package/connection/stats.js.map +1 -1
- package/connection/ticker.d.ts +4 -0
- package/connection/ticker.d.ts.map +1 -0
- package/connection/ticker.js +66 -0
- package/connection/ticker.js.map +1 -0
- package/connection/tokens.d.ts +2 -0
- package/connection/tokens.d.ts.map +1 -0
- package/connection/tokens.js +404 -0
- package/connection/tokens.js.map +1 -0
- package/connection/transport.d.ts.map +1 -1
- package/connection/transport.js +4 -5
- package/connection/transport.js.map +1 -1
- package/connection/withdrawal.d.ts +2 -0
- package/connection/withdrawal.d.ts.map +1 -0
- package/connection/withdrawal.js +23 -0
- package/connection/withdrawal.js.map +1 -0
- package/consume.js +213 -47
- package/consume.js.map +1 -1
- package/cover.d.ts +59 -0
- package/cover.d.ts.map +1 -0
- package/cover.js +375 -0
- package/cover.js.map +1 -0
- package/datagram.d.ts +70 -11
- package/datagram.d.ts.map +1 -1
- package/datagram.js +317 -2
- package/datagram.js.map +1 -1
- package/datagram_stream.d.ts +18 -0
- package/datagram_stream.d.ts.map +1 -0
- package/datagram_stream.js +67 -0
- package/datagram_stream.js.map +1 -0
- package/defined.test-util.d.ts +2 -0
- package/defined.test-util.d.ts.map +1 -0
- package/defined.test-util.js +7 -0
- package/defined.test-util.js.map +1 -0
- package/delivered.d.ts +75 -0
- package/delivered.d.ts.map +1 -0
- package/delivered.js +228 -0
- package/delivered.js.map +1 -0
- package/demand.d.ts +173 -0
- package/demand.d.ts.map +1 -0
- package/demand.js +582 -0
- package/demand.js.map +1 -0
- package/drops.d.ts +93 -0
- package/drops.d.ts.map +1 -0
- package/drops.js +283 -0
- package/drops.js.map +1 -0
- package/error.d.ts +120 -21
- package/error.d.ts.map +1 -1
- package/error.js +230 -38
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -3
- package/errors.js.map +1 -1
- package/fill.d.ts +174 -0
- package/fill.d.ts.map +1 -0
- package/fill.js +760 -0
- package/fill.js.map +1 -0
- package/flate/decoder.d.ts +2 -0
- package/flate/decoder.d.ts.map +1 -0
- package/flate/decoder.js +63 -0
- package/flate/decoder.js.map +1 -0
- package/flate/encoder.d.ts +2 -0
- package/flate/encoder.d.ts.map +1 -0
- package/flate/encoder.js +64 -0
- package/flate/encoder.js.map +1 -0
- package/flate/group.d.ts +34 -0
- package/flate/group.d.ts.map +1 -0
- package/flate/group.js +140 -0
- package/flate/group.js.map +1 -0
- package/frame.d.ts +80 -0
- package/frame.d.ts.map +1 -0
- package/frame.js +296 -0
- package/frame.js.map +1 -0
- package/frame.test-util.d.ts +5 -0
- package/frame.test-util.d.ts.map +1 -0
- package/frame.test-util.js +9 -0
- package/frame.test-util.js.map +1 -0
- package/group.d.ts +108 -45
- package/group.d.ts.map +1 -1
- package/group.js +1616 -308
- package/group.js.map +1 -1
- package/group_api.d.ts +7 -0
- package/group_api.d.ts.map +1 -0
- package/group_api.js +7 -0
- package/group_api.js.map +1 -0
- package/hop.d.ts +62 -76
- package/hop.d.ts.map +1 -1
- package/hop.js +92 -65
- package/hop.js.map +1 -1
- package/identity.d.ts +39 -0
- package/identity.d.ts.map +1 -0
- package/identity.js +47 -0
- package/identity.js.map +1 -0
- package/ietf/active_count.d.ts +2 -0
- package/ietf/active_count.d.ts.map +1 -0
- package/ietf/active_count.js +30 -0
- package/ietf/active_count.js.map +1 -0
- package/ietf/aliases.js +69 -36
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -55
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +1 -31
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +305 -144
- package/ietf/connection.js.map +1 -1
- package/ietf/datagram.d.ts +60 -0
- package/ietf/datagram.d.ts.map +1 -0
- package/ietf/datagram.js +152 -0
- package/ietf/datagram.js.map +1 -0
- package/ietf/error.d.ts +3 -3
- package/ietf/error.js +82 -101
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +93 -37
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -94
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +21 -31
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -172
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +12 -10
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -36
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -2
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +8 -20
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -15
- package/ietf/index.js.map +1 -1
- package/ietf/join.d.ts +7 -0
- package/ietf/join.d.ts.map +1 -0
- package/ietf/join.js +234 -0
- package/ietf/join.js.map +1 -0
- package/ietf/message.d.ts +18 -2
- package/ietf/message.d.ts.map +1 -1
- package/ietf/message.js +60 -41
- package/ietf/message.js.map +1 -1
- package/ietf/message.test-util.d.ts +6 -0
- package/ietf/message.test-util.d.ts.map +1 -0
- package/ietf/message.test-util.js +13 -0
- package/ietf/message.test-util.js.map +1 -0
- package/ietf/namespace.d.ts +19 -5
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -27
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +195 -33
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -179
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +25 -45
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -473
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +17 -2
- package/ietf/priority.d.ts.map +1 -1
- package/ietf/priority.js +19 -5
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +6 -5
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -49
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +25 -33
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -140
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +49 -72
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -185
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -601
- package/ietf/publisher.js.map +1 -1
- package/ietf/range.d.ts +2 -0
- package/ietf/range.d.ts.map +1 -0
- package/ietf/range.js +222 -0
- package/ietf/range.js.map +1 -0
- package/ietf/request.d.ts +6 -30
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -79
- package/ietf/request.js.map +1 -1
- package/ietf/request_stream.d.ts +1 -6
- package/ietf/request_stream.d.ts.map +1 -1
- package/ietf/request_stream.js +306 -17
- package/ietf/request_stream.js.map +1 -1
- package/ietf/session.d.ts +41 -0
- package/ietf/session.d.ts.map +1 -0
- package/ietf/session.js +65 -0
- package/ietf/session.js.map +1 -0
- package/ietf/setup.d.ts +5 -30
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -118
- package/ietf/setup.js.map +1 -1
- package/ietf/setup_options.d.ts +31 -0
- package/ietf/setup_options.d.ts.map +1 -0
- package/ietf/setup_options.js +138 -0
- package/ietf/setup_options.js.map +1 -0
- package/ietf/solicit.js +4 -15
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +52 -45
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -240
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +16 -79
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -202
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -537
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -28
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +27 -24
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -62
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +13 -42
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +22 -49
- package/ietf/version.js.map +1 -1
- package/implementation.d.ts +2 -0
- package/implementation.d.ts.map +1 -0
- package/implementation.js +5 -0
- package/implementation.js.map +1 -0
- package/index.d.ts +34 -19
- package/index.d.ts.map +1 -1
- package/index.js +19 -7
- package/index.js.map +1 -1
- package/internal.d.ts +1515 -67
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -80
- package/internal.js.map +1 -1
- package/ledger.d.ts +23 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +247 -0
- package/ledger.js.map +1 -0
- package/listing.d.ts +132 -0
- package/listing.d.ts.map +1 -0
- package/listing.js +486 -0
- package/listing.js.map +1 -0
- package/lite/announce.d.ts +127 -66
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -159
- package/lite/announce.js.map +1 -1
- package/lite/announce_stream.d.ts +2 -0
- package/lite/announce_stream.d.ts.map +1 -0
- package/lite/announce_stream.js +92 -0
- package/lite/announce_stream.js.map +1 -0
- package/lite/answer.d.ts +22 -0
- package/lite/answer.d.ts.map +1 -0
- package/lite/answer.js +301 -0
- package/lite/answer.js.map +1 -0
- package/lite/auth.d.ts +45 -0
- package/lite/auth.d.ts.map +1 -0
- package/lite/auth.js +204 -0
- package/lite/auth.js.map +1 -0
- package/lite/compat.d.ts +31 -0
- package/lite/compat.d.ts.map +1 -0
- package/lite/compat.js +86 -0
- package/lite/compat.js.map +1 -0
- package/lite/connection.d.ts +1 -45
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +360 -78
- package/lite/connection.js.map +1 -1
- package/lite/datagram-end.d.ts +26 -0
- package/lite/datagram-end.d.ts.map +1 -0
- package/lite/datagram-end.js +30 -0
- package/lite/datagram-end.js.map +1 -0
- package/lite/datagram.d.ts +73 -8
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +144 -10
- package/lite/datagram.js.map +1 -1
- package/lite/duration.d.ts +6 -0
- package/lite/duration.d.ts.map +1 -0
- package/lite/duration.js +14 -0
- package/lite/duration.js.map +1 -0
- package/lite/error.d.ts +9 -0
- package/lite/error.d.ts.map +1 -0
- package/lite/error.js +24 -0
- package/lite/error.js.map +1 -0
- package/lite/fills.d.ts +162 -0
- package/lite/fills.d.ts.map +1 -0
- package/lite/fills.js +486 -0
- package/lite/fills.js.map +1 -0
- package/lite/fit.d.ts +49 -0
- package/lite/fit.d.ts.map +1 -0
- package/lite/fit.js +305 -0
- package/lite/fit.js.map +1 -0
- package/lite/goaway.d.ts +2 -2
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -14
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +67 -16
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -31
- package/lite/group.js.map +1 -1
- package/lite/identity.d.ts +25 -0
- package/lite/identity.d.ts.map +1 -0
- package/lite/identity.js +79 -0
- package/lite/identity.js.map +1 -0
- package/lite/index.d.ts +14 -13
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -2
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +10 -2
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -45
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +9 -2
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +11 -106
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts +2 -2
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -1
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +10 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +2548 -438
- package/lite/publisher.js.map +1 -1
- package/lite/routed.d.ts +59 -0
- package/lite/routed.d.ts.map +1 -0
- package/lite/routed.js +564 -0
- package/lite/routed.js.map +1 -0
- package/lite/session.d.ts +2 -28
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -100
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +32 -5
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -22
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +5 -11
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +5 -2
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +478 -78
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -143
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +7 -44
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +3290 -516
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +27 -12
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -38
- package/lite/track.js.map +1 -1
- package/lite/tracks.d.ts +55 -0
- package/lite/tracks.d.ts.map +1 -0
- package/lite/tracks.js +114 -0
- package/lite/tracks.js.map +1 -0
- package/lite/version.d.ts +132 -24
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +378 -34
- package/lite/version.js.map +1 -1
- package/meta.d.ts +77 -0
- package/meta.d.ts.map +1 -0
- package/meta.js +130 -0
- package/meta.js.map +1 -0
- package/meta_api.d.ts +7 -0
- package/meta_api.d.ts.map +1 -0
- package/meta_api.js +7 -0
- package/meta_api.js.map +1 -0
- package/mint.d.ts +28 -0
- package/mint.d.ts.map +1 -0
- package/mint.js +66 -0
- package/mint.js.map +1 -0
- package/open.d.ts +63 -0
- package/open.d.ts.map +1 -0
- package/open.js +250 -0
- package/open.js.map +1 -0
- package/origin.d.ts +394 -142
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -687
- package/origin.js.map +1 -1
- package/package.json +8 -13
- package/path.d.ts +51 -51
- package/path.d.ts.map +1 -1
- package/path.js +210 -58
- package/path.js.map +1 -1
- package/payload.d.ts +33 -0
- package/payload.d.ts.map +1 -0
- package/payload.js +65 -0
- package/payload.js.map +1 -0
- package/prefix.d.ts +152 -0
- package/prefix.d.ts.map +1 -0
- package/prefix.js +349 -0
- package/prefix.js.map +1 -0
- package/priority.d.ts +8 -0
- package/priority.d.ts.map +1 -0
- package/priority.js +185 -0
- package/priority.js.map +1 -0
- package/queue.d.ts +2 -0
- package/queue.d.ts.map +1 -0
- package/queue.js +46 -0
- package/queue.js.map +1 -0
- package/ranges.d.ts +36 -0
- package/ranges.d.ts.map +1 -0
- package/ranges.js +312 -0
- package/ranges.js.map +1 -0
- package/rescale.d.ts +24 -0
- package/rescale.d.ts.map +1 -0
- package/rescale.js +39 -0
- package/rescale.js.map +1 -0
- package/resume.d.ts +55 -0
- package/resume.d.ts.map +1 -0
- package/resume.js +4173 -0
- package/resume.js.map +1 -0
- package/resume.test-util.d.ts +2 -0
- package/resume.test-util.d.ts.map +1 -0
- package/resume.test-util.js +25 -0
- package/resume.test-util.js.map +1 -0
- package/skips.d.ts +48 -0
- package/skips.d.ts.map +1 -0
- package/skips.js +182 -0
- package/skips.js.map +1 -0
- package/stream.d.ts +78 -40
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -93
- package/stream.js.map +1 -1
- package/subscription.test-util.d.ts +2 -0
- package/subscription.test-util.d.ts.map +1 -0
- package/subscription.test-util.js +49 -0
- package/subscription.test-util.js.map +1 -0
- package/tail.d.ts +23 -14
- package/tail.d.ts.map +1 -1
- package/tail.js +224 -98
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -92
- package/time.js.map +1 -1
- package/timed.d.ts +21 -0
- package/timed.d.ts.map +1 -0
- package/timed.js +2 -0
- package/timed.js.map +1 -0
- package/track.d.ts +578 -246
- package/track.d.ts.map +1 -1
- package/track.js +7306 -772
- package/track.js.map +1 -1
- package/track_api.d.ts +7 -0
- package/track_api.d.ts.map +1 -0
- package/track_api.js +7 -0
- package/track_api.js.map +1 -0
- package/util/abort.d.ts +1 -0
- package/util/abort.d.ts.map +1 -1
- package/util/abort.js +23 -2
- package/util/abort.js.map +1 -1
- package/util/announce.d.ts +4 -0
- package/util/announce.d.ts.map +1 -0
- package/util/announce.js +11 -0
- package/util/announce.js.map +1 -0
- package/util/bigint.d.ts +3 -0
- package/util/bigint.d.ts.map +1 -0
- package/util/bigint.js +8 -0
- package/util/bigint.js.map +1 -0
- package/util/change.d.ts +12 -0
- package/util/change.d.ts.map +1 -0
- package/util/change.js +18 -0
- package/util/change.js.map +1 -0
- package/util/deadline.d.ts +2 -0
- package/util/deadline.d.ts.map +1 -0
- package/util/deadline.js +108 -0
- package/util/deadline.js.map +1 -0
- package/util/decode_error.d.ts +3 -0
- package/util/decode_error.d.ts.map +1 -0
- package/util/decode_error.js +11 -0
- package/util/decode_error.js.map +1 -0
- package/util/demand.d.ts +8 -0
- package/util/demand.d.ts.map +1 -0
- package/util/demand.js +24 -0
- package/util/demand.js.map +1 -0
- package/util/given_up.d.ts +2 -0
- package/util/given_up.d.ts.map +1 -0
- package/util/given_up.js +101 -0
- package/util/given_up.js.map +1 -0
- package/util/hex.d.ts +6 -0
- package/util/hex.d.ts.map +1 -1
- package/util/hex.js +19 -5
- package/util/hex.js.map +1 -1
- package/util/key.d.ts +15 -0
- package/util/key.d.ts.map +1 -0
- package/util/key.js +38 -0
- package/util/key.js.map +1 -0
- package/util/limits.d.ts +2 -0
- package/util/limits.d.ts.map +1 -0
- package/util/limits.js +76 -0
- package/util/limits.js.map +1 -0
- package/util/observed.d.ts +23 -0
- package/util/observed.d.ts.map +1 -0
- package/util/observed.js +122 -0
- package/util/observed.js.map +1 -0
- package/util/sorted.d.ts +2 -0
- package/util/sorted.d.ts.map +1 -0
- package/util/sorted.js +149 -0
- package/util/sorted.js.map +1 -0
- package/util/timeout.d.ts +2 -1
- package/util/timeout.d.ts.map +1 -1
- package/util/timeout.js +13 -10
- package/util/timeout.js.map +1 -1
- package/util/timer.d.ts +2 -0
- package/util/timer.d.ts.map +1 -0
- package/util/timer.js +19 -0
- package/util/timer.js.map +1 -0
- package/util/u64.js +0 -1
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -2
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -2
- package/util/varint.js.map +1 -1
- package/util/watch.d.ts +8 -0
- package/util/watch.d.ts.map +1 -0
- package/util/watch.js +38 -0
- package/util/watch.js.map +1 -0
- package/util/yield.d.ts +2 -0
- package/util/yield.d.ts.map +1 -0
- package/util/yield.js +31 -0
- package/util/yield.js.map +1 -0
- package/varint.d.ts +0 -29
- package/varint.d.ts.map +1 -1
- package/varint.js +7 -29
- package/varint.js.map +1 -1
- package/varint_api.d.ts +7 -0
- package/varint_api.d.ts.map +1 -0
- package/varint_api.js +7 -0
- package/varint_api.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/window.d.ts +570 -0
- package/window.d.ts.map +1 -0
- package/window.js +1677 -0
- package/window.js.map +1 -0
- package/wire.d.ts +150 -35
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -1
- package/wire.js.map +1 -1
- package/connection/established.d.ts +0 -53
- package/connection/established.d.ts.map +0 -1
- package/connection/established.js +0 -3
- package/connection/established.js.map +0 -1
- package/ietf/adapter.d.ts +0 -75
- package/ietf/adapter.d.ts.map +0 -1
- package/ietf/adapter.js +0 -700
- package/ietf/adapter.js.map +0 -1
- package/lite/datagram_stream.d.ts +0 -8
- package/lite/datagram_stream.d.ts.map +0 -1
- package/lite/datagram_stream.js +0 -44
- package/lite/datagram_stream.js.map +0 -1
- package/lite/fetch.d.ts +0 -28
- package/lite/fetch.d.ts.map +0 -1
- package/lite/fetch.js +0 -79
- package/lite/fetch.js.map +0 -1
- package/util/log.d.ts +0 -5
- package/util/log.d.ts.map +0 -1
- package/util/log.js +0 -17
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -19
- package/zod.js.map +0 -1
package/lite/announce.js
CHANGED
|
@@ -1,19 +1,57 @@
|
|
|
1
|
-
/* @ts-self-types="./announce.d.ts" */
|
|
2
1
|
import { ProtocolViolation } from "../error.js";
|
|
3
|
-
import {
|
|
2
|
+
import { MAX_HOPS, toHop, UNKNOWN_HOP, wireHop } from "../hop.js";
|
|
4
3
|
import * as Path from "../path.js";
|
|
4
|
+
import { encodeVarint } from "../stream.js";
|
|
5
|
+
import { SEGMENT_BYTES } from "../util/limits.js";
|
|
6
|
+
import { decodeRoute, encodeRoute } from "./identity.js";
|
|
5
7
|
import * as Message from "./message.js";
|
|
6
|
-
import {
|
|
8
|
+
import { MAX_MESSAGE_SIZE } from "./message.js";
|
|
9
|
+
import { fromWire, toWire } from "./priority.js";
|
|
10
|
+
import { hasAnnounceCompression, hasAnnounceId, hasAnnounceOk, hasExcludeHop, hasRouteCost, hasRoutes, hasSynced, Version, } from "./version.js";
|
|
7
11
|
// Pre-lite-06 inner status values, carried inside the single ANNOUNCE_BROADCAST body.
|
|
8
12
|
const STATUS_ENDED = 0;
|
|
9
13
|
const STATUS_ACTIVE = 1;
|
|
10
|
-
|
|
14
|
+
// The lite-05 draft's explicit `restart` status: a metadata update.
|
|
15
|
+
const STATUS_UPDATE = 2;
|
|
11
16
|
// lite-06 announce message types: an outer discriminator carried before the length
|
|
12
17
|
// prefix, so each announcement is an independently-typed, length-delimited message
|
|
13
18
|
// (mirroring SUBSCRIBE_START/END/DROP on the subscribe stream).
|
|
14
19
|
const ANNOUNCE_START = 0;
|
|
15
20
|
const ANNOUNCE_END = 1;
|
|
16
|
-
const
|
|
21
|
+
const ANNOUNCE_UPDATE = 2;
|
|
22
|
+
// lite-07: what only two nodes that both declared a Node ID exchange. An endpoint declares none,
|
|
23
|
+
// so receiving one is a protocol violation.
|
|
24
|
+
const ANNOUNCE_FLOOR = 3;
|
|
25
|
+
const SYNCED = 4;
|
|
26
|
+
// lite-07: an edit of the prefixes the sender wants, and the marker answering one.
|
|
27
|
+
const ANNOUNCE_REQUEST = 5;
|
|
28
|
+
const ANNOUNCE_OK = 6;
|
|
29
|
+
const ROUTE = 7;
|
|
30
|
+
const ROUTE_END = 8;
|
|
31
|
+
const DEAD = 9;
|
|
32
|
+
const DRAIN = 10;
|
|
33
|
+
/** The most nodes a lite-07 claim's chain may name: one that would reach 32 is never taken. */
|
|
34
|
+
export const CHAIN_MAX = 31;
|
|
35
|
+
// Claim flags.
|
|
36
|
+
const UNAVAILABLE = 0x1;
|
|
37
|
+
const DRAINING = 0x2;
|
|
38
|
+
const MARKED = 0x4;
|
|
39
|
+
/** A claim this origin publishes itself: no cost, at the top priority, announced again by no one. */
|
|
40
|
+
export function ownClaim(epoch, above = 0n) {
|
|
41
|
+
return { epoch, cost: 0n, above, unavailable: false, draining: false, marked: false, priority: 127, chain: [] };
|
|
42
|
+
}
|
|
43
|
+
/** Whether two claims say the same. */
|
|
44
|
+
export function claimsEqual(a, b) {
|
|
45
|
+
return (a.epoch === b.epoch &&
|
|
46
|
+
a.cost === b.cost &&
|
|
47
|
+
a.above === b.above &&
|
|
48
|
+
a.unavailable === b.unavailable &&
|
|
49
|
+
a.draining === b.draining &&
|
|
50
|
+
a.marked === b.marked &&
|
|
51
|
+
a.priority === b.priority &&
|
|
52
|
+
a.chain.length === b.chain.length &&
|
|
53
|
+
a.chain.every((node, i) => node === b.chain[i]));
|
|
54
|
+
}
|
|
17
55
|
// Both wire rules on a hop chain, applied to what we send and to what we receive: a
|
|
18
56
|
// chain that revisits a hop looped, so neither forwarding it nor subscribing through it
|
|
19
57
|
// is safe, and a receiver must end the session over one. `UNKNOWN_HOP` identifies
|
|
@@ -35,7 +73,7 @@ function checkHops(hops) {
|
|
|
35
73
|
}
|
|
36
74
|
}
|
|
37
75
|
}
|
|
38
|
-
async function encodeHops(w, version, hops) {
|
|
76
|
+
async function encodeHops(w, version, hops = []) {
|
|
39
77
|
checkHops(hops);
|
|
40
78
|
switch (version) {
|
|
41
79
|
case Version.DRAFT_01:
|
|
@@ -48,7 +86,7 @@ async function encodeHops(w, version, hops) {
|
|
|
48
86
|
// Lite04+: hop count + individual Hop varints.
|
|
49
87
|
await w.u53(hops.length);
|
|
50
88
|
for (const origin of hops) {
|
|
51
|
-
await w.u62(origin);
|
|
89
|
+
await w.u62(wireHop(origin, version));
|
|
52
90
|
}
|
|
53
91
|
break;
|
|
54
92
|
}
|
|
@@ -73,91 +111,227 @@ async function decodeHops(r, version) {
|
|
|
73
111
|
throw new Error(`hop count ${count} exceeds maximum ${MAX_HOPS}`);
|
|
74
112
|
const hops = [];
|
|
75
113
|
for (let i = 0; i < count; i++) {
|
|
76
|
-
hops.push(
|
|
114
|
+
hops.push(toHop(await r.u62()));
|
|
77
115
|
}
|
|
78
116
|
checkHops(hops);
|
|
79
117
|
return hops;
|
|
80
118
|
}
|
|
81
119
|
}
|
|
82
120
|
}
|
|
83
|
-
// Lite-07 carries a base around a path and a hop list. A distance of 0 names
|
|
84
|
-
// nothing, and a keep without a base is a violation. Other versions have no room for
|
|
85
|
-
// a base at all.
|
|
86
|
-
function checkBase(version, base) {
|
|
87
|
-
if (base && !hasAnnounceCompression(version)) {
|
|
88
|
-
throw new Error("announce compression not supported for this version");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function toBase(distance, keep) {
|
|
92
|
-
if (distance !== 0n)
|
|
93
|
-
return { distance, keep };
|
|
94
|
-
if (keep !== 0)
|
|
95
|
-
throw new ProtocolViolation("announce keep without a base");
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
121
|
async function encodePath(w, version, suffix, base) {
|
|
99
|
-
checkBase(version, base);
|
|
100
122
|
if (hasAnnounceCompression(version)) {
|
|
101
123
|
await w.u62(base?.distance ?? 0n);
|
|
102
124
|
await w.u53(base?.keep ?? 0);
|
|
103
125
|
}
|
|
126
|
+
else if (base) {
|
|
127
|
+
throw new Error("announce compression not supported for this version");
|
|
128
|
+
}
|
|
104
129
|
await w.string(Path.encode(suffix));
|
|
105
130
|
}
|
|
106
131
|
async function decodePath(r, version) {
|
|
107
132
|
if (!hasAnnounceCompression(version))
|
|
108
133
|
return { suffix: Path.decode(await r.string()) };
|
|
109
|
-
const pathBase = toBase(await r.u62(), await r.u53());
|
|
110
|
-
const suffix = Path.decode(await r.string());
|
|
111
|
-
return pathBase ? { suffix, pathBase } : { suffix };
|
|
112
|
-
}
|
|
113
|
-
async function encodeHopsBlock(w, version, hops, base) {
|
|
114
|
-
checkBase(version, base);
|
|
115
|
-
if (!hasAnnounceCompression(version))
|
|
116
|
-
return encodeHops(w, version, hops);
|
|
117
|
-
await w.u62(base?.distance ?? 0n);
|
|
118
|
-
await encodeHops(w, version, hops);
|
|
119
|
-
await w.u53(base?.keep ?? 0);
|
|
120
|
-
}
|
|
121
|
-
async function decodeHopsBlock(r, version) {
|
|
122
|
-
if (!hasAnnounceCompression(version))
|
|
123
|
-
return { hops: await decodeHops(r, version) };
|
|
124
134
|
const distance = await r.u62();
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
135
|
+
const keep = await r.u53();
|
|
136
|
+
// A distance of 0 names nothing, so a keep without a base is a violation.
|
|
137
|
+
if (distance === 0n && keep !== 0)
|
|
138
|
+
throw new ProtocolViolation("announce keep without a base");
|
|
139
|
+
const suffix = Path.decode(await r.string());
|
|
140
|
+
return distance === 0n ? { suffix } : { suffix, pathBase: { distance, keep } };
|
|
128
141
|
}
|
|
129
|
-
//
|
|
130
|
-
// versions carry neither. Costs saturate at 2^62-1 on every version, even where lite-07's
|
|
142
|
+
// Lite07 carries one static cost. Lite06 retains its second field at the ceiling;
|
|
143
|
+
// older versions carry neither. Costs saturate at 2^62-1 on every version, even where lite-07's
|
|
131
144
|
// varints could carry more, so a cost always forwards to a peer on an older version.
|
|
132
145
|
const MAX_COST = 2n ** 62n - 1n;
|
|
133
146
|
const saturate = (v) => (v > MAX_COST ? MAX_COST : v);
|
|
134
147
|
async function encodeRouteCost(w, version, cost) {
|
|
135
148
|
if (!hasRouteCost(version))
|
|
136
149
|
return;
|
|
137
|
-
await w.u62(saturate(cost
|
|
138
|
-
|
|
150
|
+
await w.u62(saturate(cost ?? 0n));
|
|
151
|
+
if (version === Version.DRAFT_06)
|
|
152
|
+
await w.u62(MAX_COST);
|
|
139
153
|
}
|
|
140
154
|
async function decodeRouteCost(r, version) {
|
|
141
155
|
if (!hasRouteCost(version))
|
|
142
156
|
return undefined;
|
|
143
|
-
|
|
157
|
+
const cost = saturate(await r.u62());
|
|
158
|
+
if (version === Version.DRAFT_06)
|
|
159
|
+
await r.u62();
|
|
160
|
+
return cost;
|
|
161
|
+
}
|
|
162
|
+
/** Encode what a lite-07 claim says after its epoch: cost, above, flags, priority, and chain. */
|
|
163
|
+
async function encodeClaim(w, claim) {
|
|
164
|
+
if (claim.chain.length > CHAIN_MAX || claim.chain.some((node) => node === 0n))
|
|
165
|
+
throw new Error("no node sends that chain");
|
|
166
|
+
await w.u62(saturate(claim.cost));
|
|
167
|
+
await w.u62(claim.above);
|
|
168
|
+
await w.u8((claim.unavailable ? UNAVAILABLE : 0) | (claim.draining ? DRAINING : 0) | (claim.marked ? MARKED : 0));
|
|
169
|
+
await w.u8(toWire(claim.priority));
|
|
170
|
+
await w.u53(claim.chain.length);
|
|
171
|
+
for (const node of claim.chain)
|
|
172
|
+
await w.u62(node);
|
|
173
|
+
}
|
|
174
|
+
/** Decode a lite-07 claim of `epoch`. A chain past the limit or naming Node ID 0, and a flag this
|
|
175
|
+
* version does not define, fail the stream: no sender builds one. Mirrors rs/moq-net. */
|
|
176
|
+
async function decodeClaim(r, epoch) {
|
|
177
|
+
// Costs saturate at 2^62-1 on every version, so a larger one reads as the ceiling.
|
|
178
|
+
const cost = saturate(await r.u62());
|
|
179
|
+
const above = await r.u62();
|
|
180
|
+
const flags = await r.u8();
|
|
181
|
+
if (flags & ~(UNAVAILABLE | DRAINING | MARKED))
|
|
182
|
+
throw new ProtocolViolation(`unknown claim flags ${flags}`);
|
|
183
|
+
const priority = fromWire(await r.u8());
|
|
184
|
+
const count = await r.u62();
|
|
185
|
+
if (count > BigInt(CHAIN_MAX))
|
|
186
|
+
throw new ProtocolViolation(`claim chain of ${count} nodes`);
|
|
187
|
+
const chain = [];
|
|
188
|
+
for (let i = 0n; i < count; i++) {
|
|
189
|
+
const node = await r.u62();
|
|
190
|
+
if (node === 0n)
|
|
191
|
+
throw new ProtocolViolation("Node ID 0 names no node");
|
|
192
|
+
chain.push(node);
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
epoch,
|
|
196
|
+
cost,
|
|
197
|
+
above,
|
|
198
|
+
unavailable: (flags & UNAVAILABLE) !== 0,
|
|
199
|
+
draining: (flags & DRAINING) !== 0,
|
|
200
|
+
marked: (flags & MARKED) !== 0,
|
|
201
|
+
priority,
|
|
202
|
+
chain,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** Encode an ANNOUNCE_REQUEST body: `More`, the Prefix IDs to remove, then the prefixes to add,
|
|
206
|
+
* each with its `Hidden`. */
|
|
207
|
+
async function encodeRequest(w, more, remove, add) {
|
|
208
|
+
await w.bool(more);
|
|
209
|
+
await w.u53(remove.length);
|
|
210
|
+
for (const id of remove)
|
|
211
|
+
await w.u62(id);
|
|
212
|
+
await w.u53(add.length);
|
|
213
|
+
for (const { prefix, hidden } of add) {
|
|
214
|
+
await w.string(Path.encode(prefix));
|
|
215
|
+
await w.bool(hidden);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Decode an ANNOUNCE_REQUEST body. The prefixes are the sender's own, so one that is no path
|
|
219
|
+
* fails the message rather than being refused. Each entry takes bytes, so the body bounds both
|
|
220
|
+
* counts before either loop runs out. */
|
|
221
|
+
async function decodeRequest(r) {
|
|
222
|
+
const more = await r.bool();
|
|
223
|
+
const remove = [];
|
|
224
|
+
for (let left = await r.u62(); left > 0n; left--)
|
|
225
|
+
remove.push(await r.u62());
|
|
226
|
+
const add = [];
|
|
227
|
+
for (let left = await r.u62(); left > 0n; left--) {
|
|
228
|
+
add.push({ prefix: Path.decode(await r.string()), hidden: await r.bool() });
|
|
229
|
+
}
|
|
230
|
+
return { status: "request", more, remove, add };
|
|
231
|
+
}
|
|
232
|
+
/** The bytes one Add of `prefix` takes: its length, its bytes, and its flag. */
|
|
233
|
+
function addSize(prefix, version) {
|
|
234
|
+
const length = new TextEncoder().encode(Path.encode(prefix)).byteLength;
|
|
235
|
+
return encodeVarint(length, version).byteLength + length + 1;
|
|
236
|
+
}
|
|
237
|
+
/** The bytes an ANNOUNCE_REQUEST body takes with `removes` Prefix IDs totalling `ids` bytes and
|
|
238
|
+
* `adds` Adds totalling `added` bytes. */
|
|
239
|
+
function requestSize(removes, ids, adds, added, version) {
|
|
240
|
+
return 1 + encodeVarint(removes, version).byteLength + encodeVarint(adds, version).byteLength + ids + added;
|
|
241
|
+
}
|
|
242
|
+
/** Whether the prefixes `set` fit the Adds of one ANNOUNCE_REQUEST, as a subscriber's whole set
|
|
243
|
+
* must. */
|
|
244
|
+
export function requestFits(set, version) {
|
|
245
|
+
let adds = 0;
|
|
246
|
+
let added = 0;
|
|
247
|
+
for (const prefix of set) {
|
|
248
|
+
adds++;
|
|
249
|
+
added += addSize(prefix, version);
|
|
250
|
+
}
|
|
251
|
+
return requestSize(0, 0, adds, added, version) <= MAX_MESSAGE_SIZE;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The ANNOUNCE_REQUESTs of one edit removing the Prefix IDs `remove` and adding `add`: as many as
|
|
255
|
+
* it takes for each to fit one message, every one but the last with `more`. The receiver applies
|
|
256
|
+
* them together at the last, so how they split changes nothing. Mirrors `request_parts` in
|
|
257
|
+
* rs/moq-net.
|
|
258
|
+
*
|
|
259
|
+
* @internal
|
|
260
|
+
*/
|
|
261
|
+
export function requestParts(remove, add, version) {
|
|
262
|
+
const parts = [];
|
|
263
|
+
let part = { remove: [], add: [] };
|
|
264
|
+
let ids = 0;
|
|
265
|
+
let added = 0;
|
|
266
|
+
const fits = (id, adding) => requestSize(part.remove.length + (id > 0 ? 1 : 0), ids + id, part.add.length + (adding > 0 ? 1 : 0), added + adding, version) <= MAX_MESSAGE_SIZE;
|
|
267
|
+
const next = () => {
|
|
268
|
+
parts.push(part);
|
|
269
|
+
part = { remove: [], add: [] };
|
|
270
|
+
ids = 0;
|
|
271
|
+
added = 0;
|
|
272
|
+
};
|
|
273
|
+
for (const id of remove) {
|
|
274
|
+
const bytes = encodeVarint(id, version).byteLength;
|
|
275
|
+
if (!fits(bytes, 0))
|
|
276
|
+
next();
|
|
277
|
+
part.remove.push(id);
|
|
278
|
+
ids += bytes;
|
|
279
|
+
}
|
|
280
|
+
for (const one of add) {
|
|
281
|
+
const bytes = addSize(one.prefix, version);
|
|
282
|
+
if (!fits(0, bytes))
|
|
283
|
+
next();
|
|
284
|
+
part.add.push(one);
|
|
285
|
+
added += bytes;
|
|
286
|
+
}
|
|
287
|
+
parts.push(part);
|
|
288
|
+
return parts.map((part, i) => ({ status: "request", more: i + 1 < parts.length, ...part }));
|
|
144
289
|
}
|
|
145
290
|
// lite-06 message body (no discriminator; the type is carried outside the length prefix).
|
|
146
291
|
async function encodeAnnounce06Body(w, msg, version) {
|
|
147
292
|
switch (msg.status) {
|
|
148
293
|
case "active":
|
|
149
|
-
|
|
150
|
-
|
|
294
|
+
if (hasRoutes(version))
|
|
295
|
+
throw new Error("a lite-07 claim names its identity");
|
|
296
|
+
await encodePath(w, version, msg.suffix, undefined);
|
|
297
|
+
await encodeRoute(w, version, undefined, undefined);
|
|
298
|
+
await encodeHops(w, version, msg.hops);
|
|
151
299
|
await encodeRouteCost(w, version, msg.cost);
|
|
152
300
|
break;
|
|
153
301
|
case "endedId":
|
|
154
302
|
await w.u62(msg.id);
|
|
303
|
+
if (hasRoutes(version))
|
|
304
|
+
await w.bool(msg.lost ?? false);
|
|
155
305
|
break;
|
|
156
|
-
case "
|
|
306
|
+
case "update":
|
|
307
|
+
if (hasRoutes(version))
|
|
308
|
+
throw new Error("a lite-07 update carries its claim");
|
|
157
309
|
await w.u62(msg.id);
|
|
158
|
-
await
|
|
310
|
+
await encodeHops(w, version, msg.hops);
|
|
159
311
|
await encodeRouteCost(w, version, msg.cost);
|
|
160
312
|
break;
|
|
313
|
+
case "start":
|
|
314
|
+
if (!hasRoutes(version))
|
|
315
|
+
throw new Error("claims not supported for this version");
|
|
316
|
+
await encodePath(w, version, msg.suffix, msg.pathBase);
|
|
317
|
+
await encodeRoute(w, version, msg.identity, msg.claim.epoch);
|
|
318
|
+
await encodeClaim(w, msg.claim);
|
|
319
|
+
break;
|
|
320
|
+
case "change":
|
|
321
|
+
if (!hasRoutes(version))
|
|
322
|
+
throw new Error("claims not supported for this version");
|
|
323
|
+
await w.u62(msg.id);
|
|
324
|
+
await w.u62(msg.claim.epoch);
|
|
325
|
+
await encodeClaim(w, msg.claim);
|
|
326
|
+
break;
|
|
327
|
+
case "synced":
|
|
328
|
+
await w.u62(msg.prefix);
|
|
329
|
+
break;
|
|
330
|
+
case "request":
|
|
331
|
+
await encodeRequest(w, msg.more, msg.remove, msg.add);
|
|
332
|
+
break;
|
|
333
|
+
case "ok":
|
|
334
|
+
break;
|
|
161
335
|
case "ended":
|
|
162
336
|
// The pre-lite-06 path-form retraction has no place on lite-06.
|
|
163
337
|
throw new Error("ended-by-path not supported for this version");
|
|
@@ -166,14 +340,28 @@ async function encodeAnnounce06Body(w, msg, version) {
|
|
|
166
340
|
}
|
|
167
341
|
}
|
|
168
342
|
// lite-06 outer message type for a given announcement.
|
|
169
|
-
function announce06Type(msg) {
|
|
343
|
+
function announce06Type(msg, version) {
|
|
170
344
|
switch (msg.status) {
|
|
171
345
|
case "active":
|
|
346
|
+
case "start":
|
|
172
347
|
return ANNOUNCE_START;
|
|
173
348
|
case "endedId":
|
|
174
349
|
return ANNOUNCE_END;
|
|
175
|
-
case "
|
|
176
|
-
|
|
350
|
+
case "update":
|
|
351
|
+
case "change":
|
|
352
|
+
return ANNOUNCE_UPDATE;
|
|
353
|
+
case "synced":
|
|
354
|
+
if (!hasSynced(version))
|
|
355
|
+
throw new Error("synced not supported for this version");
|
|
356
|
+
return SYNCED;
|
|
357
|
+
case "request":
|
|
358
|
+
if (!hasRoutes(version))
|
|
359
|
+
throw new Error("announce edits not supported for this version");
|
|
360
|
+
return ANNOUNCE_REQUEST;
|
|
361
|
+
case "ok":
|
|
362
|
+
if (!hasRoutes(version))
|
|
363
|
+
throw new Error("announce edits not supported for this version");
|
|
364
|
+
return ANNOUNCE_OK;
|
|
177
365
|
case "ended":
|
|
178
366
|
throw new Error("ended-by-path not supported for this version");
|
|
179
367
|
case "skipped":
|
|
@@ -184,28 +372,62 @@ async function decodeAnnounce06Body(r, typ, version) {
|
|
|
184
372
|
switch (typ) {
|
|
185
373
|
case ANNOUNCE_START: {
|
|
186
374
|
const path = await decodePath(r, version);
|
|
187
|
-
const
|
|
188
|
-
|
|
375
|
+
const served = await decodeRoute(r, version);
|
|
376
|
+
if (hasRoutes(version)) {
|
|
377
|
+
// Every lite-07 claim names its identity.
|
|
378
|
+
if (served.identity === undefined)
|
|
379
|
+
throw new ProtocolViolation("a claim without an identity");
|
|
380
|
+
const claim = await decodeClaim(r, served.epoch ?? 0n);
|
|
381
|
+
return { status: "start", ...path, identity: served.identity, claim };
|
|
382
|
+
}
|
|
383
|
+
const hops = await decodeHops(r, version);
|
|
384
|
+
return { status: "active", suffix: path.suffix, hops, cost: await decodeRouteCost(r, version) };
|
|
189
385
|
}
|
|
190
|
-
case ANNOUNCE_END:
|
|
191
|
-
return { status: "endedId", id: await r.u62() };
|
|
192
|
-
case ANNOUNCE_RESTART: {
|
|
386
|
+
case ANNOUNCE_END: {
|
|
193
387
|
const id = await r.u62();
|
|
194
|
-
|
|
195
|
-
return { status: "restart", id, ...hops, cost: await decodeRouteCost(r, version) };
|
|
388
|
+
return hasRoutes(version) ? { status: "endedId", id, lost: await r.bool() } : { status: "endedId", id };
|
|
196
389
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
390
|
+
case ANNOUNCE_UPDATE: {
|
|
391
|
+
const id = await r.u62();
|
|
392
|
+
if (hasRoutes(version))
|
|
393
|
+
return { status: "change", id, claim: await decodeClaim(r, await r.u62()) };
|
|
394
|
+
const hops = await decodeHops(r, version);
|
|
395
|
+
return { status: "update", id, hops, cost: await decodeRouteCost(r, version) };
|
|
396
|
+
}
|
|
397
|
+
case SYNCED:
|
|
398
|
+
if (!hasSynced(version))
|
|
399
|
+
break;
|
|
400
|
+
return { status: "synced", prefix: await r.u62() };
|
|
401
|
+
case ANNOUNCE_REQUEST:
|
|
402
|
+
if (!hasRoutes(version))
|
|
403
|
+
break;
|
|
404
|
+
return decodeRequest(r);
|
|
405
|
+
case ANNOUNCE_OK:
|
|
406
|
+
if (!hasRoutes(version))
|
|
407
|
+
break;
|
|
408
|
+
return { status: "ok" };
|
|
409
|
+
case ANNOUNCE_FLOOR:
|
|
410
|
+
case ROUTE:
|
|
411
|
+
case ROUTE_END:
|
|
412
|
+
case DEAD:
|
|
413
|
+
case DRAIN:
|
|
414
|
+
if (!hasRoutes(version))
|
|
415
|
+
break;
|
|
416
|
+
// Only two nodes that both declared a Node ID exchange routes, and this one declares none.
|
|
417
|
+
throw new ProtocolViolation(`route message ${typ} to a node that declared no Node ID`);
|
|
418
|
+
}
|
|
419
|
+
// lite-07 defines every type its streams carry, so an unknown one is a violation.
|
|
420
|
+
if (hasRoutes(version))
|
|
421
|
+
throw new ProtocolViolation(`unknown announce message type ${typ}`);
|
|
422
|
+
// Lite06 skips the length-prefixed body so a build that predates a type negotiating
|
|
423
|
+
// the same ALPN does not kill the announce stream.
|
|
424
|
+
await r.readAll();
|
|
425
|
+
return { status: "skipped" };
|
|
203
426
|
}
|
|
204
427
|
// Pre-lite-06 single ANNOUNCE_BROADCAST body: an inner status byte, then path + hops.
|
|
205
428
|
async function encodeLegacyBody(w, msg, version) {
|
|
206
429
|
switch (msg.status) {
|
|
207
430
|
case "active":
|
|
208
|
-
checkBase(version, msg.pathBase ?? msg.hopBase);
|
|
209
431
|
await w.u8(STATUS_ACTIVE);
|
|
210
432
|
await w.string(Path.encode(msg.suffix));
|
|
211
433
|
await encodeHops(w, version, msg.hops);
|
|
@@ -215,18 +437,16 @@ async function encodeLegacyBody(w, msg, version) {
|
|
|
215
437
|
await w.string(Path.encode(msg.suffix));
|
|
216
438
|
await encodeHops(w, version, []);
|
|
217
439
|
break;
|
|
218
|
-
|
|
219
|
-
case "restart":
|
|
220
|
-
case "skipped":
|
|
440
|
+
default:
|
|
221
441
|
// The id-referencing forms only exist on lite-06+.
|
|
222
442
|
throw new Error("announce ids not supported for this version");
|
|
223
443
|
}
|
|
224
444
|
}
|
|
225
445
|
async function decodeLegacyBody(r, version) {
|
|
226
446
|
const status = await r.u8();
|
|
227
|
-
// On lite-05
|
|
228
|
-
//
|
|
229
|
-
const active = status === STATUS_ACTIVE || (status ===
|
|
447
|
+
// On lite-05 an update travels as a duplicate `active`, but the explicit update status
|
|
448
|
+
// is accepted on decode and treated the same. Older versions never defined it.
|
|
449
|
+
const active = status === STATUS_ACTIVE || (status === STATUS_UPDATE && hasAnnounceOk(version));
|
|
230
450
|
if (status !== STATUS_ENDED && !active) {
|
|
231
451
|
throw new Error("invalid announce status");
|
|
232
452
|
}
|
|
@@ -238,8 +458,7 @@ async function decodeLegacyBody(r, version) {
|
|
|
238
458
|
export async function encodeAnnounceBroadcast(w, msg, version) {
|
|
239
459
|
if (hasAnnounceId(version)) {
|
|
240
460
|
// lite-06+: outer type discriminator, then a size-prefixed body (like the subscribe stream).
|
|
241
|
-
|
|
242
|
-
return Message.encode(w, (w) => encodeAnnounce06Body(w, msg, version));
|
|
461
|
+
return Message.encode(w, (w) => encodeAnnounce06Body(w, msg, version), { id: announce06Type(msg, version) });
|
|
243
462
|
}
|
|
244
463
|
return Message.encode(w, (w) => encodeLegacyBody(w, msg, version));
|
|
245
464
|
}
|
|
@@ -262,105 +481,104 @@ export async function decodeAnnounceBroadcastMaybe(r, version) {
|
|
|
262
481
|
return Message.decodeMaybe(r, (r) => decodeLegacyBody(r, version));
|
|
263
482
|
}
|
|
264
483
|
/**
|
|
265
|
-
* The live announcements on one lite-06+ announce stream, by Announce ID: what
|
|
266
|
-
*
|
|
267
|
-
*
|
|
484
|
+
* The live announcements on one lite-06+ announce stream, by Announce ID: what ANNOUNCE_END
|
|
485
|
+
* and ANNOUNCE_UPDATE reference, and what a lite-07 base copies from. Every
|
|
486
|
+
* violation throws {@link ProtocolViolation}.
|
|
268
487
|
*/
|
|
269
488
|
export class AnnounceHistory {
|
|
270
489
|
#next = 0n;
|
|
271
490
|
#live = new Map();
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return hops;
|
|
281
|
-
const tail = this.#base(base).hops;
|
|
282
|
-
if (base.keep > tail.length)
|
|
283
|
-
throw new ProtocolViolation(`announce keeps ${base.keep} of ${tail.length} hops`);
|
|
284
|
-
const resolved = [...hops, ...tail.slice(tail.length - base.keep)];
|
|
285
|
-
checkHops(resolved);
|
|
286
|
-
return resolved;
|
|
287
|
-
}
|
|
288
|
-
/** An ANNOUNCE_START: resolve it and assign it the next id. */
|
|
491
|
+
// The live ids whose path was refused, which a base names only to be refused too.
|
|
492
|
+
#refused = new Set();
|
|
493
|
+
/** The Announce ID the next ANNOUNCE_START is assigned. */
|
|
494
|
+
get next() {
|
|
495
|
+
return this.#next;
|
|
496
|
+
}
|
|
497
|
+
/** An ANNOUNCE_START: assign it the next id, and resolve its suffix, or undefined when that
|
|
498
|
+
* suffix, or the base it names, is no path this node can hold. */
|
|
289
499
|
start(msg) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.#
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
500
|
+
const suffix = msg && this.#resolve(msg);
|
|
501
|
+
const id = this.#next++;
|
|
502
|
+
if (suffix === undefined)
|
|
503
|
+
this.#refused.add(id);
|
|
504
|
+
else
|
|
505
|
+
this.#live.set(id, suffix);
|
|
506
|
+
return suffix;
|
|
507
|
+
}
|
|
508
|
+
#resolve(msg) {
|
|
509
|
+
const suffix = msg.suffix;
|
|
510
|
+
if (!msg.pathBase)
|
|
511
|
+
return suffix;
|
|
512
|
+
const id = this.#next - msg.pathBase.distance;
|
|
513
|
+
if (this.#refused.has(id))
|
|
514
|
+
return undefined;
|
|
515
|
+
const base = this.#live.get(id);
|
|
516
|
+
if (base === undefined)
|
|
517
|
+
throw new ProtocolViolation(`announce base ${msg.pathBase.distance} is not live`);
|
|
518
|
+
// A keep counts whole parts, so a kept head never ends inside an escape.
|
|
519
|
+
const head = Path.parts(base);
|
|
520
|
+
const keep = msg.pathBase.keep;
|
|
521
|
+
if (keep > head.length)
|
|
522
|
+
throw new ProtocolViolation(`announce keeps ${keep} of ${head.length} parts`);
|
|
523
|
+
// A path that does not resolve, such as one too deep, is refused as content, as rs/moq-net does.
|
|
524
|
+
const kept = head.slice(0, keep);
|
|
525
|
+
if (suffix !== Path.empty())
|
|
526
|
+
kept.push(suffix);
|
|
527
|
+
return Path.tryDecode(kept.join("/"));
|
|
528
|
+
}
|
|
529
|
+
/** The suffix of the live announcement `id`, which an update references. */
|
|
530
|
+
get(id) {
|
|
316
531
|
const live = this.#live.get(id);
|
|
317
|
-
if (
|
|
532
|
+
if (live === undefined)
|
|
318
533
|
throw new ProtocolViolation(`unknown announce id: ${id}`);
|
|
534
|
+
return live;
|
|
535
|
+
}
|
|
536
|
+
/** An ANNOUNCE_END: retire the id, returning its suffix, or undefined if it was refused. */
|
|
537
|
+
end(id) {
|
|
538
|
+
if (this.#refused.delete(id))
|
|
539
|
+
return undefined;
|
|
540
|
+
const live = this.get(id);
|
|
319
541
|
this.#live.delete(id);
|
|
320
|
-
return live
|
|
542
|
+
return live;
|
|
321
543
|
}
|
|
322
544
|
}
|
|
323
545
|
/**
|
|
324
|
-
* ANNOUNCE_REQUEST: sent by the subscriber to request ANNOUNCE_BROADCAST messages
|
|
325
|
-
* for a path prefix. Renamed from `AnnounceInterest` in
|
|
546
|
+
* ANNOUNCE_REQUEST before lite-07: sent by the subscriber to request ANNOUNCE_BROADCAST messages
|
|
547
|
+
* for a path prefix, opening a bidirectional Announce Stream. Renamed from `AnnounceInterest` in
|
|
548
|
+
* lite-05. Lite-07 edits a set of prefixes on its one stream instead (the `request` message).
|
|
326
549
|
*/
|
|
327
550
|
export class AnnounceRequest {
|
|
328
551
|
prefix;
|
|
329
|
-
/** Lite04/05 only: the
|
|
330
|
-
*
|
|
331
|
-
* exclusion". Not on the wire elsewhere, so a value set here is ignored when
|
|
332
|
-
* for another version and decodes as
|
|
333
|
-
*
|
|
334
|
-
* Must be a bigint: peer origins are up to 62 bits and overflow u53. */
|
|
552
|
+
/** Lite04/05 only: the Hop id of the peer asking for announces, which the publisher
|
|
553
|
+
* uses to skip announces that already passed through it. {@link UNKNOWN_HOP} means
|
|
554
|
+
* "no exclusion". Not on the wire elsewhere, so a value set here is ignored when
|
|
555
|
+
* encoding for another version and decodes as unknown. */
|
|
335
556
|
excludeHop;
|
|
336
|
-
|
|
337
|
-
* the wire earlier, so a value set here is ignored when encoding for an older version
|
|
338
|
-
* and decodes as false. */
|
|
339
|
-
hidden;
|
|
340
|
-
constructor(prefix, excludeHop = 0n, hidden = false) {
|
|
557
|
+
constructor(prefix, excludeHop = UNKNOWN_HOP) {
|
|
341
558
|
this.prefix = prefix;
|
|
342
559
|
this.excludeHop = excludeHop;
|
|
343
|
-
|
|
560
|
+
}
|
|
561
|
+
static #guard(version) {
|
|
562
|
+
if (hasRoutes(version))
|
|
563
|
+
throw new Error("announce request streams not supported for this version");
|
|
344
564
|
}
|
|
345
565
|
async #encode(w, version) {
|
|
346
566
|
await w.string(Path.encode(this.prefix));
|
|
347
567
|
if (hasExcludeHop(version)) {
|
|
348
|
-
await w.u62(this.excludeHop);
|
|
349
|
-
}
|
|
350
|
-
if (hasHidden(version)) {
|
|
351
|
-
await w.bool(this.hidden);
|
|
568
|
+
await w.u62(wireHop(this.excludeHop, version));
|
|
352
569
|
}
|
|
353
570
|
}
|
|
354
571
|
static async #decode(r, version) {
|
|
355
572
|
const prefix = Path.decode(await r.string());
|
|
356
|
-
const excludeHop = hasExcludeHop(version) ? await r.u62() :
|
|
357
|
-
|
|
358
|
-
return new AnnounceRequest(prefix, excludeHop, hidden);
|
|
573
|
+
const excludeHop = hasExcludeHop(version) ? toHop(await r.u62()) : UNKNOWN_HOP;
|
|
574
|
+
return new AnnounceRequest(prefix, excludeHop);
|
|
359
575
|
}
|
|
360
576
|
async encode(w, version) {
|
|
577
|
+
AnnounceRequest.#guard(version);
|
|
361
578
|
return Message.encode(w, (w) => this.#encode(w, version));
|
|
362
579
|
}
|
|
363
580
|
static async decode(r, version) {
|
|
581
|
+
AnnounceRequest.#guard(version);
|
|
364
582
|
return Message.decode(r, (r) => AnnounceRequest.#decode(r, version));
|
|
365
583
|
}
|
|
366
584
|
}
|
|
@@ -387,30 +605,38 @@ export class AnnounceInit {
|
|
|
387
605
|
await w.string(Path.encode(path));
|
|
388
606
|
}
|
|
389
607
|
}
|
|
390
|
-
static async #decode(r) {
|
|
608
|
+
static async #decode(r, budget) {
|
|
391
609
|
const count = await r.u53();
|
|
610
|
+
// Refused before decoding any, so the set grows no larger than what may be announced.
|
|
611
|
+
if (count > budget)
|
|
612
|
+
throw new Error(`announce init lists ${count} broadcasts with ${budget} slots left`);
|
|
392
613
|
const suffixes = [];
|
|
393
614
|
for (let i = 0; i < count; i++) {
|
|
394
615
|
suffixes.push(Path.decode(await r.string()));
|
|
395
616
|
}
|
|
396
617
|
return new AnnounceInit(suffixes);
|
|
397
618
|
}
|
|
619
|
+
// The whole initial set in one message, capped like Rust's so it fits one storage segment
|
|
620
|
+
// (1 MiB) with its type and size prefixes. A larger set is refused on both ends.
|
|
621
|
+
static MAX_SIZE = SEGMENT_BYTES - 16;
|
|
398
622
|
async encode(w, version) {
|
|
399
623
|
AnnounceInit.#guard(version);
|
|
400
|
-
return Message.encode(w, this.#encode.bind(this));
|
|
624
|
+
return Message.encode(w, this.#encode.bind(this), { max: AnnounceInit.MAX_SIZE });
|
|
401
625
|
}
|
|
402
|
-
|
|
626
|
+
/** Decode the initial set, refusing one that lists more than `budget` broadcasts. */
|
|
627
|
+
static async decode(r, version, budget) {
|
|
403
628
|
AnnounceInit.#guard(version);
|
|
404
|
-
return Message.decode(r, AnnounceInit.#decode);
|
|
629
|
+
return Message.decode(r, (r) => AnnounceInit.#decode(r, budget), AnnounceInit.MAX_SIZE);
|
|
405
630
|
}
|
|
406
631
|
}
|
|
407
632
|
/// Sent by the publisher as the first message on an announce stream, before any
|
|
408
|
-
/// individual Announce messages. Lite05
|
|
633
|
+
/// individual Announce messages. Lite05/06 only; the successor to AnnounceInit. Lite-07 answers
|
|
634
|
+
/// on its one stream instead (the `ok` message).
|
|
409
635
|
///
|
|
410
636
|
/// `origin` is the responder's Hop ID, which the subscriber stamps onto each
|
|
411
637
|
/// announce's hop chain (the publisher no longer stamps itself), or the reserved
|
|
412
|
-
/// {@link UNKNOWN_HOP} when the responder has no identity to give. `active` is
|
|
413
|
-
///
|
|
638
|
+
/// {@link UNKNOWN_HOP} when the responder has no identity to give. `active` is the
|
|
639
|
+
/// initial start count.
|
|
414
640
|
export class AnnounceOk {
|
|
415
641
|
hop;
|
|
416
642
|
active;
|
|
@@ -419,25 +645,24 @@ export class AnnounceOk {
|
|
|
419
645
|
this.active = active;
|
|
420
646
|
}
|
|
421
647
|
static #guard(version) {
|
|
422
|
-
if (!hasAnnounceOk(version)) {
|
|
648
|
+
if (!hasAnnounceOk(version) || hasRoutes(version)) {
|
|
423
649
|
throw new Error("announce ok not supported for this version");
|
|
424
650
|
}
|
|
425
651
|
}
|
|
426
|
-
async #encode(w) {
|
|
427
|
-
await w.u62(this.hop);
|
|
652
|
+
async #encode(w, version) {
|
|
653
|
+
await w.u62(wireHop(this.hop, version));
|
|
428
654
|
await w.u53(this.active);
|
|
429
655
|
}
|
|
430
656
|
static async #decode(r) {
|
|
431
657
|
// The draft reserves 0 for "unknown": the responder was never assigned an id, or
|
|
432
658
|
// withholds it to obscure its routing. It names nobody, so callers must not stamp
|
|
433
659
|
// it onto a hop chain, but it is a legal message and not grounds to drop the stream.
|
|
434
|
-
const origin =
|
|
435
|
-
|
|
436
|
-
return new AnnounceOk(origin, active);
|
|
660
|
+
const origin = toHop(await r.u62());
|
|
661
|
+
return new AnnounceOk(origin, await r.u53());
|
|
437
662
|
}
|
|
438
663
|
async encode(w, version) {
|
|
439
664
|
AnnounceOk.#guard(version);
|
|
440
|
-
return Message.encode(w, this.#encode
|
|
665
|
+
return Message.encode(w, (w) => this.#encode(w, version));
|
|
441
666
|
}
|
|
442
667
|
static async decode(r, version) {
|
|
443
668
|
AnnounceOk.#guard(version);
|