@moq/net 0.4.8 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (662) hide show
  1. package/README.md +7 -1
  2. package/announce.d.ts +1 -1
  3. package/announce.d.ts.map +1 -1
  4. package/announce.js +1 -1
  5. package/announce.js.map +1 -1
  6. package/announced.d.ts +51 -47
  7. package/announced.d.ts.map +1 -1
  8. package/announced.js +183 -31
  9. package/announced.js.map +1 -1
  10. package/announced.test-util.d.ts +2 -0
  11. package/announced.test-util.d.ts.map +1 -0
  12. package/announced.test-util.js +27 -0
  13. package/announced.test-util.js.map +1 -0
  14. package/auth.d.ts +64 -0
  15. package/auth.d.ts.map +1 -0
  16. package/auth.js +20 -0
  17. package/auth.js.map +1 -0
  18. package/auth_gate.d.ts +2 -0
  19. package/auth_gate.d.ts.map +1 -0
  20. package/auth_gate.js +24 -0
  21. package/auth_gate.js.map +1 -0
  22. package/auth_session.d.ts +49 -0
  23. package/auth_session.d.ts.map +1 -0
  24. package/auth_session.js +1097 -0
  25. package/auth_session.js.map +1 -0
  26. package/bandwidth.d.ts +129 -25
  27. package/bandwidth.d.ts.map +1 -1
  28. package/bandwidth.js +410 -138
  29. package/bandwidth.js.map +1 -1
  30. package/bandwidth_api.d.ts +1 -1
  31. package/bandwidth_api.d.ts.map +1 -1
  32. package/bandwidth_api.js +1 -1
  33. package/bandwidth_api.js.map +1 -1
  34. package/broadcast.d.ts +62 -36
  35. package/broadcast.d.ts.map +1 -1
  36. package/broadcast.js +556 -172
  37. package/broadcast.js.map +1 -1
  38. package/cache.d.ts +103 -0
  39. package/cache.d.ts.map +1 -0
  40. package/cache.js +254 -0
  41. package/cache.js.map +1 -0
  42. package/claim.test-util.d.ts +5 -0
  43. package/claim.test-util.d.ts.map +1 -0
  44. package/claim.test-util.js +13 -0
  45. package/claim.test-util.js.map +1 -0
  46. package/connection/accept.d.ts +20 -12
  47. package/connection/accept.d.ts.map +1 -1
  48. package/connection/accept.js +97 -129
  49. package/connection/accept.js.map +1 -1
  50. package/connection/browser.d.ts.map +1 -1
  51. package/connection/browser.js +28 -19
  52. package/connection/browser.js.map +1 -1
  53. package/connection/connect.d.ts +119 -23
  54. package/connection/connect.d.ts.map +1 -1
  55. package/connection/connect.js +535 -216
  56. package/connection/connect.js.map +1 -1
  57. package/connection/dials.d.ts +45 -0
  58. package/connection/dials.d.ts.map +1 -0
  59. package/connection/dials.js +109 -0
  60. package/connection/dials.js.map +1 -0
  61. package/connection/endpoint.d.ts +60 -0
  62. package/connection/endpoint.d.ts.map +1 -0
  63. package/connection/endpoint.js +114 -0
  64. package/connection/endpoint.js.map +1 -0
  65. package/connection/forward.d.ts +7 -1
  66. package/connection/forward.d.ts.map +1 -1
  67. package/connection/forward.js +265 -80
  68. package/connection/forward.js.map +1 -1
  69. package/connection/goaway.d.ts +16 -9
  70. package/connection/goaway.d.ts.map +1 -1
  71. package/connection/goaway.js +22 -108
  72. package/connection/goaway.js.map +1 -1
  73. package/connection/handshake.d.ts +32 -6
  74. package/connection/handshake.d.ts.map +1 -1
  75. package/connection/handshake.js +97 -20
  76. package/connection/handshake.js.map +1 -1
  77. package/connection/index.d.ts +3 -6
  78. package/connection/index.d.ts.map +1 -1
  79. package/connection/index.js +1 -2
  80. package/connection/index.js.map +1 -1
  81. package/connection/liveness.d.ts +14 -0
  82. package/connection/liveness.d.ts.map +1 -0
  83. package/connection/liveness.js +30 -0
  84. package/connection/liveness.js.map +1 -0
  85. package/connection/pool.d.ts +137 -58
  86. package/connection/pool.d.ts.map +1 -1
  87. package/connection/pool.js +281 -117
  88. package/connection/pool.js.map +1 -1
  89. package/connection/reload.d.ts +60 -12
  90. package/connection/reload.d.ts.map +1 -1
  91. package/connection/reload.js +859 -233
  92. package/connection/reload.js.map +1 -1
  93. package/connection/session.d.ts +91 -0
  94. package/connection/session.d.ts.map +1 -0
  95. package/connection/session.js +2 -0
  96. package/connection/session.js.map +1 -0
  97. package/connection/stats.d.ts +20 -11
  98. package/connection/stats.d.ts.map +1 -1
  99. package/connection/stats.js +64 -8
  100. package/connection/stats.js.map +1 -1
  101. package/connection/ticker.d.ts +4 -0
  102. package/connection/ticker.d.ts.map +1 -0
  103. package/connection/ticker.js +66 -0
  104. package/connection/ticker.js.map +1 -0
  105. package/connection/tokens.d.ts +2 -0
  106. package/connection/tokens.d.ts.map +1 -0
  107. package/connection/tokens.js +404 -0
  108. package/connection/tokens.js.map +1 -0
  109. package/connection/transport.d.ts.map +1 -1
  110. package/connection/transport.js +4 -4
  111. package/connection/transport.js.map +1 -1
  112. package/connection/withdrawal.d.ts +2 -0
  113. package/connection/withdrawal.d.ts.map +1 -0
  114. package/connection/withdrawal.js +23 -0
  115. package/connection/withdrawal.js.map +1 -0
  116. package/consume.js +213 -46
  117. package/consume.js.map +1 -1
  118. package/cover.d.ts +59 -0
  119. package/cover.d.ts.map +1 -0
  120. package/cover.js +375 -0
  121. package/cover.js.map +1 -0
  122. package/datagram.d.ts +70 -11
  123. package/datagram.d.ts.map +1 -1
  124. package/datagram.js +317 -1
  125. package/datagram.js.map +1 -1
  126. package/datagram_stream.d.ts +18 -0
  127. package/datagram_stream.d.ts.map +1 -0
  128. package/datagram_stream.js +67 -0
  129. package/datagram_stream.js.map +1 -0
  130. package/defined.test-util.d.ts +2 -0
  131. package/defined.test-util.d.ts.map +1 -0
  132. package/defined.test-util.js +7 -0
  133. package/defined.test-util.js.map +1 -0
  134. package/delivered.d.ts +75 -0
  135. package/delivered.d.ts.map +1 -0
  136. package/delivered.js +228 -0
  137. package/delivered.js.map +1 -0
  138. package/demand.d.ts +173 -0
  139. package/demand.d.ts.map +1 -0
  140. package/demand.js +582 -0
  141. package/demand.js.map +1 -0
  142. package/drops.d.ts +93 -0
  143. package/drops.d.ts.map +1 -0
  144. package/drops.js +283 -0
  145. package/drops.js.map +1 -0
  146. package/error.d.ts +120 -21
  147. package/error.d.ts.map +1 -1
  148. package/error.js +230 -37
  149. package/error.js.map +1 -1
  150. package/errors.d.ts +2 -2
  151. package/errors.d.ts.map +1 -1
  152. package/errors.js +2 -2
  153. package/errors.js.map +1 -1
  154. package/fill.d.ts +174 -0
  155. package/fill.d.ts.map +1 -0
  156. package/fill.js +760 -0
  157. package/fill.js.map +1 -0
  158. package/flate/decoder.d.ts +2 -0
  159. package/flate/decoder.d.ts.map +1 -0
  160. package/flate/decoder.js +63 -0
  161. package/flate/decoder.js.map +1 -0
  162. package/flate/encoder.d.ts +2 -0
  163. package/flate/encoder.d.ts.map +1 -0
  164. package/flate/encoder.js +64 -0
  165. package/flate/encoder.js.map +1 -0
  166. package/flate/group.d.ts +34 -0
  167. package/flate/group.d.ts.map +1 -0
  168. package/flate/group.js +140 -0
  169. package/flate/group.js.map +1 -0
  170. package/frame.d.ts +80 -0
  171. package/frame.d.ts.map +1 -0
  172. package/frame.js +296 -0
  173. package/frame.js.map +1 -0
  174. package/frame.test-util.d.ts +5 -0
  175. package/frame.test-util.d.ts.map +1 -0
  176. package/frame.test-util.js +9 -0
  177. package/frame.test-util.js.map +1 -0
  178. package/group.d.ts +108 -45
  179. package/group.d.ts.map +1 -1
  180. package/group.js +1616 -307
  181. package/group.js.map +1 -1
  182. package/group_api.d.ts +7 -0
  183. package/group_api.d.ts.map +1 -0
  184. package/group_api.js +7 -0
  185. package/group_api.js.map +1 -0
  186. package/hop.d.ts +62 -76
  187. package/hop.d.ts.map +1 -1
  188. package/hop.js +92 -64
  189. package/hop.js.map +1 -1
  190. package/identity.d.ts +39 -0
  191. package/identity.d.ts.map +1 -0
  192. package/identity.js +47 -0
  193. package/identity.js.map +1 -0
  194. package/ietf/active_count.d.ts +2 -0
  195. package/ietf/active_count.d.ts.map +1 -0
  196. package/ietf/active_count.js +30 -0
  197. package/ietf/active_count.js.map +1 -0
  198. package/ietf/aliases.js +69 -35
  199. package/ietf/aliases.js.map +1 -1
  200. package/ietf/cluster.d.ts +3 -3
  201. package/ietf/cluster.js +14 -62
  202. package/ietf/cluster.js.map +1 -1
  203. package/ietf/connection.d.ts +1 -31
  204. package/ietf/connection.d.ts.map +1 -1
  205. package/ietf/connection.js +305 -143
  206. package/ietf/connection.js.map +1 -1
  207. package/ietf/datagram.d.ts +60 -0
  208. package/ietf/datagram.d.ts.map +1 -0
  209. package/ietf/datagram.js +152 -0
  210. package/ietf/datagram.js.map +1 -0
  211. package/ietf/error.d.ts +3 -3
  212. package/ietf/error.js +82 -100
  213. package/ietf/error.js.map +1 -1
  214. package/ietf/fetch.d.ts +91 -35
  215. package/ietf/fetch.d.ts.map +1 -1
  216. package/ietf/fetch.js +172 -93
  217. package/ietf/fetch.js.map +1 -1
  218. package/ietf/filter.d.ts +20 -30
  219. package/ietf/filter.d.ts.map +1 -1
  220. package/ietf/filter.js +140 -171
  221. package/ietf/filter.js.map +1 -1
  222. package/ietf/goaway.d.ts +11 -9
  223. package/ietf/goaway.d.ts.map +1 -1
  224. package/ietf/goaway.js +22 -35
  225. package/ietf/goaway.js.map +1 -1
  226. package/ietf/hidden.js +1 -1
  227. package/ietf/hidden.js.map +1 -1
  228. package/ietf/index.d.ts +2 -14
  229. package/ietf/index.d.ts.map +1 -1
  230. package/ietf/index.js +4 -14
  231. package/ietf/index.js.map +1 -1
  232. package/ietf/join.d.ts +7 -0
  233. package/ietf/join.d.ts.map +1 -0
  234. package/ietf/join.js +234 -0
  235. package/ietf/join.js.map +1 -0
  236. package/ietf/message.d.ts +18 -2
  237. package/ietf/message.d.ts.map +1 -1
  238. package/ietf/message.js +60 -40
  239. package/ietf/message.js.map +1 -1
  240. package/ietf/message.test-util.d.ts +6 -0
  241. package/ietf/message.test-util.d.ts.map +1 -0
  242. package/ietf/message.test-util.js +13 -0
  243. package/ietf/message.test-util.js.map +1 -0
  244. package/ietf/namespace.d.ts +17 -3
  245. package/ietf/namespace.d.ts.map +1 -1
  246. package/ietf/namespace.js +78 -26
  247. package/ietf/namespace.js.map +1 -1
  248. package/ietf/object.d.ts +194 -32
  249. package/ietf/object.d.ts.map +1 -1
  250. package/ietf/object.js +405 -178
  251. package/ietf/object.js.map +1 -1
  252. package/ietf/parameters.d.ts +22 -42
  253. package/ietf/parameters.d.ts.map +1 -1
  254. package/ietf/parameters.js +260 -472
  255. package/ietf/parameters.js.map +1 -1
  256. package/ietf/priority.d.ts +17 -2
  257. package/ietf/priority.d.ts.map +1 -1
  258. package/ietf/priority.js +19 -4
  259. package/ietf/priority.js.map +1 -1
  260. package/ietf/properties.d.ts +5 -4
  261. package/ietf/properties.d.ts.map +1 -1
  262. package/ietf/properties.js +78 -48
  263. package/ietf/properties.js.map +1 -1
  264. package/ietf/publish.d.ts +22 -30
  265. package/ietf/publish.d.ts.map +1 -1
  266. package/ietf/publish.js +45 -139
  267. package/ietf/publish.js.map +1 -1
  268. package/ietf/publish_namespace.d.ts +46 -69
  269. package/ietf/publish_namespace.d.ts.map +1 -1
  270. package/ietf/publish_namespace.js +66 -184
  271. package/ietf/publish_namespace.js.map +1 -1
  272. package/ietf/publisher.js +1800 -600
  273. package/ietf/publisher.js.map +1 -1
  274. package/ietf/range.d.ts +2 -0
  275. package/ietf/range.d.ts.map +1 -0
  276. package/ietf/range.js +222 -0
  277. package/ietf/range.js.map +1 -0
  278. package/ietf/request.d.ts +3 -27
  279. package/ietf/request.d.ts.map +1 -1
  280. package/ietf/request.js +41 -78
  281. package/ietf/request.js.map +1 -1
  282. package/ietf/request_stream.d.ts +1 -6
  283. package/ietf/request_stream.d.ts.map +1 -1
  284. package/ietf/request_stream.js +306 -16
  285. package/ietf/request_stream.js.map +1 -1
  286. package/ietf/session.d.ts +41 -0
  287. package/ietf/session.d.ts.map +1 -0
  288. package/ietf/session.js +65 -0
  289. package/ietf/session.js.map +1 -0
  290. package/ietf/setup.d.ts +4 -29
  291. package/ietf/setup.d.ts.map +1 -1
  292. package/ietf/setup.js +6 -117
  293. package/ietf/setup.js.map +1 -1
  294. package/ietf/setup_options.d.ts +31 -0
  295. package/ietf/setup_options.d.ts.map +1 -0
  296. package/ietf/setup_options.js +138 -0
  297. package/ietf/setup_options.js.map +1 -0
  298. package/ietf/solicit.js +4 -14
  299. package/ietf/solicit.js.map +1 -1
  300. package/ietf/subscribe.d.ts +48 -41
  301. package/ietf/subscribe.d.ts.map +1 -1
  302. package/ietf/subscribe.js +118 -239
  303. package/ietf/subscribe.js.map +1 -1
  304. package/ietf/subscribe_namespace.d.ts +13 -76
  305. package/ietf/subscribe_namespace.d.ts.map +1 -1
  306. package/ietf/subscribe_namespace.js +30 -201
  307. package/ietf/subscribe_namespace.js.map +1 -1
  308. package/ietf/subscriber.js +1839 -536
  309. package/ietf/subscriber.js.map +1 -1
  310. package/ietf/token.js +105 -27
  311. package/ietf/token.js.map +1 -1
  312. package/ietf/track.d.ts +25 -22
  313. package/ietf/track.d.ts.map +1 -1
  314. package/ietf/track.js +48 -61
  315. package/ietf/track.js.map +1 -1
  316. package/ietf/version.d.ts +13 -42
  317. package/ietf/version.d.ts.map +1 -1
  318. package/ietf/version.js +22 -48
  319. package/ietf/version.js.map +1 -1
  320. package/implementation.d.ts +2 -0
  321. package/implementation.d.ts.map +1 -0
  322. package/implementation.js +5 -0
  323. package/implementation.js.map +1 -0
  324. package/index.d.ts +25 -10
  325. package/index.d.ts.map +1 -1
  326. package/index.js +19 -6
  327. package/index.js.map +1 -1
  328. package/internal.d.ts +1512 -64
  329. package/internal.d.ts.map +1 -1
  330. package/internal.js +557 -79
  331. package/internal.js.map +1 -1
  332. package/ledger.d.ts +23 -0
  333. package/ledger.d.ts.map +1 -0
  334. package/ledger.js +247 -0
  335. package/ledger.js.map +1 -0
  336. package/listing.d.ts +132 -0
  337. package/listing.d.ts.map +1 -0
  338. package/listing.js +486 -0
  339. package/listing.js.map +1 -0
  340. package/lite/announce.d.ts +124 -63
  341. package/lite/announce.d.ts.map +1 -1
  342. package/lite/announce.js +384 -158
  343. package/lite/announce.js.map +1 -1
  344. package/lite/announce_stream.d.ts +2 -0
  345. package/lite/announce_stream.d.ts.map +1 -0
  346. package/lite/announce_stream.js +92 -0
  347. package/lite/announce_stream.js.map +1 -0
  348. package/lite/answer.d.ts +22 -0
  349. package/lite/answer.d.ts.map +1 -0
  350. package/lite/answer.js +301 -0
  351. package/lite/answer.js.map +1 -0
  352. package/lite/auth.d.ts +45 -0
  353. package/lite/auth.d.ts.map +1 -0
  354. package/lite/auth.js +204 -0
  355. package/lite/auth.js.map +1 -0
  356. package/lite/compat.d.ts +31 -0
  357. package/lite/compat.d.ts.map +1 -0
  358. package/lite/compat.js +86 -0
  359. package/lite/compat.js.map +1 -0
  360. package/lite/connection.d.ts +1 -45
  361. package/lite/connection.d.ts.map +1 -1
  362. package/lite/connection.js +360 -77
  363. package/lite/connection.js.map +1 -1
  364. package/lite/datagram-end.d.ts +26 -0
  365. package/lite/datagram-end.d.ts.map +1 -0
  366. package/lite/datagram-end.js +30 -0
  367. package/lite/datagram-end.js.map +1 -0
  368. package/lite/datagram.d.ts +73 -8
  369. package/lite/datagram.d.ts.map +1 -1
  370. package/lite/datagram.js +144 -9
  371. package/lite/datagram.js.map +1 -1
  372. package/lite/duration.d.ts +6 -0
  373. package/lite/duration.d.ts.map +1 -0
  374. package/lite/duration.js +14 -0
  375. package/lite/duration.js.map +1 -0
  376. package/lite/error.d.ts +9 -0
  377. package/lite/error.d.ts.map +1 -0
  378. package/lite/error.js +24 -0
  379. package/lite/error.js.map +1 -0
  380. package/lite/fills.d.ts +162 -0
  381. package/lite/fills.d.ts.map +1 -0
  382. package/lite/fills.js +486 -0
  383. package/lite/fills.js.map +1 -0
  384. package/lite/fit.d.ts +49 -0
  385. package/lite/fit.d.ts.map +1 -0
  386. package/lite/fit.js +305 -0
  387. package/lite/fit.js.map +1 -0
  388. package/lite/goaway.d.ts +1 -1
  389. package/lite/goaway.d.ts.map +1 -1
  390. package/lite/goaway.js +5 -13
  391. package/lite/goaway.js.map +1 -1
  392. package/lite/group.d.ts +64 -13
  393. package/lite/group.d.ts.map +1 -1
  394. package/lite/group.js +108 -30
  395. package/lite/group.js.map +1 -1
  396. package/lite/identity.d.ts +25 -0
  397. package/lite/identity.d.ts.map +1 -0
  398. package/lite/identity.js +79 -0
  399. package/lite/identity.js.map +1 -0
  400. package/lite/index.d.ts +2 -1
  401. package/lite/index.d.ts.map +1 -1
  402. package/lite/index.js +2 -1
  403. package/lite/index.js.map +1 -1
  404. package/lite/message.d.ts +9 -1
  405. package/lite/message.d.ts.map +1 -1
  406. package/lite/message.js +28 -44
  407. package/lite/message.js.map +1 -1
  408. package/lite/priority.d.ts +9 -2
  409. package/lite/priority.d.ts.map +1 -1
  410. package/lite/priority.js +11 -105
  411. package/lite/priority.js.map +1 -1
  412. package/lite/probe.d.ts.map +1 -1
  413. package/lite/probe.js +9 -0
  414. package/lite/probe.js.map +1 -1
  415. package/lite/publisher.d.ts +10 -1
  416. package/lite/publisher.d.ts.map +1 -1
  417. package/lite/publisher.js +2548 -437
  418. package/lite/publisher.js.map +1 -1
  419. package/lite/routed.d.ts +59 -0
  420. package/lite/routed.d.ts.map +1 -0
  421. package/lite/routed.js +564 -0
  422. package/lite/routed.js.map +1 -0
  423. package/lite/session.d.ts +1 -27
  424. package/lite/session.d.ts.map +1 -1
  425. package/lite/session.js +0 -99
  426. package/lite/session.js.map +1 -1
  427. package/lite/setup.d.ts +29 -2
  428. package/lite/setup.d.ts.map +1 -1
  429. package/lite/setup.js +95 -21
  430. package/lite/setup.js.map +1 -1
  431. package/lite/stream.d.ts +5 -11
  432. package/lite/stream.d.ts.map +1 -1
  433. package/lite/stream.js +5 -1
  434. package/lite/stream.js.map +1 -1
  435. package/lite/subscribe.d.ts +475 -75
  436. package/lite/subscribe.d.ts.map +1 -1
  437. package/lite/subscribe.js +1373 -142
  438. package/lite/subscribe.js.map +1 -1
  439. package/lite/subscriber.d.ts +7 -44
  440. package/lite/subscriber.d.ts.map +1 -1
  441. package/lite/subscriber.js +3290 -515
  442. package/lite/subscriber.js.map +1 -1
  443. package/lite/track.d.ts +24 -9
  444. package/lite/track.d.ts.map +1 -1
  445. package/lite/track.js +116 -37
  446. package/lite/track.js.map +1 -1
  447. package/lite/tracks.d.ts +55 -0
  448. package/lite/tracks.d.ts.map +1 -0
  449. package/lite/tracks.js +114 -0
  450. package/lite/tracks.js.map +1 -0
  451. package/lite/version.d.ts +132 -24
  452. package/lite/version.d.ts.map +1 -1
  453. package/lite/version.js +378 -33
  454. package/lite/version.js.map +1 -1
  455. package/meta.d.ts +77 -0
  456. package/meta.d.ts.map +1 -0
  457. package/meta.js +130 -0
  458. package/meta.js.map +1 -0
  459. package/meta_api.d.ts +7 -0
  460. package/meta_api.d.ts.map +1 -0
  461. package/meta_api.js +7 -0
  462. package/meta_api.js.map +1 -0
  463. package/mint.d.ts +28 -0
  464. package/mint.d.ts.map +1 -0
  465. package/mint.js +66 -0
  466. package/mint.js.map +1 -0
  467. package/open.d.ts +63 -0
  468. package/open.d.ts.map +1 -0
  469. package/open.js +250 -0
  470. package/open.js.map +1 -0
  471. package/origin.d.ts +392 -140
  472. package/origin.d.ts.map +1 -1
  473. package/origin.js +2533 -686
  474. package/origin.js.map +1 -1
  475. package/package.json +8 -13
  476. package/path.d.ts +51 -51
  477. package/path.d.ts.map +1 -1
  478. package/path.js +210 -57
  479. package/path.js.map +1 -1
  480. package/payload.d.ts +33 -0
  481. package/payload.d.ts.map +1 -0
  482. package/payload.js +65 -0
  483. package/payload.js.map +1 -0
  484. package/prefix.d.ts +152 -0
  485. package/prefix.d.ts.map +1 -0
  486. package/prefix.js +349 -0
  487. package/prefix.js.map +1 -0
  488. package/priority.d.ts +8 -0
  489. package/priority.d.ts.map +1 -0
  490. package/priority.js +185 -0
  491. package/priority.js.map +1 -0
  492. package/queue.d.ts +2 -0
  493. package/queue.d.ts.map +1 -0
  494. package/queue.js +46 -0
  495. package/queue.js.map +1 -0
  496. package/ranges.d.ts +36 -0
  497. package/ranges.d.ts.map +1 -0
  498. package/ranges.js +312 -0
  499. package/ranges.js.map +1 -0
  500. package/rescale.d.ts +24 -0
  501. package/rescale.d.ts.map +1 -0
  502. package/rescale.js +39 -0
  503. package/rescale.js.map +1 -0
  504. package/resume.d.ts +55 -0
  505. package/resume.d.ts.map +1 -0
  506. package/resume.js +4173 -0
  507. package/resume.js.map +1 -0
  508. package/resume.test-util.d.ts +2 -0
  509. package/resume.test-util.d.ts.map +1 -0
  510. package/resume.test-util.js +25 -0
  511. package/resume.test-util.js.map +1 -0
  512. package/skips.d.ts +48 -0
  513. package/skips.d.ts.map +1 -0
  514. package/skips.js +182 -0
  515. package/skips.js.map +1 -0
  516. package/stream.d.ts +75 -37
  517. package/stream.d.ts.map +1 -1
  518. package/stream.js +236 -92
  519. package/stream.js.map +1 -1
  520. package/subscription.test-util.d.ts +2 -0
  521. package/subscription.test-util.d.ts.map +1 -0
  522. package/subscription.test-util.js +49 -0
  523. package/subscription.test-util.js.map +1 -0
  524. package/tail.d.ts +23 -14
  525. package/tail.d.ts.map +1 -1
  526. package/tail.js +224 -97
  527. package/tail.js.map +1 -1
  528. package/time.d.ts +41 -102
  529. package/time.d.ts.map +1 -1
  530. package/time.js +129 -91
  531. package/time.js.map +1 -1
  532. package/timed.d.ts +21 -0
  533. package/timed.d.ts.map +1 -0
  534. package/timed.js +2 -0
  535. package/timed.js.map +1 -0
  536. package/track.d.ts +577 -245
  537. package/track.d.ts.map +1 -1
  538. package/track.js +7306 -771
  539. package/track.js.map +1 -1
  540. package/track_api.d.ts +7 -0
  541. package/track_api.d.ts.map +1 -0
  542. package/track_api.js +7 -0
  543. package/track_api.js.map +1 -0
  544. package/util/abort.d.ts +1 -0
  545. package/util/abort.d.ts.map +1 -1
  546. package/util/abort.js +23 -1
  547. package/util/abort.js.map +1 -1
  548. package/util/announce.d.ts +4 -0
  549. package/util/announce.d.ts.map +1 -0
  550. package/util/announce.js +11 -0
  551. package/util/announce.js.map +1 -0
  552. package/util/bigint.d.ts +3 -0
  553. package/util/bigint.d.ts.map +1 -0
  554. package/util/bigint.js +8 -0
  555. package/util/bigint.js.map +1 -0
  556. package/util/change.d.ts +12 -0
  557. package/util/change.d.ts.map +1 -0
  558. package/util/change.js +18 -0
  559. package/util/change.js.map +1 -0
  560. package/util/deadline.d.ts +2 -0
  561. package/util/deadline.d.ts.map +1 -0
  562. package/util/deadline.js +108 -0
  563. package/util/deadline.js.map +1 -0
  564. package/util/decode_error.d.ts +3 -0
  565. package/util/decode_error.d.ts.map +1 -0
  566. package/util/decode_error.js +11 -0
  567. package/util/decode_error.js.map +1 -0
  568. package/util/demand.d.ts +8 -0
  569. package/util/demand.d.ts.map +1 -0
  570. package/util/demand.js +24 -0
  571. package/util/demand.js.map +1 -0
  572. package/util/given_up.d.ts +2 -0
  573. package/util/given_up.d.ts.map +1 -0
  574. package/util/given_up.js +101 -0
  575. package/util/given_up.js.map +1 -0
  576. package/util/hex.d.ts +6 -0
  577. package/util/hex.d.ts.map +1 -1
  578. package/util/hex.js +19 -4
  579. package/util/hex.js.map +1 -1
  580. package/util/key.d.ts +15 -0
  581. package/util/key.d.ts.map +1 -0
  582. package/util/key.js +38 -0
  583. package/util/key.js.map +1 -0
  584. package/util/limits.d.ts +2 -0
  585. package/util/limits.d.ts.map +1 -0
  586. package/util/limits.js +76 -0
  587. package/util/limits.js.map +1 -0
  588. package/util/observed.d.ts +23 -0
  589. package/util/observed.d.ts.map +1 -0
  590. package/util/observed.js +122 -0
  591. package/util/observed.js.map +1 -0
  592. package/util/sorted.d.ts +2 -0
  593. package/util/sorted.d.ts.map +1 -0
  594. package/util/sorted.js +149 -0
  595. package/util/sorted.js.map +1 -0
  596. package/util/timeout.d.ts +2 -1
  597. package/util/timeout.d.ts.map +1 -1
  598. package/util/timeout.js +13 -9
  599. package/util/timeout.js.map +1 -1
  600. package/util/timer.d.ts +2 -0
  601. package/util/timer.d.ts.map +1 -0
  602. package/util/timer.js +19 -0
  603. package/util/timer.js.map +1 -0
  604. package/util/utf8.d.ts +2 -0
  605. package/util/utf8.d.ts.map +1 -1
  606. package/util/utf8.js +7 -1
  607. package/util/utf8.js.map +1 -1
  608. package/util/varint.d.ts.map +1 -1
  609. package/util/varint.js +8 -1
  610. package/util/varint.js.map +1 -1
  611. package/util/watch.d.ts +8 -0
  612. package/util/watch.d.ts.map +1 -0
  613. package/util/watch.js +38 -0
  614. package/util/watch.js.map +1 -0
  615. package/util/yield.d.ts +2 -0
  616. package/util/yield.d.ts.map +1 -0
  617. package/util/yield.js +31 -0
  618. package/util/yield.js.map +1 -0
  619. package/varint.d.ts +0 -29
  620. package/varint.d.ts.map +1 -1
  621. package/varint.js +7 -28
  622. package/varint.js.map +1 -1
  623. package/varint_api.d.ts +7 -0
  624. package/varint_api.d.ts.map +1 -0
  625. package/varint_api.js +7 -0
  626. package/varint_api.js.map +1 -0
  627. package/version.d.ts +2 -0
  628. package/version.d.ts.map +1 -0
  629. package/version.js +4 -0
  630. package/version.js.map +1 -0
  631. package/window.d.ts +570 -0
  632. package/window.d.ts.map +1 -0
  633. package/window.js +1677 -0
  634. package/window.js.map +1 -0
  635. package/wire.d.ts +145 -30
  636. package/wire.d.ts.map +1 -1
  637. package/wire.js +27 -0
  638. package/wire.js.map +1 -1
  639. package/connection/established.d.ts +0 -53
  640. package/connection/established.d.ts.map +0 -1
  641. package/connection/established.js +0 -2
  642. package/connection/established.js.map +0 -1
  643. package/ietf/adapter.d.ts +0 -75
  644. package/ietf/adapter.d.ts.map +0 -1
  645. package/ietf/adapter.js +0 -699
  646. package/ietf/adapter.js.map +0 -1
  647. package/lite/datagram_stream.d.ts +0 -8
  648. package/lite/datagram_stream.d.ts.map +0 -1
  649. package/lite/datagram_stream.js +0 -43
  650. package/lite/datagram_stream.js.map +0 -1
  651. package/lite/fetch.d.ts +0 -28
  652. package/lite/fetch.d.ts.map +0 -1
  653. package/lite/fetch.js +0 -78
  654. package/lite/fetch.js.map +0 -1
  655. package/util/log.d.ts +0 -5
  656. package/util/log.d.ts.map +0 -1
  657. package/util/log.js +0 -16
  658. package/util/log.js.map +0 -1
  659. package/zod.d.ts +0 -13
  660. package/zod.d.ts.map +0 -1
  661. package/zod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C1B,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI;QAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI;KAC4C,CAAC;IAExE,yEAAyE;IACzE,0EAA0E;IAC1E,kEAAkE;IAClE,mBAAmB;IACnB,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;QAC7B,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QAChC,QAAQ;KACR,CAAC,CAAC;IAEH,2EAA2E;IAC3E,kFAAkF;IAClF,4EAA4E;IAC5E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACzE,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import Session, { type Version as QmuxVersion } from \"@moq/qmux\";\nimport { error, fromClose } from \"../error.ts\";\nimport * as Ietf from \"../ietf/index.ts\";\nimport * as Lite from \"../lite/index.ts\";\nimport type { Consumer as OriginConsumer, Producer as OriginProducer } from \"../origin.ts\";\nimport { Stream } from \"../stream.ts\";\nimport * as Time from \"../time.ts\";\nimport * as Hex from \"../util/hex.ts\";\nimport { dev, redact } from \"../util/log.ts\";\nimport { isWebTransportSupported } from \"./browser.ts\";\nimport type { Established } from \"./established.ts\";\nimport { forwardAnnounced } from \"./forward.ts\";\nimport { exchangeSetup } from \"./handshake.ts\";\n\n// Default head start for WebTransport before attempting the WebSocket fallback.\nconst DEFAULT_WEBSOCKET_DELAY_MS = Time.Milli(500);\n\n// RESET_STREAM and CONNECTION_CLOSE are separate transport notifications. Give the latter\n// time to surface its authoritative code without letting a reset-only peer stall SETUP forever.\nconst SETUP_CLOSE_GRACE_MS = 100;\n\n/** Tuning for the WebSocket fallback used when WebTransport is unavailable or loses the connect race. */\nexport interface WebSocketProps {\n\t/** Enable the WebSocket fallback. Defaults to `true`. */\n\tenabled?: boolean;\n\n\t/** Use a different URL than WebTransport. By default, `https` maps to `wss` and `http` to `ws`. */\n\turl?: URL;\n\n\t/**\n\t * The delay in milliseconds before attempting the WebSocket fallback (default: 500).\n\t * If WebSocket won the previous race for a given URL, this is 0.\n\t */\n\tdelay?: Time.Milli;\n}\n\n/**\n * A server certificate hash used to pin a self-signed server, one entry of\n * `serverCertificateHashes`. Unlike the DOM type, `value` also accepts a hex string (the\n * format moq servers report via their certificate fingerprints), decoded automatically.\n */\nexport interface CertificateHash {\n\t/** The hash algorithm. Defaults to `sha-256` (the only supported value). */\n\talgorithm?: \"sha-256\";\n\t/** The certificate hash: raw bytes or a hex string. */\n\tvalue: BufferSource | string;\n}\n\n/** WebTransport options extended with friendlier certificate pinning (hex hashes or a raw certificate). */\nexport interface WebTransportProps extends Omit<WebTransportOptions, \"serverCertificateHashes\"> {\n\t/**\n\t * Pin the server to one or more certificate hashes. Each `value` may be raw\n\t * bytes or a hex string; the algorithm defaults to `sha-256`.\n\t */\n\tserverCertificateHashes?: CertificateHash[];\n\n\t/**\n\t * Pin the server by supplying its certificate directly; the SHA-256 hash is\n\t * computed for you. Accepts a PEM string or raw DER bytes. Use this when you\n\t * have the certificate but not its precomputed fingerprint.\n\t */\n\tserverCertificate?: string | BufferSource;\n}\n\n/** Options for {@link connect}. */\nexport interface ConnectProps {\n\t/** The relay URL. */\n\turl: URL;\n\n\t/** WebTransport options. */\n\twebtransport?: WebTransportProps;\n\n\t/** WebSocket (fallback) options. */\n\twebsocket?: WebSocketProps;\n\n\t/**\n\t * Use a pre-existing WebTransport session instead of connecting; skips the\n\t * WebTransport/WebSocket race. The publisher acquires the session's datagram\n\t * writer lock (`datagrams.writable.getWriter()`) for the session's lifetime,\n\t * so the caller must not hold it. Aborting via {@link ConnectProps.signal}\n\t * closes this session, so don't share one you intend to reuse afterwards.\n\t */\n\ttransport?: WebTransport;\n\n\t/**\n\t * Whether the relay supports broadcast discovery; see {@link Established.discovery}.\n\t * Defaults to true.\n\t */\n\tdiscovery?: boolean;\n\n\t/**\n\t * The origin whose broadcasts the session announces and serves to the peer. Omit to\n\t * publish nothing.\n\t *\n\t * The origin is borrowed, not owned: closing the session leaves its broadcasts alone,\n\t * and the same origin can back several sessions (or successive reconnects), each\n\t * announcing the table for as long as it lasts.\n\t */\n\tpublish?: OriginConsumer;\n\n\t/**\n\t * The origin the session feeds with the peer's announced broadcasts. Omit to discover\n\t * nothing.\n\t *\n\t * Everything the peer announces appears in the origin's table for the session's\n\t * lifetime, consumable by path; the entries retract when the session dies. Pass the\n\t * producer behind {@link ConnectProps.publish} to route both directions through one\n\t * origin: a locally published path is then served back to local consumers directly, and\n\t * the session still never announces the peer's own broadcasts back to it.\n\t */\n\tconsume?: OriginProducer;\n\n\t/**\n\t * Aborts the connection attempt with the signal's reason. An already-aborted\n\t * signal rejects before anything opens, and aborting after the connection is\n\t * established has no effect. Use `AbortSignal.timeout(ms)` for a deadline.\n\t */\n\tsignal?: AbortSignal;\n}\n\n/** The per-session wiring shared by every negotiated protocol path. */\ntype SessionProps = {\n\tdiscovery: boolean;\n\tpublish?: OriginConsumer;\n};\n\n// Save if WebSocket won the last race, so we won't give QUIC a head start next time.\nconst websocketWon = new Set<string>();\n\n/** The default connect signal: never aborts. */\nconst NEVER_ABORTED = new AbortController().signal;\n\n/**\n * Establishes a connection to a MOQ server.\n *\n * @param url - The URL of the server to connect to\n * @param props - Connection options\n * @returns A promise that resolves to an established session\n */\nexport async function connect({ url, ...props }: ConnectProps): Promise<Established> {\n\tconst signal = props.signal ?? NEVER_ABORTED;\n\tsignal.throwIfAborted();\n\n\t// Resolves on abort so every in-flight transport tears itself down.\n\tconst { promise: abort, resolve } = Promise.withResolvers<void>();\n\tconst onAbort = () => resolve();\n\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\n\tconst pending = connectInner(url, props, abort);\n\ttry {\n\t\t// A `pending` rejection propagates unless the abort beat it to the finish line.\n\t\tconst connection = await Promise.race([pending, abort.then(() => undefined)]);\n\t\tif (connection && !signal.aborted) {\n\t\t\tif (props.consume) forwardAnnounced(connection, props.consume);\n\t\t\treturn connection;\n\t\t}\n\n\t\t// Close a connection that settles after the abort.\n\t\tpending.then((conn) => conn.close()).catch(() => {});\n\t\tthrow signal.reason;\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\nasync function connectInner(url: URL, props: Omit<ConnectProps, \"url\">, abort: Promise<void>): Promise<Established> {\n\tconst wiring: SessionProps = {\n\t\tdiscovery: props.discovery ?? true,\n\t\tpublish: props.publish,\n\t};\n\n\tif (props.transport) {\n\t\tconst transport = props.transport;\n\t\tvoid abort.then(() => transport.close());\n\t\treturn connectTransport(url, transport, wiring);\n\t}\n\n\t// Stop transports after one connects or the caller aborts.\n\tconst { promise: raced, resolve: done } = Promise.withResolvers<void>();\n\tconst cancel = Promise.race([raced, abort]);\n\n\tconst webtransport = isWebTransportSupported() ? connectWebTransport(url, cancel, props.webtransport) : undefined;\n\n\t// Give QUIC a head start to connect before trying WebSocket, unless WebSocket has won in the past.\n\t// NOTE that QUIC should be faster because it involves 1/2 fewer RTTs.\n\tconst headstart =\n\t\t!webtransport || websocketWon.has(url.toString()) ? 0 : (props.websocket?.delay ?? DEFAULT_WEBSOCKET_DELAY_MS);\n\tconst websocket =\n\t\tprops.websocket?.enabled !== false\n\t\t\t? connectWebSocket(props.websocket?.url ?? url, headstart, cancel)\n\t\t\t: undefined;\n\n\tif (!websocket && !webtransport) {\n\t\tthrow new Error(\"no transport available; WebTransport not supported and WebSocket is disabled\");\n\t}\n\n\t// Race the available transports, using `.any` to ignore if one participant has an error.\n\t// `webtransport`/`websocket` are `Promise | undefined`, so test existence explicitly: a\n\t// promise is always truthy, so bare truthiness here would be a misused-promise.\n\tconst session = await Promise.any(\n\t\twebtransport !== undefined\n\t\t\t? websocket !== undefined\n\t\t\t\t? [websocket, webtransport]\n\t\t\t\t: [webtransport]\n\t\t\t: [websocket],\n\t);\n\tdone();\n\n\tif (!session) throw new Error(\"no transport available\");\n\n\t// Abort the setup handshake without leaking the selected transport.\n\tvoid abort.then(() => session.close());\n\n\t// Save if WebSocket won the last race, so we won't give QUIC a head start next time.\n\tif (session instanceof Session) {\n\t\t// Still a warning, not a debug line: losing the race means we fell back off QUIC.\n\t\tif (dev()) console.warn(redact(url), \"connected via WebSocket\");\n\t\twebsocketWon.add(url.toString());\n\t} else if (dev()) {\n\t\tconsole.debug(redact(url), \"connected via WebTransport\");\n\t}\n\n\t// The remaining setup is identical whether the transport was raced or supplied.\n\treturn await connectTransport(url, session as WebTransport, wiring);\n}\n\nasync function connectTransport(url: URL, session: WebTransport, wiring: SessionProps): Promise<Established> {\n\tconst closed = session.closed.then(fromClose, error);\n\tconst terminal = closed.then((cause) => {\n\t\tthrow cause ?? new Error(\"session closed during SETUP\");\n\t});\n\n\ttry {\n\t\treturn await Promise.race([terminal, negotiate(url, session, wiring)]);\n\t} catch (cause) {\n\t\t// A session shutdown can reject its SETUP stream before `closed` publishes the\n\t\t// peer's close code. Wait briefly without closing locally, since a local clean close\n\t\t// could overwrite that code. A reset-only peer is cleaned up after the grace period.\n\t\tconst pending = Symbol(\"session close pending\");\n\t\tconst final = await Promise.race([\n\t\t\tclosed,\n\t\t\tnew Promise<typeof pending>((resolve) => setTimeout(() => resolve(pending), SETUP_CLOSE_GRACE_MS)),\n\t\t]);\n\t\tif (final !== pending) {\n\t\t\tif (final) throw final;\n\t\t\tthrow cause;\n\t\t}\n\n\t\tsession.close();\n\t\tthrow cause;\n\t}\n}\n\n// Negotiate the MoQ protocol over an established transport. The caller races this against\n// the session closing so a close code is not lost behind a failed or stalled SETUP stream.\nasync function negotiate(url: URL, session: WebTransport, wiring: SessionProps): Promise<Established> {\n\t// The DOM lib has no `protocol` property yet. It is \"\" when none was negotiated, and\n\t// undefined in a browser that predates subprotocols (Firefox before 155).\n\tconst protocol: string | undefined = (session as { protocol?: string }).protocol || undefined;\n\tif (dev()) console.debug(redact(url), \"negotiated ALPN:\", protocol ?? \"(none)\");\n\n\t// Choose setup encoding based on negotiated WebTransport protocol (if any).\n\tlet setupVersion: Ietf.Version;\n\tconst modernVersion =\n\t\tprotocol === Ietf.ALPN.DRAFT_22\n\t\t\t? Ietf.Version.DRAFT_22\n\t\t\t: protocol === Ietf.ALPN.DRAFT_21\n\t\t\t\t? Ietf.Version.DRAFT_21\n\t\t\t\t: protocol === Ietf.ALPN.DRAFT_20\n\t\t\t\t\t? Ietf.Version.DRAFT_20\n\t\t\t\t\t: protocol === Ietf.ALPN.DRAFT_19\n\t\t\t\t\t\t? Ietf.Version.DRAFT_19\n\t\t\t\t\t\t: protocol === Ietf.ALPN.DRAFT_18\n\t\t\t\t\t\t\t? Ietf.Version.DRAFT_18\n\t\t\t\t\t\t\t: protocol === Ietf.ALPN.DRAFT_17\n\t\t\t\t\t\t\t\t? Ietf.Version.DRAFT_17\n\t\t\t\t\t\t\t\t: undefined;\n\tif (modernVersion !== undefined) {\n\t\treturn await handshakeAlpn(url, session, modernVersion, wiring);\n\t} else if (protocol === Ietf.ALPN.DRAFT_16) {\n\t\tsetupVersion = Ietf.Version.DRAFT_16;\n\t} else if (protocol === Ietf.ALPN.DRAFT_15) {\n\t\tsetupVersion = Ietf.Version.DRAFT_15;\n\t} else if (protocol === Lite.ALPN_07_WIP) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_07, ...wiring });\n\t} else if (protocol === Lite.ALPN_06) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_06, ...wiring });\n\t} else if (protocol === Lite.ALPN_05) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_05, ...wiring });\n\t} else if (protocol === Lite.ALPN_04) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_04, ...wiring });\n\t} else if (protocol === Lite.ALPN_03) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_03, ...wiring });\n\t} else if (protocol === Lite.ALPN || protocol === \"\" || protocol === undefined) {\n\t\tsetupVersion = Ietf.Version.DRAFT_14;\n\t} else {\n\t\tthrow new Error(`unsupported WebTransport protocol: ${protocol}`);\n\t}\n\n\tconst stream = await Stream.open(session, { version: setupVersion });\n\tawait stream.writer.u53(Lite.StreamId.ClientCompat);\n\n\tconst encoder = new TextEncoder();\n\n\tconst params = new Ietf.SetupOptions();\n\tparams.setVarint(Ietf.SetupOption.MaxRequestId, 42069n);\n\tparams.setBytes(Ietf.SetupOption.Implementation, encoder.encode(\"moq-lite-js\"));\n\tIetf.solicitIntoSetup(params);\n\tIetf.hiddenIntoSetup(params);\n\n\tconst client = new Ietf.ClientSetup({\n\t\tversions:\n\t\t\tsetupVersion === Ietf.Version.DRAFT_16\n\t\t\t\t? [Ietf.Version.DRAFT_16]\n\t\t\t\t: setupVersion === Ietf.Version.DRAFT_15\n\t\t\t\t\t? [Ietf.Version.DRAFT_15]\n\t\t\t\t\t: [Lite.Version.DRAFT_02, Lite.Version.DRAFT_01, Ietf.Version.DRAFT_14],\n\t\tparameters: params,\n\t});\n\tawait client.encode(stream.writer, setupVersion);\n\n\tconst serverCompat = await stream.reader.u53();\n\tif (serverCompat !== Lite.StreamId.ServerCompat) {\n\t\tthrow new Error(`unsupported server message type: ${serverCompat.toString()}`);\n\t}\n\n\tconst server = await Ietf.ServerSetup.decode(stream.reader, setupVersion);\n\n\tif (Object.values(Lite.Version).includes(server.version as Lite.Version)) {\n\t\treturn new Lite.Connection({\n\t\t\turl,\n\t\t\tquic: session,\n\t\t\tversion: server.version as Lite.Version,\n\t\t\tsession: stream,\n\t\t\t...wiring,\n\t\t});\n\t} else if (Object.values(Ietf.Version).includes(server.version as Ietf.Version)) {\n\t\tconst maxRequestId = server.parameters.getVarint(Ietf.SetupOption.MaxRequestId) ?? 0n;\n\t\treturn new Ietf.Connection({\n\t\t\t...wiring,\n\t\t\tclient: true,\n\t\t\turl,\n\t\t\tquic: session,\n\t\t\tcontrol: stream,\n\t\t\tmaxRequestId,\n\t\t\tversion: server.version as Ietf.IetfVersion,\n\t\t\tsolicit: Ietf.solicitFromSetup(server.parameters),\n\t\t\thidden: Ietf.hiddenFromSetup(server.parameters),\n\t\t});\n\t} else {\n\t\tthrow new Error(`unsupported server version: ${server.version.toString()}`);\n\t}\n}\n\n/**\n * Draft-17+ client handshake. ALPN already pinned the version; SETUP is\n * exchanged over a pair of uni streams using stream type 0x2F00.\n */\nasync function handshakeAlpn(\n\turl: URL,\n\tsession: WebTransport,\n\tversion: Ietf.IetfVersion,\n\twiring: SessionProps,\n): Promise<Established> {\n\tconst { control, early, solicit, hidden, cluster } = await exchangeSetup(session, version, \"moq-lite-js\");\n\n\treturn new Ietf.Connection({\n\t\t...wiring,\n\t\tclient: true,\n\t\turl,\n\t\tquic: session,\n\t\tcontrol,\n\t\tearly,\n\t\tsolicit,\n\t\thidden,\n\t\tcluster,\n\t\t// v17+ uses NativeSession which manages its own request IDs; maxRequestId is unused.\n\t\tmaxRequestId: 0n,\n\t\tversion,\n\t});\n}\n\n// One entry of the DOM `serverCertificateHashes`, derived without naming the lib type.\ntype WebTransportHash = NonNullable<WebTransportOptions[\"serverCertificateHashes\"]>[number];\n\n// Strip PEM armor and base64-decode to the raw DER bytes.\nfunction pemToDer(pem: string): Uint8Array<ArrayBuffer> {\n\t// indexOf rather than a lazy regex, which goes quadratic on repeated BEGIN lines without an END.\n\tconst begin = \"-----BEGIN CERTIFICATE-----\";\n\tconst start = pem.indexOf(begin);\n\tconst end = start < 0 ? -1 : pem.indexOf(\"-----END CERTIFICATE-----\", start + begin.length);\n\tconst body = end < 0 ? \"\" : pem.slice(start + begin.length, end).replace(/\\s+/g, \"\");\n\tif (!body) {\n\t\tthrow new Error(\"invalid PEM certificate: missing -----BEGIN/END CERTIFICATE----- armor\");\n\t}\n\n\tconst binary = atob(body);\n\tconst der = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tder[i] = binary.charCodeAt(i);\n\t}\n\treturn der;\n}\n\n/**\n * Compute the SHA-256 hash of a certificate, the value `serverCertificateHashes`\n * pins. Accepts a PEM string or raw DER bytes. Matches the hex fingerprints a moq\n * server reports, so `Hex.fromBytes(await certificateHash(pem))` round-trips.\n */\nexport async function certificateHash(cert: string | BufferSource): Promise<Uint8Array<ArrayBuffer>> {\n\tconst der = typeof cert === \"string\" ? pemToDer(cert) : cert;\n\tconst digest = await crypto.subtle.digest(\"SHA-256\", der);\n\treturn new Uint8Array(digest);\n}\n\n// Normalize our friendlier pinning options into the DOM `serverCertificateHashes`.\nasync function resolveCertificateHashes(options?: WebTransportProps): Promise<WebTransportHash[] | undefined> {\n\tconst hashes: WebTransportHash[] = [];\n\n\tfor (const hash of options?.serverCertificateHashes ?? []) {\n\t\tconst value = typeof hash.value === \"string\" ? Hex.toBytes(hash.value) : hash.value;\n\t\thashes.push({ algorithm: hash.algorithm ?? \"sha-256\", value });\n\t}\n\n\tif (options?.serverCertificate !== undefined) {\n\t\thashes.push({ algorithm: \"sha-256\", value: await certificateHash(options.serverCertificate) });\n\t}\n\n\treturn hashes.length > 0 ? hashes : undefined;\n}\n\nasync function connectWebTransport(\n\turl: URL,\n\tcancel: Promise<void>,\n\toptions?: WebTransportProps,\n): Promise<WebTransport | undefined> {\n\tlet finalUrl = url;\n\n\t// Our custom pinning fields are normalized separately; the rest are DOM options.\n\tconst { serverCertificate: _cert, serverCertificateHashes: _hashes, ...webtransport } = options ?? {};\n\n\tconst finalOptions: WebTransportOptions = {\n\t\tallowPooling: false,\n\t\tcongestionControl: \"low-latency\",\n\t\tprotocols: [\n\t\t\t// Lite.ALPN_07_WIP is intentionally omitted: lite-07 is work-in-progress and\n\t\t\t// not advertised by default (negotiate still accepts it if a server selects it).\n\t\t\tLite.ALPN_06,\n\t\t\tLite.ALPN_05,\n\t\t\tLite.ALPN_04,\n\t\t\tLite.ALPN_03,\n\t\t\tLite.ALPN,\n\t\t\tIetf.ALPN.DRAFT_22,\n\t\t\tIetf.ALPN.DRAFT_21,\n\t\t\tIetf.ALPN.DRAFT_20,\n\t\t\tIetf.ALPN.DRAFT_19,\n\t\t\tIetf.ALPN.DRAFT_18,\n\t\t\tIetf.ALPN.DRAFT_17,\n\t\t\tIetf.ALPN.DRAFT_16,\n\t\t\tIetf.ALPN.DRAFT_15,\n\t\t],\n\t\t...webtransport,\n\t};\n\n\t// Accumulate caller-provided pins first, then append anything we fetch below,\n\t// so a fetched fingerprint never clobbers hashes passed in via options.\n\tconst hashes = (await resolveCertificateHashes(options)) ?? [];\n\n\t// Only perform certificate fetch and URL rewrite when polyfill is not needed\n\t// This is needed because WebTransport is a butt to work with in local development.\n\tif (url.protocol === \"http:\") {\n\t\tconst fingerprintUrl = new URL(url);\n\t\tfingerprintUrl.pathname = \"/certificate.sha256\";\n\t\t// The certificate endpoint is unauthenticated, so don't hand it the token.\n\t\tfingerprintUrl.search = \"\";\n\n\t\t// Dev-only path: http:// can't be a real WebTransport origin, so we fetch the\n\t\t// self-signed cert's hash over plain HTTP and pin it. Production uses https://\n\t\t// and never reaches here. Keep this at debug so it doesn't read as a problem.\n\t\tif (dev()) {\n\t\t\tconsole.debug(\n\t\t\t\tredact(fingerprintUrl),\n\t\t\t\t\"performing an insecure fingerprint fetch; use https:// in production\",\n\t\t\t);\n\t\t}\n\n\t\t// Fetch the fingerprint from the server.\n\t\t// TODO cancel the request if the effect is cancelled.\n\t\tconst fingerprint = await Promise.race([fetch(fingerprintUrl), cancel]);\n\t\tif (!fingerprint) return undefined;\n\n\t\tconst fingerprintText = await Promise.race([fingerprint.text(), cancel]);\n\t\tif (fingerprintText === undefined) return undefined;\n\n\t\thashes.push({ algorithm: \"sha-256\", value: Hex.toBytes(fingerprintText) });\n\n\t\tfinalUrl = new URL(url);\n\t\tfinalUrl.protocol = \"https:\";\n\t}\n\n\tif (hashes.length > 0) {\n\t\tfinalOptions.serverCertificateHashes = hashes;\n\t}\n\n\tconst quic = new WebTransport(finalUrl, finalOptions);\n\n\t// Both .ready and .closed reject on failure; catch .closed to avoid an unhandled rejection.\n\tquic.closed.catch(() => {});\n\n\t// Wait for the WebTransport to connect, or for the cancel promise to resolve.\n\t// Close the connection if we lost the race.\n\tconst loaded = await Promise.race([quic.ready.then(() => true), cancel]);\n\tif (!loaded) {\n\t\tquic.close();\n\t\treturn undefined;\n\t}\n\n\treturn quic;\n}\n\n// TODO accept arguments to control the port/path used.\nasync function connectWebSocket(url: URL, delay: number, cancel: Promise<void>): Promise<Session | undefined> {\n\tconst timer = new Promise<void>((resolve) => setTimeout(resolve, delay));\n\n\tconst active = await Promise.race([cancel, timer.then(() => true)]);\n\tif (!active) return undefined;\n\n\t// moq-transport-18 and newer are pinned to qmux-01. Every other ALPN we\n\t// support is currently negotiated as `qmux-00.{alpn}` on the wire, but we\n\t// don't want to lock that in: set the value to `null` so the polyfill\n\t// advertises every QMux draft it knows about and the server picks one.\n\t// Insertion order is the negotiation preference on the wire.\n\tconst versions = {\n\t\t// Lite.ALPN_07_WIP omitted on purpose: lite-07 is work-in-progress, not advertised by default.\n\t\t[Lite.ALPN_06]: null,\n\t\t[Lite.ALPN_05]: null,\n\t\t[Lite.ALPN_04]: null,\n\t\t[Lite.ALPN_03]: null,\n\t\t[Lite.ALPN]: null,\n\t\t[Ietf.ALPN.DRAFT_22]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_21]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_20]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_19]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_18]: \"qmux-01\",\n\t\t[Ietf.ALPN.DRAFT_17]: null,\n\t\t[Ietf.ALPN.DRAFT_16]: null,\n\t\t[Ietf.ALPN.DRAFT_15]: null,\n\t} as const satisfies Record<string, QmuxVersion | QmuxVersion[] | null>;\n\n\t// The default (`requireProtocol: false`) also advertises bare `qmux-01`,\n\t// `qmux-00`, and `webtransport` so we still interop with relays that only\n\t// know a wire-format version (today's moq-relay only accepts bare\n\t// `webtransport`).\n\tconst quic = new Session(url, {\n\t\tprotocols: Object.keys(versions),\n\t\tversions,\n\t});\n\n\t// Wait for the WebSocket to connect, or for the cancel promise to resolve.\n\t// `ready` rejects on a refused/failed connection, so a throw here is the caller's\n\t// cue to retry; a lost cancel race instead resolves and we close the loser.\n\tconst loaded = await Promise.race([quic.ready.then(() => true), cancel]);\n\tif (!loaded) {\n\t\tquic.close();\n\t\treturn undefined;\n\t}\n\n\treturn quic;\n}\n"]}
