@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/lite/announce.js
CHANGED
|
@@ -1,18 +1,57 @@
|
|
|
1
1
|
import { ProtocolViolation } from "../error.js";
|
|
2
|
-
import {
|
|
2
|
+
import { MAX_HOPS, toHop, UNKNOWN_HOP, wireHop } from "../hop.js";
|
|
3
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";
|
|
4
7
|
import * as Message from "./message.js";
|
|
5
|
-
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";
|
|
6
11
|
// Pre-lite-06 inner status values, carried inside the single ANNOUNCE_BROADCAST body.
|
|
7
12
|
const STATUS_ENDED = 0;
|
|
8
13
|
const STATUS_ACTIVE = 1;
|
|
9
|
-
|
|
14
|
+
// The lite-05 draft's explicit `restart` status: a metadata update.
|
|
15
|
+
const STATUS_UPDATE = 2;
|
|
10
16
|
// lite-06 announce message types: an outer discriminator carried before the length
|
|
11
17
|
// prefix, so each announcement is an independently-typed, length-delimited message
|
|
12
18
|
// (mirroring SUBSCRIBE_START/END/DROP on the subscribe stream).
|
|
13
19
|
const ANNOUNCE_START = 0;
|
|
14
20
|
const ANNOUNCE_END = 1;
|
|
15
|
-
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
|
+
}
|
|
16
55
|
// Both wire rules on a hop chain, applied to what we send and to what we receive: a
|
|
17
56
|
// chain that revisits a hop looped, so neither forwarding it nor subscribing through it
|
|
18
57
|
// is safe, and a receiver must end the session over one. `UNKNOWN_HOP` identifies
|
|
@@ -34,7 +73,7 @@ function checkHops(hops) {
|
|
|
34
73
|
}
|
|
35
74
|
}
|
|
36
75
|
}
|
|
37
|
-
async function encodeHops(w, version, hops) {
|
|
76
|
+
async function encodeHops(w, version, hops = []) {
|
|
38
77
|
checkHops(hops);
|
|
39
78
|
switch (version) {
|
|
40
79
|
case Version.DRAFT_01:
|
|
@@ -47,7 +86,7 @@ async function encodeHops(w, version, hops) {
|
|
|
47
86
|
// Lite04+: hop count + individual Hop varints.
|
|
48
87
|
await w.u53(hops.length);
|
|
49
88
|
for (const origin of hops) {
|
|
50
|
-
await w.u62(origin);
|
|
89
|
+
await w.u62(wireHop(origin, version));
|
|
51
90
|
}
|
|
52
91
|
break;
|
|
53
92
|
}
|
|
@@ -72,91 +111,227 @@ async function decodeHops(r, version) {
|
|
|
72
111
|
throw new Error(`hop count ${count} exceeds maximum ${MAX_HOPS}`);
|
|
73
112
|
const hops = [];
|
|
74
113
|
for (let i = 0; i < count; i++) {
|
|
75
|
-
hops.push(
|
|
114
|
+
hops.push(toHop(await r.u62()));
|
|
76
115
|
}
|
|
77
116
|
checkHops(hops);
|
|
78
117
|
return hops;
|
|
79
118
|
}
|
|
80
119
|
}
|
|
81
120
|
}
|
|
82
|
-
// Lite-07 carries a base around a path and a hop list. A distance of 0 names
|
|
83
|
-
// nothing, and a keep without a base is a violation. Other versions have no room for
|
|
84
|
-
// a base at all.
|
|
85
|
-
function checkBase(version, base) {
|
|
86
|
-
if (base && !hasAnnounceCompression(version)) {
|
|
87
|
-
throw new Error("announce compression not supported for this version");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function toBase(distance, keep) {
|
|
91
|
-
if (distance !== 0n)
|
|
92
|
-
return { distance, keep };
|
|
93
|
-
if (keep !== 0)
|
|
94
|
-
throw new ProtocolViolation("announce keep without a base");
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
121
|
async function encodePath(w, version, suffix, base) {
|
|
98
|
-
checkBase(version, base);
|
|
99
122
|
if (hasAnnounceCompression(version)) {
|
|
100
123
|
await w.u62(base?.distance ?? 0n);
|
|
101
124
|
await w.u53(base?.keep ?? 0);
|
|
102
125
|
}
|
|
126
|
+
else if (base) {
|
|
127
|
+
throw new Error("announce compression not supported for this version");
|
|
128
|
+
}
|
|
103
129
|
await w.string(Path.encode(suffix));
|
|
104
130
|
}
|
|
105
131
|
async function decodePath(r, version) {
|
|
106
132
|
if (!hasAnnounceCompression(version))
|
|
107
133
|
return { suffix: Path.decode(await r.string()) };
|
|
108
|
-
const pathBase = toBase(await r.u62(), await r.u53());
|
|
109
|
-
const suffix = Path.decode(await r.string());
|
|
110
|
-
return pathBase ? { suffix, pathBase } : { suffix };
|
|
111
|
-
}
|
|
112
|
-
async function encodeHopsBlock(w, version, hops, base) {
|
|
113
|
-
checkBase(version, base);
|
|
114
|
-
if (!hasAnnounceCompression(version))
|
|
115
|
-
return encodeHops(w, version, hops);
|
|
116
|
-
await w.u62(base?.distance ?? 0n);
|
|
117
|
-
await encodeHops(w, version, hops);
|
|
118
|
-
await w.u53(base?.keep ?? 0);
|
|
119
|
-
}
|
|
120
|
-
async function decodeHopsBlock(r, version) {
|
|
121
|
-
if (!hasAnnounceCompression(version))
|
|
122
|
-
return { hops: await decodeHops(r, version) };
|
|
123
134
|
const distance = await r.u62();
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
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 } };
|
|
127
141
|
}
|
|
128
|
-
//
|
|
129
|
-
// 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
|
|
130
144
|
// varints could carry more, so a cost always forwards to a peer on an older version.
|
|
131
145
|
const MAX_COST = 2n ** 62n - 1n;
|
|
132
146
|
const saturate = (v) => (v > MAX_COST ? MAX_COST : v);
|
|
133
147
|
async function encodeRouteCost(w, version, cost) {
|
|
134
148
|
if (!hasRouteCost(version))
|
|
135
149
|
return;
|
|
136
|
-
await w.u62(saturate(cost
|
|
137
|
-
|
|
150
|
+
await w.u62(saturate(cost ?? 0n));
|
|
151
|
+
if (version === Version.DRAFT_06)
|
|
152
|
+
await w.u62(MAX_COST);
|
|
138
153
|
}
|
|
139
154
|
async function decodeRouteCost(r, version) {
|
|
140
155
|
if (!hasRouteCost(version))
|
|
141
156
|
return undefined;
|
|
142
|
-
|
|
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 }));
|
|
143
289
|
}
|
|
144
290
|
// lite-06 message body (no discriminator; the type is carried outside the length prefix).
|
|
145
291
|
async function encodeAnnounce06Body(w, msg, version) {
|
|
146
292
|
switch (msg.status) {
|
|
147
293
|
case "active":
|
|
148
|
-
|
|
149
|
-
|
|
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);
|
|
150
299
|
await encodeRouteCost(w, version, msg.cost);
|
|
151
300
|
break;
|
|
152
301
|
case "endedId":
|
|
153
302
|
await w.u62(msg.id);
|
|
303
|
+
if (hasRoutes(version))
|
|
304
|
+
await w.bool(msg.lost ?? false);
|
|
154
305
|
break;
|
|
155
|
-
case "
|
|
306
|
+
case "update":
|
|
307
|
+
if (hasRoutes(version))
|
|
308
|
+
throw new Error("a lite-07 update carries its claim");
|
|
156
309
|
await w.u62(msg.id);
|
|
157
|
-
await
|
|
310
|
+
await encodeHops(w, version, msg.hops);
|
|
158
311
|
await encodeRouteCost(w, version, msg.cost);
|
|
159
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;
|
|
160
335
|
case "ended":
|
|
161
336
|
// The pre-lite-06 path-form retraction has no place on lite-06.
|
|
162
337
|
throw new Error("ended-by-path not supported for this version");
|
|
@@ -165,14 +340,28 @@ async function encodeAnnounce06Body(w, msg, version) {
|
|
|
165
340
|
}
|
|
166
341
|
}
|
|
167
342
|
// lite-06 outer message type for a given announcement.
|
|
168
|
-
function announce06Type(msg) {
|
|
343
|
+
function announce06Type(msg, version) {
|
|
169
344
|
switch (msg.status) {
|
|
170
345
|
case "active":
|
|
346
|
+
case "start":
|
|
171
347
|
return ANNOUNCE_START;
|
|
172
348
|
case "endedId":
|
|
173
349
|
return ANNOUNCE_END;
|
|
174
|
-
case "
|
|
175
|
-
|
|
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;
|
|
176
365
|
case "ended":
|
|
177
366
|
throw new Error("ended-by-path not supported for this version");
|
|
178
367
|
case "skipped":
|
|
@@ -183,28 +372,62 @@ async function decodeAnnounce06Body(r, typ, version) {
|
|
|
183
372
|
switch (typ) {
|
|
184
373
|
case ANNOUNCE_START: {
|
|
185
374
|
const path = await decodePath(r, version);
|
|
186
|
-
const
|
|
187
|
-
|
|
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) };
|
|
188
385
|
}
|
|
189
|
-
case ANNOUNCE_END:
|
|
190
|
-
return { status: "endedId", id: await r.u62() };
|
|
191
|
-
case ANNOUNCE_RESTART: {
|
|
386
|
+
case ANNOUNCE_END: {
|
|
192
387
|
const id = await r.u62();
|
|
193
|
-
|
|
194
|
-
return { status: "restart", id, ...hops, cost: await decodeRouteCost(r, version) };
|
|
388
|
+
return hasRoutes(version) ? { status: "endedId", id, lost: await r.bool() } : { status: "endedId", id };
|
|
195
389
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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" };
|
|
202
426
|
}
|
|
203
427
|
// Pre-lite-06 single ANNOUNCE_BROADCAST body: an inner status byte, then path + hops.
|
|
204
428
|
async function encodeLegacyBody(w, msg, version) {
|
|
205
429
|
switch (msg.status) {
|
|
206
430
|
case "active":
|
|
207
|
-
checkBase(version, msg.pathBase ?? msg.hopBase);
|
|
208
431
|
await w.u8(STATUS_ACTIVE);
|
|
209
432
|
await w.string(Path.encode(msg.suffix));
|
|
210
433
|
await encodeHops(w, version, msg.hops);
|
|
@@ -214,18 +437,16 @@ async function encodeLegacyBody(w, msg, version) {
|
|
|
214
437
|
await w.string(Path.encode(msg.suffix));
|
|
215
438
|
await encodeHops(w, version, []);
|
|
216
439
|
break;
|
|
217
|
-
|
|
218
|
-
case "restart":
|
|
219
|
-
case "skipped":
|
|
440
|
+
default:
|
|
220
441
|
// The id-referencing forms only exist on lite-06+.
|
|
221
442
|
throw new Error("announce ids not supported for this version");
|
|
222
443
|
}
|
|
223
444
|
}
|
|
224
445
|
async function decodeLegacyBody(r, version) {
|
|
225
446
|
const status = await r.u8();
|
|
226
|
-
// On lite-05
|
|
227
|
-
//
|
|
228
|
-
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));
|
|
229
450
|
if (status !== STATUS_ENDED && !active) {
|
|
230
451
|
throw new Error("invalid announce status");
|
|
231
452
|
}
|
|
@@ -237,8 +458,7 @@ async function decodeLegacyBody(r, version) {
|
|
|
237
458
|
export async function encodeAnnounceBroadcast(w, msg, version) {
|
|
238
459
|
if (hasAnnounceId(version)) {
|
|
239
460
|
// lite-06+: outer type discriminator, then a size-prefixed body (like the subscribe stream).
|
|
240
|
-
|
|
241
|
-
return Message.encode(w, (w) => encodeAnnounce06Body(w, msg, version));
|
|
461
|
+
return Message.encode(w, (w) => encodeAnnounce06Body(w, msg, version), { id: announce06Type(msg, version) });
|
|
242
462
|
}
|
|
243
463
|
return Message.encode(w, (w) => encodeLegacyBody(w, msg, version));
|
|
244
464
|
}
|
|
@@ -261,105 +481,104 @@ export async function decodeAnnounceBroadcastMaybe(r, version) {
|
|
|
261
481
|
return Message.decodeMaybe(r, (r) => decodeLegacyBody(r, version));
|
|
262
482
|
}
|
|
263
483
|
/**
|
|
264
|
-
* The live announcements on one lite-06+ announce stream, by Announce ID: what
|
|
265
|
-
*
|
|
266
|
-
*
|
|
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}.
|
|
267
487
|
*/
|
|
268
488
|
export class AnnounceHistory {
|
|
269
489
|
#next = 0n;
|
|
270
490
|
#live = new Map();
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
return hops;
|
|
280
|
-
const tail = this.#base(base).hops;
|
|
281
|
-
if (base.keep > tail.length)
|
|
282
|
-
throw new ProtocolViolation(`announce keeps ${base.keep} of ${tail.length} hops`);
|
|
283
|
-
const resolved = [...hops, ...tail.slice(tail.length - base.keep)];
|
|
284
|
-
checkHops(resolved);
|
|
285
|
-
return resolved;
|
|
286
|
-
}
|
|
287
|
-
/** 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. */
|
|
288
499
|
start(msg) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
this.#
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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) {
|
|
315
531
|
const live = this.#live.get(id);
|
|
316
|
-
if (
|
|
532
|
+
if (live === undefined)
|
|
317
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);
|
|
318
541
|
this.#live.delete(id);
|
|
319
|
-
return live
|
|
542
|
+
return live;
|
|
320
543
|
}
|
|
321
544
|
}
|
|
322
545
|
/**
|
|
323
|
-
* ANNOUNCE_REQUEST: sent by the subscriber to request ANNOUNCE_BROADCAST messages
|
|
324
|
-
* 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).
|
|
325
549
|
*/
|
|
326
550
|
export class AnnounceRequest {
|
|
327
551
|
prefix;
|
|
328
|
-
/** Lite04/05 only: the
|
|
329
|
-
*
|
|
330
|
-
* exclusion". Not on the wire elsewhere, so a value set here is ignored when
|
|
331
|
-
* for another version and decodes as
|
|
332
|
-
*
|
|
333
|
-
* 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. */
|
|
334
556
|
excludeHop;
|
|
335
|
-
|
|
336
|
-
* the wire earlier, so a value set here is ignored when encoding for an older version
|
|
337
|
-
* and decodes as false. */
|
|
338
|
-
hidden;
|
|
339
|
-
constructor(prefix, excludeHop = 0n, hidden = false) {
|
|
557
|
+
constructor(prefix, excludeHop = UNKNOWN_HOP) {
|
|
340
558
|
this.prefix = prefix;
|
|
341
559
|
this.excludeHop = excludeHop;
|
|
342
|
-
|
|
560
|
+
}
|
|
561
|
+
static #guard(version) {
|
|
562
|
+
if (hasRoutes(version))
|
|
563
|
+
throw new Error("announce request streams not supported for this version");
|
|
343
564
|
}
|
|
344
565
|
async #encode(w, version) {
|
|
345
566
|
await w.string(Path.encode(this.prefix));
|
|
346
567
|
if (hasExcludeHop(version)) {
|
|
347
|
-
await w.u62(this.excludeHop);
|
|
348
|
-
}
|
|
349
|
-
if (hasHidden(version)) {
|
|
350
|
-
await w.bool(this.hidden);
|
|
568
|
+
await w.u62(wireHop(this.excludeHop, version));
|
|
351
569
|
}
|
|
352
570
|
}
|
|
353
571
|
static async #decode(r, version) {
|
|
354
572
|
const prefix = Path.decode(await r.string());
|
|
355
|
-
const excludeHop = hasExcludeHop(version) ? await r.u62() :
|
|
356
|
-
|
|
357
|
-
return new AnnounceRequest(prefix, excludeHop, hidden);
|
|
573
|
+
const excludeHop = hasExcludeHop(version) ? toHop(await r.u62()) : UNKNOWN_HOP;
|
|
574
|
+
return new AnnounceRequest(prefix, excludeHop);
|
|
358
575
|
}
|
|
359
576
|
async encode(w, version) {
|
|
577
|
+
AnnounceRequest.#guard(version);
|
|
360
578
|
return Message.encode(w, (w) => this.#encode(w, version));
|
|
361
579
|
}
|
|
362
580
|
static async decode(r, version) {
|
|
581
|
+
AnnounceRequest.#guard(version);
|
|
363
582
|
return Message.decode(r, (r) => AnnounceRequest.#decode(r, version));
|
|
364
583
|
}
|
|
365
584
|
}
|
|
@@ -386,30 +605,38 @@ export class AnnounceInit {
|
|
|
386
605
|
await w.string(Path.encode(path));
|
|
387
606
|
}
|
|
388
607
|
}
|
|
389
|
-
static async #decode(r) {
|
|
608
|
+
static async #decode(r, budget) {
|
|
390
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`);
|
|
391
613
|
const suffixes = [];
|
|
392
614
|
for (let i = 0; i < count; i++) {
|
|
393
615
|
suffixes.push(Path.decode(await r.string()));
|
|
394
616
|
}
|
|
395
617
|
return new AnnounceInit(suffixes);
|
|
396
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;
|
|
397
622
|
async encode(w, version) {
|
|
398
623
|
AnnounceInit.#guard(version);
|
|
399
|
-
return Message.encode(w, this.#encode.bind(this));
|
|
624
|
+
return Message.encode(w, this.#encode.bind(this), { max: AnnounceInit.MAX_SIZE });
|
|
400
625
|
}
|
|
401
|
-
|
|
626
|
+
/** Decode the initial set, refusing one that lists more than `budget` broadcasts. */
|
|
627
|
+
static async decode(r, version, budget) {
|
|
402
628
|
AnnounceInit.#guard(version);
|
|
403
|
-
return Message.decode(r, AnnounceInit.#decode);
|
|
629
|
+
return Message.decode(r, (r) => AnnounceInit.#decode(r, budget), AnnounceInit.MAX_SIZE);
|
|
404
630
|
}
|
|
405
631
|
}
|
|
406
632
|
/// Sent by the publisher as the first message on an announce stream, before any
|
|
407
|
-
/// 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).
|
|
408
635
|
///
|
|
409
636
|
/// `origin` is the responder's Hop ID, which the subscriber stamps onto each
|
|
410
637
|
/// announce's hop chain (the publisher no longer stamps itself), or the reserved
|
|
411
|
-
/// {@link UNKNOWN_HOP} when the responder has no identity to give. `active` is
|
|
412
|
-
///
|
|
638
|
+
/// {@link UNKNOWN_HOP} when the responder has no identity to give. `active` is the
|
|
639
|
+
/// initial start count.
|
|
413
640
|
export class AnnounceOk {
|
|
414
641
|
hop;
|
|
415
642
|
active;
|
|
@@ -418,25 +645,24 @@ export class AnnounceOk {
|
|
|
418
645
|
this.active = active;
|
|
419
646
|
}
|
|
420
647
|
static #guard(version) {
|
|
421
|
-
if (!hasAnnounceOk(version)) {
|
|
648
|
+
if (!hasAnnounceOk(version) || hasRoutes(version)) {
|
|
422
649
|
throw new Error("announce ok not supported for this version");
|
|
423
650
|
}
|
|
424
651
|
}
|
|
425
|
-
async #encode(w) {
|
|
426
|
-
await w.u62(this.hop);
|
|
652
|
+
async #encode(w, version) {
|
|
653
|
+
await w.u62(wireHop(this.hop, version));
|
|
427
654
|
await w.u53(this.active);
|
|
428
655
|
}
|
|
429
656
|
static async #decode(r) {
|
|
430
657
|
// The draft reserves 0 for "unknown": the responder was never assigned an id, or
|
|
431
658
|
// withholds it to obscure its routing. It names nobody, so callers must not stamp
|
|
432
659
|
// it onto a hop chain, but it is a legal message and not grounds to drop the stream.
|
|
433
|
-
const origin =
|
|
434
|
-
|
|
435
|
-
return new AnnounceOk(origin, active);
|
|
660
|
+
const origin = toHop(await r.u62());
|
|
661
|
+
return new AnnounceOk(origin, await r.u53());
|
|
436
662
|
}
|
|
437
663
|
async encode(w, version) {
|
|
438
664
|
AnnounceOk.#guard(version);
|
|
439
|
-
return Message.encode(w, this.#encode
|
|
665
|
+
return Message.encode(w, (w) => this.#encode(w, version));
|
|
440
666
|
}
|
|
441
667
|
static async decode(r, version) {
|
|
442
668
|
AnnounceOk.#guard(version);
|