@moqtap/codec 0.10.0 → 0.12.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 (262) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/README.md +3 -2
  3. package/dist/auth-redaction-B9JJOlIY.d.cts +100 -0
  4. package/dist/auth-redaction-B9JJOlIY.d.ts +100 -0
  5. package/dist/{chunk-RYKQXBG6.cjs → chunk-27K5BUAG.cjs} +481 -517
  6. package/dist/{chunk-WCPENYNE.js → chunk-3RNQMGKA.js} +359 -390
  7. package/dist/{chunk-TSUZ6GJV.js → chunk-5AWIXOLB.js} +438 -469
  8. package/dist/{chunk-4XLYCT5Q.cjs → chunk-5IMHJIAZ.cjs} +52 -2
  9. package/dist/{chunk-KTNERCTZ.cjs → chunk-5JGZCKJO.cjs} +488 -518
  10. package/dist/{chunk-WCTMPDUX.cjs → chunk-73K4OSAN.cjs} +401 -432
  11. package/dist/{chunk-N2V7Z37J.js → chunk-7VQKRGRD.js} +19 -3
  12. package/dist/{chunk-BIBMDTU5.cjs → chunk-A3UCQOIB.cjs} +486 -517
  13. package/dist/{chunk-K2B3OVFK.js → chunk-A7PDMVXM.js} +24 -3
  14. package/dist/{chunk-VZHL2U2N.cjs → chunk-A7VQO6YC.cjs} +54 -38
  15. package/dist/{chunk-AQ445VV7.cjs → chunk-ACQHZLRZ.cjs} +66 -46
  16. package/dist/{chunk-L5DRACXS.js → chunk-BBICOMW6.js} +25 -3
  17. package/dist/{chunk-T4VWPKDG.cjs → chunk-BNIUVOCJ.cjs} +529 -599
  18. package/dist/{chunk-UKKDOOUO.cjs → chunk-CNC6ANS4.cjs} +58 -37
  19. package/dist/{chunk-OZRK73NQ.js → chunk-FDLQSWHK.js} +433 -469
  20. package/dist/{chunk-IJAF6PAY.js → chunk-FFNOE4UR.js} +19 -3
  21. package/dist/{chunk-CZNW3R5E.cjs → chunk-GMENT63T.cjs} +54 -38
  22. package/dist/{chunk-XCRCAUGI.cjs → chunk-HM7BLRVP.cjs} +291 -297
  23. package/dist/{chunk-XHAP2YST.js → chunk-HZONHFNO.js} +19 -3
  24. package/dist/{chunk-SDJTSMOW.cjs → chunk-ILYABWDK.cjs} +60 -38
  25. package/dist/{chunk-IDV2JYJ6.cjs → chunk-KRSFTZVO.cjs} +56 -40
  26. package/dist/{chunk-RIIA4ALQ.cjs → chunk-KSPH6KMH.cjs} +54 -38
  27. package/dist/{chunk-OUNN4IQB.cjs → chunk-KTY4LAUV.cjs} +482 -497
  28. package/dist/chunk-OBATJBNL.cjs +868 -0
  29. package/dist/{chunk-RZTLQAKF.js → chunk-OJNLJT5D.js} +0 -1
  30. package/dist/{chunk-FT3HDNIB.js → chunk-PJK2ZS3I.js} +467 -537
  31. package/dist/{chunk-G53WYUXL.js → chunk-PSMZKHOC.js} +441 -456
  32. package/dist/{chunk-7RE6KSIY.cjs → chunk-Q5JQGHWY.cjs} +0 -1
  33. package/dist/{chunk-BX2N7TZM.js → chunk-SQTUQY5E.js} +31 -11
  34. package/dist/chunk-T2TCLZZV.js +2304 -0
  35. package/dist/chunk-WB65UG7G.cjs +2304 -0
  36. package/dist/{chunk-CF5DDD3Q.js → chunk-WCRLAKDW.js} +239 -245
  37. package/dist/{chunk-KYVTM5VI.js → chunk-WL2YUEXH.js} +19 -3
  38. package/dist/chunk-XPCBPACE.js +868 -0
  39. package/dist/{chunk-KGDVC4O6.js → chunk-YCNIVZS7.js} +439 -469
  40. package/dist/{chunk-KLPWJU6W.js → chunk-YRZQVNZO.js} +50 -0
  41. package/dist/{codec-DOmAmFkI.d.ts → codec-B-oUU-cp.d.ts} +21 -2
  42. package/dist/{codec-DNmiG2e0.d.cts → codec-B3RpCI9k.d.cts} +21 -2
  43. package/dist/codec-B5pcOS3m.d.cts +38 -0
  44. package/dist/{codec-BNy5syCU.d.ts → codec-BLjxwK2f.d.ts} +21 -2
  45. package/dist/{codec-alVA27Uc.d.ts → codec-BV3CL_3m.d.ts} +21 -2
  46. package/dist/{codec-Czejcmxr.d.cts → codec-BYCDWgED.d.ts} +22 -3
  47. package/dist/{codec-DaXjRrOV.d.ts → codec-Bwqq7ZQT.d.ts} +22 -3
  48. package/dist/{codec-CFWu5KVT.d.cts → codec-BzWxOFby.d.cts} +22 -3
  49. package/dist/codec-C-nJhNNl.d.ts +38 -0
  50. package/dist/{codec-EvybrBuY.d.cts → codec-C11VEPbQ.d.cts} +21 -2
  51. package/dist/codec-C9U0Vzy9.d.cts +68 -0
  52. package/dist/{codec-Cm3D261p.d.ts → codec-CCx22jnd.d.ts} +21 -2
  53. package/dist/{codec-CwZ6OCPP.d.ts → codec-CP3zkfTv.d.ts} +22 -3
  54. package/dist/{codec-BxQTybUX.d.cts → codec-CRmOLDpt.d.ts} +22 -3
  55. package/dist/{codec-DzkdW4kO.d.cts → codec-CUu56DDU.d.cts} +21 -2
  56. package/dist/codec-Cb8mUre3.d.ts +68 -0
  57. package/dist/{codec-f7vxeVIS.d.cts → codec-CemqAQdR.d.cts} +22 -3
  58. package/dist/{codec-gl4_QEva.d.ts → codec-CxMvsVMS.d.ts} +21 -2
  59. package/dist/{codec-Bd60SGKH.d.cts → codec-DIgMVTi4.d.cts} +21 -2
  60. package/dist/{codec--CVeqGQv.d.ts → codec-DYzozF68.d.ts} +21 -2
  61. package/dist/{codec-CWnf8mn_.d.cts → codec-D_O9zxax.d.ts} +22 -3
  62. package/dist/{codec-08ZOr5wI.d.ts → codec-Ddc-QxV6.d.cts} +22 -3
  63. package/dist/{codec-CBdOIfMY.d.ts → codec-DoojMl2z.d.cts} +22 -3
  64. package/dist/{codec-BrTi4K7r.d.cts → codec-DqdjiOQF.d.ts} +22 -3
  65. package/dist/{codec-CXCjya_G.d.cts → codec-Dstemwrq.d.cts} +21 -2
  66. package/dist/{codec-Dl_QIXMz.d.ts → codec-Dt6nuejp.d.ts} +21 -2
  67. package/dist/{codec-Bux_Q40X.d.ts → codec-DuYhd8fP.d.cts} +22 -3
  68. package/dist/{codec-Cfo_z5ET.d.cts → codec-DwNOFgPU.d.cts} +21 -2
  69. package/dist/{codec-guzqtfMk.d.cts → codec-l01BpNhF.d.cts} +21 -2
  70. package/dist/{codec-C3mdsGx3.d.ts → codec-psN2vB6I.d.cts} +22 -3
  71. package/dist/draft07-session.d.cts +3 -3
  72. package/dist/draft07-session.d.ts +3 -3
  73. package/dist/draft07.cjs +48 -4
  74. package/dist/draft07.d.cts +44 -4
  75. package/dist/draft07.d.ts +44 -4
  76. package/dist/draft07.js +49 -5
  77. package/dist/draft08-session.d.cts +3 -3
  78. package/dist/draft08-session.d.ts +3 -3
  79. package/dist/draft08.cjs +76 -3
  80. package/dist/draft08.d.cts +73 -5
  81. package/dist/draft08.d.ts +73 -5
  82. package/dist/draft08.js +77 -4
  83. package/dist/draft09-session.d.cts +3 -3
  84. package/dist/draft09-session.d.ts +3 -3
  85. package/dist/draft09.cjs +76 -3
  86. package/dist/draft09.d.cts +73 -5
  87. package/dist/draft09.d.ts +73 -5
  88. package/dist/draft09.js +77 -4
  89. package/dist/draft10-session.d.cts +3 -3
  90. package/dist/draft10-session.d.ts +3 -3
  91. package/dist/draft10.cjs +76 -3
  92. package/dist/draft10.d.cts +73 -5
  93. package/dist/draft10.d.ts +73 -5
  94. package/dist/draft10.js +77 -4
  95. package/dist/draft11-session.d.cts +3 -3
  96. package/dist/draft11-session.d.ts +3 -3
  97. package/dist/draft11.cjs +104 -3
  98. package/dist/draft11.d.cts +101 -5
  99. package/dist/draft11.d.ts +101 -5
  100. package/dist/draft11.js +105 -4
  101. package/dist/draft12-session.d.cts +3 -3
  102. package/dist/draft12-session.d.ts +3 -3
  103. package/dist/draft12.cjs +113 -3
  104. package/dist/draft12.d.cts +110 -5
  105. package/dist/draft12.d.ts +110 -5
  106. package/dist/draft12.js +114 -4
  107. package/dist/draft13-session.d.cts +3 -3
  108. package/dist/draft13-session.d.ts +3 -3
  109. package/dist/draft13.cjs +105 -3
  110. package/dist/draft13.d.cts +102 -5
  111. package/dist/draft13.d.ts +102 -5
  112. package/dist/draft13.js +106 -4
  113. package/dist/draft14-session.d.cts +3 -3
  114. package/dist/draft14-session.d.ts +3 -3
  115. package/dist/draft14.cjs +107 -3
  116. package/dist/draft14.d.cts +104 -31
  117. package/dist/draft14.d.ts +104 -31
  118. package/dist/draft14.js +108 -4
  119. package/dist/draft15-session.d.cts +4 -4
  120. package/dist/draft15-session.d.ts +4 -4
  121. package/dist/draft15.cjs +69 -3
  122. package/dist/draft15.d.cts +68 -25
  123. package/dist/draft15.d.ts +68 -25
  124. package/dist/draft15.js +70 -4
  125. package/dist/draft16-session.cjs +2 -2
  126. package/dist/draft16-session.d.cts +4 -4
  127. package/dist/draft16-session.d.ts +4 -4
  128. package/dist/draft16-session.js +1 -1
  129. package/dist/draft16.cjs +76 -8
  130. package/dist/draft16.d.cts +70 -16
  131. package/dist/draft16.d.ts +70 -16
  132. package/dist/draft16.js +73 -5
  133. package/dist/draft17-session.d.cts +4 -4
  134. package/dist/draft17-session.d.ts +4 -4
  135. package/dist/draft17.cjs +77 -3
  136. package/dist/draft17.d.cts +75 -6
  137. package/dist/draft17.d.ts +75 -6
  138. package/dist/draft17.js +78 -4
  139. package/dist/draft18-session.d.cts +4 -4
  140. package/dist/draft18-session.d.ts +4 -4
  141. package/dist/draft18.cjs +8 -3
  142. package/dist/draft18.d.cts +6 -5
  143. package/dist/draft18.d.ts +6 -5
  144. package/dist/draft18.js +9 -4
  145. package/dist/draft19-session.d.cts +4 -4
  146. package/dist/draft19-session.d.ts +4 -4
  147. package/dist/draft19.cjs +11 -4
  148. package/dist/draft19.d.cts +6 -5
  149. package/dist/draft19.d.ts +6 -5
  150. package/dist/draft19.js +12 -5
  151. package/dist/draft20-session.d.cts +4 -4
  152. package/dist/draft20-session.d.ts +4 -4
  153. package/dist/draft20.cjs +8 -3
  154. package/dist/draft20.d.cts +6 -5
  155. package/dist/draft20.d.ts +6 -5
  156. package/dist/draft20.js +9 -4
  157. package/dist/draft21-session.cjs +8 -0
  158. package/dist/draft21-session.d.cts +195 -0
  159. package/dist/draft21-session.d.ts +195 -0
  160. package/dist/draft21-session.js +8 -0
  161. package/dist/draft21.cjs +222 -0
  162. package/dist/draft21.d.cts +176 -0
  163. package/dist/draft21.d.ts +176 -0
  164. package/dist/draft21.js +222 -0
  165. package/dist/index.cjs +37 -31
  166. package/dist/index.d.cts +29 -23
  167. package/dist/index.d.ts +29 -23
  168. package/dist/index.js +22 -16
  169. package/dist/{session-types-Dn7b3RZM.d.ts → session-types-Cxx7W8zZ.d.ts} +1 -1
  170. package/dist/{session-types-B9idsih-.d.cts → session-types-DZkI_qFG.d.cts} +1 -1
  171. package/dist/session.cjs +7 -3
  172. package/dist/session.d.cts +11 -9
  173. package/dist/session.d.ts +11 -9
  174. package/dist/session.js +6 -2
  175. package/dist/{types-DG5_iKuv.d.cts → types-2NisMA8_.d.cts} +1 -1
  176. package/dist/{types-DG5_iKuv.d.ts → types-2NisMA8_.d.ts} +1 -1
  177. package/dist/{types-C1rxh-id.d.cts → types-Btp416jt.d.cts} +8 -0
  178. package/dist/{types-C1rxh-id.d.ts → types-Btp416jt.d.ts} +8 -0
  179. package/dist/{types-CZTzbIzQ.d.cts → types-BxTL1NXw.d.cts} +7 -0
  180. package/dist/{types-CZTzbIzQ.d.ts → types-BxTL1NXw.d.ts} +7 -0
  181. package/dist/{types-pShrs3fN.d.cts → types-CuibHYcf.d.cts} +7 -0
  182. package/dist/{types-pShrs3fN.d.ts → types-CuibHYcf.d.ts} +7 -0
  183. package/dist/{types-CY-QWxd-.d.cts → types-CwN7AEoL.d.cts} +13 -1
  184. package/dist/{types-CY-QWxd-.d.ts → types-CwN7AEoL.d.ts} +13 -1
  185. package/dist/{types-D4bmW8rY.d.cts → types-DAnalt5K.d.cts} +7 -0
  186. package/dist/{types-D4bmW8rY.d.ts → types-DAnalt5K.d.ts} +7 -0
  187. package/dist/types-DDwidj2d.d.cts +371 -0
  188. package/dist/types-DDwidj2d.d.ts +371 -0
  189. package/dist/{types-Bg86GGVZ.d.cts → types-DxXNP32l.d.cts} +8 -0
  190. package/dist/{types-Bg86GGVZ.d.ts → types-DxXNP32l.d.ts} +8 -0
  191. package/package.json +15 -3
  192. package/src/core/auth-redaction.ts +190 -0
  193. package/src/core/types.ts +1 -0
  194. package/src/drafts/draft07/codec.ts +40 -0
  195. package/src/drafts/draft07/error-codes.ts +44 -0
  196. package/src/drafts/draft07/index.ts +15 -0
  197. package/src/drafts/draft08/codec.ts +40 -0
  198. package/src/drafts/draft08/error-codes.ts +76 -0
  199. package/src/drafts/draft08/index.ts +21 -0
  200. package/src/drafts/draft09/codec.ts +40 -0
  201. package/src/drafts/draft09/error-codes.ts +76 -0
  202. package/src/drafts/draft09/index.ts +21 -0
  203. package/src/drafts/draft10/codec.ts +40 -0
  204. package/src/drafts/draft10/error-codes.ts +76 -0
  205. package/src/drafts/draft10/index.ts +21 -0
  206. package/src/drafts/draft11/codec.ts +60 -0
  207. package/src/drafts/draft11/error-codes.ts +106 -0
  208. package/src/drafts/draft11/index.ts +23 -0
  209. package/src/drafts/draft12/codec.ts +61 -0
  210. package/src/drafts/draft12/error-codes.ts +116 -0
  211. package/src/drafts/draft12/index.ts +25 -0
  212. package/src/drafts/draft13/codec.ts +69 -11
  213. package/src/drafts/draft13/error-codes.ts +107 -0
  214. package/src/drafts/draft13/index.ts +23 -0
  215. package/src/drafts/draft13/types.ts +1 -1
  216. package/src/drafts/draft14/codec.ts +65 -4
  217. package/src/drafts/draft14/data-streams.ts +331 -259
  218. package/src/drafts/draft14/error-codes.ts +109 -0
  219. package/src/drafts/draft14/index.ts +23 -0
  220. package/src/drafts/draft15/codec.ts +65 -8
  221. package/src/drafts/draft15/data-streams.ts +489 -444
  222. package/src/drafts/draft15/error-codes.ts +66 -0
  223. package/src/drafts/draft15/index.ts +15 -0
  224. package/src/drafts/draft15/types.ts +7 -0
  225. package/src/drafts/draft16/codec.ts +146 -52
  226. package/src/drafts/draft16/data-streams.ts +513 -442
  227. package/src/drafts/draft16/error-codes.ts +68 -0
  228. package/src/drafts/draft16/index.ts +15 -0
  229. package/src/drafts/draft16/messages.ts +4 -4
  230. package/src/drafts/draft16/session-fsm.ts +0 -1
  231. package/src/drafts/draft16/types.ts +22 -8
  232. package/src/drafts/draft17/codec.ts +73 -12
  233. package/src/drafts/draft17/data-streams.ts +567 -488
  234. package/src/drafts/draft17/index.ts +15 -0
  235. package/src/drafts/draft17/types.ts +7 -0
  236. package/src/drafts/draft18/codec.ts +66 -9
  237. package/src/drafts/draft18/data-streams.ts +570 -482
  238. package/src/drafts/draft18/index.ts +3 -0
  239. package/src/drafts/draft18/types.ts +16 -8
  240. package/src/drafts/draft19/codec.ts +70 -10
  241. package/src/drafts/draft19/data-streams.ts +570 -482
  242. package/src/drafts/draft19/error-codes.ts +3 -1
  243. package/src/drafts/draft19/index.ts +3 -0
  244. package/src/drafts/draft19/messages.ts +3 -1
  245. package/src/drafts/draft19/types.ts +22 -11
  246. package/src/drafts/draft20/codec.ts +90 -23
  247. package/src/drafts/draft20/data-streams.ts +610 -563
  248. package/src/drafts/draft20/index.ts +3 -0
  249. package/src/drafts/draft20/types.ts +14 -2
  250. package/src/drafts/draft21/codec.ts +1816 -0
  251. package/src/drafts/draft21/data-streams.ts +1338 -0
  252. package/src/drafts/draft21/error-codes.ts +135 -0
  253. package/src/drafts/draft21/index.ts +168 -0
  254. package/src/drafts/draft21/messages.ts +68 -0
  255. package/src/drafts/draft21/rules.ts +107 -0
  256. package/src/drafts/draft21/session-fsm.ts +1063 -0
  257. package/src/drafts/draft21/session.ts +21 -0
  258. package/src/drafts/draft21/types.ts +473 -0
  259. package/src/index.ts +9 -1
  260. package/src/session.ts +4 -0
  261. package/dist/codec-BJ7BHuiZ.d.ts +0 -18
  262. package/dist/codec-C6Mx4bwz.d.cts +0 -18