1
+ {"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/connection/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAe,IAAI,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhG,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE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iBAAiB,CAAC,CAAC;QACpF,CAAC;gBAAS,CAAC;YACV,MAAM,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { Duration, Elapsed, sleep, timeout } from \"@moq/clock\";\nimport type { Session as Qmux, SessionOptions as QmuxOptions, Version as QmuxVersion } from \"@moq/qmux\";\nimport { type Getter, race } from \"@moq/signals\";\nimport type * as Auth from \"../auth.ts\";\nimport { vacant } from \"../auth_session.ts\";\nimport type { Viewers } from \"../bandwidth.ts\";\nimport { ConnectTimeout, error, fromClose, ProtocolViolation, sessionCause } from \"../error.ts\";\nimport type { Cost } from \"../hop.ts\";\nimport * as Ietf from \"../ietf/index.ts\";\nimport { IMPLEMENTATION } from \"../implementation.ts\";\nimport * as Lite from \"../lite/index.ts\";\nimport type { Consumer as OriginConsumer, Producer as OriginProducer } from \"../origin.ts\";\nimport { Stream } from \"../stream.ts\";\nimport * as Hex from \"../util/hex.ts\";\nimport { after } from \"../util/timer.ts\";\nimport { webTransportDialed } from \"./browser.ts\";\nimport { parse, show } from \"./endpoint.ts\";\nimport { DISCOVERY_REMOVED, forwardAnnounced } from \"./forward.ts\";\nimport { checkCost, connectTimeout, exchangeSetup, handsOff, type Link, link } from \"./handshake.ts\";\nimport * as Liveness from \"./liveness.ts\";\nimport type { Session } from \"./session.ts\";\nimport { inspect } from \"./stats.ts\";\nimport { credential, fallback, hold, type Presentation } from \"./tokens.ts\";\nimport { transportOf } from \"./transport.ts\";\n\n// Default head start for WebTransport before attempting the WebSocket fallback.\nconst DEFAULT_WEBSOCKET_DELAY = Duration.millis(500);\n\n// How long the first WebTransport dial may stay unopened before a second one dials alongside\n// it. The same moment as the WebSocket's default head start, so a fresh WebTransport flow\n// races the fallback rather than losing to it, which would leave the session on WebSocket for\n// good. A healthy open is about two round trips, so this spares round trips up to about\n// 250 ms, and it is inside the 2 s ceiling RFC 8305 recommends for staggered attempts.\nconst WEBTRANSPORT_HEDGE = DEFAULT_WEBSOCKET_DELAY;\n\n// How long a WebSocket dial may stay unopened before it is closed and dialed again. Generous,\n// since script cannot tell a silent connect from a slow one; Firefox and socket.io give a\n// WebSocket 20 s to open.\nconst WEBSOCKET_REDIAL = Duration.millis(10_000);\n\n// MoQ holds a stream open per subscription and per live group, far past qmux's default of\n// 100 each way, where the peer's opens are refused or wait on credit forever. Matches\n// `moq-tokio`'s `quic.max_streams`, the limit of Rust's sessions and the relay.\nconst DEFAULT_MAX_STREAMS = 10_000;\n\n// Match moq-tokio so WebSocket readers have the same bandwidth-delay budget.\nconst DEFAULT_RECEIVE_WINDOW = 4 << 20;\nconst DEFAULT_STREAM_RECEIVE_WINDOW = 4 << 20;\n\n// RESET_STREAM and CONNECTION_CLOSE are separate transport notifications. Give the latter\n// time to surface its authoritative code without letting a reset-only peer stall SETUP forever.\nconst SETUP_CLOSE_GRACE = Duration.millis(100);\n\n/** Tuning for the WebSocket fallback used when WebTransport is unavailable or loses the connect race. */\nexport interface WebSocketProps {\n\t/** Enable the WebSocket fallback. Defaults to `true`. */\n\tenabled?: boolean;\n\n\t/** Use a different URL than WebTransport. By default, `https` maps to `wss` and `http` to `ws`. */\n\turl?: URL;\n\n\t/**\n\t * The delay in milliseconds before attempting the WebSocket fallback (default: 500).\n\t * It is 0 while WebSocket holds the last win against the host and port the fallback dials,\n\t * until WebTransport wins a race there again.\n\t */\n\tdelay?: Duration;\n\n\t/**\n\t * How many streams the server may hold open at once, applied to bidirectional and\n\t * unidirectional streams alike (default: 10,000), like `moq-tokio`'s `quic.max_streams`.\n\t * MoQ holds a stream per subscription and per live group, so a low limit stalls or refuses them.\n\t * Must be a positive integer.\n\t */\n\tmaxStreams?: number;\n\n\t/** Connection receive window in bytes (default: 4 MiB). Must be a positive safe integer. */\n\treceiveWindow?: number;\n\n\t/** Per-stream receive window in bytes (default: 4 MiB). Must be a positive safe integer. */\n\tstreamReceiveWindow?: number;\n\n\t/**\n\t * How long the session may go without a frame before it closes, like `moq-tokio`'s\n\t * `quic.idle_timeout` on its QMux sessions (default: 30 s, longer than QUIC's 10 s because\n\t * TCP's retransmit backoff delays probes after an outage). A quiet session probes its peer\n\t * every 3/10 of it, and the session's `liveness` turns `stale` after two of those unheard.\n\t * `null` turns it off: when the server's is off too and it sets no PING interval, a quiet session then sends nothing, so a\n\t * server that sleeps between messages stays asleep, but a proxy with its own idle limit\n\t * (Cloudflare's is about 100 s) closes it. Only QMux drafts 01 and later negotiate it: a\n\t * `qmux-00` session runs no idle timer and never probes. Must be positive.\n\t */\n\tidleTimeout?: Duration | null;\n}\n\n/**\n * A server certificate hash used to pin a self-signed server, one entry of\n * `serverCertificateHashes`. Unlike the DOM type, `value` also accepts a hex string (the\n * format moq servers report via their certificate fingerprints), decoded automatically.\n */\nexport interface CertificateHash {\n\t/** The hash algorithm. Defaults to `sha-256` (the only supported value). */\n\talgorithm?: \"sha-256\";\n\t/** The certificate hash: raw bytes or a hex string. */\n\tvalue: BufferSource | string;\n}\n\n/**\n * WebTransport options extended with friendlier certificate pinning (hex hashes or a raw certificate).\n * The subprotocols come from {@link ConnectProps.versions}, shared with the WebSocket fallback.\n */\nexport interface WebTransportProps extends Omit<WebTransportOptions, \"serverCertificateHashes\" | \"protocols\"> {\n\t/**\n\t * Race WebTransport where the runtime supports it. Defaults to `true`; `false` dials only the\n\t * WebSocket fallback, which probes its peer and so reports the session's `liveness`.\n\t */\n\tenabled?: boolean;\n\n\t/**\n\t * Pin the server to one or more certificate hashes. Each `value` may be raw\n\t * bytes or a hex string; the algorithm defaults to `sha-256`.\n\t */\n\tserverCertificateHashes?: CertificateHash[];\n\n\t/**\n\t * Pin the server by supplying its certificate directly; the SHA-256 hash is\n\t * computed for you. Accepts a PEM string or raw DER bytes. Use this when you\n\t * have the certificate but not its precomputed fingerprint.\n\t */\n\tserverCertificate?: string | BufferSource;\n}\n\n// Each version name, most preferred first, with the ALPN that negotiates it. `setup` is the\n// version code offered in SETUP, used when the transport negotiated `moql` or no ALPN at all;\n// moq-transport has no version list in SETUP.\nconst VERSIONS: Record<string, { alpn: string; setup?: Lite.Version }> = {\n\t\"moq-lite-07\": { alpn: Lite.ALPN_07, setup: Lite.Version.DRAFT_07 },\n\t\"moq-lite-06\": { alpn: Lite.ALPN_06, setup: Lite.Version.DRAFT_06 },\n\t\"moq-lite-05\": { alpn: Lite.ALPN_05, setup: Lite.Version.DRAFT_05 },\n\t\"moq-lite-04\": { alpn: Lite.ALPN_04, setup: Lite.Version.DRAFT_04 },\n\t\"moq-lite-03\": { alpn: Lite.ALPN_03, setup: Lite.Version.DRAFT_03 },\n\t\"moq-lite-02\": { alpn: Lite.ALPN, setup: Lite.Version.DRAFT_02 },\n\t\"moq-lite-01\": { alpn: Lite.ALPN, setup: Lite.Version.DRAFT_01 },\n\t\"moq-transport-23\": { alpn: Ietf.ALPN.DRAFT_23 },\n\t\"moq-transport-22\": { alpn: Ietf.ALPN.DRAFT_22 },\n\t\"moq-transport-20\": { alpn: Ietf.ALPN.DRAFT_20 },\n\t\"moq-transport-18\": { alpn: Ietf.ALPN.DRAFT_18 },\n};\n\n// The partial draft-23 port is offered only when named.\nconst OPT_IN = new Set([\"moq-transport-23\"]);\nconst DEFAULT_VERSIONS = Object.keys(VERSIONS).filter((name) => !OPT_IN.has(name));\n\n// moq-transport is pinned to qmux-01. Every other ALPN is currently\n// negotiated as `qmux-00.{alpn}`, but `null` lets the polyfill advertise every QMux draft\n// it knows and the server pick one.\nconst QMUX: Record<string, QmuxVersion | QmuxVersion[] | null> = {\n\t[Ietf.ALPN.DRAFT_23]: \"qmux-01\",\n\t[Ietf.ALPN.DRAFT_22]: \"qmux-01\",\n\t[Ietf.ALPN.DRAFT_20]: \"qmux-01\",\n\t[Ietf.ALPN.DRAFT_18]: \"qmux-01\",\n};\n\n/** What one version list offers: the ALPNs in preference order, and the versions offered in SETUP. */\ninterface Offer {\n\talpns: string[];\n\tsetup: Lite.Version[];\n\t/** Whether the caller named the versions, so the peer must pick one of them. */\n\texplicit: boolean;\n\t/** Whether every offered version carries the connection credential in SETUP. */\n\tsetupToken: boolean;\n}\n\n// moq-lite gained the SETUP token in lite-07; every moq-transport draft has one.\nfunction hasSetupToken(name: string): boolean {\n\treturn !name.startsWith(\"moq-lite-\") || name === \"moq-lite-07\";\n}\n\nfunction offer(versions?: readonly string[]): Offer {\n\tconst names = versions ?? DEFAULT_VERSIONS;\n\tconst alpns = new Set<string>();\n\tconst setup: Lite.Version[] = [];\n\tfor (const name of names) {\n\t\tconst version = VERSIONS[name];\n\t\tif (!version) throw new TypeError(`unsupported version: ${name}`);\n\t\talpns.add(version.alpn);\n\t\tif (version.setup !== undefined) setup.push(version.setup);\n\t}\n\treturn { alpns: [...alpns], setup, explicit: versions !== undefined, setupToken: names.every(hasSetupToken) };\n}\n\n/** Copy a version list that can be offered, throwing a `TypeError` if it is empty or has an unsupported or duplicate name. */\nexport function checkVersions(versions: readonly string[]): string[] {\n\tif (versions.length === 0) throw new TypeError(\"versions must not be empty\");\n\tconst seen = new Set<string>();\n\tfor (const name of versions) {\n\t\tif (!Object.hasOwn(VERSIONS, name)) throw new TypeError(`unsupported version: ${name}`);\n\t\tif (seen.has(name)) throw new TypeError(`duplicate version: ${name}`);\n\t\tseen.add(name);\n\t}\n\treturn [...versions];\n}\n\n/**\n * What a server accepts of `versions` (spelled as {@link ConnectProps.versions}): the ALPNs, and the\n * moq-lite versions a `moql` SETUP may select. `undefined` accepts every supported version. @internal\n */\nexport function acceptable(versions?: readonly string[]): { alpns: string[]; setup: Lite.Version[] } | undefined {\n\treturn versions === undefined ? undefined : offer(checkVersions(versions));\n}\n\n/** Validate the transport options and snapshot an ordered version list before acquiring a connection. @internal */\nexport function normalizeVersions(props?: {\n\tversions?: readonly string[];\n\twebtransport?: WebTransportProps;\n\twebsocket?: WebSocketProps;\n}): string[] | undefined {\n\tif (props?.webtransport && \"protocols\" in props.webtransport)\n\t\tthrow new TypeError(\"webtransport.protocols was removed; set versions instead\");\n\tif (props?.websocket && \"protocols\" in props.websocket)\n\t\tthrow new TypeError(\"websocket.protocols was removed; set versions instead\");\n\tfor (const key of [\"maxStreams\", \"receiveWindow\", \"streamReceiveWindow\"] as const) {\n\t\tconst value = props?.websocket?.[key];\n\t\tif (value !== undefined && !(Number.isSafeInteger(value) && value > 0))\n\t\t\tthrow new RangeError(`websocket.${key} must be a positive safe integer: ${value}`);\n\t}\n\tconst idleTimeout = props?.websocket?.idleTimeout;\n\tif (\n\t\tidleTimeout !== undefined &&\n\t\tidleTimeout !== null &&\n\t\t!(!idleTimeout.isZero() && Number.isSafeInteger(Math.ceil(idleTimeout.asMillis())))\n\t)\n\t\tthrow new RangeError(`websocket.idleTimeout must be positive or null: ${idleTimeout}`);\n\treturn props?.versions === undefined ? undefined : checkVersions(props.versions);\n}\n\n/** Options for {@link Connection.connect}. */\nexport interface ConnectProps {\n\t/** The relay URL. */\n\turl: URL;\n\n\t/**\n\t * Protocol versions to offer on every transport, most preferred first, spelled like\n\t * `moq-lite-07`. Defaults to every supported version except the partial\n\t * `moq-transport-23`; list every fallback you still want. With a peer that negotiates no\n\t * subprotocol (such as WebTransport in Firefox before 155), the version is negotiated in\n\t * SETUP instead, which moq-transport cannot do.\n\t */\n\tversions?: readonly string[];\n\n\t/** WebTransport options. */\n\twebtransport?: WebTransportProps;\n\n\t/** WebSocket (fallback) options. */\n\twebsocket?: WebSocketProps;\n\n\t/**\n\t * Use a pre-existing WebTransport session instead of connecting; skips the\n\t * WebTransport/WebSocket race. The publisher acquires the session's datagram\n\t * writer lock (`datagrams.writable.getWriter()`) for the session's lifetime,\n\t * so the caller must not hold it. Aborting via {@link ConnectProps.signal}, or\n\t * {@link ConnectProps.timeout} passing, closes this session, so don't share one\n\t * you intend to reuse afterwards.\n\t */\n\ttransport?: WebTransport;\n\n\t/**\n\t * The origin whose broadcasts the session announces and serves to the peer. Omit to\n\t * publish nothing.\n\t *\n\t * The origin is borrowed, not owned: closing the session leaves its broadcasts alone,\n\t * and the same origin can back several sessions (or successive reconnects), each\n\t * announcing the table for as long as it lasts.\n\t */\n\tpublish?: OriginConsumer;\n\n\t/**\n\t * The origin the session feeds with the peer's announced broadcasts. Omit to discover\n\t * nothing.\n\t *\n\t * What the peer announces under the prefixes the origin's readers watch\n\t * (`announced(scope)`, `request(path)`, or `follow(path)`) appears in its table for\n\t * the session's lifetime, consumable by path; nothing is asked until something watches,\n\t * and the entries retract when the session dies. Pass the producer behind\n\t * {@link ConnectProps.publish} to route both directions through one origin: a locally\n\t * published path is then served back to local consumers directly, and the session still\n\t * never announces the peer's own broadcasts back to it.\n\t */\n\tconsume?: OriginProducer;\n\n\t/**\n\t * Price this link, in the units the rest of the mesh uses (moq-lite-06+, and moq-transport\n\t * via the MoQ Cluster extension). Added to the route cost of every announcement the peer\n\t * sends, and declared in SETUP so the peer adds it to every announcement we send. Wins over a\n\t * price the peer declares; an unpriced link costs 1, which routes by hop count. Zero is\n\t * refused on moq-lite-07. Rank the link with {@link OriginProducer.withPriority} on\n\t * {@link ConnectProps.consume}.\n\t */\n\tcost?: Cost;\n\n\t/**\n\t * Credentials to present, kept apart from the URL.\n\t *\n\t * The first is the connection credential: it rides SETUP, and the URL's `jwt` query too\n\t * while an offered version can't carry it in SETUP (moq-lite before 07). Each other token\n\t * rides its own AUTH stream, widening the session's grant. A URL that already has a `jwt`\n\t * keeps it as the connection credential, and then every token rides AUTH.\n\t */\n\ttokens?: readonly string[];\n\n\t/**\n\t * Carry the connection credential, the first of {@link ConnectProps.tokens}, in the URL's\n\t * `auth` query parameter instead of SETUP and `jwt`. For a relay that reads a credential of\n\t * its own from the URL and takes a SETUP token or `jwt` to be its own kind. The peer's\n\t * verdict on it is judged like any connection credential, and a credential in a `Signal` of\n\t * tokens is replaced for each dial without changing the URL. Replacing it on a live session\n\t * takes a redial: the new credential rides no AUTH stream, so `answered()` waits for it.\n\t *\n\t * An `auth` parameter the URL already has is replaced. A URL's own `jwt` still wins: then\n\t * every token rides AUTH. A supplied `transport` never dials the URL, so it refuses `urlAuth`.\n\t */\n\turlAuth?: boolean;\n\n\t/**\n\t * Build the session on `auth`, so it presents every token the handle holds and a route\n\t * naming one of its `Credential`s keeps it across a reconnect. Omit to give the session a handle\n\t * of its own, which ends with it.\n\t *\n\t * The handle backs one active session at a time, plus the ones draining after a GOAWAY or a\n\t * `close()`: connecting another while one is still active rejects with {@link Auth.Duplicate}.\n\t */\n\tauth?: Auth.Handle;\n\n\t/**\n\t * The implementation this side advertises in SETUP, a User-Agent style product token such as\n\t * `my-app/1.0`. Defaults to this library's, like `moq-net-js/0.4.2`. Empty sends nothing.\n\t */\n\timplementation?: string;\n\n\t/**\n\t * The viewers whose ceilings summed the session sends as its PROBE target, so a peer\n\t * that advertised `Increase` probes the connection up to it (moq-lite-05+). Omit to send\n\t * no target. The registry is borrowed, so the same one can span reconnects.\n\t */\n\tviewers?: Viewers;\n\n\t/**\n\t * Maximum time for one connect, covering the dial and the MoQ handshake, which has no\n\t * deadline of its own (default: 30 s). `null` waits forever. Past it, the connect rejects\n\t * with {@link ConnectTimeout} and closes whatever it had opened.\n\t */\n\ttimeout?: Duration | null;\n\n\t/**\n\t * Aborts the connection attempt with the signal's reason. An already-aborted\n\t * signal rejects before anything opens, and aborting after the connection is\n\t * established has no effect. Set {@link ConnectProps.timeout} for a deadline.\n\t */\n\tsignal?: AbortSignal;\n}\n\n/** The per-session wiring shared by every negotiated protocol path. */\ntype SessionProps = {\n\tpublish?: OriginConsumer;\n\t/** The auth handle the session is built on, or undefined for one of its own. */\n\thandle?: Auth.Handle;\n\t/** Whether this side dialed; only the dialing side aborts on a publication its grant does not cover. */\n\tclient: boolean;\n\t/** The connection credential SETUP presents, on versions that carry one. */\n\ttoken?: Uint8Array;\n\t/** The implementation this side advertises in SETUP; empty sends nothing. */\n\timplementation: string;\n\t/** The PROBE target to send a peer that advertised `Increase`. */\n\tprobeTarget?: Getter<number>;\n\t/** The peer's liveness, on a transport that probes it. */\n\tliveness?: Getter<Liveness.Liveness>;\n} & Link;\n\n/**\n * Servers (host and port) the WebSocket fallback dials where WebSocket won the last race, so the\n * next dial there skips QUIC's head start. Both transports still race. The entry is provisional:\n * a WebTransport win or {@link reachable} probe deletes it, since UDP gets through again, and so\n * does the end of the MoQ session the winning WebSocket carried, so a redial after an outage gives WebTransport\n * its head start. Keyed like moq-tokio's: whether UDP reaches a server does not depend on the\n * path or query, which may hold a rotating credential.\n */\nconst websocketWon = new Set<string>();\n\n/** The {@link websocketWon} key for the URL the WebSocket fallback dials. */\nfunction websocketKey(url: URL): string {\n\tconst endpoint = parse(url);\n\treturn `${endpoint.url.hostname}:${endpoint.port}`;\n}\n\n/** The default connect signal: never aborts. */\nconst NEVER_ABORTED = new AbortController().signal;\n\n/**\n * Establishes a connection to a MOQ server.\n *\n * @returns A promise that resolves to an established session\n */\nexport function connect(props: ConnectProps): Promise<Session> {\n\treturn establish(props);\n}\n\n/**\n * {@link connect}, finishing the MoQ handshake over `reached`, a WebTransport session a\n * {@link reachable} probe opened, instead of racing the transports.\n *\n * @internal\n */\nexport async function establish({ url, ...props }: ConnectProps, reached?: Reached): Promise<Session> {\n\tif (\"discovery\" in props) throw new TypeError(DISCOVERY_REMOVED);\n\tprops.versions = normalizeVersions(props);\n\tif (props.transport && props.versions) throw new TypeError(\"versions cannot reconfigure a supplied transport\");\n\t// The URL is never dialed for a supplied transport, so the credential it carries would be dropped.\n\tif (props.transport && props.urlAuth) throw new TypeError(\"urlAuth cannot reach a supplied transport\");\n\tconst signal = props.signal ?? NEVER_ABORTED;\n\tif (signal.aborted) reached?.transport.close();\n\tsignal.throwIfAborted();\n\t// Fail before dialing; the session checks again when it attaches.\n\tif (props.auth) vacant(props.auth);\n\tcheckCost(props.cost);\n\tconst limit = connectTimeout(props.timeout);\n\n\t// Resolves on abort or timeout so every in-flight transport tears itself down.\n\tconst { promise: abort, resolve } = Promise.withResolvers<void>();\n\tconst onAbort = () => resolve();\n\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\n\tlet expired: ConnectTimeout | undefined;\n\tconst disarm =\n\t\tlimit !== null\n\t\t\t? after(limit, () => {\n\t\t\t\t\texpired = new ConnectTimeout(limit);\n\t\t\t\t\tresolve();\n\t\t\t\t})\n\t\t\t: () => {};\n\n\tconst tokens = reached?.tokens ?? props.tokens ?? [];\n\tconst pending = connectInner(url, tokens, props, abort, reached?.transport);\n\ttry {\n\t\t// A `pending` rejection propagates unless the abort or timeout beat it to the finish line.\n\t\tconst connected = await Promise.race([pending, abort.then(() => undefined)]);\n\t\tif (connected && !signal.aborted && !expired) {\n\t\t\tconst [connection, dial] = connected;\n\t\t\tif (props.consume) forwardAnnounced(connection, props.consume);\n\t\t\t// Before the caller sees the session, so its first requests wait on these answers.\n\t\t\thold(connection, dial, tokens);\n\t\t\treturn connection;\n\t\t}\n\n\t\t// Close a connection that settles after the abort or timeout.\n\t\tpending.then(([conn]) => conn.abort()).catch(() => {});\n\t\t// The caller's abort is teardown and wins over the timeout.\n\t\tthrow signal.aborted ? signal.reason : expired;\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\tdisarm();\n\t}\n}\n\n/**\n * A WebTransport session a {@link reachable} probe opened, and the tokens its dial presented.\n *\n * @internal\n */\nexport class Reached {\n\treadonly transport: WebTransport;\n\treadonly tokens: readonly string[];\n\n\tconstructor(transport: WebTransport, tokens: readonly string[]) {\n\t\tthis.transport = transport;\n\t\tthis.tokens = tokens;\n\t}\n}\n\n/**\n * Open a bare WebTransport session to `url`, for a session on the WebSocket fallback deciding\n * to move back. It presents what a dial would and runs no MoQ handshake: {@link establish}\n * finishes that over it, or the caller closes it. Reaching it clears the WebSocket win.\n * Resolves undefined on failure, after `props.timeout`, or once `signal` aborts.\n *\n * @internal\n */\nexport async function reachable(\n\turl: URL,\n\tprops: Pick<ConnectProps, \"tokens\" | \"urlAuth\" | \"versions\" | \"webtransport\" | \"websocket\" | \"timeout\">,\n\tsignal: AbortSignal,\n): Promise<Reached | undefined> {\n\tif (!webTransportDialed(props.webtransport) || signal.aborted) return undefined;\n\tconst tokens = props.tokens ?? [];\n\tconst offered = offer(normalizeVersions(props));\n\tconst carrier = { setupToken: offered.setupToken, urlAuth: props.urlAuth };\n\tconst dialUrl = parse(credential(url, tokens, carrier).url).url;\n\tconst { promise: cancel, resolve } = Promise.withResolvers<void>();\n\tconst onAbort = () => resolve();\n\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\tconst limit = connectTimeout(props.timeout);\n\tconst disarm = limit !== null ? after(limit, resolve) : () => {};\n\ttry {\n\t\tconst target = await resolveWebTransport(dialUrl, cancel, offered.alpns, props.webtransport);\n\t\tconst quic = target && (await dialWebTransport(target, cancel));\n\t\tif (!quic) return undefined;\n\t\tif (signal.aborted) {\n\t\t\tquic.close();\n\t\t\treturn undefined;\n\t\t}\n\t\twebsocketWon.delete(websocketKey(props.websocket?.url ? new URL(props.websocket.url) : dialUrl));\n\t\treturn new Reached(quic, tokens);\n\t} catch {\n\t\treturn undefined;\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\tdisarm();\n\t}\n}\n\n/** Dial `raw`, resolving with the session and the credential the winning transport presented. */\nasync function connectInner(\n\traw: URL,\n\ttokens: readonly string[],\n\tprops: Omit<ConnectProps, \"url\">,\n\tabort: Promise<void>,\n\treached?: WebTransport,\n): Promise<[Session, Presentation]> {\n\tconst offered = offer(props.versions);\n\tconst carrier = { setupToken: offered.setupToken, urlAuth: props.urlAuth };\n\tconst dial = credential(raw, tokens, carrier);\n\tconst url = parse(dial.url).url;\n\tconst fallbackDial = props.websocket?.url && fallback(raw, props.websocket.url, tokens, carrier);\n\tconst wiring = (presented: Presentation): SessionProps => ({\n\t\tpublish: props.publish,\n\t\thandle: props.auth,\n\t\tclient: true,\n\t\ttoken: presented.setup === undefined ? undefined : new TextEncoder().encode(presented.setup),\n\t\timplementation: props.implementation ?? IMPLEMENTATION,\n\t\tprobeTarget: props.viewers?.target,\n\t\t...link(props),\n\t});\n\n\tif (props.transport) {\n\t\tconst transport = props.transport;\n\t\tvoid abort.then(() => transport.close());\n\t\tlet liveness: Getter<Liveness.Liveness> | undefined;\n\t\ttry {\n\t\t\tliveness = await Liveness.watch(transport);\n\t\t} catch (err) {\n\t\t\ttransport.close();\n\t\t\tthrow err;\n\t\t}\n\t\treturn [await connectTransport(url, transport, { ...wiring(dial), liveness }, offered.setup), dial];\n\t}\n\n\tconst websocketUrl = fallbackDial?.url ?? url;\n\tconst server = websocketKey(websocketUrl);\n\t// A probe already reached WebTransport, so there is nothing to race.\n\tconst session = reached ?? (await dialRace(url, websocketUrl, server, props, offered, abort));\n\tif (!session) throw new Error(\"no transport available\");\n\n\t// Abort the setup handshake without leaking the selected transport.\n\tvoid abort.then(() => session.close());\n\n\t// Record who won the race to this server, so QUIC's next head start follows the last result.\n\t// A dial that left WebTransport out raced nothing, so it records nothing.\n\tconst websocket = transportOf(session) === \"websocket\";\n\tconst raced = webTransportDialed(props.webtransport);\n\tif (websocket) {\n\t\tconsole.debug(show(parse(url)), \"connected via WebSocket\");\n\t\tif (raced) websocketWon.add(server);\n\t} else {\n\t\tconsole.debug(show(parse(url)), \"connected via WebTransport\");\n\t\twebsocketWon.delete(server);\n\t}\n\n\t// The remaining setup is identical whether the transport was raced or supplied.\n\tconst protocol = (session as { protocol?: string }).protocol || undefined;\n\tif (offered.explicit && protocol && !offered.alpns.includes(protocol)) {\n\t\tsession.close();\n\t\tthrow new Error(`server selected an unoffered protocol: ${protocol}`);\n\t}\n\tif (offered.explicit && !protocol && offered.setup.length === 0) {\n\t\tsession.close();\n\t\tthrow new Error(\"server negotiated no protocol, and no offered version negotiates in SETUP\");\n\t}\n\tconst won = websocket && fallbackDial ? fallbackDial : dial;\n\tlet liveness: Getter<Liveness.Liveness> | undefined;\n\ttry {\n\t\tliveness = await Liveness.watch(session as WebTransport);\n\t} catch (err) {\n\t\tsession.close();\n\t\tthrow err;\n\t}\n\tconst connection = await connectTransport(\n\t\turl,\n\t\tsession as WebTransport,\n\t\t{ ...wiring(won), liveness },\n\t\toffered.setup,\n\t);\n\tif (websocket && raced) {\n\t\tconst forget = () => websocketWon.delete(server);\n\t\tvoid connection.closed.then(forget, forget);\n\t}\n\treturn [connection, won];\n}\n\n/** Race WebTransport against the WebSocket fallback to `url`, resolving with the winner. */\nasync function dialRace(\n\turl: URL,\n\twebsocketUrl: URL,\n\tserver: string,\n\tprops: Omit<ConnectProps, \"url\">,\n\toffered: Offer,\n\tabort: Promise<void>,\n): Promise<WebTransport | Qmux | undefined> {\n\t// Stop transports after one connects or the caller aborts.\n\tconst { promise: raced, resolve: done } = Promise.withResolvers<void>();\n\tconst cancel = Promise.race([raced, abort]);\n\n\tconst webtransport = webTransportDialed(props.webtransport)\n\t\t? hedgeWebTransport(url, cancel, offered.alpns, props.webtransport)\n\t\t: undefined;\n\n\t// Give QUIC a head start to connect before trying WebSocket, unless WebSocket won the last race\n\t// to this server. NOTE that QUIC should be faster because it involves 1/2 fewer RTTs.\n\tconst headstart =\n\t\t!webtransport || websocketWon.has(server) ? Duration.ZERO : (props.websocket?.delay ?? DEFAULT_WEBSOCKET_DELAY);\n\tconst websocket =\n\t\tprops.websocket?.enabled !== false\n\t\t\t? connectWebSocket(websocketUrl, headstart, cancel, {\n\t\t\t\t\t// The default (`requireProtocol: false`) also advertises the bare `qmux-02`,\n\t\t\t\t\t// `qmux-01`, and `qmux-00`, so we still interop with relays that only know a\n\t\t\t\t\t// wire-format version.\n\t\t\t\t\tprotocols: offered.alpns,\n\t\t\t\t\tversions: Object.fromEntries(offered.alpns.map((alpn) => [alpn, QMUX[alpn] ?? null])),\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tmaxStreams: props.websocket?.maxStreams ?? DEFAULT_MAX_STREAMS,\n\t\t\t\t\t\treceiveWindow: props.websocket?.receiveWindow ?? DEFAULT_RECEIVE_WINDOW,\n\t\t\t\t\t\tstreamReceiveWindow: props.websocket?.streamReceiveWindow ?? DEFAULT_STREAM_RECEIVE_WINDOW,\n\t\t\t\t\t\tidleTimeout: props.websocket?.idleTimeout,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t: undefined;\n\n\tif (!websocket && !webtransport) {\n\t\tthrow new Error(\"no transport available; WebTransport is unsupported or disabled, and WebSocket is disabled\");\n\t}\n\n\t// Race the available transports, using `.any` to ignore if one participant has an error.\n\t// `webtransport`/`websocket` are `Promise | undefined`, so test existence explicitly: a\n\t// promise is always truthy, so bare truthiness here would be a misused-promise.\n\tconst contenders: Promise<WebTransport | Qmux | undefined>[] = [];\n\tif (websocket !== undefined) contenders.push(websocket);\n\tif (webtransport !== undefined) contenders.push(webtransport);\n\tconst session = await Promise.any(contenders).catch((err: unknown) => {\n\t\t// Promise.any rejects with an empty message; name each transport's failure instead.\n\t\tif (!(err instanceof AggregateError)) throw err;\n\t\tconst reasons = err.errors.map((e: unknown) => (e instanceof Error ? e.message : String(e)));\n\t\tthrow new Error(`no transport connected: ${reasons.join(\"; \")}`, { cause: err });\n\t});\n\tdone();\n\t// A contender that opened in the same turn as the winner has already returned its\n\t// transport, so cancelling cannot close it; the rest close themselves on cancel.\n\tcloseLosers(contenders, session);\n\n\treturn session;\n}\n\nasync function connectTransport(\n\turl: URL,\n\tsession: WebTransport,\n\twiring: SessionProps,\n\tsetup: Lite.Version[],\n): Promise<Session> {\n\tconst closed = session.closed.then(fromClose, error);\n\tconst terminal = closed.then((cause) => {\n\t\tthrow cause ?? new Error(\"session closed during SETUP\");\n\t});\n\n\ttry {\n\t\treturn await Promise.race([terminal, inspect(session).then(() => negotiate(url, session, wiring, setup))]);\n\t} catch (failure) {\n\t\t// We refused the peer's SETUP and already closed with the code that says why.\n\t\tif (failure instanceof ProtocolViolation) throw failure;\n\t\t// A session failure already guarantees a terminal close; its authoritative code\n\t\t// must not be overwritten by the reset-only fallback while the browser delivers it.\n\t\tconst cause = await sessionCause(session, failure);\n\t\t// A session shutdown can reject its SETUP stream before `closed` publishes the\n\t\t// peer's close code. Wait briefly without closing locally, since a local clean close\n\t\t// could overwrite that code. A reset-only peer is cleaned up after the grace period.\n\t\tconst pending = Symbol(\"session close pending\");\n\t\tconst final = await Promise.race([closed, sleep(SETUP_CLOSE_GRACE).then(() => pending)]);\n\t\tif (final !== pending) {\n\t\t\tif (final) throw final;\n\t\t\tthrow cause;\n\t\t}\n\n\t\tsession.close();\n\t\tthrow cause;\n\t}\n}\n\n// Negotiate the MoQ protocol over an established transport. The caller races this against\n// the session closing so a close code is not lost behind a failed or stalled SETUP stream.\n// `setup` lists the versions a `moql` or ALPN-less session offers in SETUP.\n// A moq-lite version newer than 02 selected there continues as its ALPN would.\nasync function negotiate(\n\turl: URL,\n\tsession: WebTransport,\n\twiring: SessionProps,\n\tsetup: Lite.Version[],\n): Promise<Session> {\n\t// The DOM lib has no `protocol` property yet. It is \"\" when none was negotiated, and\n\t// undefined in a browser that predates subprotocols (Firefox before 155).\n\tconst protocol: string | undefined = (session as { protocol?: string }).protocol || undefined;\n\tconsole.debug(show(parse(url)), \"negotiated ALPN:\", protocol ?? \"(none)\");\n\n\tconst ietf =\n\t\tprotocol === Ietf.ALPN.DRAFT_23\n\t\t\t? Ietf.Version.DRAFT_23\n\t\t\t: protocol === Ietf.ALPN.DRAFT_22\n\t\t\t\t? Ietf.Version.DRAFT_22\n\t\t\t\t: protocol === Ietf.ALPN.DRAFT_20\n\t\t\t\t\t? Ietf.Version.DRAFT_20\n\t\t\t\t\t: protocol === Ietf.ALPN.DRAFT_18\n\t\t\t\t\t\t? Ietf.Version.DRAFT_18\n\t\t\t\t\t\t: undefined;\n\tif (ietf !== undefined) {\n\t\treturn await handshakeAlpn(url, session, ietf, wiring);\n\t} else if (protocol === Lite.ALPN_07) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_07, ...wiring });\n\t} else if (protocol === Lite.ALPN_06) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_06, ...wiring });\n\t} else if (protocol === Lite.ALPN_05) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_05, ...wiring });\n\t} else if (protocol === Lite.ALPN_04) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_04, ...wiring });\n\t} else if (protocol === Lite.ALPN_03) {\n\t\treturn new Lite.Connection({ url, quic: session, version: Lite.Version.DRAFT_03, ...wiring });\n\t} else if (protocol !== Lite.ALPN && protocol !== undefined) {\n\t\tthrow new Error(`unsupported WebTransport protocol: ${protocol}`);\n\t}\n\n\t// `moql`, or no subprotocol: negotiate moq-lite in SETUP, which keeps lite-02's framing\n\t// whichever version it offers.\n\tif (setup.length === 0) throw new Error(\"no version negotiates in SETUP\");\n\tconst stream = await Stream.open(session, { version: Lite.Version.DRAFT_02 });\n\tawait new Lite.ClientSetup(setup).encode(stream.writer);\n\tconst server = await Lite.ServerSetup.decode(stream.reader);\n\tconst version = setup.find((v) => v === server.version);\n\tif (version === undefined) throw new Error(`unsupported server version: 0x${server.version.toString(16)}`);\n\tif (handsOff(version)) {\n\t\t// The server ends the stream after its SETUP; nothing else may follow.\n\t\tif (!(await stream.reader.done())) throw new Error(\"unexpected data after SERVER_SETUP\");\n\t\tstream.close();\n\t\treturn new Lite.Connection({ url, quic: session, version, ...wiring });\n\t}\n\treturn new Lite.Connection({ url, quic: session, version, session: stream, ...wiring });\n}\n\n/**\n * Moq-transport client handshake. ALPN already pinned the version; SETUP is\n * exchanged over a pair of uni streams using stream type 0x2F00.\n */\nasync function handshakeAlpn(\n\turl: URL,\n\tsession: WebTransport,\n\tversion: Ietf.IetfVersion,\n\twiring: SessionProps,\n): Promise<Session> {\n\t// Spread whole, so every negotiated flag reaches the connection.\n\t// The IETF session code loads on demand, since most sessions negotiate lite; the ALPN already\n\t// committed to IETF, so fetch it alongside SETUP.\n\tconst [setup, { Connection }] = await Promise.all([\n\t\texchangeSetup(session, version, wiring.implementation, wiring),\n\t\timport(\"../ietf/connection.ts\"),\n\t]);\n\n\treturn new Connection({\n\t\t...wiring,\n\t\tclient: true,\n\t\turl,\n\t\tquic: session,\n\t\t...setup,\n\t\tversion,\n\t});\n}\n\n// One entry of the DOM `serverCertificateHashes`, derived without naming the lib type.\ntype WebTransportHash = NonNullable<WebTransportOptions[\"serverCertificateHashes\"]>[number];\n\n// Strip PEM armor and base64-decode to the raw DER bytes.\nfunction pemToDer(pem: string): Uint8Array<ArrayBuffer> {\n\t// indexOf rather than a lazy regex, which goes quadratic on repeated BEGIN lines without an END.\n\tconst begin = \"-----BEGIN CERTIFICATE-----\";\n\tconst start = pem.indexOf(begin);\n\tconst end = start < 0 ? -1 : pem.indexOf(\"-----END CERTIFICATE-----\", start + begin.length);\n\tconst body = end < 0 ? \"\" : pem.slice(start + begin.length, end).replace(/\\s+/g, \"\");\n\tif (!body) {\n\t\tthrow new Error(\"invalid PEM certificate: missing -----BEGIN/END CERTIFICATE----- armor\");\n\t}\n\n\tconst binary = atob(body);\n\tconst der = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tder[i] = binary.charCodeAt(i);\n\t}\n\treturn der;\n}\n\n/**\n * Compute the SHA-256 hash of a certificate, the value `serverCertificateHashes`\n * pins. Accepts a PEM string or raw DER bytes. Matches the hex fingerprints a moq\n * server reports, so `Hex.fromBytes(await certificateHash(pem))` round-trips.\n */\nexport async function certificateHash(cert: string | BufferSource): Promise<Uint8Array<ArrayBuffer>> {\n\tconst der = typeof cert === \"string\" ? pemToDer(cert) : cert;\n\tconst digest = await crypto.subtle.digest(\"SHA-256\", der);\n\treturn new Uint8Array(digest);\n}\n\n// Normalize our friendlier pinning options into the DOM `serverCertificateHashes`.\nasync function resolveCertificateHashes(options?: WebTransportProps): Promise<WebTransportHash[] | undefined> {\n\tconst hashes: WebTransportHash[] = [];\n\n\tfor (const hash of options?.serverCertificateHashes ?? []) {\n\t\tconst value = typeof hash.value === \"string\" ? Hex.toBytes(hash.value) : hash.value;\n\t\thashes.push({ algorithm: hash.algorithm ?? \"sha-256\", value });\n\t}\n\n\tif (options?.serverCertificate !== undefined) {\n\t\thashes.push({ algorithm: \"sha-256\", value: await certificateHash(options.serverCertificate) });\n\t}\n\n\treturn hashes.length > 0 ? hashes : undefined;\n}\n\n// Close every transport the race opened other than `winner`.\nfunction closeLosers(contenders: Promise<WebTransport | Qmux | undefined>[], winner: unknown): void {\n\tfor (const contender of contenders) {\n\t\tvoid contender.then(\n\t\t\t(transport) => {\n\t\t\t\tif (transport && transport !== winner) transport.close();\n\t\t\t},\n\t\t\t() => {},\n\t\t);\n\t}\n}\n\n/**\n * Dial WebTransport, and dial it again alongside if the first has not opened within\n * {@link WEBTRANSPORT_HEDGE}. The first to open wins and the other is closed.\n *\n * A load balancer that still places some new flows on a target that just died sends every\n * packet of such a flow there, and the browser waits seconds before failing the dial. A\n * second dial is a new flow that the balancer places afresh. Neither dial is cut on a timer of\n * its own, only by the attempt's {@link ConnectProps.timeout}: the browser's handshake timer\n * tells a silent dial from a slow one, which script cannot, and every dial the browser fails\n * or abandons counts against its WebTransport throttle. A first dial that fails outright is\n * not hedged; that is left to the caller's retry.\n */\nasync function hedgeWebTransport(\n\turl: URL,\n\tcancel: Promise<void>,\n\talpns: string[],\n\toptions?: WebTransportProps,\n): Promise<WebTransport | undefined> {\n\t// Resolve pins (and fetch an http:// fingerprint) once, before the hedge delay starts, so a slow\n\t// fingerprint fetch can't start a second dial and both dials share the one fetch.\n\tconst target = await resolveWebTransport(url, cancel, alpns, options);\n\tif (!target) return undefined;\n\n\tconst first = dialWebTransport(target, cancel);\n\n\t// The first dial opening, failing, or being cancelled settles this before the delay does.\n\tconst hedge = await timeout(WEBTRANSPORT_HEDGE, first).then(\n\t\t() => false,\n\t\t(err: unknown) => err instanceof Elapsed,\n\t);\n\tif (!hedge) return first;\n\tconsole.debug(show(parse(url)), `WebTransport not open after ${WEBTRANSPORT_HEDGE}; dialing a second`);\n\n\tconst dials = [first, dialWebTransport(target, cancel)];\n\ttry {\n\t\tconst winner = await Promise.any(dials);\n\t\tcloseLosers(dials, winner);\n\t\treturn winner;\n\t} catch (err) {\n\t\t// Both failed. Report the first dial's reason, as when there is no hedge, so `no transport\n\t\t// connected` keeps one reason per transport; a browser words every handshake failure alike.\n\t\tthrow (err as AggregateError).errors[0];\n\t}\n}\n\ninterface WebTransportTarget {\n\turl: URL;\n\toptions: WebTransportOptions;\n}\n\n/** Resolve the URL and options to dial, or `undefined` once `cancel` resolves. */\nasync function resolveWebTransport(\n\turl: URL,\n\tcancel: Promise<void>,\n\talpns: string[],\n\toptions?: WebTransportProps,\n): Promise<WebTransportTarget | undefined> {\n\tlet finalUrl = url;\n\n\t// Our custom pinning fields are normalized separately; the rest are DOM options.\n\tconst {\n\t\tenabled: _enabled,\n\t\tserverCertificate: _cert,\n\t\tserverCertificateHashes: _hashes,\n\t\t...webtransport\n\t} = options ?? {};\n\n\tconst finalOptions: WebTransportOptions = {\n\t\tallowPooling: false,\n\t\tcongestionControl: \"low-latency\",\n\t\t...webtransport,\n\t\tprotocols: alpns,\n\t};\n\n\t// Accumulate caller-provided pins first, then append anything we fetch below,\n\t// so a fetched fingerprint never clobbers hashes passed in via options.\n\tconst hashes = (await resolveCertificateHashes(options)) ?? [];\n\n\t// Only perform certificate fetch and URL rewrite when polyfill is not needed\n\t// This is needed because WebTransport is a butt to work with in local development.\n\tif (url.protocol === \"http:\") {\n\t\tconst fingerprintUrl = new URL(url);\n\t\tfingerprintUrl.pathname = \"/certificate.sha256\";\n\t\t// The certificate endpoint is unauthenticated, so don't hand it the token.\n\t\tfingerprintUrl.search = \"\";\n\n\t\t// Dev-only path: http:// can't be a real WebTransport origin, so we fetch the\n\t\t// self-signed cert's hash over plain HTTP and pin it. Production uses https://\n\t\t// and never reaches here. Keep this at debug so it doesn't read as a problem.\n\t\tconsole.debug(\n\t\t\tshow(parse(fingerprintUrl)),\n\t\t\t\"performing an insecure fingerprint fetch; use https:// in production\",\n\t\t);\n\n\t\tconst fingerprint = await fetchFingerprint(fingerprintUrl, cancel);\n\t\tif (!fingerprint) return undefined;\n\n\t\thashes.push({ algorithm: \"sha-256\", value: fingerprint });\n\n\t\tfinalUrl = new URL(url);\n\t\tfinalUrl.protocol = \"https:\";\n\t}\n\n\tif (hashes.length > 0) {\n\t\tfinalOptions.serverCertificateHashes = hashes;\n\t}\n\n\treturn { url: finalUrl, options: finalOptions };\n}\n\nasync function dialWebTransport(target: WebTransportTarget, cancel: Promise<void>): Promise<WebTransport | undefined> {\n\tconst quic = new WebTransport(target.url, target.options);\n\n\t// Both .ready and .closed reject on failure; catch .closed to avoid an unhandled rejection.\n\tquic.closed.catch(() => {});\n\n\t// Wait for the WebTransport to connect, or for the cancel promise to resolve.\n\t// Close the connection if we lost the race.\n\tconst loaded = await Promise.race([quic.ready.then(() => true), cancel]);\n\tif (!loaded) {\n\t\tquic.close();\n\t\treturn undefined;\n\t}\n\n\treturn quic;\n}\n\n/** A SHA-256 certificate fingerprint is 32 bytes, served as this many hex characters. */\nconst FINGERPRINT_HEX_LENGTH = 64;\n\n/**\n * Fetch the SHA-256 certificate fingerprint served at `url`, or `undefined` once `cancel` resolves.\n *\n * Resolving `cancel` aborts the request. The body is read chunk by chunk and refused at the first\n * chunk that takes it past a fingerprint, so a reply with no `Content-Length` cannot accumulate:\n * it holds at most a fingerprint plus the one chunk the network stack handed over.\n */\nasync function fetchFingerprint(url: URL, cancel: Promise<void>): Promise<Uint8Array<ArrayBuffer> | undefined> {\n\tconst controller = new AbortController();\n\tvoid cancel.then(() => controller.abort());\n\n\ttry {\n\t\tconst response = await fetch(url, { signal: controller.signal });\n\t\tif (!response.ok) throw new Error(`fingerprint fetch failed: HTTP ${response.status}`);\n\n\t\tconst body = new Uint8Array(FINGERPRINT_HEX_LENGTH);\n\t\tlet length = 0;\n\t\tconst reader = response.body?.getReader();\n\t\tfor (;;) {\n\t\t\tconst chunk = await reader?.read();\n\t\t\tif (!chunk || chunk.done) break;\n\t\t\tif (length + chunk.value.byteLength > body.length) {\n\t\t\t\tthrow new Error(`fingerprint is longer than ${FINGERPRINT_HEX_LENGTH} hex characters`);\n\t\t\t}\n\t\t\tbody.set(chunk.value, length);\n\t\t\tlength += chunk.value.byteLength;\n\t\t}\n\t\tif (length !== body.length) {\n\t\t\tthrow new Error(`fingerprint is ${length} characters, expected ${FINGERPRINT_HEX_LENGTH} hex characters`);\n\t\t}\n\n\t\treturn Hex.toBytes(new TextDecoder().decode(body));\n\t} catch (err) {\n\t\t// Cancelled: another transport won or the caller aborted, which is no failure of this dial.\n\t\tif (controller.signal.aborted) return undefined;\n\t\tthrow err;\n\t} finally {\n\t\t// Releases the request and cancels any unread body, whichever way this ended.\n\t\tcontroller.abort();\n\t}\n}\n\n// TODO accept arguments to control the port/path used.\n/**\n * Dial the WebSocket fallback after `delay`, and if a dial has not opened within\n * {@link WEBSOCKET_REDIAL}, close it and dial again, doubling the wait each time.\n *\n * A browser lets one WebSocket to an address be connecting at a time (RFC 6455 section 4.1),\n * so a second dial alongside a silent one only queues behind it, and a TCP connect whose SYNs\n * go unanswered waits for the OS's connect timeout. Closing the silent dial lets the next one\n * start, on a new connection that a load balancer places afresh. The doubling lets a\n * slow but working path through, and {@link ConnectProps.timeout} bounds the whole attempt. A\n * dial that fails outright is not redialed.\n */\nasync function connectWebSocket(\n\turl: URL,\n\tdelay: Duration,\n\tcancel: Promise<void>,\n\toptions: QmuxOptions,\n): Promise<Qmux | undefined> {\n\tconst active = await race([cancel, sleep(delay).then(() => true)]);\n\tif (!active) return undefined;\n\n\t// qmux loads only once the fallback dials, so a session WebTransport wins within its head\n\t// start never downloads it.\n\tconst qmux = await race([cancel, import(\"@moq/qmux\")]);\n\tif (!qmux) return undefined;\n\tconst { Session } = qmux;\n\n\tfor (let wait = WEBSOCKET_REDIAL; ; wait = wait.mul(2)) {\n\t\tconst quic = new Session(url, options);\n\n\t\t// Wait for the WebSocket to connect, for the cancel promise to resolve, or for the\n\t\t// redial. `ready` rejects on a refused/failed connection, so a throw here is the\n\t\t// caller's cue to retry; a lost cancel race instead resolves and we close the loser.\n\t\tconst disarm = new AbortController();\n\t\ttry {\n\t\t\t// `race` rather than `Promise.race`, and `cancel` itself rather than something derived\n\t\t\t// from it: `cancel` outlives every dial, and `race` releases what it attached.\n\t\t\tconst outcome = await race([\n\t\t\t\tquic.ready.then(() => \"open\" as const),\n\t\t\t\tcancel,\n\t\t\t\tsleep(wait, { signal: disarm.signal }).then(() => \"redial\" as const),\n\t\t\t]);\n\t\t\tif (outcome === \"open\") return quic;\n\t\t\tquic.close();\n\t\t\tif (outcome !== \"redial\") return undefined;\n\t\t\tconsole.debug(show(parse(url)), `WebSocket not open after ${wait}; dialing again`);\n\t\t} finally {\n\t\t\tdisarm.abort();\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,45 @@
1
+ /** One dial of a connection, waiting for the tokens it presents. */
2
+ export declare class Dial {
3
+ #private;
4
+ /** Where the dial goes: the connection's URL, or the relay a GOAWAY redirected it to. */
5
+ readonly url: URL;
6
+ /**
7
+ * Why the previous attempt or session ended, such as a refused credential or a redirect before
8
+ * the session was healthy, or undefined when nothing failed since a session last served, as
9
+ * for the first dial or a healthy session's GOAWAY handover.
10
+ */
11
+ readonly failure?: Error;
12
+ /** Aborted once the connection no longer waits for this dial's tokens: on close, or past the connect timeout. */
13
+ readonly signal: AbortSignal;
14
+ private constructor();
15
+ /**
16
+ * Present `tokens` on this dial, as a fixed list would be; the first answer counts. Only the
17
+ * first, the connection credential, is this dial's alone: the rest join the connection's
18
+ * shared set, which a successor attaches to before its own answer replaces them, so a
19
+ * single-use token belongs first.
20
+ */
21
+ present(tokens: readonly string[]): void;
22
+ /**
23
+ * Stop the connection with `err` instead of dialing, as for a {@link failure} no retry can
24
+ * repair. A probe back to WebTransport, which the serving session does without, is skipped instead.
25
+ */
26
+ fail(err: Error): void;
27
+ }
28
+ /**
29
+ * Tokens a connection asks for at each dial, for a credential that must be fresh when it is
30
+ * presented, such as a proof a peer admits once and only shortly after it was signed. Pass it as
31
+ * a connection's `tokens` and answer each {@link next} dial: every dial waits for its answer,
32
+ * whatever starts it, a reconnect, a GOAWAY's handover, a page resuming, or a probe back to
33
+ * WebTransport, so none presents tokens signed for another.
34
+ *
35
+ * A URL never reached stops at its first failure, as with fixed tokens, reported on the
36
+ * connection's `error` with no further dial to ask. Once a session was established, answering is
37
+ * how a connection retries: it backs off and asks again, with the reason on
38
+ * {@link Dial.failure}, until a dial {@link Dial.fail}s.
39
+ */
40
+ export declare class Dials {
41
+ #private;
42
+ /** The next dial waiting for its tokens, or undefined once the connection closed. */
43
+ next(): Promise<Dial | undefined>;
44
+ }
45
+ //# sourceMappingURL=dials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dials.d.ts","sourceRoot":"","sources":["../../src/connection/dials.ts"],"names":[],"mappings":"AAQA,oEAAoE;AACpE,qBAAa,IAAI;;IAChB,yFAAyF;IACzF,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAElB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;IAEzB,iHAAiH;IACjH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAI7B,OAAO,eAQN;IASD;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAEvC;IAED;;;OAGG;IACH,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAErB;CACD;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,KAAK;;IAgBjB,qFAAqF;IAC/E,IAAI,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAQtC;CAoBD"}
@@ -0,0 +1,109 @@
1
+ import { Signal } from "@moq/signals";
2
+ // Set by Dial's static block, which alone may call its private constructor.
3
+ let makeDial;
4
+ /** One dial of a connection, waiting for the tokens it presents. */
5
+ export class Dial {
6
+ /** Where the dial goes: the connection's URL, or the relay a GOAWAY redirected it to. */
7
+ url;
8
+ /**
9
+ * Why the previous attempt or session ended, such as a refused credential or a redirect before
10
+ * the session was healthy, or undefined when nothing failed since a session last served, as
11
+ * for the first dial or a healthy session's GOAWAY handover.
12
+ */
13
+ failure;
14
+ /** Aborted once the connection no longer waits for this dial's tokens: on close, or past the connect timeout. */
15
+ signal;
16
+ #answer = Promise.withResolvers();
17
+ constructor(url, signal, failure) {
18
+ this.url = url;
19
+ this.signal = signal;
20
+ this.failure = failure;
21
+ // A dial its connection abandoned rejects unread.
22
+ this.#answer.promise.catch(() => { });
23
+ if (signal.aborted)
24
+ this.#answer.reject(signal.reason);
25
+ else
26
+ signal.addEventListener("abort", () => this.#answer.reject(signal.reason), { once: true });
27
+ }
28
+ static {
29
+ makeDial = (url, signal, failure) => {
30
+ const dial = new Dial(url, signal, failure);
31
+ return [dial, dial.#answer.promise];
32
+ };
33
+ }
34
+ /**
35
+ * Present `tokens` on this dial, as a fixed list would be; the first answer counts. Only the
36
+ * first, the connection credential, is this dial's alone: the rest join the connection's
37
+ * shared set, which a successor attaches to before its own answer replaces them, so a
38
+ * single-use token belongs first.
39
+ */
40
+ present(tokens) {
41
+ this.#answer.resolve({ tokens: [...tokens] });
42
+ }
43
+ /**
44
+ * Stop the connection with `err` instead of dialing, as for a {@link failure} no retry can
45
+ * repair. A probe back to WebTransport, which the serving session does without, is skipped instead.
46
+ */
47
+ fail(err) {
48
+ this.#answer.resolve({ refused: err });
49
+ }
50
+ }
51
+ /**
52
+ * Tokens a connection asks for at each dial, for a credential that must be fresh when it is
53
+ * presented, such as a proof a peer admits once and only shortly after it was signed. Pass it as
54
+ * a connection's `tokens` and answer each {@link next} dial: every dial waits for its answer,
55
+ * whatever starts it, a reconnect, a GOAWAY's handover, a page resuming, or a probe back to
56
+ * WebTransport, so none presents tokens signed for another.
57
+ *
58
+ * A URL never reached stops at its first failure, as with fixed tokens, reported on the
59
+ * connection's `error` with no further dial to ask. Once a session was established, answering is
60
+ * how a connection retries: it backs off and asks again, with the reason on
61
+ * {@link Dial.failure}, until a dial {@link Dial.fail}s.
62
+ */
63
+ export class Dials {
64
+ #waiting = [];
65
+ #queued = new Signal(0);
66
+ #claimed = false;
67
+ #closed = false;
68
+ /** Whether a connection took these dials, which serve one. @internal */
69
+ get claimed() {
70
+ return this.#claimed;
71
+ }
72
+ /** Take these dials for one connection. @internal */
73
+ claim() {
74
+ this.#claimed = true;
75
+ }
76
+ /** The next dial waiting for its tokens, or undefined once the connection closed. */
77
+ async next() {
78
+ for (;;) {
79
+ for (let dial = this.#waiting.shift(); dial; dial = this.#waiting.shift()) {
80
+ if (!dial.signal.aborted)
81
+ return dial;
82
+ }
83
+ if (this.#closed)
84
+ return undefined;
85
+ await this.#queued.changed();
86
+ }
87
+ }
88
+ /** Ask for the tokens of a dial to `url`, until `signal` aborts, which rejects it. @internal */
89
+ request(url, signal, failure) {
90
+ if (this.#closed)
91
+ return Promise.reject(new Error("connection closed"));
92
+ const [dial, answer] = makeDial(url, signal, failure);
93
+ // Dials the loop abandoned unread go now, so an app that stops reading holds at most one.
94
+ const live = this.#waiting.filter((waiting) => !waiting.signal.aborted);
95
+ this.#waiting.splice(0, this.#waiting.length, ...live, dial);
96
+ this.#queued.update((n) => n + 1);
97
+ return answer;
98
+ }
99
+ /** End {@link next}, failing every dial still waiting. @internal */
100
+ close() {
101
+ if (this.#closed)
102
+ return;
103
+ this.#closed = true;
104
+ for (const dial of this.#waiting.splice(0))
105
+ dial.fail(new Error("connection closed"));
106
+ this.#queued.update((n) => n + 1);
107
+ }
108
+ }
109
+ //# sourceMappingURL=dials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dials.js","sourceRoot":"","sources":["../../src/connection/dials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC,4EAA4E;AAC5E,IAAI,QAAqF,CAAC;AAE1F,oEAAoE;AACpE,MAAM,OAAO,IAAI;IAChB,yFAAyF;IAChF,GAAG,CAAM;IAElB;;;;OAIG;IACM,OAAO,CAAS;IAEzB,iHAAiH;IACxG,MAAM,CAAc;IAEpB,OAAO,GAAG,OAAO,CAAC,aAAa,EA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IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IACf,CAAC;IAED,oEAAoE;IACpE,KAAK;QACJ,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;QACtF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,CAAC;CACD","sourcesContent":["import { Signal } from \"@moq/signals\";\n\n/** How the app answered a dial: the tokens to present, or why the connection should stop. @internal */\nexport type Answer = { tokens: readonly string[] } | { refused: Error };\n\n// Set by Dial's static block, which alone may call its private constructor.\nlet makeDial: (url: URL, signal: AbortSignal, failure?: Error) => [Dial, Promise<Answer>];\n\n/** One dial of a connection, waiting for the tokens it presents. */\nexport class Dial {\n\t/** Where the dial goes: the connection's URL, or the relay a GOAWAY redirected it to. */\n\treadonly url: URL;\n\n\t/**\n\t * Why the previous attempt or session ended, such as a refused credential or a redirect before\n\t * the session was healthy, or undefined when nothing failed since a session last served, as\n\t * for the first dial or a healthy session's GOAWAY handover.\n\t */\n\treadonly failure?: Error;\n\n\t/** Aborted once the connection no longer waits for this dial's tokens: on close, or past the connect timeout. */\n\treadonly signal: AbortSignal;\n\n\treadonly #answer = Promise.withResolvers<Answer>();\n\n\tprivate constructor(url: URL, signal: AbortSignal, failure?: Error) {\n\t\tthis.url = url;\n\t\tthis.signal = signal;\n\t\tthis.failure = failure;\n\t\t// A dial its connection abandoned rejects unread.\n\t\tthis.#answer.promise.catch(() => {});\n\t\tif (signal.aborted) this.#answer.reject(signal.reason);\n\t\telse signal.addEventListener(\"abort\", () => this.#answer.reject(signal.reason), { once: true });\n\t}\n\n\tstatic {\n\t\tmakeDial = (url, signal, failure) => {\n\t\t\tconst dial = new Dial(url, signal, failure);\n\t\t\treturn [dial, dial.#answer.promise];\n\t\t};\n\t}\n\n\t/**\n\t * Present `tokens` on this dial, as a fixed list would be; the first answer counts. Only the\n\t * first, the connection credential, is this dial's alone: the rest join the connection's\n\t * shared set, which a successor attaches to before its own answer replaces them, so a\n\t * single-use token belongs first.\n\t */\n\tpresent(tokens: readonly string[]): void {\n\t\tthis.#answer.resolve({ tokens: [...tokens] });\n\t}\n\n\t/**\n\t * Stop the connection with `err` instead of dialing, as for a {@link failure} no retry can\n\t * repair. A probe back to WebTransport, which the serving session does without, is skipped instead.\n\t */\n\tfail(err: Error): void {\n\t\tthis.#answer.resolve({ refused: err });\n\t}\n}\n\n/**\n * Tokens a connection asks for at each dial, for a credential that must be fresh when it is\n * presented, such as a proof a peer admits once and only shortly after it was signed. Pass it as\n * a connection's `tokens` and answer each {@link next} dial: every dial waits for its answer,\n * whatever starts it, a reconnect, a GOAWAY's handover, a page resuming, or a probe back to\n * WebTransport, so none presents tokens signed for another.\n *\n * A URL never reached stops at its first failure, as with fixed tokens, reported on the\n * connection's `error` with no further dial to ask. Once a session was established, answering is\n * how a connection retries: it backs off and asks again, with the reason on\n * {@link Dial.failure}, until a dial {@link Dial.fail}s.\n */\nexport class Dials {\n\treadonly #waiting: Dial[] = [];\n\treadonly #queued = new Signal(0);\n\t#claimed = false;\n\t#closed = false;\n\n\t/** Whether a connection took these dials, which serve one. @internal */\n\tget claimed(): boolean {\n\t\treturn this.#claimed;\n\t}\n\n\t/** Take these dials for one connection. @internal */\n\tclaim(): void {\n\t\tthis.#claimed = true;\n\t}\n\n\t/** The next dial waiting for its tokens, or undefined once the connection closed. */\n\tasync next(): Promise<Dial | undefined> {\n\t\tfor (;;) {\n\t\t\tfor (let dial = this.#waiting.shift(); dial; dial = this.#waiting.shift()) {\n\t\t\t\tif (!dial.signal.aborted) return dial;\n\t\t\t}\n\t\t\tif (this.#closed) return undefined;\n\t\t\tawait this.#queued.changed();\n\t\t}\n\t}\n\n\t/** Ask for the tokens of a dial to `url`, until `signal` aborts, which rejects it. @internal */\n\trequest(url: URL, signal: AbortSignal, failure?: Error): Promise<Answer> {\n\t\tif (this.#closed) return Promise.reject(new Error(\"connection closed\"));\n\t\tconst [dial, answer] = makeDial(url, signal, failure);\n\t\t// Dials the loop abandoned unread go now, so an app that stops reading holds at most one.\n\t\tconst live = this.#waiting.filter((waiting) => !waiting.signal.aborted);\n\t\tthis.#waiting.splice(0, this.#waiting.length, ...live, dial);\n\t\tthis.#queued.update((n) => n + 1);\n\t\treturn answer;\n\t}\n\n\t/** End {@link next}, failing every dial still waiting. @internal */\n\tclose(): void {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tfor (const dial of this.#waiting.splice(0)) dial.fail(new Error(\"connection closed\"));\n\t\tthis.#queued.update((n) => n + 1);\n\t}\n}\n"]}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Where a URL dials, parsed once so every decision about it reads the host the transport
3
+ * connects to: GOAWAY redirect checks, the dial itself, and what logs show.
4
+ *
5
+ * Mirrors `rs/moq-net/src/reconnect/redirect.rs`.
6
+ *
7
+ * @module
8
+ */
9
+ /** A host as a dial reads it: an IPv4 or IPv6 literal, or a name left to DNS. */
10
+ type Host = {
11
+ readonly kind: "ipv4";
12
+ readonly octets: readonly number[];
13
+ } | {
14
+ readonly kind: "ipv6";
15
+ readonly segments: readonly number[];
16
+ } | {
17
+ readonly kind: "name";
18
+ readonly name: string;
19
+ };
20
+ /** Where a URL dials: its scheme, its host, and its port, which defaults by scheme. */
21
+ export interface Endpoint {
22
+ /** The scheme without its colon, as written (`moql`, not the `https` a browser dials it over). */
23
+ readonly scheme: string;
24
+ readonly host: Host;
25
+ readonly port: number;
26
+ /**
27
+ * The URL a browser transport dials. A raw QUIC `moqt:` or `moql:` URL is reached over
28
+ * WebTransport with its scheme swapped for https (draft-ietf-moq-transport-18 §3.1.3); the
29
+ * CONNECT carries the scheme, so a server refuses the raw one.
30
+ */
31
+ readonly url: URL;
32
+ }
33
+ /**
34
+ * Parse where `url` dials. Throws a `TypeError` for a URL with no host, which no transport
35
+ * here can dial.
36
+ *
37
+ * Only the special schemes (`http`, `https`, `ws`, `wss`) have their host parsed by the URL
38
+ * parser; any other scheme keeps it opaque, so `moql://127.1` reads `127.1` while the dial,
39
+ * made over https, connects to 127.0.0.1. Reading the host back through https makes both the
40
+ * same: an address in any spelling the dial accepts is that address here.
41
+ */
42
+ export declare function parse(url: URL): Endpoint;
43
+ /** Whether two endpoints dial the same host, whatever their scheme or port. */
44
+ export declare function sameHost(a: Endpoint, b: Endpoint): boolean;
45
+ /**
46
+ * Formats an endpoint for logs and errors as scheme, host, and port only.
47
+ *
48
+ * A URL can carry a credential in its userinfo, query, or path (raw QUIC has no headers, so a
49
+ * token can ride as a path segment). Dropping all three rather than redacting known-secret
50
+ * spellings is deliberate: a denylist only covers the credentials that exist today.
51
+ */
52
+ export declare function show(endpoint: Endpoint): string;
53
+ /**
54
+ * Whether an endpoint says it names something only reachable from this host or network. A
55
+ * judgement about the address it spells, not about where a dial lands: a name is dialed,
56
+ * never resolved here, so `false` means "not local on its face", never "verified remote".
57
+ */
58
+ export declare function isLocal({ host }: Endpoint): boolean;
59
+ export {};
60
+ //# sourceMappingURL=endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/connection/endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,iFAAiF;AACjF,KAAK,IAAI,GACN;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC7D;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD,uFAAuF;AACvF,MAAM,WAAW,QAAQ;IACxB,kGAAkG;IAClG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CASxC;AAiCD,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,GAAG,OAAO,CAYnD"}