@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/routed.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type GetPromise, type Getter } from "@moq/signals";
|
|
2
|
+
import type * as announce from "../announced.ts";
|
|
3
|
+
import type { Grant } from "../auth.ts";
|
|
4
|
+
import type { Goaway } from "../connection/goaway.ts";
|
|
5
|
+
import type { BroadcastCache } from "../consume.ts";
|
|
6
|
+
import { Cost, WireRoute } from "../hop.ts";
|
|
7
|
+
import * as Path from "../path.ts";
|
|
8
|
+
import { type Slots } from "../util/limits.ts";
|
|
9
|
+
import { type AnnounceBroadcast } from "./announce.ts";
|
|
10
|
+
import type { Version } from "./version.ts";
|
|
11
|
+
/** What a `routes()` reader asked for. */
|
|
12
|
+
export interface Request {
|
|
13
|
+
/** The prefix the reader lists: claims at or beneath it. */
|
|
14
|
+
prefix: Path.Valid;
|
|
15
|
+
/** Also report claims with a `.`-prefixed segment below the prefix. */
|
|
16
|
+
hidden: boolean;
|
|
17
|
+
/** Also report claims above the prefix, whose subtree covers it. */
|
|
18
|
+
covering: boolean;
|
|
19
|
+
/** Report each identity's claim at a path rather than the best one. */
|
|
20
|
+
claims: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** What the session's route layer is built on. */
|
|
23
|
+
export interface Session {
|
|
24
|
+
quic: WebTransport;
|
|
25
|
+
version: Version;
|
|
26
|
+
consumes: BroadcastCache;
|
|
27
|
+
/** The session's announce cap: one slot per live claim. */
|
|
28
|
+
slots: Slots;
|
|
29
|
+
/** Rank a route last once the peer sent GOAWAY. */
|
|
30
|
+
drained(route: WireRoute): WireRoute;
|
|
31
|
+
/** What crossing this link adds to a claim's cost, once known. */
|
|
32
|
+
cost(): Promise<Cost>;
|
|
33
|
+
/** This link's rank, which every claim through it carries at most. */
|
|
34
|
+
priority: number;
|
|
35
|
+
goaway?: GetPromise<Goaway>;
|
|
36
|
+
/** Our grant: the peer answers a prefix wider than what it lets us subscribe to region by region. */
|
|
37
|
+
grant?: Getter<Grant | undefined>;
|
|
38
|
+
/** Send one message on this session's Announce Stream. */
|
|
39
|
+
send(msg: AnnounceBroadcast): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/** The claims a lite-07 session's peer sends, shared by every reader of the session. */
|
|
42
|
+
export declare class Routed {
|
|
43
|
+
#private;
|
|
44
|
+
constructor(session: Session);
|
|
45
|
+
/** Feed `announced` what the stream carries for `request`, until its last consumer leaves. */
|
|
46
|
+
attach(announced: announce.Producer, request: Request): void;
|
|
47
|
+
/** This side finished its stream: the prefixes asked of the peer stay as they are. */
|
|
48
|
+
silence(): void;
|
|
49
|
+
/** The peer finished its stream: it is leaving, its claims go, and it answers nothing more. */
|
|
50
|
+
finish(): void;
|
|
51
|
+
/** The session ended: every reader ends with `err`, and every claim goes. */
|
|
52
|
+
close(err?: Error): void;
|
|
53
|
+
/**
|
|
54
|
+
* Apply one message the peer sent on its Announce Stream as a publisher. Once the peer left,
|
|
55
|
+
* whatever it still sends about the claims that ended with it is moot.
|
|
56
|
+
*/
|
|
57
|
+
receive(msg: AnnounceBroadcast): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=routed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routed.d.ts","sourceRoot":"","sources":["../../src/lite/routed.ts"],"names":[],"mappings":"AAYA,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,MAAM,EAAQ,MAAM,cAAc,CAAC;AAChF,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAe,SAAS,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAEN,KAAK,iBAAiB,EAKtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,0CAA0C;AAC1C,MAAM,WAAW,OAAO;IACvB,4DAA4D;IAC5D,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC;IACnB,uEAAuE;IACvE,MAAM,EAAE,OAAO,CAAC;IAChB,oEAAoE;IACpE,QAAQ,EAAE,OAAO,CAAC;IAClB,uEAAuE;IACvE,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,kDAAkD;AAClD,MAAM,WAAW,OAAO;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,cAAc,CAAC;IACzB,2DAA2D;IAC3D,KAAK,EAAE,KAAK,CAAC;IACb,mDAAmD;IACnD,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IACrC,kEAAkE;IAClE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC5B,qGAAqG;IACrG,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAClC,0DAA0D;IAC1D,IAAI,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAmDD,wFAAwF;AACxF,qBAAa,MAAM;;IAgClB,YAAY,OAAO,EAAE,OAAO,EAgB3B;IAyBD,8FAA8F;IAC9F,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAqB3D;IAsFD,sFAAsF;IACtF,OAAO,IAAI,IAAI,CAGd;IAED,+FAA+F;IAC/F,MAAM,IAAI,IAAI,CAIb;IAED,6EAA6E;IAC7E,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAavB;IAiND;;;OAGG;IACG,OAAO,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEnD;CACD"}
|
package/lite/routed.js
ADDED
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
// Lite-07: what the peer sends on its Announce Stream as a publisher, and the prefixes this
|
|
2
|
+
// session asks it for on its own.
|
|
3
|
+
//
|
|
4
|
+
// Every `routes()` reader of the session shares the one stream. The session asks the peer only
|
|
5
|
+
// for the covering set of what its readers want, no prefix at or below another, edited in place
|
|
6
|
+
// one ANNOUNCE_REQUEST at a time, and each reader is fed from the claims the stream carries,
|
|
7
|
+
// presented under the reader's own prefix as the peer would present them to a request for it.
|
|
8
|
+
//
|
|
9
|
+
// This node is an endpoint: it declares no Node ID, so the peer sends it claims and never routes.
|
|
10
|
+
// Each claim is one identity's at a path, with what the peer's own reader shows of it: its cost,
|
|
11
|
+
// how far above the path it was made, and whether a route still reaches it.
|
|
12
|
+
import { race } from "@moq/signals";
|
|
13
|
+
import { error, ProtocolViolation, peerEnded } from "../error.js";
|
|
14
|
+
import { Cost, routesEqual, WireRoute } from "../hop.js";
|
|
15
|
+
import { arrival, bestOfTier, coveringPrefixes, hiddenBelow } from "../internal.js";
|
|
16
|
+
import * as Path from "../path.js";
|
|
17
|
+
import { SlotMap } from "../util/limits.js";
|
|
18
|
+
import { AnnounceHistory, requestFits, requestParts, } from "./announce.js";
|
|
19
|
+
// The most a claim at `path` can be above it: a claim above the session's root covers the whole
|
|
20
|
+
// of what the peer shows. Mirrors rs/moq-net.
|
|
21
|
+
const checkAbove = (path, above) => {
|
|
22
|
+
if (above > BigInt(Path.parts(path).length))
|
|
23
|
+
throw new ProtocolViolation(`a claim at ${path} cannot be ${above} segments above it`);
|
|
24
|
+
};
|
|
25
|
+
/** The claims a lite-07 session's peer sends, shared by every reader of the session. */
|
|
26
|
+
export class Routed {
|
|
27
|
+
#session;
|
|
28
|
+
#readers = new Set();
|
|
29
|
+
/** The prefixes asked of the peer. */
|
|
30
|
+
#asked = new Map();
|
|
31
|
+
#nextPrefix = 0n;
|
|
32
|
+
/** The ANNOUNCE_REQUEST the peer has not answered yet. */
|
|
33
|
+
#editing;
|
|
34
|
+
/** The peer finished its stream: it answers nothing more. */
|
|
35
|
+
#finished = false;
|
|
36
|
+
/** This side finished its stream: it asks for nothing more. */
|
|
37
|
+
#silent = false;
|
|
38
|
+
/** The grant showed a reader more since the last edit: the next goes even when it changes
|
|
39
|
+
* nothing, since its ANNOUNCE_OK follows what the change shows under a wider prefix. */
|
|
40
|
+
#regranted = false;
|
|
41
|
+
/** What our grant lets us subscribe to, as last seen. */
|
|
42
|
+
#granted;
|
|
43
|
+
// Each live claim holds one of the session's announce slots.
|
|
44
|
+
#claims;
|
|
45
|
+
// The claims shown at each path, oldest first.
|
|
46
|
+
#byPath = new Map();
|
|
47
|
+
#history = new AnnounceHistory();
|
|
48
|
+
// What crossing this link costs, known before the first claim arrives.
|
|
49
|
+
#cost;
|
|
50
|
+
// Set once the session lets go of its claims, which then show nothing anew.
|
|
51
|
+
#closing = false;
|
|
52
|
+
#stopDrain;
|
|
53
|
+
#stopGrant;
|
|
54
|
+
constructor(session) {
|
|
55
|
+
this.#session = session;
|
|
56
|
+
this.#claims = new SlotMap(session.slots);
|
|
57
|
+
// A draining peer ranks its claims last from the GOAWAY itself.
|
|
58
|
+
this.#stopDrain = session.goaway?.changed(() => {
|
|
59
|
+
if (this.#closing)
|
|
60
|
+
return;
|
|
61
|
+
// As one change, so a path its claims cover never passes through another route.
|
|
62
|
+
session.consumes.batch(() => {
|
|
63
|
+
for (const [id, live] of this.#claims)
|
|
64
|
+
this.#serve(id, live, false, false);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
this.#granted = session.grant?.peek()?.subscribe;
|
|
68
|
+
this.#stopGrant = session.grant?.subscribe(() => {
|
|
69
|
+
this.#ask();
|
|
70
|
+
this.#release();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Note a grant change, read as it is set rather than when its listeners run, so a reader
|
|
74
|
+
// attached between the two waits too. What it newly shows within a prefix asked may already be
|
|
75
|
+
// in the peer's answer, unheard here: the next edit goes, since its answer follows the change,
|
|
76
|
+
// and the readers there and any reader arriving before that answer wait for it. Elsewhere, and
|
|
77
|
+
// on a narrowing, nothing new can arrive, and a reader stays synced. Mirrors rs/moq-net.
|
|
78
|
+
#regrant() {
|
|
79
|
+
const next = this.#session.grant?.peek()?.subscribe;
|
|
80
|
+
const granted = this.#granted;
|
|
81
|
+
if (next === granted || (next && granted?.equals(next)))
|
|
82
|
+
return;
|
|
83
|
+
this.#granted = next;
|
|
84
|
+
const regions = gained(granted, next);
|
|
85
|
+
const overlaps = (prefix) => regions.some((region) => Path.hasPrefix(region, prefix) || Path.hasPrefix(prefix, region));
|
|
86
|
+
if ([...this.#asked.values()].some((asked) => overlaps(asked.path)))
|
|
87
|
+
this.#regranted = true;
|
|
88
|
+
for (const reader of this.#readers) {
|
|
89
|
+
if (!overlaps(reader.prefix))
|
|
90
|
+
continue;
|
|
91
|
+
this.#regranted = true;
|
|
92
|
+
if (!reader.synced)
|
|
93
|
+
continue;
|
|
94
|
+
reader.synced = false;
|
|
95
|
+
reader.announced.behind();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Feed `announced` what the stream carries for `request`, until its last consumer leaves. */
|
|
99
|
+
attach(announced, request) {
|
|
100
|
+
if (this.#closing) {
|
|
101
|
+
announced.close();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const reader = { ...request, announced, reported: new Map(), synced: false };
|
|
105
|
+
this.#readers.add(reader);
|
|
106
|
+
// What the stream already carries shows before the reader counts as synced.
|
|
107
|
+
const paths = new Set();
|
|
108
|
+
for (const path of this.#byPath.keys()) {
|
|
109
|
+
const at = presentedAt(reader, path);
|
|
110
|
+
if (at !== undefined)
|
|
111
|
+
paths.add(at);
|
|
112
|
+
}
|
|
113
|
+
for (const path of paths)
|
|
114
|
+
this.#refresh(reader, path, false);
|
|
115
|
+
this.#ask();
|
|
116
|
+
this.#release();
|
|
117
|
+
void race([announced.closed]).then(() => {
|
|
118
|
+
if (!this.#readers.delete(reader))
|
|
119
|
+
return;
|
|
120
|
+
this.#ask();
|
|
121
|
+
this.#release();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
// The covering set of what the readers want: no prefix at or below another. A prefix asks for
|
|
125
|
+
// hidden claims when a reader beneath it does, or sits behind a hidden segment itself.
|
|
126
|
+
#wanted() {
|
|
127
|
+
const heads = new Set();
|
|
128
|
+
for (const reader of this.#readers)
|
|
129
|
+
heads.add(reader.prefix);
|
|
130
|
+
const covering = (head) => {
|
|
131
|
+
let top = head;
|
|
132
|
+
for (const above of coveringPrefixes(head))
|
|
133
|
+
if (heads.has(above))
|
|
134
|
+
top = above;
|
|
135
|
+
return top;
|
|
136
|
+
};
|
|
137
|
+
const wanted = new Map();
|
|
138
|
+
for (const reader of this.#readers) {
|
|
139
|
+
const top = covering(reader.prefix);
|
|
140
|
+
const hidden = reader.hidden || hiddenBelow(top, reader.prefix);
|
|
141
|
+
wanted.set(top, (wanted.get(top) ?? false) || hidden);
|
|
142
|
+
}
|
|
143
|
+
// The whole set has to fit one request: past that, everything is asked for at the root.
|
|
144
|
+
if (!requestFits(wanted.keys(), this.#session.version)) {
|
|
145
|
+
const hidden = [...this.#readers].some((reader) => reader.hidden || hiddenBelow(Path.empty(), reader.prefix));
|
|
146
|
+
return new Map([[Path.empty(), hidden]]);
|
|
147
|
+
}
|
|
148
|
+
return wanted;
|
|
149
|
+
}
|
|
150
|
+
// The edit that brings what is asked of the peer in line with what the readers want.
|
|
151
|
+
#edit() {
|
|
152
|
+
const wanted = this.#wanted();
|
|
153
|
+
const remove = [];
|
|
154
|
+
for (const [id, asked] of this.#asked) {
|
|
155
|
+
if (wanted.get(asked.path) === asked.hidden)
|
|
156
|
+
wanted.delete(asked.path);
|
|
157
|
+
else
|
|
158
|
+
remove.push(id);
|
|
159
|
+
}
|
|
160
|
+
return { remove, add: [...wanted].map(([prefix, hidden]) => ({ prefix, hidden })) };
|
|
161
|
+
}
|
|
162
|
+
// Ask the peer for what the readers now want, one edit at a time.
|
|
163
|
+
#ask() {
|
|
164
|
+
this.#regrant();
|
|
165
|
+
if (this.#editing || this.#finished || this.#silent || this.#closing)
|
|
166
|
+
return;
|
|
167
|
+
const { remove, add } = this.#edit();
|
|
168
|
+
if (remove.length === 0 && add.length === 0 && !this.#regranted)
|
|
169
|
+
return;
|
|
170
|
+
this.#regranted = false;
|
|
171
|
+
const added = [];
|
|
172
|
+
for (const { prefix, hidden } of add) {
|
|
173
|
+
const id = this.#nextPrefix++;
|
|
174
|
+
this.#asked.set(id, { path: prefix, hidden, live: false, synced: false });
|
|
175
|
+
added.push(id);
|
|
176
|
+
}
|
|
177
|
+
this.#editing = { remove, add: added };
|
|
178
|
+
console.debug(`announced: remove=${remove.join(",")} add=${add.map(({ prefix }) => prefix).join(",")}`);
|
|
179
|
+
// However large, the edit goes whole, in as many messages as it takes. A peer that stopped
|
|
180
|
+
// the stream is leaving, which the session's own handling of the stop ends these routes for.
|
|
181
|
+
for (const part of requestParts(remove, add, this.#session.version)) {
|
|
182
|
+
this.#session.send(part).catch((err) => {
|
|
183
|
+
if (!peerEnded(this.#session.quic, err))
|
|
184
|
+
this.close(error(err));
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Let each reader see its prefix synced once its answer is in: the peer answered every
|
|
189
|
+
// request, and sent the initial set of each prefix asked for it.
|
|
190
|
+
#release() {
|
|
191
|
+
const done = this.#finished || this.#silent;
|
|
192
|
+
if (!done) {
|
|
193
|
+
this.#ask();
|
|
194
|
+
if (this.#editing)
|
|
195
|
+
return;
|
|
196
|
+
const { remove, add } = this.#edit();
|
|
197
|
+
if (remove.length > 0 || add.length > 0)
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
for (const reader of this.#readers) {
|
|
201
|
+
if (reader.synced)
|
|
202
|
+
continue;
|
|
203
|
+
const answered = [...this.#asked.values()].every((asked) => asked.synced ||
|
|
204
|
+
!(Path.hasPrefix(asked.path, reader.prefix) || Path.hasPrefix(reader.prefix, asked.path)));
|
|
205
|
+
if (!done && !answered)
|
|
206
|
+
continue;
|
|
207
|
+
reader.synced = true;
|
|
208
|
+
reader.announced.synced();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** This side finished its stream: the prefixes asked of the peer stay as they are. */
|
|
212
|
+
silence() {
|
|
213
|
+
this.#silent = true;
|
|
214
|
+
this.#release();
|
|
215
|
+
}
|
|
216
|
+
/** The peer finished its stream: it is leaving, its claims go, and it answers nothing more. */
|
|
217
|
+
finish() {
|
|
218
|
+
this.#finished = true;
|
|
219
|
+
for (const id of [...this.#claims.keys()])
|
|
220
|
+
this.#end(id, true);
|
|
221
|
+
this.#release();
|
|
222
|
+
}
|
|
223
|
+
/** The session ended: every reader ends with `err`, and every claim goes. */
|
|
224
|
+
close(err) {
|
|
225
|
+
if (this.#closing)
|
|
226
|
+
return;
|
|
227
|
+
this.#closing = true;
|
|
228
|
+
this.#stopDrain?.();
|
|
229
|
+
this.#stopGrant?.();
|
|
230
|
+
for (const live of this.#claims.values()) {
|
|
231
|
+
if (live.path !== undefined && live.taken)
|
|
232
|
+
this.#session.consumes.withdraw(live.path, live.owner);
|
|
233
|
+
}
|
|
234
|
+
this.#claims.clear();
|
|
235
|
+
this.#byPath.clear();
|
|
236
|
+
const readers = [...this.#readers];
|
|
237
|
+
this.#readers.clear();
|
|
238
|
+
for (const reader of readers)
|
|
239
|
+
reader.announced.close(err);
|
|
240
|
+
}
|
|
241
|
+
#claim(id) {
|
|
242
|
+
const found = this.#claims.get(id);
|
|
243
|
+
if (!found)
|
|
244
|
+
throw new ProtocolViolation(`unknown announce id ${id}`);
|
|
245
|
+
return found;
|
|
246
|
+
}
|
|
247
|
+
// A claim through this session: its cost plus this link's; ranked below every available claim
|
|
248
|
+
// while the peer or a node on its way drains, then by the lowest priority on its way, this
|
|
249
|
+
// link's included; and unavailable while no route reaches it.
|
|
250
|
+
#candidate(live, claim) {
|
|
251
|
+
if (this.#cost === undefined)
|
|
252
|
+
throw new Error("a claim before the link was priced");
|
|
253
|
+
return this.#session.drained(WireRoute.normalize({
|
|
254
|
+
identity: live.identity,
|
|
255
|
+
epoch: claim.epoch,
|
|
256
|
+
cost: Cost.charged(claim.cost, this.#cost),
|
|
257
|
+
claimed: true,
|
|
258
|
+
priority: Math.min(this.#session.priority, claim.priority),
|
|
259
|
+
above: claim.above,
|
|
260
|
+
draining: claim.draining || undefined,
|
|
261
|
+
available: !claim.unavailable,
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
// Whether `live` is shown: at a path this node can hold, on a run that was told available.
|
|
265
|
+
#shown(live) {
|
|
266
|
+
return live.path !== undefined && live.taken;
|
|
267
|
+
}
|
|
268
|
+
// Bring what the session shows of the claim `id` in line with `live`, which `was` shown or
|
|
269
|
+
// not before the change. `restart` marks another epoch, whose consumes subscribe fresh, and
|
|
270
|
+
// `lost` a claim let go rather than withdrawn.
|
|
271
|
+
#serve(id, live, restart, lost, was = this.#shown(live)) {
|
|
272
|
+
if (live.path === undefined)
|
|
273
|
+
return;
|
|
274
|
+
const consumes = this.#session.consumes;
|
|
275
|
+
let ids = this.#byPath.get(live.path);
|
|
276
|
+
if (this.#shown(live)) {
|
|
277
|
+
if (!ids) {
|
|
278
|
+
ids = new Set();
|
|
279
|
+
this.#byPath.set(live.path, ids);
|
|
280
|
+
}
|
|
281
|
+
// A claim shown anew or restarted iterates last, as the newest; a re-price keeps its
|
|
282
|
+
// place, as the consume cache does. See mostSpecific.
|
|
283
|
+
if (!was || restart) {
|
|
284
|
+
ids.delete(id);
|
|
285
|
+
live.ref = {};
|
|
286
|
+
arrival(live.ref);
|
|
287
|
+
}
|
|
288
|
+
ids.add(id);
|
|
289
|
+
consumes.announce(live.path, live.owner, this.#candidate(live, live.claim), restart);
|
|
290
|
+
}
|
|
291
|
+
else if (was) {
|
|
292
|
+
ids?.delete(id);
|
|
293
|
+
if (ids?.size === 0)
|
|
294
|
+
this.#byPath.delete(live.path);
|
|
295
|
+
consumes.withdraw(live.path, live.owner);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
this.#touch(live.path, lost);
|
|
301
|
+
}
|
|
302
|
+
// The claim `id` is gone: its publisher withdrew it unless `lost`.
|
|
303
|
+
#end(id, lost) {
|
|
304
|
+
const live = this.#claim(id);
|
|
305
|
+
this.#history.end(id);
|
|
306
|
+
this.#claims.delete(id);
|
|
307
|
+
const was = this.#shown(live);
|
|
308
|
+
live.taken = false;
|
|
309
|
+
this.#serve(id, live, false, lost, was);
|
|
310
|
+
}
|
|
311
|
+
// The claims `reader` is shown at `path`, each with where it is filed and how it is shown:
|
|
312
|
+
// those at the path itself, and at the reader's own prefix each claim at or above it, as the
|
|
313
|
+
// peer presents a claim covering more than a requested prefix: that many segments more above
|
|
314
|
+
// the path, so a claim exactly there still outranks it. Oldest first at each filing.
|
|
315
|
+
#candidates(reader, path) {
|
|
316
|
+
const candidates = [];
|
|
317
|
+
for (const at of path === reader.prefix ? coveringPrefixes(path) : [path]) {
|
|
318
|
+
const by = BigInt(Path.parts(path).length - Path.parts(at).length);
|
|
319
|
+
for (const id of this.#byPath.get(at) ?? []) {
|
|
320
|
+
const live = this.#claim(id);
|
|
321
|
+
const filed = this.#candidate(live, live.claim);
|
|
322
|
+
const shown = by === 0n ? filed : this.#candidate(live, { ...live.claim, above: live.claim.above + by });
|
|
323
|
+
candidates.push({ prefix: at, ref: live.ref, filed, shown });
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return candidates;
|
|
327
|
+
}
|
|
328
|
+
// Report to `reader` the best claim at `path`, or with `claims` each identity's, and each
|
|
329
|
+
// one's end. `lost` marks the claims leaving as let go rather than withdrawn, so they go
|
|
330
|
+
// offline rather than ending.
|
|
331
|
+
#refresh(reader, path, lost) {
|
|
332
|
+
const { announced } = reader;
|
|
333
|
+
if (announced.closed.peek() !== undefined)
|
|
334
|
+
return;
|
|
335
|
+
// Keyed by identity with `claims`, and otherwise the one key `undefined`.
|
|
336
|
+
const now = new Map();
|
|
337
|
+
if (visible(reader, path)) {
|
|
338
|
+
const candidates = this.#candidates(reader, path);
|
|
339
|
+
// At the reader's own prefix, the same pick a consume of `path` makes from the cache,
|
|
340
|
+
// ranked where each claim is filed, newest first at each filing. Beneath it, the best
|
|
341
|
+
// claim filed at `path`, as the origin's listing shows each row: each carries its Above,
|
|
342
|
+
// so the reader holds every filing. Ranked from the claims alone, never walking the
|
|
343
|
+
// prefixes they are not filed at, so a refresh stays linear in the claims shown.
|
|
344
|
+
const depths = new Map();
|
|
345
|
+
const pick = (among) => {
|
|
346
|
+
// Alone, it is the pick: nothing supersedes or outranks it.
|
|
347
|
+
if (among.length === 1)
|
|
348
|
+
return among[0];
|
|
349
|
+
const orders = new Map();
|
|
350
|
+
const filed = [];
|
|
351
|
+
// Newest first at each filing, as mostSpecific numbers them.
|
|
352
|
+
for (let i = among.length - 1; i >= 0; i--) {
|
|
353
|
+
const candidate = among[i];
|
|
354
|
+
const { prefix, ref } = candidate;
|
|
355
|
+
let depth = depths.get(prefix);
|
|
356
|
+
if (depth === undefined) {
|
|
357
|
+
depth = Path.parts(prefix).length;
|
|
358
|
+
depths.set(prefix, depth);
|
|
359
|
+
}
|
|
360
|
+
const order = orders.get(prefix) ?? 0;
|
|
361
|
+
orders.set(prefix, order + 1);
|
|
362
|
+
filed.push({ prefix, depth, order, arrival: arrival(ref), candidate, route: candidate.filed });
|
|
363
|
+
}
|
|
364
|
+
return bestOfTier(path, filed)?.candidate;
|
|
365
|
+
};
|
|
366
|
+
if (reader.claims) {
|
|
367
|
+
// Each identity's pick, as a consume pinned to it makes, from one pass over the claims.
|
|
368
|
+
const identities = new Map();
|
|
369
|
+
for (const candidate of candidates) {
|
|
370
|
+
const own = identities.get(candidate.filed.identity);
|
|
371
|
+
if (own)
|
|
372
|
+
own.push(candidate);
|
|
373
|
+
else
|
|
374
|
+
identities.set(candidate.filed.identity, [candidate]);
|
|
375
|
+
}
|
|
376
|
+
for (const [identity, own] of identities) {
|
|
377
|
+
const best = pick(own);
|
|
378
|
+
if (best)
|
|
379
|
+
now.set(identity, best.shown);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
const best = pick(candidates);
|
|
384
|
+
if (best)
|
|
385
|
+
now.set(undefined, best.shown);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const prev = reader.reported.get(path) ?? new Map();
|
|
389
|
+
// Arrivals first, so a reader sees a claim replaced rather than the path gone between.
|
|
390
|
+
for (const [key, next] of now) {
|
|
391
|
+
const was = prev.get(key);
|
|
392
|
+
if (was && routesEqual(was, next))
|
|
393
|
+
continue;
|
|
394
|
+
const restart = !!was && (was.identity !== next.identity || was.epoch !== next.epoch);
|
|
395
|
+
const kind = !was ? "start" : restart ? "restart" : "update";
|
|
396
|
+
console.debug(`announced: broadcast=${path} ${kind} identity=${next.identity}`);
|
|
397
|
+
announced.append({ prefix: path, kind, route: next });
|
|
398
|
+
}
|
|
399
|
+
for (const [key, was] of prev) {
|
|
400
|
+
if (now.has(key))
|
|
401
|
+
continue;
|
|
402
|
+
console.debug(`announced: broadcast=${path} active=false lost=${lost}`);
|
|
403
|
+
announced.append({ prefix: path, kind: lost ? "offline" : "end", route: was });
|
|
404
|
+
}
|
|
405
|
+
if (now.size > 0)
|
|
406
|
+
reader.reported.set(path, now);
|
|
407
|
+
else
|
|
408
|
+
reader.reported.delete(path);
|
|
409
|
+
}
|
|
410
|
+
// Report the claims at `path` to every reader it shows under: at the path itself for a reader
|
|
411
|
+
// above it, and at the reader's own prefix for one below.
|
|
412
|
+
#touch(path, lost) {
|
|
413
|
+
for (const reader of this.#readers) {
|
|
414
|
+
const at = presentedAt(reader, path);
|
|
415
|
+
if (at !== undefined)
|
|
416
|
+
this.#refresh(reader, at, lost);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// ANNOUNCE_OK: the last edit takes effect on the peer's stream. Both ends drop every claim
|
|
420
|
+
// within a prefix it removed, and the peer tells again what an added prefix covers.
|
|
421
|
+
#ok() {
|
|
422
|
+
const editing = this.#editing;
|
|
423
|
+
if (!editing)
|
|
424
|
+
throw new ProtocolViolation("ANNOUNCE_OK with no ANNOUNCE_REQUEST unanswered");
|
|
425
|
+
this.#editing = undefined;
|
|
426
|
+
const removed = [];
|
|
427
|
+
for (const id of editing.remove) {
|
|
428
|
+
const asked = this.#asked.get(id);
|
|
429
|
+
if (asked)
|
|
430
|
+
removed.push(asked.path);
|
|
431
|
+
this.#asked.delete(id);
|
|
432
|
+
}
|
|
433
|
+
// Whether a prefix in effect before the edit survives it: the peer's claims within one stay.
|
|
434
|
+
const survives = [...this.#asked.values()].some((asked) => asked.live);
|
|
435
|
+
for (const id of editing.add) {
|
|
436
|
+
const asked = this.#asked.get(id);
|
|
437
|
+
if (!asked)
|
|
438
|
+
throw new Error("an added prefix");
|
|
439
|
+
asked.live = true;
|
|
440
|
+
}
|
|
441
|
+
if (removed.length > 0) {
|
|
442
|
+
for (const [id, live] of [...this.#claims]) {
|
|
443
|
+
const { path } = live;
|
|
444
|
+
// A claim whose path could not be resolved lies in a prefix this side cannot name.
|
|
445
|
+
// The peer may still hold it, and ends it by its id, so it goes only when no earlier
|
|
446
|
+
// prefix is left for it to lie in.
|
|
447
|
+
const within = path === undefined ? !survives : removed.some((prefix) => Path.hasPrefix(prefix, path));
|
|
448
|
+
// The peer never ended it: it only stopped telling this session.
|
|
449
|
+
if (within)
|
|
450
|
+
this.#end(id, true);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// What the readers want may have moved while the peer answered.
|
|
454
|
+
this.#ask();
|
|
455
|
+
this.#release();
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Apply one message the peer sent on its Announce Stream as a publisher. Once the peer left,
|
|
459
|
+
* whatever it still sends about the claims that ended with it is moot.
|
|
460
|
+
*/
|
|
461
|
+
async receive(msg) {
|
|
462
|
+
if (this.#closing || this.#finished)
|
|
463
|
+
return;
|
|
464
|
+
switch (msg.status) {
|
|
465
|
+
case "ok":
|
|
466
|
+
this.#ok();
|
|
467
|
+
break;
|
|
468
|
+
case "synced": {
|
|
469
|
+
const asked = this.#asked.get(msg.prefix);
|
|
470
|
+
if (!asked?.live)
|
|
471
|
+
throw new ProtocolViolation(`SYNCED for unknown Prefix ID ${msg.prefix}`);
|
|
472
|
+
if (asked.synced)
|
|
473
|
+
throw new ProtocolViolation(`duplicate SYNCED for Prefix ID ${msg.prefix}`);
|
|
474
|
+
asked.synced = true;
|
|
475
|
+
this.#release();
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
case "request":
|
|
479
|
+
// The peer's own request is answered by the publisher half.
|
|
480
|
+
break;
|
|
481
|
+
case "start": {
|
|
482
|
+
// Every claim, and every change to one, arrives after the first start.
|
|
483
|
+
this.#cost ??= await this.#session.cost();
|
|
484
|
+
if (this.#closing || this.#finished)
|
|
485
|
+
return;
|
|
486
|
+
// Every claim's path is relative to the session, whichever requested prefix it lies in.
|
|
487
|
+
const path = this.#history.start(msg);
|
|
488
|
+
const id = this.#history.next - 1n;
|
|
489
|
+
if (path === undefined)
|
|
490
|
+
console.warn(`refusing a claim: claim=${id} reason=path`);
|
|
491
|
+
else
|
|
492
|
+
checkAbove(path, msg.claim.above);
|
|
493
|
+
for (const other of path === undefined ? [] : (this.#byPath.get(path) ?? [])) {
|
|
494
|
+
if (this.#claim(other).identity === msg.identity)
|
|
495
|
+
throw new ProtocolViolation(`${path} claimed twice for one identity`);
|
|
496
|
+
}
|
|
497
|
+
const live = {
|
|
498
|
+
path,
|
|
499
|
+
identity: msg.identity,
|
|
500
|
+
claim: msg.claim,
|
|
501
|
+
taken: false,
|
|
502
|
+
owner: {},
|
|
503
|
+
ref: {},
|
|
504
|
+
};
|
|
505
|
+
this.#claims.set(id, live);
|
|
506
|
+
live.taken = !msg.claim.unavailable;
|
|
507
|
+
this.#serve(id, live, false, false, false);
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
case "change": {
|
|
511
|
+
const live = this.#claim(msg.id);
|
|
512
|
+
if (live.path !== undefined)
|
|
513
|
+
checkAbove(live.path, msg.claim.above);
|
|
514
|
+
const was = this.#shown(live);
|
|
515
|
+
const run = live.claim.epoch !== msg.claim.epoch || live.claim.above !== msg.claim.above;
|
|
516
|
+
const restart = live.claim.epoch !== msg.claim.epoch;
|
|
517
|
+
live.claim = msg.claim;
|
|
518
|
+
// The bit counts only on a run this node already holds: another run is taken once
|
|
519
|
+
// it is told available, and the one held before it is lost.
|
|
520
|
+
live.taken = run ? !msg.claim.unavailable : live.taken || !msg.claim.unavailable;
|
|
521
|
+
this.#serve(msg.id, live, restart, true, was);
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
case "endedId":
|
|
525
|
+
this.#end(msg.id, msg.lost ?? false);
|
|
526
|
+
break;
|
|
527
|
+
case "skipped":
|
|
528
|
+
case "active":
|
|
529
|
+
case "update":
|
|
530
|
+
case "ended":
|
|
531
|
+
// Lite-07 names every claim's identity, ends one by its Announce ID, and decoding
|
|
532
|
+
// refuses an unknown type, which only lite-06 skips.
|
|
533
|
+
throw new ProtocolViolation(`${msg.status} announcement on lite-07`);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
// Whether `reader` reports a claim at `path`. A path holding a `*` is kept on record but never
|
|
538
|
+
// reported: no origin accepts one, and an older subscriber would read it as a wildcard.
|
|
539
|
+
function visible(reader, path) {
|
|
540
|
+
const matches = Path.hasPrefix(reader.prefix, path) || (reader.covering && Path.hasPrefix(path, reader.prefix));
|
|
541
|
+
return matches && !path.includes("*") && (reader.hidden || !hiddenBelow(reader.prefix, path));
|
|
542
|
+
}
|
|
543
|
+
// Where `reader` is shown a claim at `path`: there when it lies within the reader's prefix, at
|
|
544
|
+
// the prefix itself when it covers more, and nowhere otherwise.
|
|
545
|
+
function presentedAt(reader, path) {
|
|
546
|
+
if (Path.hasPrefix(reader.prefix, path))
|
|
547
|
+
return path;
|
|
548
|
+
return Path.hasPrefix(path, reader.prefix) ? reader.prefix : undefined;
|
|
549
|
+
}
|
|
550
|
+
// The prefixes holding what the grant `next` shows that `before` did not: each of its prefixes
|
|
551
|
+
// `before` does not cover, less any too long for a path, which covers nothing a peer could name.
|
|
552
|
+
// Empty for a narrowing. Mirrors rs/moq-net's `Permit::beyond`.
|
|
553
|
+
function gained(before, next) {
|
|
554
|
+
if (!before)
|
|
555
|
+
return [];
|
|
556
|
+
if (!next)
|
|
557
|
+
return [Path.empty()];
|
|
558
|
+
return next
|
|
559
|
+
.toArray()
|
|
560
|
+
.filter((prefix) => !before.matches(prefix.text))
|
|
561
|
+
.map((prefix) => prefix.text)
|
|
562
|
+
.filter((region) => Path.check(region) === undefined);
|
|
563
|
+
}
|
|
564
|
+
//# sourceMappingURL=routed.js.map
|