@moq/net 0.4.7 → 0.4.8

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.
Files changed (151) hide show
  1. package/announce.d.ts +1 -1
  2. package/announce.js +0 -1
  3. package/announced.js +0 -1
  4. package/bandwidth.js +0 -1
  5. package/bandwidth_api.d.ts +1 -1
  6. package/bandwidth_api.js +0 -1
  7. package/broadcast.d.ts +3 -3
  8. package/broadcast.js +0 -1
  9. package/connection/accept.d.ts +2 -2
  10. package/connection/accept.js +0 -1
  11. package/connection/browser.js +0 -1
  12. package/connection/connect.d.ts +3 -3
  13. package/connection/connect.js +0 -1
  14. package/connection/established.d.ts +4 -4
  15. package/connection/established.js +0 -1
  16. package/connection/forward.js +0 -1
  17. package/connection/goaway.d.ts +1 -1
  18. package/connection/goaway.js +15 -2
  19. package/connection/goaway.js.map +1 -1
  20. package/connection/handshake.d.ts +2 -2
  21. package/connection/handshake.js +0 -1
  22. package/connection/index.d.ts +7 -7
  23. package/connection/index.js +0 -1
  24. package/connection/pool.d.ts +13 -13
  25. package/connection/pool.js +0 -1
  26. package/connection/reload.d.ts +1 -1
  27. package/connection/reload.js +0 -1
  28. package/connection/stats.d.ts +1 -1
  29. package/connection/stats.js +0 -1
  30. package/connection/transport.js +0 -1
  31. package/consume.js +0 -1
  32. package/datagram.d.ts +1 -1
  33. package/datagram.js +0 -1
  34. package/error.js +0 -1
  35. package/errors.d.ts +1 -1
  36. package/errors.js +0 -1
  37. package/group.d.ts +1 -1
  38. package/group.js +0 -1
  39. package/hop.js +0 -1
  40. package/ietf/adapter.d.ts +3 -3
  41. package/ietf/adapter.js +0 -1
  42. package/ietf/aliases.js +0 -1
  43. package/ietf/cluster.js +10 -3
  44. package/ietf/cluster.js.map +1 -1
  45. package/ietf/connection.d.ts +5 -5
  46. package/ietf/connection.js +0 -1
  47. package/ietf/error.js +0 -1
  48. package/ietf/fetch.d.ts +2 -2
  49. package/ietf/fetch.js +0 -1
  50. package/ietf/filter.d.ts +2 -2
  51. package/ietf/filter.js +0 -1
  52. package/ietf/goaway.d.ts +3 -3
  53. package/ietf/goaway.js +0 -1
  54. package/ietf/hidden.js +0 -1
  55. package/ietf/index.d.ts +20 -20
  56. package/ietf/index.js +0 -1
  57. package/ietf/message.d.ts +1 -1
  58. package/ietf/message.js +0 -1
  59. package/ietf/namespace.d.ts +2 -2
  60. package/ietf/namespace.js +0 -1
  61. package/ietf/object.d.ts +3 -3
  62. package/ietf/object.js +0 -1
  63. package/ietf/parameters.d.ts +3 -3
  64. package/ietf/parameters.js +0 -1
  65. package/ietf/priority.js +0 -1
  66. package/ietf/properties.d.ts +3 -3
  67. package/ietf/properties.js +0 -1
  68. package/ietf/publish.d.ts +3 -3
  69. package/ietf/publish.js +0 -1
  70. package/ietf/publish_namespace.d.ts +4 -4
  71. package/ietf/publish_namespace.js +0 -1
  72. package/ietf/publisher.js +0 -1
  73. package/ietf/request.d.ts +3 -3
  74. package/ietf/request.js +0 -1
  75. package/ietf/request_stream.d.ts +2 -2
  76. package/ietf/request_stream.js +0 -1
  77. package/ietf/setup.d.ts +3 -3
  78. package/ietf/setup.js +0 -1
  79. package/ietf/solicit.js +0 -1
  80. package/ietf/subscribe.d.ts +6 -6
  81. package/ietf/subscribe.js +0 -1
  82. package/ietf/subscribe_namespace.d.ts +4 -4
  83. package/ietf/subscribe_namespace.js +0 -1
  84. package/ietf/subscriber.js +0 -1
  85. package/ietf/token.js +0 -1
  86. package/ietf/track.d.ts +3 -3
  87. package/ietf/track.js +0 -1
  88. package/ietf/version.js +0 -1
  89. package/index.d.ts +13 -13
  90. package/index.d.ts.map +1 -1
  91. package/index.js +0 -1
  92. package/index.js.map +1 -1
  93. package/internal.d.ts +7 -7
  94. package/internal.js +0 -1
  95. package/lite/announce.d.ts +4 -4
  96. package/lite/announce.js +0 -1
  97. package/lite/connection.d.ts +7 -7
  98. package/lite/connection.js +0 -1
  99. package/lite/datagram.d.ts +1 -1
  100. package/lite/datagram.js +0 -1
  101. package/lite/datagram_stream.js +0 -1
  102. package/lite/fetch.d.ts +3 -3
  103. package/lite/fetch.js +0 -1
  104. package/lite/goaway.d.ts +2 -2
  105. package/lite/goaway.js +0 -1
  106. package/lite/group.d.ts +3 -3
  107. package/lite/group.js +0 -1
  108. package/lite/index.d.ts +13 -13
  109. package/lite/index.js +0 -1
  110. package/lite/message.d.ts +1 -1
  111. package/lite/message.js +0 -1
  112. package/lite/priority.js +0 -1
  113. package/lite/probe.d.ts +2 -2
  114. package/lite/probe.js +0 -1
  115. package/lite/publisher.js +0 -1
  116. package/lite/session.d.ts +2 -2
  117. package/lite/session.js +0 -1
  118. package/lite/setup.d.ts +3 -3
  119. package/lite/setup.js +0 -1
  120. package/lite/stream.d.ts +6 -6
  121. package/lite/stream.js +0 -1
  122. package/lite/subscribe.d.ts +3 -3
  123. package/lite/subscribe.js +0 -1
  124. package/lite/subscriber.d.ts +7 -7
  125. package/lite/subscriber.js +0 -1
  126. package/lite/track.d.ts +3 -3
  127. package/lite/track.js +0 -1
  128. package/lite/version.js +0 -1
  129. package/origin.d.ts +6 -6
  130. package/origin.js +0 -1
  131. package/package.json +2 -2
  132. package/path.js +0 -1
  133. package/stream.d.ts +3 -3
  134. package/stream.js +0 -1
  135. package/tail.d.ts +1 -1
  136. package/tail.js +0 -1
  137. package/time.js +0 -1
  138. package/track.d.ts +4 -4
  139. package/track.js +0 -1
  140. package/util/abort.js +0 -1
  141. package/util/hex.js +0 -1
  142. package/util/log.js +0 -1
  143. package/util/timeout.js +0 -1
  144. package/util/u64.js +0 -1
  145. package/util/utf8.js +0 -1
  146. package/util/varint.js +0 -1
  147. package/varint.js +0 -1
  148. package/wire.d.ts +7 -7
  149. package/wire.js +0 -1
  150. package/zod.d.ts +2 -2
  151. package/zod.js +0 -1
package/announce.d.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- export { Consumer, isActive, type Kind, type Update } from "./announced";
6
+ export { Consumer, isActive, type Kind, type Update } from "./announced.ts";
7
7
  //# sourceMappingURL=announce.d.ts.map
package/announce.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./announce.d.ts" */
2
1
  /**
3
2
  * Broadcast announcement streams.
4
3
  *
package/announced.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./announced.d.ts" */
2
1
  /**
3
2
  * Broadcast announcement streams: which broadcast paths are available under a scope.
4
3
  *
package/bandwidth.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./bandwidth.d.ts" */
2
1
  /**
3
2
  * Rate estimation split among the tracks sharing one connection.
4
3
  *
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- export { Allocator, type Demand, type Handle, Reservation } from "./bandwidth";
6
+ export { Allocator, type Demand, type Handle, Reservation } from "./bandwidth.ts";
7
7
  //# sourceMappingURL=bandwidth_api.d.ts.map
package/bandwidth_api.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./bandwidth_api.d.ts" */
2
1
  /**
3
2
  * Public bandwidth allocation handles.
4
3
  *
package/broadcast.d.ts CHANGED
@@ -4,9 +4,9 @@
4
4
  * @module
5
5
  */
6
6
  import { type GetPromise } from "@moq/signals";
7
- import { Route } from "./hop";
8
- import * as Path from "./path";
9
- import * as track from "./track";
7
+ import { Route } from "./hop.ts";
8
+ import * as Path from "./path.ts";
9
+ import * as track from "./track.ts";
10
10
  /**
11
11
  * The write side of a broadcast.
12
12
  *
package/broadcast.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./broadcast.d.ts" */
2
1
  /**
3
2
  * Broadcast role handles: a named collection of tracks produced by a publisher.
4
3
  *
@@ -1,5 +1,5 @@
1
- import type { Consumer as OriginConsumer, Producer as OriginProducer } from "../origin";
2
- import type { Established } from "./established";
1
+ import type { Consumer as OriginConsumer, Producer as OriginProducer } from "../origin.ts";
2
+ import type { Established } from "./established.ts";
3
3
  /** Options for {@link accept}. */