@@ -2,6 +2,8 @@
2
2
 
3
3
  export const DRAFT_VERSION = 0xff000012n
4
4
 
5
+ export type { AuthRedaction } from '../../core/auth-redaction.js'
6
+ export { REDACTION_FILL } from '../../core/auth-redaction.js'
5
7
  export type { Draft18Codec } from './codec.js'
6
8
  export {
7
9
  createDataStreamDecoder,
@@ -18,6 +20,7 @@ export {
18
20
  encodeFetchStream,
19
21
  encodeMessage,
20
22
  encodeSubgroupStream,
23
+ redactAuthTokens,
21
24
  } from './codec.js'
22
25
  export type {
23
26
  DataStreamResetCodeValue,
@@ -41,14 +41,14 @@ export interface LargestObject {
41
41
 
42
42
  // Version-specific parameters (delta-encoded types, count-prefixed)
43
43
  export interface Draft18Params {
44
- object_delivery_timeout?: bigint // 0x02 varint (renamed from delivery_timeout in draft-17)
44
+ object_delivery_timeout?: bigint // 0x02 varint; drafts 11-17 name the same codepoint DELIVERY_TIMEOUT
45
45
  authorization_token?: readonly AuthorizationToken[] // 0x03 length-prefixed nested
46
46
  rendezvous_timeout?: bigint // 0x04 varint
47
47
  subgroup_delivery_timeout?: bigint // 0x06 varint (NEW in draft-18)
48
48
  expires?: bigint // 0x08 varint
49
49
  largest_object?: LargestObject // 0x09 Location (2 bare varints)
50
50
  fill_timeout?: bigint // 0x0a varint (NEW in draft-18)
51
- forward?: bigint // 0x10 uint8 (was varint in draft-17)
51
+ forward?: bigint // 0x10 uint8; drafts 15 and 16 encode this parameter as a varint
52
52
  subscriber_priority?: bigint // 0x20 uint8
53
53
  subscription_filter?: SubscriptionFilter // 0x21 length-prefixed
54
54
  group_order?: bigint // 0x22 uint8
@@ -59,7 +59,7 @@ export interface Draft18Params {
59
59
 
60
60
  // Track properties (KVP encoding, no count prefix, read until end of payload)
61
61
  export interface Draft18TrackProperties {
62
- object_delivery_timeout?: bigint // 0x02 even varint (renamed from delivery_timeout)
62
+ object_delivery_timeout?: bigint // 0x02 even varint; drafts 11-17 name the same codepoint DELIVERY_TIMEOUT
63
63
  max_cache_duration?: bigint // 0x04 even varint
64
64
  subgroup_delivery_timeout?: bigint // 0x06 even varint (NEW in draft-18)
65
65
  immutable_properties?: Uint8Array // 0x0b odd length-prefixed
@@ -101,7 +101,7 @@ export interface Draft18Setup extends Draft18BaseMessage {
101
101
  readonly options: Draft18SetupOptions
102
102
  }
103
103
 
104
- // Subscribe — Required Request ID Delta REMOVED in draft-18
104
+ // Subscribe — draft-18 Section 10.7. No Required Request ID Delta; draft-17 alone carries that field.
105
105
  export interface Draft18Subscribe extends Draft18BaseMessage {
106
106
  readonly type: 'subscribe'
107
107
  readonly request_id: bigint
@@ -159,7 +159,7 @@ export interface Draft18NamespaceDone extends Draft18BaseMessage {
159
159
  readonly namespace_suffix: string[]
160
160
  }
161
161
 
162
- // SUBSCRIBE_NAMESPACE — type 0x50, subscribe_options field removed in draft-18
162
+ // SUBSCRIBE_NAMESPACE — type 0x50; no Subscribe Options field in draft-18.
163
163
  export interface Draft18SubscribeNamespace extends Draft18BaseMessage {
164
164
  readonly type: 'subscribe_namespace'
165
165
  readonly request_id: bigint
@@ -167,7 +167,7 @@ export interface Draft18SubscribeNamespace extends Draft18BaseMessage {
167
167
  readonly parameters: Draft18Params
168
168
  }
169
169
 
170
- // SUBSCRIBE_TRACKS — NEW in draft-18, type 0x51
170
+ // SUBSCRIBE_TRACKS — type 0x51.
171
171
  export interface Draft18SubscribeTracks extends Draft18BaseMessage {
172
172
  readonly type: 'subscribe_tracks'
173
173
  readonly request_id: bigint
@@ -214,7 +214,7 @@ export interface Draft18FetchOk extends Draft18BaseMessage {
214
214
  readonly track_properties: Draft18TrackProperties
215
215
  }
216
216
 
217
- // Track Status — same format as subscribe in draft-18 (without required_request_id_delta)
217
+ // Track Status — format identical to SUBSCRIBE (Section 10.7), minus the subscriber parameters related to Track delivery (Section 10.14).
218
218
  export interface Draft18TrackStatus extends Draft18BaseMessage {
219
219
  readonly type: 'track_status'
220
220
  readonly request_id: bigint
@@ -223,7 +223,7 @@ export interface Draft18TrackStatus extends Draft18BaseMessage {
223
223
  readonly parameters: Draft18Params
224
224
  }
225
225
 
226
- // REQUEST_OK — gained trailing Track Properties in draft-18
226
+ // REQUEST_OK — carries trailing Track Properties after the parameters.
227
227
  export interface Draft18RequestOk extends Draft18BaseMessage {
228
228
  readonly type: 'request_ok'
229
229
  readonly parameters: Draft18Params
@@ -332,10 +332,18 @@ export type Draft18DataStream = SubgroupStream | DatagramObject | FetchStream
332
332
  // Streaming data stream decoder types
333
333
  export interface SubgroupStreamHeader {
334
334
  readonly type: 'subgroup_header'
335
+ /**
336
+ * The stream Type Flags, the same value `SubgroupStream.headerType` carries.
337
+ * It is reported so the incremental decoder does not drop the flags the
338
+ * header encodes, which is what lets a consumer tell the modes apart.
339
+ */
340
+ readonly headerType: number
335
341
  readonly trackAlias: bigint
336
342
  readonly groupId: bigint
337
343
  readonly subgroupId: bigint
338
344
  readonly publisherPriority: number
345
+ readonly endOfGroup?: boolean
346
+ readonly firstObject?: boolean
339
347
  }
340
348
 
341
349
  export interface FetchStreamHeader {
@@ -1,3 +1,4 @@
1
+ import { type AuthRedaction, recordAuthValueSpan, redactWith } from '../../core/auth-redaction.js'
1
2
  import { MoqtBufferReader as BufferReader } from '../../core/buffer-reader.js'
2
3
  import { MoqtBufferWriter as BufferWriter } from '../../core/buffer-writer.js'
3
4
  import { bytesToHex, hexToBytes } from '../../core/hex.js'
@@ -191,10 +192,9 @@ function decodeSetupOptions(reader: BufferReader, payloadEnd: number): Draft19Se
191
192
  if (optType === SETUP_OPT_PATH) {
192
193
  result.path = textDecoder.decode(bytes)
193
194
  } else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
194
- result.authorization_token = [
195
- ...(result.authorization_token ?? []),
196
- decodeAuthorizationToken(new BufferReader(bytes)),
197
- ]
195
+ const token = decodeAuthorizationToken(new BufferReader(bytes))
196
+ noteAuthTokenValue(reader.offset - length, length, token)
197
+ result.authorization_token = [...(result.authorization_token ?? []), token]
198
198
  } else if (optType === SETUP_OPT_AUTHORITY) {
199
199
  result.authority = textDecoder.decode(bytes)
200
200
  } else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
@@ -232,6 +232,32 @@ function encodeAuthorizationToken(token: AuthorizationToken, w: BufferWriter): v
232
232
  }
233
233
  }
234
234
 
235
+ /**
236
+ * Record where a Token Value sits, so it can be overwritten before the frame
237
+ * reaches anything that keeps it.
238
+ *
239
+ * The span falls out of the decode with no second walk. The Token Value is the
240
+ * tail of the Token structure — draft-19 Section 10.2.2, Figure 5: it is NOT
241
+ * length-prefixed inside the Token and consumes the remainder of the outer
242
+ * length-prefixed parameter value. So its start is the parameter value's end
243
+ * minus the value's own length, and the fields before it (Alias Type, Token
244
+ * Alias, Token Type) are left alone deliberately: they are structure, not
245
+ * secret, and they are what distinguishes a session that failed to
246
+ * authenticate from one that never tried.
247
+ *
248
+ * DELETE (0x0) and USE_ALIAS (0x2) carry no value at all, so they record
249
+ * nothing and their frames pass through untouched.
250
+ */
251
+ function noteAuthTokenValue(
252
+ valueStart: number,
253
+ valueLength: number,
254
+ token: AuthorizationToken,
255
+ ): void {
256
+ const value = token.token_value
257
+ if (value === undefined || value.byteLength === 0) return
258
+ recordAuthValueSpan(valueStart + valueLength - value.byteLength, value.byteLength)
259
+ }
260
+
235
261
  function decodeAuthorizationToken(r: BufferReader): AuthorizationToken {
236
262
  const alias_type = r.readVarInt()
237
263
  const aliasType = Number(alias_type)
@@ -282,7 +308,7 @@ const PARAM_LARGEST_OBJECT = 0x09n
282
308
  const PARAM_FILL_TIMEOUT = 0x0an
283
309
  const PARAM_FORWARD = 0x10n
284
310
  const PARAM_SUBSCRIBER_PRIORITY = 0x20n
285
- const PARAM_LOCATION_FILTER = 0x21n // renamed from SUBSCRIPTION_FILTER in draft-19
311
+ const PARAM_LOCATION_FILTER = 0x21n // LOCATION_FILTER (draft-19 Section 10.2.9); drafts 15-18 name 0x21 SUBSCRIPTION_FILTER
286
312
  const PARAM_GROUP_ORDER = 0x22n
287
313
  const PARAM_SUBGROUP_FILTER = 0x25n // NEW in draft-19
288
314
  const PARAM_OBJECTID_FILTER = 0x26n // NEW in draft-19
@@ -590,10 +616,9 @@ function decodeParams(reader: BufferReader, messageType: string): Draft19Params
590
616
  } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
591
617
  const length = Number(reader.readVarInt())
592
618
  const bytes = reader.readBytes(length)
593
- result.authorization_token = [
594
- ...(result.authorization_token ?? []),
595
- decodeAuthorizationToken(new BufferReader(bytes)),
596
- ]
619
+ const token = decodeAuthorizationToken(new BufferReader(bytes))
620
+ noteAuthTokenValue(reader.offset - length, length, token)
621
+ result.authorization_token = [...(result.authorization_token ?? []), token]
597
622
  } else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
598
623
  result.rendezvous_timeout = reader.readVarInt()
599
624
  } else if (paramType === PARAM_SUBGROUP_DELIVERY_TIMEOUT) {
@@ -608,7 +633,7 @@ function decodeParams(reader: BufferReader, messageType: string): Draft19Params
608
633
  } else if (paramType === PARAM_FILL_TIMEOUT) {
609
634
  result.fill_timeout = reader.readVarInt()
610
635
  } else if (paramType === PARAM_FORWARD) {
611
- // uint8 in draft-18 (was varint in draft-17)
636
+ // uint8 (Section 10.2.17); drafts 15 and 16 encode this as a varint
612
637
  result.forward = BigInt(reader.readUint8())
613
638
  } else if (paramType === PARAM_SUBSCRIBER_PRIORITY) {
614
639
  // uint8: single raw byte
@@ -1478,3 +1503,38 @@ export function createDraft19Codec(): Draft19Codec {
1478
1503
  createDataStreamDecoder,
1479
1504
  }
1480
1505
  }
1506
+
1507
+ /**
1508
+ * Overwrite every Authorization Token value in a draft-19 control frame.
1509
+ *
1510
+ * One decode, whose *output is discarded*: the point is not to read the
1511
+ * message, it is to learn where the tokens were so the caller never has to hold
1512
+ * a frame that contains one. A caller that also wants the message should decode
1513
+ * the **redacted** frame with {@link decodeMessage}, which then cannot produce a
1514
+ * token value because there is no longer one in the bytes.
1515
+ *
1516
+ * A frame that fails to decode is still redacted as far as the decode got. That
1517
+ * is the useful direction to fail in: a value that was read is a value that was
1518
+ * exposed, whatever went wrong after it.
1519
+ *
1520
+ * See {@link AuthRedaction.incomplete} for the one result a caller must not
1521
+ * treat as clean, and {@link AuthRedaction.decoded} for the residual it cannot
1522
+ * close.
1523
+ */
1524
+ export function redactAuthTokens(bytes: Uint8Array): AuthRedaction {
1525
+ let payloadStart: number
1526
+ try {
1527
+ const probe = new BufferReader(bytes)
1528
+ probe.readVarInt()
1529
+ probe.readUint8()
1530
+ probe.readUint8()
1531
+ payloadStart = probe.offset
1532
+ } catch {
1533
+ // Too short to carry a message header, and so too short for the parameters
1534
+ // that carry a token. Reported as not decoded rather than as clean: the
1535
+ // framer only ever emits complete frames, so a caller that gets here is
1536
+ // holding something this function did not check.
1537
+ return { bytes, redacted: 0, incomplete: false, decoded: false }
1538
+ }
1539
+ return redactWith(bytes, payloadStart, () => decodeMessage(bytes).ok)
1540
+ }