@moq/net 0.4.7 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/announce.d.ts +1 -1
- package/announce.d.ts.map +1 -1
- package/announce.js +1 -2
- package/announce.js.map +1 -1
- package/announced.d.ts +51 -47
- package/announced.d.ts.map +1 -1
- package/announced.js +183 -32
- package/announced.js.map +1 -1
- package/announced.test-util.d.ts +2 -0
- package/announced.test-util.d.ts.map +1 -0
- package/announced.test-util.js +27 -0
- package/announced.test-util.js.map +1 -0
- package/auth.d.ts +64 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +20 -0
- package/auth.js.map +1 -0
- package/auth_gate.d.ts +2 -0
- package/auth_gate.d.ts.map +1 -0
- package/auth_gate.js +24 -0
- package/auth_gate.js.map +1 -0
- package/auth_session.d.ts +49 -0
- package/auth_session.d.ts.map +1 -0
- package/auth_session.js +1097 -0
- package/auth_session.js.map +1 -0
- package/bandwidth.d.ts +129 -25
- package/bandwidth.d.ts.map +1 -1
- package/bandwidth.js +410 -139
- package/bandwidth.js.map +1 -1
- package/bandwidth_api.d.ts +1 -1
- package/bandwidth_api.d.ts.map +1 -1
- package/bandwidth_api.js +1 -2
- package/bandwidth_api.js.map +1 -1
- package/broadcast.d.ts +64 -38
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +556 -173
- package/broadcast.js.map +1 -1
- package/cache.d.ts +103 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +254 -0
- package/cache.js.map +1 -0
- package/claim.test-util.d.ts +5 -0
- package/claim.test-util.d.ts.map +1 -0
- package/claim.test-util.js +13 -0
- package/claim.test-util.js.map +1 -0
- package/connection/accept.d.ts +21 -13
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +97 -130
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +28 -20
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +120 -24
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +535 -217
- package/connection/connect.js.map +1 -1
- package/connection/dials.d.ts +45 -0
- package/connection/dials.d.ts.map +1 -0
- package/connection/dials.js +109 -0
- package/connection/dials.js.map +1 -0
- package/connection/endpoint.d.ts +60 -0
- package/connection/endpoint.d.ts.map +1 -0
- package/connection/endpoint.js +114 -0
- package/connection/endpoint.js.map +1 -0
- package/connection/forward.d.ts +7 -1
- package/connection/forward.d.ts.map +1 -1
- package/connection/forward.js +265 -81
- package/connection/forward.js.map +1 -1
- package/connection/goaway.d.ts +16 -9
- package/connection/goaway.d.ts.map +1 -1
- package/connection/goaway.js +22 -95
- package/connection/goaway.js.map +1 -1
- package/connection/handshake.d.ts +34 -8
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +97 -21
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +4 -7
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +1 -3
- package/connection/index.js.map +1 -1
- package/connection/liveness.d.ts +14 -0
- package/connection/liveness.d.ts.map +1 -0
- package/connection/liveness.js +30 -0
- package/connection/liveness.js.map +1 -0
- package/connection/pool.d.ts +142 -63
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +281 -118
- package/connection/pool.js.map +1 -1
- package/connection/reload.d.ts +60 -12
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +859 -234
- package/connection/reload.js.map +1 -1
- package/connection/session.d.ts +91 -0
- package/connection/session.d.ts.map +1 -0
- package/connection/session.js +2 -0
- package/connection/session.js.map +1 -0
- package/connection/stats.d.ts +20 -11
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js +64 -9
- package/connection/stats.js.map +1 -1
- package/connection/ticker.d.ts +4 -0
- package/connection/ticker.d.ts.map +1 -0
- package/connection/ticker.js +66 -0
- package/connection/ticker.js.map +1 -0
- package/connection/tokens.d.ts +2 -0
- package/connection/tokens.d.ts.map +1 -0
- package/connection/tokens.js +404 -0
- package/connection/tokens.js.map +1 -0
- package/connection/transport.d.ts.map +1 -1
- package/connection/transport.js +4 -5
- package/connection/transport.js.map +1 -1
- package/connection/withdrawal.d.ts +2 -0
- package/connection/withdrawal.d.ts.map +1 -0
- package/connection/withdrawal.js +23 -0
- package/connection/withdrawal.js.map +1 -0
- package/consume.js +213 -47
- package/consume.js.map +1 -1
- package/cover.d.ts +59 -0
- package/cover.d.ts.map +1 -0
- package/cover.js +375 -0
- package/cover.js.map +1 -0
- package/datagram.d.ts +70 -11
- package/datagram.d.ts.map +1 -1
- package/datagram.js +317 -2
- package/datagram.js.map +1 -1
- package/datagram_stream.d.ts +18 -0
- package/datagram_stream.d.ts.map +1 -0
- package/datagram_stream.js +67 -0
- package/datagram_stream.js.map +1 -0
- package/defined.test-util.d.ts +2 -0
- package/defined.test-util.d.ts.map +1 -0
- package/defined.test-util.js +7 -0
- package/defined.test-util.js.map +1 -0
- package/delivered.d.ts +75 -0
- package/delivered.d.ts.map +1 -0
- package/delivered.js +228 -0
- package/delivered.js.map +1 -0
- package/demand.d.ts +173 -0
- package/demand.d.ts.map +1 -0
- package/demand.js +582 -0
- package/demand.js.map +1 -0
- package/drops.d.ts +93 -0
- package/drops.d.ts.map +1 -0
- package/drops.js +283 -0
- package/drops.js.map +1 -0
- package/error.d.ts +120 -21
- package/error.d.ts.map +1 -1
- package/error.js +230 -38
- package/error.js.map +1 -1
- package/errors.d.ts +2 -2
- package/errors.d.ts.map +1 -1
- package/errors.js +2 -3
- package/errors.js.map +1 -1
- package/fill.d.ts +174 -0
- package/fill.d.ts.map +1 -0
- package/fill.js +760 -0
- package/fill.js.map +1 -0
- package/flate/decoder.d.ts +2 -0
- package/flate/decoder.d.ts.map +1 -0
- package/flate/decoder.js +63 -0
- package/flate/decoder.js.map +1 -0
- package/flate/encoder.d.ts +2 -0
- package/flate/encoder.d.ts.map +1 -0
- package/flate/encoder.js +64 -0
- package/flate/encoder.js.map +1 -0
- package/flate/group.d.ts +34 -0
- package/flate/group.d.ts.map +1 -0
- package/flate/group.js +140 -0
- package/flate/group.js.map +1 -0
- package/frame.d.ts +80 -0
- package/frame.d.ts.map +1 -0
- package/frame.js +296 -0
- package/frame.js.map +1 -0
- package/frame.test-util.d.ts +5 -0
- package/frame.test-util.d.ts.map +1 -0
- package/frame.test-util.js +9 -0
- package/frame.test-util.js.map +1 -0
- package/group.d.ts +108 -45
- package/group.d.ts.map +1 -1
- package/group.js +1616 -308
- package/group.js.map +1 -1
- package/group_api.d.ts +7 -0
- package/group_api.d.ts.map +1 -0
- package/group_api.js +7 -0
- package/group_api.js.map +1 -0
- package/hop.d.ts +62 -76
- package/hop.d.ts.map +1 -1
- package/hop.js +92 -65
- package/hop.js.map +1 -1
- package/identity.d.ts +39 -0
- package/identity.d.ts.map +1 -0
- package/identity.js +47 -0
- package/identity.js.map +1 -0
- package/ietf/active_count.d.ts +2 -0
- package/ietf/active_count.d.ts.map +1 -0
- package/ietf/active_count.js +30 -0
- package/ietf/active_count.js.map +1 -0
- package/ietf/aliases.js +69 -36
- package/ietf/aliases.js.map +1 -1
- package/ietf/cluster.d.ts +3 -3
- package/ietf/cluster.js +14 -55
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +1 -31
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +305 -144
- package/ietf/connection.js.map +1 -1
- package/ietf/datagram.d.ts +60 -0
- package/ietf/datagram.d.ts.map +1 -0
- package/ietf/datagram.js +152 -0
- package/ietf/datagram.js.map +1 -0
- package/ietf/error.d.ts +3 -3
- package/ietf/error.js +82 -101
- package/ietf/error.js.map +1 -1
- package/ietf/fetch.d.ts +93 -37
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +172 -94
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +21 -31
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +140 -172
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts +12 -10
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -36
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.js +1 -2
- package/ietf/hidden.js.map +1 -1
- package/ietf/index.d.ts +8 -20
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +4 -15
- package/ietf/index.js.map +1 -1
- package/ietf/join.d.ts +7 -0
- package/ietf/join.d.ts.map +1 -0
- package/ietf/join.js +234 -0
- package/ietf/join.js.map +1 -0
- package/ietf/message.d.ts +18 -2
- package/ietf/message.d.ts.map +1 -1
- package/ietf/message.js +60 -41
- package/ietf/message.js.map +1 -1
- package/ietf/message.test-util.d.ts +6 -0
- package/ietf/message.test-util.d.ts.map +1 -0
- package/ietf/message.test-util.js +13 -0
- package/ietf/message.test-util.js.map +1 -0
- package/ietf/namespace.d.ts +19 -5
- package/ietf/namespace.d.ts.map +1 -1
- package/ietf/namespace.js +78 -27
- package/ietf/namespace.js.map +1 -1
- package/ietf/object.d.ts +195 -33
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +405 -179
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +25 -45
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +260 -473
- package/ietf/parameters.js.map +1 -1
- package/ietf/priority.d.ts +17 -2
- package/ietf/priority.d.ts.map +1 -1
- package/ietf/priority.js +19 -5
- package/ietf/priority.js.map +1 -1
- package/ietf/properties.d.ts +6 -5
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +78 -49
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +25 -33
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +45 -140
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +49 -72
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +66 -185
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.js +1800 -601
- package/ietf/publisher.js.map +1 -1
- package/ietf/range.d.ts +2 -0
- package/ietf/range.d.ts.map +1 -0
- package/ietf/range.js +222 -0
- package/ietf/range.js.map +1 -0
- package/ietf/request.d.ts +6 -30
- package/ietf/request.d.ts.map +1 -1
- package/ietf/request.js +41 -79
- package/ietf/request.js.map +1 -1
- package/ietf/request_stream.d.ts +1 -6
- package/ietf/request_stream.d.ts.map +1 -1
- package/ietf/request_stream.js +306 -17
- package/ietf/request_stream.js.map +1 -1
- package/ietf/session.d.ts +41 -0
- package/ietf/session.d.ts.map +1 -0
- package/ietf/session.js +65 -0
- package/ietf/session.js.map +1 -0
- package/ietf/setup.d.ts +5 -30
- package/ietf/setup.d.ts.map +1 -1
- package/ietf/setup.js +6 -118
- package/ietf/setup.js.map +1 -1
- package/ietf/setup_options.d.ts +31 -0
- package/ietf/setup_options.d.ts.map +1 -0
- package/ietf/setup_options.js +138 -0
- package/ietf/setup_options.js.map +1 -0
- package/ietf/solicit.js +4 -15
- package/ietf/solicit.js.map +1 -1
- package/ietf/subscribe.d.ts +52 -45
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +118 -240
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +16 -79
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +30 -202
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +1839 -537
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.js +105 -28
- package/ietf/token.js.map +1 -1
- package/ietf/track.d.ts +27 -24
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +48 -62
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +13 -42
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +22 -49
- package/ietf/version.js.map +1 -1
- package/implementation.d.ts +2 -0
- package/implementation.d.ts.map +1 -0
- package/implementation.js +5 -0
- package/implementation.js.map +1 -0
- package/index.d.ts +34 -19
- package/index.d.ts.map +1 -1
- package/index.js +19 -7
- package/index.js.map +1 -1
- package/internal.d.ts +1515 -67
- package/internal.d.ts.map +1 -1
- package/internal.js +557 -80
- package/internal.js.map +1 -1
- package/ledger.d.ts +23 -0
- package/ledger.d.ts.map +1 -0
- package/ledger.js +247 -0
- package/ledger.js.map +1 -0
- package/listing.d.ts +132 -0
- package/listing.d.ts.map +1 -0
- package/listing.js +486 -0
- package/listing.js.map +1 -0
- package/lite/announce.d.ts +127 -66
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +384 -159
- package/lite/announce.js.map +1 -1
- package/lite/announce_stream.d.ts +2 -0
- package/lite/announce_stream.d.ts.map +1 -0
- package/lite/announce_stream.js +92 -0
- package/lite/announce_stream.js.map +1 -0
- package/lite/answer.d.ts +22 -0
- package/lite/answer.d.ts.map +1 -0
- package/lite/answer.js +301 -0
- package/lite/answer.js.map +1 -0
- package/lite/auth.d.ts +45 -0
- package/lite/auth.d.ts.map +1 -0
- package/lite/auth.js +204 -0
- package/lite/auth.js.map +1 -0
- package/lite/compat.d.ts +31 -0
- package/lite/compat.d.ts.map +1 -0
- package/lite/compat.js +86 -0
- package/lite/compat.js.map +1 -0
- package/lite/connection.d.ts +1 -45
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +360 -78
- package/lite/connection.js.map +1 -1
- package/lite/datagram-end.d.ts +26 -0
- package/lite/datagram-end.d.ts.map +1 -0
- package/lite/datagram-end.js +30 -0
- package/lite/datagram-end.js.map +1 -0
- package/lite/datagram.d.ts +73 -8
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +144 -10
- package/lite/datagram.js.map +1 -1
- package/lite/duration.d.ts +6 -0
- package/lite/duration.d.ts.map +1 -0
- package/lite/duration.js +14 -0
- package/lite/duration.js.map +1 -0
- package/lite/error.d.ts +9 -0
- package/lite/error.d.ts.map +1 -0
- package/lite/error.js +24 -0
- package/lite/error.js.map +1 -0
- package/lite/fills.d.ts +162 -0
- package/lite/fills.d.ts.map +1 -0
- package/lite/fills.js +486 -0
- package/lite/fills.js.map +1 -0
- package/lite/fit.d.ts +49 -0
- package/lite/fit.d.ts.map +1 -0
- package/lite/fit.js +305 -0
- package/lite/fit.js.map +1 -0
- package/lite/goaway.d.ts +2 -2
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +5 -14
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +67 -16
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +108 -31
- package/lite/group.js.map +1 -1
- package/lite/identity.d.ts +25 -0
- package/lite/identity.d.ts.map +1 -0
- package/lite/identity.js +79 -0
- package/lite/identity.js.map +1 -0
- package/lite/index.d.ts +14 -13
- package/lite/index.d.ts.map +1 -1
- package/lite/index.js +2 -2
- package/lite/index.js.map +1 -1
- package/lite/message.d.ts +10 -2
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +28 -45
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +9 -2
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +11 -106
- package/lite/priority.js.map +1 -1
- package/lite/probe.d.ts +2 -2
- package/lite/probe.d.ts.map +1 -1
- package/lite/probe.js +9 -1
- package/lite/probe.js.map +1 -1
- package/lite/publisher.d.ts +10 -1
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +2548 -438
- package/lite/publisher.js.map +1 -1
- package/lite/routed.d.ts +59 -0
- package/lite/routed.d.ts.map +1 -0
- package/lite/routed.js +564 -0
- package/lite/routed.js.map +1 -0
- package/lite/session.d.ts +2 -28
- package/lite/session.d.ts.map +1 -1
- package/lite/session.js +0 -100
- package/lite/session.js.map +1 -1
- package/lite/setup.d.ts +32 -5
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +95 -22
- package/lite/setup.js.map +1 -1
- package/lite/stream.d.ts +5 -11
- package/lite/stream.d.ts.map +1 -1
- package/lite/stream.js +5 -2
- package/lite/stream.js.map +1 -1
- package/lite/subscribe.d.ts +478 -78
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +1373 -143
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +7 -44
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +3290 -516
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +27 -12
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +116 -38
- package/lite/track.js.map +1 -1
- package/lite/tracks.d.ts +55 -0
- package/lite/tracks.d.ts.map +1 -0
- package/lite/tracks.js +114 -0
- package/lite/tracks.js.map +1 -0
- package/lite/version.d.ts +132 -24
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +378 -34
- package/lite/version.js.map +1 -1
- package/meta.d.ts +77 -0
- package/meta.d.ts.map +1 -0
- package/meta.js +130 -0
- package/meta.js.map +1 -0
- package/meta_api.d.ts +7 -0
- package/meta_api.d.ts.map +1 -0
- package/meta_api.js +7 -0
- package/meta_api.js.map +1 -0
- package/mint.d.ts +28 -0
- package/mint.d.ts.map +1 -0
- package/mint.js +66 -0
- package/mint.js.map +1 -0
- package/open.d.ts +63 -0
- package/open.d.ts.map +1 -0
- package/open.js +250 -0
- package/open.js.map +1 -0
- package/origin.d.ts +394 -142
- package/origin.d.ts.map +1 -1
- package/origin.js +2533 -687
- package/origin.js.map +1 -1
- package/package.json +8 -13
- package/path.d.ts +51 -51
- package/path.d.ts.map +1 -1
- package/path.js +210 -58
- package/path.js.map +1 -1
- package/payload.d.ts +33 -0
- package/payload.d.ts.map +1 -0
- package/payload.js +65 -0
- package/payload.js.map +1 -0
- package/prefix.d.ts +152 -0
- package/prefix.d.ts.map +1 -0
- package/prefix.js +349 -0
- package/prefix.js.map +1 -0
- package/priority.d.ts +8 -0
- package/priority.d.ts.map +1 -0
- package/priority.js +185 -0
- package/priority.js.map +1 -0
- package/queue.d.ts +2 -0
- package/queue.d.ts.map +1 -0
- package/queue.js +46 -0
- package/queue.js.map +1 -0
- package/ranges.d.ts +36 -0
- package/ranges.d.ts.map +1 -0
- package/ranges.js +312 -0
- package/ranges.js.map +1 -0
- package/rescale.d.ts +24 -0
- package/rescale.d.ts.map +1 -0
- package/rescale.js +39 -0
- package/rescale.js.map +1 -0
- package/resume.d.ts +55 -0
- package/resume.d.ts.map +1 -0
- package/resume.js +4173 -0
- package/resume.js.map +1 -0
- package/resume.test-util.d.ts +2 -0
- package/resume.test-util.d.ts.map +1 -0
- package/resume.test-util.js +25 -0
- package/resume.test-util.js.map +1 -0
- package/skips.d.ts +48 -0
- package/skips.d.ts.map +1 -0
- package/skips.js +182 -0
- package/skips.js.map +1 -0
- package/stream.d.ts +78 -40
- package/stream.d.ts.map +1 -1
- package/stream.js +236 -93
- package/stream.js.map +1 -1
- package/subscription.test-util.d.ts +2 -0
- package/subscription.test-util.d.ts.map +1 -0
- package/subscription.test-util.js +49 -0
- package/subscription.test-util.js.map +1 -0
- package/tail.d.ts +23 -14
- package/tail.d.ts.map +1 -1
- package/tail.js +224 -98
- package/tail.js.map +1 -1
- package/time.d.ts +41 -102
- package/time.d.ts.map +1 -1
- package/time.js +129 -92
- package/time.js.map +1 -1
- package/timed.d.ts +21 -0
- package/timed.d.ts.map +1 -0
- package/timed.js +2 -0
- package/timed.js.map +1 -0
- package/track.d.ts +578 -246
- package/track.d.ts.map +1 -1
- package/track.js +7306 -772
- package/track.js.map +1 -1
- package/track_api.d.ts +7 -0
- package/track_api.d.ts.map +1 -0
- package/track_api.js +7 -0
- package/track_api.js.map +1 -0
- package/util/abort.d.ts +1 -0
- package/util/abort.d.ts.map +1 -1
- package/util/abort.js +23 -2
- package/util/abort.js.map +1 -1
- package/util/announce.d.ts +4 -0
- package/util/announce.d.ts.map +1 -0
- package/util/announce.js +11 -0
- package/util/announce.js.map +1 -0
- package/util/bigint.d.ts +3 -0
- package/util/bigint.d.ts.map +1 -0
- package/util/bigint.js +8 -0
- package/util/bigint.js.map +1 -0
- package/util/change.d.ts +12 -0
- package/util/change.d.ts.map +1 -0
- package/util/change.js +18 -0
- package/util/change.js.map +1 -0
- package/util/deadline.d.ts +2 -0
- package/util/deadline.d.ts.map +1 -0
- package/util/deadline.js +108 -0
- package/util/deadline.js.map +1 -0
- package/util/decode_error.d.ts +3 -0
- package/util/decode_error.d.ts.map +1 -0
- package/util/decode_error.js +11 -0
- package/util/decode_error.js.map +1 -0
- package/util/demand.d.ts +8 -0
- package/util/demand.d.ts.map +1 -0
- package/util/demand.js +24 -0
- package/util/demand.js.map +1 -0
- package/util/given_up.d.ts +2 -0
- package/util/given_up.d.ts.map +1 -0
- package/util/given_up.js +101 -0
- package/util/given_up.js.map +1 -0
- package/util/hex.d.ts +6 -0
- package/util/hex.d.ts.map +1 -1
- package/util/hex.js +19 -5
- package/util/hex.js.map +1 -1
- package/util/key.d.ts +15 -0
- package/util/key.d.ts.map +1 -0
- package/util/key.js +38 -0
- package/util/key.js.map +1 -0
- package/util/limits.d.ts +2 -0
- package/util/limits.d.ts.map +1 -0
- package/util/limits.js +76 -0
- package/util/limits.js.map +1 -0
- package/util/observed.d.ts +23 -0
- package/util/observed.d.ts.map +1 -0
- package/util/observed.js +122 -0
- package/util/observed.js.map +1 -0
- package/util/sorted.d.ts +2 -0
- package/util/sorted.d.ts.map +1 -0
- package/util/sorted.js +149 -0
- package/util/sorted.js.map +1 -0
- package/util/timeout.d.ts +2 -1
- package/util/timeout.d.ts.map +1 -1
- package/util/timeout.js +13 -10
- package/util/timeout.js.map +1 -1
- package/util/timer.d.ts +2 -0
- package/util/timer.d.ts.map +1 -0
- package/util/timer.js +19 -0
- package/util/timer.js.map +1 -0
- package/util/u64.js +0 -1
- package/util/utf8.d.ts +2 -0
- package/util/utf8.d.ts.map +1 -1
- package/util/utf8.js +7 -2
- package/util/utf8.js.map +1 -1
- package/util/varint.d.ts.map +1 -1
- package/util/varint.js +8 -2
- package/util/varint.js.map +1 -1
- package/util/watch.d.ts +8 -0
- package/util/watch.d.ts.map +1 -0
- package/util/watch.js +38 -0
- package/util/watch.js.map +1 -0
- package/util/yield.d.ts +2 -0
- package/util/yield.d.ts.map +1 -0
- package/util/yield.js +31 -0
- package/util/yield.js.map +1 -0
- package/varint.d.ts +0 -29
- package/varint.d.ts.map +1 -1
- package/varint.js +7 -29
- package/varint.js.map +1 -1
- package/varint_api.d.ts +7 -0
- package/varint_api.d.ts.map +1 -0
- package/varint_api.js +7 -0
- package/varint_api.js.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
- package/window.d.ts +570 -0
- package/window.d.ts.map +1 -0
- package/window.js +1677 -0
- package/window.js.map +1 -0
- package/wire.d.ts +150 -35
- package/wire.d.ts.map +1 -1
- package/wire.js +27 -1
- package/wire.js.map +1 -1
- package/connection/established.d.ts +0 -53
- package/connection/established.d.ts.map +0 -1
- package/connection/established.js +0 -3
- package/connection/established.js.map +0 -1
- package/ietf/adapter.d.ts +0 -75
- package/ietf/adapter.d.ts.map +0 -1
- package/ietf/adapter.js +0 -700
- package/ietf/adapter.js.map +0 -1
- package/lite/datagram_stream.d.ts +0 -8
- package/lite/datagram_stream.d.ts.map +0 -1
- package/lite/datagram_stream.js +0 -44
- package/lite/datagram_stream.js.map +0 -1
- package/lite/fetch.d.ts +0 -28
- package/lite/fetch.d.ts.map +0 -1
- package/lite/fetch.js +0 -79
- package/lite/fetch.js.map +0 -1
- package/util/log.d.ts +0 -5
- package/util/log.d.ts.map +0 -1
- package/util/log.js +0 -17
- package/util/log.js.map +0 -1
- package/zod.d.ts +0 -13
- package/zod.d.ts.map +0 -1
- package/zod.js +0 -19
- package/zod.js.map +0 -1
package/error.js
CHANGED
|
@@ -1,47 +1,59 @@
|
|
|
1
|
-
/* @ts-self-types="./error.d.ts" */
|
|
2
1
|
/**
|
|
3
2
|
* Errors, including the code a peer reports when it resets a stream or closes the session.
|
|
4
3
|
*
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
6
|
+
import { transportOf } from "./connection/transport.js";
|
|
7
7
|
import { sharedStreamCode } from "./ietf/error.js";
|
|
8
8
|
import { TimeoutError } from "./util/timeout.js";
|
|
9
9
|
/**
|
|
10
10
|
* Codes a peer sends when terminating the session, mirroring the Rust `Session`.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* to construct an application code
|
|
14
|
-
*
|
|
12
|
+
* moq-lite's registry, which reuses moq-transport's value for each code the two share. Call
|
|
13
|
+
* `SessionCode.app(code)` to construct an application code: `code` is 0-based and sent as
|
|
14
|
+
* `64 + code`, as the Rust `SessionError::App` is. {@link StreamCode} is
|
|
15
|
+
* the other registry, and the two are disjoint, so the same integer means different things in
|
|
16
|
+
* each.
|
|
15
17
|
*
|
|
16
18
|
* Codes 32-47 are reserved: nothing is sent there, and the draft gives a received one no
|
|
17
|
-
* meaning
|
|
19
|
+
* meaning. A code only moq-transport defines arrives as its number too, so treat anything not
|
|
20
|
+
* listed below as an unspecified error rather than guessing.
|
|
18
21
|
*
|
|
19
22
|
* @public
|
|
20
23
|
*/
|
|
21
|
-
export const SessionCode = Object.freeze(
|
|
24
|
+
export const SessionCode = Object.freeze({
|
|
25
|
+
/** An application's own code, 0 through 65535, sent past the library's range as `64 + code`. */
|
|
26
|
+
app: (code) => applicationCode(code),
|
|
22
27
|
/** Ending the session normally, with no error. */
|
|
23
28
|
Cancel: 0x0,
|
|
24
29
|
/** Something went wrong that isn't worth a dedicated code. */
|
|
25
30
|
Internal: 0x1,
|
|
26
31
|
/** The credentials don't grant the requested path or operation. Retrying will fail again. */
|
|
27
32
|
Unauthorized: 0x2,
|
|
33
|
+
/** The authorization token expired. Retrying with refreshed credentials may succeed. */
|
|
34
|
+
Expired: 0x18,
|
|
28
35
|
/** A protocol rule was broken; the session is unusable. */
|
|
29
36
|
ProtocolViolation: 0x3,
|
|
30
|
-
/**
|
|
31
|
-
|
|
37
|
+
/** The peer went past what the session allows: a request ID past MAX_REQUEST_ID, or too many announcements. */
|
|
38
|
+
TooManyRequests: 0x7,
|
|
32
39
|
/** The peer did not close within the GOAWAY drain deadline. */
|
|
33
40
|
GoawayTimeout: 0x10,
|
|
34
41
|
/** A control message took too long. */
|
|
35
42
|
Timeout: 0x11,
|
|
36
43
|
/** No version could be negotiated. */
|
|
37
44
|
Version: 0x15,
|
|
38
|
-
|
|
45
|
+
/** The token could not be parsed. Retrying with the same token will fail again. */
|
|
46
|
+
MalformedAuthToken: 0x16,
|
|
47
|
+
/** The peer cannot support the requested feature, token, or grant. */
|
|
48
|
+
Unsupported: 0x30,
|
|
49
|
+
});
|
|
39
50
|
/**
|
|
40
51
|
* Codes a peer sends when resetting a stream, mirroring the Rust `Stream`.
|
|
41
52
|
*
|
|
42
53
|
* The counterpart to {@link SessionCode}, and a disjoint space: a stream reset of 0 is
|
|
43
|
-
*
|
|
44
|
-
* `StreamCode(code)` to construct an application code
|
|
54
|
+
* `StreamCode.Internal`, not a cancellation (`StreamCode.Cancel` is 1). Call
|
|
55
|
+
* `StreamCode.app(code)` to construct an application code: `code` is 0-based and sent as
|
|
56
|
+
* `64 + code`, as the Rust `StreamError::App` is.
|
|
45
57
|
*
|
|
46
58
|
* Conditions the shared codes don't cover are assigned in moq-lite's own 48-63 range, so a
|
|
47
59
|
* received one is the named code. 32 through 47 is reserved: nothing is sent there and a
|
|
@@ -49,7 +61,9 @@ export const SessionCode = Object.freeze(Object.assign((code) => applicationCode
|
|
|
49
61
|
*
|
|
50
62
|
* @public
|
|
51
63
|
*/
|
|
52
|
-
export const StreamCode = Object.freeze(
|
|
64
|
+
export const StreamCode = Object.freeze({
|
|
65
|
+
/** An application's own code, 0 through 65535, sent past the library's range as `64 + code`. */
|
|
66
|
+
app: (code) => applicationCode(code),
|
|
53
67
|
/** Something went wrong that isn't worth a dedicated code. */
|
|
54
68
|
Internal: 0x0,
|
|
55
69
|
/** The sender is done with this stream, not failing. A routine unsubscribe. */
|
|
@@ -64,6 +78,8 @@ export const StreamCode = Object.freeze(Object.assign((code) => applicationCode(
|
|
|
64
78
|
TooFarBehind: 0x5,
|
|
65
79
|
/** The track's content could not be parsed. */
|
|
66
80
|
MalformedTrack: 0x12,
|
|
81
|
+
/** The request asks what the publisher can't serve on this track, such as a time on a live-only one. */
|
|
82
|
+
NotSupported: 0x30,
|
|
67
83
|
/** The peer took too long to answer a control request. */
|
|
68
84
|
ControlTimeout: 0x31,
|
|
69
85
|
/** The requested broadcast or track does not exist at the peer. */
|
|
@@ -74,16 +90,25 @@ export const StreamCode = Object.freeze(Object.assign((code) => applicationCode(
|
|
|
74
90
|
Evicted: 0x35,
|
|
75
91
|
/** A frame declared a payload larger than the receiver accepts. */
|
|
76
92
|
FrameTooLarge: 0x38,
|
|
77
|
-
/**
|
|
78
|
-
|
|
93
|
+
/** A frame ended at a different size than declared. */
|
|
94
|
+
WrongSize: 0x37,
|
|
95
|
+
/** The broadcast is neither announced nor served, so there is no route to it. */
|
|
96
|
+
Unroutable: 0x36,
|
|
97
|
+
/** The grant does not cover this request, or no longer does. The session stays up. */
|
|
98
|
+
Unauthorized: 0x3b,
|
|
79
99
|
/** A group grew past its cache budget and was aborted. */
|
|
80
100
|
GroupTooLarge: 0x32,
|
|
81
|
-
|
|
101
|
+
/** A frame's timedness or timestamp doesn't match its track's timescale. */
|
|
102
|
+
TimestampMismatch: 0x39,
|
|
103
|
+
/** The group start will never be produced (declared skipped, or a discontinuity). */
|
|
104
|
+
Skip: 0x3a,
|
|
105
|
+
});
|
|
106
|
+
// The wire code for an application's 0-based `code`, bounded to u16 as Rust bounds `App`.
|
|
82
107
|
function applicationCode(code) {
|
|
83
|
-
if (!Number.isInteger(code) || code <
|
|
108
|
+
if (!Number.isInteger(code) || code < 0 || code > 0xffff) {
|
|
84
109
|
throw new RangeError(`invalid application error code: ${code}`);
|
|
85
110
|
}
|
|
86
|
-
return code;
|
|
111
|
+
return code + 64;
|
|
87
112
|
}
|
|
88
113
|
/**
|
|
89
114
|
* An error the peer reported by closing the session, carrying its {@link SessionCode}.
|
|
@@ -118,7 +143,7 @@ export class Session extends Error {
|
|
|
118
143
|
* This surfaces on every transport, so catch this type rather than feature-detecting
|
|
119
144
|
* `WebTransportError`, which a non-browser runtime never defines and the WebSocket fallback
|
|
120
145
|
* never throws. Local conditions with a code of their own subclass it ({@link TooFarBehind},
|
|
121
|
-
* {@link FrameTooLarge}, {@link GroupTooLarge}, {@link NotFound}), so the same `code` check catches a condition
|
|
146
|
+
* {@link FrameTooLarge}, {@link GroupTooLarge}, {@link TimestampMismatch}, {@link NotFound}), so the same `code` check catches a condition
|
|
122
147
|
* whether it was raised here or reported by the peer.
|
|
123
148
|
*
|
|
124
149
|
* ```ts
|
|
@@ -163,7 +188,7 @@ export class TooFarBehind extends Stream {
|
|
|
163
188
|
* A frame is larger than a group can cache, so appending it would exceed the budget by itself.
|
|
164
189
|
*
|
|
165
190
|
* Raised locally by a frame write, and decoded from a moq-lite peer's `FRAME_TOO_LARGE` reset.
|
|
166
|
-
* Mirrors the Rust `
|
|
191
|
+
* Mirrors the Rust `StreamError::FrameTooLarge`, which rejects the same frame before touching any state.
|
|
167
192
|
*
|
|
168
193
|
* @public
|
|
169
194
|
*/
|
|
@@ -177,10 +202,10 @@ export class FrameTooLarge extends Stream {
|
|
|
177
202
|
}
|
|
178
203
|
}
|
|
179
204
|
/**
|
|
180
|
-
* A
|
|
205
|
+
* A peer could not retain a group and aborted it.
|
|
181
206
|
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
207
|
+
* Decoded from a moq-lite peer's `GROUP_TOO_LARGE` reset. Local groups shed their front
|
|
208
|
+
* instead of aborting when their retained tail exceeds its budget.
|
|
184
209
|
*
|
|
185
210
|
* @public
|
|
186
211
|
*/
|
|
@@ -193,6 +218,24 @@ export class GroupTooLarge extends Stream {
|
|
|
193
218
|
this.name = "GroupTooLarge";
|
|
194
219
|
}
|
|
195
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* A frame's timestamp doesn't fit its track: a timestamp on a track with no timescale, none
|
|
223
|
+
* on a track that has one, or a group's first frame starting before the group below it.
|
|
224
|
+
*
|
|
225
|
+
* Raised locally by a frame or datagram write, and decoded from a moq-lite peer's
|
|
226
|
+
* `TIMESTAMP_MISMATCH` reset. Mirrors the Rust `StreamError::TimestampMismatch`.
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export class TimestampMismatch extends Stream {
|
|
231
|
+
constructor(options) {
|
|
232
|
+
super(StreamCode.TimestampMismatch, {
|
|
233
|
+
...options,
|
|
234
|
+
message: "frame timestamp doesn't fit its track",
|
|
235
|
+
});
|
|
236
|
+
this.name = "TimestampMismatch";
|
|
237
|
+
}
|
|
238
|
+
}
|
|
196
239
|
/**
|
|
197
240
|
* The requested broadcast or track is not served here.
|
|
198
241
|
*
|
|
@@ -218,6 +261,22 @@ export class RefusedRedirect extends Error {
|
|
|
218
261
|
this.name = "RefusedRedirect";
|
|
219
262
|
}
|
|
220
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* The dial and the MoQ handshake together outlived the connect's `timeout` option.
|
|
266
|
+
*
|
|
267
|
+
* A caller can retry it. Mirrors the Rust `Error::ConnectTimeout`.
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export class ConnectTimeout extends Error {
|
|
272
|
+
/** The timeout that elapsed. */
|
|
273
|
+
timeout;
|
|
274
|
+
constructor(timeout) {
|
|
275
|
+
super(`connect timed out after ${timeout}`);
|
|
276
|
+
this.name = "ConnectTimeout";
|
|
277
|
+
this.timeout = timeout;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
221
280
|
/**
|
|
222
281
|
* A peer broke the protocol in a way the spec says must end the session.
|
|
223
282
|
*
|
|
@@ -228,14 +287,22 @@ export class RefusedRedirect extends Error {
|
|
|
228
287
|
* @public
|
|
229
288
|
*/
|
|
230
289
|
export class ProtocolViolation extends Error {
|
|
290
|
+
/** The session code to close with: `ProtocolViolation` unless the draft names a more specific one. */
|
|
291
|
+
code;
|
|
231
292
|
constructor(message, options) {
|
|
232
293
|
super(message, options);
|
|
233
294
|
this.name = "ProtocolViolation";
|
|
295
|
+
this.code = options?.code ?? SessionCode.ProtocolViolation;
|
|
234
296
|
}
|
|
235
297
|
}
|
|
236
298
|
/** Package-internal compatibility names used by the wire implementation. */
|
|
237
299
|
export { Session as SessionError, Stream as StreamError, TooFarBehind as Lagged };
|
|
238
|
-
|
|
300
|
+
/**
|
|
301
|
+
* The raw code a transport's stream error carries, or undefined for any other error.
|
|
302
|
+
*
|
|
303
|
+
* @internal
|
|
304
|
+
*/
|
|
305
|
+
export function streamCode(err) {
|
|
239
306
|
if (typeof err !== "object" || err === null)
|
|
240
307
|
return undefined;
|
|
241
308
|
const { source, streamErrorCode } = err;
|
|
@@ -251,9 +318,12 @@ function streamCode(err) {
|
|
|
251
318
|
* means. Mirrors the Rust `From<&Error> for Stream`.
|
|
252
319
|
*
|
|
253
320
|
* Lossy on purpose. An error describes what went wrong here, while the registry is what the peer
|
|
254
|
-
* can act on, so anything without a code of its own degrades to {@link StreamCode.Internal}
|
|
255
|
-
* rather than inventing one. A {@link Session}
|
|
256
|
-
*
|
|
321
|
+
* can act on, so anything without a code of its own degrades to {@link StreamCode | StreamCode.Internal}
|
|
322
|
+
* rather than inventing one. A {@link Session} is {@link StreamCode | StreamCode.Unroutable}: a stream that
|
|
323
|
+
* can still be reset outlived the session that failed, so that was the route it was served
|
|
324
|
+
* through, and forwarding the session's code would mistranslate it across disjoint registries.
|
|
325
|
+
* An application code is the exception, since both registries share the 64+ range. A session
|
|
326
|
+
* that failed at the transport, with no code at all, is {@link StreamCode | StreamCode.Unroutable} too.
|
|
257
327
|
*
|
|
258
328
|
* On an IETF stream the code has to be one the negotiated draft assigns the same meaning to,
|
|
259
329
|
* so a condition it does not register degrades to INTERNAL_ERROR as well. See
|
|
@@ -265,7 +335,7 @@ export function toStreamCode(err, options) {
|
|
|
265
335
|
const code = localStreamCode(err);
|
|
266
336
|
if (options?.version === undefined)
|
|
267
337
|
return code;
|
|
268
|
-
return sharedStreamCode(code
|
|
338
|
+
return sharedStreamCode(code) ? code : StreamCode.Internal;
|
|
269
339
|
}
|
|
270
340
|
/** The moq-lite code for a local failure, before any draft has a say. */
|
|
271
341
|
function localStreamCode(err) {
|
|
@@ -276,13 +346,84 @@ function localStreamCode(err) {
|
|
|
276
346
|
// Session-scoped: the peer learns which rule it broke from the session close, not from here.
|
|
277
347
|
if (err instanceof ProtocolViolation)
|
|
278
348
|
return StreamCode.SessionClosed;
|
|
349
|
+
// App codes share the 64+ range in both registries.
|
|
350
|
+
if (err instanceof Session)
|
|
351
|
+
return err.code >= 64 ? err.code : StreamCode.Unroutable;
|
|
352
|
+
// A session that failed underneath without a close code, as on a network or idle failure.
|
|
353
|
+
const source = typeof err === "object" && err !== null ? err.source : undefined;
|
|
354
|
+
if (source === "session")
|
|
355
|
+
return StreamCode.Unroutable;
|
|
279
356
|
return StreamCode.Internal;
|
|
280
357
|
}
|
|
281
358
|
/**
|
|
282
|
-
*
|
|
359
|
+
* What a caller does after a request fails, as {@link retry} answers it. Mirrors the Rust `Retry`.
|
|
360
|
+
*
|
|
361
|
+
* @public
|
|
362
|
+
*/
|
|
363
|
+
export const Retry = Object.freeze({
|
|
364
|
+
/**
|
|
365
|
+
* The source failed to deliver rather than judging the request, so asking it again may
|
|
366
|
+
* succeed: its connection dropped, its session ended, or it is going away.
|
|
367
|
+
*/
|
|
368
|
+
Same: "same",
|
|
369
|
+
/**
|
|
370
|
+
* The source lost its route to the content, so only another route continues it. Asking the
|
|
371
|
+
* same source again can only replace the withdrawal's cause with a refusal.
|
|
372
|
+
*/
|
|
373
|
+
Reroute: "reroute",
|
|
374
|
+
/**
|
|
375
|
+
* The answer judged the request or what it carried, so it repeats on every attempt: refused,
|
|
376
|
+
* not found, or malformed.
|
|
377
|
+
*/
|
|
378
|
+
Never: "never",
|
|
379
|
+
});
|
|
380
|
+
// Stream codes that report the source failing to deliver rather than judging what it carried.
|
|
381
|
+
const DELIVERY_FAILURES = new Set([
|
|
382
|
+
StreamCode.Internal,
|
|
383
|
+
StreamCode.Cancel,
|
|
384
|
+
StreamCode.SessionClosed,
|
|
385
|
+
StreamCode.GoingAway,
|
|
386
|
+
StreamCode.ControlTimeout,
|
|
387
|
+
]);
|
|
388
|
+
/**
|
|
389
|
+
* What to do after a request failed with `err`: ask the same source again, find another route,
|
|
390
|
+
* or give up. Mirrors the Rust `Error::retry`.
|
|
391
|
+
*
|
|
392
|
+
* A session closing, whatever its code, is the route failing to deliver: whether the session
|
|
393
|
+
* comes back is the connection's call, not the request's.
|
|
394
|
+
*
|
|
395
|
+
* @public
|
|
396
|
+
*/
|
|
397
|
+
export function retry(err) {
|
|
398
|
+
if (err instanceof Stream) {
|
|
399
|
+
if (err.code === StreamCode.Unroutable)
|
|
400
|
+
return Retry.Reroute;
|
|
401
|
+
return DELIVERY_FAILURES.has(err.code) ? Retry.Same : Retry.Never;
|
|
402
|
+
}
|
|
403
|
+
return err instanceof Session || sessionClosed(err) ? Retry.Same : Retry.Never;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* A group was created at a start its track declared skipped.
|
|
407
|
+
*
|
|
408
|
+
* A skip says the start will never be produced, so it is final. See the group producer's
|
|
409
|
+
* `skip`, the gaps an append leaves, and `Requests.skipGroups`. Mirrors the Rust `Error::Skipped`.
|
|
410
|
+
*
|
|
411
|
+
* @public
|
|
412
|
+
*/
|
|
413
|
+
export class Skipped extends Error {
|
|
414
|
+
/** The start that was refused. */
|
|
415
|
+
start;
|
|
416
|
+
constructor(start) {
|
|
417
|
+
super(`group start ${start} was skipped`);
|
|
418
|
+
this.name = "Skipped";
|
|
419
|
+
this.start = start;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* The {@link StreamCode | StreamCode.ControlTimeout} error for a control request the peer never answered.
|
|
283
424
|
*
|
|
284
425
|
* A control request that outlives its deadline is not late content, so it does not go out as
|
|
285
|
-
* {@link StreamCode.DeliveryTimeout} the way a bare {@link TimeoutError} would. Callers that
|
|
426
|
+
* {@link StreamCode | StreamCode.DeliveryTimeout} the way a bare {@link TimeoutError} would. Callers that
|
|
286
427
|
* bound a request's response build this instead.
|
|
287
428
|
*
|
|
288
429
|
* @internal
|
|
@@ -291,6 +432,15 @@ export function controlTimeout(cause) {
|
|
|
291
432
|
const message = cause instanceof Error && cause.message ? cause.message : "control request timed out";
|
|
292
433
|
return new Stream(StreamCode.ControlTimeout, { cause, message });
|
|
293
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* The {@link StreamCode | StreamCode.Unauthorized} error for a request the grant does not cover, naming
|
|
437
|
+
* the broadcast. Unlike {@link SessionCode.Unauthorized}, it ends only this stream.
|
|
438
|
+
*
|
|
439
|
+
* @internal
|
|
440
|
+
*/
|
|
441
|
+
export function unauthorized(broadcast) {
|
|
442
|
+
return new Stream(StreamCode.Unauthorized, { message: `unauthorized: ${broadcast}` });
|
|
443
|
+
}
|
|
294
444
|
/**
|
|
295
445
|
* Decode a transport failure into a {@link Stream} when it carries a stream reset code,
|
|
296
446
|
* otherwise pass it through.
|
|
@@ -303,9 +453,8 @@ export function controlTimeout(cause) {
|
|
|
303
453
|
* the same `instanceof` as one raised here.
|
|
304
454
|
*
|
|
305
455
|
* On an IETF stream a code keeps its value unless moq-lite claims that number for something
|
|
306
|
-
* the draft does not
|
|
307
|
-
*
|
|
308
|
-
* read as {@link StreamCode.Internal} with the wire value kept in the message, since
|
|
456
|
+
* the draft does not, such as its own 48-63 range. Those read as
|
|
457
|
+
* {@link StreamCode | StreamCode.Internal} with the wire value kept in the message, since
|
|
309
458
|
* {@link StreamCode} is one numeric space and cannot hold a foreign code without lying about
|
|
310
459
|
* it. A code moq-lite names nothing for survives intact: nothing can misread it.
|
|
311
460
|
*
|
|
@@ -315,7 +464,7 @@ export function fromTransport(err, options) {
|
|
|
315
464
|
const code = streamCode(err);
|
|
316
465
|
if (code === undefined)
|
|
317
466
|
return error(err);
|
|
318
|
-
if (options?.version !== undefined && !sharedStreamCode(code
|
|
467
|
+
if (options?.version !== undefined && !sharedStreamCode(code) && claimedLocally(code)) {
|
|
319
468
|
return new Stream(StreamCode.Internal, { cause: err, message: `remote error: ${code}` });
|
|
320
469
|
}
|
|
321
470
|
if (code === StreamCode.TooFarBehind)
|
|
@@ -324,13 +473,15 @@ export function fromTransport(err, options) {
|
|
|
324
473
|
return new FrameTooLarge({ cause: err });
|
|
325
474
|
if (code === StreamCode.GroupTooLarge)
|
|
326
475
|
return new GroupTooLarge({ cause: err });
|
|
476
|
+
if (code === StreamCode.TimestampMismatch)
|
|
477
|
+
return new TimestampMismatch({ cause: err });
|
|
327
478
|
return new Stream(code, { cause: err });
|
|
328
479
|
}
|
|
329
480
|
/** The codes moq-lite names, which a foreign one must not borrow. */
|
|
330
|
-
const NAMED_CODES = new Set(Object.values(StreamCode));
|
|
481
|
+
const NAMED_CODES = new Set(Object.values(StreamCode).filter((code) => typeof code === "number"));
|
|
331
482
|
/**
|
|
332
483
|
* Whether moq-lite could give `code` a meaning of its own: one of its named codes, or
|
|
333
|
-
* anywhere in the 64+ range, where `StreamCode(code)` mints an application code and an
|
|
484
|
+
* anywhere in the 64+ range, where `StreamCode.app(code)` mints an application code and an
|
|
334
485
|
* application compares against its own. moq-transport registers nothing above 0x12 and has
|
|
335
486
|
* no application range at all, so a foreign code landing there is never what it looks like.
|
|
336
487
|
*/
|
|
@@ -343,7 +494,7 @@ const legacyWebTransportErrors = new WeakSet();
|
|
|
343
494
|
*
|
|
344
495
|
* Both the WebTransport spec and the WebSocket fallback take the reset code from a
|
|
345
496
|
* `WebTransportError`'s `streamErrorCode` and send 0 for anything else, a plain `Error`
|
|
346
|
-
* included. Since 0 is {@link StreamCode.Internal}, cancelling with a bare `Error` tells the
|
|
497
|
+
* included. Since 0 is {@link StreamCode | StreamCode.Internal}, cancelling with a bare `Error` tells the
|
|
347
498
|
* peer we failed rather than that we are done.
|
|
348
499
|
*
|
|
349
500
|
* The native constructor exists exactly where native WebTransport does, which is where the
|
|
@@ -383,6 +534,22 @@ export function fromClose(info) {
|
|
|
383
534
|
return null;
|
|
384
535
|
return new Session(code, { reason: info.reason });
|
|
385
536
|
}
|
|
537
|
+
// WebTransport rejects a close reason over 1024 bytes of UTF-8 by throwing, so a reason
|
|
538
|
+
// built from peer-supplied data has to be bounded before it gets there. A broadcast path
|
|
539
|
+
// is peer-supplied and long enough to reach this on its own.
|
|
540
|
+
const MAX_CLOSE_REASON = 1024;
|
|
541
|
+
/**
|
|
542
|
+
* The longest prefix of `text` that fits a session close reason. `encodeInto` stops on a
|
|
543
|
+
* whole code point, so `read` never lands mid-character the way slicing bytes would.
|
|
544
|
+
*
|
|
545
|
+
* @internal
|
|
546
|
+
*/
|
|
547
|
+
export function closeReason(text) {
|
|
548
|
+
const encoder = new TextEncoder();
|
|
549
|
+
const buf = new Uint8Array(MAX_CLOSE_REASON);
|
|
550
|
+
const { read } = encoder.encodeInto(text, buf);
|
|
551
|
+
return text.slice(0, read);
|
|
552
|
+
}
|
|
386
553
|
/**
|
|
387
554
|
* The session's close as the error it ends everything with, carrying the peer's code. A clean
|
|
388
555
|
* close code is still an error here: whatever the close cut off did not end.
|
|
@@ -392,6 +559,32 @@ export function fromClose(info) {
|
|
|
392
559
|
export function closeError(quic) {
|
|
393
560
|
return quic.closed.then((info) => fromClose(info) ?? new Session(SessionCode.Cancel, { reason: info.reason }), (err) => error(err));
|
|
394
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* Whether a stream failed because its whole session closed, rather than on its own.
|
|
564
|
+
*
|
|
565
|
+
* @internal
|
|
566
|
+
*/
|
|
567
|
+
export function sessionClosed(err) {
|
|
568
|
+
return typeof err === "object" && err !== null && err.source === "session";
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Whether a stream of `quic` failed because the peer reset or stopped it without an application
|
|
572
|
+
* code of its own, as a browser reports a closing session's WT_SESSION_GONE (as code 0), either raw
|
|
573
|
+
* or through {@link fromTransport}, rather than on a local error, a session close, or a reset with a
|
|
574
|
+
* code. Only native WebTransport cannot tell the two apart: the WebSocket fallback reports a
|
|
575
|
+
* session's close as such, so a code-0 reset there is the peer's internal error.
|
|
576
|
+
*
|
|
577
|
+
* @internal
|
|
578
|
+
*/
|
|
579
|
+
export function peerEnded(quic, err) {
|
|
580
|
+
if (transportOf(quic) !== "webtransport")
|
|
581
|
+
return false;
|
|
582
|
+
const raw = err instanceof Stream ? err.cause : err;
|
|
583
|
+
if (typeof raw !== "object" || raw === null)
|
|
584
|
+
return false;
|
|
585
|
+
const { source, streamErrorCode } = raw;
|
|
586
|
+
return source === "stream" && (streamErrorCode === 0 || streamErrorCode === null);
|
|
587
|
+
}
|
|
395
588
|
/**
|
|
396
589
|
* Report a failure the session's close caused as the session's own error, which carries the
|
|
397
590
|
* peer's close code; any other failure passes through.
|
|
@@ -399,8 +592,7 @@ export function closeError(quic) {
|
|
|
399
592
|
* @internal
|
|
400
593
|
*/
|
|
401
594
|
export async function sessionCause(quic, err) {
|
|
402
|
-
|
|
403
|
-
if (quic && source === "session")
|
|
595
|
+
if (quic && sessionClosed(err))
|
|
404
596
|
return closeError(quic);
|
|
405
597
|
return error(err);
|
|
406
598
|
}
|
package/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CACvC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAY,EAAe,EAAE,CAAC,eAAe,CAAC,IAAI,CAAgB,EAAE;IAClF,kDAAkD;IAClD,MAAM,EAAE,GAAkB;IAC1B,8DAA8D;IAC9D,QAAQ,EAAE,GAAkB;IAC5B,6FAA6F;IAC7F,YAAY,EAAE,GAAkB;IAChC,2DAA2D;IAC3D,iBAAiB,EAAE,GAAkB;IACrC,oEAAoE;IACpE,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K,MAAM,GAAG,CAAC,CAAC,CAAC,sBAAsB,MAAM,EAAE,CAAC;IAChF,CAAC;IAED,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,IAAI,eAAe,CAAC;AAC/C,CAAC","sourcesContent":["/**\n * Errors, including the code a peer reports when it resets a stream or closes the session.\n *\n * @module\n */\n\nimport { sharedStreamCode } from \"./ietf/error.ts\";\nimport type { IetfVersion } from \"./ietf/version.ts\";\nimport { TimeoutError } from \"./util/timeout.ts\";\n\n/** The nominal brand for session termination codes. */\ndeclare const SESSION_CODE: unique symbol;\n\n/** A code from the session termination registry. */\nexport type SessionCode = number & { readonly [SESSION_CODE]: true };\n\n/**\n * Codes a peer sends when terminating the session, mirroring the Rust `Session`.\n *\n * Specified by moq-lite, which reuses moq-transport's codes unchanged. Call `SessionCode(code)`\n * to construct an application code in the 64+ range. {@link StreamCode} is the other registry,\n * and the two are disjoint, so the same integer means different things in each.\n *\n * Codes 32-47 are reserved: nothing is sent there, and the draft gives a received one no\n * meaning, so treat anything not listed below as an unspecified error rather than guessing.\n *\n * @public\n */\nexport const SessionCode = Object.freeze(\n\tObject.assign((code: number): SessionCode => applicationCode(code) as SessionCode, {\n\t\t/** Ending the session normally, with no error. */\n\t\tCancel: 0x0 as SessionCode,\n\t\t/** Something went wrong that isn't worth a dedicated code. */\n\t\tInternal: 0x1 as SessionCode,\n\t\t/** The credentials don't grant the requested path or operation. Retrying will fail again. */\n\t\tUnauthorized: 0x2 as SessionCode,\n\t\t/** A protocol rule was broken; the session is unusable. */\n\t\tProtocolViolation: 0x3 as SessionCode,\n\t\t/** A key-value pair was malformed or repeated more than allowed. */\n\t\tKeyValueFormatting: 0x6 as SessionCode,\n\t\t/** The peer did not close within the GOAWAY drain deadline. */\n\t\tGoawayTimeout: 0x10 as SessionCode,\n\t\t/** A control message took too long. */\n\t\tTimeout: 0x11 as SessionCode,\n\t\t/** No version could be negotiated. */\n\t\tVersion: 0x15 as SessionCode,\n\t} as const),\n);\n\n/** The nominal brand for stream reset codes. */\ndeclare const STREAM_CODE: unique symbol;\n\n/** A code from the stream reset registry. */\nexport type StreamCode = number & { readonly [STREAM_CODE]: true };\n\n/**\n * Codes a peer sends when resetting a stream, mirroring the Rust `Stream`.\n *\n * The counterpart to {@link SessionCode}, and a disjoint space: a stream reset of 0 is\n * {@link StreamCode.Internal}, not a cancellation ({@link StreamCode.Cancel} is 1). Call\n * `StreamCode(code)` to construct an application code in the 64+ range.\n *\n * Conditions the shared codes don't cover are assigned in moq-lite's own 48-63 range, so a\n * received one is the named code. 32 through 47 is reserved: nothing is sent there and a\n * received one is an unspecified error.\n *\n * @public\n */\nexport const StreamCode = Object.freeze(\n\tObject.assign((code: number): StreamCode => applicationCode(code) as StreamCode, {\n\t\t/** Something went wrong that isn't worth a dedicated code. */\n\t\tInternal: 0x0 as StreamCode,\n\t\t/** The sender is done with this stream, not failing. A routine unsubscribe. */\n\t\tCancel: 0x1 as StreamCode,\n\t\t/** The content missed its delivery deadline. */\n\t\tDeliveryTimeout: 0x2 as StreamCode,\n\t\t/** The session ended, taking this stream with it. */\n\t\tSessionClosed: 0x3 as StreamCode,\n\t\t/** The session is going away (a GOAWAY was received). */\n\t\tGoingAway: 0x4 as StreamCode,\n\t\t/** The reader fell too far behind and content was dropped to catch up. */\n\t\tTooFarBehind: 0x5 as StreamCode,\n\t\t/** The track's content could not be parsed. */\n\t\tMalformedTrack: 0x12 as StreamCode,\n\t\t/** The peer took too long to answer a control request. */\n\t\tControlTimeout: 0x31 as StreamCode,\n\t\t/** The requested broadcast or track does not exist at the peer. */\n\t\tNotFound: 0x33 as StreamCode,\n\t\t/** The group was superseded by a newer one and dropped. */\n\t\tOld: 0x34 as StreamCode,\n\t\t/** The group was dropped under memory pressure, so it can be re-fetched. */\n\t\tEvicted: 0x35 as StreamCode,\n\t\t/** A frame declared a payload larger than the receiver accepts. */\n\t\tFrameTooLarge: 0x38 as StreamCode,\n\t\t/** The publisher could serve this request but has no capacity for it now. */\n\t\tNoCapacity: 0x30 as StreamCode,\n\t\t/** A group grew past its cache budget and was aborted. */\n\t\tGroupTooLarge: 0x32 as StreamCode,\n\t} as const),\n);\n\nfunction applicationCode(code: number): number {\n\tif (!Number.isInteger(code) || code < 64 || code > 0xffffffff) {\n\t\tthrow new RangeError(`invalid application error code: ${code}`);\n\t}\n\treturn code;\n}\n\n/**\n * An error the peer reported by closing the session, carrying its {@link SessionCode}.\n *\n * This surfaces on every transport, so catch this type rather than feature-detecting\n * `WebTransportError`, which a non-browser runtime never defines and the WebSocket fallback\n * never throws.\n *\n * ```ts\n * connection.error.subscribe((err) => {\n * if (err instanceof Session && err.code === SessionCode.Unauthorized) {\n * console.warn(\"server rejected the session\");\n * }\n * });\n * ```\n *\n * @public\n */\nexport class Session extends Error {\n\t/** The session code the peer sent, verbatim. */\n\treadonly code: SessionCode;\n\n\tconstructor(code: SessionCode, options?: { cause?: unknown; reason?: string }) {\n\t\tsuper(options?.reason ? `remote error: ${code} (${options.reason})` : `remote error: ${code}`, options);\n\t\tthis.name = \"Session\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Options for a {@link Stream}. */\nexport interface StreamOptions {\n\t/** The failure this one wraps. */\n\tcause?: unknown;\n\t/** The peer's human-readable reason, appended to the default message. */\n\treason?: string;\n\t/** Replaces the default `remote error: <code>` text, for a condition raised locally. */\n\tmessage?: string;\n}\n\n/**\n * An error carrying a {@link StreamCode}: the code a peer sent when it reset a stream, or the\n * one this side sends when it resets one.\n *\n * This surfaces on every transport, so catch this type rather than feature-detecting\n * `WebTransportError`, which a non-browser runtime never defines and the WebSocket fallback\n * never throws. Local conditions with a code of their own subclass it ({@link TooFarBehind},\n * {@link FrameTooLarge}, {@link GroupTooLarge}, {@link NotFound}), so the same `code` check catches a condition\n * whether it was raised here or reported by the peer.\n *\n * ```ts\n * try {\n * frame = await group.readFrame();\n * } catch (err) {\n * if (err instanceof Stream && err.code === StreamCode.Cancel) return;\n * throw err;\n * }\n * ```\n *\n * @public\n */\nexport class Stream extends Error {\n\t/** The stream code; moq-lite resets forward it verbatim. */\n\treadonly code: StreamCode;\n\n\tconstructor(code: StreamCode, options?: StreamOptions) {\n\t\tsuper(\n\t\t\toptions?.message ??\n\t\t\t\t(options?.reason ? `remote error: ${code} (${options.reason})` : `remote error: ${code}`),\n\t\t\toptions,\n\t\t);\n\t\tthis.name = \"Stream\";\n\t\tthis.code = code;\n\t}\n}\n\n/**\n * The reader asked for a frame the group never held, so the stream has a gap.\n *\n * Raised locally by a frame read, and decoded from a moq-lite peer's `TOO_FAR_BEHIND` reset, since a gap\n * reads the same either way.\n *\n * @public\n */\nexport class TooFarBehind extends Stream {\n\tconstructor(options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.TooFarBehind, {\n\t\t\t...options,\n\t\t\tmessage: \"lagged: frames were evicted before being read\",\n\t\t});\n\t\tthis.name = \"TooFarBehind\";\n\t}\n}\n\n/**\n * A frame is larger than a group can cache, so appending it would exceed the budget by itself.\n *\n * Raised locally by a frame write, and decoded from a moq-lite peer's `FRAME_TOO_LARGE` reset.\n * Mirrors the Rust `Error::FrameTooLarge`, which rejects the same frame before touching any state.\n *\n * @public\n */\nexport class FrameTooLarge extends Stream {\n\tconstructor(options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.FrameTooLarge, {\n\t\t\t...options,\n\t\t\tmessage: \"frame too large: larger than a group can cache\",\n\t\t});\n\t\tthis.name = \"FrameTooLarge\";\n\t}\n}\n\n/**\n * A write grew the group past its cache budget, so the group is aborted.\n *\n * Raised locally by a frame write, and decoded from a moq-lite peer's `GROUP_TOO_LARGE`\n * reset. Mirrors the Rust `Error::GroupTooLarge`.\n *\n * @public\n */\nexport class GroupTooLarge extends Stream {\n\tconstructor(options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.GroupTooLarge, {\n\t\t\t...options,\n\t\t\tmessage: \"group too large: exceeded the cache budget\",\n\t\t});\n\t\tthis.name = \"GroupTooLarge\";\n\t}\n}\n\n/**\n * The requested broadcast or track is not served here.\n *\n * @public\n */\nexport class NotFound extends Stream {\n\tconstructor(what: string, options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.NotFound, { ...options, message: `not found: ${what}` });\n\t\tthis.name = \"NotFound\";\n\t}\n}\n\n/**\n * A peer's GOAWAY named a redirect the connection refuses, or one it could not parse.\n *\n * Terminal: the peer is leaving, so the connection stops rather than redialing the old\n * address. Mirrors the Rust `Error::RefusedRedirect`.\n *\n * @public\n */\nexport class RefusedRedirect extends Error {\n\tconstructor(reason: string) {\n\t\tsuper(`GOAWAY redirect refused: ${reason}`);\n\t\tthis.name = \"RefusedRedirect\";\n\t}\n}\n\n/**\n * A peer broke the protocol in a way the spec says must end the session.\n *\n * Thrown where the violation is detected, rather than handled there: a decoder has no session\n * to close. The dispatch that owns the session watches for it and closes, so a nonconforming\n * peer cannot repeat the violation on the next stream.\n *\n * @public\n */\nexport class ProtocolViolation extends Error {\n\tconstructor(message: string, options?: { cause?: unknown }) {\n\t\tsuper(message, options);\n\t\tthis.name = \"ProtocolViolation\";\n\t}\n}\n\n/** Package-internal compatibility names used by the wire implementation. */\nexport { Session as SessionError, Stream as StreamError, TooFarBehind as Lagged };\n/** Package-internal compatibility name used by the wire implementation. */\nexport type StreamErrorOptions = StreamOptions;\n\n/** The WebTransport-shaped fields a stream reset code arrives in. */\ntype StreamErrorLike = { source?: unknown; streamErrorCode?: unknown };\n\nfunction streamCode(err: unknown): StreamCode | undefined {\n\tif (typeof err !== \"object\" || err === null) return undefined;\n\n\tconst { source, streamErrorCode } = err as StreamErrorLike;\n\tif (source !== \"stream\" || typeof streamErrorCode !== \"number\") return undefined;\n\n\treturn streamErrorCode as StreamCode;\n}\n\n/** Transport context for encoding and decoding errors. @internal */\ninterface TransportErrorOptions {\n\t/** The negotiated IETF draft, or absent for moq-lite. */\n\tversion?: IetfVersion;\n}\n\n/**\n * Which {@link StreamCode} to send when resetting a stream because of `err`.\n *\n * The counterpart to {@link fromTransport}, and the pair has to agree: a code we send for a\n * condition is the code we read that condition back from, or two peers disagree about what it\n * means. Mirrors the Rust `From<&Error> for Stream`.\n *\n * Lossy on purpose. An error describes what went wrong here, while the registry is what the peer\n * can act on, so anything without a code of its own degrades to {@link StreamCode.Internal}\n * rather than inventing one. A {@link Session} lands there too: the two registries are\n * disjoint, so forwarding its code onto a stream would mistranslate it.\n *\n * On an IETF stream the code has to be one the negotiated draft assigns the same meaning to,\n * so a condition it does not register degrades to INTERNAL_ERROR as well. See\n * {@link sharedStreamCode}.\n *\n * @internal\n */\nexport function toStreamCode(err: unknown, options?: TransportErrorOptions): StreamCode {\n\tconst code = localStreamCode(err);\n\tif (options?.version === undefined) return code;\n\treturn sharedStreamCode(code, options.version) ? code : StreamCode.Internal;\n}\n\n/** The moq-lite code for a local failure, before any draft has a say. */\nfunction localStreamCode(err: unknown): StreamCode {\n\tif (err instanceof Stream) return err.code;\n\tif (err instanceof TimeoutError) return StreamCode.DeliveryTimeout;\n\t// Session-scoped: the peer learns which rule it broke from the session close, not from here.\n\tif (err instanceof ProtocolViolation) return StreamCode.SessionClosed;\n\treturn StreamCode.Internal;\n}\n\n/**\n * The {@link StreamCode.ControlTimeout} error for a control request the peer never answered.\n *\n * A control request that outlives its deadline is not late content, so it does not go out as\n * {@link StreamCode.DeliveryTimeout} the way a bare {@link TimeoutError} would. Callers that\n * bound a request's response build this instead.\n *\n * @internal\n */\nexport function controlTimeout(cause: unknown): Stream {\n\tconst message = cause instanceof Error && cause.message ? cause.message : \"control request timed out\";\n\treturn new Stream(StreamCode.ControlTimeout, { cause, message });\n}\n\n/**\n * Decode a transport failure into a {@link Stream} when it carries a stream reset code,\n * otherwise pass it through.\n *\n * Native WebTransport rejects with a `WebTransportError`; the WebSocket fallback mints an error\n * with the same `source`/`streamErrorCode` fields. Reading the fields rather than the class\n * covers both, and works in a runtime with no `WebTransportError` at all.\n *\n * On moq-lite, a code with a local class decodes back into it, so a peer's condition is caught by\n * the same `instanceof` as one raised here.\n *\n * On an IETF stream a code keeps its value unless moq-lite claims that number for something\n * the draft does not: `0x4` is GOING_AWAY here but UNKNOWN_OBJECT_STATUS on draft-16 and 17,\n * and reading one back as the other would retire a session that is not going anywhere. Those\n * read as {@link StreamCode.Internal} with the wire value kept in the message, since\n * {@link StreamCode} is one numeric space and cannot hold a foreign code without lying about\n * it. A code moq-lite names nothing for survives intact: nothing can misread it.\n *\n * @internal Called at the transport boundary so the raw error never reaches an application.\n */\nexport function fromTransport(err: unknown, options?: TransportErrorOptions): Error {\n\tconst code = streamCode(err);\n\tif (code === undefined) return error(err);\n\tif (options?.version !== undefined && !sharedStreamCode(code, options.version) && claimedLocally(code)) {\n\t\treturn new Stream(StreamCode.Internal, { cause: err, message: `remote error: ${code}` });\n\t}\n\tif (code === StreamCode.TooFarBehind) return new TooFarBehind({ cause: err });\n\tif (code === StreamCode.FrameTooLarge) return new FrameTooLarge({ cause: err });\n\tif (code === StreamCode.GroupTooLarge) return new GroupTooLarge({ cause: err });\n\treturn new Stream(code, { cause: err });\n}\n\n/** The codes moq-lite names, which a foreign one must not borrow. */\nconst NAMED_CODES: ReadonlySet<number> = new Set(Object.values(StreamCode));\n\n/**\n * Whether moq-lite could give `code` a meaning of its own: one of its named codes, or\n * anywhere in the 64+ range, where `StreamCode(code)` mints an application code and an\n * application compares against its own. moq-transport registers nothing above 0x12 and has\n * no application range at all, so a foreign code landing there is never what it looks like.\n */\nfunction claimedLocally(code: number): boolean {\n\treturn code >= 64 || NAMED_CODES.has(code);\n}\n\nconst legacyWebTransportErrors = new WeakSet<object>();\n\n/**\n * Build the `reason` to hand `abort()` / `cancel()` so the transport puts `code` on the wire.\n *\n * Both the WebTransport spec and the WebSocket fallback take the reset code from a\n * `WebTransportError`'s `streamErrorCode` and send 0 for anything else, a plain `Error`\n * included. Since 0 is {@link StreamCode.Internal}, cancelling with a bare `Error` tells the\n * peer we failed rather than that we are done.\n *\n * The native constructor exists exactly where native WebTransport does, which is where the\n * fallback isn't used, so mint a matching shape elsewhere rather than feature-detect a global\n * that will not be there.\n *\n * @internal\n */\nexport function toTransport(code: StreamCode, message: string): Error {\n\tconst Native = (globalThis as { WebTransportError?: typeof WebTransportError }).WebTransportError;\n\tif (Native) {\n\t\tconst Legacy = Native as unknown as new (init: { message: string; streamErrorCode: number }) => Error;\n\t\tif (legacyWebTransportErrors.has(Native)) return new Legacy({ message, streamErrorCode: code });\n\n\t\ttry {\n\t\t\treturn new Native(message, { source: \"stream\", streamErrorCode: code });\n\t\t} catch (err) {\n\t\t\t// Chromium still implements the previous single-dictionary constructor.\n\t\t\tif (!(err instanceof TypeError)) throw err;\n\t\t\tlegacyWebTransportErrors.add(Native);\n\t\t\treturn new Legacy({ message, streamErrorCode: code });\n\t\t}\n\t}\n\n\treturn Object.assign(new Error(message), { source: \"stream\" as const, streamErrorCode: code });\n}\n\n/**\n * Decode a session close into its terminal error: `null` for a clean close\n * ({@link SessionCode.Cancel}), otherwise a {@link Session} carrying the peer's code.\n *\n * @internal Applied to the transport's `closed` info so the code survives to the application.\n */\nexport function fromClose(info: WebTransportCloseInfo): Session | null {\n\tconst code = (info.closeCode ?? SessionCode.Cancel) as SessionCode;\n\tif (code === SessionCode.Cancel) return null;\n\treturn new Session(code, { reason: info.reason });\n}\n\n/**\n * The session's close as the error it ends everything with, carrying the peer's code. A clean\n * close code is still an error here: whatever the close cut off did not end.\n *\n * @internal\n */\nexport function closeError(quic: WebTransport): Promise<Error> {\n\treturn quic.closed.then(\n\t\t(info) => fromClose(info) ?? new Session(SessionCode.Cancel, { reason: info.reason }),\n\t\t(err: unknown) => error(err),\n\t);\n}\n\n/**\n * Report a failure the session's close caused as the session's own error, which carries the\n * peer's close code; any other failure passes through.\n *\n * @internal\n */\nexport async function sessionCause(quic: WebTransport | undefined, err: unknown): Promise<Error> {\n\tconst source = typeof err === \"object\" && err !== null ? (err as { source?: unknown }).source : undefined;\n\tif (quic && source === \"session\") return closeError(quic);\n\treturn error(err);\n}\n\n/**\n * Coerce an unknown thrown value into an `Error`.\n *\n * @internal\n */\nexport function error(err: unknown): Error {\n\treturn err instanceof Error ? err : new Error(String(err));\n}\n\n/**\n * Format an error into a non-empty, human-readable string for logging.\n *\n * Safari always leaves `WebTransportError.message` blank, so a bare `err.message` degrades to\n * an empty string and the reason is lost. This falls back to the error type name and appends\n * the WebTransport `source` and application `streamErrorCode`, so the log line always says\n * something.\n */\nexport function reason(err: unknown): string {\n\tconst e = error(err);\n\n\t// WebTransportError carries the failure origin and the peer's application error code,\n\t// often the only identifying detail since WebKit leaves `message` empty.\n\tif (typeof WebTransportError !== \"undefined\" && e instanceof WebTransportError) {\n\t\tconst parts = [`source=${e.source}`];\n\t\tif (e.streamErrorCode !== null) parts.push(`code=${e.streamErrorCode}`);\n\t\tconst detail = parts.join(\" \");\n\t\treturn e.message ? `${e.message} (${detail})` : `WebTransportError: ${detail}`;\n\t}\n\n\treturn e.message || e.name || \"unknown error\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,gGAAgG;IAChG,GAAG,EAAE,CAAC,IAAY,EAAe,EAAE,CAAC,eAAe,CAAC,IAAI,CAAgB;IACxE,kDAAkD;IAClD,MAAM,EAAE,GAAkB;IAC1B,8DAA8D;IAC9D,QAAQ,EAAE,GAAkB;IAC5B,6FAA6F;IAC7F,YAAY,EAAE,GAAkB;IAChC,wFAAwF;IACxF,OAAO,EAAE,IAAmB;IAC5B,2DAA2D;IAC3D,iBAAiB,EAAE,GAAkB;IACrC,+GAA+G;IAC/G,eAAe,EAAE,GAAkB;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CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,sBAAsB,MAAM,EAAE,CAAC;IAChF,CAAC;IAED,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,IAAI,eAAe,CAAC;AAC/C,CAAC","sourcesContent":["/**\n * Errors, including the code a peer reports when it resets a stream or closes the session.\n *\n * @module\n */\n\nimport type { Duration } from \"@moq/clock\";\nimport { transportOf } from \"./connection/transport.ts\";\nimport { sharedStreamCode } from \"./ietf/error.ts\";\nimport type { IetfVersion } from \"./ietf/version.ts\";\nimport { TimeoutError } from \"./util/timeout.ts\";\n\n/** The nominal brand for session termination codes. */\ndeclare const SESSION_CODE: unique symbol;\n\n/** A code from the session termination registry. */\nexport type SessionCode = number & { readonly [SESSION_CODE]: true };\n\n/**\n * Codes a peer sends when terminating the session, mirroring the Rust `Session`.\n *\n * moq-lite's registry, which reuses moq-transport's value for each code the two share. Call\n * `SessionCode.app(code)` to construct an application code: `code` is 0-based and sent as\n * `64 + code`, as the Rust `SessionError::App` is. {@link StreamCode} is\n * the other registry, and the two are disjoint, so the same integer means different things in\n * each.\n *\n * Codes 32-47 are reserved: nothing is sent there, and the draft gives a received one no\n * meaning. A code only moq-transport defines arrives as its number too, so treat anything not\n * listed below as an unspecified error rather than guessing.\n *\n * @public\n */\nexport const SessionCode = Object.freeze({\n\t/** An application's own code, 0 through 65535, sent past the library's range as `64 + code`. */\n\tapp: (code: number): SessionCode => applicationCode(code) as SessionCode,\n\t/** Ending the session normally, with no error. */\n\tCancel: 0x0 as SessionCode,\n\t/** Something went wrong that isn't worth a dedicated code. */\n\tInternal: 0x1 as SessionCode,\n\t/** The credentials don't grant the requested path or operation. Retrying will fail again. */\n\tUnauthorized: 0x2 as SessionCode,\n\t/** The authorization token expired. Retrying with refreshed credentials may succeed. */\n\tExpired: 0x18 as SessionCode,\n\t/** A protocol rule was broken; the session is unusable. */\n\tProtocolViolation: 0x3 as SessionCode,\n\t/** The peer went past what the session allows: a request ID past MAX_REQUEST_ID, or too many announcements. */\n\tTooManyRequests: 0x7 as SessionCode,\n\t/** The peer did not close within the GOAWAY drain deadline. */\n\tGoawayTimeout: 0x10 as SessionCode,\n\t/** A control message took too long. */\n\tTimeout: 0x11 as SessionCode,\n\t/** No version could be negotiated. */\n\tVersion: 0x15 as SessionCode,\n\t/** The token could not be parsed. Retrying with the same token will fail again. */\n\tMalformedAuthToken: 0x16 as SessionCode,\n\t/** The peer cannot support the requested feature, token, or grant. */\n\tUnsupported: 0x30 as SessionCode,\n} as const);\n\n/** The nominal brand for stream reset codes. */\ndeclare const STREAM_CODE: unique symbol;\n\n/** A code from the stream reset registry. */\nexport type StreamCode = number & { readonly [STREAM_CODE]: true };\n\n/**\n * Codes a peer sends when resetting a stream, mirroring the Rust `Stream`.\n *\n * The counterpart to {@link SessionCode}, and a disjoint space: a stream reset of 0 is\n * `StreamCode.Internal`, not a cancellation (`StreamCode.Cancel` is 1). Call\n * `StreamCode.app(code)` to construct an application code: `code` is 0-based and sent as\n * `64 + code`, as the Rust `StreamError::App` is.\n *\n * Conditions the shared codes don't cover are assigned in moq-lite's own 48-63 range, so a\n * received one is the named code. 32 through 47 is reserved: nothing is sent there and a\n * received one is an unspecified error.\n *\n * @public\n */\nexport const StreamCode = Object.freeze({\n\t/** An application's own code, 0 through 65535, sent past the library's range as `64 + code`. */\n\tapp: (code: number): StreamCode => applicationCode(code) as StreamCode,\n\t/** Something went wrong that isn't worth a dedicated code. */\n\tInternal: 0x0 as StreamCode,\n\t/** The sender is done with this stream, not failing. A routine unsubscribe. */\n\tCancel: 0x1 as StreamCode,\n\t/** The content missed its delivery deadline. */\n\tDeliveryTimeout: 0x2 as StreamCode,\n\t/** The session ended, taking this stream with it. */\n\tSessionClosed: 0x3 as StreamCode,\n\t/** The session is going away (a GOAWAY was received). */\n\tGoingAway: 0x4 as StreamCode,\n\t/** The reader fell too far behind and content was dropped to catch up. */\n\tTooFarBehind: 0x5 as StreamCode,\n\t/** The track's content could not be parsed. */\n\tMalformedTrack: 0x12 as StreamCode,\n\t/** The request asks what the publisher can't serve on this track, such as a time on a live-only one. */\n\tNotSupported: 0x30 as StreamCode,\n\t/** The peer took too long to answer a control request. */\n\tControlTimeout: 0x31 as StreamCode,\n\t/** The requested broadcast or track does not exist at the peer. */\n\tNotFound: 0x33 as StreamCode,\n\t/** The group was superseded by a newer one and dropped. */\n\tOld: 0x34 as StreamCode,\n\t/** The group was dropped under memory pressure, so it can be re-fetched. */\n\tEvicted: 0x35 as StreamCode,\n\t/** A frame declared a payload larger than the receiver accepts. */\n\tFrameTooLarge: 0x38 as StreamCode,\n\t/** A frame ended at a different size than declared. */\n\tWrongSize: 0x37 as StreamCode,\n\t/** The broadcast is neither announced nor served, so there is no route to it. */\n\tUnroutable: 0x36 as StreamCode,\n\t/** The grant does not cover this request, or no longer does. The session stays up. */\n\tUnauthorized: 0x3b as StreamCode,\n\t/** A group grew past its cache budget and was aborted. */\n\tGroupTooLarge: 0x32 as StreamCode,\n\t/** A frame's timedness or timestamp doesn't match its track's timescale. */\n\tTimestampMismatch: 0x39 as StreamCode,\n\t/** The group start will never be produced (declared skipped, or a discontinuity). */\n\tSkip: 0x3a as StreamCode,\n} as const);\n\n// The wire code for an application's 0-based `code`, bounded to u16 as Rust bounds `App`.\nfunction applicationCode(code: number): number {\n\tif (!Number.isInteger(code) || code < 0 || code > 0xffff) {\n\t\tthrow new RangeError(`invalid application error code: ${code}`);\n\t}\n\treturn code + 64;\n}\n\n/**\n * An error the peer reported by closing the session, carrying its {@link SessionCode}.\n *\n * This surfaces on every transport, so catch this type rather than feature-detecting\n * `WebTransportError`, which a non-browser runtime never defines and the WebSocket fallback\n * never throws.\n *\n * ```ts\n * connection.error.subscribe((err) => {\n * if (err instanceof Session && err.code === SessionCode.Unauthorized) {\n * console.warn(\"server rejected the session\");\n * }\n * });\n * ```\n *\n * @public\n */\nexport class Session extends Error {\n\t/** The session code the peer sent, verbatim. */\n\treadonly code: SessionCode;\n\n\tconstructor(code: SessionCode, options?: { cause?: unknown; reason?: string }) {\n\t\tsuper(options?.reason ? `remote error: ${code} (${options.reason})` : `remote error: ${code}`, options);\n\t\tthis.name = \"Session\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Options for a {@link Stream}. */\nexport interface StreamOptions {\n\t/** The failure this one wraps. */\n\tcause?: unknown;\n\t/** The peer's human-readable reason, appended to the default message. */\n\treason?: string;\n\t/** Replaces the default `remote error: <code>` text, for a condition raised locally. */\n\tmessage?: string;\n}\n\n/**\n * An error carrying a {@link StreamCode}: the code a peer sent when it reset a stream, or the\n * one this side sends when it resets one.\n *\n * This surfaces on every transport, so catch this type rather than feature-detecting\n * `WebTransportError`, which a non-browser runtime never defines and the WebSocket fallback\n * never throws. Local conditions with a code of their own subclass it ({@link TooFarBehind},\n * {@link FrameTooLarge}, {@link GroupTooLarge}, {@link TimestampMismatch}, {@link NotFound}), so the same `code` check catches a condition\n * whether it was raised here or reported by the peer.\n *\n * ```ts\n * try {\n * frame = await group.readFrame();\n * } catch (err) {\n * if (err instanceof Stream && err.code === StreamCode.Cancel) return;\n * throw err;\n * }\n * ```\n *\n * @public\n */\nexport class Stream extends Error {\n\t/** The stream code; moq-lite resets forward it verbatim. */\n\treadonly code: StreamCode;\n\n\tconstructor(code: StreamCode, options?: StreamOptions) {\n\t\tsuper(\n\t\t\toptions?.message ??\n\t\t\t\t(options?.reason ? `remote error: ${code} (${options.reason})` : `remote error: ${code}`),\n\t\t\toptions,\n\t\t);\n\t\tthis.name = \"Stream\";\n\t\tthis.code = code;\n\t}\n}\n\n/**\n * The reader asked for a frame the group never held, so the stream has a gap.\n *\n * Raised locally by a frame read, and decoded from a moq-lite peer's `TOO_FAR_BEHIND` reset, since a gap\n * reads the same either way.\n *\n * @public\n */\nexport class TooFarBehind extends Stream {\n\tconstructor(options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.TooFarBehind, {\n\t\t\t...options,\n\t\t\tmessage: \"lagged: frames were evicted before being read\",\n\t\t});\n\t\tthis.name = \"TooFarBehind\";\n\t}\n}\n\n/**\n * A frame is larger than a group can cache, so appending it would exceed the budget by itself.\n *\n * Raised locally by a frame write, and decoded from a moq-lite peer's `FRAME_TOO_LARGE` reset.\n * Mirrors the Rust `StreamError::FrameTooLarge`, which rejects the same frame before touching any state.\n *\n * @public\n */\nexport class FrameTooLarge extends Stream {\n\tconstructor(options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.FrameTooLarge, {\n\t\t\t...options,\n\t\t\tmessage: \"frame too large: larger than a group can cache\",\n\t\t});\n\t\tthis.name = \"FrameTooLarge\";\n\t}\n}\n\n/**\n * A peer could not retain a group and aborted it.\n *\n * Decoded from a moq-lite peer's `GROUP_TOO_LARGE` reset. Local groups shed their front\n * instead of aborting when their retained tail exceeds its budget.\n *\n * @public\n */\nexport class GroupTooLarge extends Stream {\n\tconstructor(options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.GroupTooLarge, {\n\t\t\t...options,\n\t\t\tmessage: \"group too large: exceeded the cache budget\",\n\t\t});\n\t\tthis.name = \"GroupTooLarge\";\n\t}\n}\n\n/**\n * A frame's timestamp doesn't fit its track: a timestamp on a track with no timescale, none\n * on a track that has one, or a group's first frame starting before the group below it.\n *\n * Raised locally by a frame or datagram write, and decoded from a moq-lite peer's\n * `TIMESTAMP_MISMATCH` reset. Mirrors the Rust `StreamError::TimestampMismatch`.\n *\n * @public\n */\nexport class TimestampMismatch extends Stream {\n\tconstructor(options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.TimestampMismatch, {\n\t\t\t...options,\n\t\t\tmessage: \"frame timestamp doesn't fit its track\",\n\t\t});\n\t\tthis.name = \"TimestampMismatch\";\n\t}\n}\n\n/**\n * The requested broadcast or track is not served here.\n *\n * @public\n */\nexport class NotFound extends Stream {\n\tconstructor(what: string, options?: { cause?: unknown }) {\n\t\tsuper(StreamCode.NotFound, { ...options, message: `not found: ${what}` });\n\t\tthis.name = \"NotFound\";\n\t}\n}\n\n/**\n * A peer's GOAWAY named a redirect the connection refuses, or one it could not parse.\n *\n * Terminal: the peer is leaving, so the connection stops rather than redialing the old\n * address. Mirrors the Rust `Error::RefusedRedirect`.\n *\n * @public\n */\nexport class RefusedRedirect extends Error {\n\tconstructor(reason: string) {\n\t\tsuper(`GOAWAY redirect refused: ${reason}`);\n\t\tthis.name = \"RefusedRedirect\";\n\t}\n}\n\n/**\n * The dial and the MoQ handshake together outlived the connect's `timeout` option.\n *\n * A caller can retry it. Mirrors the Rust `Error::ConnectTimeout`.\n *\n * @public\n */\nexport class ConnectTimeout extends Error {\n\t/** The timeout that elapsed. */\n\treadonly timeout: Duration;\n\n\tconstructor(timeout: Duration) {\n\t\tsuper(`connect timed out after ${timeout}`);\n\t\tthis.name = \"ConnectTimeout\";\n\t\tthis.timeout = timeout;\n\t}\n}\n\n/**\n * A peer broke the protocol in a way the spec says must end the session.\n *\n * Thrown where the violation is detected, rather than handled there: a decoder has no session\n * to close. The dispatch that owns the session watches for it and closes, so a nonconforming\n * peer cannot repeat the violation on the next stream.\n *\n * @public\n */\nexport class ProtocolViolation extends Error {\n\t/** The session code to close with: `ProtocolViolation` unless the draft names a more specific one. */\n\treadonly code: SessionCode;\n\n\tconstructor(message: string, options?: { cause?: unknown; code?: SessionCode }) {\n\t\tsuper(message, options);\n\t\tthis.name = \"ProtocolViolation\";\n\t\tthis.code = options?.code ?? SessionCode.ProtocolViolation;\n\t}\n}\n\n/** Package-internal compatibility names used by the wire implementation. */\nexport { Session as SessionError, Stream as StreamError, TooFarBehind as Lagged };\n\n/** The WebTransport-shaped fields a stream reset code arrives in. */\ntype StreamErrorLike = { source?: unknown; streamErrorCode?: unknown };\n\n/**\n * The raw code a transport's stream error carries, or undefined for any other error.\n *\n * @internal\n */\nexport function streamCode(err: unknown): StreamCode | undefined {\n\tif (typeof err !== \"object\" || err === null) return undefined;\n\n\tconst { source, streamErrorCode } = err as StreamErrorLike;\n\tif (source !== \"stream\" || typeof streamErrorCode !== \"number\") return undefined;\n\n\treturn streamErrorCode as StreamCode;\n}\n\n/** Transport context for encoding and decoding errors. @internal */\ninterface TransportErrorOptions {\n\t/** The negotiated IETF draft, or absent for moq-lite. */\n\tversion?: IetfVersion;\n}\n\n/**\n * Which {@link StreamCode} to send when resetting a stream because of `err`.\n *\n * The counterpart to {@link fromTransport}, and the pair has to agree: a code we send for a\n * condition is the code we read that condition back from, or two peers disagree about what it\n * means. Mirrors the Rust `From<&Error> for Stream`.\n *\n * Lossy on purpose. An error describes what went wrong here, while the registry is what the peer\n * can act on, so anything without a code of its own degrades to {@link StreamCode | StreamCode.Internal}\n * rather than inventing one. A {@link Session} is {@link StreamCode | StreamCode.Unroutable}: a stream that\n * can still be reset outlived the session that failed, so that was the route it was served\n * through, and forwarding the session's code would mistranslate it across disjoint registries.\n * An application code is the exception, since both registries share the 64+ range. A session\n * that failed at the transport, with no code at all, is {@link StreamCode | StreamCode.Unroutable} too.\n *\n * On an IETF stream the code has to be one the negotiated draft assigns the same meaning to,\n * so a condition it does not register degrades to INTERNAL_ERROR as well. See\n * {@link sharedStreamCode}.\n *\n * @internal\n */\nexport function toStreamCode(err: unknown, options?: TransportErrorOptions): StreamCode {\n\tconst code = localStreamCode(err);\n\tif (options?.version === undefined) return code;\n\treturn sharedStreamCode(code) ? code : StreamCode.Internal;\n}\n\n/** The moq-lite code for a local failure, before any draft has a say. */\nfunction localStreamCode(err: unknown): StreamCode {\n\tif (err instanceof Stream) return err.code;\n\tif (err instanceof TimeoutError) return StreamCode.DeliveryTimeout;\n\t// Session-scoped: the peer learns which rule it broke from the session close, not from here.\n\tif (err instanceof ProtocolViolation) return StreamCode.SessionClosed;\n\t// App codes share the 64+ range in both registries.\n\tif (err instanceof Session) return err.code >= 64 ? (err.code as number as StreamCode) : StreamCode.Unroutable;\n\t// A session that failed underneath without a close code, as on a network or idle failure.\n\tconst source = typeof err === \"object\" && err !== null ? (err as { source?: unknown }).source : undefined;\n\tif (source === \"session\") return StreamCode.Unroutable;\n\treturn StreamCode.Internal;\n}\n\n/**\n * What a caller does after a request fails, as {@link retry} answers it. Mirrors the Rust `Retry`.\n *\n * @public\n */\nexport const Retry = Object.freeze({\n\t/**\n\t * The source failed to deliver rather than judging the request, so asking it again may\n\t * succeed: its connection dropped, its session ended, or it is going away.\n\t */\n\tSame: \"same\",\n\t/**\n\t * The source lost its route to the content, so only another route continues it. Asking the\n\t * same source again can only replace the withdrawal's cause with a refusal.\n\t */\n\tReroute: \"reroute\",\n\t/**\n\t * The answer judged the request or what it carried, so it repeats on every attempt: refused,\n\t * not found, or malformed.\n\t */\n\tNever: \"never\",\n} as const);\n\n/** One of the {@link Retry} answers. @public */\nexport type Retry = (typeof Retry)[keyof typeof Retry];\n\n// Stream codes that report the source failing to deliver rather than judging what it carried.\nconst DELIVERY_FAILURES: ReadonlySet<number> = new Set([\n\tStreamCode.Internal,\n\tStreamCode.Cancel,\n\tStreamCode.SessionClosed,\n\tStreamCode.GoingAway,\n\tStreamCode.ControlTimeout,\n]);\n\n/**\n * What to do after a request failed with `err`: ask the same source again, find another route,\n * or give up. Mirrors the Rust `Error::retry`.\n *\n * A session closing, whatever its code, is the route failing to deliver: whether the session\n * comes back is the connection's call, not the request's.\n *\n * @public\n */\nexport function retry(err: unknown): Retry {\n\tif (err instanceof Stream) {\n\t\tif (err.code === StreamCode.Unroutable) return Retry.Reroute;\n\t\treturn DELIVERY_FAILURES.has(err.code) ? Retry.Same : Retry.Never;\n\t}\n\treturn err instanceof Session || sessionClosed(err) ? Retry.Same : Retry.Never;\n}\n\n/**\n * A group was created at a start its track declared skipped.\n *\n * A skip says the start will never be produced, so it is final. See the group producer's\n * `skip`, the gaps an append leaves, and `Requests.skipGroups`. Mirrors the Rust `Error::Skipped`.\n *\n * @public\n */\nexport class Skipped extends Error {\n\t/** The start that was refused. */\n\treadonly start: bigint;\n\n\tconstructor(start: bigint) {\n\t\tsuper(`group start ${start} was skipped`);\n\t\tthis.name = \"Skipped\";\n\t\tthis.start = start;\n\t}\n}\n\n/**\n * The {@link StreamCode | StreamCode.ControlTimeout} error for a control request the peer never answered.\n *\n * A control request that outlives its deadline is not late content, so it does not go out as\n * {@link StreamCode | StreamCode.DeliveryTimeout} the way a bare {@link TimeoutError} would. Callers that\n * bound a request's response build this instead.\n *\n * @internal\n */\nexport function controlTimeout(cause: unknown): Stream {\n\tconst message = cause instanceof Error && cause.message ? cause.message : \"control request timed out\";\n\treturn new Stream(StreamCode.ControlTimeout, { cause, message });\n}\n\n/**\n * The {@link StreamCode | StreamCode.Unauthorized} error for a request the grant does not cover, naming\n * the broadcast. Unlike {@link SessionCode.Unauthorized}, it ends only this stream.\n *\n * @internal\n */\nexport function unauthorized(broadcast: string): Stream {\n\treturn new Stream(StreamCode.Unauthorized, { message: `unauthorized: ${broadcast}` });\n}\n\n/**\n * Decode a transport failure into a {@link Stream} when it carries a stream reset code,\n * otherwise pass it through.\n *\n * Native WebTransport rejects with a `WebTransportError`; the WebSocket fallback mints an error\n * with the same `source`/`streamErrorCode` fields. Reading the fields rather than the class\n * covers both, and works in a runtime with no `WebTransportError` at all.\n *\n * On moq-lite, a code with a local class decodes back into it, so a peer's condition is caught by\n * the same `instanceof` as one raised here.\n *\n * On an IETF stream a code keeps its value unless moq-lite claims that number for something\n * the draft does not, such as its own 48-63 range. Those read as\n * {@link StreamCode | StreamCode.Internal} with the wire value kept in the message, since\n * {@link StreamCode} is one numeric space and cannot hold a foreign code without lying about\n * it. A code moq-lite names nothing for survives intact: nothing can misread it.\n *\n * @internal Called at the transport boundary so the raw error never reaches an application.\n */\nexport function fromTransport(err: unknown, options?: TransportErrorOptions): Error {\n\tconst code = streamCode(err);\n\tif (code === undefined) return error(err);\n\tif (options?.version !== undefined && !sharedStreamCode(code) && claimedLocally(code)) {\n\t\treturn new Stream(StreamCode.Internal, { cause: err, message: `remote error: ${code}` });\n\t}\n\tif (code === StreamCode.TooFarBehind) return new TooFarBehind({ cause: err });\n\tif (code === StreamCode.FrameTooLarge) return new FrameTooLarge({ cause: err });\n\tif (code === StreamCode.GroupTooLarge) return new GroupTooLarge({ cause: err });\n\tif (code === StreamCode.TimestampMismatch) return new TimestampMismatch({ cause: err });\n\treturn new Stream(code, { cause: err });\n}\n\n/** The codes moq-lite names, which a foreign one must not borrow. */\nconst NAMED_CODES: ReadonlySet<number> = new Set(\n\tObject.values(StreamCode).filter((code): code is StreamCode => typeof code === \"number\"),\n);\n\n/**\n * Whether moq-lite could give `code` a meaning of its own: one of its named codes, or\n * anywhere in the 64+ range, where `StreamCode.app(code)` mints an application code and an\n * application compares against its own. moq-transport registers nothing above 0x12 and has\n * no application range at all, so a foreign code landing there is never what it looks like.\n */\nfunction claimedLocally(code: number): boolean {\n\treturn code >= 64 || NAMED_CODES.has(code);\n}\n\nconst legacyWebTransportErrors = new WeakSet<object>();\n\n/**\n * Build the `reason` to hand `abort()` / `cancel()` so the transport puts `code` on the wire.\n *\n * Both the WebTransport spec and the WebSocket fallback take the reset code from a\n * `WebTransportError`'s `streamErrorCode` and send 0 for anything else, a plain `Error`\n * included. Since 0 is {@link StreamCode | StreamCode.Internal}, cancelling with a bare `Error` tells the\n * peer we failed rather than that we are done.\n *\n * The native constructor exists exactly where native WebTransport does, which is where the\n * fallback isn't used, so mint a matching shape elsewhere rather than feature-detect a global\n * that will not be there.\n *\n * @internal\n */\nexport function toTransport(code: StreamCode, message: string): Error {\n\tconst Native = (globalThis as { WebTransportError?: typeof WebTransportError }).WebTransportError;\n\tif (Native) {\n\t\tconst Legacy = Native as unknown as new (init: { message: string; streamErrorCode: number }) => Error;\n\t\tif (legacyWebTransportErrors.has(Native)) return new Legacy({ message, streamErrorCode: code });\n\n\t\ttry {\n\t\t\treturn new Native(message, { source: \"stream\", streamErrorCode: code });\n\t\t} catch (err) {\n\t\t\t// Chromium still implements the previous single-dictionary constructor.\n\t\t\tif (!(err instanceof TypeError)) throw err;\n\t\t\tlegacyWebTransportErrors.add(Native);\n\t\t\treturn new Legacy({ message, streamErrorCode: code });\n\t\t}\n\t}\n\n\treturn Object.assign(new Error(message), { source: \"stream\" as const, streamErrorCode: code });\n}\n\n/**\n * Decode a session close into its terminal error: `null` for a clean close\n * ({@link SessionCode.Cancel}), otherwise a {@link Session} carrying the peer's code.\n *\n * @internal Applied to the transport's `closed` info so the code survives to the application.\n */\nexport function fromClose(info: WebTransportCloseInfo): Session | null {\n\tconst code = (info.closeCode ?? SessionCode.Cancel) as SessionCode;\n\tif (code === SessionCode.Cancel) return null;\n\treturn new Session(code, { reason: info.reason });\n}\n\n// WebTransport rejects a close reason over 1024 bytes of UTF-8 by throwing, so a reason\n// built from peer-supplied data has to be bounded before it gets there. A broadcast path\n// is peer-supplied and long enough to reach this on its own.\nconst MAX_CLOSE_REASON = 1024;\n\n/**\n * The longest prefix of `text` that fits a session close reason. `encodeInto` stops on a\n * whole code point, so `read` never lands mid-character the way slicing bytes would.\n *\n * @internal\n */\nexport function closeReason(text: string): string {\n\tconst encoder = new TextEncoder();\n\tconst buf = new Uint8Array(MAX_CLOSE_REASON);\n\tconst { read } = encoder.encodeInto(text, buf);\n\treturn text.slice(0, read);\n}\n\n/**\n * The session's close as the error it ends everything with, carrying the peer's code. A clean\n * close code is still an error here: whatever the close cut off did not end.\n *\n * @internal\n */\nexport function closeError(quic: WebTransport): Promise<Error> {\n\treturn quic.closed.then(\n\t\t(info) => fromClose(info) ?? new Session(SessionCode.Cancel, { reason: info.reason }),\n\t\t(err: unknown) => error(err),\n\t);\n}\n\n/**\n * Whether a stream failed because its whole session closed, rather than on its own.\n *\n * @internal\n */\nexport function sessionClosed(err: unknown): boolean {\n\treturn typeof err === \"object\" && err !== null && (err as { source?: unknown }).source === \"session\";\n}\n\n/**\n * Whether a stream of `quic` failed because the peer reset or stopped it without an application\n * code of its own, as a browser reports a closing session's WT_SESSION_GONE (as code 0), either raw\n * or through {@link fromTransport}, rather than on a local error, a session close, or a reset with a\n * code. Only native WebTransport cannot tell the two apart: the WebSocket fallback reports a\n * session's close as such, so a code-0 reset there is the peer's internal error.\n *\n * @internal\n */\nexport function peerEnded(quic: WebTransport, err: unknown): boolean {\n\tif (transportOf(quic) !== \"webtransport\") return false;\n\tconst raw = err instanceof Stream ? err.cause : err;\n\tif (typeof raw !== \"object\" || raw === null) return false;\n\tconst { source, streamErrorCode } = raw as StreamErrorLike;\n\treturn source === \"stream\" && (streamErrorCode === 0 || streamErrorCode === null);\n}\n\n/**\n * Report a failure the session's close caused as the session's own error, which carries the\n * peer's close code; any other failure passes through.\n *\n * @internal\n */\nexport async function sessionCause(quic: WebTransport | undefined, err: unknown): Promise<Error> {\n\tif (quic && sessionClosed(err)) return closeError(quic);\n\treturn error(err);\n}\n\n/**\n * Coerce an unknown thrown value into an `Error`.\n *\n * @internal\n */\nexport function error(err: unknown): Error {\n\treturn err instanceof Error ? err : new Error(String(err));\n}\n\n/**\n * Format an error into a non-empty, human-readable string for logging.\n *\n * Safari always leaves `WebTransportError.message` blank, so a bare `err.message` degrades to\n * an empty string and the reason is lost. This falls back to the error type name and appends\n * the WebTransport `source` and application `streamErrorCode`, so the log line always says\n * something.\n */\nexport function reason(err: unknown): string {\n\tconst e = error(err);\n\n\t// WebTransportError carries the failure origin and the peer's application error code,\n\t// often the only identifying detail since WebKit leaves `message` empty.\n\tif (typeof WebTransportError !== \"undefined\" && e instanceof WebTransportError) {\n\t\tconst parts = [`source=${e.source}`];\n\t\tif (e.streamErrorCode !== null) parts.push(`code=${e.streamErrorCode}`);\n\t\tconst detail = parts.join(\" \");\n\t\treturn e.message ? `${e.message} (${detail})` : `WebTransportError: ${detail}`;\n\t}\n\n\treturn e.message || e.name || \"unknown error\";\n}\n"]}
|
package/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Session and stream error types.
|
|
2
|
+
* Session and stream error types, and what to do after one.
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
export { FrameTooLarge, GroupTooLarge, NotFound, ProtocolViolation, RefusedRedirect, Session, Stream, type StreamOptions, TooFarBehind, } from "./error";
|
|
6
|
+
export { ConnectTimeout, FrameTooLarge, GroupTooLarge, NotFound, ProtocolViolation, RefusedRedirect, Retry, retry, Session, Skipped, Stream, type StreamOptions, TimestampMismatch, TooFarBehind, } from "./error.ts";
|
|
7
7
|
//# sourceMappingURL=errors.d.ts.map
|
package/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,aAAa,EACb,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,MAAM,EACN,KAAK,aAAa,EAClB,YAAY,GACZ,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,cAAc,EACd,aAAa,EACb,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,aAAa,EAClB,iBAAiB,EACjB,YAAY,GACZ,MAAM,YAAY,CAAC"}
|