@moq/net 0.4.0 → 0.4.2

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 (204) hide show
  1. package/announced.d.ts +14 -0
  2. package/announced.d.ts.map +1 -1
  3. package/announced.js.map +1 -1
  4. package/broadcast.d.ts +27 -10
  5. package/broadcast.d.ts.map +1 -1
  6. package/broadcast.js +47 -21
  7. package/broadcast.js.map +1 -1
  8. package/connection/accept.js +14 -4
  9. package/connection/accept.js.map +1 -1
  10. package/connection/connect.d.ts.map +1 -1
  11. package/connection/connect.js +14 -4
  12. package/connection/connect.js.map +1 -1
  13. package/connection/established.d.ts +2 -1
  14. package/connection/established.d.ts.map +1 -1
  15. package/connection/established.js.map +1 -1
  16. package/connection/forward.js +61 -47
  17. package/connection/forward.js.map +1 -1
  18. package/connection/goaway.d.ts +34 -0
  19. package/connection/goaway.d.ts.map +1 -0
  20. package/connection/goaway.js +176 -0
  21. package/connection/goaway.js.map +1 -0
  22. package/connection/handshake.d.ts +5 -2
  23. package/connection/handshake.d.ts.map +1 -1
  24. package/connection/handshake.js +45 -10
  25. package/connection/handshake.js.map +1 -1
  26. package/connection/pool.d.ts +24 -11
  27. package/connection/pool.d.ts.map +1 -1
  28. package/connection/pool.js +50 -18
  29. package/connection/pool.js.map +1 -1
  30. package/connection/reload.d.ts.map +1 -1
  31. package/connection/reload.js +189 -35
  32. package/connection/reload.js.map +1 -1
  33. package/error.d.ts +11 -0
  34. package/error.d.ts.map +1 -1
  35. package/error.js +35 -0
  36. package/error.js.map +1 -1
  37. package/errors.d.ts +1 -1
  38. package/errors.d.ts.map +1 -1
  39. package/errors.js +1 -1
  40. package/errors.js.map +1 -1
  41. package/group.d.ts.map +1 -1
  42. package/group.js +5 -4
  43. package/group.js.map +1 -1
  44. package/hop.d.ts +8 -0
  45. package/hop.d.ts.map +1 -1
  46. package/hop.js +16 -0
  47. package/hop.js.map +1 -1
  48. package/ietf/adapter.d.ts +9 -1
  49. package/ietf/adapter.d.ts.map +1 -1
  50. package/ietf/adapter.js +46 -17
  51. package/ietf/adapter.js.map +1 -1
  52. package/ietf/cluster.d.ts +3 -3
  53. package/ietf/cluster.js +3 -3
  54. package/ietf/cluster.js.map +1 -1
  55. package/ietf/connection.d.ts +1 -1
  56. package/ietf/connection.d.ts.map +1 -1
  57. package/ietf/connection.js +118 -41
  58. package/ietf/connection.js.map +1 -1
  59. package/ietf/error.js +27 -2
  60. package/ietf/error.js.map +1 -1
  61. package/ietf/fetch.d.ts +7 -20
  62. package/ietf/fetch.d.ts.map +1 -1
  63. package/ietf/fetch.js +52 -22
  64. package/ietf/fetch.js.map +1 -1
  65. package/ietf/filter.d.ts +2 -0
  66. package/ietf/filter.d.ts.map +1 -1
  67. package/ietf/filter.js +4 -0
  68. package/ietf/filter.js.map +1 -1
  69. package/ietf/goaway.d.ts +9 -1
  70. package/ietf/goaway.d.ts.map +1 -1
  71. package/ietf/goaway.js +20 -0
  72. package/ietf/goaway.js.map +1 -1
  73. package/ietf/hidden.d.ts +2 -0
  74. package/ietf/hidden.d.ts.map +1 -0
  75. package/ietf/hidden.js +30 -0
  76. package/ietf/hidden.js.map +1 -0
  77. package/ietf/index.d.ts +2 -1
  78. package/ietf/index.d.ts.map +1 -1
  79. package/ietf/index.js +2 -1
  80. package/ietf/index.js.map +1 -1
  81. package/ietf/object.d.ts +15 -8
  82. package/ietf/object.d.ts.map +1 -1
  83. package/ietf/object.js +54 -36
  84. package/ietf/object.js.map +1 -1
  85. package/ietf/parameters.d.ts +12 -0
  86. package/ietf/parameters.d.ts.map +1 -1
  87. package/ietf/parameters.js +82 -12
  88. package/ietf/parameters.js.map +1 -1
  89. package/ietf/properties.d.ts +1 -0
  90. package/ietf/properties.d.ts.map +1 -1
  91. package/ietf/properties.js +14 -0
  92. package/ietf/properties.js.map +1 -1
  93. package/ietf/publish.d.ts +19 -2
  94. package/ietf/publish.d.ts.map +1 -1
  95. package/ietf/publish.js +40 -6
  96. package/ietf/publish.js.map +1 -1
  97. package/ietf/publish_namespace.d.ts +2 -2
  98. package/ietf/publish_namespace.js +2 -2
  99. package/ietf/publish_namespace.js.map +1 -1
  100. package/ietf/publisher.js +383 -214
  101. package/ietf/publisher.js.map +1 -1
  102. package/ietf/subscribe.d.ts +7 -1
  103. package/ietf/subscribe.d.ts.map +1 -1
  104. package/ietf/subscribe.js +25 -18
  105. package/ietf/subscribe.js.map +1 -1
  106. package/ietf/subscribe_namespace.d.ts +8 -2
  107. package/ietf/subscribe_namespace.d.ts.map +1 -1
  108. package/ietf/subscribe_namespace.js +20 -11
  109. package/ietf/subscribe_namespace.js.map +1 -1
  110. package/ietf/subscriber.js +226 -88
  111. package/ietf/subscriber.js.map +1 -1
  112. package/ietf/token.d.ts +2 -0
  113. package/ietf/token.d.ts.map +1 -0
  114. package/ietf/token.js +99 -0
  115. package/ietf/token.js.map +1 -0
  116. package/ietf/track.d.ts +4 -0
  117. package/ietf/track.d.ts.map +1 -1
  118. package/ietf/track.js +6 -20
  119. package/ietf/track.js.map +1 -1
  120. package/index.d.ts +1 -1
  121. package/index.d.ts.map +1 -1
  122. package/index.js.map +1 -1
  123. package/internal.d.ts +19 -3
  124. package/internal.d.ts.map +1 -1
  125. package/internal.js +43 -0
  126. package/internal.js.map +1 -1
  127. package/lite/announce.d.ts +46 -2
  128. package/lite/announce.d.ts.map +1 -1
  129. package/lite/announce.js +133 -15
  130. package/lite/announce.js.map +1 -1
  131. package/lite/connection.d.ts +1 -1
  132. package/lite/connection.d.ts.map +1 -1
  133. package/lite/connection.js +30 -9
  134. package/lite/connection.js.map +1 -1
  135. package/lite/datagram.d.ts +3 -2
  136. package/lite/datagram.d.ts.map +1 -1
  137. package/lite/datagram.js +7 -8
  138. package/lite/datagram.js.map +1 -1
  139. package/lite/group.d.ts +12 -8
  140. package/lite/group.d.ts.map +1 -1
  141. package/lite/group.js +37 -16
  142. package/lite/group.js.map +1 -1
  143. package/lite/message.d.ts +2 -2
  144. package/lite/message.d.ts.map +1 -1
  145. package/lite/message.js +14 -5
  146. package/lite/message.js.map +1 -1
  147. package/lite/publisher.js +174 -133
  148. package/lite/publisher.js.map +1 -1
  149. package/lite/setup.d.ts +1 -1
  150. package/lite/setup.d.ts.map +1 -1
  151. package/lite/setup.js +22 -19
  152. package/lite/setup.js.map +1 -1
  153. package/lite/subscribe.d.ts +10 -4
  154. package/lite/subscribe.d.ts.map +1 -1
  155. package/lite/subscribe.js +20 -10
  156. package/lite/subscribe.js.map +1 -1
  157. package/lite/subscriber.d.ts +10 -2
  158. package/lite/subscriber.d.ts.map +1 -1
  159. package/lite/subscriber.js +333 -188
  160. package/lite/subscriber.js.map +1 -1
  161. package/lite/version.d.ts +11 -0
  162. package/lite/version.d.ts.map +1 -1
  163. package/lite/version.js +56 -0
  164. package/lite/version.js.map +1 -1
  165. package/origin.d.ts +46 -19
  166. package/origin.d.ts.map +1 -1
  167. package/origin.js +529 -189
  168. package/origin.js.map +1 -1
  169. package/package.json +8 -4
  170. package/stream.d.ts +79 -14
  171. package/stream.d.ts.map +1 -1
  172. package/stream.js +375 -133
  173. package/stream.js.map +1 -1
  174. package/tail.d.ts +18 -0
  175. package/tail.d.ts.map +1 -0
  176. package/tail.js +167 -0
  177. package/tail.js.map +1 -0
  178. package/track.d.ts +46 -7
  179. package/track.d.ts.map +1 -1
  180. package/track.js +263 -101
  181. package/track.js.map +1 -1
  182. package/util/abort.d.ts +2 -0
  183. package/util/abort.d.ts.map +1 -0
  184. package/util/abort.js +20 -0
  185. package/util/abort.js.map +1 -0
  186. package/util/u64.d.ts +39 -0
  187. package/util/u64.d.ts.map +1 -0
  188. package/util/u64.js +83 -0
  189. package/util/u64.js.map +1 -0
  190. package/util/varint.d.ts +29 -0
  191. package/util/varint.d.ts.map +1 -0
  192. package/util/varint.js +198 -0
  193. package/util/varint.js.map +1 -0
  194. package/varint.d.ts +10 -6
  195. package/varint.d.ts.map +1 -1
  196. package/varint.js +40 -237
  197. package/varint.js.map +1 -1
  198. package/wire.d.ts +19 -3
  199. package/wire.d.ts.map +1 -1
  200. package/wire.js.map +1 -1
  201. package/ietf/control.d.ts +0 -135
  202. package/ietf/control.d.ts.map +0 -1
  203. package/ietf/control.js +0 -242
  204. package/ietf/control.js.map +0 -1
@@ -1,22 +1,25 @@
1
1
  /* @ts-self-types="./connection.d.ts" */
2
- import { Signal } from "@moq/signals";
2
+ import { Once, Signal } from "@moq/signals";
3
3
  import { transportStats } from "../connection/stats.js";
4
4
  import { transportOf } from "../connection/transport.js";