4
4
  export interface AcceptProps {
5
5
  /** The accepted transport. */
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./accept.d.ts" */
2
1
  import * as Ietf from "../ietf/index.js";
3
2
  import * as Lite from "../lite/index.js";
4
3
  import { Stream } from "../stream.js";
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./browser.d.ts" */
2
1
  import Bowser from "bowser";
3
2
  /** Returns whether a browser user agent has a usable WebTransport implementation. */
4
3
  export function isWebTransportUserAgentSupported(userAgent) {
@@ -1,6 +1,6 @@
1
- import type { Consumer as OriginConsumer, Producer as OriginProducer } from "../origin";
2
- import * as Time from "../time";
3
- import type { Established } from "./established";
1
+ import type { Consumer as OriginConsumer, Producer as OriginProducer } from "../origin.ts";
2
+ import * as Time from "../time.ts";
3
+ import type { Established } from "./established.ts";
4
4
  /** Tuning for the WebSocket fallback used when WebTransport is unavailable or loses the connect race. */
5
5
  export interface WebSocketProps {
6
6
  /** Enable the WebSocket fallback. Defaults to `true`. */
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./connect.d.ts" */
2
1
  import Session from "@moq/qmux";
3
2
  import { error, fromClose } from "../error.js";
4
3
  import * as Ietf from "../ietf/index.js";
@@ -1,8 +1,8 @@
1
1
  import type { Getter } from "@moq/signals";
2
- import type * as announce from "../announced";
3
- import type * as Path from "../path";
4
- import type { Probe, Stats } from "./stats";
5
- import type { Transport } from "./transport";
2
+ import type * as announce from "../announced.ts";
3
+ import type * as Path from "../path.ts";
4
+ import type { Probe, Stats } from "./stats.ts";
5
+ import type { Transport } from "./transport.ts";
6
6
  /**
7
7
  * An established MoQ session, implemented by both the moq-lite and moq-ietf protocols.
8
8
  *
@@ -1,3 +1,2 @@
1
- /* @ts-self-types="./established.d.ts" */
2
1
  export {};
3
2
  //# sourceMappingURL=established.js.map
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./forward.d.ts" */
2
1
  /**
3
2
  * Feeds a session's announced routes into an origin; the `consume` connect option.
4
3
  *
@@ -1,4 +1,4 @@
1
- import * as Time from "../time";
1
+ import * as Time from "../time.ts";
2
2
  /** A peer's GOAWAY as a session received it. */
3
3
  export interface Drain {
4
4
  /** Where to reconnect, including any credentials it needs. Empty means the same endpoint. */
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./goaway.d.ts" */
2
1
  /**
3
2
  * GOAWAY handling for the reconnect loop: the peer's drain signal and the policy for the
4
3
  * redirect it may name. Mirrors `Goaway` and `Redirect` in `moq_tokio::connection`.
@@ -104,7 +103,20 @@ function schemeTier(protocol) {
104
103
  * @internal
105
104
  */
106
105
  export function isLocal(url) {
107
- const host = url.hostname.toLowerCase();
106
+ let host = url.hostname.toLowerCase();
107
+ // A non-special scheme (`moqt:`) keeps its host opaque; reading it back through
108
+ // https decodes every IPv4 spelling the dial accepts (`127.1`, `0x7f000001`).
109
+ if (host !== "" && !host.startsWith("[") && !SPECIAL.has(url.protocol)) {
110
+ try {
111
+ host = new URL(`https://${host}/`).hostname;
112
+ }
113
+ catch {
114
+ // Not a valid special host, so not an address literal either.
115
+ }
116
+ }
117
+ // A trailing dot names the same host.
118
+ if (host.endsWith("."))
119
+ host = host.slice(0, -1);
108
120
  // No host at all, e.g. a `unix:` socket path.
109
121
  if (host === "")
110
122
  return true;
@@ -117,6 +129,7 @@ export function isLocal(url) {
117
129
  const v4 = parseIpv4(host);
118
130
  return v4 !== undefined && isLocalV4(v4);
119
131
  }
132
+ const SPECIAL = new Set(["http:", "https:", "ws:", "wss:", "ftp:", "file:"]);
120
133
  function parseIpv4(host) {
121
134
  const parts = host.split(".");
122
135
  if (parts.length !== 4)
@@ -1 +1 @@
1
- {"version":3,"file":"goaway.js","sourceRoot":"","sources":["../../src/connection/goaway.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AAoCnC,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IA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C,KAAK,MAAM,EAAE,CAAC;QAC1E,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO;IACN,uCAAuC;IACvC,CAAC,UAAU,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC;QAC1C,sDAAsD;QACtD,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,MAAM;QAC3B,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,MAAM,CAC3B,CAAC;AACH,CAAC","sourcesContent":["/**\n * GOAWAY handling for the reconnect loop: the peer's drain signal and the policy for the\n * redirect it may name. Mirrors `Goaway` and `Redirect` in `moq_tokio::connection`.\n *\n * @module\n */\nimport { RefusedRedirect } from \"../error.ts\";\nimport * as Time from \"../time.ts\";\n\n/** A peer's GOAWAY as a session received it. */\nexport interface Drain {\n\t/** Where to reconnect, including any credentials it needs. Empty means the same endpoint. */\n\treadonly uri: string;\n\t/** When the peer force-closes the session. Undefined when the wire carried none. */\n\treadonly timeout?: Time.Milli;\n}\n\n/**\n * What to do with the URI a peer names in its GOAWAY.\n *\n * - `same-host` (the default) follows it only onto the host already dialed, so a peer can move\n * the connection between ports or schemes but not to another host.\n * - `follow` also lets the peer name the host. The name is dialed as written, so only use it\n * with a relay trusted not to point the connection into the local network.\n * - `ignore` reconnects to the current URL whatever the peer names.\n *\n * A malformed or refused URI ends the connection with {@link RefusedRedirect}.\n */\nexport type Redirect = \"follow\" | \"same-host\" | \"ignore\";\n\n/** How a reconnecting connection reacts to a peer's GOAWAY. */\nexport interface GoawayProps {\n\t/** What to do with the URI the peer names (default: `same-host`). */\n\tredirect?: Redirect;\n\n\t/**\n\t * How long the old session keeps serving after the GOAWAY while the replacement dials\n\t * (default: 10000ms). A cap: a shorter deadline from the peer wins, a longer one does not\n\t * extend it.\n\t */\n\thandover?: Time.Milli;\n}\n\n/** The handover cap when the caller names none. */\nexport const DEFAULT_HANDOVER = Time.Milli(10_000);\n\n/**\n * How long a drained session may keep serving: the cap, lowered to the peer's deadline when\n * it named a positive one. Absence is not a zero-length handover.\n *\n * @internal\n */\nexport function handover(cap: Time.Milli, timeout?: Time.Milli): Time.Milli {\n\treturn timeout !== undefined && timeout > 0 ? Time.Milli(Math.min(cap, timeout)) : cap;\n}\n\n/**\n * The URL a redirect is judged against. A WebSocket fallback that won the race is the host\n * we dialed; the primary URL was not, so same-host must not treat it as the current peer.\n *\n * @internal\n */\nexport function dialed(primary: URL, transport: \"webtransport\" | \"websocket\", websocket?: URL): URL {\n\treturn transport === \"websocket\" && websocket ? websocket : primary;\n}\n\n/**\n * Whether a certificate pin constrains this session. The pin is a WebTransport option, so it\n * holds the host only when that transport is the one that connected.\n *\n * @internal\n */\nexport function pinnedTransport(transport: \"webtransport\" | \"websocket\", configured: boolean): boolean {\n\treturn configured && transport === \"webtransport\";\n}\n\n/**\n * The URL a GOAWAY assigns: `undefined` keeps the current URL (the peer named none, or the\n * policy ignores a URI it could parse), and a URL replaces it. Throws {@link RefusedRedirect}\n * for an explicit URI the policy will not follow, including a malformed one under `ignore`.\n *\n * `pinned` is a certificate pin on the connection, which can only verify the host it was\n * configured for, so it refuses a host change even under `follow`.\n *\n * @internal\n */\nexport function target(policy: Redirect, uri: string, current: URL, pinned: boolean): URL | undefined {\n\tif (uri === \"\") return undefined;\n\n\t// The URI can carry credentials, so the error names the reason, never the URI.\n\t// Parse before `ignore`: a malformed redirect is terminal even when the policy\n\t// would otherwise stay on the current URL.\n\tlet next: URL;\n\ttry {\n\t\tnext = new URL(uri);\n\t} catch {\n\t\tthrow new RefusedRedirect(\"the GOAWAY URI is malformed\");\n\t}\n\tif (policy === \"ignore\") return undefined;\n\n\tif (schemeTier(next.protocol) < schemeTier(current.protocol)) {\n\t\tthrow new RefusedRedirect(\"the GOAWAY redirect downgrades the scheme\");\n\t}\n\n\t// Only as far as the URL itself says: a name is dialed, never resolved here, so this\n\t// refuses a peer naming a local address outright, not one hiding it behind a hostname.\n\t// That gap is why `same-host` is the default.\n\tif (isLocal(next) && !isLocal(current)) {\n\t\tthrow new RefusedRedirect(\"the GOAWAY redirect widens reachability to a local address\");\n\t}\n\n\t// Host only, not the full authority: the port is what a peer legitimately moves us\n\t// across when it hands off to a sibling process on the same box.\n\tconst sameHost = next.hostname === current.hostname;\n\tif (policy === \"same-host\" && !sameHost) {\n\t\tthrow new RefusedRedirect(\"the GOAWAY redirect leaves the current host\");\n\t}\n\tif (pinned && !sameHost) {\n\t\tthrow new RefusedRedirect(\"the GOAWAY redirect leaves the host a certificate pin verifies\");\n\t}\n\n\treturn next;\n}\n\n/** Rank a scheme so a redirect cannot silently drop encryption; unknown schemes rank lowest. */\nfunction schemeTier(protocol: string): number {\n\tswitch (protocol) {\n\t\tcase \"https:\":\n\t\tcase \"wss:\":\n\t\tcase \"moqt:\":\n\t\tcase \"moql:\":\n\t\t\treturn 2;\n\t\tcase \"http:\":\n\t\tcase \"ws:\":\n\t\tcase \"tcp:\":\n\t\t\treturn 1;\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}\n\n/**\n * Whether a URL says it names something only reachable from this host or network. A judgement\n * about the URL, not about where a dial lands: `false` means \"not local on its face\".\n *\n * @internal\n */\nexport function isLocal(url: URL): boolean {\n\tconst host = url.hostname.toLowerCase();\n\t// No host at all, e.g. a `unix:` socket path.\n\tif (host === \"\") return true;\n\tif (host === \"localhost\" || host.endsWith(\".localhost\")) return true;\n\n\tif (host.startsWith(\"[\") && host.endsWith(\"]\")) {\n\t\tconst segments = parseIpv6(host.slice(1, -1));\n\t\treturn segments !== undefined && isLocalV6(segments);\n\t}\n\n\tconst v4 = parseIpv4(host);\n\treturn v4 !== undefined && isLocalV4(v4);\n}\n\nfunction parseIpv4(host: string): number[] | undefined {\n\tconst parts = host.split(\".\");\n\tif (parts.length !== 4) return undefined;\n\tconst octets = parts.map((part) => (/^\\d{1,3}$/.test(part) ? Number(part) : Number.NaN));\n\treturn octets.every((octet) => octet <= 255) ? octets : undefined;\n}\n\nfunction isLocalV4([a, b, c, d]: number[]): boolean {\n\treturn (\n\t\ta === 127 ||\n\t\ta === 10 ||\n\t\t(a === 172 && b >= 16 && b <= 31) ||\n\t\t(a === 192 && b === 168) ||\n\t\t(a === 169 && b === 254) ||\n\t\t(a === 0 && b === 0 && c === 0 && d === 0)\n\t);\n}\n\n/** Parse an IPv6 literal (without brackets) into its eight 16-bit segments. */\nfunction parseIpv6(host: string): number[] | undefined {\n\t// Drop a zone id; it scopes the address without changing it.\n\tlet text = host.split(\"%\")[0] ?? \"\";\n\n\t// A trailing dotted quad (`::ffff:127.0.0.1`) spells the last two segments.\n\tconst lastColon = text.lastIndexOf(\":\");\n\tconst quad = parseIpv4(text.slice(lastColon + 1));\n\tif (quad) {\n\t\tconst [a = 0, b = 0, c = 0, d = 0] = quad;\n\t\tconst word = (hi: number, lo: number) => ((hi << 8) | lo).toString(16);\n\t\ttext = `${text.slice(0, lastColon + 1)}${word(a, b)}:${word(c, d)}`;\n\t}\n\n\tconst halves = text.split(\"::\");\n\tif (halves.length > 2) return undefined;\n\tconst words = (part: string) => (part === \"\" ? [] : part.split(\":\"));\n\tconst head = words(halves[0] ?? \"\");\n\tconst rest = halves.length === 2 ? words(halves[1] ?? \"\") : [];\n\tconst missing = 8 - head.length - rest.length;\n\tif (halves.length === 2 ? missing < 0 : missing !== 0) return undefined;\n\n\tconst all = [...head, ...Array<string>(missing).fill(\"0\"), ...rest];\n\tconst segments = all.map((word) => (/^[0-9a-f]{1,4}$/i.test(word) ? Number.parseInt(word, 16) : Number.NaN));\n\treturn segments.some(Number.isNaN) ? undefined : segments;\n}\n\nfunction isLocalV6(segments: number[]): boolean {\n\t// An IPv4-mapped address reaches the same host as the v4 it wraps.\n\tif (segments.slice(0, 5).every((s) => s === 0) && segments[5] === 0xffff) {\n\t\tconst [hi = 0, lo = 0] = segments.slice(6);\n\t\treturn isLocalV4([hi >> 8, hi & 0xff, lo >> 8, lo & 0xff]);\n\t}\n\tconst first = segments[0] ?? 0;\n\tconst zeroPrefix = segments.slice(0, 7).every((s) => s === 0);\n\tconst last = segments[7] ?? 0;\n\treturn (\n\t\t// Loopback (::1) and unspecified (::).\n\t\t(zeroPrefix && (last === 1 || last === 0)) ||\n\t\t// Unique local (fc00::/7) and link local (fe80::/10).\n\t\t(first & 0xfe00) === 0xfc00 ||\n\t\t(first & 0xffc0) === 0xfe80\n\t);\n}\n"]}
1
+ {"version":3,"file":"goaway.js","sourceRoot":"","sources":["../../src/connection/goaway.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AAoCnC,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAe,EAAE,OAAoB;IAC7D,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,C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for the reconnect loop: the peer's drain signal and the policy for the\n * redirect it may name. Mirrors `Goaway` and `Redirect` in `moq_tokio::connection`.\n *\n * @module\n */\nimport { RefusedRedirect } from \"../error.ts\";\nimport * as Time from \"../time.ts\";\n\n/** A peer's GOAWAY as a session received it. */\nexport interface Drain {\n\t/** Where to reconnect, including any credentials it needs. Empty means the same endpoint. */\n\treadonly uri: string;\n\t/** When the peer force-closes the session. Undefined when the wire carried none. */\n\treadonly timeout?: Time.Milli;\n}\n\n/**\n * What to do with the URI a peer names in its GOAWAY.\n *\n * - `same-host` (the default) follows it only onto the host already dialed, so a peer can move\n * the connection between ports or schemes but not to another host.\n * - `follow` also lets the peer name the host. The name is dialed as written, so only use it\n * with a relay trusted not to point the connection into the local network.\n * - `ignore` reconnects to the current URL whatever the peer names.\n *\n * A malformed or refused URI ends the connection with {@link RefusedRedirect}.\n */\nexport type Redirect = \"follow\" | \"same-host\" | \"ignore\";\n\n/** How a reconnecting connection reacts to a peer's GOAWAY. */\nexport interface GoawayProps {\n\t/** What to do with the URI the peer names (default: `same-host`). */\n\tredirect?: Redirect;\n\n\t/**\n\t * How long the old session keeps serving after the GOAWAY while the replacement dials\n\t * (default: 10000ms). A cap: a shorter deadline from the peer wins, a longer one does not\n\t * extend it.\n\t */\n\thandover?: Time.Milli;\n}\n\n/** The handover cap when the caller names none. */\nexport const DEFAULT_HANDOVER = Time.Milli(10_000);\n\n/**\n * How long a drained session may keep serving: the cap, lowered to the peer's deadline when\n * it named a positive one. Absence is not a zero-length handover.\n *\n * @internal\n */\nexport function handover(cap: Time.Milli, timeout?: Time.Milli): Time.Milli {\n\treturn timeout !== undefined && timeout > 0 ? Time.Milli(Math.min(cap, timeout)) : cap;\n}\n\n/**\n * The URL a redirect is judged against. A WebSocket fallback that won the race is the host\n * we dialed; the primary URL was not, so same-host must not treat it as the current peer.\n *\n * @internal\n */\nexport function dialed(primary: URL, transport: \"webtransport\" | \"websocket\", websocket?: URL): URL {\n\treturn transport === \"websocket\" && websocket ? websocket : primary;\n}\n\n/**\n * Whether a certificate pin constrains this session. The pin is a WebTransport option, so it\n * holds the host only when that transport is the one that connected.\n *\n * @internal\n */\nexport function pinnedTransport(transport: \"webtransport\" | \"websocket\", configured: boolean): boolean {\n\treturn configured && transport === \"webtransport\";\n}\n\n/**\n * The URL a GOAWAY assigns: `undefined` keeps the current URL (the peer named none, or the\n * policy ignores a URI it could parse), and a URL replaces it. Throws {@link RefusedRedirect}\n * for an explicit URI the policy will not follow, including a malformed one under `ignore`.\n *\n * `pinned` is a certificate pin on the connection, which can only verify the host it was\n * configured for, so it refuses a host change even under `follow`.\n *\n * @internal\n */\nexport function target(policy: Redirect, uri: string, current: URL, pinned: boolean): URL | undefined {\n\tif (uri === \"\") return undefined;\n\n\t// The URI can carry credentials, so the error names the reason, never the URI.\n\t// Parse before `ignore`: a malformed redirect is terminal even when the policy\n\t// would otherwise stay on the current URL.\n\tlet next: URL;\n\ttry {\n\t\tnext = new URL(uri);\n\t} catch {\n\t\tthrow new RefusedRedirect(\"the GOAWAY URI is malformed\");\n\t}\n\tif (policy === \"ignore\") return undefined;\n\n\tif (schemeTier(next.protocol) < schemeTier(current.protocol)) {\n\t\tthrow new RefusedRedirect(\"the GOAWAY redirect downgrades the scheme\");\n\t}\n\n\t// Only as far as the URL itself says: a name is dialed, never resolved here, so this\n\t// refuses a peer naming a local address outright, not one hiding it behind a hostname.\n\t// That gap is why `same-host` is the default.\n\tif (isLocal(next) && !isLocal(current)) {\n\t\tthrow new RefusedRedirect(\"the GOAWAY redirect widens reachability to a local address\");\n\t}\n\n\t// Host only, not the full authority: the port is what a peer legitimately moves us\n\t// across when it hands off to a sibling process on the same box.\n\tconst sameHost = next.hostname === current.hostname;\n\tif (policy === \"same-host\" && !sameHost) {\n\t\tthrow new RefusedRedirect(\"the GOAWAY redirect leaves the current host\");\n\t}\n\tif (pinned && !sameHost) {\n\t\tthrow new RefusedRedirect(\"the GOAWAY redirect leaves the host a certificate pin verifies\");\n\t}\n\n\treturn next;\n}\n\n/** Rank a scheme so a redirect cannot silently drop encryption; unknown schemes rank lowest. */\nfunction schemeTier(protocol: string): number {\n\tswitch (protocol) {\n\t\tcase \"https:\":\n\t\tcase \"wss:\":\n\t\tcase \"moqt:\":\n\t\tcase \"moql:\":\n\t\t\treturn 2;\n\t\tcase \"http:\":\n\t\tcase \"ws:\":\n\t\tcase \"tcp:\":\n\t\t\treturn 1;\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}\n\n/**\n * Whether a URL says it names something only reachable from this host or network. A judgement\n * about the URL, not about where a dial lands: `false` means \"not local on its face\".\n *\n * @internal\n */\nexport function isLocal(url: URL): boolean {\n\tlet host = url.hostname.toLowerCase();\n\t// A non-special scheme (`moqt:`) keeps its host opaque; reading it back through\n\t// https decodes every IPv4 spelling the dial accepts (`127.1`, `0x7f000001`).\n\tif (host !== \"\" && !host.startsWith(\"[\") && !SPECIAL.has(url.protocol)) {\n\t\ttry {\n\t\t\thost = new URL(`https://${host}/`).hostname;\n\t\t} catch {\n\t\t\t// Not a valid special host, so not an address literal either.\n\t\t}\n\t}\n\t// A trailing dot names the same host.\n\tif (host.endsWith(\".\")) host = host.slice(0, -1);\n\t// No host at all, e.g. a `unix:` socket path.\n\tif (host === \"\") return true;\n\tif (host === \"localhost\" || host.endsWith(\".localhost\")) return true;\n\n\tif (host.startsWith(\"[\") && host.endsWith(\"]\")) {\n\t\tconst segments = parseIpv6(host.slice(1, -1));\n\t\treturn segments !== undefined && isLocalV6(segments);\n\t}\n\n\tconst v4 = parseIpv4(host);\n\treturn v4 !== undefined && isLocalV4(v4);\n}\n\nconst SPECIAL = new Set([\"http:\", \"https:\", \"ws:\", \"wss:\", \"ftp:\", \"file:\"]);\n\nfunction parseIpv4(host: string): number[] | undefined {\n\tconst parts = host.split(\".\");\n\tif (parts.length !== 4) return undefined;\n\tconst octets = parts.map((part) => (/^\\d{1,3}$/.test(part) ? Number(part) : Number.NaN));\n\treturn octets.every((octet) => octet <= 255) ? octets : undefined;\n}\n\nfunction isLocalV4([a, b, c, d]: number[]): boolean {\n\treturn (\n\t\ta === 127 ||\n\t\ta === 10 ||\n\t\t(a === 172 && b >= 16 && b <= 31) ||\n\t\t(a === 192 && b === 168) ||\n\t\t(a === 169 && b === 254) ||\n\t\t(a === 0 && b === 0 && c === 0 && d === 0)\n\t);\n}\n\n/** Parse an IPv6 literal (without brackets) into its eight 16-bit segments. */\nfunction parseIpv6(host: string): number[] | undefined {\n\t// Drop a zone id; it scopes the address without changing it.\n\tlet text = host.split(\"%\")[0] ?? \"\";\n\n\t// A trailing dotted quad (`::ffff:127.0.0.1`) spells the last two segments.\n\tconst lastColon = text.lastIndexOf(\":\");\n\tconst quad = parseIpv4(text.slice(lastColon + 1));\n\tif (quad) {\n\t\tconst [a = 0, b = 0, c = 0, d = 0] = quad;\n\t\tconst word = (hi: number, lo: number) => ((hi << 8) | lo).toString(16);\n\t\ttext = `${text.slice(0, lastColon + 1)}${word(a, b)}:${word(c, d)}`;\n\t}\n\n\tconst halves = text.split(\"::\");\n\tif (halves.length > 2) return undefined;\n\tconst words = (part: string) => (part === \"\" ? [] : part.split(\":\"));\n\tconst head = words(halves[0] ?? \"\");\n\tconst rest = halves.length === 2 ? words(halves[1] ?? \"\") : [];\n\tconst missing = 8 - head.length - rest.length;\n\tif (halves.length === 2 ? missing < 0 : missing !== 0) return undefined;\n\n\tconst all = [...head, ...Array<string>(missing).fill(\"0\"), ...rest];\n\tconst segments = all.map((word) => (/^[0-9a-f]{1,4}$/i.test(word) ? Number.parseInt(word, 16) : Number.NaN));\n\treturn segments.some(Number.isNaN) ? undefined : segments;\n}\n\nfunction isLocalV6(segments: number[]): boolean {\n\t// An IPv4-mapped address reaches the same host as the v4 it wraps.\n\tif (segments.slice(0, 5).every((s) => s === 0) && segments[5] === 0xffff) {\n\t\tconst [hi = 0, lo = 0] = segments.slice(6);\n\t\treturn isLocalV4([hi >> 8, hi & 0xff, lo >> 8, lo & 0xff]);\n\t}\n\tconst first = segments[0] ?? 0;\n\tconst zeroPrefix = segments.slice(0, 7).every((s) => s === 0);\n\tconst last = segments[7] ?? 0;\n\treturn (\n\t\t// Loopback (::1) and unspecified (::).\n\t\t(zeroPrefix && (last === 1 || last === 0)) ||\n\t\t// Unique local (fc00::/7) and link local (fe80::/10).\n\t\t(first & 0xfe00) === 0xfc00 ||\n\t\t(first & 0xffc0) === 0xfe80\n\t);\n}\n"]}
@@ -1,5 +1,5 @@
1
- import * as Ietf from "../ietf/index";
2
- import { Reader, Stream } from "../stream";
1
+ import * as Ietf from "../ietf/index.ts";
2
+ import { Reader, Stream } from "../stream.ts";
3
3
  /**
4
4
  * Draft-17+ SETUP exchange. Each side opens a uni stream, writes its Setup
5
5
  * message, and reads the peer's Setup off an incoming uni stream. The two
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./handshake.d.ts" */
2
1
  import { StreamError } from "../error.js";
3
2
  import { randomHop } from "../hop.js";
4
3
  import * as Ietf from "../ietf/index.js";
@@ -3,11 +3,11 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- export { type AcceptProps, accept } from "./accept";
7
- export { isWebTransportSupported } from "./browser";
8
- export { type CertificateHash, type ConnectProps, certificateHash, connect, type WebSocketProps, type WebTransportProps, } from "./connect";
9
- export type { Established } from "./established";
10
- export { Connection, type ConnectionProps } from "./pool";
11
- export type { Probe, Stats } from "./stats";
12
- export type { Transport } from "./transport";
6
+ export { type AcceptProps, accept } from "./accept.ts";
7
+ export { isWebTransportSupported } from "./browser.ts";
8
+ export { type CertificateHash, type ConnectProps, certificateHash, connect, type WebSocketProps, type WebTransportProps, } from "./connect.ts";
9
+ export type { Established } from "./established.ts";
10
+ export { Connection, type ConnectionProps } from "./pool.ts";
11
+ export type { Probe, Stats } from "./stats.ts";
12
+ export type { Transport } from "./transport.ts";
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./index.d.ts" */
2
1
  /**
3
2
  * A reconnecting, shareable handle on a MoQ session, plus one-shot connect/accept.
4
3
  *
@@ -4,19 +4,19 @@
4
4
  * @module
5
5
  */
6
6
  import { type GetPromise, type Getter, Signal } from "@moq/signals";
7
- import * as Announce from "../announced";
8
- import type { Handle } from "../bandwidth";
9
- import * as Origin from "../origin";
10
- import * as Path from "../path";
11
- import * as Time from "../time";
12
- import { type AcceptProps as AcceptPropsType, accept } from "./accept";
13
- import { isWebTransportSupported } from "./browser";
14
- import { type CertificateHash as CertificateHashType, type ConnectProps as ConnectPropsType, certificateHash, connect, type WebSocketProps as WebSocketPropsType, type WebTransportProps as WebTransportPropsType } from "./connect";
15
- import type { Established as EstablishedType } from "./established";
16
- import type { GoawayProps, Redirect as RedirectType } from "./goaway";
17
- import { type ReloadDelay, type ReloadStatus } from "./reload";
18
- import type { Probe as ProbeType, Stats as StatsType } from "./stats";
19
- import type { Transport as TransportType } from "./transport";
7
+ import * as Announce from "../announced.ts";
8
+ import type { Handle } from "../bandwidth.ts";
9
+ import * as Origin from "../origin.ts";
10
+ import * as Path from "../path.ts";
11
+ import * as Time from "../time.ts";
12
+ import { type AcceptProps as AcceptPropsType, accept } from "./accept.ts";
13
+ import { isWebTransportSupported } from "./browser.ts";
14
+ import { type CertificateHash as CertificateHashType, type ConnectProps as ConnectPropsType, certificateHash, connect, type WebSocketProps as WebSocketPropsType, type WebTransportProps as WebTransportPropsType } from "./connect.ts";
15
+ import type { Established as EstablishedType } from "./established.ts";
16
+ import type { GoawayProps, Redirect as RedirectType } from "./goaway.ts";
17
+ import { type ReloadDelay, type ReloadStatus } from "./reload.ts";
18
+ import type { Probe as ProbeType, Stats as StatsType } from "./stats.ts";
19
+ import type { Transport as TransportType } from "./transport.ts";
20
20
  /** Options for {@link Connection}. */
21
21
  export interface ConnectionProps {
22
22
  /** The relay to connect to; pass a `Signal` to switch relays live. */
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./pool.d.ts" */
2
1
  /**
3
2
  * A reconnecting, shareable connection: one origin and one reconnect loop per relay URL.
4
3
  *
@@ -1,4 +1,4 @@
1
- import * as Time from "../time";
1
+ import * as Time from "../time.ts";
2
2
  /**
3
3
  * Exponential backoff settings for the reconnect loop.
4
4
  *
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./reload.d.ts" */
2
1
  import { Effect, Once, Signal } from "@moq/signals";
3
2
  import * as Announce from "../announced.js";
4
3
  import { Allocator } from "../bandwidth.js";
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import * as Time from "../time";
6
+ import * as Time from "../time.ts";
7
7
  /**
8
8
  * A point-in-time snapshot of the transport's counters, from `WebTransport.getStats()`.
9
9
  *
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./stats.d.ts" */
2
1
  /**
3
2
  * Connection statistics: what the local transport counts, and what the peer reports.
4
3
  *
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./transport.d.ts" */
2
1
  import Session from "@moq/qmux";
3
2
  /**
4
3
  * The transport a live session is actually running over. qmux implements the `WebTransport`
package/consume.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./consume.d.ts" */
2
1
  /**
3
2
  * Per-path dedup cache for consumed broadcasts, shared by the moq-lite and moq-ietf
4
3
  * subscribers.
package/datagram.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import type { Timestamp } from "./time";
6
+ import type { Timestamp } from "./time.ts";
7
7
  /**
8
8
  * A single unreliable payload on a track: a sequence number, a presentation timestamp, and the bytes.
9
9
  *
package/datagram.js CHANGED
@@ -1,3 +1,2 @@
1
- /* @ts-self-types="./datagram.d.ts" */
2
1
  export {};
3
2
  //# sourceMappingURL=datagram.js.map
package/error.js CHANGED
@@ -1,4 +1,3 @@
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
  *
package/errors.d.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- export { FrameTooLarge, GroupTooLarge, NotFound, ProtocolViolation, RefusedRedirect, Session, Stream, type StreamOptions, TooFarBehind, } from "./error";
6
+ export { FrameTooLarge, GroupTooLarge, NotFound, ProtocolViolation, RefusedRedirect, Session, Stream, type StreamOptions, TooFarBehind, } from "./error.ts";
7
7
  //# sourceMappingURL=errors.d.ts.map
package/errors.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./errors.d.ts" */
2
1
  /**
3
2
  * Session and stream error types.
4
3
  *
package/group.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @module
5
5
  */
6
6
  import { type GetPromise } from "@moq/signals";
7
- import { Timestamp } from "./time";
7
+ import { Timestamp } from "./time.ts";
8
8
  /** Maximum bytes of frames in a group. A write that would exceed this aborts with {@link GroupTooLarge}. */
9
9
  export declare const MAX_GROUP_CACHE_BYTES: number;
10
10
  /** Maximum number of frames in a group. 8192 is the largest legal group; the 8193rd write is {@link GroupTooLarge}. */
package/group.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./group.d.ts" */
2
1
  /**
3
2
  * Group role handles: an ordered stream of frames within a track, delivered over one QUIC stream.
4
3
  *
package/hop.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./hop.d.ts" */
2
1
  /**
3
2
  * Endpoint identity within a hop chain, shared by both wire protocols.
4
3
  *
package/ietf/adapter.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Once } from "@moq/signals";
2
- import type { Drain } from "../connection/goaway";
3
- import { Stream } from "../stream";
4
- import { type IetfVersion } from "./version";
2
+ import type { Drain } from "../connection/goaway.ts";
3
+ import { Stream } from "../stream.ts";
4
+ import { type IetfVersion } from "./version.ts";
5
5
  /**
6
6
  * Interface for opening outgoing bidi streams and allocating request IDs.
7
7
  * Implemented by both ControlStreamAdapter (v14-v16) and NativeSession (v17).
package/ietf/adapter.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./adapter.d.ts" */
2
1
  import { Once } from "@moq/signals";
3
2
  import { Mutex } from "async-mutex";
4
3
  import { error, ProtocolViolation } from "../error.js";
package/ietf/aliases.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./aliases.d.ts" */
2
1
  const TRACK_ALIAS_TIMEOUT_MS = 1000;
3
2
  /**
4
3
  * How many cancelled aliases to remember. Objects keep arriving for about a round trip
package/ietf/cluster.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./cluster.d.ts" */
2
1
  /**
3
2
  * The MoQ Cluster extension (draft-lcurley-moq-cluster-01).
4
3
  *
@@ -53,7 +52,7 @@ export function fromSetup(params, version) {
53
52
  const value = params.getVarint(SetupOption.HopId);
54
53
  if (value === undefined)
55
54
  return undefined;
56
- return HopSchema.parse(value);
55
+ return fromWire(value);
57
56
  }
58
57
  /**
59
58
  * Declare our own Hop ID, which is also what negotiates the extension.
@@ -205,6 +204,14 @@ export function updateFromParams(params) {
205
204
  export function apply(held, update) {
206
205
  return { hops: update.hops ?? held.hops, cost: update.cost ?? held.cost };
207
206
  }
207
+ /**
208
+ * Read a Hop ID off the wire. The draft gives it the full 64-bit varint range, but a
209
+ * {@link Hop} on this release line is 62 bits, so a wider id reads as {@link UNKNOWN_HOP}:
210
+ * it identifies nothing, which costs loop detection through that hop instead of the session.
211
+ */
212
+ function fromWire(value) {
213
+ return value >= 1n << 62n ? UNKNOWN_HOP : HopSchema.parse(value);
214
+ }
208
215
  /** Read a HOP_PATH value: bare varints filling the parameter, with no count of their own. */
209
216
  function decodeHops(value) {
210
217
  const hops = [];
@@ -212,7 +219,7 @@ function decodeHops(value) {
212
219
  while (rest.length > 0) {
213
220
  // A short read here means the entries did not exactly fill the length.
214
221
  const [hop, remain] = Varint.decodeLeadingOnes(rest);
215
- hops.push(HopSchema.parse(hop));
222
+ hops.push(fromWire(hop));
216
223
  rest = remain;
217
224
  // Bail before the buffer does: a hostile length would otherwise cost us one
218
225
  // allocation per entry all the way to 64KB of parameter value.
@@ -1 +1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ChC,IAAI,GAAG,MAAM,CAAC;QAEd,4EAA4E;QAC5E,+DAA+D;QAC/D,IAAI,IAAI,CAAC,MAAM,GAAG,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,CAAC;IACf,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,IAAW;IAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC5D,IAAI,IAAI,CAAC,MAAM,GAAG,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,CAAC,MAAM,oBAAoB,QAAQ,EAAE,CAAC,CAAC;IAEpG,0EAA0E;IAC1E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,KAAK,WAAW;YAAE,SAAS;QAClC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,gCAAgC,CAAC,CAAC;IAClG,CAAC;AACF,CAAC","sourcesContent":["/**\n * The MoQ Cluster extension (draft-lcurley-moq-cluster-01).\n *\n * moq-transport carries no routing information, so a peer cannot tell whether an\n * advertisement already passed through us. This extension adds it:\n *\n * - each endpoint declares its own Hop ID via the HOP_ID Setup Option, which is also what\n * negotiates the extension;\n * - every advertisement carries the HOP_PATH it traversed and the accumulated ROUTE_COST\n * of that path, as Key-Value-Pair message parameters on PUBLISH_NAMESPACE and NAMESPACE,\n * and a PUBLISH_NAMESPACE is repriced with the same parameters on a REQUEST_UPDATE.\n *\n * These are the semantics moq-lite carries natively on every announcement (see\n * `lite/announce.ts`); this module is the moq-transport binding, negotiated on draft-17+\n * only, where SETUP is a Key-Value-Pair block.\n *\n * A broadcast we produce carries a single-entry HOP_PATH and a cost of 0, and a route we\n * forward carries its own hop chain and warm cost with our id appended. What we get out of\n * declaring is also the other direction. A relay that knows our Hop ID withholds the advertisements that already flowed\n * through us, so publishing a broadcast no longer announces it back to us, which is what\n * moq-lite has always done with its own hop chain.\n *\n * @module\n * @internal\n */\n\nimport { ProtocolViolation, reason } from \"../error.ts\";\nimport { type Hop, HopSchema, MAX_HOPS, UNKNOWN_HOP } from \"../hop.ts\";\nimport type { Reader } from \"../stream.ts\";\nimport * as Varint from \"../varint.ts\";\nimport { Parameters, SetupOption, type SetupOptions } from \"./parameters.ts\";\nimport { type IetfVersion, Version } from \"./version.ts\";\n\n/**\n * Whether a version can negotiate the extension.\n *\n * Draft-17 is the first with the unified SETUP: a bare Key-Value-Pair block that a new\n * option slots into without touching the message shape. Earlier drafts exchange SETUP over\n * the legacy control stream, which this extension does not cover.\n *\n * @internal\n */\nexport function supported(version: IetfVersion): boolean {\n\treturn version !== Version.DRAFT_14 && version !== Version.DRAFT_15 && version !== Version.DRAFT_16;\n}\n\n/**\n * The Hop IDs this session declared, one per direction.\n *\n * @internal\n */\nexport interface Hops {\n\t/** Our own Hop ID, declared in SETUP and stamped onto every advertisement we send. */\n\tself: Hop;\n\n\t/**\n\t * The peer's Hop ID, or `undefined` when it declared no HOP_ID.\n\t *\n\t * This is what decides whether advertisements carry the parameters at all, in both\n\t * directions: a peer that declared nothing has not read ours either, so sending it a\n\t * HOP_PATH would be a protocol violation and expecting one back would reject a legal\n\t * message. A peer that declared the reserved 0 negotiated the extension but withheld its\n\t * identity, so the parameters flow and there is simply nothing to exclude.\n\t */\n\tpeer?: Hop;\n}\n\n/**\n * The cluster parameters carried on one advertisement.\n *\n * Present on every PUBLISH_NAMESPACE and NAMESPACE of a session that negotiated the\n * extension, and on none of a session that did not.\n *\n * @internal\n */\nexport interface Advert {\n\t/** HOP_PATH: the path this advertisement traversed, publisher first, sender last. */\n\thops: Hop[];\n\n\t/** ROUTE_COST: the marginal cost of subscribing via this advertisement. Absent on the\n\t * wire means 0, so an endpoint that prices nothing sends nothing. */\n\tcost: bigint;\n}\n\n/**\n * The cluster parameters a REQUEST_UPDATE on a PUBLISH_NAMESPACE carries: only what\n * changed, since an omitted parameter keeps its value.\n *\n * @internal\n */\nexport interface Update {\n\t/** HOP_PATH, when the route changed. */\n\thops?: Hop[];\n\n\t/** ROUTE_COST, when the cost changed. A cost that dropped to 0 arrives as an explicit\n\t * 0 here, unlike the advertisement itself where absent means 0. */\n\tcost?: bigint;\n}\n\n/**\n * Read the peer's Hop ID out of its SETUP, or `undefined` when it did not negotiate.\n *\n * @internal\n */\nexport function fromSetup(params: SetupOptions, version: IetfVersion): Hop | undefined {\n\tif (!supported(version)) return undefined;\n\n\t// 0 is legal: the peer speaks the extension but withholds its identity.\n\tconst value = params.getVarint(SetupOption.HopId);\n\tif (value === undefined) return undefined;\n\treturn HopSchema.parse(value);\n}\n\n/**\n * Declare our own Hop ID, which is also what negotiates the extension.\n *\n * @internal\n */\nexport function intoSetup(params: SetupOptions, self: Hop, version: IetfVersion) {\n\tif (!supported(version)) return;\n\tparams.setVarint(SetupOption.HopId, self);\n}\n\n/**\n * Whether the session negotiated the extension, which is what decides whether an\n * advertisement carries the parameters in either direction.\n *\n * @internal\n */\nexport function negotiated(ids: Hops | undefined): boolean {\n\treturn ids?.peer !== undefined;\n}\n\n/**\n * The advertisement to send for one of our own broadcasts, or `undefined` on a session\n * that negotiated nothing.\n *\n * The sender's own Hop ID is always the last entry, so a receiver reconstructs the full\n * path without the sender restating it. We originate everything we advertise, so the path\n * is just us and the cost is 0: a subscription costs the peer nothing but the transfer,\n * since we are already producing the content.\n *\n * @internal\n */\nexport function advertise(ids: Hops | undefined): Advert | undefined {\n\tif (ids === undefined || ids.peer === undefined) return undefined;\n\treturn { hops: [ids.self], cost: 0n };\n}\n\n/**\n * Whether this advertisement looped back through `self`.\n *\n * A receiver discards such an advertisement: forwarding it would extend the loop, and\n * subscribing through it would route the receiver back to itself. Hop ID 0 identifies\n * nothing, so a receiver that withheld its own identity detects nothing.\n *\n * @internal\n */\nexport function loops(advert: Advert, self: Hop): boolean {\n\treturn self !== UNKNOWN_HOP && advert.hops.includes(self);\n}\n\n/**\n * Write an advertisement's parameters, ready to encode onto the wire.\n *\n * @internal\n */\nexport function intoParams(advert: Advert): Parameters {\n\tconst params = new Parameters();\n\tparams.hopPath = encodeHops(advert.hops);\n\n\t// Absent means 0, so a free path sends nothing.\n\tif (advert.cost !== 0n) params.routeCost = advert.cost;\n\n\treturn params;\n}\n\n/**\n * Write a REQUEST_UPDATE's parameters: only what changed, and a cost of 0 explicitly,\n * since an omitted parameter keeps its value.\n *\n * @internal\n */\nexport function updateIntoParams(update: Update): Parameters {\n\tconst params = new Parameters();\n\tif (update.hops !== undefined) params.hopPath = encodeHops(update.hops);\n\tif (update.cost !== undefined) params.routeCost = update.cost;\n\treturn params;\n}\n\n/** Write a HOP_PATH value: the entries fill it with no count of their own, framed by the\n * parameter's own length prefix. */\nfunction encodeHops(hops: Hop[]): Uint8Array {\n\tvalidate(hops);\n\n\tconst encoded = hops.map((hop) => Varint.encodeLeadingOnes(hop));\n\tconst value = new Uint8Array(encoded.reduce((total, hop) => total + hop.length, 0));\n\tlet offset = 0;\n\tfor (const hop of encoded) {\n\t\tvalue.set(hop, offset);\n\t\toffset += hop.length;\n\t}\n\treturn value;\n}\n\n/**\n * Read the parameters a negotiated session puts on every advertisement.\n *\n * The parameter block is mandatory there, so a message that ends before it (the base form)\n * or one whose block does not parse is the peer's violation, same as a block that parses but\n * carries no HOP_PATH.\n *\n * @internal\n */\nexport async function decodeParams(r: Reader, version: IetfVersion): Promise<Advert> {\n\tlet params: Parameters;\n\ttry {\n\t\tparams = await Parameters.decode(r, version);\n\t} catch (err) {\n\t\tthrow new ProtocolViolation(reason(err), { cause: err });\n\t}\n\n\treturn fromParams(params);\n}\n\n/**\n * Read an advertisement out of a decoded parameter block.\n *\n * Every way this fails is one the draft says to close the session over: a negotiated session\n * that omits HOP_PATH, entries that do not exactly fill the parameter, an empty list, or a\n * non-zero Hop ID appearing twice. So they all surface as one {@link ProtocolViolation},\n * which the session dispatch acts on.\n *\n * @internal\n */\nexport function fromParams(params: Parameters): Advert {\n\ttry {\n\t\tconst value = params.hopPath;\n\t\tif (value === undefined) throw new Error(\"advertisement is missing HOP_PATH\");\n\t\treturn { hops: decodeHops(value), cost: params.routeCost ?? 0n };\n\t} catch (err) {\n\t\tthrow new ProtocolViolation(reason(err), { cause: err });\n\t}\n}\n\n/**\n * Read a REQUEST_UPDATE's parameters: each is optional, and a malformed HOP_PATH is the\n * same violation it is on an advertisement.\n *\n * @internal\n */\nexport function updateFromParams(params: Parameters): Update {\n\ttry {\n\t\tconst value = params.hopPath;\n\t\treturn { hops: value === undefined ? undefined : decodeHops(value), cost: params.routeCost };\n\t} catch (err) {\n\t\tthrow new ProtocolViolation(reason(err), { cause: err });\n\t}\n}\n\n/**\n * The advertisement after `update` lands on `held`: an omitted parameter keeps its value.\n *\n * @internal\n */\nexport function apply(held: Advert, update: Update): Advert {\n\treturn { hops: update.hops ?? held.hops, cost: update.cost ?? held.cost };\n}\n\n/** Read a HOP_PATH value: bare varints filling the parameter, with no count of their own. */\nfunction decodeHops(value: Uint8Array): Hop[] {\n\tconst hops: Hop[] = [];\n\tlet rest = value;\n\twhile (rest.length > 0) {\n\t\t// A short read here means the entries did not exactly fill the length.\n\t\tconst [hop, remain] = Varint.decodeLeadingOnes(rest);\n\t\thops.push(HopSchema.parse(hop));\n\t\trest = remain;\n\n\t\t// Bail before the buffer does: a hostile length would otherwise cost us one\n\t\t// allocation per entry all the way to 64KB of parameter value.\n\t\tif (hops.length > MAX_HOPS) throw new Error(`hop count exceeds maximum ${MAX_HOPS}`);\n\t}\n\n\tvalidate(hops);\n\treturn hops;\n}\n\n/**\n * Reject a path that cannot have come from a conforming sender: an empty list, one longer\n * than we accept, or a non-zero Hop ID appearing twice (a loop). Duplicate zeros are legal,\n * since 0 identifies nothing.\n */\nfunction validate(hops: Hop[]) {\n\tif (hops.length === 0) throw new Error(\"hop path is empty\");\n\tif (hops.length > MAX_HOPS) throw new Error(`hop count ${hops.length} exceeds maximum ${MAX_HOPS}`);\n\n\t// MAX_HOPS is 32, so the quadratic scan is cheaper than allocating a set.\n\tfor (let i = 0; i < hops.length; i++) {\n\t\tconst hop = hops[i];\n\t\tif (hop === UNKNOWN_HOP) continue;\n\t\tif (hops.indexOf(hop, i + 1) !== -1) throw new Error(`hop ${hop} appears twice in the hop path`);\n\t}\n}\n"]}
1
+ {"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/ietf/cluster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAY,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEvE,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAqB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAoB,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,OAAoB;IAC7C,OAAO,OAAO,KAAK,OAAO,CAAC,QAAQ,IAAI,OAAO,KAAK,OAAO,CAAC,QAAQ,IAAI,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC;AACrG,CAAC;AAuDD;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,MAAoB,EAAE,OAAoB;IACnE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAE1C,wEAAwE;IACxE,MAAM,KAAK,GAAG,MAAM,CAA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EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,KAAK,WAAW;YAAE,SAAS;QAClC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,gCAAgC,CAAC,CAAC;IAClG,CAAC;AACF,CAAC","sourcesContent":["/**\n * The MoQ Cluster extension (draft-lcurley-moq-cluster-01).\n *\n * moq-transport carries no routing information, so a peer cannot tell whether an\n * advertisement already passed through us. This extension adds it:\n *\n * - each endpoint declares its own Hop ID via the HOP_ID Setup Option, which is also what\n * negotiates the extension;\n * - every advertisement carries the HOP_PATH it traversed and the accumulated ROUTE_COST\n * of that path, as Key-Value-Pair message parameters on PUBLISH_NAMESPACE and NAMESPACE,\n * and a PUBLISH_NAMESPACE is repriced with the same parameters on a REQUEST_UPDATE.\n *\n * These are the semantics moq-lite carries natively on every announcement (see\n * `lite/announce.ts`); this module is the moq-transport binding, negotiated on draft-17+\n * only, where SETUP is a Key-Value-Pair block.\n *\n * A broadcast we produce carries a single-entry HOP_PATH and a cost of 0, and a route we\n * forward carries its own hop chain and warm cost with our id appended. What we get out of\n * declaring is also the other direction. A relay that knows our Hop ID withholds the advertisements that already flowed\n * through us, so publishing a broadcast no longer announces it back to us, which is what\n * moq-lite has always done with its own hop chain.\n *\n * @module\n * @internal\n */\n\nimport { ProtocolViolation, reason } from \"../error.ts\";\nimport { type Hop, HopSchema, MAX_HOPS, UNKNOWN_HOP } from \"../hop.ts\";\nimport type { Reader } from \"../stream.ts\";\nimport * as Varint from \"../varint.ts\";\nimport { Parameters, SetupOption, type SetupOptions } from \"./parameters.ts\";\nimport { type IetfVersion, Version } from \"./version.ts\";\n\n/**\n * Whether a version can negotiate the extension.\n *\n * Draft-17 is the first with the unified SETUP: a bare Key-Value-Pair block that a new\n * option slots into without touching the message shape. Earlier drafts exchange SETUP over\n * the legacy control stream, which this extension does not cover.\n *\n * @internal\n */\nexport function supported(version: IetfVersion): boolean {\n\treturn version !== Version.DRAFT_14 && version !== Version.DRAFT_15 && version !== Version.DRAFT_16;\n}\n\n/**\n * The Hop IDs this session declared, one per direction.\n *\n * @internal\n */\nexport interface Hops {\n\t/** Our own Hop ID, declared in SETUP and stamped onto every advertisement we send. */\n\tself: Hop;\n\n\t/**\n\t * The peer's Hop ID, or `undefined` when it declared no HOP_ID.\n\t *\n\t * This is what decides whether advertisements carry the parameters at all, in both\n\t * directions: a peer that declared nothing has not read ours either, so sending it a\n\t * HOP_PATH would be a protocol violation and expecting one back would reject a legal\n\t * message. A peer that declared the reserved 0 negotiated the extension but withheld its\n\t * identity, so the parameters flow and there is simply nothing to exclude.\n\t */\n\tpeer?: Hop;\n}\n\n/**\n * The cluster parameters carried on one advertisement.\n *\n * Present on every PUBLISH_NAMESPACE and NAMESPACE of a session that negotiated the\n * extension, and on none of a session that did not.\n *\n * @internal\n */\nexport interface Advert {\n\t/** HOP_PATH: the path this advertisement traversed, publisher first, sender last. */\n\thops: Hop[];\n\n\t/** ROUTE_COST: the marginal cost of subscribing via this advertisement. Absent on the\n\t * wire means 0, so an endpoint that prices nothing sends nothing. */\n\tcost: bigint;\n}\n\n/**\n * The cluster parameters a REQUEST_UPDATE on a PUBLISH_NAMESPACE carries: only what\n * changed, since an omitted parameter keeps its value.\n *\n * @internal\n */\nexport interface Update {\n\t/** HOP_PATH, when the route changed. */\n\thops?: Hop[];\n\n\t/** ROUTE_COST, when the cost changed. A cost that dropped to 0 arrives as an explicit\n\t * 0 here, unlike the advertisement itself where absent means 0. */\n\tcost?: bigint;\n}\n\n/**\n * Read the peer's Hop ID out of its SETUP, or `undefined` when it did not negotiate.\n *\n * @internal\n */\nexport function fromSetup(params: SetupOptions, version: IetfVersion): Hop | undefined {\n\tif (!supported(version)) return undefined;\n\n\t// 0 is legal: the peer speaks the extension but withholds its identity.\n\tconst value = params.getVarint(SetupOption.HopId);\n\tif (value === undefined) return undefined;\n\treturn fromWire(value);\n}\n\n/**\n * Declare our own Hop ID, which is also what negotiates the extension.\n *\n * @internal\n */\nexport function intoSetup(params: SetupOptions, self: Hop, version: IetfVersion) {\n\tif (!supported(version)) return;\n\tparams.setVarint(SetupOption.HopId, self);\n}\n\n/**\n * Whether the session negotiated the extension, which is what decides whether an\n * advertisement carries the parameters in either direction.\n *\n * @internal\n */\nexport function negotiated(ids: Hops | undefined): boolean {\n\treturn ids?.peer !== undefined;\n}\n\n/**\n * The advertisement to send for one of our own broadcasts, or `undefined` on a session\n * that negotiated nothing.\n *\n * The sender's own Hop ID is always the last entry, so a receiver reconstructs the full\n * path without the sender restating it. We originate everything we advertise, so the path\n * is just us and the cost is 0: a subscription costs the peer nothing but the transfer,\n * since we are already producing the content.\n *\n * @internal\n */\nexport function advertise(ids: Hops | undefined): Advert | undefined {\n\tif (ids === undefined || ids.peer === undefined) return undefined;\n\treturn { hops: [ids.self], cost: 0n };\n}\n\n/**\n * Whether this advertisement looped back through `self`.\n *\n * A receiver discards such an advertisement: forwarding it would extend the loop, and\n * subscribing through it would route the receiver back to itself. Hop ID 0 identifies\n * nothing, so a receiver that withheld its own identity detects nothing.\n *\n * @internal\n */\nexport function loops(advert: Advert, self: Hop): boolean {\n\treturn self !== UNKNOWN_HOP && advert.hops.includes(self);\n}\n\n/**\n * Write an advertisement's parameters, ready to encode onto the wire.\n *\n * @internal\n */\nexport function intoParams(advert: Advert): Parameters {\n\tconst params = new Parameters();\n\tparams.hopPath = encodeHops(advert.hops);\n\n\t// Absent means 0, so a free path sends nothing.\n\tif (advert.cost !== 0n) params.routeCost = advert.cost;\n\n\treturn params;\n}\n\n/**\n * Write a REQUEST_UPDATE's parameters: only what changed, and a cost of 0 explicitly,\n * since an omitted parameter keeps its value.\n *\n * @internal\n */\nexport function updateIntoParams(update: Update): Parameters {\n\tconst params = new Parameters();\n\tif (update.hops !== undefined) params.hopPath = encodeHops(update.hops);\n\tif (update.cost !== undefined) params.routeCost = update.cost;\n\treturn params;\n}\n\n/** Write a HOP_PATH value: the entries fill it with no count of their own, framed by the\n * parameter's own length prefix. */\nfunction encodeHops(hops: Hop[]): Uint8Array {\n\tvalidate(hops);\n\n\tconst encoded = hops.map((hop) => Varint.encodeLeadingOnes(hop));\n\tconst value = new Uint8Array(encoded.reduce((total, hop) => total + hop.length, 0));\n\tlet offset = 0;\n\tfor (const hop of encoded) {\n\t\tvalue.set(hop, offset);\n\t\toffset += hop.length;\n\t}\n\treturn value;\n}\n\n/**\n * Read the parameters a negotiated session puts on every advertisement.\n *\n * The parameter block is mandatory there, so a message that ends before it (the base form)\n * or one whose block does not parse is the peer's violation, same as a block that parses but\n * carries no HOP_PATH.\n *\n * @internal\n */\nexport async function decodeParams(r: Reader, version: IetfVersion): Promise<Advert> {\n\tlet params: Parameters;\n\ttry {\n\t\tparams = await Parameters.decode(r, version);\n\t} catch (err) {\n\t\tthrow new ProtocolViolation(reason(err), { cause: err });\n\t}\n\n\treturn fromParams(params);\n}\n\n/**\n * Read an advertisement out of a decoded parameter block.\n *\n * Every way this fails is one the draft says to close the session over: a negotiated session\n * that omits HOP_PATH, entries that do not exactly fill the parameter, an empty list, or a\n * non-zero Hop ID appearing twice. So they all surface as one {@link ProtocolViolation},\n * which the session dispatch acts on.\n *\n * @internal\n */\nexport function fromParams(params: Parameters): Advert {\n\ttry {\n\t\tconst value = params.hopPath;\n\t\tif (value === undefined) throw new Error(\"advertisement is missing HOP_PATH\");\n\t\treturn { hops: decodeHops(value), cost: params.routeCost ?? 0n };\n\t} catch (err) {\n\t\tthrow new ProtocolViolation(reason(err), { cause: err });\n\t}\n}\n\n/**\n * Read a REQUEST_UPDATE's parameters: each is optional, and a malformed HOP_PATH is the\n * same violation it is on an advertisement.\n *\n * @internal\n */\nexport function updateFromParams(params: Parameters): Update {\n\ttry {\n\t\tconst value = params.hopPath;\n\t\treturn { hops: value === undefined ? undefined : decodeHops(value), cost: params.routeCost };\n\t} catch (err) {\n\t\tthrow new ProtocolViolation(reason(err), { cause: err });\n\t}\n}\n\n/**\n * The advertisement after `update` lands on `held`: an omitted parameter keeps its value.\n *\n * @internal\n */\nexport function apply(held: Advert, update: Update): Advert {\n\treturn { hops: update.hops ?? held.hops, cost: update.cost ?? held.cost };\n}\n\n/**\n * Read a Hop ID off the wire. The draft gives it the full 64-bit varint range, but a\n * {@link Hop} on this release line is 62 bits, so a wider id reads as {@link UNKNOWN_HOP}:\n * it identifies nothing, which costs loop detection through that hop instead of the session.\n */\nfunction fromWire(value: bigint): Hop {\n\treturn value >= 1n << 62n ? UNKNOWN_HOP : HopSchema.parse(value);\n}\n\n/** Read a HOP_PATH value: bare varints filling the parameter, with no count of their own. */\nfunction decodeHops(value: Uint8Array): Hop[] {\n\tconst hops: Hop[] = [];\n\tlet rest = value;\n\twhile (rest.length > 0) {\n\t\t// A short read here means the entries did not exactly fill the length.\n\t\tconst [hop, remain] = Varint.decodeLeadingOnes(rest);\n\t\thops.push(fromWire(hop));\n\t\trest = remain;\n\n\t\t// Bail before the buffer does: a hostile length would otherwise cost us one\n\t\t// allocation per entry all the way to 64KB of parameter value.\n\t\tif (hops.length > MAX_HOPS) throw new Error(`hop count exceeds maximum ${MAX_HOPS}`);\n\t}\n\n\tvalidate(hops);\n\treturn hops;\n}\n\n/**\n * Reject a path that cannot have come from a conforming sender: an empty list, one longer\n * than we accept, or a non-zero Hop ID appearing twice (a loop). Duplicate zeros are legal,\n * since 0 identifies nothing.\n */\nfunction validate(hops: Hop[]) {\n\tif (hops.length === 0) throw new Error(\"hop path is empty\");\n\tif (hops.length > MAX_HOPS) throw new Error(`hop count ${hops.length} exceeds maximum ${MAX_HOPS}`);\n\n\t// MAX_HOPS is 32, so the quadratic scan is cheaper than allocating a set.\n\tfor (let i = 0; i < hops.length; i++) {\n\t\tconst hop = hops[i];\n\t\tif (hop === UNKNOWN_HOP) continue;\n\t\tif (hops.indexOf(hop, i + 1) !== -1) throw new Error(`hop ${hop} appears twice in the hop path`);\n\t}\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { type Getter } from "@moq/signals";
2
- import type * as announce from "../announced";
3
- import type { Established } from "../connection/established";
4
- import { type Probe, type Stats } from "../connection/stats";
5
- import { type Transport } from "../connection/transport";
6
- import type * as Path from "../path";
2
+ import type * as announce from "../announced.ts";
3
+ import type { Established } from "../connection/established.ts";
4
+ import { type Probe, type Stats } from "../connection/stats.ts";
5
+ import { type Transport } from "../connection/transport.ts";
6
+ import type * as Path from "../path.ts";
7
7
  /**
8
8
  * Represents a connection to a MoQ server using moq-transport protocol.
9
9
  *
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./connection.d.ts" */
2
1
  import { Once, Signal } from "@moq/signals";
3
2
  import { transportStats } from "../connection/stats.js";
4
3
  import { transportOf } from "../connection/transport.js";
package/ietf/error.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./error.d.ts" */
2
1
  /**
3
2
  * The moq-transport error code registries, per negotiated draft.
4
3
  *
package/ietf/fetch.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type Reader, Writer } from "../stream";
2
- import { type IetfVersion } from "./version";
1
+ import { type Reader, Writer } from "../stream.ts";
2
+ import { type IetfVersion } from "./version.ts";
3
3
  /**
4
4
  * The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it
5
5
  * answers. Written by the publisher when serving a subscription's fill.