@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
package/hop.d.ts CHANGED
@@ -1,26 +1,22 @@
1
+ import * as Identity from "./identity.ts";
2
+ import { type StreamVersion } from "./stream.ts";
1
3
  /**
2
- * Endpoint identity within a hop chain, shared by both wire protocols.
4
+ * One relay's identity in a broadcast's hop chain: any 64-bit id.
3
5
  *
4
- * moq-lite carries these natively on every announcement; moq-transport carries them
5
- * via the MoQ Cluster extension (see `ietf/cluster.ts`). Mirrors `Hop` in
6
- * `rs/moq-net`.
7
- *
8
- * @module
9
- */
10
- import * as z from "zod/mini";
11
- /**
12
- * One relay's identity in a broadcast's hop chain, encoded as a 62-bit varint on the wire.
13
- *
14
- * Names a *hop*, not an {@link !Origin | Origin} routing table: this is the id a relay
6
+ * Names a *hop*, not an `Origin` routing table: this is the id a relay
15
7
  * stamps into a chain as an announcement passes through, so a receiver can spot its own
16
8
  * id and reject a loop. The SETUP parameter that carries it session-wide is `Hop` too.
17
9
  *
18
- * The {@link HopSchema} validates any incoming value and brands it so the type system
10
+ * {@link toHop} validates any incoming value and brands it so the type system
19
11
  * enforces "only validated ids flow into hop chains." Internal code that synthesizes one
20
- * (e.g. {@link randomHop}) uses `HopSchema.parse(...)` to brand a raw bigint.
12
+ * (e.g. `randomHop`) brands a raw bigint the same way.
21
13
  */
22
- export declare const HopSchema: z.core.$ZodBranded<z.ZodMiniBigInt<bigint>, "Hop", "out">;
23
- export type Hop = z.infer<typeof HopSchema>;
14
+ export type Hop = bigint & {
15
+ readonly [hopBrand]: true;
16
+ };
17
+ declare const hopBrand: unique symbol;
18
+ /** Brand `value` as a {@link Hop}, refusing anything outside the unsigned 64-bit range. */
19
+ export declare function toHop(value: bigint): Hop;
24
20
  /**
25
21
  * The reserved id 0, meaning "no identity".
26
22
  *
@@ -30,6 +26,14 @@ export type Hop = z.infer<typeof HopSchema>;
30
26
  * is anonymous for route selection.
31
27
  */
32
28
  export declare const UNKNOWN_HOP: Hop;
29
+ /**
30
+ * The id `hop` carries on a wire in `version`'s varint form.
31
+ *
32
+ * A QUIC varint stops at 2^62-1, so a larger id travels as {@link UNKNOWN_HOP}: the route
33
+ * still reaches the peer, losing loop detection through this hop on that link only.
34
+ * Mirrors `Hop::wire_id` in rs/moq-net.
35
+ */
36
+ export declare function wireHop(hop: Hop, version: StreamVersion): Hop;
33
37
  /**
34
38
  * Maximum length of a hop chain. Must match `MAX_HOPS` in Rust's `model/origin.rs`.
35
39
  *
@@ -43,73 +47,55 @@ export declare const MAX_HOPS = 32;
43
47
  * `crypto.getRandomValues` is overkill for best-effort loop detection, but
44
48
  * used for slightly better distribution than `Math.random` at negligible cost.
45
49
  *
46
- * TEMPORARY: the wire format allows 62 bits, but older `@moq/lite` JS clients
47
- * decode `AnnounceInterest.exclude_hop` as a u53 (number) and throw on anything
48
- * > 2^53-1. To keep those clients alive against fresh peers, we cap the random
49
- * id at 53 bits. Restore to 62 bits once the u62 fix has propagated to deployed
50
- * bundles. Mirrors `Hop::random` in rs/moq-net.
50
+ * Older `@moq/lite` JS clients decode `AnnounceInterest.exclude_hop` as a u53
51
+ * (number) and throw on anything > 2^53-1, so the random id stays below 2^53 to keep
52
+ * those clients alive against fresh peers. Mirrors `Hop::random` in rs/moq-net.
51
53
  */
52
54
  export declare function randomHop(): Hop;
53
- /**
54
- * Name an unknown original publisher: put `stamp`, the receiving connection's own random id,
55
- * in front of a chain that starts with 0, and turn an empty chain into `[stamp, 0]`. A
56
- * publisher that reconnects then reads downstream as a new first hop, while the 0 after the
57
- * stamp keeps the route ranked as anonymous. `undefined` if the chain is full or already holds
58
- * `stamp`. Mirrors `Hops::stamp` in rs/moq-net.
59
- */
60
- export declare function stampHops(hops: readonly Hop[], stamp: Hop): Hop[] | undefined;
61
- /**
62
- * What pulling content via a route costs, in two magnitudes accumulated together
63
- * and compared in that order: lower {@link Cost.warm} wins, and {@link Cost.cold}
64
- * breaks the tie.
65
- *
66
- * Both price the same path against different cache states. `warm` is what one more
67
- * subscription would cost the mesh right now, so it collapses to zero at any relay
68
- * already carrying the broadcast. `cold` prices the identical path as if nothing were
69
- * cached, so it keeps flowing through a warm relay unchanged and still says which of
70
- * two warm relays sits closer to the publisher.
71
- */
72
- export interface Cost {
73
- /** The cost as the mesh stands today, discounted to zero at every carrying relay. */
74
- warm: bigint;
75
- /** The same path with every warm discount removed. */
76
- cold: bigint;
77
- }
78
- /** Constructors for {@link Cost}. */
55
+ /** The static cost of pulling content through a route; lower wins. */
56
+ export type Cost = bigint;
57
+ /** Common route prices. */
79
58
  export declare const Cost: {
80
- /** A free path in both magnitudes: what a live publisher seeds. */
81
- zero: Cost;
59
+ /** The price a live publisher seeds. */
60
+ zero: bigint;
61
+ /** Crossing a link neither end priced, so an unpriced mesh routes by hop count. */
62
+ link: bigint;
63
+ /** The most a wire cost carries. */
64
+ max: bigint;
65
+ /** A route's cost plus the price of the link it arrived on, saturating at {@link Cost.max}. */
66
+ charged(route: Cost, link: Cost): Cost;
82
67
  };