5
- import { error, fromClose, ProtocolViolation, StreamCode, StreamError } from "../error.js";
5
+ import { error, fromClose, ProtocolViolation, SessionCode, StreamCode, StreamError } from "../error.js";
6
6
  import { Readers } from "../stream.js";
7
7
  import { registerWire } from "../wire.js";
8
8
  import { ControlStreamAdapter, NativeSession } from "./adapter.js";
9
9
  import * as Cluster from "./cluster.js";
10
+ import { Fetch, FetchHeader } from "./fetch.js";
10
11
  import { GoAway } from "./goaway.js";
11
12
  import { Group } from "./object.js";
12
13
  import { Publish } from "./publish.js";
13
14
  import { PublishNamespace } from "./publish_namespace.js";
14
15
  import { Publisher } from "./publisher.js";
15
16
  import { Subscribe, SubscribeUpdate } from "./subscribe.js";
16
- import { SubscribeNamespace, SubscribeNamespaceLegacy } from "./subscribe_namespace.js";
17
+ import { SUBSCRIBE_TRACKS_ID, SubscribeNamespace, SubscribeNamespaceLegacy } from "./subscribe_namespace.js";
17
18
  import { Subscriber } from "./subscriber.js";
18
19
  import { TrackStatusRequest } from "./track.js";
19
20
  import { Version, versionName } from "./version.js";
21
+ // The PADDING stream type (draft-18+): bytes a peer sends to probe for bandwidth.
22
+ const PADDING = 0x132b3e28n;
20
23
  /**
21
24
  * Represents a connection to a MoQ server using moq-transport protocol.
22
25
  *
@@ -35,6 +38,8 @@ export class Connection {
35
38
  probe = new Signal({});
36
39
  // The established WebTransport session.
37
40
  #quic;
41
+ // Whether this side opened the session. Only a server may name a redirect.
42
+ #client;
38
43
  // Session abstraction: adapter for v14-v16, native for v17.
39
44
  #session;
40
45
  // Module for contributing tracks.
@@ -45,6 +50,8 @@ export class Connection {
45
50
  #solicit;
46
51
  // The Hop IDs this session declared; see {@link Cluster}.
47
52
  #cluster;
53
+ // The peer's GOAWAY: read here on v17+, by the control stream adapter before that.
54
+ #goaway;
48
55
  // Just to avoid logging when `close()` is called.
49
56
  #closed = false;
50
57
  /**
@@ -56,29 +63,33 @@ export class Connection {
56
63
  * @param version - The negotiated protocol version
57
64
  * @param solicit - What the peer's SETUP declared (undefined when it declared nothing)
58
65
  * @param cluster - The Hop IDs the SETUP exchange settled, on the versions that negotiate them
66
+ * @param early - Uni streams that arrived before the peer's SETUP
59
67
  *
60
68
  * @internal
61
69
  */
