@moq/net 0.4.7 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/announce.d.ts +1 -1
- package/announce.d.ts.map +1 -1
- package/announce.js +1 -2
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -32
- package/announced.js.map +1 -1
- package/announced.test-util.d.ts +2 -0
- package/announced.test-util.d.ts.map +1 -0
- package/announced.test-util.js +27 -0
- package/announced.test-util.js.map +1 -0
- package/auth.d.ts +64 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +20 -0
- package/auth.js.map +1 -0
- package/auth_gate.d.ts +2 -0
- package/auth_gate.d.ts.map +1 -0
- package/auth_gate.js +24 -0
- package/auth_gate.js.map +1 -0
- package/auth_session.d.ts +49 -0
- package/auth_session.d.ts.map +1 -0
- package/auth_session.js +1097 -0
- package/auth_session.js.map +1 -0
- package/bandwidth.d.ts +129 -25
- package/bandwidth.d.ts.map +1 -1
- package/bandwidth.js +410 -139
- package/bandwidth.js.map +1 -1
- package/bandwidth_api.d.ts +1 -1
- package/bandwidth_api.d.ts.map +1 -1
- package/bandwidth_api.js +1 -2
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +64 -38
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -173
- package/broadcast.js.map +1 -1
- package/cache.d.ts +103 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +254 -0
- package/cache.js.map +1 -0
- package/claim.test-util.d.ts +5 -0
- package/claim.test-util.d.ts.map +1 -0
- package/claim.test-util.js +13 -0
- package/claim.test-util.js.map +1 -0
- package/connection/accept.d.ts +21 -13
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -130
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -20
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +120 -24
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -217
- package/connection/connect.js.map +1 -1
- package/connection/dials.d.ts +45 -0
- package/connection/dials.d.ts.map +1 -0
- package/connection/dials.js +109 -0
- package/connection/dials.js.map +1 -0
- package/connection/endpoint.d.ts +60 -0
- package/connection/endpoint.d.ts.map +1 -0
- package/connection/endpoint.js +114 -0
- package/connection/endpoint.js.map +1 -0
- package/connection/forward.d.ts +7 -1
- package/connection/forward.d.ts.map +1 -1
- package/connection/forward.js +265 -81
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +16 -9
- package/connection/goaway.d.ts.map +1 -1
- package/connection/goaway.js +22 -95
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +34 -8
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -21
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +4 -7
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -3
- package/connection/index.js.map +1 -1
- package/connection/liveness.d.ts +14 -0
- package/connection/liveness.d.ts.map +1 -0
- package/connection/liveness.js +30 -0
- package/connection/liveness.js.map +1 -0
- package/connection/pool.d.ts +142 -63
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -118
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts +60 -12
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +859 -234
- package/connection/reload.js.map +1 -1
- package/connection/session.d.ts +91 -0
- package/connection/session.d.ts.map +1 -0
- package/connection/session.js +2 -0
- package/connection/session.js.map +1 -0
- package/connection/stats.d.ts +20 -11
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js +64 -9
- package/connection/stats.js.map +1 -1
- package/connection/ticker.d.ts +4 -0
- package/connection/ticker.d.ts.map +1 -0
- package/connection/ticker.js +66 -0
- package/connection/ticker.js.map +1 -0
- package/connection/tokens.d.ts +2 -0
- package/connection/tokens.d.ts.map +1 -0
- package/connection/tokens.js +404 -0
- package/connection/tokens.js.map +1 -0
- package/connection/transport.d.ts.map +1 -1
- package/connection/transport.js +4 -5
- package/connection/transport.js.map +1 -1
- package/connection/withdrawal.d.ts +2 -0
- package/connection/withdrawal.d.ts.map +1 -0
- package/connection/withdrawal.js +23 -0
- package/connection/withdrawal.js.map +1 -0
- package/consume.js +213 -47
- package/consume.js.map +1 -1
- package/cover.d.ts +59 -0
- package/cover.d.ts.map +1 -0
- package/cover.js +375 -0
- package/cover.js.map +1 -0
- package/datagram.d.ts +70 -11
- package/datagram.d.ts.map +1 -1
- package/datagram.js +317 -2
- package/datagram.js.map +1 -1
- package/datagram_stream.d.ts +18 -0
- package/datagram_stream.d.ts.map +1 -0
- package/datagram_stream.js +67 -0
- package/datagram_stream.js.map +1 -0
- package/defined.test-util.d.ts +2 -0
- package/defined.test-util.d.ts.map +1 -0
- package/defined.test-util.js +7 -0
- package/defined.test-util.js.map +1 -0
- package/delivered.d.ts +75 -0
- package/delivered.d.ts.map +1 -0
- package/delivered.js +228 -0
- package/delivered.js.map +1 -0
- package/demand.d.ts +173 -0
- package/demand.d.ts.map +1 -0
- package/demand.js +582 -0
- package/demand.js.map +1 -0
- package/drops.d.ts +93 -0
- package/drops.d.ts.map +1 -0
- package/drops.js +283 -0
- package/drops.js.map +1 -0
- package/error.d.ts +120 -21
- package/error.d.ts.map +1 -1
- package/error.js +230 -38
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -3
- package/errors.js.map +1 -1
- package/fill.d.ts +174 -0
- package/fill.d.ts.map +1 -0
- package/fill.js +760 -0
- package/fill.js.map +1 -0
- package/flate/decoder.d.ts +2 -0
- package/flate/decoder.d.ts.map +1 -0
- package/flate/decoder.js +63 -0
- package/flate/decoder.js.map +1 -0
- package/flate/encoder.d.ts +2 -0
- package/flate/encoder.d.ts.map +1 -0
- package/flate/encoder.js +64 -0
- package/flate/encoder.js.map +1 -0
- package/flate/group.d.ts +34 -0
- package/flate/group.d.ts.map +1 -0
- package/flate/group.js +140 -0
- package/flate/group.js.map +1 -0
- package/frame.d.ts +80 -0
- package/frame.d.ts.map +1 -0
- package/frame.js +296 -0
- package/frame.js.map +1 -0
- package/frame.test-util.d.ts +5 -0
- package/frame.test-util.d.ts.map +1 -0
- package/frame.test-util.js +9 -0
- package/frame.test-util.js.map +1 -0
- package/group.d.ts +108 -45
- package/group.d.ts.map +1 -1
- package/group.js +1616 -308
- package/group.js.map +1 -1
- package/group_api.d.ts +7 -0
- package/group_api.d.ts.map +1 -0
- package/group_api.js +7 -0
- package/group_api.js.map +1 -0
- package/hop.d.ts +62 -76
- package/hop.d.ts.map +1 -1
- package/hop.js +92 -65
- package/hop.js.map +1 -1
- package/identity.d.ts +39 -0
- package/identity.d.ts.map +1 -0
- package/identity.js +47 -0
- package/identity.js.map +1 -0
- package/ietf/active_count.d.ts +2 -0
- package/ietf/active_count.d.ts.map +1 -0
- package/ietf/active_count.js +30 -0
- package/ietf/active_count.js.map +1 -0
- package/ietf/aliases.js +69 -36
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -55
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +1 -31
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +305 -144
- package/ietf/connection.js.map +1 -1
- package/ietf/datagram.d.ts +60 -0
- package/ietf/datagram.d.ts.map +1 -0
- package/ietf/datagram.js +152 -0
- package/ietf/datagram.js.map +1 -0
- package/ietf/error.d.ts +3 -3
- package/ietf/error.js +82 -101
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +93 -37
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -94
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +21 -31
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -172
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +12 -10
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -36
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -2
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +8 -20
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -15
- package/ietf/index.js.map +1 -1
- package/ietf/join.d.ts +7 -0
- package/ietf/join.d.ts.map +1 -0
- package/ietf/join.js +234 -0
- package/ietf/join.js.map +1 -0
- package/ietf/message.d.ts +18 -2
- package/ietf/message.d.ts.map +1 -1
- package/ietf/message.js +60 -41
- package/ietf/message.js.map +1 -1
- package/ietf/message.test-util.d.ts +6 -0
- package/ietf/message.test-util.d.ts.map +1 -0
- package/ietf/message.test-util.js +13 -0
- package/ietf/message.test-util.js.map +1 -0
- package/ietf/namespace.d.ts +19 -5
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -27
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +195 -33
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -179
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +25 -45
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -473
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +17 -2
- package/ietf/priority.d.ts.map +1 -1
- package/ietf/priority.js +19 -5
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +6 -5
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -49
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +25 -33
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -140
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +49 -72
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -185
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -601
- package/ietf/publisher.js.map +1 -1
- package/ietf/range.d.ts +2 -0
- package/ietf/range.d.ts.map +1 -0
- package/ietf/range.js +222 -0
- package/ietf/range.js.map +1 -0
- package/ietf/request.d.ts +6 -30
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -79
- package/ietf/request.js.map +1 -1
- package/ietf/request_stream.d.ts +1 -6
- package/ietf/request_stream.d.ts.map +1 -1
- package/ietf/request_stream.js +306 -17
- package/ietf/request_stream.js.map +1 -1
- package/ietf/session.d.ts +41 -0
- package/ietf/session.d.ts.map +1 -0
- package/ietf/session.js +65 -0
- package/ietf/session.js.map +1 -0
- package/ietf/setup.d.ts +5 -30
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -118
- package/ietf/setup.js.map +1 -1
- package/ietf/setup_options.d.ts +31 -0
- package/ietf/setup_options.d.ts.map +1 -0
- package/ietf/setup_options.js +138 -0
- package/ietf/setup_options.js.map +1 -0
- package/ietf/solicit.js +4 -15
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +52 -45
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -240
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +16 -79
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -202
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -537
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -28
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +27 -24
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -62
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +13 -42
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +22 -49
- package/ietf/version.js.map +1 -1
- package/implementation.d.ts +2 -0
- package/implementation.d.ts.map +1 -0
- package/implementation.js +5 -0
- package/implementation.js.map +1 -0
- package/index.d.ts +34 -19
- package/index.d.ts.map +1 -1
- package/index.js +19 -7
- package/index.js.map +1 -1
- package/internal.d.ts +1515 -67
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -80
- package/internal.js.map +1 -1
- package/ledger.d.ts +23 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +247 -0
- package/ledger.js.map +1 -0
- package/listing.d.ts +132 -0
- package/listing.d.ts.map +1 -0
- package/listing.js +486 -0
- package/listing.js.map +1 -0
- package/lite/announce.d.ts +127 -66
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -159
- package/lite/announce.js.map +1 -1
- package/lite/announce_stream.d.ts +2 -0
- package/lite/announce_stream.d.ts.map +1 -0
- package/lite/announce_stream.js +92 -0
- package/lite/announce_stream.js.map +1 -0
- package/lite/answer.d.ts +22 -0
- package/lite/answer.d.ts.map +1 -0
- package/lite/answer.js +301 -0
- package/lite/answer.js.map +1 -0
- package/lite/auth.d.ts +45 -0
- package/lite/auth.d.ts.map +1 -0
- package/lite/auth.js +204 -0
- package/lite/auth.js.map +1 -0
- package/lite/compat.d.ts +31 -0
- package/lite/compat.d.ts.map +1 -0
- package/lite/compat.js +86 -0
- package/lite/compat.js.map +1 -0
- package/lite/connection.d.ts +1 -45
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +360 -78
- package/lite/connection.js.map +1 -1
- package/lite/datagram-end.d.ts +26 -0
- package/lite/datagram-end.d.ts.map +1 -0
- package/lite/datagram-end.js +30 -0
- package/lite/datagram-end.js.map +1 -0
- package/lite/datagram.d.ts +73 -8
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +144 -10
- package/lite/datagram.js.map +1 -1
- package/lite/duration.d.ts +6 -0
- package/lite/duration.d.ts.map +1 -0
- package/lite/duration.js +14 -0
- package/lite/duration.js.map +1 -0
- package/lite/error.d.ts +9 -0
- package/lite/error.d.ts.map +1 -0
- package/lite/error.js +24 -0
- package/lite/error.js.map +1 -0
- package/lite/fills.d.ts +162 -0
- package/lite/fills.d.ts.map +1 -0
- package/lite/fills.js +486 -0
- package/lite/fills.js.map +1 -0
- package/lite/fit.d.ts +49 -0
- package/lite/fit.d.ts.map +1 -0
- package/lite/fit.js +305 -0
- package/lite/fit.js.map +1 -0
- package/lite/goaway.d.ts +2 -2
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -14
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +67 -16
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -31
- package/lite/group.js.map +1 -1
- package/lite/identity.d.ts +25 -0
- package/lite/identity.d.ts.map +1 -0
- package/lite/identity.js +79 -0
- package/lite/identity.js.map +1 -0
- package/lite/index.d.ts +14 -13
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -2
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +10 -2
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -45
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +9 -2
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +11 -106
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts +2 -2
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -1
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +10 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +2548 -438
- package/lite/publisher.js.map +1 -1
- package/lite/routed.d.ts +59 -0
- package/lite/routed.d.ts.map +1 -0
- package/lite/routed.js +564 -0
- package/lite/routed.js.map +1 -0
- package/lite/session.d.ts +2 -28
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -100
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +32 -5
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -22
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +5 -11
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +5 -2
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +478 -78
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -143
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +7 -44
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +3290 -516
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +27 -12
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -38
- package/lite/track.js.map +1 -1
- package/lite/tracks.d.ts +55 -0
- package/lite/tracks.d.ts.map +1 -0
- package/lite/tracks.js +114 -0
- package/lite/tracks.js.map +1 -0
- package/lite/version.d.ts +132 -24
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +378 -34
- package/lite/version.js.map +1 -1
- package/meta.d.ts +77 -0
- package/meta.d.ts.map +1 -0
- package/meta.js +130 -0
- package/meta.js.map +1 -0
- package/meta_api.d.ts +7 -0
- package/meta_api.d.ts.map +1 -0
- package/meta_api.js +7 -0
- package/meta_api.js.map +1 -0
- package/mint.d.ts +28 -0
- package/mint.d.ts.map +1 -0
- package/mint.js +66 -0
- package/mint.js.map +1 -0
- package/open.d.ts +63 -0
- package/open.d.ts.map +1 -0
- package/open.js +250 -0
- package/open.js.map +1 -0
- package/origin.d.ts +394 -142
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -687
- package/origin.js.map +1 -1
- package/package.json +8 -13
- package/path.d.ts +51 -51
- package/path.d.ts.map +1 -1
- package/path.js +210 -58
- package/path.js.map +1 -1
- package/payload.d.ts +33 -0
- package/payload.d.ts.map +1 -0
- package/payload.js +65 -0
- package/payload.js.map +1 -0
- package/prefix.d.ts +152 -0
- package/prefix.d.ts.map +1 -0
- package/prefix.js +349 -0
- package/prefix.js.map +1 -0
- package/priority.d.ts +8 -0
- package/priority.d.ts.map +1 -0
- package/priority.js +185 -0
- package/priority.js.map +1 -0
- package/queue.d.ts +2 -0
- package/queue.d.ts.map +1 -0
- package/queue.js +46 -0
- package/queue.js.map +1 -0
- package/ranges.d.ts +36 -0
- package/ranges.d.ts.map +1 -0
- package/ranges.js +312 -0
- package/ranges.js.map +1 -0
- package/rescale.d.ts +24 -0
- package/rescale.d.ts.map +1 -0
- package/rescale.js +39 -0
- package/rescale.js.map +1 -0
- package/resume.d.ts +55 -0
- package/resume.d.ts.map +1 -0
- package/resume.js +4173 -0
- package/resume.js.map +1 -0
- package/resume.test-util.d.ts +2 -0
- package/resume.test-util.d.ts.map +1 -0
- package/resume.test-util.js +25 -0
- package/resume.test-util.js.map +1 -0
- package/skips.d.ts +48 -0
- package/skips.d.ts.map +1 -0
- package/skips.js +182 -0
- package/skips.js.map +1 -0
- package/stream.d.ts +78 -40
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -93
- package/stream.js.map +1 -1
- package/subscription.test-util.d.ts +2 -0
- package/subscription.test-util.d.ts.map +1 -0
- package/subscription.test-util.js +49 -0
- package/subscription.test-util.js.map +1 -0
- package/tail.d.ts +23 -14
- package/tail.d.ts.map +1 -1
- package/tail.js +224 -98
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -92
- package/time.js.map +1 -1
- package/timed.d.ts +21 -0
- package/timed.d.ts.map +1 -0
- package/timed.js +2 -0
- package/timed.js.map +1 -0
- package/track.d.ts +578 -246
- package/track.d.ts.map +1 -1
- package/track.js +7306 -772
- package/track.js.map +1 -1
- package/track_api.d.ts +7 -0
- package/track_api.d.ts.map +1 -0
- package/track_api.js +7 -0
- package/track_api.js.map +1 -0
- package/util/abort.d.ts +1 -0
- package/util/abort.d.ts.map +1 -1
- package/util/abort.js +23 -2
- package/util/abort.js.map +1 -1
- package/util/announce.d.ts +4 -0
- package/util/announce.d.ts.map +1 -0
- package/util/announce.js +11 -0
- package/util/announce.js.map +1 -0
- package/util/bigint.d.ts +3 -0
- package/util/bigint.d.ts.map +1 -0
- package/util/bigint.js +8 -0
- package/util/bigint.js.map +1 -0
- package/util/change.d.ts +12 -0
- package/util/change.d.ts.map +1 -0
- package/util/change.js +18 -0
- package/util/change.js.map +1 -0
- package/util/deadline.d.ts +2 -0
- package/util/deadline.d.ts.map +1 -0
- package/util/deadline.js +108 -0
- package/util/deadline.js.map +1 -0
- package/util/decode_error.d.ts +3 -0
- package/util/decode_error.d.ts.map +1 -0
- package/util/decode_error.js +11 -0
- package/util/decode_error.js.map +1 -0
- package/util/demand.d.ts +8 -0
- package/util/demand.d.ts.map +1 -0
- package/util/demand.js +24 -0
- package/util/demand.js.map +1 -0
- package/util/given_up.d.ts +2 -0
- package/util/given_up.d.ts.map +1 -0
- package/util/given_up.js +101 -0
- package/util/given_up.js.map +1 -0
- package/util/hex.d.ts +6 -0
- package/util/hex.d.ts.map +1 -1
- package/util/hex.js +19 -5
- package/util/hex.js.map +1 -1
- package/util/key.d.ts +15 -0
- package/util/key.d.ts.map +1 -0
- package/util/key.js +38 -0
- package/util/key.js.map +1 -0
- package/util/limits.d.ts +2 -0
- package/util/limits.d.ts.map +1 -0
- package/util/limits.js +76 -0
- package/util/limits.js.map +1 -0
- package/util/observed.d.ts +23 -0
- package/util/observed.d.ts.map +1 -0
- package/util/observed.js +122 -0
- package/util/observed.js.map +1 -0
- package/util/sorted.d.ts +2 -0
- package/util/sorted.d.ts.map +1 -0
- package/util/sorted.js +149 -0
- package/util/sorted.js.map +1 -0
- package/util/timeout.d.ts +2 -1
- package/util/timeout.d.ts.map +1 -1
- package/util/timeout.js +13 -10
- package/util/timeout.js.map +1 -1
- package/util/timer.d.ts +2 -0
- package/util/timer.d.ts.map +1 -0
- package/util/timer.js +19 -0
- package/util/timer.js.map +1 -0
- package/util/u64.js +0 -1
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -2
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -2
- package/util/varint.js.map +1 -1
- package/util/watch.d.ts +8 -0
- package/util/watch.d.ts.map +1 -0
- package/util/watch.js +38 -0
- package/util/watch.js.map +1 -0
- package/util/yield.d.ts +2 -0
- package/util/yield.d.ts.map +1 -0
- package/util/yield.js +31 -0
- package/util/yield.js.map +1 -0
- package/varint.d.ts +0 -29
- package/varint.d.ts.map +1 -1
- package/varint.js +7 -29
- package/varint.js.map +1 -1
- package/varint_api.d.ts +7 -0
- package/varint_api.d.ts.map +1 -0
- package/varint_api.js +7 -0
- package/varint_api.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/window.d.ts +570 -0
- package/window.d.ts.map +1 -0
- package/window.js +1677 -0
- package/window.js.map +1 -0
- package/wire.d.ts +150 -35
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -1
- package/wire.js.map +1 -1
- package/connection/established.d.ts +0 -53
- package/connection/established.d.ts.map +0 -1
- package/connection/established.js +0 -3
- package/connection/established.js.map +0 -1
- package/ietf/adapter.d.ts +0 -75
- package/ietf/adapter.d.ts.map +0 -1
- package/ietf/adapter.js +0 -700
- package/ietf/adapter.js.map +0 -1
- package/lite/datagram_stream.d.ts +0 -8
- package/lite/datagram_stream.d.ts.map +0 -1
- package/lite/datagram_stream.js +0 -44
- package/lite/datagram_stream.js.map +0 -1
- package/lite/fetch.d.ts +0 -28
- package/lite/fetch.d.ts.map +0 -1
- package/lite/fetch.js +0 -79
- package/lite/fetch.js.map +0 -1
- package/util/log.d.ts +0 -5
- package/util/log.d.ts.map +0 -1
- package/util/log.js +0 -17
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -19
- package/zod.js.map +0 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a URL dials, parsed once so every decision about it reads the host the transport
|
|
3
|
+
* connects to: GOAWAY redirect checks, the dial itself, and what logs show.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors `rs/moq-net/src/reconnect/redirect.rs`.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Parse where `url` dials. Throws a `TypeError` for a URL with no host, which no transport
|
|
11
|
+
* here can dial.
|
|
12
|
+
*
|
|
13
|
+
* Only the special schemes (`http`, `https`, `ws`, `wss`) have their host parsed by the URL
|
|
14
|
+
* parser; any other scheme keeps it opaque, so `moql://127.1` reads `127.1` while the dial,
|
|
15
|
+
* made over https, connects to 127.0.0.1. Reading the host back through https makes both the
|
|
16
|
+
* same: an address in any spelling the dial accepts is that address here.
|
|
17
|
+
*/
|
|
18
|
+
export function parse(url) {
|
|
19
|
+
if (url.host === "")
|
|
20
|
+
throw new TypeError(`${url.protocol} URL has no host`);
|
|
21
|
+
const scheme = url.protocol.slice(0, -1);
|
|
22
|
+
const special = SPECIAL.has(scheme);
|
|
23
|
+
// Rebuilt rather than assigned, since the URL setter refuses a change from a non-special
|
|
24
|
+
// scheme to a special one.
|
|
25
|
+
const dial = special ? url : new URL(`https:${url.href.slice(url.protocol.length)}`);
|
|
26
|
+
const port = url.port === "" ? defaultPort(scheme) : Number(url.port);
|
|
27
|
+
return { scheme, host: parseHost(dial.hostname), port, url: dial };
|
|
28
|
+
}
|
|
29
|
+
const SPECIAL = new Set(["http", "https", "ws", "wss"]);
|
|
30
|
+
function defaultPort(scheme) {
|
|
31
|
+
return scheme === "http" || scheme === "ws" ? 80 : 443;
|
|
32
|
+
}
|
|
33
|
+
// The URL parser leaves a special scheme's host canonical: an IPv4 address as a dotted quad,
|
|
34
|
+
// an IPv6 one bracketed in lowercase hex without a zone or dotted tail, and a name lowercased.
|
|
35
|
+
function parseHost(hostname) {
|
|
36
|
+
if (hostname.startsWith("[")) {
|
|
37
|
+
const segments = parseIpv6(hostname.slice(1, -1));
|
|
38
|
+
if (!segments)
|
|
39
|
+
throw new TypeError(`unparsable IPv6 host: ${hostname}`);
|
|
40
|
+
return { kind: "ipv6", segments };
|
|
41
|
+
}
|
|
42
|
+
const parts = hostname.split(".");
|
|
43
|
+
if (parts.length === 4 && parts.every((part) => /^\d{1,3}$/.test(part))) {
|
|
44
|
+
return { kind: "ipv4", octets: parts.map(Number) };
|
|
45
|
+
}
|
|
46
|
+
return { kind: "name", name: hostname };
|
|
47
|
+
}
|
|
48
|
+
function parseIpv6(text) {
|
|
49
|
+
const halves = text.split("::");
|
|
50
|
+
const words = (part) => (part === "" ? [] : part.split(":"));
|
|
51
|
+
const head = words(halves[0] ?? "");
|
|
52
|
+
const rest = halves.length === 2 ? words(halves[1] ?? "") : [];
|
|
53
|
+
const all = [...head, ...Array(8 - head.length - rest.length).fill("0"), ...rest];
|
|
54
|
+
const segments = all.map((word) => Number.parseInt(word, 16));
|
|
55
|
+
return segments.length === 8 && !segments.some(Number.isNaN) ? segments : undefined;
|
|
56
|
+
}
|
|
57
|
+
/** Whether two endpoints dial the same host, whatever their scheme or port. */
|
|
58
|
+
export function sameHost(a, b) {
|
|
59
|
+
// The dial URL's host is canonical, so equal hosts spell it the same.
|
|
60
|
+
return a.url.hostname === b.url.hostname;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Formats an endpoint for logs and errors as scheme, host, and port only.
|
|
64
|
+
*
|
|
65
|
+
* A URL can carry a credential in its userinfo, query, or path (raw QUIC has no headers, so a
|
|
66
|
+
* token can ride as a path segment). Dropping all three rather than redacting known-secret
|
|
67
|
+
* spellings is deliberate: a denylist only covers the credentials that exist today.
|
|
68
|
+
*/
|
|
69
|
+
export function show(endpoint) {
|
|
70
|
+
return `${endpoint.scheme}://${endpoint.url.hostname}:${endpoint.port}`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether an endpoint says it names something only reachable from this host or network. A
|
|
74
|
+
* judgement about the address it spells, not about where a dial lands: a name is dialed,
|
|
75
|
+
* never resolved here, so `false` means "not local on its face", never "verified remote".
|
|
76
|
+
*/
|
|
77
|
+
export function isLocal({ host }) {
|
|
78
|
+
switch (host.kind) {
|
|
79
|
+
case "ipv4":
|
|
80
|
+
return isLocalV4(host.octets);
|
|
81
|
+
case "ipv6":
|
|
82
|
+
return isLocalV6(host.segments);
|
|
83
|
+
case "name": {
|
|
84
|
+
// A trailing dot names the same host from the root.
|
|
85
|
+
const name = host.name.endsWith(".") ? host.name.slice(0, -1) : host.name;
|
|
86
|
+
return name === "localhost" || name.endsWith(".localhost");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function isLocalV4([a, b, c, d]) {
|
|
91
|
+
return (a === 127 ||
|
|
92
|
+
a === 10 ||
|
|
93
|
+
(a === 172 && b >= 16 && b <= 31) ||
|
|
94
|
+
(a === 192 && b === 168) ||
|
|
95
|
+
(a === 169 && b === 254) ||
|
|
96
|
+
(a === 0 && b === 0 && c === 0 && d === 0));
|
|
97
|
+
}
|
|
98
|
+
function isLocalV6(segments) {
|
|
99
|
+
// An IPv4-mapped address reaches the same host as the v4 it wraps.
|
|
100
|
+
if (segments.slice(0, 5).every((s) => s === 0) && segments[5] === 0xffff) {
|
|
101
|
+
const [hi = 0, lo = 0] = segments.slice(6);
|
|
102
|
+
return isLocalV4([hi >> 8, hi & 0xff, lo >> 8, lo & 0xff]);
|
|
103
|
+
}
|
|
104
|
+
const first = segments[0] ?? 0;
|
|
105
|
+
const zeroPrefix = segments.slice(0, 7).every((s) => s === 0);
|
|
106
|
+
const last = segments[7] ?? 0;
|
|
107
|
+
return (
|
|
108
|
+
// Loopback (::1) and unspecified (::).
|
|
109
|
+
(zeroPrefix && (last === 1 || last === 0)) ||
|
|
110
|
+
// Unique local (fc00::/7) and link local (fe80::/10).
|
|
111
|
+
(first & 0xfe00) === 0xfc00 ||
|
|
112
|
+
(first & 0xffc0) === 0xfe80);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=endpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/connection/endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsBH;;;;;;;;GAQG;AACH,MAAM,UAAU,KAAK,CAAC,GAAQ;IAC7B,IAAI,GAAG,CAAC,IAAI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AC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO;IACN,uCAAuC;IACvC,CAAC,UAAU,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC;QAC1C,sDAAsD;QACtD,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,MAAM;QAC3B,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,MAAM,CAC3B,CAAC;AACH,CAAC","sourcesContent":["/**\n * Where a URL dials, parsed once so every decision about it reads the host the transport\n * connects to: GOAWAY redirect checks, the dial itself, and what logs show.\n *\n * Mirrors `rs/moq-net/src/reconnect/redirect.rs`.\n *\n * @module\n */\n\n/** A host as a dial reads it: an IPv4 or IPv6 literal, or a name left to DNS. */\ntype Host =\n\t| { readonly kind: \"ipv4\"; readonly octets: readonly number[] }\n\t| { readonly kind: \"ipv6\"; readonly segments: readonly number[] }\n\t| { readonly kind: \"name\"; readonly name: string };\n\n/** Where a URL dials: its scheme, its host, and its port, which defaults by scheme. */\nexport interface Endpoint {\n\t/** The scheme without its colon, as written (`moql`, not the `https` a browser dials it over). */\n\treadonly scheme: string;\n\treadonly host: Host;\n\treadonly port: number;\n\t/**\n\t * The URL a browser transport dials. A raw QUIC `moqt:` or `moql:` URL is reached over\n\t * WebTransport with its scheme swapped for https (draft-ietf-moq-transport-18 §3.1.3); the\n\t * CONNECT carries the scheme, so a server refuses the raw one.\n\t */\n\treadonly url: URL;\n}\n\n/**\n * Parse where `url` dials. Throws a `TypeError` for a URL with no host, which no transport\n * here can dial.\n *\n * Only the special schemes (`http`, `https`, `ws`, `wss`) have their host parsed by the URL\n * parser; any other scheme keeps it opaque, so `moql://127.1` reads `127.1` while the dial,\n * made over https, connects to 127.0.0.1. Reading the host back through https makes both the\n * same: an address in any spelling the dial accepts is that address here.\n */\nexport function parse(url: URL): Endpoint {\n\tif (url.host === \"\") throw new TypeError(`${url.protocol} URL has no host`);\n\tconst scheme = url.protocol.slice(0, -1);\n\tconst special = SPECIAL.has(scheme);\n\t// Rebuilt rather than assigned, since the URL setter refuses a change from a non-special\n\t// scheme to a special one.\n\tconst dial = special ? url : new URL(`https:${url.href.slice(url.protocol.length)}`);\n\tconst port = url.port === \"\" ? defaultPort(scheme) : Number(url.port);\n\treturn { scheme, host: parseHost(dial.hostname), port, url: dial };\n}\n\nconst SPECIAL = new Set([\"http\", \"https\", \"ws\", \"wss\"]);\n\nfunction defaultPort(scheme: string): number {\n\treturn scheme === \"http\" || scheme === \"ws\" ? 80 : 443;\n}\n\n// The URL parser leaves a special scheme's host canonical: an IPv4 address as a dotted quad,\n// an IPv6 one bracketed in lowercase hex without a zone or dotted tail, and a name lowercased.\nfunction parseHost(hostname: string): Host {\n\tif (hostname.startsWith(\"[\")) {\n\t\tconst segments = parseIpv6(hostname.slice(1, -1));\n\t\tif (!segments) throw new TypeError(`unparsable IPv6 host: ${hostname}`);\n\t\treturn { kind: \"ipv6\", segments };\n\t}\n\tconst parts = hostname.split(\".\");\n\tif (parts.length === 4 && parts.every((part) => /^\\d{1,3}$/.test(part))) {\n\t\treturn { kind: \"ipv4\", octets: parts.map(Number) };\n\t}\n\treturn { kind: \"name\", name: hostname };\n}\n\nfunction parseIpv6(text: string): number[] | undefined {\n\tconst halves = text.split(\"::\");\n\tconst words = (part: string) => (part === \"\" ? [] : part.split(\":\"));\n\tconst head = words(halves[0] ?? \"\");\n\tconst rest = halves.length === 2 ? words(halves[1] ?? \"\") : [];\n\tconst all = [...head, ...Array<string>(8 - head.length - rest.length).fill(\"0\"), ...rest];\n\tconst segments = all.map((word) => Number.parseInt(word, 16));\n\treturn segments.length === 8 && !segments.some(Number.isNaN) ? segments : undefined;\n}\n\n/** Whether two endpoints dial the same host, whatever their scheme or port. */\nexport function sameHost(a: Endpoint, b: Endpoint): boolean {\n\t// The dial URL's host is canonical, so equal hosts spell it the same.\n\treturn a.url.hostname === b.url.hostname;\n}\n\n/**\n * Formats an endpoint for logs and errors as scheme, host, and port only.\n *\n * A URL can carry a credential in its userinfo, query, or path (raw QUIC has no headers, so a\n * token can ride as a path segment). Dropping all three rather than redacting known-secret\n * spellings is deliberate: a denylist only covers the credentials that exist today.\n */\nexport function show(endpoint: Endpoint): string {\n\treturn `${endpoint.scheme}://${endpoint.url.hostname}:${endpoint.port}`;\n}\n\n/**\n * Whether an endpoint says it names something only reachable from this host or network. A\n * judgement about the address it spells, not about where a dial lands: a name is dialed,\n * never resolved here, so `false` means \"not local on its face\", never \"verified remote\".\n */\nexport function isLocal({ host }: Endpoint): boolean {\n\tswitch (host.kind) {\n\t\tcase \"ipv4\":\n\t\t\treturn isLocalV4(host.octets);\n\t\tcase \"ipv6\":\n\t\t\treturn isLocalV6(host.segments);\n\t\tcase \"name\": {\n\t\t\t// A trailing dot names the same host from the root.\n\t\t\tconst name = host.name.endsWith(\".\") ? host.name.slice(0, -1) : host.name;\n\t\t\treturn name === \"localhost\" || name.endsWith(\".localhost\");\n\t\t}\n\t}\n}\n\nfunction isLocalV4([a, b, c, d]: readonly number[]): boolean {\n\treturn (\n\t\ta === 127 ||\n\t\ta === 10 ||\n\t\t(a === 172 && b >= 16 && b <= 31) ||\n\t\t(a === 192 && b === 168) ||\n\t\t(a === 169 && b === 254) ||\n\t\t(a === 0 && b === 0 && c === 0 && d === 0)\n\t);\n}\n\nfunction isLocalV6(segments: readonly number[]): boolean {\n\t// An IPv4-mapped address reaches the same host as the v4 it wraps.\n\tif (segments.slice(0, 5).every((s) => s === 0) && segments[5] === 0xffff) {\n\t\tconst [hi = 0, lo = 0] = segments.slice(6);\n\t\treturn isLocalV4([hi >> 8, hi & 0xff, lo >> 8, lo & 0xff]);\n\t}\n\tconst first = segments[0] ?? 0;\n\tconst zeroPrefix = segments.slice(0, 7).every((s) => s === 0);\n\tconst last = segments[7] ?? 0;\n\treturn (\n\t\t// Loopback (::1) and unspecified (::).\n\t\t(zeroPrefix && (last === 1 || last === 0)) ||\n\t\t// Unique local (fc00::/7) and link local (fe80::/10).\n\t\t(first & 0xfe00) === 0xfc00 ||\n\t\t(first & 0xffc0) === 0xfe80\n\t);\n}\n"]}
|
package/connection/forward.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Feeds a session's announced routes into an origin; the `consume` connect option.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** Why a connection refuses the removed `discovery` option rather than ignoring it. */
|
|
7
|
+
export declare const DISCOVERY_REMOVED = "the discovery option is removed: a session asks only about watched prefixes and turns blind if the relay refuses";
|
|
2
8
|
//# sourceMappingURL=forward.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forward.d.ts","sourceRoot":"","sources":["../../src/connection/forward.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"forward.d.ts","sourceRoot":"","sources":["../../src/connection/forward.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,uFAAuF;AACvF,eAAO,MAAM,iBAAiB,qHACqF,CAAC"}
|
package/connection/forward.js
CHANGED
|
@@ -1,128 +1,312 @@
|
|
|
1
|
-
/* @ts-self-types="./forward.d.ts" */
|
|
2
1
|
/**
|
|
3
2
|
* Feeds a session's announced routes into an origin; the `consume` connect option.
|
|
4
3
|
*
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
6
|
+
import { Duration } from "@moq/clock";
|
|
7
7
|
import { race } from "@moq/signals";
|
|
8
|
-
import {
|
|
8
|
+
import { routesEqual } from "../hop.js";
|
|
9
|
+
import { coveringPrefixes } from "../internal.js";
|
|
9
10
|
import * as Path from "../path.js";
|
|
11
|
+
import { after } from "../util/timer.js";
|
|
10
12
|
import { wireOf } from "../wire.js";
|
|
13
|
+
/** Why a connection refuses the removed `discovery` option rather than ignoring it. */
|
|
14
|
+
export const DISCOVERY_REMOVED = "the discovery option is removed: a session asks only about watched prefixes and turns blind if the relay refuses";
|
|
15
|
+
/** How long an announce request outlives its last watcher, so a watcher torn down and rebuilt reuses it. */
|
|
16
|
+
const LINGER = Duration.millis(2000);
|
|
17
|
+
function keyOf(prefix, route) {
|
|
18
|
+
return route.claimed && route.identity !== undefined ? `${prefix}\u0000${route.identity}` : prefix;
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* Wire a session into `origin` for the session's lifetime: forward the peer's announced
|
|
13
|
-
* routes
|
|
14
|
-
* subscriptions.
|
|
22
|
+
* routes under the prefixes the origin's readers watch, and answer the origin's open
|
|
23
|
+
* requests with blind subscriptions.
|
|
24
|
+
*
|
|
25
|
+
* Discovery is lazy. One announce request opens per prefix in the origin's covering set of
|
|
26
|
+
* watches (`announced(scope)` and every `request(path)`) that no open request
|
|
27
|
+
* already covers, and closes {@link LINGER} after nothing at or beneath its prefix is watched.
|
|
28
|
+
* A narrower watch rides an open broader request, and a narrower request already open stays
|
|
29
|
+
* open until the broader one covering it goes, so neither takes the other's routes over
|
|
30
|
+
* before it has synced, which not every version can tell. A route both report is inserted once and
|
|
31
|
+
* driven by its first reporter; if it changes hands anyway (a request failing), it restarts
|
|
32
|
+
* unless one identity proves both requests saw one stream.
|
|
33
|
+
*
|
|
34
|
+
* A peer that refuses overlapping requests gets exclusive discovery instead: a broader request
|
|
35
|
+
* closes the narrower ones beneath it, and the session keeps it off the wire until they have
|
|
36
|
+
* left. The routes a closed request carried go with it, and come back once the broader request
|
|
37
|
+
* reports them.
|
|
38
|
+
*
|
|
39
|
+
* A lite-07 claim serves only the paths the session's floors still certify beneath it, asked
|
|
40
|
+
* per request, and asked again for every open request when a floor moves that with no route
|
|
41
|
+
* changing.
|
|
15
42
|
*
|
|
16
|
-
* Each active announcement inserts a route covering the announced prefix, served
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* re-populates it.
|
|
43
|
+
* Each active announcement inserts a route covering the announced prefix, served lazily
|
|
44
|
+
* through this connection, so nothing touches the wire until somebody requests a path
|
|
45
|
+
* under it. A retraction removes the entry, and so does the session dying, which is what
|
|
46
|
+
* scopes remote routes to the session that announced them. A reconnect wires a fresh
|
|
47
|
+
* session to the same origin and re-opens whatever is still watched.
|
|
22
48
|
*
|
|
23
|
-
*
|
|
24
|
-
* requests
|
|
49
|
+
* A peer that refuses or resets an announce request downgrades the whole session to blind
|
|
50
|
+
* answers: plain requests subscribe through it without waiting for an announcement, and
|
|
51
|
+
* later watches open nothing on it.
|
|
25
52
|
*
|
|
26
53
|
* @internal
|
|
27
54
|
*/
|
|
28
55
|
export function forwardAnnounced(conn, origin) {
|
|
29
56
|
const originWire = wireOf(origin);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
57
|
+
const session = wireOf(conn);
|
|
58
|
+
const exclusive = session.exclusive;
|
|
59
|
+
// Reassigned on a downgrade, so the origin stops counting this session as discovering.
|
|
60
|
+
// Called through a closure so the session's death always detaches the current one.
|
|
61
|
+
let detach = originWire.attach(true);
|
|
34
62
|
let dead = false;
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
detach();
|
|
39
|
-
});
|
|
63
|
+
let blind = false;
|
|
64
|
+
const interests = new Map();
|
|
65
|
+
const routes = new Map();
|
|
40
66
|
void serveRequests(conn, origin);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
const report = (interest, event) => {
|
|
68
|
+
const { prefix, route } = event;
|
|
69
|
+
const key = keyOf(prefix, route);
|
|
70
|
+
if (event.kind === "end" || event.kind === "offline") {
|
|
71
|
+
unreport(interest, key, event.kind === "end");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
interest.reported.add(key);
|
|
75
|
+
const existing = routes.get(key);
|
|
76
|
+
if (!existing) {
|
|
77
|
+
const handle = originWire.receive(prefix, route);
|
|
78
|
+
routes.set(key, { prefix, handle, reporters: new Map([[interest, route]]) });
|
|
79
|
+
void drive(handle, conn);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const joined = existing.reporters.has(interest);
|
|
83
|
+
existing.reporters.set(interest, route);
|
|
84
|
+
// Another request covering the prefix only holds it; the first reporter drives it.
|
|
85
|
+
if (joined && existing.reporters.keys().next().value === interest) {
|
|
86
|
+
updateReported(existing, route, event.kind === "restart");
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Bring the handle up to its driving reporter's route: a fresh route for another publisher
|
|
91
|
+
* identity or epoch, so nothing resolved through the old one is joined again, and an in-place
|
|
92
|
+
* update otherwise.
|
|
93
|
+
*/
|
|
94
|
+
const updateReported = (existing, route, restart) => {
|
|
95
|
+
const current = wireOf(existing.handle).info;
|
|
96
|
+
if (restart || route.identity !== current?.identity || route.epoch !== current?.epoch) {
|
|
97
|
+
// Inserted before the old one leaves, so local readers see one restart rather than
|
|
98
|
+
// an end and a start.
|
|
99
|
+
const handle = originWire.receive(existing.prefix, route);
|
|
100
|
+
existing.handle.close();
|
|
101
|
+
existing.handle = handle;
|
|
102
|
+
void drive(handle, conn);
|
|
103
|
+
}
|
|
104
|
+
else if (!routesEqual(current, route)) {
|
|
105
|
+
wireOf(existing.handle).update(route);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/** Stop `interest` reporting the route `key` names, which its peer `ended` rather than lost. */
|
|
109
|
+
const unreport = (interest, key, ended = false) => {
|
|
110
|
+
interest.reported.delete(key);
|
|
111
|
+
const existing = routes.get(key);
|
|
112
|
+
if (!existing)
|
|
113
|
+
return;
|
|
114
|
+
const driving = existing.reporters.keys().next().value === interest;
|
|
115
|
+
if (!existing.reporters.delete(interest))
|
|
116
|
+
return;
|
|
117
|
+
const next = existing.reporters.values().next();
|
|
118
|
+
if (next.done) {
|
|
119
|
+
routes.delete(key);
|
|
120
|
+
if (ended)
|
|
121
|
+
wireOf(existing.handle).end();
|
|
122
|
+
else
|
|
123
|
+
existing.handle.close();
|
|
124
|
+
}
|
|
125
|
+
else if (driving) {
|
|
126
|
+
// The next request takes over driving. Without an identity nothing proves it reports
|
|
127
|
+
// the stream the handle serves, so the route restarts rather than stitch two together.
|
|
128
|
+
updateReported(existing, next.value, next.value.identity === undefined);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const downgrade = (failure) => {
|
|
132
|
+
if (blind)
|
|
133
|
+
return;
|
|
134
|
+
blind = true;
|
|
135
|
+
// Plain requests can still use this session's blind answers. Announcement followers
|
|
136
|
+
// keep waiting for a source that can discover their path.
|
|
137
|
+
console.warn("broadcast discovery failed; broadcasts resolve on request only.", failure);
|
|
138
|
+
detach();
|
|
139
|
+
detach = originWire.attach(false);
|
|
140
|
+
};
|
|
141
|
+
const open = (prefix) => {
|
|
142
|
+
if (exclusive) {
|
|
143
|
+
for (const [other, narrower] of interests) {
|
|
144
|
+
if (other === prefix || !Path.hasPrefix(prefix, other))
|
|
145
|
+
continue;
|
|
146
|
+
interests.delete(other);
|
|
147
|
+
narrower.closing = true;
|
|
148
|
+
narrower.linger?.();
|
|
149
|
+
narrower.linger = undefined;
|
|
150
|
+
narrower.announced.close();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Hidden and covering routes are mirrored too; each local reader opts in on its own.
|
|
154
|
+
const interest = {
|
|
155
|
+
announced: conn.routes(prefix, { hidden: true, covering: true, claims: true }),
|
|
156
|
+
reported: new Set(),
|
|
157
|
+
closing: false,
|
|
158
|
+
held: new Map(),
|
|
159
|
+
};
|
|
160
|
+
interests.set(prefix, interest);
|
|
161
|
+
// The origin's readers under the prefix wait on this request's initial set. Released
|
|
162
|
+
// once the session stream has synced, which it reports only after the last of those
|
|
163
|
+
// events is reported here. A closing stream also reads as synced, but a failure is not
|
|
164
|
+
// an answer: the loop below releases it with the downgrade, in one step.
|
|
165
|
+
const snapshot = originWire.snapshot(prefix);
|
|
166
|
+
const synced = interest.announced.synced.subscribe((synced) => {
|
|
167
|
+
if (synced && interest.announced.closed.peek() === undefined)
|
|
168
|
+
snapshot();
|
|
169
|
+
});
|
|
170
|
+
// A request with no initial set to wait for is synced before the listener exists.
|
|
171
|
+
if (interest.announced.synced.peek())
|
|
172
|
+
snapshot();
|
|
52
173
|
void (async () => {
|
|
53
174
|
let failure;
|
|
54
175
|
try {
|
|
55
176
|
for (;;) {
|
|
56
|
-
const event = await announced.next();
|
|
177
|
+
const event = await interest.announced.next();
|
|
57
178
|
if (!event)
|
|
58
179
|
break;
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
if (isActive(event.kind)) {
|
|
62
|
-
const existing = inserted.get(event.prefix);
|
|
63
|
-
if (existing) {
|
|
64
|
-
existing.update(event.route);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const handle = originWire.receive(event.prefix, event.route);
|
|
68
|
-
inserted.set(event.prefix, handle);
|
|
69
|
-
void drive(handle, conn);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
const handle = inserted.get(event.prefix);
|
|
74
|
-
inserted.delete(event.prefix);
|
|
75
|
-
handle?.close();
|
|
76
|
-
}
|
|
180
|
+
if (originWire.accepts(event.prefix))
|
|
181
|
+
report(interest, event);
|
|
77
182
|
}
|
|
78
183
|
}
|
|
79
184
|
catch (err) {
|
|
80
|
-
// The session died mid-stream, or the
|
|
81
|
-
// cleanup below retracts everything this stream fed either way.
|
|
185
|
+
// The session died mid-stream, or the peer refused or reset the request.
|
|
82
186
|
failure = err;
|
|
83
187
|
}
|
|
84
188
|
finally {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
189
|
+
synced();
|
|
190
|
+
snapshot();
|
|
191
|
+
for (const reported of [...interest.reported])
|
|
192
|
+
unreport(interest, reported);
|
|
193
|
+
interest.announced.close();
|
|
194
|
+
interest.linger?.();
|
|
195
|
+
if (interests.get(prefix) === interest)
|
|
196
|
+
interests.delete(prefix);
|
|
197
|
+
if (!dead && !interest.closing)
|
|
198
|
+
downgrade(failure);
|
|
199
|
+
// What this request held now settles on its own, unless it is watched again.
|
|
200
|
+
for (const [held, narrower] of interest.held) {
|
|
201
|
+
if (!dead && interests.get(held) === narrower && !beneath.has(held))
|
|
202
|
+
release(held, narrower);
|
|
99
203
|
}
|
|
100
204
|
}
|
|
101
205
|
})();
|
|
102
|
-
}
|
|
206
|
+
};
|
|
207
|
+
// How many reports want each prefix; overlapping watches can name one prefix twice.
|
|
208
|
+
const wanted = new Map();
|
|
209
|
+
// How many wanted prefixes sit at or beneath each prefix, so a request knows in a walk up
|
|
210
|
+
// its path whether anything beneath it is still watched.
|
|
211
|
+
const beneath = new Map();
|
|
212
|
+
/**
|
|
213
|
+
* Settle a request nothing beneath it watches any more. A broader open request that is
|
|
214
|
+
* still needed holds it until that one goes, so the broader never takes its routes over
|
|
215
|
+
* before it has synced; otherwise it lingers out.
|
|
216
|
+
*/
|
|
217
|
+
const release = (prefix, interest) => {
|
|
218
|
+
for (const above of coveringPrefixes(prefix)) {
|
|
219
|
+
if (above === prefix)
|
|
220
|
+
continue;
|
|
221
|
+
const holder = interests.get(above);
|
|
222
|
+
if (!holder || !beneath.has(above))
|
|
223
|
+
continue;
|
|
224
|
+
holder.held.set(prefix, interest);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
interest.linger?.();
|
|
228
|
+
interest.linger = after(LINGER, () => {
|
|
229
|
+
// Forgotten now rather than once its stream winds down, so a watch arriving
|
|
230
|
+
// meanwhile opens a fresh request instead of reviving this one.
|
|
231
|
+
interests.delete(prefix);
|
|
232
|
+
interest.closing = true;
|
|
233
|
+
interest.announced.close();
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
const unsubscribe = originWire.interests((prefix, want) => {
|
|
237
|
+
if (dead)
|
|
238
|
+
return;
|
|
239
|
+
const count = (wanted.get(prefix) ?? 0) + (want ? 1 : -1);
|
|
240
|
+
if (count > 0)
|
|
241
|
+
wanted.set(prefix, count);
|
|
242
|
+
else
|
|
243
|
+
wanted.delete(prefix);
|
|
244
|
+
if (count !== (want ? 1 : 0))
|
|
245
|
+
return;
|
|
246
|
+
for (const above of coveringPrefixes(prefix)) {
|
|
247
|
+
const held = (beneath.get(above) ?? 0) + (want ? 1 : -1);
|
|
248
|
+
if (held > 0)
|
|
249
|
+
beneath.set(above, held);
|
|
250
|
+
else
|
|
251
|
+
beneath.delete(above);
|
|
252
|
+
}
|
|
253
|
+
// A request stays open while anything beneath it is watched, so a narrower watch rides
|
|
254
|
+
// it rather than opening a request that would later have to take its routes over.
|
|
255
|
+
let covered = false;
|
|
256
|
+
for (const above of coveringPrefixes(prefix)) {
|
|
257
|
+
const interest = interests.get(above);
|
|
258
|
+
if (!interest)
|
|
259
|
+
continue;
|
|
260
|
+
covered = true;
|
|
261
|
+
if (beneath.has(above)) {
|
|
262
|
+
interest.linger?.();
|
|
263
|
+
interest.linger = undefined;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
release(above, interest);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (want && !covered && !blind)
|
|
270
|
+
open(prefix);
|
|
271
|
+
});
|
|
272
|
+
void conn.closed.then(() => {
|
|
273
|
+
dead = true;
|
|
274
|
+
unsubscribe();
|
|
275
|
+
// End every request the moment the session closes rather than waiting for the wire to
|
|
276
|
+
// error it, so the retractions land promptly.
|
|
277
|
+
for (const interest of interests.values())
|
|
278
|
+
interest.announced.close();
|
|
279
|
+
detach();
|
|
280
|
+
});
|
|
103
281
|
}
|
|
104
282
|
/**
|
|
105
|
-
* Answer the
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* legal, and a missing broadcast surfaces as a reset on the first track. The first session
|
|
109
|
-
* to answer wins; when this session dies its answers are withdrawn so a later session
|
|
110
|
-
* answers again, which is what makes a request span reconnects.
|
|
111
|
-
*
|
|
112
|
-
* A path the table already routes is left alone. A request resolves to the table's route over
|
|
113
|
-
* any blind answer, so answering one would only park a handle nothing reads.
|
|
283
|
+
* Answer the requests under a received route by consuming them from the session, pinned to the
|
|
284
|
+
* route's identity: the session may carry another identity's claim at the prefix, which ranks
|
|
285
|
+
* apart from this one, and must never be served under this one's identity.
|
|
114
286
|
*/
|
|
115
287
|
async function drive(handle, conn) {
|
|
116
288
|
const session = wireOf(conn);
|
|
117
289
|
try {
|
|
118
290
|
for await (const request of handle.requested()) {
|
|
119
|
-
request.
|
|
291
|
+
// Read per request: a handover may update the handle in place.
|
|
292
|
+
request.serve(session.consume(request.path, wireOf(handle).info?.identity));
|
|
120
293
|
}
|
|
121
294
|
}
|
|
122
295
|
catch {
|
|
123
296
|
handle.close();
|
|
124
297
|
}
|
|
125
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Answer the origin's open requests with blind subscriptions for the session's lifetime.
|
|
301
|
+
*
|
|
302
|
+
* Every session answers, discovery or not: subscribing to an unannounced path is always
|
|
303
|
+
* legal, and a missing broadcast surfaces as a reset on the first track. The first session
|
|
304
|
+
* to answer wins; when this session dies its answers are withdrawn, and the requests they
|
|
305
|
+
* resolved end with it, since a later session is another publisher identity.
|
|
306
|
+
*
|
|
307
|
+
* A path the table already routes is left alone. A request resolves to the table's route over
|
|
308
|
+
* any blind answer, so answering one would only park a handle nothing reads.
|
|
309
|
+
*/
|
|
126
310
|
async function serveRequests(conn, origin) {
|
|
127
311
|
const table = wireOf(origin);
|
|
128
312
|
const session = wireOf(conn);
|
|
@@ -138,10 +322,10 @@ async function serveRequests(conn, origin) {
|
|
|
138
322
|
});
|
|
139
323
|
for (;;) {
|
|
140
324
|
const map = table.requests.peek();
|
|
141
|
-
if (
|
|
325
|
+
if (origin.closed.peek() !== undefined || dead)
|
|
142
326
|
break;
|
|
143
327
|
for (const [path, slot] of map) {
|
|
144
|
-
if (
|
|
328
|
+
if (!table.blind(slot))
|
|
145
329
|
continue;
|
|
146
330
|
if (answered.get(path)?.slot === slot || slot.answer !== undefined)
|
|
147
331
|
continue;
|
|
@@ -155,7 +339,7 @@ async function serveRequests(conn, origin) {
|
|
|
155
339
|
// A replaced slot counts as withdrawn: the answer we hold belongs to the slot that
|
|
156
340
|
// went away, not to whatever now occupies the path.
|
|
157
341
|
for (const [path, entry] of [...answered]) {
|
|
158
|
-
if (map.get(path) === entry.slot && entry.slot
|
|
342
|
+
if (map.get(path) === entry.slot && table.blind(entry.slot))
|
|
159
343
|
continue;
|
|
160
344
|
answered.delete(path);
|
|
161
345
|
entry.withdraw();
|