83
68
  /**
84
- * The path a route took through the mesh and what using it costs.
69
+ * The stream a received route serves and what using it costs: read-only facts on an
70
+ * announcement. Mirrors `RouteInfo` in rs/moq-net.
85
71
  *
86
- * The metadata half of an advertisement: an origin `dynamic()` pairs it with the
87
- * pattern it covers, a broadcast `announce()` with the broadcast's exact path, and
88
- * an announce event carries it so consumers can read it back.
72
+ * Carried by an announce event. Applications never build one: an origin `Route` takes
73
+ * `RouteOptions`, and the origin and the relays fill in the rest.
89
74
  */
90
- export interface Route {
91
- /** The chain of hops the route has traversed, oldest first. */
92
- hops: Hop[];
75
+ export interface RouteInfo {
76
+ /**
77
+ * The stream the route serves: routes with one identity serve one continuous sequence
78
+ * space, so a subscription resumes from one to another. Pass it to an origin `request` to
79
+ * pin this stream.
80
+ */
81
+ readonly identity: Identity.Valid;
93
82
  /** What pulling content via this route costs; lower wins. */
94
- cost: Cost;
83
+ readonly cost: Cost;
84
+ /**
85
+ * Whether a usable path reaches the route's origin. An unavailable route is held: the
86
+ * network lost every path to it but may recover one, so the announcement stays. It ranks
87
+ * below every available claim of its prefix, a draining one included, though a more specific
88
+ * claim still shadows a broader one, and requests through it may fail until it recovers:
89
+ * request again once it turns available.
90
+ */
91
+ readonly available: boolean;
92
+ /**
93
+ * Whether the route ranks below every other available one, whatever its cost, yet above one
94
+ * held unavailable, and still serves when nothing else does: the session it arrived on is
95
+ * going away (the peer sent a GOAWAY), or a lite-07 path to its origin crosses such a session.
96
+ * A ranking state, never a saturated cost.
97
+ */
98
+ readonly draining: boolean;
95
99
  }
96
- /** Constructors and helpers for {@link Route}. */
97
- export declare const Route: {
98
- /** An empty hop chain at zero cost: what a publisher seeds for a live broadcast. */
99
- default: Route;
100
- /** Normalize a partial route, treating a bare bigint cost as both magnitudes alike. */
101
- normalize(route?: Route | {
102
- hops?: readonly Hop[];
103
- cost?: Cost | bigint;
104
- }): Route;
105
- };
106
- /**
107
- * Whether this route passed through an anonymous hop (id 0) at any depth.
108
- *
109
- * An empty chain is a local announcement, not the anonymous mark. Ingress fills a
110
- * received empty list with {@link UNKNOWN_HOP} before yielding it.
111
- */
112
- export declare function isAnonymous(route: Route): boolean;
113
- /** Whether two routes name the same hop chain and cost. */
114
- export declare function routesEqual(a: Route | undefined, b: Route | undefined): boolean;
100
+ export {};
115
101
  //# sourceMappingURL=hop.d.ts.map
package/hop.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hop.d.ts","sourceRoot":"","sources":["../src/hop.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,2DAGR,CAAC;AAEf,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,GAAyB,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,KAAK,CAAC;AAE3B;;;;;;;;;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AAM,GAAG;IAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAEzD,OAAO,CAAC,MAAM,QAAQ,EAAE,OAAO,MAAM,CAAC;AAEtC,2FAA2F;AAC3F,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAGxC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,GAAe,CAAC;AAE1C;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,GAAG,GAAG,CAE7D;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,KAAK,CAAC;AAE3B;;;;;;;;;GASG;AACH,wBAAgB,SAAS,IAAI,GAAG,CAO/B;AAED,sEAAsE;AACtE,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,2BAA2B;AAC3B,eAAO,MAAM,IAAI;IAChB,wCAAwC;IACxC,IAAI;IACJ,mFAAmF;IACnF,IAAI;IACJ,oCAAoC;IACpC,GAAG;IACH,+FAA+F;IAC/F,OAAO,QAAQ,IAAI,QAAQ,IAAI,GAAG,IAAI;CAItC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACzB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC;IAClC,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC3B"}
package/hop.js CHANGED
@@ -1,28 +1,11 @@
1
- /**
2
- * Endpoint identity within a hop chain, shared by both wire protocols.
3
- *
4
- * moq-lite carries these natively on every announcement; moq-transport carries them
5
- * via the MoQ Cluster extension (see `ietf/cluster.ts`). Mirrors `Hop` in
6
- * `rs/moq-net`.
7
- *
8
- * @module
9
- */
10
- import * as z from "zod/mini";
11
- /**
12
- * One relay's identity in a broadcast's hop chain, encoded as a 62-bit varint on the wire.
13
- *
14
- * Names a *hop*, not an {@link !Origin | Origin} routing table: this is the id a relay
15
- * stamps into a chain as an announcement passes through, so a receiver can spot its own
16
- * id and reject a loop. The SETUP parameter that carries it session-wide is `Hop` too.
17
- *
18
- * The {@link HopSchema} validates any incoming value and brands it so the type system
19
- * enforces "only validated ids flow into hop chains." Internal code that synthesizes one
20
- * (e.g. {@link randomHop}) uses `HopSchema.parse(...)` to brand a raw bigint.
21
- */
22
- export const HopSchema = z
23
- .bigint()
24
- .check(z.refine((value) => value >= 0n && value < 1n << 62n, "Hop must be a non-negative 62-bit integer"))
25
- .brand("Hop");
1
+ import * as Identity from "./identity.js";
2
+ import { isLeadingOnes } from "./stream.js";
3
+ /** Brand `value` as a {@link Hop}, refusing anything outside the unsigned 64-bit range. */
4
+ export function toHop(value) {
5
+ if (value < 0n || value >= 1n << 64n)
6
+ throw new RangeError("Hop must be a non-negative 64-bit integer");
7
+ return value;
8
+ }
26
9
  /**
27
10
  * The reserved id 0, meaning "no identity".
28
11
  *
@@ -31,7 +14,17 @@ export const HopSchema = z
31
14
  * in common, and never excluded from an advertisement. A chain that holds a 0 anywhere
32
15
  * is anonymous for route selection.
33
16
  */
34
- export const UNKNOWN_HOP = HopSchema.parse(0n);
17
+ export const UNKNOWN_HOP = toHop(0n);
18
+ /**
19
+ * The id `hop` carries on a wire in `version`'s varint form.
20
+ *
21
+ * A QUIC varint stops at 2^62-1, so a larger id travels as {@link UNKNOWN_HOP}: the route
22
+ * still reaches the peer, losing loop detection through this hop on that link only.
23
+ * Mirrors `Hop::wire_id` in rs/moq-net.
24
+ */
25
+ export function wireHop(hop, version) {
26
+ return hop >= 1n << 62n && !isLeadingOnes(version) ? UNKNOWN_HOP : hop;
27
+ }
35
28
  /**
36
29
  * Maximum length of a hop chain. Must match `MAX_HOPS` in Rust's `model/origin.rs`.
37
30
  *
@@ -45,11 +38,9 @@ export const MAX_HOPS = 32;
45
38
  * `crypto.getRandomValues` is overkill for best-effort loop detection, but
46
39
  * used for slightly better distribution than `Math.random` at negligible cost.
47
40
  *
48
- * TEMPORARY: the wire format allows 62 bits, but older `@moq/lite` JS clients
49
- * decode `AnnounceInterest.exclude_hop` as a u53 (number) and throw on anything
50
- * > 2^53-1. To keep those clients alive against fresh peers, we cap the random
51
- * id at 53 bits. Restore to 62 bits once the u62 fix has propagated to deployed
52
- * bundles. Mirrors `Hop::random` in rs/moq-net.
41
+ * Older `@moq/lite` JS clients decode `AnnounceInterest.exclude_hop` as a u53
42
+ * (number) and throw on anything > 2^53-1, so the random id stays below 2^53 to keep
43
+ * those clients alive against fresh peers. Mirrors `Hop::random` in rs/moq-net.
53
44
  */
54
45
  export function randomHop() {
55
46
  const buf = new BigUint64Array(1);
@@ -57,61 +48,98 @@ export function randomHop() {
57
48
  // Mask to 53 bits.
58
49
  const raw = buf[0] & 0x1fffffffffffffn;
59
50
  // Guard against the (astronomically unlikely) zero draw.
60
- return HopSchema.parse(raw === 0n ? 1n : raw);
51
+ return toHop(raw === 0n ? 1n : raw);
61
52
  }
53
+ /** Common route prices. */
54
+ export const Cost = {
55
+ /** The price a live publisher seeds. */
56
+ zero: 0n,
57
+ /** Crossing a link neither end priced, so an unpriced mesh routes by hop count. */
58
+ link: 1n,
59
+ /** The most a wire cost carries. */
60
+ max: 2n ** 62n - 1n,
61
+ /** A route's cost plus the price of the link it arrived on, saturating at {@link Cost.max}. */
62
+ charged(route, link) {
63
+ const sum = route + link;
64
+ return sum > Cost.max ? Cost.max : sum;
65
+ },
66
+ };
62
67
  /**
63
- * Name an unknown original publisher: put `stamp`, the receiving connection's own random id,
64
- * in front of a chain that starts with 0, and turn an empty chain into `[stamp, 0]`. A
65
- * publisher that reconnects then reads downstream as a new first hop, while the 0 after the
66
- * stamp keeps the route ranked as anonymous. `undefined` if the chain is full or already holds
67
- * `stamp`. Mirrors `Hops::stamp` in rs/moq-net.
68
+ * The read-only facts an announcement shows of `route`, leaving its epoch, hop chain, and
69
+ * credential internal.
70
+ *
71
+ * @internal
68
72
  */
69
- export function stampHops(hops, stamp) {
70
- if (hops.length === 0)
71
- return [stamp, UNKNOWN_HOP];
72
- if (hops[0] !== UNKNOWN_HOP)
73
- return [...hops];
74
- if (hops.length >= MAX_HOPS || hops.includes(stamp))
75
- return undefined;
76
- return [stamp, ...hops];
73
+ export function routeInfo(route) {
74
+ if (route.identity === undefined)
75
+ throw new Error("a delivered route has an identity");
76
+ return {
77
+ identity: route.identity,
78
+ cost: route.cost,
79
+ available: route.available ?? true,
80
+ draining: route.draining ?? false,
81
+ };
77
82
  }
78
- /** Constructors for {@link Cost}. */
79
- export const Cost = {
80
- /** A free path in both magnitudes: what a live publisher seeds. */
81
- zero: { warm: 0n, cold: 0n },
82
- };
83
- /** Constructors and helpers for {@link Route}. */
84
- export const Route = {
83
+ /** Constructors and helpers for {@link WireRoute}. @internal */
84
+ export const WireRoute = {
85
85
  /** An empty hop chain at zero cost: what a publisher seeds for a live broadcast. */
86
86
  default: { hops: [], cost: Cost.zero },
87
- /** Normalize a partial route, treating a bare bigint cost as both magnitudes alike. */
87
+ /**
88
+ * Fill route defaults and saturate the static price at the wire ceiling. A plain JavaScript
89
+ * caller can pass any string as a named identity, so its text is checked as `Identity.parse`
90
+ * does, before a peer refuses it.
91
+ */
88
92
  normalize(route = {}) {
89
- const hops = route.hops ? [...route.hops] : [];
90
- const cost = route.cost;
91
- if (cost === undefined)
92
- return { hops, cost: Cost.zero };
93
- if (typeof cost === "bigint")
94
- return { hops, cost: { warm: cost, cold: cost } };
95
- return { hops, cost: { warm: cost.warm, cold: cost.cold } };
93
+ const cost = route.cost ?? Cost.zero;
94
+ if (typeof cost !== "bigint" || cost < 0n)
95
+ throw new RangeError("route cost must be a non-negative bigint");
96
+ const identity = typeof route.identity === "string" ? Identity.parse(route.identity) : route.identity;
97
+ const max = 2n ** 62n - 1n;
98
+ return {
99
+ identity,
100
+ epoch: identity === undefined ? undefined : (route.epoch ?? 0n),
101
+ hops: route.hops ? [...route.hops] : [],
102
+ cost: cost > max ? max : cost,
103
+ auth: route.auth,
104
+ draining: route.draining,
105
+ available: route.available,
106
+ claimed: route.claimed,
107
+ priority: route.priority,
108
+ above: route.above,
109
+ };
96
110
  },
97
111
  };
98
112
  /**
99
113
  * Whether this route passed through an anonymous hop (id 0) at any depth.
100
114
  *
101
115
  * An empty chain is a local announcement, not the anonymous mark. Ingress fills a
102
- * received empty list with {@link UNKNOWN_HOP} before yielding it.
116
+ * received empty list with the anonymous hop before yielding it.
117
+ *
118
+ * @internal
103
119
  */
104
120
  export function isAnonymous(route) {
105
121
  return route.hops.includes(UNKNOWN_HOP);
106
122
  }
107
- /** Whether two routes name the same hop chain and cost. */
123
+ /**
124
+ * Whether two routes name the same identity, epoch, hop chain, cost, auth, drain state,
125
+ * availability, whether a lite-07 peer claimed it, priority, and how far above its path a claim is.
126
+ *
127
+ * @internal
128
+ */
108
129
  export function routesEqual(a, b) {
109
130
  if (a === b)
110
131
  return true;
111
132
  if (!a || !b)
112
133
  return false;
113
- return (a.cost.warm === b.cost.warm &&
114
- a.cost.cold === b.cost.cold &&
134
+ return (a.identity === b.identity &&
135
+ a.epoch === b.epoch &&
136
+ a.cost === b.cost &&
137
+ a.auth === b.auth &&
138
+ (a.draining ?? false) === (b.draining ?? false) &&
139
+ (a.available ?? true) === (b.available ?? true) &&
140
+ (a.claimed ?? false) === (b.claimed ?? false) &&
141
+ (a.priority ?? 0) === (b.priority ?? 0) &&
142
+ (a.above ?? 0n) === (b.above ?? 0n) &&
115
143
  a.hops.length === b.hops.length &&
116
144
  a.hops.every((hop, i) => hop === b.hops[i]));
117
145
  }
package/hop.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hop.js","sourceRoot":"","sources":["../src/hop.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,CAAC,MAAM,UAAU,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AAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,CACN,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI;QAC3B,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI;QAC3B,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM;QAC/B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AACH,CAAC","sourcesContent":["/**\n * Endpoint identity within a hop chain, shared by both wire protocols.\n *\n * moq-lite carries these natively on every announcement; moq-transport carries them\n * via the MoQ Cluster extension (see `ietf/cluster.ts`). Mirrors `Hop` in\n * `rs/moq-net`.\n *\n * @module\n */\nimport * as z from \"zod/mini\";\n\n/**\n * One relay's identity in a broadcast's hop chain, encoded as a 62-bit varint on the wire.\n *\n * Names a *hop*, not an {@link !Origin | Origin} routing table: this is the id a relay\n * stamps into a chain as an announcement passes through, so a receiver can spot its own\n * id and reject a loop. The SETUP parameter that carries it session-wide is `Hop` too.\n *\n * The {@link HopSchema} validates any incoming value and brands it so the type system\n * enforces \"only validated ids flow into hop chains.\" Internal code that synthesizes one\n * (e.g. {@link randomHop}) uses `HopSchema.parse(...)` to brand a raw bigint.\n */\nexport const HopSchema = z\n\t.bigint()\n\t.check(z.refine((value) => value >= 0n && value < 1n << 62n, \"Hop must be a non-negative 62-bit integer\"))\n\t.brand(\"Hop\");\n\nexport type Hop = z.infer<typeof HopSchema>;\n\n/**\n * The reserved id 0, meaning \"no identity\".\n *\n * It stands in for an endpoint that never declared one, and any number of endpoints can\n * be 0, so it identifies nothing: it is never a loop, never a publisher two chains have\n * in common, and never excluded from an advertisement. A chain that holds a 0 anywhere\n * is anonymous for route selection.\n */\nexport const UNKNOWN_HOP: Hop = HopSchema.parse(0n);\n\n/**\n * Maximum length of a hop chain. Must match `MAX_HOPS` in Rust's `model/origin.rs`.\n *\n * Broadcasts with longer chains are rejected, which bounds loop detection and rejects\n * pathological announcements across clusters with unbounded forwarding.\n */\nexport const MAX_HOPS = 32;\n\n/**\n * Generate a fresh hop with a random non-zero id.\n *\n * `crypto.getRandomValues` is overkill for best-effort loop detection, but\n * used for slightly better distribution than `Math.random` at negligible cost.\n *\n * TEMPORARY: the wire format allows 62 bits, but older `@moq/lite` JS clients\n * decode `AnnounceInterest.exclude_hop` as a u53 (number) and throw on anything\n * > 2^53-1. To keep those clients alive against fresh peers, we cap the random\n * id at 53 bits. Restore to 62 bits once the u62 fix has propagated to deployed\n * bundles. Mirrors `Hop::random` in rs/moq-net.\n */\nexport function randomHop(): Hop {\n\tconst buf = new BigUint64Array(1);\n\tcrypto.getRandomValues(buf);\n\t// Mask to 53 bits.\n\tconst raw = buf[0] & 0x1f_ffff_ffff_ffffn;\n\t// Guard against the (astronomically unlikely) zero draw.\n\treturn HopSchema.parse(raw === 0n ? 1n : raw);\n}\n\n/**\n * Name an unknown original publisher: put `stamp`, the receiving connection's own random id,\n * in front of a chain that starts with 0, and turn an empty chain into `[stamp, 0]`. A\n * publisher that reconnects then reads downstream as a new first hop, while the 0 after the\n * stamp keeps the route ranked as anonymous. `undefined` if the chain is full or already holds\n * `stamp`. Mirrors `Hops::stamp` in rs/moq-net.\n */\nexport function stampHops(hops: readonly Hop[], stamp: Hop): Hop[] | undefined {\n\tif (hops.length === 0) return [stamp, UNKNOWN_HOP];\n\tif (hops[0] !== UNKNOWN_HOP) return [...hops];\n\tif (hops.length >= MAX_HOPS || hops.includes(stamp)) return undefined;\n\treturn [stamp, ...hops];\n}\n\n/**\n * What pulling content via a route costs, in two magnitudes accumulated together\n * and compared in that order: lower {@link Cost.warm} wins, and {@link Cost.cold}\n * breaks the tie.\n *\n * Both price the same path against different cache states. `warm` is what one more\n * subscription would cost the mesh right now, so it collapses to zero at any relay\n * already carrying the broadcast. `cold` prices the identical path as if nothing were\n * cached, so it keeps flowing through a warm relay unchanged and still says which of\n * two warm relays sits closer to the publisher.\n */\nexport interface Cost {\n\t/** The cost as the mesh stands today, discounted to zero at every carrying relay. */\n\twarm: bigint;\n\t/** The same path with every warm discount removed. */\n\tcold: bigint;\n}\n\n/** Constructors for {@link Cost}. */\nexport const Cost = {\n\t/** A free path in both magnitudes: what a live publisher seeds. */\n\tzero: { warm: 0n, cold: 0n } as Cost,\n};\n\n/**\n * The path a route took through the mesh and what using it costs.\n *\n * The metadata half of an advertisement: an origin `dynamic()` pairs it with the\n * pattern it covers, a broadcast `announce()` with the broadcast's exact path, and\n * an announce event carries it so consumers can read it back.\n */\nexport interface Route {\n\t/** The chain of hops the route has traversed, oldest first. */\n\thops: Hop[];\n\t/** What pulling content via this route costs; lower wins. */\n\tcost: Cost;\n}\n\n/** Constructors and helpers for {@link Route}. */\nexport const Route = {\n\t/** An empty hop chain at zero cost: what a publisher seeds for a live broadcast. */\n\tdefault: { hops: [], cost: Cost.zero } as Route,\n\n\t/** Normalize a partial route, treating a bare bigint cost as both magnitudes alike. */\n\tnormalize(route: Route | { hops?: readonly Hop[]; cost?: Cost | bigint } = {}): Route {\n\t\tconst hops = route.hops ? [...route.hops] : [];\n\t\tconst cost = route.cost;\n\t\tif (cost === undefined) return { hops, cost: Cost.zero };\n\t\tif (typeof cost === \"bigint\") return { hops, cost: { warm: cost, cold: cost } };\n\t\treturn { hops, cost: { warm: cost.warm, cold: cost.cold } };\n\t},\n};\n\n/**\n * Whether this route passed through an anonymous hop (id 0) at any depth.\n *\n * An empty chain is a local announcement, not the anonymous mark. Ingress fills a\n * received empty list with {@link UNKNOWN_HOP} before yielding it.\n */\nexport function isAnonymous(route: Route): boolean {\n\treturn route.hops.includes(UNKNOWN_HOP);\n}\n\n/** Whether two routes name the same hop chain and cost. */\nexport function routesEqual(a: Route | undefined, b: Route | undefined): boolean {\n\tif (a === b) return true;\n\tif (!a || !b) return false;\n\treturn (\n\t\ta.cost.warm === b.cost.warm &&\n\t\ta.cost.cold === b.cost.cold &&\n\t\ta.hops.length === b.hops.length &&\n\t\ta.hops.every((hop, i) => hop === b.hops[i])\n\t);\n}\n"]}
1
+ {"version":3,"file":"hop.js","sourceRoot":"","sources":["../src/hop.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAC;AAiBhE,2FAA2F;AAC3F,MAAM,UAAU,KAAK,CAAC,KAAa;IAClC,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,IAAI,EAAE,IAAI,GAAG;QAAE,MAAM,IAAI,UAAU,CAAC,2CAA2C,CAAC,CAAC;IACxG,OAAO,KAAY,CAAC;AACrB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,GAAQ,EAAE,OAAsB;IACvD,OAAO,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC;AACxE,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAC;AAE3B;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS;IACxB,MAAM,GAAG,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC5B,mBAAmB;IACnB,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,iBAAoB,CAAC;IAC1C,yDAAyD;IACzD,OAAO,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC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AC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC;QAC/C,CAAC,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC;QAC/C,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC;QAC7C,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACnC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM;QAC/B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AACH,CAAC","sourcesContent":["/**\n * Endpoint identity within a hop chain, shared by both wire protocols.\n *\n * moq-lite carries these natively on every announcement; moq-transport carries them\n * via the MoQ Cluster extension (see `ietf/cluster.ts`). Mirrors `Hop` in\n * `rs/moq-net`.\n *\n * @module\n */\nimport type { Credential } from \"./auth.ts\";\nimport * as Identity from \"./identity.ts\";\nimport { isLeadingOnes, type StreamVersion } from \"./stream.ts\";\n\n/**\n * One relay's identity in a broadcast's hop chain: any 64-bit id.\n *\n * Names a *hop*, not an `Origin` routing table: this is the id a relay\n * stamps into a chain as an announcement passes through, so a receiver can spot its own\n * id and reject a loop. The SETUP parameter that carries it session-wide is `Hop` too.\n *\n * {@link toHop} validates any incoming value and brands it so the type system\n * enforces \"only validated ids flow into hop chains.\" Internal code that synthesizes one\n * (e.g. `randomHop`) brands a raw bigint the same way.\n */\nexport type Hop = bigint & { readonly [hopBrand]: true };\n\ndeclare const hopBrand: unique symbol;\n\n/** Brand `value` as a {@link Hop}, refusing anything outside the unsigned 64-bit range. */\nexport function toHop(value: bigint): Hop {\n\tif (value < 0n || value >= 1n << 64n) throw new RangeError(\"Hop must be a non-negative 64-bit integer\");\n\treturn value as Hop;\n}\n\n/**\n * The reserved id 0, meaning \"no identity\".\n *\n * It stands in for an endpoint that never declared one, and any number of endpoints can\n * be 0, so it identifies nothing: it is never a loop, never a publisher two chains have\n * in common, and never excluded from an advertisement. A chain that holds a 0 anywhere\n * is anonymous for route selection.\n */\nexport const UNKNOWN_HOP: Hop = toHop(0n);\n\n/**\n * The id `hop` carries on a wire in `version`'s varint form.\n *\n * A QUIC varint stops at 2^62-1, so a larger id travels as {@link UNKNOWN_HOP}: the route\n * still reaches the peer, losing loop detection through this hop on that link only.\n * Mirrors `Hop::wire_id` in rs/moq-net.\n */\nexport function wireHop(hop: Hop, version: StreamVersion): Hop {\n\treturn hop >= 1n << 62n && !isLeadingOnes(version) ? UNKNOWN_HOP : hop;\n}\n\n/**\n * Maximum length of a hop chain. Must match `MAX_HOPS` in Rust's `model/origin.rs`.\n *\n * Broadcasts with longer chains are rejected, which bounds loop detection and rejects\n * pathological announcements across clusters with unbounded forwarding.\n */\nexport const MAX_HOPS = 32;\n\n/**\n * Generate a fresh hop with a random non-zero id.\n *\n * `crypto.getRandomValues` is overkill for best-effort loop detection, but\n * used for slightly better distribution than `Math.random` at negligible cost.\n *\n * Older `@moq/lite` JS clients decode `AnnounceInterest.exclude_hop` as a u53\n * (number) and throw on anything > 2^53-1, so the random id stays below 2^53 to keep\n * those clients alive against fresh peers. Mirrors `Hop::random` in rs/moq-net.\n */\nexport function randomHop(): Hop {\n\tconst buf = new BigUint64Array(1);\n\tcrypto.getRandomValues(buf);\n\t// Mask to 53 bits.\n\tconst raw = buf[0] & 0x1f_ffff_ffff_ffffn;\n\t// Guard against the (astronomically unlikely) zero draw.\n\treturn toHop(raw === 0n ? 1n : raw);\n}\n\n/** The static cost of pulling content through a route; lower wins. */\nexport type Cost = bigint;\n\n/** Common route prices. */\nexport const Cost = {\n\t/** The price a live publisher seeds. */\n\tzero: 0n,\n\t/** Crossing a link neither end priced, so an unpriced mesh routes by hop count. */\n\tlink: 1n,\n\t/** The most a wire cost carries. */\n\tmax: 2n ** 62n - 1n,\n\t/** A route's cost plus the price of the link it arrived on, saturating at {@link Cost.max}. */\n\tcharged(route: Cost, link: Cost): Cost {\n\t\tconst sum = route + link;\n\t\treturn sum > Cost.max ? Cost.max : sum;\n\t},\n};\n\n/**\n * The stream a received route serves and what using it costs: read-only facts on an\n * announcement. Mirrors `RouteInfo` in rs/moq-net.\n *\n * Carried by an announce event. Applications never build one: an origin `Route` takes\n * `RouteOptions`, and the origin and the relays fill in the rest.\n */\nexport interface RouteInfo {\n\t/**\n\t * The stream the route serves: routes with one identity serve one continuous sequence\n\t * space, so a subscription resumes from one to another. Pass it to an origin `request` to\n\t * pin this stream.\n\t */\n\treadonly identity: Identity.Valid;\n\t/** What pulling content via this route costs; lower wins. */\n\treadonly cost: Cost;\n\t/**\n\t * Whether a usable path reaches the route's origin. An unavailable route is held: the\n\t * network lost every path to it but may recover one, so the announcement stays. It ranks\n\t * below every available claim of its prefix, a draining one included, though a more specific\n\t * claim still shadows a broader one, and requests through it may fail until it recovers:\n\t * request again once it turns available.\n\t */\n\treadonly available: boolean;\n\t/**\n\t * Whether the route ranks below every other available one, whatever its cost, yet above one\n\t * held unavailable, and still serves when nothing else does: the session it arrived on is\n\t * going away (the peer sent a GOAWAY), or a lite-07 path to its origin crosses such a session.\n\t * A ranking state, never a saturated cost.\n\t */\n\treadonly draining: boolean;\n}\n\n/**\n * The read-only facts an announcement shows of `route`, leaving its epoch, hop chain, and\n * credential internal.\n *\n * @internal\n */\nexport function routeInfo(route: WireRoute): RouteInfo {\n\tif (route.identity === undefined) throw new Error(\"a delivered route has an identity\");\n\treturn {\n\t\tidentity: route.identity,\n\t\tcost: route.cost,\n\t\tavailable: route.available ?? true,\n\t\tdraining: route.draining ?? false,\n\t};\n}\n\n/**\n * A route as the origin and sessions carry it: the {@link RouteInfo} facts plus the epoch that\n * orders an identity's incarnations, the hop chain it took, the credential that advertises it,\n * and whether it drains, which applications never see.\n *\n * @internal\n */\nexport interface WireRoute {\n\t/** See {@link RouteInfo.identity}. Always set on a route the origin delivers. */\n\treadonly identity?: Identity.Valid;\n\t/**\n\t * Which incarnation of {@link identity} this is: among its routes at one prefix only the\n\t * highest epoch is eligible, cheaper or not. Never compared across identities.\n\t */\n\treadonly epoch?: bigint;\n\t/**\n\t * The chain of hops the route has traversed, oldest first. A 0 entry is the anonymous mark;\n\t * see {@link isAnonymous}. A route announced on this origin has none.\n\t */\n\treadonly hops: readonly Hop[];\n\t/** What pulling content via this route costs; lower wins. */\n\treadonly cost: Cost;\n\t/**\n\t * The token the request advertising this route carries, from `auth.add()`, or undefined\n\t * for the session's own credential. Only the session that issued it carries it, as the\n\t * token on its moq-transport PUBLISH_NAMESPACE: any other session, the inline NAMESPACE\n\t * answering a solicited SUBSCRIBE_NAMESPACE, and moq-lite advertise the route unnamed.\n\t * Swapping it renews the request with REQUEST_UPDATE. Local: a relay never forwards it.\n\t */\n\treadonly auth?: Credential;\n\t/**\n\t * See {@link RouteInfo.draining}; unset means not draining. Never forwarded at its own cost:\n\t * a relay advertises a draining route at its real cost.\n\t */\n\treadonly draining?: boolean;\n\t/** See {@link RouteInfo.available}; unset means available. */\n\treadonly available?: boolean;\n\t/**\n\t * A claim a lite-07 peer sent, one per identity at a path, which a reader asking for every\n\t * claim reports as a route of its own. Unset on a route announced here and on every other\n\t * version. Local: readers never see it.\n\t */\n\treadonly claimed?: boolean;\n\t/**\n\t * The lowest priority of a link on the way to a lite-07 claim's publisher: higher ranks\n\t * first, after drain and before cost. Unset ranks as 0, the priority of a link no one set.\n\t * Local, as `claimed` is.\n\t */\n\treadonly priority?: number;\n\t/**\n\t * How many segments broader the lite-07 claim is than the path it is presented at: a claim\n\t * exactly at a path outranks every broader one shown there, before anything else. Unset ranks\n\t * as 0. Local, as `claimed` is.\n\t */\n\treadonly above?: bigint;\n}\n\n/** Constructors and helpers for {@link WireRoute}. @internal */\nexport const WireRoute = {\n\t/** An empty hop chain at zero cost: what a publisher seeds for a live broadcast. */\n\tdefault: { hops: [], cost: Cost.zero } as WireRoute,\n\n\t/**\n\t * Fill route defaults and saturate the static price at the wire ceiling. A plain JavaScript\n\t * caller can pass any string as a named identity, so its text is checked as `Identity.parse`\n\t * does, before a peer refuses it.\n\t */\n\tnormalize(route: Partial<WireRoute> = {}): WireRoute {\n\t\tconst cost = route.cost ?? Cost.zero;\n\t\tif (typeof cost !== \"bigint\" || cost < 0n) throw new RangeError(\"route cost must be a non-negative bigint\");\n\t\tconst identity = typeof route.identity === \"string\" ? Identity.parse(route.identity) : route.identity;\n\t\tconst max = 2n ** 62n - 1n;\n\t\treturn {\n\t\t\tidentity,\n\t\t\tepoch: identity === undefined ? undefined : (route.epoch ?? 0n),\n\t\t\thops: route.hops ? [...route.hops] : [],\n\t\t\tcost: cost > max ? max : cost,\n\t\t\tauth: route.auth,\n\t\t\tdraining: route.draining,\n\t\t\tavailable: route.available,\n\t\t\tclaimed: route.claimed,\n\t\t\tpriority: route.priority,\n\t\t\tabove: route.above,\n\t\t};\n\t},\n};\n\n/**\n * Whether this route passed through an anonymous hop (id 0) at any depth.\n *\n * An empty chain is a local announcement, not the anonymous mark. Ingress fills a\n * received empty list with the anonymous hop before yielding it.\n *\n * @internal\n */\nexport function isAnonymous(route: WireRoute): boolean {\n\treturn route.hops.includes(UNKNOWN_HOP);\n}\n\n/**\n * Whether two routes name the same identity, epoch, hop chain, cost, auth, drain state,\n * availability, whether a lite-07 peer claimed it, priority, and how far above its path a claim is.\n *\n * @internal\n */\nexport function routesEqual(a: WireRoute | undefined, b: WireRoute | undefined): boolean {\n\tif (a === b) return true;\n\tif (!a || !b) return false;\n\treturn (\n\t\ta.identity === b.identity &&\n\t\ta.epoch === b.epoch &&\n\t\ta.cost === b.cost &&\n\t\ta.auth === b.auth &&\n\t\t(a.draining ?? false) === (b.draining ?? false) &&\n\t\t(a.available ?? true) === (b.available ?? true) &&\n\t\t(a.claimed ?? false) === (b.claimed ?? false) &&\n\t\t(a.priority ?? 0) === (b.priority ?? 0) &&\n\t\t(a.above ?? 0n) === (b.above ?? 0n) &&\n\t\ta.hops.length === b.hops.length &&\n\t\ta.hops.every((hop, i) => hop === b.hops[i])\n\t);\n}\n"]}
package/identity.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Stream identities: one continuous stream at a path. Within one, group keys never
3
+ * restart and never name two different groups, so a reader continues across every route that
4
+ * shares it; different identities are never stitched together.
5
+ * Mirrors `Identity` in rs/moq-net.
6
+ *
7
+ * @module
8
+ */
9
+ import { Minted } from "./mint.ts";
10
+ /** A named identity: its text, as a publisher or catalog names it. */
11
+ export type Named = string & {
12
+ readonly _brand: "identity";
13
+ };
14
+ /** An identity a session {@link isMinted minted}; see {@link Valid}. */
15
+ export type { Minted };
16
+ /**
17
+ * A validated identity, compared with `===` and used as a map key. A named identity is its
18
+ * text; one a session minted is an object no caller can build, interned so equal ones are the
19
+ * same object, so the two kinds never match even with the same text. Read the text with
20
+ * {@link text}.
21
+ */
22
+ export type Valid = Named | Minted;
23
+ /**
24
+ * Parse a named identity's text, refusing an empty one, one longer than 256 UTF-8 bytes, or an
25
+ * ill-formed one (a lone surrogate, which UTF-8 cannot carry).
26
+ */
27
+ export declare function parse(text: string): Named;
28
+ /** A fresh random identity, for a new stream: 128 random bits as hex. */
29
+ export declare function random(): Named;
30
+ /** The identity's text, which alone does not tell a minted identity from a named one. */
31
+ export declare function text(identity: Valid): string;
32
+ /**
33
+ * Whether a session minted this identity, for a route whose wire (an older moq-lite, or
34
+ * moq-transport) carries none. It names the announcement rather than the publisher's stream,
35
+ * so it can neither match nor contradict an identity the publisher named. Hops that forward it
36
+ * keep the flag, and only a session sets it: {@link parse} never builds a minted identity.
37
+ */
38
+ export declare function isMinted(identity: Valid): identity is Minted;
39
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAO,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,sEAAsE;AACtE,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAE7D,wEAAwE;AACxE,YAAY,EAAE,MAAM,EAAE,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAOnC;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CASzC;AAED,yEAAyE;AACzE,wBAAgB,MAAM,IAAI,KAAK,CAE9B;AAED,yFAAyF;AACzF,wBAAgB,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,KAAK,GAAG,QAAQ,IAAI,MAAM,CAE5D"}
package/identity.js ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Stream identities: one continuous stream at a path. Within one, group keys never
3
+ * restart and never name two different groups, so a reader continues across every route that
4
+ * shares it; different identities are never stitched together.
5
+ * Mirrors `Identity` in rs/moq-net.
6
+ *
7
+ * @module
8
+ */
9
+ import { hex, Minted } from "./mint.js";
10
+ // The most UTF-8 bytes an identity holds: room for a public key in any common text encoding
11
+ // while bounding what a claim makes a relay hold. Mirrors `MAX_LEN` in rs/moq-net.
12
+ const MAX_BYTES = 256;
13
+ const encoder = new TextEncoder();
14
+ /**
15
+ * Parse a named identity's text, refusing an empty one, one longer than 256 UTF-8 bytes, or an
16
+ * ill-formed one (a lone surrogate, which UTF-8 cannot carry).
17
+ */
18
+ export function parse(text) {
19
+ if (text.length === 0)
20
+ throw new RangeError("invalid identity: empty");
21
+ if (!text.isWellFormed())
22
+ throw new RangeError("invalid identity: ill-formed text");
23
+ // Every UTF-16 code unit is at least one UTF-8 byte and at most three, so only a length in
24
+ // between needs encoding to tell.
25
+ if (text.length > MAX_BYTES || (text.length * 3 > MAX_BYTES && encoder.encode(text).byteLength > MAX_BYTES)) {
26
+ throw new RangeError("invalid identity: longer than 256 bytes");
27
+ }
28
+ return text;
29
+ }
30
+ /** A fresh random identity, for a new stream: 128 random bits as hex. */
31
+ export function random() {
32
+ return hex();
33
+ }
34
+ /** The identity's text, which alone does not tell a minted identity from a named one. */
35
+ export function text(identity) {
36
+ return typeof identity === "string" ? identity : identity.text;
37
+ }
38
+ /**
39
+ * Whether a session minted this identity, for a route whose wire (an older moq-lite, or
40
+ * moq-transport) carries none. It names the announcement rather than the publisher's stream,
41
+ * so it can neither match nor contradict an identity the publisher named. Hops that forward it
42
+ * keep the flag, and only a session sets it: {@link parse} never builds a minted identity.
43
+ */
44
+ export function isMinted(identity) {
45
+ return Minted.is(identity);
46
+ }
47
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAgBxC,4FAA4F;AAC5F,mFAAmF;AACnF,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,IAAY;IACjC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,CAAC;IACvE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;QAAE,MAAM,IAAI,UAAU,CAAC,mCAAmC,CAAC,CAAC;IACpF,2FAA2F;IAC3F,kCAAkC;IAClC,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC;QAC7G,MAAM,IAAI,UAAU,CAAC,yCAAyC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,IAAa,CAAC;AACtB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,MAAM;IACrB,OAAO,GAAG,EAAW,CAAC;AACvB,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,IAAI,CAAC,QAAe;IACnC,OAAO,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAe;IACvC,OAAO,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["/**\n * Stream identities: one continuous stream at a path. Within one, group keys never\n * restart and never name two different groups, so a reader continues across every route that\n * shares it; different identities are never stitched together.\n * Mirrors `Identity` in rs/moq-net.\n *\n * @module\n */\n\nimport { hex, Minted } from \"./mint.ts\";\n\n/** A named identity: its text, as a publisher or catalog names it. */\nexport type Named = string & { readonly _brand: \"identity\" };\n\n/** An identity a session {@link isMinted minted}; see {@link Valid}. */\nexport type { Minted };\n\n/**\n * A validated identity, compared with `===` and used as a map key. A named identity is its\n * text; one a session minted is an object no caller can build, interned so equal ones are the\n * same object, so the two kinds never match even with the same text. Read the text with\n * {@link text}.\n */\nexport type Valid = Named | Minted;\n\n// The most UTF-8 bytes an identity holds: room for a public key in any common text encoding\n// while bounding what a claim makes a relay hold. Mirrors `MAX_LEN` in rs/moq-net.\nconst MAX_BYTES = 256;\nconst encoder = new TextEncoder();\n\n/**\n * Parse a named identity's text, refusing an empty one, one longer than 256 UTF-8 bytes, or an\n * ill-formed one (a lone surrogate, which UTF-8 cannot carry).\n */\nexport function parse(text: string): Named {\n\tif (text.length === 0) throw new RangeError(\"invalid identity: empty\");\n\tif (!text.isWellFormed()) throw new RangeError(\"invalid identity: ill-formed text\");\n\t// Every UTF-16 code unit is at least one UTF-8 byte and at most three, so only a length in\n\t// between needs encoding to tell.\n\tif (text.length > MAX_BYTES || (text.length * 3 > MAX_BYTES && encoder.encode(text).byteLength > MAX_BYTES)) {\n\t\tthrow new RangeError(\"invalid identity: longer than 256 bytes\");\n\t}\n\treturn text as Named;\n}\n\n/** A fresh random identity, for a new stream: 128 random bits as hex. */\nexport function random(): Named {\n\treturn hex() as Named;\n}\n\n/** The identity's text, which alone does not tell a minted identity from a named one. */\nexport function text(identity: Valid): string {\n\treturn typeof identity === \"string\" ? identity : identity.text;\n}\n\n/**\n * Whether a session minted this identity, for a route whose wire (an older moq-lite, or\n * moq-transport) carries none. It names the announcement rather than the publisher's stream,\n * so it can neither match nor contradict an identity the publisher named. Hops that forward it\n * keep the flag, and only a session sets it: {@link parse} never builds a minted identity.\n */\nexport function isMinted(identity: Valid): identity is Minted {\n\treturn Minted.is(identity);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=active_count.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active_count.d.ts","sourceRoot":"","sources":["../../src/ietf/active_count.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import { SetupOption } from "./setup_options.js";
2
+ /**
3
+ * The MoQ Active Count extension (draft-lcurley-moq-active-count-00).
4
+ *
5
+ * A publisher answers SUBSCRIBE_NAMESPACE with a NAMESPACE for every suffix it already
6
+ * advertises, then reports changes on the same stream. Nothing in moq-transport says where
7
+ * the first part ends, so when both endpoints declare the ACTIVE_COUNT option, the
8
+ * publisher puts on its REQUEST_OK how many NAMESPACE messages come before the
9
+ * subscription is synced.
10
+ *
11
+ * @module
12
+ * @internal
13
+ */
14
+ /**
15
+ * Whether the extension is negotiated. We always declare it, so the peer's SETUP decides.
16
+ *
17
+ * @internal
18
+ */
19
+ export function activeCountFromSetup(params) {
20
+ return params.getVarint(SetupOption.ActiveCount) !== undefined;
21
+ }
22
+ /**
23
+ * Declare that we count and read the peer's count.
24
+ *
25
+ * @internal
26
+ */
27
+ export function activeCountIntoSetup(params) {
28
+ params.setVarint(SetupOption.ActiveCount, 1n);
29
+ }
30
+ //# sourceMappingURL=active_count.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active_count.js","sourceRoot":"","sources":["../../src/ietf/active_count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAEpE;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACxD,OAAO,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,SAAS,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACxD,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { SetupOption, type SetupOptions } from \"./setup_options.ts\";\n\n/**\n * The MoQ Active Count extension (draft-lcurley-moq-active-count-00).\n *\n * A publisher answers SUBSCRIBE_NAMESPACE with a NAMESPACE for every suffix it already\n * advertises, then reports changes on the same stream. Nothing in moq-transport says where\n * the first part ends, so when both endpoints declare the ACTIVE_COUNT option, the\n * publisher puts on its REQUEST_OK how many NAMESPACE messages come before the\n * subscription is synced.\n *\n * @module\n * @internal\n */\n\n/**\n * Whether the extension is negotiated. We always declare it, so the peer's SETUP decides.\n *\n * @internal\n */\nexport function activeCountFromSetup(params: SetupOptions): boolean {\n\treturn params.getVarint(SetupOption.ActiveCount) !== undefined;\n}\n\n/**\n * Declare that we count and read the peer's count.\n *\n * @internal\n */\nexport function activeCountIntoSetup(params: SetupOptions) {\n\tparams.setVarint(SetupOption.ActiveCount, 1n);\n}\n"]}