62
- constructor({ url, quic, control, maxRequestId, version, client, discovery = true, publish, solicit, cluster, }) {
70
+ constructor({ url, quic, control, maxRequestId, version, client, discovery = true, publish, solicit, hidden = false, cluster, early = [], }) {
63
71
  this.url = url;
64
72
  this.discovery = discovery;
65
73
  this.version = versionName(version);
66
74
  this.transport = transportOf(quic);
67
75
  this.#quic = quic;
76
+ this.#client = client;
68
77
  // Two-path dispatch: v14-v16 uses adapter, v17+ uses native bidi streams
69
78
  if (version >= Version.DRAFT_17) {
70
79
  this.#session = new NativeSession(quic, version, client);
80
+ this.#goaway = new Once();
71
81
  // v17+: control/setup stream only carries GoAway
72
82
  void this.#runGoAway(control, version);
73
83
  }
74
84
  else {
75
85
  const adapter = new ControlStreamAdapter(quic, control, version, maxRequestId, client);
76
86
  this.#session = adapter;
87
+ this.#goaway = adapter.goaway;
77
88
  // Start the adapter read loop (routes control messages to virtual streams)
78
89
  void adapter.run().catch((err) => {
79
90
  if (!this.#closed)
80
91
  console.error("adapter error", err);
81
- this.close();
92
+ this.#close();
82
93
  });
83
94
  }
84
95
  this.#publisher = new Publisher({
@@ -86,13 +97,14 @@ export class Connection {
86
97
  session: this.#session,
87
98
  publish,
88
99
  requiresSolicitation: solicit ?? false,
100
+ hidden,
89
101
  cluster,
90
102
  });
91
103
  this.#solicit = solicit;
92
104
  this.#cluster = cluster;
93
- this.#subscriber = new Subscriber({ session: this.#session, cluster });
94
- registerWire(this, { consume: (path) => this.#subscriber.consume(path) });
95
- void this.#run();
105
+ this.#subscriber = new Subscriber({ session: this.#session, quic, cluster, hidden });
106
+ registerWire(this, { consume: (path) => this.#subscriber.consume(path), goaway: this.#goaway });
107
+ void this.#run(early);
96
108
  }
97
109
  /** Snapshot the transport's counters; see {@link Established.stats}. */
98
110
  async stats() {
@@ -102,20 +114,33 @@ export class Connection {
102
114
  * Closes the connection.
103
115
  */
104
116
  close() {
117
+ if (this.#closed)
118
+ return;
119
+ this.#subscriber.close();
120
+ this.#close();
121
+ }
122
+ // Close with the session code the peer should see, a clean close by default.
123
+ #close(info) {
105
124
  if (this.#closed)
106
125
  return;
107
126
  this.#closed = true;
108
- this.#session.close();
127
+ // Before the session, whose own close would send a clean code first.
109
128
  try {
110
- this.#quic.close();
129
+ this.#quic.close(info);
111
130
  }
112
131
  catch {
113
132
  // ignore
114
133
  }
134
+ this.#session.close();
135
+ }
136
+ // The peer broke the protocol, so losing the stream is not enough: nothing stops it
137
+ // repeating the violation on the next one.
138
+ #violated(err) {
139
+ this.#close({ closeCode: SessionCode.ProtocolViolation, reason: err.message });
115
140
  }
116
- async #run() {
141
+ async #run(early) {
117
142
  try {
118
- await Promise.all([this.#runBidis(), this.#runUnis(), this.#publisher.runPublishNamespaces()]);
143
+ await Promise.all([this.#runBidis(), this.#runUnis(early), this.#publisher.runPublishNamespaces()]);
119
144
  }
120
145
  catch (err) {
121
146
  if (!this.#closed) {
@@ -123,12 +148,12 @@ export class Connection {
123
148
  }
124
149
  }
125
150
  finally {
126
- this.close();
151
+ this.#close();
127
152
  }
128
153
  }
129
154
  /** Gets an announced reader for `scope`; see {@link Established.announced}. */
130
- announced(scope) {
131
- return this.#subscriber.announced(scope);
155
+ announced(scope, options) {
156
+ return this.#subscriber.announced(scope, options);
132
157
  }
133
158
  /**
134
159
  * Accepts bidi streams (virtual for v14-v16, real for v17) and dispatches.
@@ -141,10 +166,8 @@ export class Connection {
141
166
  void this.#runBidi(stream).catch((err) => {
142
167
  console.error("error processing bidi stream", err);
143
168
  stream.abort(new Error("bidi stream error"));
144
- // The peer broke the protocol, so losing the stream is not enough: nothing
145
- // stops it repeating the violation on the next one.
146
169
  if (err instanceof ProtocolViolation)
147
- this.close();
170
+ this.#violated(err);
148
171
  });
149
172
  }
150
173
  }
@@ -164,7 +187,11 @@ export class Connection {
164
187
  }
165
188
  case SubscribeNamespaceLegacy.id: {
166
189
  const legacy = await SubscribeNamespaceLegacy.decode(stream.reader, this.#session.version);
167
- const msg = new SubscribeNamespace({ requestId: legacy.requestId, namespace: legacy.namespace });
190
+ const msg = new SubscribeNamespace({
191
+ requestId: legacy.requestId,
192
+ namespace: legacy.namespace,
193
+ hidden: legacy.hidden,
194
+ });
168
195
  await this.#publisher.runSubscribeNamespace(msg, stream);
169
196
  break;
170
197
  }
@@ -179,11 +206,24 @@ export class Connection {
179
206
  await this.#publisher.runSubscribe(msg, stream);
180
207
  break;
181
208
  }
209
+ case SUBSCRIBE_TRACKS_ID: {
210
+ // 0x51 is only a message from draft-18 on.
211
+ if (this.#session.version < Version.DRAFT_18) {
212
+ throw new ProtocolViolation("SUBSCRIBE_TRACKS before draft-18");
213
+ }
214
+ await this.#publisher.runSubscribeTracks(stream);
215
+ break;
216
+ }
182
217
  case TrackStatusRequest.id: {
183
218
  const msg = await TrackStatusRequest.decode(stream.reader, this.#session.version);
184
219
  await this.#publisher.runTrackStatusRequest(msg, stream);
185
220
  break;
186
221
  }
222
+ case Fetch.id: {
223
+ const msg = await Fetch.decode(stream.reader, this.#session.version);
224
+ await this.#publisher.runFetch(msg, stream);
225
+ break;
226
+ }
187
227
  // Subscriber handles incoming notifications
188
228
  case PublishNamespace.id: {
189
229
  const msg = await PublishNamespace.decode(stream.reader, this.#session.version, Cluster.negotiated(this.#cluster));
@@ -200,7 +240,7 @@ export class Connection {
200
240
  const legacy = this.#session.version === Version.DRAFT_14 || this.#session.version === Version.DRAFT_15;
201
241
  if (this.#solicit !== undefined && !legacy) {
202
242
  console.error(`unsolicited publish_namespace from a peer that implements MoQ Solicit: broadcast=${msg.trackNamespace}`);
203
- this.close();
243
+ this.#close();
204
244
  break;
205
245
  }
206
246
  await this.#subscriber.runPublishNamespace(msg, stream);
@@ -219,41 +259,78 @@ export class Connection {
219
259
  /**
220
260
  * Handles unidirectional streams for media delivery (groups).
221
261
  */
222
- async #runUnis() {
262
+ async #runUnis(early) {
263
+ // Streams that beat the SETUP go first, in arrival order.
264
+ for (const stream of early)
265
+ this.#spawnUni(stream);
223
266
  const readers = new Readers(this.#quic, this.#session.version);
224
267
  for (;;) {
225
268
  const stream = await readers.next();
226
269
  if (!stream)
227
270
  break;
228
- this.#runUni(stream)
229
- .then(() => {
230
- stream.stop(new StreamError(StreamCode.Cancel, { message: "cancel" }));
231
- })
232
- .catch((err) => {
233
- console.error("error processing object stream", err);
234
- stream.stop(err);
235
- });
271
+ this.#spawnUni(stream);
236
272
  }
237
273
  }
274
+ #spawnUni(stream) {
275
+ this.#runUni(stream)
276
+ .then(() => {
277
+ stream.stop(new StreamError(StreamCode.Cancel, { message: "cancel" }));
278
+ })
279
+ .catch((err) => {
280
+ console.error("error processing object stream", err);
281
+ stream.stop(err);
282
+ // An unknown or invalid stream type MUST close the session, not just the stream.
283
+ if (err instanceof ProtocolViolation)
284
+ this.#violated(err);
285
+ });
286
+ }
238
287
  async #runUni(stream) {
239
- const header = await Group.decode(stream, this.#session.version);
240
- await this.#subscriber.handleGroup(header, stream);
288
+ const version = this.#session.version;
289
+ // Full width, so an unknown type past 2^53 is still classified rather than thrown.
290
+ const type = await stream.u62();
291
+ // SUBGROUP_HEADER types match 0b0XX1XXXX; Group.decode validates the bits per draft.
292
+ if (type <= 0xffn && (type & 0x90n) === 0x10n) {
293
+ const header = await Group.decode(stream, version, Number(type));
294
+ await this.#subscriber.handleGroup(header, stream);
295
+ return;
296
+ }
297
+ // The receiver MUST discard padding. We read it to the end rather than cancel,
298
+ // so a peer probing for bandwidth gets the throughput it is measuring.
299
+ if (type === PADDING && version >= Version.DRAFT_18) {
300
+ await stream.discard();
301
+ return;
302
+ }
303
+ // We never FETCH, so a fetch response answers nothing of ours.
304
+ if (type === BigInt(FetchHeader.type))
305
+ throw new Error("unexpected fetch stream");
306
+ // Anything else is unknown, and a second SETUP is a violation too.
307
+ throw new ProtocolViolation(`unknown uni stream type: 0x${type.toString(16)}`);
241
308
  }
242
309
  /**
243
310
  * v17+ only: reads GoAway from the setup/control stream.
311
+ *
312
+ * The session keeps serving after a GOAWAY so its groups in flight can finish while the
313
+ * caller migrates; only the stream ending, or a second GOAWAY, closes it here.
244
314
  */
245
315
  async #runGoAway(controlStream, version) {
246
316
  try {
247
- const done = await controlStream.reader.done();
248
- if (done)
249
- return;
250
- const typeId = await controlStream.reader.u53();
251
- if (typeId === GoAway.id) {
317
+ for (;;) {
318
+ const done = await controlStream.reader.done();
319
+ if (done)
320
+ return;
321
+ const typeId = await controlStream.reader.u53();
322
+ if (typeId !== GoAway.id) {
323
+ console.warn(`unexpected message on setup stream: 0x${typeId.toString(16)}`);
324
+ return;
325
+ }
252
326
  const msg = await GoAway.decode(controlStream.reader, version);
253
- console.warn(`received GOAWAY with redirect URI: ${msg.newSessionUri}`);
254
- }
255
- else {
256
- console.warn(`unexpected message on setup stream: 0x${typeId.toString(16)}`);
327
+ if (this.#goaway.peek() !== undefined)
328
+ throw new ProtocolViolation("duplicate GOAWAY");
329
+ // A client may leave, but only the server may name where to go.
330
+ if (!this.#client && msg.newSessionUri !== "") {
331
+ throw new ProtocolViolation("client GOAWAY must not name a redirect");
332
+ }
333
+ this.#goaway.set(msg.drain());
257
334
  }
258
335
  }
259
336
  catch (err) {
@@ -262,7 +339,7 @@ export class Connection {
262
339
  }
263
340
  }
264
341
  finally {
265
- this.close();
342
+ this.#close();
266
343
  }
267
344
  }
268
345
  /** Resolves when the session closes, decoding the peer's close code; see {@link Established.closed}. */
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/ietf/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,EAA0B,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAkB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG3F,OAAO,EAAe,OAAO,EAAe,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AACjF,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAoB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtE;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACtB,6BAA6B;IACpB,GAAG,CAAM;IAElB,mCAAmC;IAC1B,OAAO,CAAS;IAEzB,6CAA6C;IAC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pD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,aAAqB,EAAE,OAAoB;QAC3D,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC/C,IAAI,IAAI;gBAAE,OAAO;YAEjB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;YAChD,IAAI,MAAM,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;gBAC1B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC/D,OAAO,CAAC,IAAI,CAAC,sCAAsC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;YACzE,CAAC;iBAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,yCAAyC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAC9E,CAAC;QACF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;IACF,CAAC;IAED,wGAAwG;IACxG,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAY,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;CACD","sourcesContent":["import { type Getter, Signal } from \"@moq/signals\";\nimport type * as announce from \"../announced.ts\";\nimport type { Established } from \"../connection/established.ts\";\nimport { type Probe, type Stats, transportStats } from \"../connection/stats.ts\";\nimport { type Transport, transportOf } from \"../connection/transport.ts\";\nimport { error, fromClose, ProtocolViolation, StreamCode, StreamError } from \"../error.ts\";\nimport type { Consumer as OriginConsumer } from \"../origin.ts\";\nimport type * as Path from \"../path.ts\";\nimport { type Reader, Readers, type Stream } from \"../stream.ts\";\nimport { registerWire } from \"../wire.ts\";\nimport { ControlStreamAdapter, NativeSession, type Session } from \"./adapter.ts\";\nimport * as Cluster from \"./cluster.ts\";\nimport { GoAway } from \"./goaway.ts\";\nimport { Group } from \"./object.ts\";\nimport { Publish } from \"./publish.ts\";\nimport { PublishNamespace } from \"./publish_namespace.ts\";\nimport { Publisher } from \"./publisher.ts\";\nimport { Subscribe, SubscribeUpdate } from \"./subscribe.ts\";\nimport { SubscribeNamespace, SubscribeNamespaceLegacy } from \"./subscribe_namespace.ts\";\nimport { Subscriber } from \"./subscriber.ts\";\nimport { TrackStatusRequest } from \"./track.ts\";\nimport { type IetfVersion, Version, versionName } from \"./version.ts\";\n\n/**\n * Represents a connection to a MoQ server using moq-transport protocol.\n *\n * @public\n */\nexport class Connection implements Established {\n\t// The URL of the connection.\n\treadonly url: URL;\n\n\t// The negotiated protocol version.\n\treadonly version: string;\n\n\t// The wire transport this session runs over.\n\treadonly transport: Transport;\n\n\t/** Whether the relay supports broadcast discovery; see {@link Established.discovery}. */\n\treadonly discovery: boolean;\n\n\t/** moq-transport has no PROBE, so this stays empty; see {@link Established.probe}. */\n\treadonly probe: Getter<Probe> = new Signal<Probe>({});\n\n\t// The established WebTransport session.\n\t#quic: WebTransport;\n\n\t// Session abstraction: adapter for v14-v16, native for v17.\n\t#session: Session;\n\n\t// Module for contributing tracks.\n\t#publisher: Publisher;\n\n\t// Module for distributing tracks.\n\t#subscriber: Subscriber;\n\n\t// What the peer declared about being solicited; see {@link Ietf.solicitFromSetup}.\n\t#solicit: boolean | undefined;\n\n\t// The Hop IDs this session declared; see {@link Cluster}.\n\t#cluster?: Cluster.Hops;\n\n\t// Just to avoid logging when `close()` is called.\n\t#closed = false;\n\n\t/**\n\t * Creates a new Connection instance.\n\t * @param url - The URL of the connection\n\t * @param quic - The WebTransport session\n\t * @param control - The control/setup stream\n\t * @param maxRequestId - The initial max request ID\n\t * @param version - The negotiated protocol version\n\t * @param solicit - What the peer's SETUP declared (undefined when it declared nothing)\n\t * @param cluster - The Hop IDs the SETUP exchange settled, on the versions that negotiate them\n\t *\n\t * @internal\n\t */\n\tconstructor({\n\t\turl,\n\t\tquic,\n\t\tcontrol,\n\t\tmaxRequestId,\n\t\tversion,\n\t\tclient,\n\t\tdiscovery = true,\n\t\tpublish,\n\t\tsolicit,\n\t\tcluster,\n\t}: {\n\t\turl: URL;\n\t\tquic: WebTransport;\n\t\tcontrol: Stream;\n\t\tmaxRequestId: bigint;\n\t\tversion: IetfVersion;\n\t\t/** Whether this peer initiated the session, selecting the even request-ID space. */\n\t\tclient: boolean;\n\t\tdiscovery?: boolean;\n\t\t/** The origin whose broadcasts are served to the peer. Omit to publish nothing. */\n\t\tpublish?: OriginConsumer;\n\t\t/**\n\t\t * What the peer declared about being solicited. `undefined` means it declared\n\t\t * nothing, which is the one case where announcing at us unasked is not a bug.\n\t\t */\n\t\tsolicit?: boolean;\n\t\t/**\n\t\t * The Hop IDs this session declared (MoQ Cluster). `undefined` on a version that\n\t\t * cannot negotiate the extension, as is a `peer` the peer never declared.\n\t\t */\n\t\tcluster?: Cluster.Hops;\n\t}) {\n\t\tthis.url = url;\n\t\tthis.discovery = discovery;\n\t\tthis.version = versionName(version);\n\t\tthis.transport = transportOf(quic);\n\t\tthis.#quic = quic;\n\n\t\t// Two-path dispatch: v14-v16 uses adapter, v17+ uses native bidi streams\n\t\tif (version >= Version.DRAFT_17) {\n\t\t\tthis.#session = new NativeSession(quic, version, client);\n\t\t\t// v17+: control/setup stream only carries GoAway\n\t\t\tvoid this.#runGoAway(control, version);\n\t\t} else {\n\t\t\tconst adapter = new ControlStreamAdapter(quic, control, version, maxRequestId, client);\n\t\t\tthis.#session = adapter;\n\t\t\t// Start the adapter read loop (routes control messages to virtual streams)\n\t\t\tvoid adapter.run().catch((err: unknown) => {\n\t\t\t\tif (!this.#closed) console.error(\"adapter error\", err);\n\t\t\t\tthis.close();\n\t\t\t});\n\t\t}\n\n\t\tthis.#publisher = new Publisher({\n\t\t\tquic: this.#quic,\n\t\t\tsession: this.#session,\n\t\t\tpublish,\n\t\t\trequiresSolicitation: solicit ?? false,\n\t\t\tcluster,\n\t\t});\n\t\tthis.#solicit = solicit;\n\t\tthis.#cluster = cluster;\n\t\tthis.#subscriber = new Subscriber({ session: this.#session, cluster });\n\t\tregisterWire(this, { consume: (path) => this.#subscriber.consume(path) });\n\n\t\tvoid this.#run();\n\t}\n\n\t/** Snapshot the transport's counters; see {@link Established.stats}. */\n\tasync stats(): Promise<Stats> {\n\t\treturn transportStats(this.#quic);\n\t}\n\n\t/**\n\t * Closes the connection.\n\t */\n\tclose() {\n\t\tif (this.#closed) return;\n\n\t\tthis.#closed = true;\n\n\t\tthis.#session.close();\n\n\t\ttry {\n\t\t\tthis.#quic.close();\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t}\n\n\tasync #run(): Promise<void> {\n\t\ttry {\n\t\t\tawait Promise.all([this.#runBidis(), this.#runUnis(), this.#publisher.runPublishNamespaces()]);\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"fatal error running connection\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/** Gets an announced reader for `scope`; see {@link Established.announced}. */\n\tannounced(scope?: Path.Pattern): announce.Consumer {\n\t\treturn this.#subscriber.announced(scope);\n\t}\n\n\t/**\n\t * Accepts bidi streams (virtual for v14-v16, real for v17) and dispatches.\n\t */\n\tasync #runBidis() {\n\t\tfor (;;) {\n\t\t\tconst stream = await this.#session.acceptBi();\n\t\t\tif (!stream) break;\n\n\t\t\tvoid this.#runBidi(stream).catch((err: unknown) => {\n\t\t\t\tconsole.error(\"error processing bidi stream\", err);\n\t\t\t\tstream.abort(new Error(\"bidi stream error\"));\n\n\t\t\t\t// The peer broke the protocol, so losing the stream is not enough: nothing\n\t\t\t\t// stops it repeating the violation on the next one.\n\t\t\t\tif (err instanceof ProtocolViolation) this.close();\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Unified bidi stream dispatch. Reads typeId and routes to handler.\n\t * Matches the lite module's runBidi pattern.\n\t */\n\tasync #runBidi(stream: Stream) {\n\t\tconst typeId = await stream.reader.u53();\n\n\t\tswitch (typeId) {\n\t\t\t// Draft-18 SUBSCRIBE_NAMESPACE (0x50) and the legacy 0x11 message decode\n\t\t\t// to the same request_id + namespace; the legacy options field is ignored.\n\t\t\tcase SubscribeNamespace.id: {\n\t\t\t\tconst msg = await SubscribeNamespace.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeNamespaceLegacy.id: {\n\t\t\t\tconst legacy = await SubscribeNamespaceLegacy.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = new SubscribeNamespace({ requestId: legacy.requestId, namespace: legacy.namespace });\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeUpdate.id: {\n\t\t\t\t// REQUEST_UPDATE (0x02) is a follow-up, not a valid initial message\n\t\t\t\tstream.abort(new Error(\"unexpected REQUEST_UPDATE as initial message\"));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Publisher handles incoming requests\n\t\t\tcase Subscribe.id: {\n\t\t\t\tconst msg = await Subscribe.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribe(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TrackStatusRequest.id: {\n\t\t\t\tconst msg = await TrackStatusRequest.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runTrackStatusRequest(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Subscriber handles incoming notifications\n\t\t\tcase PublishNamespace.id: {\n\t\t\t\tconst msg = await PublishNamespace.decode(\n\t\t\t\t\tstream.reader,\n\t\t\t\t\tthis.#session.version,\n\t\t\t\t\tCluster.negotiated(this.#cluster),\n\t\t\t\t);\n\n\t\t\t\t// We always declare that advertisements to us must be solicited (MoQ\n\t\t\t\t// Solicit), and writing the option at all proves the peer implements the\n\t\t\t\t// extension, whichever value it chose. It also cannot have advertised\n\t\t\t\t// before reading our SETUP, since our SETUP is what says whether\n\t\t\t\t// advertising unasked is allowed. So this is a bug in the peer, and a\n\t\t\t\t// silent one on both sides if we tolerate it.\n\t\t\t\t//\n\t\t\t\t// Draft-14/15 are exempt: they have no inline NAMESPACE, so a\n\t\t\t\t// PUBLISH_NAMESPACE request is also how a peer answers our\n\t\t\t\t// SUBSCRIBE_NAMESPACE there, and the message alone does not say which.\n\t\t\t\tconst legacy = this.#session.version === Version.DRAFT_14 || this.#session.version === Version.DRAFT_15;\n\t\t\t\tif (this.#solicit !== undefined && !legacy) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`unsolicited publish_namespace from a peer that implements MoQ Solicit: broadcast=${msg.trackNamespace}`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.close();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tawait this.#subscriber.runPublishNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Publish.id: {\n\t\t\t\tconst msg = await Publish.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#subscriber.runPublish(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn(`unexpected bidi stream type: 0x${typeId.toString(16)}`);\n\t\t\t\tstream.abort(new Error(\"unexpected stream type\"));\n\t\t}\n\t}\n\n\t/**\n\t * Handles unidirectional streams for media delivery (groups).\n\t */\n\tasync #runUnis() {\n\t\tconst readers = new Readers(this.#quic, this.#session.version);\n\n\t\tfor (;;) {\n\t\t\tconst stream = await readers.next();\n\t\t\tif (!stream) break;\n\n\t\t\tthis.#runUni(stream)\n\t\t\t\t.then(() => {\n\t\t\t\t\tstream.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t\t\t\t})\n\t\t\t\t.catch((err: unknown) => {\n\t\t\t\t\tconsole.error(\"error processing object stream\", err);\n\t\t\t\t\tstream.stop(err);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tasync #runUni(stream: Reader) {\n\t\tconst header = await Group.decode(stream, this.#session.version);\n\t\tawait this.#subscriber.handleGroup(header, stream);\n\t}\n\n\t/**\n\t * v17+ only: reads GoAway from the setup/control stream.\n\t */\n\tasync #runGoAway(controlStream: Stream, version: IetfVersion) {\n\t\ttry {\n\t\t\tconst done = await controlStream.reader.done();\n\t\t\tif (done) return;\n\n\t\t\tconst typeId = await controlStream.reader.u53();\n\t\t\tif (typeId === GoAway.id) {\n\t\t\t\tconst msg = await GoAway.decode(controlStream.reader, version);\n\t\t\t\tconsole.warn(`received GOAWAY with redirect URI: ${msg.newSessionUri}`);\n\t\t\t} else {\n\t\t\t\tconsole.warn(`unexpected message on setup stream: 0x${typeId.toString(16)}`);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"error reading setup stream\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/** Resolves when the session closes, decoding the peer's close code; see {@link Established.closed}. */\n\tget closed(): Promise<Error | null> {\n\t\treturn this.#quic.closed.then(fromClose, (err: unknown) => error(err));\n\t}\n}\n"]}
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/ietf/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAIzD,OAAO,EAA0B,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAkB,WAAW,EAAE,MAAM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B,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;gBAChD,IAAI,MAAM,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;oBAC1B,OAAO,CAAC,IAAI,CAAC,yCAAyC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;oBAC7E,OAAO;gBACR,CAAC;gBAED,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC/D,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,SAAS;oBAAE,MAAM,IAAI,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;gBACvF,gEAAgE;gBAChE,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,GAAG,CAAC,aAAa,KAAK,EAAE,EAAE,CAAC;oBAC/C,MAAM,IAAI,iBAAiB,CAAC,wCAAwC,CAAC,CAAC;gBACvE,CAAC;gBACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;IACF,CAAC;IAED,wGAAwG;IACxG,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAY,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;CACD","sourcesContent":["import { type Getter, Once, Signal } from \"@moq/signals\";\nimport type * as announce from \"../announced.ts\";\nimport type { Established } from \"../connection/established.ts\";\nimport type { Drain } from \"../connection/goaway.ts\";\nimport { type Probe, type Stats, transportStats } from \"../connection/stats.ts\";\nimport { type Transport, transportOf } from \"../connection/transport.ts\";\nimport { error, fromClose, ProtocolViolation, SessionCode, StreamCode, StreamError } from \"../error.ts\";\nimport type { Consumer as OriginConsumer } from \"../origin.ts\";\nimport type * as Path from \"../path.ts\";\nimport { type Reader, Readers, type Stream } from \"../stream.ts\";\nimport { registerWire } from \"../wire.ts\";\nimport { ControlStreamAdapter, NativeSession, type Session } from \"./adapter.ts\";\nimport * as Cluster from \"./cluster.ts\";\nimport { Fetch, FetchHeader } from \"./fetch.ts\";\nimport { GoAway } from \"./goaway.ts\";\nimport { Group } from \"./object.ts\";\nimport { Publish } from \"./publish.ts\";\nimport { PublishNamespace } from \"./publish_namespace.ts\";\nimport { Publisher } from \"./publisher.ts\";\nimport { Subscribe, SubscribeUpdate } from \"./subscribe.ts\";\nimport { SUBSCRIBE_TRACKS_ID, SubscribeNamespace, SubscribeNamespaceLegacy } from \"./subscribe_namespace.ts\";\nimport { Subscriber } from \"./subscriber.ts\";\nimport { TrackStatusRequest } from \"./track.ts\";\nimport { type IetfVersion, Version, versionName } from \"./version.ts\";\n\n// The PADDING stream type (draft-18+): bytes a peer sends to probe for bandwidth.\nconst PADDING = 0x132b3e28n;\n\n/**\n * Represents a connection to a MoQ server using moq-transport protocol.\n *\n * @public\n */\nexport class Connection implements Established {\n\t// The URL of the connection.\n\treadonly url: URL;\n\n\t// The negotiated protocol version.\n\treadonly version: string;\n\n\t// The wire transport this session runs over.\n\treadonly transport: Transport;\n\n\t/** Whether the relay supports broadcast discovery; see {@link Established.discovery}. */\n\treadonly discovery: boolean;\n\n\t/** moq-transport has no PROBE, so this stays empty; see {@link Established.probe}. */\n\treadonly probe: Getter<Probe> = new Signal<Probe>({});\n\n\t// The established WebTransport session.\n\t#quic: WebTransport;\n\n\t// Whether this side opened the session. Only a server may name a redirect.\n\t#client: boolean;\n\n\t// Session abstraction: adapter for v14-v16, native for v17.\n\t#session: Session;\n\n\t// Module for contributing tracks.\n\t#publisher: Publisher;\n\n\t// Module for distributing tracks.\n\t#subscriber: Subscriber;\n\n\t// What the peer declared about being solicited; see {@link Ietf.solicitFromSetup}.\n\t#solicit: boolean | undefined;\n\n\t// The Hop IDs this session declared; see {@link Cluster}.\n\t#cluster?: Cluster.Hops;\n\n\t// The peer's GOAWAY: read here on v17+, by the control stream adapter before that.\n\t#goaway: Once<Drain>;\n\n\t// Just to avoid logging when `close()` is called.\n\t#closed = false;\n\n\t/**\n\t * Creates a new Connection instance.\n\t * @param url - The URL of the connection\n\t * @param quic - The WebTransport session\n\t * @param control - The control/setup stream\n\t * @param maxRequestId - The initial max request ID\n\t * @param version - The negotiated protocol version\n\t * @param solicit - What the peer's SETUP declared (undefined when it declared nothing)\n\t * @param cluster - The Hop IDs the SETUP exchange settled, on the versions that negotiate them\n\t * @param early - Uni streams that arrived before the peer's SETUP\n\t *\n\t * @internal\n\t */\n\tconstructor({\n\t\turl,\n\t\tquic,\n\t\tcontrol,\n\t\tmaxRequestId,\n\t\tversion,\n\t\tclient,\n\t\tdiscovery = true,\n\t\tpublish,\n\t\tsolicit,\n\t\thidden = false,\n\t\tcluster,\n\t\tearly = [],\n\t}: {\n\t\turl: URL;\n\t\tquic: WebTransport;\n\t\tcontrol: Stream;\n\t\tmaxRequestId: bigint;\n\t\tversion: IetfVersion;\n\t\t/** Whether this peer initiated the session, selecting the even request-ID space. */\n\t\tclient: boolean;\n\t\tdiscovery?: boolean;\n\t\t/** The origin whose broadcasts are served to the peer. Omit to publish nothing. */\n\t\tpublish?: OriginConsumer;\n\t\t/**\n\t\t * What the peer declared about being solicited. `undefined` means it declared\n\t\t * nothing, which is the one case where announcing at us unasked is not a bug.\n\t\t */\n\t\tsolicit?: boolean;\n\t\t/** Whether the peer understands the HIDDEN parameter (MoQ Hidden). */\n\t\thidden?: boolean;\n\t\t/**\n\t\t * The Hop IDs this session declared (MoQ Cluster). `undefined` on a version that\n\t\t * cannot negotiate the extension, as is a `peer` the peer never declared.\n\t\t */\n\t\tcluster?: Cluster.Hops;\n\t\t/** Uni streams that arrived before the peer's SETUP, type unread (v17+). */\n\t\tearly?: Reader[];\n\t}) {\n\t\tthis.url = url;\n\t\tthis.discovery = discovery;\n\t\tthis.version = versionName(version);\n\t\tthis.transport = transportOf(quic);\n\t\tthis.#quic = quic;\n\t\tthis.#client = client;\n\n\t\t// Two-path dispatch: v14-v16 uses adapter, v17+ uses native bidi streams\n\t\tif (version >= Version.DRAFT_17) {\n\t\t\tthis.#session = new NativeSession(quic, version, client);\n\t\t\tthis.#goaway = new Once();\n\t\t\t// v17+: control/setup stream only carries GoAway\n\t\t\tvoid this.#runGoAway(control, version);\n\t\t} else {\n\t\t\tconst adapter = new ControlStreamAdapter(quic, control, version, maxRequestId, client);\n\t\t\tthis.#session = adapter;\n\t\t\tthis.#goaway = adapter.goaway;\n\t\t\t// Start the adapter read loop (routes control messages to virtual streams)\n\t\t\tvoid adapter.run().catch((err: unknown) => {\n\t\t\t\tif (!this.#closed) console.error(\"adapter error\", err);\n\t\t\t\tthis.#close();\n\t\t\t});\n\t\t}\n\n\t\tthis.#publisher = new Publisher({\n\t\t\tquic: this.#quic,\n\t\t\tsession: this.#session,\n\t\t\tpublish,\n\t\t\trequiresSolicitation: solicit ?? false,\n\t\t\thidden,\n\t\t\tcluster,\n\t\t});\n\t\tthis.#solicit = solicit;\n\t\tthis.#cluster = cluster;\n\t\tthis.#subscriber = new Subscriber({ session: this.#session, quic, cluster, hidden });\n\t\tregisterWire(this, { consume: (path) => this.#subscriber.consume(path), goaway: this.#goaway });\n\n\t\tvoid this.#run(early);\n\t}\n\n\t/** Snapshot the transport's counters; see {@link Established.stats}. */\n\tasync stats(): Promise<Stats> {\n\t\treturn transportStats(this.#quic);\n\t}\n\n\t/**\n\t * Closes the connection.\n\t */\n\tclose() {\n\t\tif (this.#closed) return;\n\t\tthis.#subscriber.close();\n\t\tthis.#close();\n\t}\n\n\t// Close with the session code the peer should see, a clean close by default.\n\t#close(info?: WebTransportCloseInfo) {\n\t\tif (this.#closed) return;\n\n\t\tthis.#closed = true;\n\n\t\t// Before the session, whose own close would send a clean code first.\n\t\ttry {\n\t\t\tthis.#quic.close(info);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\tthis.#session.close();\n\t}\n\n\t// The peer broke the protocol, so losing the stream is not enough: nothing stops it\n\t// repeating the violation on the next one.\n\t#violated(err: ProtocolViolation) {\n\t\tthis.#close({ closeCode: SessionCode.ProtocolViolation, reason: err.message });\n\t}\n\n\tasync #run(early: Reader[]): Promise<void> {\n\t\ttry {\n\t\t\tawait Promise.all([this.#runBidis(), this.#runUnis(early), this.#publisher.runPublishNamespaces()]);\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"fatal error running connection\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#close();\n\t\t}\n\t}\n\n\t/** Gets an announced reader for `scope`; see {@link Established.announced}. */\n\tannounced(scope?: Path.Pattern, options?: announce.Options): announce.Consumer {\n\t\treturn this.#subscriber.announced(scope, options);\n\t}\n\n\t/**\n\t * Accepts bidi streams (virtual for v14-v16, real for v17) and dispatches.\n\t */\n\tasync #runBidis() {\n\t\tfor (;;) {\n\t\t\tconst stream = await this.#session.acceptBi();\n\t\t\tif (!stream) break;\n\n\t\t\tvoid this.#runBidi(stream).catch((err: unknown) => {\n\t\t\t\tconsole.error(\"error processing bidi stream\", err);\n\t\t\t\tstream.abort(new Error(\"bidi stream error\"));\n\t\t\t\tif (err instanceof ProtocolViolation) this.#violated(err);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Unified bidi stream dispatch. Reads typeId and routes to handler.\n\t * Matches the lite module's runBidi pattern.\n\t */\n\tasync #runBidi(stream: Stream) {\n\t\tconst typeId = await stream.reader.u53();\n\n\t\tswitch (typeId) {\n\t\t\t// Draft-18 SUBSCRIBE_NAMESPACE (0x50) and the legacy 0x11 message decode\n\t\t\t// to the same request_id + namespace; the legacy options field is ignored.\n\t\t\tcase SubscribeNamespace.id: {\n\t\t\t\tconst msg = await SubscribeNamespace.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeNamespaceLegacy.id: {\n\t\t\t\tconst legacy = await SubscribeNamespaceLegacy.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = new SubscribeNamespace({\n\t\t\t\t\trequestId: legacy.requestId,\n\t\t\t\t\tnamespace: legacy.namespace,\n\t\t\t\t\thidden: legacy.hidden,\n\t\t\t\t});\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeUpdate.id: {\n\t\t\t\t// REQUEST_UPDATE (0x02) is a follow-up, not a valid initial message\n\t\t\t\tstream.abort(new Error(\"unexpected REQUEST_UPDATE as initial message\"));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Publisher handles incoming requests\n\t\t\tcase Subscribe.id: {\n\t\t\t\tconst msg = await Subscribe.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribe(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SUBSCRIBE_TRACKS_ID: {\n\t\t\t\t// 0x51 is only a message from draft-18 on.\n\t\t\t\tif (this.#session.version < Version.DRAFT_18) {\n\t\t\t\t\tthrow new ProtocolViolation(\"SUBSCRIBE_TRACKS before draft-18\");\n\t\t\t\t}\n\t\t\t\tawait this.#publisher.runSubscribeTracks(stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TrackStatusRequest.id: {\n\t\t\t\tconst msg = await TrackStatusRequest.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runTrackStatusRequest(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Fetch.id: {\n\t\t\t\tconst msg = await Fetch.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runFetch(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Subscriber handles incoming notifications\n\t\t\tcase PublishNamespace.id: {\n\t\t\t\tconst msg = await PublishNamespace.decode(\n\t\t\t\t\tstream.reader,\n\t\t\t\t\tthis.#session.version,\n\t\t\t\t\tCluster.negotiated(this.#cluster),\n\t\t\t\t);\n\n\t\t\t\t// We always declare that advertisements to us must be solicited (MoQ\n\t\t\t\t// Solicit), and writing the option at all proves the peer implements the\n\t\t\t\t// extension, whichever value it chose. It also cannot have advertised\n\t\t\t\t// before reading our SETUP, since our SETUP is what says whether\n\t\t\t\t// advertising unasked is allowed. So this is a bug in the peer, and a\n\t\t\t\t// silent one on both sides if we tolerate it.\n\t\t\t\t//\n\t\t\t\t// Draft-14/15 are exempt: they have no inline NAMESPACE, so a\n\t\t\t\t// PUBLISH_NAMESPACE request is also how a peer answers our\n\t\t\t\t// SUBSCRIBE_NAMESPACE there, and the message alone does not say which.\n\t\t\t\tconst legacy = this.#session.version === Version.DRAFT_14 || this.#session.version === Version.DRAFT_15;\n\t\t\t\tif (this.#solicit !== undefined && !legacy) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`unsolicited publish_namespace from a peer that implements MoQ Solicit: broadcast=${msg.trackNamespace}`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.#close();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tawait this.#subscriber.runPublishNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Publish.id: {\n\t\t\t\tconst msg = await Publish.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#subscriber.runPublish(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn(`unexpected bidi stream type: 0x${typeId.toString(16)}`);\n\t\t\t\tstream.abort(new Error(\"unexpected stream type\"));\n\t\t}\n\t}\n\n\t/**\n\t * Handles unidirectional streams for media delivery (groups).\n\t */\n\tasync #runUnis(early: Reader[]) {\n\t\t// Streams that beat the SETUP go first, in arrival order.\n\t\tfor (const stream of early) this.#spawnUni(stream);\n\n\t\tconst readers = new Readers(this.#quic, this.#session.version);\n\t\tfor (;;) {\n\t\t\tconst stream = await readers.next();\n\t\t\tif (!stream) break;\n\t\t\tthis.#spawnUni(stream);\n\t\t}\n\t}\n\n\t#spawnUni(stream: Reader) {\n\t\tthis.#runUni(stream)\n\t\t\t.then(() => {\n\t\t\t\tstream.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t\t\t})\n\t\t\t.catch((err: unknown) => {\n\t\t\t\tconsole.error(\"error processing object stream\", err);\n\t\t\t\tstream.stop(err);\n\n\t\t\t\t// An unknown or invalid stream type MUST close the session, not just the stream.\n\t\t\t\tif (err instanceof ProtocolViolation) this.#violated(err);\n\t\t\t});\n\t}\n\n\tasync #runUni(stream: Reader) {\n\t\tconst version = this.#session.version;\n\t\t// Full width, so an unknown type past 2^53 is still classified rather than thrown.\n\t\tconst type = await stream.u62();\n\n\t\t// SUBGROUP_HEADER types match 0b0XX1XXXX; Group.decode validates the bits per draft.\n\t\tif (type <= 0xffn && (type & 0x90n) === 0x10n) {\n\t\t\tconst header = await Group.decode(stream, version, Number(type));\n\t\t\tawait this.#subscriber.handleGroup(header, stream);\n\t\t\treturn;\n\t\t}\n\n\t\t// The receiver MUST discard padding. We read it to the end rather than cancel,\n\t\t// so a peer probing for bandwidth gets the throughput it is measuring.\n\t\tif (type === PADDING && version >= Version.DRAFT_18) {\n\t\t\tawait stream.discard();\n\t\t\treturn;\n\t\t}\n\n\t\t// We never FETCH, so a fetch response answers nothing of ours.\n\t\tif (type === BigInt(FetchHeader.type)) throw new Error(\"unexpected fetch stream\");\n\n\t\t// Anything else is unknown, and a second SETUP is a violation too.\n\t\tthrow new ProtocolViolation(`unknown uni stream type: 0x${type.toString(16)}`);\n\t}\n\n\t/**\n\t * v17+ only: reads GoAway from the setup/control stream.\n\t *\n\t * The session keeps serving after a GOAWAY so its groups in flight can finish while the\n\t * caller migrates; only the stream ending, or a second GOAWAY, closes it here.\n\t */\n\tasync #runGoAway(controlStream: Stream, version: IetfVersion) {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst done = await controlStream.reader.done();\n\t\t\t\tif (done) return;\n\n\t\t\t\tconst typeId = await controlStream.reader.u53();\n\t\t\t\tif (typeId !== GoAway.id) {\n\t\t\t\t\tconsole.warn(`unexpected message on setup stream: 0x${typeId.toString(16)}`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst msg = await GoAway.decode(controlStream.reader, version);\n\t\t\t\tif (this.#goaway.peek() !== undefined) throw new ProtocolViolation(\"duplicate GOAWAY\");\n\t\t\t\t// A client may leave, but only the server may name where to go.\n\t\t\t\tif (!this.#client && msg.newSessionUri !== \"\") {\n\t\t\t\t\tthrow new ProtocolViolation(\"client GOAWAY must not name a redirect\");\n\t\t\t\t}\n\t\t\t\tthis.#goaway.set(msg.drain());\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"error reading setup stream\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#close();\n\t\t}\n\t}\n\n\t/** Resolves when the session closes, decoding the peer's close code; see {@link Established.closed}. */\n\tget closed(): Promise<Error | null> {\n\t\treturn this.#quic.closed.then(fromClose, (err: unknown) => error(err));\n\t}\n}\n"]}
package/ietf/error.js CHANGED
@@ -62,6 +62,23 @@ const TIMEOUT = 0x2;
62
62
  const NOT_SUPPORTED = 0x3;
63
63
  /** A draining session. Draft-17 and later. */
64
64
  const GOING_AWAY = 0x6;
65
+ /** FETCH-only errors. INVALID_JOINING_REQUEST_ID was removed in draft-20. */
66
+ const INVALID_RANGE_14 = 0x5;
67
+ const INVALID_RANGE = 0x11;
68
+ const INVALID_JOINING_REQUEST_ID_14 = 0x7;
69
+ const INVALID_JOINING_REQUEST_ID = 0x32;
70
+ function invalidRange(kind, version) {
71
+ if (kind !== "fetch")
72
+ return undefined;
73
+ return version === Version.DRAFT_14 ? INVALID_RANGE_14 : INVALID_RANGE;
74
+ }
75
+ function invalidJoiningRequestId(kind, version) {
76
+ if (kind !== "fetch")
77
+ return undefined;
78
+ if (version === Version.DRAFT_14)
79
+ return INVALID_JOINING_REQUEST_ID_14;
80
+ return version <= Version.DRAFT_19 ? INVALID_JOINING_REQUEST_ID : undefined;
81
+ }
65
82
  /** Draft-14 calls it TRACK_DOES_NOT_EXIST; draft-15 renamed it and moved it off 0x4. */
66
83
  const DOES_NOT_EXIST_14 = 0x4;
67
84
  const DOES_NOT_EXIST = 0x10;
@@ -75,7 +92,7 @@ const MALFORMED_TRACK = 0x12;
75
92
  function doesNotExist(kind, version) {
76
93
  if (version !== Version.DRAFT_14)
77
94
  return DOES_NOT_EXIST;
78
- return kind === "subscribe" || kind === "fetch" ? DOES_NOT_EXIST_14 : undefined;
95
+ return kind === "subscribe" || kind === "fetch" || kind === "track_status" ? DOES_NOT_EXIST_14 : undefined;
79
96
  }
80
97
  /** The value for "we do not want this", or undefined where none is assigned. */
81
98
  function uninterested(kind, version) {
@@ -114,13 +131,17 @@ export function toRequestCode(condition, kind, version) {
114
131
  return TIMEOUT;
115
132
  case "not_supported":
116
133
  return NOT_SUPPORTED;
134
+ case "invalid_range":
135
+ return invalidRange(kind, version) ?? INTERNAL_ERROR;
136
+ case "invalid_joining_request_id":
137
+ return invalidJoiningRequestId(kind, version) ?? INTERNAL_ERROR;
117
138
  case "does_not_exist":
118
139
  return doesNotExist(kind, version) ?? INTERNAL_ERROR;
119
140
  // A subscriber that asked for content cannot act on "we do not want it": what it needs
120
141
  // to know is that we do not have it, which is the same refusal from its side. Only the
121
142
  // requests that offer content say UNINTERESTED.
122
143
  case "uninterested":
123
- return kind === "subscribe" || kind === "fetch"
144
+ return kind === "subscribe" || kind === "fetch" || kind === "track_status"
124
145
  ? (doesNotExist(kind, version) ?? INTERNAL_ERROR)
125
146
  : (uninterested(kind, version) ?? INTERNAL_ERROR);
126
147
  case "malformed_track":
@@ -148,6 +169,10 @@ export function fromRequestCode(code, kind, version) {
148
169
  }
149
170
  if (code === doesNotExist(kind, version))
150
171
  return "does_not_exist";
172
+ if (code === invalidRange(kind, version))
173
+ return "invalid_range";
174
+ if (code === invalidJoiningRequestId(kind, version))
175
+ return "invalid_joining_request_id";
151
176
  if (code === uninterested(kind, version))
152
177
  return "uninterested";
153
178
  if (code === malformedTrack(kind, version))
package/ietf/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/ietf/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAoB,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAoB;IAClE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACP,OAAO,IAAI,CAAC;QACb,sFAAsF;QACtF,iEAAiE;QACjE,KAAK,GAAG;YACP,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC,sCAAsC;QACtC,KAAK,GAAG;YACP,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC,uCAAuC;QACvC,KAAK,IAAI;YACR,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AACF,CAAC;AAuCD,oFAAoF;AACpF,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,8CAA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AAK,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC;QAAE,OAAO,iBAAiB,CAAC;IACrE,IAAI,IAAI,KAAK,SAAS,CAAC,OAAO,CAAC;QAAE,OAAO,YAAY,CAAC;IACrD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,YAAoB,EAAE,IAAiB,EAAE,OAAoB;IACxG,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC;IACzE,OAAO,GAAG,SAAS,UAAU,IAAI,KAAK,YAAY,EAAE,CAAC;AACtD,CAAC","sourcesContent":["/**\n * The moq-transport error code registries, per negotiated draft.\n *\n * A code only means something once you know which draft carried it: the registries grew,\n * moved values, and in draft-15 collapsed five per-message tables into one. Mirrors the\n * Rust `moq_net::ietf::error` module, and the two have to agree value for value.\n *\n * @module\n */\n\nimport { type IetfVersion, Version } from \"./version.ts\";\n\n/**\n * Whether `code` means the same thing in the negotiated draft's stream reset registry as it\n * does in moq-lite's.\n *\n * The two registries agree on most of what they both assign, but this one grew across the\n * drafts we negotiate and moved a value on the way:\n *\n * | Code | draft-14/15 | draft-16/17 | draft-18+ |\n * |------|-------------|-------------|-----------|\n * | 0x0 | INTERNAL_ERROR | INTERNAL_ERROR | INTERNAL_ERROR |\n * | 0x1 | CANCELLED | CANCELLED | CANCELLED |\n * | 0x2 | DELIVERY_TIMEOUT | DELIVERY_TIMEOUT | DELIVERY_TIMEOUT |\n * | 0x3 | SESSION_CLOSED | SESSION_CLOSED | SESSION_CLOSED |\n * | 0x4 | - | UNKNOWN_OBJECT_STATUS | GOING_AWAY |\n * | 0x5 | - | TOO_FAR_BEHIND (17) | TOO_FAR_BEHIND |\n * | 0x12 | - | MALFORMED_TRACK | MALFORMED_TRACK |\n *\n * So GOING_AWAY sent to a draft-17 peer reads as UNKNOWN_OBJECT_STATUS, and that peer's\n * UNKNOWN_OBJECT_STATUS read as GOING_AWAY would retire a session that is not going\n * anywhere. Anything this says `false` about is sent as, and read as, INTERNAL_ERROR: the\n * codes moq-lite assigns in its own 48-63 range, and the ones the draft assigns that\n * moq-lite has no name for (UNKNOWN_OBJECT_STATUS, EXPIRED_AUTH_TOKEN, EXCESSIVE_LOAD).\n *\n * @internal\n */\nexport function sharedStreamCode(code: number, version: IetfVersion): boolean {\n\tswitch (code) {\n\t\tcase 0x0:\n\t\tcase 0x1:\n\t\tcase 0x2:\n\t\tcase 0x3:\n\t\t\treturn true;\n\t\t// Draft-16 and 17 give 0x4 to UNKNOWN_OBJECT_STATUS, which draft-18 moved to 0x6 when\n\t\t// it took 0x4 for GOING_AWAY. Draft-14 and 15 assign it nothing.\n\t\tcase 0x4:\n\t\t\treturn version >= Version.DRAFT_18;\n\t\t// TOO_FAR_BEHIND arrived in draft-17.\n\t\tcase 0x5:\n\t\t\treturn version >= Version.DRAFT_17;\n\t\t// MALFORMED_TRACK arrived in draft-16.\n\t\tcase 0x12:\n\t\t\treturn version >= Version.DRAFT_16;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Which request a rejection answers, so draft-14 picks the right registry.\n *\n * Draft-14 gives each error message its own registry and they disagree about 0x4; draft-15\n * folded them all into REQUEST_ERROR with a single registry, so from there on the kind\n * changes nothing.\n *\n * @internal\n */\nexport type RequestKind = \"subscribe\" | \"fetch\" | \"publish\" | \"publish_namespace\" | \"subscribe_namespace\";\n\n/**\n * What a rejection reports, before the draft picks the number for it.\n *\n * Named separately from the wire code because a rejection says less than a failure does: a\n * dozen local errors are one INTERNAL_ERROR on the wire.\n *\n * @internal\n */\nexport type RequestCondition =\n\t/** Something went wrong that the registry has no value for. */\n\t| \"internal\"\n\t/** The peer's credentials do not cover the request. */\n\t| \"unauthorized\"\n\t/** The request outlived an implementation-specific deadline. */\n\t| \"timeout\"\n\t/** This endpoint does not implement the request at all. */\n\t| \"not_supported\"\n\t/** The broadcast or track the peer asked for is not here. */\n\t| \"does_not_exist\"\n\t/** The content the peer offered is not wanted here, so it should stop offering it. */\n\t| \"uninterested\"\n\t/** The track's content could not be parsed. */\n\t| \"malformed_track\"\n\t/** A GOAWAY is draining the session, so no new request is accepted. */\n\t| \"going_away\";\n\n/** An implementation-specific error. Assigned by every draft, for every request. */\nconst INTERNAL_ERROR = 0x0;\nconst UNAUTHORIZED = 0x1;\nconst TIMEOUT = 0x2;\nconst NOT_SUPPORTED = 0x3;\n\n/** A draining session. Draft-17 and later. */\nconst GOING_AWAY = 0x6;\n\n/** Draft-14 calls it TRACK_DOES_NOT_EXIST; draft-15 renamed it and moved it off 0x4. */\nconst DOES_NOT_EXIST_14 = 0x4;\nconst DOES_NOT_EXIST = 0x10;\n\n/** Draft-14 assigns UNINTERESTED only to the two requests that offer content. */\nconst UNINTERESTED_14 = 0x4;\nconst UNINTERESTED = 0x20;\n\n/** Draft-14 assigns MALFORMED_TRACK to FETCH_ERROR only. */\nconst MALFORMED_TRACK_14 = 0x9;\nconst MALFORMED_TRACK = 0x12;\n\n/** The value for \"the thing you asked for is not here\", or undefined where none is assigned. */\nfunction doesNotExist(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return DOES_NOT_EXIST;\n\treturn kind === \"subscribe\" || kind === \"fetch\" ? DOES_NOT_EXIST_14 : undefined;\n}\n\n/** The value for \"we do not want this\", or undefined where none is assigned. */\nfunction uninterested(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return UNINTERESTED;\n\treturn kind === \"publish\" || kind === \"publish_namespace\" ? UNINTERESTED_14 : undefined;\n}\n\n/** The value for a track we could not parse, or undefined where none is assigned. */\nfunction malformedTrack(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return MALFORMED_TRACK;\n\treturn kind === \"fetch\" ? MALFORMED_TRACK_14 : undefined;\n}\n\n/** The value for a draining session, or undefined before draft-17 registered one. */\nfunction goingAway(version: IetfVersion): number | undefined {\n\treturn version >= Version.DRAFT_17 ? GOING_AWAY : undefined;\n}\n\n/**\n * The code to reject a request with, on the negotiated draft.\n *\n * A condition the draft does not register for this request falls back to INTERNAL_ERROR\n * rather than borrowing a number from another draft, which would say something the peer's\n * registry gives a different meaning. The renumbering is the trap: draft-14 SUBSCRIBE_ERROR\n * gives 0x4 to TRACK_DOES_NOT_EXIST and 0x10 to MALFORMED_AUTH_TOKEN, and draft-15 swaps\n * the two.\n *\n * @internal\n */\nexport function toRequestCode(condition: RequestCondition, kind: RequestKind, version: IetfVersion): number {\n\tswitch (condition) {\n\t\tcase \"internal\":\n\t\t\treturn INTERNAL_ERROR;\n\t\tcase \"unauthorized\":\n\t\t\treturn UNAUTHORIZED;\n\t\tcase \"timeout\":\n\t\t\treturn TIMEOUT;\n\t\tcase \"not_supported\":\n\t\t\treturn NOT_SUPPORTED;\n\t\tcase \"does_not_exist\":\n\t\t\treturn doesNotExist(kind, version) ?? INTERNAL_ERROR;\n\t\t// A subscriber that asked for content cannot act on \"we do not want it\": what it needs\n\t\t// to know is that we do not have it, which is the same refusal from its side. Only the\n\t\t// requests that offer content say UNINTERESTED.\n\t\tcase \"uninterested\":\n\t\t\treturn kind === \"subscribe\" || kind === \"fetch\"\n\t\t\t\t? (doesNotExist(kind, version) ?? INTERNAL_ERROR)\n\t\t\t\t: (uninterested(kind, version) ?? INTERNAL_ERROR);\n\t\tcase \"malformed_track\":\n\t\t\treturn malformedTrack(kind, version) ?? INTERNAL_ERROR;\n\t\tcase \"going_away\":\n\t\t\treturn goingAway(version) ?? INTERNAL_ERROR;\n\t}\n}\n\n/**\n * Read a rejection code received on the negotiated draft.\n *\n * A code the draft does not assign for this request, INTERNAL_ERROR included, is\n * `undefined`: an error, but never one given a meaning it did not carry.\n *\n * @internal\n */\nexport function fromRequestCode(code: number, kind: RequestKind, version: IetfVersion): RequestCondition | undefined {\n\tswitch (code) {\n\t\tcase UNAUTHORIZED:\n\t\t\treturn \"unauthorized\";\n\t\tcase TIMEOUT:\n\t\t\treturn \"timeout\";\n\t\tcase NOT_SUPPORTED:\n\t\t\treturn \"not_supported\";\n\t}\n\n\tif (code === doesNotExist(kind, version)) return \"does_not_exist\";\n\tif (code === uninterested(kind, version)) return \"uninterested\";\n\tif (code === malformedTrack(kind, version)) return \"malformed_track\";\n\tif (code === goingAway(version)) return \"going_away\";\n\treturn undefined;\n}\n\n/**\n * Describe a rejection a peer sent, naming the condition when the draft registers one.\n *\n * @internal\n */\nexport function requestReason(code: number, reasonPhrase: string, kind: RequestKind, version: IetfVersion): string {\n\tconst condition = fromRequestCode(code, kind, version) ?? \"unregistered\";\n\treturn `${condition} (code=${code}) ${reasonPhrase}`;\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/ietf/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAoB,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAoB;IAClE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACP,OAAO,IAAI,CAAC;QACb,sFAAsF;QACtF,iEAAiE;QACjE,KAAK,GAAG;YACP,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC,sCAAsC;QACtC,KAAK,GAAG;YACP,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC,uCAAuC;QACvC,KAAK,IAAI;YACR,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AACF,CAAC;AA+CD,oFAAoF;AACpF,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,OAAO,GAAG,G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;QAAE,OAAO,YAAY,CAAC;IACrD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,YAAoB,EAAE,IAAiB,EAAE,OAAoB;IACxG,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC;IACzE,OAAO,GAAG,SAAS,UAAU,IAAI,KAAK,YAAY,EAAE,CAAC;AACtD,CAAC","sourcesContent":["/**\n * The moq-transport error code registries, per negotiated draft.\n *\n * A code only means something once you know which draft carried it: the registries grew,\n * moved values, and in draft-15 collapsed five per-message tables into one. Mirrors the\n * Rust `moq_net::ietf::error` module, and the two have to agree value for value.\n *\n * @module\n */\n\nimport { type IetfVersion, Version } from \"./version.ts\";\n\n/**\n * Whether `code` means the same thing in the negotiated draft's stream reset registry as it\n * does in moq-lite's.\n *\n * The two registries agree on most of what they both assign, but this one grew across the\n * drafts we negotiate and moved a value on the way:\n *\n * | Code | draft-14/15 | draft-16/17 | draft-18+ |\n * |------|-------------|-------------|-----------|\n * | 0x0 | INTERNAL_ERROR | INTERNAL_ERROR | INTERNAL_ERROR |\n * | 0x1 | CANCELLED | CANCELLED | CANCELLED |\n * | 0x2 | DELIVERY_TIMEOUT | DELIVERY_TIMEOUT | DELIVERY_TIMEOUT |\n * | 0x3 | SESSION_CLOSED | SESSION_CLOSED | SESSION_CLOSED |\n * | 0x4 | - | UNKNOWN_OBJECT_STATUS | GOING_AWAY |\n * | 0x5 | - | TOO_FAR_BEHIND (17) | TOO_FAR_BEHIND |\n * | 0x12 | - | MALFORMED_TRACK | MALFORMED_TRACK |\n *\n * So GOING_AWAY sent to a draft-17 peer reads as UNKNOWN_OBJECT_STATUS, and that peer's\n * UNKNOWN_OBJECT_STATUS read as GOING_AWAY would retire a session that is not going\n * anywhere. Anything this says `false` about is sent as, and read as, INTERNAL_ERROR: the\n * codes moq-lite assigns in its own 48-63 range, and the ones the draft assigns that\n * moq-lite has no name for (UNKNOWN_OBJECT_STATUS, EXPIRED_AUTH_TOKEN, EXCESSIVE_LOAD).\n *\n * @internal\n */\nexport function sharedStreamCode(code: number, version: IetfVersion): boolean {\n\tswitch (code) {\n\t\tcase 0x0:\n\t\tcase 0x1:\n\t\tcase 0x2:\n\t\tcase 0x3:\n\t\t\treturn true;\n\t\t// Draft-16 and 17 give 0x4 to UNKNOWN_OBJECT_STATUS, which draft-18 moved to 0x6 when\n\t\t// it took 0x4 for GOING_AWAY. Draft-14 and 15 assign it nothing.\n\t\tcase 0x4:\n\t\t\treturn version >= Version.DRAFT_18;\n\t\t// TOO_FAR_BEHIND arrived in draft-17.\n\t\tcase 0x5:\n\t\t\treturn version >= Version.DRAFT_17;\n\t\t// MALFORMED_TRACK arrived in draft-16.\n\t\tcase 0x12:\n\t\t\treturn version >= Version.DRAFT_16;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Which request a rejection answers, so draft-14 picks the right registry.\n *\n * Draft-14 gives each error message its own registry and they disagree about 0x4; draft-15\n * folded them all into REQUEST_ERROR with a single registry, so from there on the kind\n * changes nothing.\n *\n * @internal\n */\nexport type RequestKind =\n\t| \"subscribe\"\n\t| \"fetch\"\n\t| \"publish\"\n\t| \"publish_namespace\"\n\t| \"subscribe_namespace\"\n\t| \"track_status\";\n\n/**\n * What a rejection reports, before the draft picks the number for it.\n *\n * Named separately from the wire code because a rejection says less than a failure does: a\n * dozen local errors are one INTERNAL_ERROR on the wire.\n *\n * @internal\n */\nexport type RequestCondition =\n\t/** Something went wrong that the registry has no value for. */\n\t| \"internal\"\n\t/** The peer's credentials do not cover the request. */\n\t| \"unauthorized\"\n\t/** The request outlived an implementation-specific deadline. */\n\t| \"timeout\"\n\t/** This endpoint does not implement the request at all. */\n\t| \"not_supported\"\n\t/** The broadcast or track the peer asked for is not here. */\n\t| \"invalid_range\"\n\t| \"invalid_joining_request_id\"\n\t| \"does_not_exist\"\n\t/** The content the peer offered is not wanted here, so it should stop offering it. */\n\t| \"uninterested\"\n\t/** The track's content could not be parsed. */\n\t| \"malformed_track\"\n\t/** A GOAWAY is draining the session, so no new request is accepted. */\n\t| \"going_away\";\n\n/** An implementation-specific error. Assigned by every draft, for every request. */\nconst INTERNAL_ERROR = 0x0;\nconst UNAUTHORIZED = 0x1;\nconst TIMEOUT = 0x2;\nconst NOT_SUPPORTED = 0x3;\n\n/** A draining session. Draft-17 and later. */\nconst GOING_AWAY = 0x6;\n\n/** FETCH-only errors. INVALID_JOINING_REQUEST_ID was removed in draft-20. */\nconst INVALID_RANGE_14 = 0x5;\nconst INVALID_RANGE = 0x11;\nconst INVALID_JOINING_REQUEST_ID_14 = 0x7;\nconst INVALID_JOINING_REQUEST_ID = 0x32;\n\nfunction invalidRange(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (kind !== \"fetch\") return undefined;\n\treturn version === Version.DRAFT_14 ? INVALID_RANGE_14 : INVALID_RANGE;\n}\n\nfunction invalidJoiningRequestId(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (kind !== \"fetch\") return undefined;\n\tif (version === Version.DRAFT_14) return INVALID_JOINING_REQUEST_ID_14;\n\treturn version <= Version.DRAFT_19 ? INVALID_JOINING_REQUEST_ID : undefined;\n}\n\n/** Draft-14 calls it TRACK_DOES_NOT_EXIST; draft-15 renamed it and moved it off 0x4. */\nconst DOES_NOT_EXIST_14 = 0x4;\nconst DOES_NOT_EXIST = 0x10;\n\n/** Draft-14 assigns UNINTERESTED only to the two requests that offer content. */\nconst UNINTERESTED_14 = 0x4;\nconst UNINTERESTED = 0x20;\n\n/** Draft-14 assigns MALFORMED_TRACK to FETCH_ERROR only. */\nconst MALFORMED_TRACK_14 = 0x9;\nconst MALFORMED_TRACK = 0x12;\n\n/** The value for \"the thing you asked for is not here\", or undefined where none is assigned. */\nfunction doesNotExist(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return DOES_NOT_EXIST;\n\treturn kind === \"subscribe\" || kind === \"fetch\" || kind === \"track_status\" ? DOES_NOT_EXIST_14 : undefined;\n}\n\n/** The value for \"we do not want this\", or undefined where none is assigned. */\nfunction uninterested(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return UNINTERESTED;\n\treturn kind === \"publish\" || kind === \"publish_namespace\" ? UNINTERESTED_14 : undefined;\n}\n\n/** The value for a track we could not parse, or undefined where none is assigned. */\nfunction malformedTrack(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return MALFORMED_TRACK;\n\treturn kind === \"fetch\" ? MALFORMED_TRACK_14 : undefined;\n}\n\n/** The value for a draining session, or undefined before draft-17 registered one. */\nfunction goingAway(version: IetfVersion): number | undefined {\n\treturn version >= Version.DRAFT_17 ? GOING_AWAY : undefined;\n}\n\n/**\n * The code to reject a request with, on the negotiated draft.\n *\n * A condition the draft does not register for this request falls back to INTERNAL_ERROR\n * rather than borrowing a number from another draft, which would say something the peer's\n * registry gives a different meaning. The renumbering is the trap: draft-14 SUBSCRIBE_ERROR\n * gives 0x4 to TRACK_DOES_NOT_EXIST and 0x10 to MALFORMED_AUTH_TOKEN, and draft-15 swaps\n * the two.\n *\n * @internal\n */\nexport function toRequestCode(condition: RequestCondition, kind: RequestKind, version: IetfVersion): number {\n\tswitch (condition) {\n\t\tcase \"internal\":\n\t\t\treturn INTERNAL_ERROR;\n\t\tcase \"unauthorized\":\n\t\t\treturn UNAUTHORIZED;\n\t\tcase \"timeout\":\n\t\t\treturn TIMEOUT;\n\t\tcase \"not_supported\":\n\t\t\treturn NOT_SUPPORTED;\n\t\tcase \"invalid_range\":\n\t\t\treturn invalidRange(kind, version) ?? INTERNAL_ERROR;\n\t\tcase \"invalid_joining_request_id\":\n\t\t\treturn invalidJoiningRequestId(kind, version) ?? INTERNAL_ERROR;\n\t\tcase \"does_not_exist\":\n\t\t\treturn doesNotExist(kind, version) ?? INTERNAL_ERROR;\n\t\t// A subscriber that asked for content cannot act on \"we do not want it\": what it needs\n\t\t// to know is that we do not have it, which is the same refusal from its side. Only the\n\t\t// requests that offer content say UNINTERESTED.\n\t\tcase \"uninterested\":\n\t\t\treturn kind === \"subscribe\" || kind === \"fetch\" || kind === \"track_status\"\n\t\t\t\t? (doesNotExist(kind, version) ?? INTERNAL_ERROR)\n\t\t\t\t: (uninterested(kind, version) ?? INTERNAL_ERROR);\n\t\tcase \"malformed_track\":\n\t\t\treturn malformedTrack(kind, version) ?? INTERNAL_ERROR;\n\t\tcase \"going_away\":\n\t\t\treturn goingAway(version) ?? INTERNAL_ERROR;\n\t}\n}\n\n/**\n * Read a rejection code received on the negotiated draft.\n *\n * A code the draft does not assign for this request, INTERNAL_ERROR included, is\n * `undefined`: an error, but never one given a meaning it did not carry.\n *\n * @internal\n */\nexport function fromRequestCode(code: number, kind: RequestKind, version: IetfVersion): RequestCondition | undefined {\n\tswitch (code) {\n\t\tcase UNAUTHORIZED:\n\t\t\treturn \"unauthorized\";\n\t\tcase TIMEOUT:\n\t\t\treturn \"timeout\";\n\t\tcase NOT_SUPPORTED:\n\t\t\treturn \"not_supported\";\n\t}\n\n\tif (code === doesNotExist(kind, version)) return \"does_not_exist\";\n\tif (code === invalidRange(kind, version)) return \"invalid_range\";\n\tif (code === invalidJoiningRequestId(kind, version)) return \"invalid_joining_request_id\";\n\tif (code === uninterested(kind, version)) return \"uninterested\";\n\tif (code === malformedTrack(kind, version)) return \"malformed_track\";\n\tif (code === goingAway(version)) return \"going_away\";\n\treturn undefined;\n}\n\n/**\n * Describe a rejection a peer sent, naming the condition when the draft registers one.\n *\n * @internal\n */\nexport function requestReason(code: number, reasonPhrase: string, kind: RequestKind, version: IetfVersion): string {\n\tconst condition = fromRequestCode(code, kind, version) ?? \"unregistered\";\n\treturn `${condition} (code=${code}) ${reasonPhrase}`;\n}\n"]}
package/ietf/fetch.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type * as Path from "../path";
2
1
  import type { Reader, Writer } from "../stream";
3
- import type { IetfVersion } from "./version";
2
+ import { type IetfVersion } from "./version";
4
3
  /**
5
4
  * The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it
6
5
  * answers. Written by the publisher when serving a subscription's fill.
@@ -18,31 +17,19 @@ export declare class FetchHeader {
18
17
  /** Read the header, with the stream type already consumed. */
19
18
  static decode(r: Reader, _version: IetfVersion): Promise<FetchHeader>;
20
19
  }
20
+ /**
21
+ * A FETCH request. We serve none, so only what a refusal needs is kept; the rest is
22
+ * decoded so a legal request is refused rather than breaking the stream.
23
+ */
21
24
  export declare class Fetch {
22
25
  #private;
23
26
  static id: number;
24
27
  requestId: bigint;
25
- trackNamespace: Path.Valid;
26
- trackName: string;
27
- subscriberPriority: number;
28
- groupOrder: number;
29
- startGroup: bigint;
30
- startObject: bigint;
31
- endGroup: bigint;
32
- endObject: bigint;
33
- constructor({ requestId, trackNamespace, trackName, subscriberPriority, groupOrder, startGroup, startObject, endGroup, endObject, }: {
28
+ constructor({ requestId }: {
34
29
  requestId: bigint;
35
- trackNamespace: Path.Valid;
36
- trackName: string;
37
- subscriberPriority: number;
38
- groupOrder: number;
39
- startGroup: bigint;
40
- startObject: bigint;
41
- endGroup: bigint;
42
- endObject: bigint;
43
30
  });
44
31
  encode(w: Writer, _version: IetfVersion): Promise<void>;
45
- static decode(r: Reader, _version: IetfVersion): Promise<Fetch>;
32
+ static decode(r: Reader, version: IetfVersion): Promise<Fetch>;
46
33
  }
47
34
  export declare class FetchOk {
48
35
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/ietf/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;GAGG;AACH,qBAAa,WAAW;IACvB,qDAAq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