@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.js +0 -18
  662. package/zod.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/connection/stats.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AA2FnC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAkB;IACtD,MAAM,QAAQ,GAAI,IAAqD,CAAC,QAAQ,CAAC;IACjF,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,OAAO,EAAE,CAAC;IAC9C,IAAI,CAAC;QACJ,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,OAAO;YACN,GAAG,EAAE,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;YAChF,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,IAAI,SAAS;YACvD,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,WAAW,EAAE,KAAK,CAAC,WAAW;SAC9B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAC;IACX,CAAC;AACF,CAAC","sourcesContent":["/**\n * Connection statistics: what the local transport counts, and what the peer reports.\n *\n * @module\n */\nimport * as Time from \"../time.ts\";\n\n/**\n * A point-in-time snapshot of the transport's counters, from `WebTransport.getStats()`.\n *\n * Pulled on demand rather than pushed: the transport has no event to subscribe to, and\n * a caller computing a rate wants to choose its own sampling instants. Snapshot twice\n * and divide by the interval you measured.\n *\n * Every field is optional. The qmux/WebSocket fallback implements no `getStats()` at\n * all and reports nothing; see {@link Probe} for what the peer measures.\n *\n * The field names match Rust's `moq_net::session::Stats` but the counters keep each\n * stack's own semantics rather than being normalized. Notably W3C excludes\n * retransmissions and QUIC overhead from the byte counts where native QUIC includes\n * them, and counts packets where native QUIC counts datagrams.\n *\n * @public\n */\nexport interface Stats {\n\t/**\n\t * Smoothed round-trip time estimate in milliseconds.\n\t *\n\t * Usually absent: browsers don't report an RTT yet even though the W3C dictionary\n\t * has the field. Use {@link Probe.rtt}, which the peer measures.\n\t */\n\trtt?: Time.Milli;\n\n\t/** Estimated send bandwidth from the congestion controller, in bits per second. */\n\testimatedSendRate?: number;\n\n\t/** Total bytes sent on streams and datagrams, excluding retransmissions and QUIC overhead. */\n\tbytesSent?: number;\n\n\t/** Total bytes received on streams and datagrams, including duplicates, excluding QUIC overhead. */\n\tbytesReceived?: number;\n\n\t/** Bytes currently declared lost. The estimate can decrease when a loss proves spurious. */\n\tbytesLost?: number;\n\n\t/** Total packets sent, including retransmissions. */\n\tpacketsSent?: number;\n\n\t/** Total packets received, including duplicates. */\n\tpacketsReceived?: number;\n\n\t/** Packets currently declared lost. The estimate can decrease when a loss proves spurious. */\n\tpacketsLost?: number;\n}\n\n/**\n * Estimates measured by the peer and delivered over the MoQ PROBE stream.\n *\n * Pushed rather than pulled: these arrive when the peer sends them, so they're read\n * from a signal. Empty until the first PROBE message, on versions without PROBE\n * (moq-lite-01/02, moq-transport), and again once the stream ends, so a consumer\n * never holds a stale estimate from a dead stream.\n *\n * @public\n */\nexport interface Probe {\n\t/**\n\t * Round-trip time in milliseconds.\n\t *\n\t * The only RTT available today, since browsers don't populate the transport's.\n\t * Measured through the peer's application layer, so it reads higher than a\n\t * transport-level RTT would.\n\t */\n\trtt?: Time.Milli;\n\n\t/** The peer's estimate of the bitrate it is receiving from us, in bits per second. */\n\testimatedRecvRate?: number;\n}\n\n/**\n * The subset of the W3C `WebTransportConnectionStats` dictionary we consume.\n * `getStats()` is not in TypeScript's DOM lib yet, so it is declared here.\n *\n * @internal\n */\nexport interface TransportStats {\n\tsmoothedRtt?: number;\n\testimatedSendRate?: number | null;\n\tbytesSent?: number;\n\tbytesReceived?: number;\n\tbytesLost?: number;\n\tpacketsSent?: number;\n\tpacketsReceived?: number;\n\tpacketsLost?: number;\n}\n\n/**\n * Snapshot `quic` via `getStats()`, or an empty snapshot when the transport doesn't\n * implement it (the qmux/WebSocket fallback, older browsers) or the call fails.\n *\n * @internal\n */\nexport async function transportStats(quic: WebTransport): Promise<Stats> {\n\tconst getStats = (quic as { getStats?: () => Promise<TransportStats> }).getStats;\n\tif (typeof getStats !== \"function\") return {};\n\ttry {\n\t\tconst stats = await getStats.call(quic);\n\t\treturn {\n\t\t\trtt: stats.smoothedRtt !== undefined ? Time.Milli(stats.smoothedRtt) : undefined,\n\t\t\testimatedSendRate: stats.estimatedSendRate ?? undefined,\n\t\t\tbytesSent: stats.bytesSent,\n\t\t\tbytesReceived: stats.bytesReceived,\n\t\t\tbytesLost: stats.bytesLost,\n\t\t\tpacketsSent: stats.packetsSent,\n\t\t\tpacketsReceived: stats.packetsReceived,\n\t\t\tpacketsLost: stats.packetsLost,\n\t\t};\n\t} catch {\n\t\treturn {};\n\t}\n}\n"]}
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/connection/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA2G7C,iEAAiE;AACjE,MAAM,KAAK,GAAG,IAAI,OAAO,EAAgB,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAkB;IAC/C,MAAM,QAAQ,GAAI,IAAqD,CAAC,QAAQ,CAAC;IACjF,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,OAAO;IAC3C,IAAI,CAAC;QACJ,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAA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AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAkB;IAC7C,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC5E,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,GAAG,IAAI,OAAO,EAAW,CAAC;AAE1C,6FAA6F;AAC7F,MAAM,UAAU,MAAM,CAAC,OAAgB,EAAE,IAAkB;IAC1D,IAAI,WAAW,CAAC,IAAI,CAAC;QAAE,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,OAAgB;IACzC,OAAO,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import { Duration, type Instant } from \"@moq/clock\";\nimport type { Session } from \"./session.ts\";\nimport { transportOf } from \"./transport.ts\";\n/**\n * Connection statistics: what the local transport counts, and what the peer reports.\n *\n * @module\n */\n\n/**\n * A point-in-time snapshot of the transport's counters, from `WebTransport.getStats()`.\n *\n * Pulled on demand rather than pushed: the transport has no event to subscribe to, and\n * a caller computing a rate wants to choose its own sampling instants. Snapshot twice\n * and divide by the interval you measured.\n *\n * Every field is optional. The qmux/WebSocket fallback reports nothing; see\n * {@link Probe} for what the peer measures.\n *\n * The field names match Rust's `moq_net::session::Stats` but the counters keep each\n * stack's own semantics rather than being normalized. Notably W3C excludes\n * retransmissions and QUIC overhead from the byte counts where native QUIC includes\n * them, and counts packets where native QUIC counts datagrams.\n *\n * @public\n */\nexport interface Stats {\n\t/**\n\t * Smoothed round-trip time estimate in milliseconds.\n\t *\n\t * Use {@link Probe.rtt} when the local transport omits it.\n\t */\n\trtt?: Duration;\n\n\t/** Estimated send bandwidth from the congestion controller, in bits per second. */\n\testimatedSendRate?: number;\n\n\t/** Total bytes sent on streams and datagrams, excluding retransmissions and QUIC overhead. */\n\tbytesSent?: number;\n\n\t/** Total bytes received on streams and datagrams, including duplicates, excluding QUIC overhead. */\n\tbytesReceived?: number;\n\n\t/** Bytes currently declared lost. The estimate can decrease when a loss proves spurious. */\n\tbytesLost?: number;\n\n\t/** Total packets sent, including retransmissions. */\n\tpacketsSent?: number;\n\n\t/** Total packets received, including duplicates. */\n\tpacketsReceived?: number;\n\n\t/** Packets currently declared lost. The estimate can decrease when a loss proves spurious. */\n\tpacketsLost?: number;\n\n\t/**\n\t * Datagrams received for a subscription with no datagram track: one this session doesn't\n\t * know, has ended, or whose answer it hasn't received. Absent on a version without datagrams:\n\t * moq-transport and moq-lite before 05.\n\t */\n\tdatagramsUnrouted?: number;\n}\n\n/** Transport counters with their sampling instant. @public */\nexport interface Sample extends Stats {\n\t/** When the request for these counters began on the monotonic clock. */\n\tat: Instant;\n}\n\n/**\n * Estimates measured by the peer and delivered over the MoQ PROBE stream.\n *\n * Pushed rather than pulled: these arrive when the peer sends them, so they're read\n * from a signal. Empty until the first PROBE message, on versions without PROBE\n * (moq-lite-01/02, moq-transport), and again once the stream ends, so a consumer\n * never holds a stale estimate from a dead stream.\n *\n * @public\n */\nexport interface Probe {\n\t/**\n\t * Round-trip time in milliseconds.\n\t *\n\t * Available on sessions whose peer reports it, even if the local transport has\n\t * no stats. It includes the peer's application-layer processing time.\n\t */\n\trtt?: Duration;\n\n\t/** The peer's send-rate estimate toward us, so our receive rate, in bits per second. */\n\testimatedRecvRate?: number;\n}\n\n/**\n * The subset of the W3C `WebTransportConnectionStats` dictionary we consume.\n * `getStats()` is not in TypeScript's DOM lib yet, so it is declared here.\n *\n * @internal\n */\nexport interface TransportStats {\n\tsmoothedRtt?: number;\n\testimatedSendRate?: number | null;\n\tbytesSent?: number;\n\tbytesReceived?: number;\n\tbytesLost?: number;\n\tpacketsSent?: number;\n\tpacketsReceived?: number;\n\tpacketsLost?: number;\n}\n\n// Transports whose `getStats()` is a stub that measures nothing.\nconst stubs = new WeakSet<WebTransport>();\n\n/**\n * Decide at setup whether `quic`'s `getStats()` measures anything. Safari's is a stub\n * whose `smoothedRtt` and counters are always 0 and whose `estimatedSendRate` is null;\n * QUIC's smoothed RTT starts at 333 ms, so a 0 RTT with no rate means nothing was\n * measured: the transport is then treated as having no `getStats()` at all. A rate\n * alongside a 0 RTT keeps the transport usable. Only this setup-time call decides, so a real RTT from a\n * later WebKit lifts the rule.\n *\n * @internal\n */\nexport async function inspect(quic: WebTransport): Promise<void> {\n\tconst getStats = (quic as { getStats?: () => Promise<TransportStats> }).getStats;\n\tif (typeof getStats !== \"function\") return;\n\ttry {\n\t\tconst stats = await getStats.call(quic);\n\t\tif (stats.smoothedRtt === 0 && stats.estimatedSendRate == null) stubs.add(quic);\n\t} catch {\n\t\t// A transport that can't answer now may later; `transportStats` handles the rejection.\n\t}\n}\n\n/**\n * `quic`'s `getStats()`, or `undefined` when it has none or {@link inspect} found a stub.\n *\n * @internal\n */\nexport function statsOf(quic: WebTransport): (() => Promise<TransportStats>) | undefined {\n\tconst getStats = (quic as { getStats?: () => Promise<TransportStats> }).getStats;\n\tif (typeof getStats !== \"function\" || stubs.has(quic)) return undefined;\n\treturn () => getStats.call(quic);\n}\n\n/**\n * Snapshot `quic` via `getStats()`, or an empty snapshot when the transport doesn't\n * implement it (older browsers), it is a stub, or the call fails.\n *\n * @internal\n */\nexport async function transportStats(quic: WebTransport): Promise<Stats> {\n\tconst getStats = statsOf(quic);\n\tif (!getStats) return {};\n\ttry {\n\t\tconst stats = await getStats();\n\t\treturn {\n\t\t\trtt: stats.smoothedRtt !== undefined ? Duration.millis(stats.smoothedRtt) : undefined,\n\t\t\testimatedSendRate: stats.estimatedSendRate ?? undefined,\n\t\t\tbytesSent: stats.bytesSent,\n\t\t\tbytesReceived: stats.bytesReceived,\n\t\t\tbytesLost: stats.bytesLost,\n\t\t\tpacketsSent: stats.packetsSent,\n\t\t\tpacketsReceived: stats.packetsReceived,\n\t\t\tpacketsLost: stats.packetsLost,\n\t\t};\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n/**\n * Whether `quic` can report a send-rate estimate: only a WebTransport session with a\n * real `getStats()`. The WebSocket fallback reports no estimate.\n *\n * @internal\n */\nexport function canEstimate(quic: WebTransport): boolean {\n\treturn transportOf(quic) === \"webtransport\" && statsOf(quic) !== undefined;\n}\n\n// The sessions whose transport can report a send-rate estimate.\nconst estimating = new WeakSet<Session>();\n\n/** Record whether `session`'s transport `quic` can report a send-rate estimate. @internal */\nexport function detect(session: Session, quic: WebTransport): void {\n\tif (canEstimate(quic)) estimating.add(session);\n}\n\n/**\n * Whether `session` can report a send-rate estimate, so sampling it is worth a timer.\n *\n * @internal\n */\nexport function estimates(session: Session): boolean {\n\treturn estimating.has(session);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { type Duration } from "@moq/clock";
2
+ /** Subscribes `fn` to the page-wide ticker for `period`; returns its dispose. */
3
+ export declare function tick(period: Duration, fn: () => void): () => void;
4
+ //# sourceMappingURL=ticker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ticker.d.ts","sourceRoot":"","sources":["../../src/connection/ticker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,YAAY,CAAC;AAwD5D,iFAAiF;AACjF,wBAAgB,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAQjE"}
@@ -0,0 +1,66 @@
1
+ import { now, sleepUntil } from "@moq/clock";
2
+ /**
3
+ * One page-wide ticker shared by every caller with the same period.
4
+ *
5
+ * Each subscriber's callback runs once per tick, all in the same task, so N
6
+ * connections sampling `getStats()` cost one timer wakeup per period instead of N
7
+ * loops ticking out of phase. The loop runs only while a subscriber is registered.
8
+ */
9
+ class Ticker {
10
+ #period;
11
+ #subscribers = new Set();
12
+ #abort;
13
+ constructor(period) {
14
+ this.#period = period;
15
+ }
16
+ /** Runs `fn` on every tick until the returned dispose is called. */
17
+ subscribe(fn) {
18
+ this.#subscribers.add(fn);
19
+ if (!this.#abort)
20
+ this.#start();
21
+ return () => {
22
+ if (!this.#subscribers.delete(fn))
23
+ return;
24
+ if (this.#subscribers.size === 0) {
25
+ this.#abort?.abort();
26
+ this.#abort = undefined;
27
+ }
28
+ };
29
+ }
30
+ #start() {
31
+ const abort = new AbortController();
32
+ this.#abort = abort;
33
+ void (async () => {
34
+ let next = now().saturatingAdd(this.#period);
35
+ for (;;) {
36
+ await sleepUntil(next, { signal: abort.signal }).catch(() => { });
37
+ if (abort.signal.aborted)
38
+ return;
39
+ // Snapshot so a callback that unsubscribes doesn't skip a neighbour.
40
+ for (const fn of [...this.#subscribers]) {
41
+ try {
42
+ fn();
43
+ }
44
+ catch (err) {
45
+ console.error("ticker callback error", err);
46
+ }
47
+ }
48
+ next = now().saturatingAdd(this.#period);
49
+ }
50
+ })();
51
+ }
52
+ }
53
+ // Keyed by nanoseconds, since equal durations are distinct objects.
54
+ const tickers = new Map();
55
+ /** Subscribes `fn` to the page-wide ticker for `period`; returns its dispose. */
56
+ export function tick(period, fn) {
57
+ if (period.isZero())
58
+ throw new RangeError("ticker period must be positive");
59
+ let ticker = tickers.get(period.asNanos());
60
+ if (!ticker) {
61
+ ticker = new Ticker(period);
62
+ tickers.set(period.asNanos(), ticker);
63
+ }
64
+ return ticker.subscribe(fn);
65
+ }
66
+ //# sourceMappingURL=ticker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ticker.js","sourceRoot":"","sources":["../../src/connection/ticker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM;IACF,OAAO,CAAW;IAClB,YAAY,GAAG,IAAI,GAAG,EAAc,CAAC;IAC9C,MAAM,CAAmB;IAEzB,YAAY,MAAgB;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,oEAAoE;IACpE,SAAS,CAAC,E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CAAC;QACF,CAAC,CAAC,EAAE,CAAC;IACN,CAAC;CACD;AAED,oEAAoE;AACpE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE1C,iFAAiF;AACjF,MAAM,UAAU,IAAI,CAAC,MAAgB,EAAE,EAAc;IACpD,IAAI,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,IAAI,UAAU,CAAC,gCAAgC,CAAC,CAAC;IAC5E,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { type Duration, now, sleepUntil } from \"@moq/clock\";\n\n/**\n * One page-wide ticker shared by every caller with the same period.\n *\n * Each subscriber's callback runs once per tick, all in the same task, so N\n * connections sampling `getStats()` cost one timer wakeup per period instead of N\n * loops ticking out of phase. The loop runs only while a subscriber is registered.\n */\nclass Ticker {\n\treadonly #period: Duration;\n\treadonly #subscribers = new Set<() => void>();\n\t#abort?: AbortController;\n\n\tconstructor(period: Duration) {\n\t\tthis.#period = period;\n\t}\n\n\t/** Runs `fn` on every tick until the returned dispose is called. */\n\tsubscribe(fn: () => void): () => void {\n\t\tthis.#subscribers.add(fn);\n\t\tif (!this.#abort) this.#start();\n\t\treturn () => {\n\t\t\tif (!this.#subscribers.delete(fn)) return;\n\t\t\tif (this.#subscribers.size === 0) {\n\t\t\t\tthis.#abort?.abort();\n\t\t\t\tthis.#abort = undefined;\n\t\t\t}\n\t\t};\n\t}\n\n\t#start() {\n\t\tconst abort = new AbortController();\n\t\tthis.#abort = abort;\n\t\tvoid (async () => {\n\t\t\tlet next = now().saturatingAdd(this.#period);\n\t\t\tfor (;;) {\n\t\t\t\tawait sleepUntil(next, { signal: abort.signal }).catch(() => {});\n\t\t\t\tif (abort.signal.aborted) return;\n\t\t\t\t// Snapshot so a callback that unsubscribes doesn't skip a neighbour.\n\t\t\t\tfor (const fn of [...this.#subscribers]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfn();\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tconsole.error(\"ticker callback error\", err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnext = now().saturatingAdd(this.#period);\n\t\t\t}\n\t\t})();\n\t}\n}\n\n// Keyed by nanoseconds, since equal durations are distinct objects.\nconst tickers = new Map<number, Ticker>();\n\n/** Subscribes `fn` to the page-wide ticker for `period`; returns its dispose. */\nexport function tick(period: Duration, fn: () => void): () => void {\n\tif (period.isZero()) throw new RangeError(\"ticker period must be positive\");\n\tlet ticker = tickers.get(period.asNanos());\n\tif (!ticker) {\n\t\tticker = new Ticker(period);\n\t\ttickers.set(period.asNanos(), ticker);\n\t}\n\treturn ticker.subscribe(fn);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/connection/tokens.ts"],"names":[],"mappings":""}
@@ -0,0 +1,404 @@
1
+ import { Signal } from "@moq/signals";
2
+ import { Unsupported } from "../auth.js";
3
+ import { ending } from "../auth_session.js";
4
+ import { error } from "../error.js";
5
+ import { wireOf } from "../wire.js";
6
+ /**
7
+ * Decide what one dial presents.
8
+ *
9
+ * A URL that already carries a `jwt` keeps it (a per-peer credential), so every token rides
10
+ * AUTH. Otherwise the first token is the connection credential: it rides the URL's `auth`
11
+ * parameter alone when the carrier asks, else SETUP, and the URL's `jwt` too when no `setupToken`
12
+ * is carried, since the URL is fixed before the version is negotiated.
13
+ *
14
+ * @internal
15
+ */
16
+ export function credential(url, tokens, carrier) {
17
+ const jwt = url.searchParams.get("jwt");
18
+ if (jwt)
19
+ return { url, connection: jwt };
20
+ const first = tokens[0];
21
+ if (carrier.urlAuth) {
22
+ // Even with no token yet, so one that arrives later waits for the next dial.
23
+ const carried = { url, carried: true };
24
+ return first === undefined ? carried : { ...carried, url: withAuth(url, first), connection: first };
25
+ }
26
+ if (first === undefined)
27
+ return { url };
28
+ return { url: carrier.setupToken ? url : withJwt(url, first), setup: first, connection: first };
29
+ }
30
+ /**
31
+ * Decide what a dial to the WebSocket fallback's own URL presents.
32
+ *
33
+ * The fallback presents the credential its URL decides, never one taken from the primary:
34
+ * its own `jwt`, else the primary URL's `jwt`, else the configured tokens as {@link credential}
35
+ * decides them.
36
+ *
37
+ * @internal
38
+ */
39
+ export function fallback(primary, url, tokens, carrier) {
40
+ const inherited = primary.searchParams.get("jwt");
41
+ if (inherited && !url.searchParams.get("jwt"))
42
+ return credential(withJwt(url, inherited), tokens, carrier);
43
+ return credential(url, tokens, carrier);
44
+ }
45
+ /** `url` with `jwt` appended to its query. @internal */
46
+ function withJwt(url, jwt) {
47
+ const next = new URL(url);
48
+ next.searchParams.append("jwt", jwt);
49
+ return next;
50
+ }
51
+ /** `url` with `auth` set to the credential, replacing any it carried, so it never repeats. */
52
+ function withAuth(url, credential) {
53
+ const next = new URL(url);
54
+ next.searchParams.set("auth", credential);
55
+ return next;
56
+ }
57
+ /**
58
+ * The tokens to hold on their own AUTH streams, each once. A credential the URL carries takes
59
+ * no token of the relay's own kind, so its replacement is no AUTH token either: the next dial
60
+ * presents it.
61
+ *
62
+ * @internal
63
+ */
64
+ export function extra(credential, tokens) {
65
+ const reserved = credential.carried ? tokens[0] : undefined;
66
+ return [...new Set(tokens)].filter((token) => token !== credential.connection && token !== reserved);
67
+ }
68
+ /**
69
+ * The configured tokens an auth handle holds on their own AUTH streams, beside the
70
+ * latest dial's connection credential. A handle shared across reconnects keeps them on
71
+ * every session it backs.
72
+ *
73
+ * A change presents the new tokens at once and withdraws the granted ones they replace only
74
+ * after every new one has its answer, so the grant never narrows in between.
75
+ *
76
+ * @internal
77
+ */
78
+ export class Held {
79
+ #handle;
80
+ #credential;
81
+ #entries = new Map();
82
+ #retiring = [];
83
+ #changed = new Signal(0);
84
+ constructor(handle, credential) {
85
+ this.#handle = handle;
86
+ this.#credential = credential;
87
+ }
88
+ /** Bumps whenever a held token is answered or ends. */
89
+ get changed() {
90
+ return this.#changed;
91
+ }
92
+ /** The credential the latest dial presented as the connection's, which no AUTH stream carries. */
93
+ get connection() {
94
+ return this.#credential.connection;
95
+ }
96
+ /** Whether `token` rides its own AUTH stream. */
97
+ has(token) {
98
+ return this.#entries.has(token);
99
+ }
100
+ /**
101
+ * The peer's first verdict on held `token`: `null` once granted in band, its refusal, or
102
+ * undefined while it has none. A token only a request carries is unsupported, not granted.
103
+ */
104
+ verdict(token) {
105
+ return this.#entries.get(token)?.answer;
106
+ }
107
+ /** Why the peer ended the first of `tokens` that is held, for good. */
108
+ ended(tokens) {
109
+ for (const token of tokens) {
110
+ const end = this.#entries.get(token)?.end;
111
+ if (end)
112
+ return end;
113
+ }
114
+ return undefined;
115
+ }
116
+ /** A new dial on the handle, whose credential decides which tokens ride AUTH. */
117
+ dialed(credential, tokens) {
118
+ this.#credential = credential;
119
+ this.update(tokens);
120
+ }
121
+ /** Hold exactly `tokens`, other than the connection credential. */
122
+ update(tokens) {
123
+ const next = new Map();
124
+ for (const token of extra(this.#credential, tokens)) {
125
+ next.set(token, this.#entries.get(token) ?? this.#present(token));
126
+ }
127
+ for (const [token, entry] of this.#entries) {
128
+ if (next.has(token))
129
+ continue;
130
+ // Only a granted token keeps the grant wide; one refused or still unanswered, such as
131
+ // one retrying while its backend fails, is withdrawn at once so repeated updates never
132
+ // pile up retrying streams.
133
+ if (entry.auth?.held)
134
+ this.#retiring.push(entry);
135
+ else
136
+ this.#withdraw(entry);
137
+ }
138
+ this.#entries = next;
139
+ this.#settle();
140
+ }
141
+ #present(token) {
142
+ const entry = { pending: true, withdrawn: false };
143
+ const refused = (err) => {
144
+ if (entry.withdrawn)
145
+ return;
146
+ if (err instanceof Unsupported)
147
+ console.debug("the peer takes no tokens in band");
148
+ else
149
+ console.warn("a configured token was refused:", err);
150
+ };
151
+ let auth;
152
+ try {
153
+ // Registered synchronously, so a request sent right after waits on its answer.
154
+ auth = this.#handle.present(token);
155
+ }
156
+ catch (err) {
157
+ refused(err);
158
+ entry.answer = error(err);
159
+ entry.end = entry.answer;
160
+ entry.pending = false;
161
+ return entry;
162
+ }
163
+ entry.auth = auth;
164
+ auth.answered
165
+ .then(() => {
166
+ entry.answer = auth.inband ? null : new Unsupported();
167
+ }, (err) => {
168
+ entry.answer = error(err);
169
+ refused(err);
170
+ })
171
+ .finally(() => {
172
+ entry.pending = false;
173
+ this.#changed.update((n) => n + 1);
174
+ this.#settle();
175
+ });
176
+ // Withdrawn by us, it ends with no verdict of the peer's.
177
+ void auth.closed.then((end) => {
178
+ if (entry.withdrawn)
179
+ return;
180
+ entry.end = end ?? new Error("the peer ended the token");
181
+ this.#changed.update((n) => n + 1);
182
+ });
183
+ return entry;
184
+ }
185
+ #withdraw(entry) {
186
+ entry.withdrawn = true;
187
+ entry.auth?.close();
188
+ }
189
+ #settle() {
190
+ if ([...this.#entries.values()].some((entry) => entry.pending))
191
+ return;
192
+ for (const entry of this.#retiring)
193
+ this.#withdraw(entry);
194
+ this.#retiring = [];
195
+ }
196
+ }
197
+ // The tokens each auth handle holds, so a handle shared across reconnects holds them once
198
+ // and a reconnecting wrapper can update them.
199
+ const held = new WeakMap();
200
+ /** Present `tokens` on `connection`, beside the credential its dial carried. @internal */
201
+ export function hold(connection, credential, tokens) {
202
+ const existing = held.get(connection.auth);
203
+ if (existing) {
204
+ existing.dialed(credential, tokens);
205
+ return existing;
206
+ }
207
+ const tokensHeld = new Held(connection.auth, credential);
208
+ tokensHeld.update(tokens);
209
+ held.set(connection.auth, tokensHeld);
210
+ return tokensHeld;
211
+ }
212
+ /** The tokens `connection` holds, if it was dialed with any. @internal */
213
+ export function heldOf(connection) {
214
+ return held.get(connection.auth);
215
+ }
216
+ /**
217
+ * The peer's verdict on the tokens a connection last set, across its reconnects, like Rust's
218
+ * `Tokens::poll_answered`.
219
+ *
220
+ * It covers the tokens the latest set newly presented, or the initial ones before any set: each
221
+ * is granted in band, or is the connection credential a dial carried and the peer accepted.
222
+ * A token the set kept, the connection credential included, counts only once the peer refuses
223
+ * it. The first verdict is the answer, and nothing is re-checked after it: a later revocation, or
224
+ * a new session that refuses a token an earlier one granted, changes nothing.
225
+ *
226
+ * @internal
227
+ */
228
+ export class Verdict {
229
+ #source;
230
+ #tokens;
231
+ // The tokens the latest set newly presented whose verdict is not yet known.
232
+ #fresh;
233
+ // The first verdict on the latest set: null once granted.
234
+ #latched;
235
+ // The connection credential the latest dial presented, once it connected.
236
+ #dialed;
237
+ #connected;
238
+ #held;
239
+ // Why the loop ended, which answers a set no session will.
240
+ #closed;
241
+ // Why the loop stopped retrying its URL, such as a refused first dial: no session will answer
242
+ // until a new key dials, so a waiting set fails with it, but it is no verdict to latch.
243
+ #gaveUp;
244
+ // Bumped whenever an input changes, so a waiting answer looks again.
245
+ #epoch = new Signal(0);
246
+ #stops = [];
247
+ // Stops watching the latest session's credential.
248
+ #unwatch;
249
+ constructor(source, handle) {
250
+ this.#source = source;
251
+ this.#tokens = source.peek();
252
+ this.#fresh = [...new Set(this.#tokens)];
253
+ this.#stops.push(ending(handle).subscribe((err) => {
254
+ if (err)
255
+ this.#end(err);
256
+ }));
257
+ }
258
+ /** Resolve once the peer first answers the latest set: rejects with its refusal, `Unsupported` when a session cannot carry a token in band, or the connection's end. */
259
+ async answered() {
260
+ for (;;) {
261
+ this.#sync();
262
+ this.#record();
263
+ if (this.#latched) {
264
+ if (this.#latched.outcome)
265
+ throw this.#latched.outcome;
266
+ return;
267
+ }
268
+ if (this.#gaveUp)
269
+ throw this.#gaveUp;
270
+ await this.#epoch.changed();
271
+ }
272
+ }
273
+ /** A dial starts: its session answers the connection credential from here, so the last one's answer is kept first. */
274
+ dialing() {
275
+ this.#sync();
276
+ this.#record();
277
+ this.#gaveUp = undefined;
278
+ this.#dialed = undefined;
279
+ this.#connected = undefined;
280
+ this.#release();
281
+ this.#notify();
282
+ }
283
+ /** The latest dial built `session`, even one that already closed: that close may be its answer. */
284
+ connected(session) {
285
+ this.#sync();
286
+ this.#record();
287
+ this.#release();
288
+ const held = heldOf(session);
289
+ if (held && held !== this.#held)
290
+ this.#stops.push(held.changed.subscribe(() => this.#notify()));
291
+ this.#held = held;
292
+ this.#dialed = held?.connection;
293
+ const connected = { credential: wireOf(session).auth.credential };
294
+ this.#connected = connected;
295
+ this.#unwatch = connected.credential.subscribe(() => this.#notify());
296
+ void session.closed.then((end) => {
297
+ // The close is the answer of a session still unanswered: the loop redials with the same credential.
298
+ connected.closed = end ?? new Error("the session closed before the peer accepted its credential");
299
+ if (this.#connected === connected)
300
+ this.#notify();
301
+ });
302
+ this.#notify();
303
+ }
304
+ /** The loop stopped retrying its URL with `err`, which fails a set still waiting for a session. */
305
+ gaveUp(err) {
306
+ this.#gaveUp = err;
307
+ this.#notify();
308
+ }
309
+ /** The tokens the source holds may have changed, such as a set the effect has yet to see. */
310
+ refresh() {
311
+ this.#notify();
312
+ }
313
+ /** The loop ended with `err`, which answers a set no session will. */
314
+ #end(err) {
315
+ this.#sync();
316
+ this.#record();
317
+ this.#closed ??= err;
318
+ this.#release();
319
+ for (const stop of this.#stops.splice(0))
320
+ stop();
321
+ this.#notify();
322
+ }
323
+ /** Take the tokens the source holds now, before an effect would have. */
324
+ #sync() {
325
+ const tokens = this.#source.peek();
326
+ if (tokens === this.#tokens || sameTokens(tokens, this.#tokens))
327
+ return;
328
+ const kept = new Set(this.#tokens);
329
+ // A token still waiting on its verdict stays fresh when the new set keeps it.
330
+ const fresh = [...new Set(tokens)].filter((token) => !kept.has(token) || (this.#fresh.includes(token) && this.#verdict(token) === undefined));
331
+ this.#fresh = fresh;
332
+ this.#tokens = tokens;
333
+ this.#latched = undefined;
334
+ }
335
+ #release() {
336
+ this.#unwatch?.();
337
+ this.#unwatch = undefined;
338
+ }
339
+ #notify() {
340
+ this.#sync();
341
+ this.#record();
342
+ this.#epoch.update((n) => n + 1);
343
+ }
344
+ /** The connection credential the latest dial presented, when the tokens still name it. */
345
+ #named() {
346
+ const connection = this.#dialed;
347
+ return connection !== undefined && this.#tokens.includes(connection) ? connection : undefined;
348
+ }
349
+ /** The peer's verdict on the connection credential: `null` once accepted, undefined while it has none or no session is live. */
350
+ #credential() {
351
+ const connected = this.#connected;
352
+ if (!connected)
353
+ return undefined;
354
+ // A session closed before the peer answered is cut off: its close is the answer.
355
+ const own = connected.credential.peek();
356
+ return own !== undefined ? own : connected.closed;
357
+ }
358
+ /** The peer's verdict on `token` of the latest set, undefined while it has none. */
359
+ #verdict(token) {
360
+ if (this.#held?.has(token))
361
+ return this.#held.verdict(token);
362
+ // Not presented until the first dial.
363
+ return this.#named() === token ? this.#credential() : undefined;
364
+ }
365
+ /** The answer to the latest set: the first refusal of any token it names, or `null` once every fresh token is granted. Undefined while one still waits. */
366
+ #answer() {
367
+ if (this.#latched)
368
+ return this.#latched.outcome;
369
+ if (this.#closed)
370
+ return this.#closed;
371
+ const ended = this.#held?.ended(this.#tokens);
372
+ if (ended)
373
+ return ended;
374
+ const credential = this.#named() === undefined ? undefined : this.#credential();
375
+ if (credential)
376
+ return credential;
377
+ let waiting = false;
378
+ for (const token of this.#fresh) {
379
+ const verdict = this.#verdict(token);
380
+ if (verdict)
381
+ return verdict;
382
+ if (verdict === undefined)
383
+ waiting = true;
384
+ }
385
+ return waiting ? undefined : null;
386
+ }
387
+ /** Keep each verdict the latest set has so far, before a dial, a new session, or a dropped one takes away where it came from. */
388
+ #record() {
389
+ if (this.#latched)
390
+ return;
391
+ const outcome = this.#answer();
392
+ if (outcome !== undefined) {
393
+ if (outcome === null)
394
+ this.#fresh = [];
395
+ this.#latched = { outcome };
396
+ return;
397
+ }
398
+ this.#fresh = this.#fresh.filter((token) => this.#verdict(token) !== null);
399
+ }
400
+ }
401
+ function sameTokens(a, b) {
402
+ return a.length === b.length && a.every((token, i) => token === b[i]);
403
+ }
404
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/connection/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAe,WAAW,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,MAAM,EAAgB,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAuBpC;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ,EAAE,MAAyB,EAAE,OAAgB;IAC/E,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,GAAG;QAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,6EAA6E;QAC7E,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACvC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IACrG,CAAC;IACD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,GAAG,EAAE,CAAC;IACxC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAA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AM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,OAAO,KAAK,IAAI;gBAAE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,GAAG,EAAE,OAAO,EAAE,CAAC;YAC5B,OAAO;QACR,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;IAC5E,CAAC;CACD;AAED,SAAS,UAAU,CAAC,CAAoB,EAAE,CAAoB;IAC7D,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { type Getter, Signal } from \"@moq/signals\";\nimport { type Handle, Unsupported } from \"../auth.ts\";\nimport { ending, type Pending } from \"../auth_session.ts\";\nimport { error } from \"../error.ts\";\nimport { wireOf } from \"../wire.ts\";\nimport type { Session } from \"./session.ts\";\n\n/** What one dial presents, decided from its URL, the offered versions, and the tokens. @internal */\nexport interface Presentation {\n\t/** The URL to dial, carrying the connection credential when an offered version has no SETUP token. */\n\turl: URL;\n\t/** The token SETUP carries, unless the URL brought its own credential. */\n\tsetup?: string;\n\t/** The credential the connection presents, from the URL or SETUP. Never also presented on AUTH. */\n\tconnection?: string;\n\t/** Whether the URL carries it for a relay that takes no token of its own, so its replacements wait for the next dial instead of riding AUTH. */\n\tcarried?: boolean;\n}\n\n/** Where a dial carries its connection credential. @internal */\nexport interface Carrier {\n\t/** Whether every offered version carries a SETUP token, so the URL needs none. */\n\tsetupToken: boolean;\n\t/** Whether the URL's `auth` parameter carries it in place of SETUP and `jwt`. */\n\turlAuth?: boolean;\n}\n\n/**\n * Decide what one dial presents.\n *\n * A URL that already carries a `jwt` keeps it (a per-peer credential), so every token rides\n * AUTH. Otherwise the first token is the connection credential: it rides the URL's `auth`\n * parameter alone when the carrier asks, else SETUP, and the URL's `jwt` too when no `setupToken`\n * is carried, since the URL is fixed before the version is negotiated.\n *\n * @internal\n */\nexport function credential(url: URL, tokens: readonly string[], carrier: Carrier): Presentation {\n\tconst jwt = url.searchParams.get(\"jwt\");\n\tif (jwt) return { url, connection: jwt };\n\tconst first = tokens[0];\n\tif (carrier.urlAuth) {\n\t\t// Even with no token yet, so one that arrives later waits for the next dial.\n\t\tconst carried = { url, carried: true };\n\t\treturn first === undefined ? carried : { ...carried, url: withAuth(url, first), connection: first };\n\t}\n\tif (first === undefined) return { url };\n\treturn { url: carrier.setupToken ? url : withJwt(url, first), setup: first, connection: first };\n}\n\n/**\n * Decide what a dial to the WebSocket fallback's own URL presents.\n *\n * The fallback presents the credential its URL decides, never one taken from the primary:\n * its own `jwt`, else the primary URL's `jwt`, else the configured tokens as {@link credential}\n * decides them.\n *\n * @internal\n */\nexport function fallback(primary: URL, url: URL, tokens: readonly string[], carrier: Carrier): Presentation {\n\tconst inherited = primary.searchParams.get(\"jwt\");\n\tif (inherited && !url.searchParams.get(\"jwt\")) return credential(withJwt(url, inherited), tokens, carrier);\n\treturn credential(url, tokens, carrier);\n}\n\n/** `url` with `jwt` appended to its query. @internal */\nfunction withJwt(url: URL, jwt: string): URL {\n\tconst next = new URL(url);\n\tnext.searchParams.append(\"jwt\", jwt);\n\treturn next;\n}\n\n/** `url` with `auth` set to the credential, replacing any it carried, so it never repeats. */\nfunction withAuth(url: URL, credential: string): URL {\n\tconst next = new URL(url);\n\tnext.searchParams.set(\"auth\", credential);\n\treturn next;\n}\n\n/**\n * The tokens to hold on their own AUTH streams, each once. A credential the URL carries takes\n * no token of the relay's own kind, so its replacement is no AUTH token either: the next dial\n * presents it.\n *\n * @internal\n */\nexport function extra(credential: Presentation, tokens: readonly string[]): string[] {\n\tconst reserved = credential.carried ? tokens[0] : undefined;\n\treturn [...new Set(tokens)].filter((token) => token !== credential.connection && token !== reserved);\n}\n\ninterface Entry {\n\tauth?: Pending;\n\tpending: boolean;\n\t/** Withdrawn by us, so its rejected answer is no refusal. */\n\twithdrawn: boolean;\n\t/** The peer's first verdict: `null` once granted, its refusal, or undefined while unanswered. */\n\tanswer?: Error | null;\n\t/** Why the peer ended the token for good: its refusal or revocation, or the handle's end. */\n\tend?: Error;\n}\n\n/**\n * The configured tokens an auth handle holds on their own AUTH streams, beside the\n * latest dial's connection credential. A handle shared across reconnects keeps them on\n * every session it backs.\n *\n * A change presents the new tokens at once and withdraws the granted ones they replace only\n * after every new one has its answer, so the grant never narrows in between.\n *\n * @internal\n */\nexport class Held {\n\t#handle: Handle;\n\t#credential: Presentation;\n\t#entries = new Map<string, Entry>();\n\t#retiring: Entry[] = [];\n\t#changed = new Signal(0);\n\n\tconstructor(handle: Handle, credential: Presentation) {\n\t\tthis.#handle = handle;\n\t\tthis.#credential = credential;\n\t}\n\n\t/** Bumps whenever a held token is answered or ends. */\n\tget changed(): Signal<number> {\n\t\treturn this.#changed;\n\t}\n\n\t/** The credential the latest dial presented as the connection's, which no AUTH stream carries. */\n\tget connection(): string | undefined {\n\t\treturn this.#credential.connection;\n\t}\n\n\t/** Whether `token` rides its own AUTH stream. */\n\thas(token: string): boolean {\n\t\treturn this.#entries.has(token);\n\t}\n\n\t/**\n\t * The peer's first verdict on held `token`: `null` once granted in band, its refusal, or\n\t * undefined while it has none. A token only a request carries is unsupported, not granted.\n\t */\n\tverdict(token: string): Error | null | undefined {\n\t\treturn this.#entries.get(token)?.answer;\n\t}\n\n\t/** Why the peer ended the first of `tokens` that is held, for good. */\n\tended(tokens: readonly string[]): Error | undefined {\n\t\tfor (const token of tokens) {\n\t\t\tconst end = this.#entries.get(token)?.end;\n\t\t\tif (end) return end;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** A new dial on the handle, whose credential decides which tokens ride AUTH. */\n\tdialed(credential: Presentation, tokens: readonly string[]) {\n\t\tthis.#credential = credential;\n\t\tthis.update(tokens);\n\t}\n\n\t/** Hold exactly `tokens`, other than the connection credential. */\n\tupdate(tokens: readonly string[]) {\n\t\tconst next = new Map<string, Entry>();\n\t\tfor (const token of extra(this.#credential, tokens)) {\n\t\t\tnext.set(token, this.#entries.get(token) ?? this.#present(token));\n\t\t}\n\t\tfor (const [token, entry] of this.#entries) {\n\t\t\tif (next.has(token)) continue;\n\t\t\t// Only a granted token keeps the grant wide; one refused or still unanswered, such as\n\t\t\t// one retrying while its backend fails, is withdrawn at once so repeated updates never\n\t\t\t// pile up retrying streams.\n\t\t\tif (entry.auth?.held) this.#retiring.push(entry);\n\t\t\telse this.#withdraw(entry);\n\t\t}\n\t\tthis.#entries = next;\n\t\tthis.#settle();\n\t}\n\n\t#present(token: string): Entry {\n\t\tconst entry: Entry = { pending: true, withdrawn: false };\n\t\tconst refused = (err: unknown) => {\n\t\t\tif (entry.withdrawn) return;\n\t\t\tif (err instanceof Unsupported) console.debug(\"the peer takes no tokens in band\");\n\t\t\telse console.warn(\"a configured token was refused:\", err);\n\t\t};\n\t\tlet auth: Pending;\n\t\ttry {\n\t\t\t// Registered synchronously, so a request sent right after waits on its answer.\n\t\t\tauth = this.#handle.present(token);\n\t\t} catch (err) {\n\t\t\trefused(err);\n\t\t\tentry.answer = error(err);\n\t\t\tentry.end = entry.answer;\n\t\t\tentry.pending = false;\n\t\t\treturn entry;\n\t\t}\n\t\tentry.auth = auth;\n\t\tauth.answered\n\t\t\t.then(\n\t\t\t\t() => {\n\t\t\t\t\tentry.answer = auth.inband ? null : new Unsupported();\n\t\t\t\t},\n\t\t\t\t(err: unknown) => {\n\t\t\t\t\tentry.answer = error(err);\n\t\t\t\t\trefused(err);\n\t\t\t\t},\n\t\t\t)\n\t\t\t.finally(() => {\n\t\t\t\tentry.pending = false;\n\t\t\t\tthis.#changed.update((n) => n + 1);\n\t\t\t\tthis.#settle();\n\t\t\t});\n\t\t// Withdrawn by us, it ends with no verdict of the peer's.\n\t\tvoid auth.closed.then((end) => {\n\t\t\tif (entry.withdrawn) return;\n\t\t\tentry.end = end ?? new Error(\"the peer ended the token\");\n\t\t\tthis.#changed.update((n) => n + 1);\n\t\t});\n\t\treturn entry;\n\t}\n\n\t#withdraw(entry: Entry) {\n\t\tentry.withdrawn = true;\n\t\tentry.auth?.close();\n\t}\n\n\t#settle() {\n\t\tif ([...this.#entries.values()].some((entry) => entry.pending)) return;\n\t\tfor (const entry of this.#retiring) this.#withdraw(entry);\n\t\tthis.#retiring = [];\n\t}\n}\n\n// The tokens each auth handle holds, so a handle shared across reconnects holds them once\n// and a reconnecting wrapper can update them.\nconst held = new WeakMap<Handle, Held>();\n\n/** Present `tokens` on `connection`, beside the credential its dial carried. @internal */\nexport function hold(connection: Session, credential: Presentation, tokens: readonly string[]): Held {\n\tconst existing = held.get(connection.auth);\n\tif (existing) {\n\t\texisting.dialed(credential, tokens);\n\t\treturn existing;\n\t}\n\tconst tokensHeld = new Held(connection.auth, credential);\n\ttokensHeld.update(tokens);\n\theld.set(connection.auth, tokensHeld);\n\treturn tokensHeld;\n}\n\n/** The tokens `connection` holds, if it was dialed with any. @internal */\nexport function heldOf(connection: Session): Held | undefined {\n\treturn held.get(connection.auth);\n}\n\n/** The latest dial's session, whose own answer to the connection credential counts. */\ninterface Connected {\n\tcredential: Getter<Error | null | undefined>;\n\t/** Why the session closed, once it did. */\n\tclosed?: Error;\n}\n\n/**\n * The peer's verdict on the tokens a connection last set, across its reconnects, like Rust's\n * `Tokens::poll_answered`.\n *\n * It covers the tokens the latest set newly presented, or the initial ones before any set: each\n * is granted in band, or is the connection credential a dial carried and the peer accepted.\n * A token the set kept, the connection credential included, counts only once the peer refuses\n * it. The first verdict is the answer, and nothing is re-checked after it: a later revocation, or\n * a new session that refuses a token an earlier one granted, changes nothing.\n *\n * @internal\n */\nexport class Verdict {\n\t#source: Getter<readonly string[]>;\n\t#tokens: readonly string[];\n\t// The tokens the latest set newly presented whose verdict is not yet known.\n\t#fresh: string[];\n\t// The first verdict on the latest set: null once granted.\n\t#latched?: { outcome: Error | null };\n\t// The connection credential the latest dial presented, once it connected.\n\t#dialed?: string;\n\t#connected?: Connected;\n\t#held?: Held;\n\t// Why the loop ended, which answers a set no session will.\n\t#closed?: Error;\n\t// Why the loop stopped retrying its URL, such as a refused first dial: no session will answer\n\t// until a new key dials, so a waiting set fails with it, but it is no verdict to latch.\n\t#gaveUp?: Error;\n\t// Bumped whenever an input changes, so a waiting answer looks again.\n\t#epoch = new Signal(0);\n\t#stops: (() => void)[] = [];\n\t// Stops watching the latest session's credential.\n\t#unwatch?: () => void;\n\n\tconstructor(source: Getter<readonly string[]>, handle: Handle) {\n\t\tthis.#source = source;\n\t\tthis.#tokens = source.peek();\n\t\tthis.#fresh = [...new Set(this.#tokens)];\n\t\tthis.#stops.push(\n\t\t\tending(handle).subscribe((err) => {\n\t\t\t\tif (err) this.#end(err);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** Resolve once the peer first answers the latest set: rejects with its refusal, `Unsupported` when a session cannot carry a token in band, or the connection's end. */\n\tasync answered(): Promise<void> {\n\t\tfor (;;) {\n\t\t\tthis.#sync();\n\t\t\tthis.#record();\n\t\t\tif (this.#latched) {\n\t\t\t\tif (this.#latched.outcome) throw this.#latched.outcome;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this.#gaveUp) throw this.#gaveUp;\n\t\t\tawait this.#epoch.changed();\n\t\t}\n\t}\n\n\t/** A dial starts: its session answers the connection credential from here, so the last one's answer is kept first. */\n\tdialing(): void {\n\t\tthis.#sync();\n\t\tthis.#record();\n\t\tthis.#gaveUp = undefined;\n\t\tthis.#dialed = undefined;\n\t\tthis.#connected = undefined;\n\t\tthis.#release();\n\t\tthis.#notify();\n\t}\n\n\t/** The latest dial built `session`, even one that already closed: that close may be its answer. */\n\tconnected(session: Session): void {\n\t\tthis.#sync();\n\t\tthis.#record();\n\t\tthis.#release();\n\t\tconst held = heldOf(session);\n\t\tif (held && held !== this.#held) this.#stops.push(held.changed.subscribe(() => this.#notify()));\n\t\tthis.#held = held;\n\t\tthis.#dialed = held?.connection;\n\t\tconst connected: Connected = { credential: wireOf(session).auth.credential };\n\t\tthis.#connected = connected;\n\t\tthis.#unwatch = connected.credential.subscribe(() => this.#notify());\n\t\tvoid session.closed.then((end) => {\n\t\t\t// The close is the answer of a session still unanswered: the loop redials with the same credential.\n\t\t\tconnected.closed = end ?? new Error(\"the session closed before the peer accepted its credential\");\n\t\t\tif (this.#connected === connected) this.#notify();\n\t\t});\n\t\tthis.#notify();\n\t}\n\n\t/** The loop stopped retrying its URL with `err`, which fails a set still waiting for a session. */\n\tgaveUp(err: Error): void {\n\t\tthis.#gaveUp = err;\n\t\tthis.#notify();\n\t}\n\n\t/** The tokens the source holds may have changed, such as a set the effect has yet to see. */\n\trefresh(): void {\n\t\tthis.#notify();\n\t}\n\n\t/** The loop ended with `err`, which answers a set no session will. */\n\t#end(err: Error): void {\n\t\tthis.#sync();\n\t\tthis.#record();\n\t\tthis.#closed ??= err;\n\t\tthis.#release();\n\t\tfor (const stop of this.#stops.splice(0)) stop();\n\t\tthis.#notify();\n\t}\n\n\t/** Take the tokens the source holds now, before an effect would have. */\n\t#sync(): void {\n\t\tconst tokens = this.#source.peek();\n\t\tif (tokens === this.#tokens || sameTokens(tokens, this.#tokens)) return;\n\t\tconst kept = new Set(this.#tokens);\n\t\t// A token still waiting on its verdict stays fresh when the new set keeps it.\n\t\tconst fresh = [...new Set(tokens)].filter(\n\t\t\t(token) => !kept.has(token) || (this.#fresh.includes(token) && this.#verdict(token) === undefined),\n\t\t);\n\t\tthis.#fresh = fresh;\n\t\tthis.#tokens = tokens;\n\t\tthis.#latched = undefined;\n\t}\n\n\t#release(): void {\n\t\tthis.#unwatch?.();\n\t\tthis.#unwatch = undefined;\n\t}\n\n\t#notify(): void {\n\t\tthis.#sync();\n\t\tthis.#record();\n\t\tthis.#epoch.update((n) => n + 1);\n\t}\n\n\t/** The connection credential the latest dial presented, when the tokens still name it. */\n\t#named(): string | undefined {\n\t\tconst connection = this.#dialed;\n\t\treturn connection !== undefined && this.#tokens.includes(connection) ? connection : undefined;\n\t}\n\n\t/** The peer's verdict on the connection credential: `null` once accepted, undefined while it has none or no session is live. */\n\t#credential(): Error | null | undefined {\n\t\tconst connected = this.#connected;\n\t\tif (!connected) return undefined;\n\t\t// A session closed before the peer answered is cut off: its close is the answer.\n\t\tconst own = connected.credential.peek();\n\t\treturn own !== undefined ? own : connected.closed;\n\t}\n\n\t/** The peer's verdict on `token` of the latest set, undefined while it has none. */\n\t#verdict(token: string): Error | null | undefined {\n\t\tif (this.#held?.has(token)) return this.#held.verdict(token);\n\t\t// Not presented until the first dial.\n\t\treturn this.#named() === token ? this.#credential() : undefined;\n\t}\n\n\t/** The answer to the latest set: the first refusal of any token it names, or `null` once every fresh token is granted. Undefined while one still waits. */\n\t#answer(): Error | null | undefined {\n\t\tif (this.#latched) return this.#latched.outcome;\n\t\tif (this.#closed) return this.#closed;\n\t\tconst ended = this.#held?.ended(this.#tokens);\n\t\tif (ended) return ended;\n\t\tconst credential = this.#named() === undefined ? undefined : this.#credential();\n\t\tif (credential) return credential;\n\t\tlet waiting = false;\n\t\tfor (const token of this.#fresh) {\n\t\t\tconst verdict = this.#verdict(token);\n\t\t\tif (verdict) return verdict;\n\t\t\tif (verdict === undefined) waiting = true;\n\t\t}\n\t\treturn waiting ? undefined : null;\n\t}\n\n\t/** Keep each verdict the latest set has so far, before a dial, a new session, or a dropped one takes away where it came from. */\n\t#record(): void {\n\t\tif (this.#latched) return;\n\t\tconst outcome = this.#answer();\n\t\tif (outcome !== undefined) {\n\t\t\tif (outcome === null) this.#fresh = [];\n\t\t\tthis.#latched = { outcome };\n\t\t\treturn;\n\t\t}\n\t\tthis.#fresh = this.#fresh.filter((token) => this.#verdict(token) !== null);\n\t}\n}\n\nfunction sameTokens(a: readonly string[], b: readonly string[]): boolean {\n\treturn a.length === b.length && a.every((token, i) => token === b[i]);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/connection/transport.ts"],"names":[],"mappings":"AAEA,8CAA8C;AAC9C,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,WAAW,CAAC"}
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/connection/transport.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,WAAW,CAAC"}
@@ -1,11 +1,11 @@
1
- import Session from "@moq/qmux";
2
1
  /**
3
- * The transport a live session is actually running over. qmux implements the `WebTransport`
4
- * interface on top of a WebSocket, so the two are indistinguishable by shape.
2
+ * The transport a live session is actually running over. The WebSocket adapter shares the
3
+ * WebTransport shape and carries its label, so `@moq/qmux` stays a lazy chunk.
5
4
  *
6
5
  * @internal Not re-exported from the package entrypoint.
7
6
  */
8
7
  export function transportOf(quic) {
9
- return quic instanceof Session ? "websocket" : "webtransport";
8
+ const label = "transport" in quic ? quic.transport : undefined;
9
+ return label === "websocket" ? label : "webtransport";
10
10
  }
11
11
  //# sourceMappingURL=transport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/connection/transport.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAKhC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAkB;IAC7C,OAAO,IAAI,YAAY,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC;AAC/D,CAAC","sourcesContent":["import Session from \"@moq/qmux\";\n\n/** The wire transport a session runs over. */\nexport type Transport = \"webtransport\" | \"websocket\";\n\n/**\n * The transport a live session is actually running over. qmux implements the `WebTransport`\n * interface on top of a WebSocket, so the two are indistinguishable by shape.\n *\n * @internal Not re-exported from the package entrypoint.\n */\nexport function transportOf(quic: WebTransport): Transport {\n\treturn quic instanceof Session ? \"websocket\" : \"webtransport\";\n}\n"]}
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/connection/transport.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAkB;IAC7C,MAAM,KAAK,GAAG,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/D,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC;AACvD,CAAC","sourcesContent":["/** The wire transport a session runs over. */\nexport type Transport = \"webtransport\" | \"websocket\";\n\n/**\n * The transport a live session is actually running over. The WebSocket adapter shares the\n * WebTransport shape and carries its label, so `@moq/qmux` stays a lazy chunk.\n *\n * @internal Not re-exported from the package entrypoint.\n */\nexport function transportOf(quic: WebTransport): Transport {\n\tconst label = \"transport\" in quic ? quic.transport : undefined;\n\treturn label === \"websocket\" ? label : \"webtransport\";\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=withdrawal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../../src/connection/withdrawal.ts"],"names":[],"mappings":""}