@moqtap/codec 0.10.0 → 0.11.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 (213) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/dist/auth-redaction-DsdLq4Qs.d.cts +102 -0
  3. package/dist/auth-redaction-DsdLq4Qs.d.ts +102 -0
  4. package/dist/{chunk-RYKQXBG6.cjs → chunk-27K5BUAG.cjs} +481 -517
  5. package/dist/{chunk-WCPENYNE.js → chunk-3RNQMGKA.js} +359 -390
  6. package/dist/{chunk-TSUZ6GJV.js → chunk-5AWIXOLB.js} +438 -469
  7. package/dist/{chunk-4XLYCT5Q.cjs → chunk-5IMHJIAZ.cjs} +52 -2
  8. package/dist/{chunk-KTNERCTZ.cjs → chunk-5JGZCKJO.cjs} +488 -518
  9. package/dist/{chunk-WCTMPDUX.cjs → chunk-73K4OSAN.cjs} +401 -432
  10. package/dist/{chunk-N2V7Z37J.js → chunk-7VQKRGRD.js} +19 -3
  11. package/dist/{chunk-BIBMDTU5.cjs → chunk-A3UCQOIB.cjs} +486 -517
  12. package/dist/{chunk-K2B3OVFK.js → chunk-A7PDMVXM.js} +24 -3
  13. package/dist/{chunk-VZHL2U2N.cjs → chunk-A7VQO6YC.cjs} +54 -38
  14. package/dist/{chunk-AQ445VV7.cjs → chunk-ACQHZLRZ.cjs} +66 -46
  15. package/dist/{chunk-L5DRACXS.js → chunk-BBICOMW6.js} +25 -3
  16. package/dist/{chunk-T4VWPKDG.cjs → chunk-BNIUVOCJ.cjs} +529 -599
  17. package/dist/{chunk-UKKDOOUO.cjs → chunk-CNC6ANS4.cjs} +58 -37
  18. package/dist/{chunk-OZRK73NQ.js → chunk-FDLQSWHK.js} +433 -469
  19. package/dist/{chunk-IJAF6PAY.js → chunk-FFNOE4UR.js} +19 -3
  20. package/dist/{chunk-CZNW3R5E.cjs → chunk-GMENT63T.cjs} +54 -38
  21. package/dist/{chunk-XCRCAUGI.cjs → chunk-HM7BLRVP.cjs} +291 -297
  22. package/dist/{chunk-XHAP2YST.js → chunk-HZONHFNO.js} +19 -3
  23. package/dist/{chunk-SDJTSMOW.cjs → chunk-ILYABWDK.cjs} +60 -38
  24. package/dist/{chunk-IDV2JYJ6.cjs → chunk-KRSFTZVO.cjs} +56 -40
  25. package/dist/{chunk-RIIA4ALQ.cjs → chunk-KSPH6KMH.cjs} +54 -38
  26. package/dist/{chunk-OUNN4IQB.cjs → chunk-KTY4LAUV.cjs} +482 -497
  27. package/dist/{chunk-RZTLQAKF.js → chunk-OJNLJT5D.js} +0 -1
  28. package/dist/{chunk-FT3HDNIB.js → chunk-PJK2ZS3I.js} +467 -537
  29. package/dist/{chunk-G53WYUXL.js → chunk-PSMZKHOC.js} +441 -456
  30. package/dist/{chunk-7RE6KSIY.cjs → chunk-Q5JQGHWY.cjs} +0 -1
  31. package/dist/{chunk-BX2N7TZM.js → chunk-SQTUQY5E.js} +31 -11
  32. package/dist/{chunk-CF5DDD3Q.js → chunk-WCRLAKDW.js} +239 -245
  33. package/dist/{chunk-KYVTM5VI.js → chunk-WL2YUEXH.js} +19 -3
  34. package/dist/{chunk-KGDVC4O6.js → chunk-YCNIVZS7.js} +439 -469
  35. package/dist/{chunk-KLPWJU6W.js → chunk-YRZQVNZO.js} +50 -0
  36. package/dist/{codec-CFWu5KVT.d.cts → codec-76xzrLTL.d.cts} +21 -2
  37. package/dist/{codec-gl4_QEva.d.ts → codec-8p40WdLg.d.ts} +20 -1
  38. package/dist/{codec-Dl_QIXMz.d.ts → codec-BN2Bu0KI.d.ts} +20 -1
  39. package/dist/{codec-Bux_Q40X.d.ts → codec-Bb6GKTrv.d.ts} +21 -2
  40. package/dist/{codec-EvybrBuY.d.cts → codec-BgpfHoAd.d.cts} +20 -1
  41. package/dist/{codec-alVA27Uc.d.ts → codec-BkheTXO7.d.ts} +20 -1
  42. package/dist/{codec-Czejcmxr.d.cts → codec-BwVDkokh.d.cts} +21 -2
  43. package/dist/{codec-BrTi4K7r.d.cts → codec-C5s1eBJX.d.cts} +21 -2
  44. package/dist/codec-CM5yd6n3.d.ts +38 -0
  45. package/dist/{codec-CWnf8mn_.d.cts → codec-Cb8HC3XV.d.cts} +21 -2
  46. package/dist/codec-Clu_skx8.d.cts +38 -0
  47. package/dist/{codec-DzkdW4kO.d.cts → codec-CpOpemR8.d.cts} +20 -1
  48. package/dist/{codec-CXCjya_G.d.cts → codec-Cshdl9Tt.d.cts} +20 -1
  49. package/dist/{codec-f7vxeVIS.d.cts → codec-DELe00w_.d.cts} +21 -2
  50. package/dist/{codec-DNmiG2e0.d.cts → codec-DHzKAUCa.d.cts} +20 -1
  51. package/dist/{codec--CVeqGQv.d.ts → codec-DdVBtvx7.d.ts} +20 -1
  52. package/dist/{codec-CBdOIfMY.d.ts → codec-DlxGuYMv.d.ts} +21 -2
  53. package/dist/{codec-BNy5syCU.d.ts → codec-DxtgPxJS.d.ts} +20 -1
  54. package/dist/{codec-guzqtfMk.d.cts → codec-GAY4lybi.d.cts} +20 -1
  55. package/dist/{codec-Cfo_z5ET.d.cts → codec-I8u2pfS4.d.cts} +20 -1
  56. package/dist/{codec-BxQTybUX.d.cts → codec-XLrnreeu.d.cts} +21 -2
  57. package/dist/{codec-DOmAmFkI.d.ts → codec-c0YEwwWn.d.ts} +20 -1
  58. package/dist/{codec-DaXjRrOV.d.ts → codec-ejDu-va6.d.ts} +21 -2
  59. package/dist/{codec-C3mdsGx3.d.ts → codec-kaBUzdpV.d.ts} +21 -2
  60. package/dist/{codec-CwZ6OCPP.d.ts → codec-mVYqkIUF.d.ts} +21 -2
  61. package/dist/{codec-08ZOr5wI.d.ts → codec-qSbO5nOa.d.ts} +21 -2
  62. package/dist/{codec-Cm3D261p.d.ts → codec-yYKGOipj.d.ts} +20 -1
  63. package/dist/{codec-Bd60SGKH.d.cts → codec-zfzg9uiy.d.cts} +20 -1
  64. package/dist/draft07.cjs +48 -4
  65. package/dist/draft07.d.cts +42 -2
  66. package/dist/draft07.d.ts +42 -2
  67. package/dist/draft07.js +49 -5
  68. package/dist/draft08.cjs +76 -3
  69. package/dist/draft08.d.cts +70 -2
  70. package/dist/draft08.d.ts +70 -2
  71. package/dist/draft08.js +77 -4
  72. package/dist/draft09.cjs +76 -3
  73. package/dist/draft09.d.cts +70 -2
  74. package/dist/draft09.d.ts +70 -2
  75. package/dist/draft09.js +77 -4
  76. package/dist/draft10.cjs +76 -3
  77. package/dist/draft10.d.cts +70 -2
  78. package/dist/draft10.d.ts +70 -2
  79. package/dist/draft10.js +77 -4
  80. package/dist/draft11.cjs +104 -3
  81. package/dist/draft11.d.cts +98 -2
  82. package/dist/draft11.d.ts +98 -2
  83. package/dist/draft11.js +105 -4
  84. package/dist/draft12.cjs +113 -3
  85. package/dist/draft12.d.cts +107 -2
  86. package/dist/draft12.d.ts +107 -2
  87. package/dist/draft12.js +114 -4
  88. package/dist/draft13.cjs +105 -3
  89. package/dist/draft13.d.cts +99 -2
  90. package/dist/draft13.d.ts +99 -2
  91. package/dist/draft13.js +106 -4
  92. package/dist/draft14.cjs +107 -3
  93. package/dist/draft14.d.cts +101 -28
  94. package/dist/draft14.d.ts +101 -28
  95. package/dist/draft14.js +108 -4
  96. package/dist/draft15-session.d.cts +1 -1
  97. package/dist/draft15-session.d.ts +1 -1
  98. package/dist/draft15.cjs +69 -3
  99. package/dist/draft15.d.cts +65 -22
  100. package/dist/draft15.d.ts +65 -22
  101. package/dist/draft15.js +70 -4
  102. package/dist/draft16-session.cjs +2 -2
  103. package/dist/draft16-session.d.cts +1 -1
  104. package/dist/draft16-session.d.ts +1 -1
  105. package/dist/draft16-session.js +1 -1
  106. package/dist/draft16.cjs +76 -8
  107. package/dist/draft16.d.cts +67 -13
  108. package/dist/draft16.d.ts +67 -13
  109. package/dist/draft16.js +73 -5
  110. package/dist/draft17-session.d.cts +1 -1
  111. package/dist/draft17-session.d.ts +1 -1
  112. package/dist/draft17.cjs +77 -3
  113. package/dist/draft17.d.cts +73 -4
  114. package/dist/draft17.d.ts +73 -4
  115. package/dist/draft17.js +78 -4
  116. package/dist/draft18-session.d.cts +1 -1
  117. package/dist/draft18-session.d.ts +1 -1
  118. package/dist/draft18.cjs +8 -3
  119. package/dist/draft18.d.cts +4 -3
  120. package/dist/draft18.d.ts +4 -3
  121. package/dist/draft18.js +9 -4
  122. package/dist/draft19-session.d.cts +1 -1
  123. package/dist/draft19-session.d.ts +1 -1
  124. package/dist/draft19.cjs +11 -4
  125. package/dist/draft19.d.cts +4 -3
  126. package/dist/draft19.d.ts +4 -3
  127. package/dist/draft19.js +12 -5
  128. package/dist/draft20-session.d.cts +1 -1
  129. package/dist/draft20-session.d.ts +1 -1
  130. package/dist/draft20.cjs +8 -3
  131. package/dist/draft20.d.cts +4 -3
  132. package/dist/draft20.d.ts +4 -3
  133. package/dist/draft20.js +9 -4
  134. package/dist/index.cjs +30 -30
  135. package/dist/index.d.cts +21 -20
  136. package/dist/index.d.ts +21 -20
  137. package/dist/index.js +15 -15
  138. package/dist/session.cjs +2 -2
  139. package/dist/session.d.cts +6 -6
  140. package/dist/session.d.ts +6 -6
  141. package/dist/session.js +1 -1
  142. package/dist/{types-C1rxh-id.d.cts → types-Btp416jt.d.cts} +8 -0
  143. package/dist/{types-C1rxh-id.d.ts → types-Btp416jt.d.ts} +8 -0
  144. package/dist/{types-CZTzbIzQ.d.cts → types-BxTL1NXw.d.cts} +7 -0
  145. package/dist/{types-CZTzbIzQ.d.ts → types-BxTL1NXw.d.ts} +7 -0
  146. package/dist/{types-pShrs3fN.d.cts → types-CuibHYcf.d.cts} +7 -0
  147. package/dist/{types-pShrs3fN.d.ts → types-CuibHYcf.d.ts} +7 -0
  148. package/dist/{types-CY-QWxd-.d.cts → types-CwN7AEoL.d.cts} +13 -1
  149. package/dist/{types-CY-QWxd-.d.ts → types-CwN7AEoL.d.ts} +13 -1
  150. package/dist/{types-D4bmW8rY.d.cts → types-DAnalt5K.d.cts} +7 -0
  151. package/dist/{types-D4bmW8rY.d.ts → types-DAnalt5K.d.ts} +7 -0
  152. package/dist/{types-Bg86GGVZ.d.cts → types-DxXNP32l.d.cts} +8 -0
  153. package/dist/{types-Bg86GGVZ.d.ts → types-DxXNP32l.d.ts} +8 -0
  154. package/package.json +3 -3
  155. package/src/core/auth-redaction.ts +192 -0
  156. package/src/drafts/draft07/codec.ts +40 -0
  157. package/src/drafts/draft07/error-codes.ts +44 -0
  158. package/src/drafts/draft07/index.ts +15 -0
  159. package/src/drafts/draft08/codec.ts +40 -0
  160. package/src/drafts/draft08/error-codes.ts +76 -0
  161. package/src/drafts/draft08/index.ts +21 -0
  162. package/src/drafts/draft09/codec.ts +40 -0
  163. package/src/drafts/draft09/error-codes.ts +76 -0
  164. package/src/drafts/draft09/index.ts +21 -0
  165. package/src/drafts/draft10/codec.ts +40 -0
  166. package/src/drafts/draft10/error-codes.ts +76 -0
  167. package/src/drafts/draft10/index.ts +21 -0
  168. package/src/drafts/draft11/codec.ts +60 -0
  169. package/src/drafts/draft11/error-codes.ts +106 -0
  170. package/src/drafts/draft11/index.ts +23 -0
  171. package/src/drafts/draft12/codec.ts +61 -0
  172. package/src/drafts/draft12/error-codes.ts +116 -0
  173. package/src/drafts/draft12/index.ts +25 -0
  174. package/src/drafts/draft13/codec.ts +69 -11
  175. package/src/drafts/draft13/error-codes.ts +107 -0
  176. package/src/drafts/draft13/index.ts +23 -0
  177. package/src/drafts/draft13/types.ts +1 -1
  178. package/src/drafts/draft14/codec.ts +65 -4
  179. package/src/drafts/draft14/data-streams.ts +331 -259
  180. package/src/drafts/draft14/error-codes.ts +109 -0
  181. package/src/drafts/draft14/index.ts +23 -0
  182. package/src/drafts/draft15/codec.ts +65 -8
  183. package/src/drafts/draft15/data-streams.ts +489 -444
  184. package/src/drafts/draft15/error-codes.ts +66 -0
  185. package/src/drafts/draft15/index.ts +15 -0
  186. package/src/drafts/draft15/types.ts +7 -0
  187. package/src/drafts/draft16/codec.ts +146 -52
  188. package/src/drafts/draft16/data-streams.ts +513 -442
  189. package/src/drafts/draft16/error-codes.ts +68 -0
  190. package/src/drafts/draft16/index.ts +15 -0
  191. package/src/drafts/draft16/messages.ts +4 -4
  192. package/src/drafts/draft16/session-fsm.ts +0 -1
  193. package/src/drafts/draft16/types.ts +22 -8
  194. package/src/drafts/draft17/codec.ts +73 -12
  195. package/src/drafts/draft17/data-streams.ts +567 -488
  196. package/src/drafts/draft17/index.ts +15 -0
  197. package/src/drafts/draft17/types.ts +7 -0
  198. package/src/drafts/draft18/codec.ts +66 -9
  199. package/src/drafts/draft18/data-streams.ts +570 -482
  200. package/src/drafts/draft18/index.ts +3 -0
  201. package/src/drafts/draft18/types.ts +16 -8
  202. package/src/drafts/draft19/codec.ts +70 -10
  203. package/src/drafts/draft19/data-streams.ts +570 -482
  204. package/src/drafts/draft19/error-codes.ts +3 -1
  205. package/src/drafts/draft19/index.ts +3 -0
  206. package/src/drafts/draft19/messages.ts +3 -1
  207. package/src/drafts/draft19/types.ts +22 -11
  208. package/src/drafts/draft20/codec.ts +90 -23
  209. package/src/drafts/draft20/data-streams.ts +610 -563
  210. package/src/drafts/draft20/index.ts +3 -0
  211. package/src/drafts/draft20/types.ts +14 -2
  212. package/dist/codec-BJ7BHuiZ.d.ts +0 -18
  213. package/dist/codec-C6Mx4bwz.d.cts +0 -18
package/CHANGELOG.md CHANGED
@@ -7,6 +7,153 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  This file starts at 0.9.0. Earlier releases are in the git history.
9
9
 
10
+ ## [0.11.0] - 2026-09-17
11
+
12
+ ### Added
13
+
14
+ - **`redactAuthTokens`, on all fourteen drafts.** Every draft entry point now
15
+ exports `redactAuthTokens`, with the `AuthRedaction` result type and the
16
+ `REDACTION_FILL` byte. It decodes a control frame for one purpose -- learning
17
+ where the credentials sat -- discards the message and returns the frame with
18
+ those bytes overwritten, so a caller never has to hold a frame containing one.
19
+
20
+ There are two credential shapes and the difference is not cosmetic. Drafts 07
21
+ through 10 have no Authorization Token: they carry AUTHORIZATION_INFO, a bare
22
+ UTF-8 string which *is* the bearer credential, so the whole parameter value
23
+ goes. From draft-11 only the Token Value is overwritten, and the Alias Type,
24
+ Token Alias and Token Type stay -- those are structure rather than secret, and
25
+ they are what distinguishes a session that failed to authenticate from one
26
+ that never tried.
27
+
28
+ A frame that fails to decode is still redacted as far as the decode reached,
29
+ which is the useful direction to fail in: a value that was read is a value
30
+ that was exposed, whatever went wrong after it. The result reports that case
31
+ as `incomplete`.
32
+
33
+ - **Every draft's error-code registries are reachable from its entry point.**
34
+ draft-17's were written, committed and left unexported, so the constants sat
35
+ in the published package with no way to name them from outside their own file.
36
+
37
+ ### Fixed
38
+
39
+ - **draft-16 Setup Parameters are delta-encoded, and were read as absolute.**
40
+ draft-16 Section 1.4.2 introduced Key-Value-Pair Types carried as "a delta
41
+ from the previous Type value", with the Length-present-when-odd parity decided
42
+ by the *resolved* type. `decodeParams` had always done this; `decodeSetupParams`
43
+ never did. Drafts 07-15 are unaffected because delta encoding did not exist
44
+ yet, and 17-20 route their setup through the delta-aware decoder -- 16 was the
45
+ only hole.
46
+
47
+ **This leaked credentials rather than merely misreading them.** With absolute
48
+ types an AUTHORIZATION_TOKEN in any position but the first resolves to the
49
+ wrong type -- 0x03 reads as 0x01, PATH, which is also odd and whose Length
50
+ happens to cover the token exactly -- so the decode *completes*, no span is
51
+ recorded, and the frame comes back unredacted with `redacted: 0` and nothing
52
+ to notice. Found by pointing a real session at a public relay, whose
53
+ SERVER_SETUP ends where the frame does only under the delta reading.
54
+
55
+ - **draft-17's Token Value is not length-prefixed.** The encoder wrote, and the
56
+ decoder read, a varint length in front of the Token Value that draft-17 does
57
+ not define. Figure 5 writes the field as `Token Value (..)` -- the rest of the
58
+ value -- and the only length genuinely present is the Key-Value-Pair's own.
59
+ Draft-18 repeats that figure and its prose verbatim and already encoded none.
60
+ Because the redactor locates the credential from the outer length, the stray
61
+ byte also left draft-17 frames unredacted. Requires `@moqtap/test-vectors`
62
+ 0.16.0, which drops the same byte from ten vectors.
63
+
64
+ - **A status Object no longer desynchronises the streaming decoders.** draft-20
65
+ Section 11.4.2: "The Object Status field is only sent if the Object Payload
66
+ Length is zero." The streaming subgroup transforms read the length, saw zero
67
+ and went to the next Object, leaving the status varint to be taken for the
68
+ next Object's Object ID Delta -- so one status Object silently decoded every
69
+ Object after it as garbage. Drafts 15, 17, 18, 19 and 20 were affected, and
70
+ draft-15's fetch decoder with them; each draft's one-shot decoder always had
71
+ the branch.
72
+
73
+ - **`bun run typecheck` no longer overwrites the published bundle.** tsup owns
74
+ `dist`, and every package `tsconfig.json` pointed `outDir` at the same
75
+ directory, so a local `build` followed by `typecheck` replaced the bundle with
76
+ an unbundled compilation plus a nested tree -- and `.npmignore` excludes
77
+ `dist/*/`, so the tarball kept the entry point and dropped the subtree it
78
+ imported. The typecheck program now emits nothing. Published tarballs were
79
+ unaffected only because both CI workflows happen to run `typecheck` before
80
+ `build`; any local `build -> typecheck -> publish` shipped it.
81
+
82
+ - **The streaming decoders and the one-shot decoders now agree.** Every draft
83
+ from 14 to 20 ships two ways to read a data stream, and nothing had ever
84
+ compared them. They had drifted, in six ways, none of which corrupted a
85
+ payload -- which is why it survived. A consumer that switched paths got
86
+ objects that looked right and carried a different shape.
87
+
88
+ On subgroup streams: the incremental decoder returned Properties as opaque
89
+ `extensionData` where the one-shot parsed them into `objectProperties`
90
+ (drafts 17-20); it dropped `headerType`, `endOfGroup` and `firstObject`
91
+ entirely; it left the Subgroup ID at zero under the mode that derives it from
92
+ the first Object's ID, rather than at that ID; and it reported every Object
93
+ as `byteOffset: 0`.
94
+
95
+ On fetch streams it was worse. The incremental decoder returned a bare
96
+ `ObjectPayload` with no `serializationFlags`, no `groupId`, no `subgroupId`,
97
+ no `publisherPriority` and no deltas, and because it carried no state between
98
+ Objects, **DATAGRAM-mode Object IDs were simply wrong** -- 0, 0, 0 where the
99
+ one-shot resolved 1, 2, 3.
100
+
101
+ Both decoders now share one header reader and one object reader per draft,
102
+ lifted out of the one-shot unchanged, so there is no second copy left to
103
+ drift. A new cross-draft test sweeps every header type and every
104
+ Serialization Flags combination each draft accepts and requires the two paths
105
+ to agree, whole-buffer and one byte at a time.
106
+
107
+ - **`createDataStreamDecoder` streams.** It picked an inner decoder and then
108
+ never wrote a byte to it: chunks accumulated in a local buffer and `flush`
109
+ decoded the whole stream in one shot, so every event arrived at end of
110
+ stream. On a subscription that stays open that is no events at all. It now
111
+ pumps the inner decoder's output as the bytes arrive. Which first bytes
112
+ select which decoder is unchanged.
113
+
114
+ ### Changed
115
+
116
+ - **Breaking, at the type level.** `SubgroupStreamHeader` gains a required
117
+ `headerType`, and `endOfGroup` and `firstObject` where the draft has them.
118
+ Code that reads the header event is unaffected; code that constructs one has
119
+ a field to add. The value is the same one `SubgroupStream.headerType`
120
+ carries.
121
+
122
+ Under the Subgroup ID mode that takes the ID from the first Object, the
123
+ header event is now emitted after that Object has been read rather than
124
+ before, because that is the first moment its Subgroup ID is known. It still
125
+ arrives ahead of every Object in the output.
126
+
127
+ ### Performance
128
+
129
+ - **The streaming decoders stop recopying their buffer on every chunk.** Both
130
+ allocated an array of `unread + chunk.length` and copied both halves into it
131
+ per chunk, which is quadratic in chunks per stream, and both built a fresh
132
+ subarray and `BufferReader` per *object*. Capacity now grows until reclaiming
133
+ the consumed prefix would leave the buffer at least half free, and never
134
+ shrinks; the reader is hoisted out of the object loop.
135
+
136
+ The buffer never compacts in place, and that is load-bearing rather than
137
+ incidental: payloads are handed out as views into it, so moving bytes within
138
+ it would corrupt an Object already emitted. The consumed prefix is dropped
139
+ only when a fresh array is being allocated anyway, which keeps the old array
140
+ alive exactly as long as the views into it.
141
+
142
+ Four megabytes, best of five, previous strategy against this one:
143
+
144
+ | objects | chunks | before | after | |
145
+ | ------- | ------ | ------ | ----- | ----- |
146
+ | 6 KB | 16 KB | 0.6 ms | 0.7 ms | 0.8x |
147
+ | 6 KB | 1 KB | 2.5 ms | 1.2 ms | 2.0x |
148
+ | 120 KB | 16 KB | 2.5 ms | 0.7 ms | 3.5x |
149
+ | 120 KB | 1 KB | 27.0 ms | 0.8 ms | 32.1x |
150
+
151
+ The first row is the shape the T10 captures have, and it is why a browser
152
+ measurement of this moved not at all: at 6 KB objects against 16 KB chunks
153
+ almost no chunk has an unread remainder to recopy. The last row is the same
154
+ code on objects those captures do contain -- they reach 120 KB -- arriving in
155
+ small chunks.
156
+
10
157
  ## [0.10.0] - 2026-09-03
11
158
 
12
159
  ### Changed
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Overwriting Authorization Token values at the point of parse.
3
+ *
4
+ * A collector that ships a customer's control plane verbatim is useful — the
5
+ * control plane is the part of a session a player library cannot misreport —
6
+ * right up until it also ships the bearer token sitting in a SETUP option or a
7
+ * SUBSCRIBE parameter. At that point a debugging tool has become a
8
+ * credential-exfiltration path.
9
+ *
10
+ * The fix has to happen **where the parse happens**, not on the way out. Bytes
11
+ * that were merely *masked before upload* still sat in memory in a form a later
12
+ * feature — a dump, an export, a bug — could reach. So this module hangs off
13
+ * the decoders themselves: the one pass that reads a Token Value is the pass
14
+ * that records where it was, and the value is overwritten before the frame is
15
+ * handed to anything that retains it.
16
+ *
17
+ * ── What is overwritten, and what deliberately is not
18
+ *
19
+ * Only the **Token Value** (draft-20 Section 10.2.2, Figure 5). The Alias Type,
20
+ * the Token Alias and the Token Type all stay:
21
+ *
22
+ * - the parameter's *presence* distinguishes a session that failed to
23
+ * authenticate from one that never tried, and losing that distinction blinds
24
+ * the tool at exactly the moment it is most wanted;
25
+ * - the Token Alias is how you see the same credential being reused across
26
+ * messages, which is a real debugging signal and is not itself a secret;
27
+ * - `USE_ALIAS` and `DELETE` carry no value at all, so those frames pass
28
+ * through untouched and it is visible that they did.
29
+ *
30
+ * The overwrite is **length-preserving**. That is not an aesthetic choice: a
31
+ * control frame carries a fixed 16-bit Message Length, and every offset a
32
+ * caller has already computed into the frame stays valid only if the frame does
33
+ * not change size. Preserving the length also preserves the fact that a token
34
+ * of *some* size was sent.
35
+ *
36
+ * ── Why a span sink and not a return value
37
+ *
38
+ * A Token Value is read in `decodeParams` and `decodeSetupOptions`, which sit
39
+ * under a dozen per-message payload decoders per draft. Threading a redaction
40
+ * channel out through all of them would mean changing every one of those
41
+ * signatures, in every draft, to carry something almost none of them use.
42
+ *
43
+ * The sink is module state, which is safe here for one specific reason and it
44
+ * is worth being explicit about it: **decoding is synchronous and single
45
+ * threaded, and no decoder re-enters the redactor.** {@link redactWith} opens
46
+ * the capture, runs one decode to completion, and closes it in a `finally`.
47
+ * There is no `await` between those points, so no second capture can interleave
48
+ * with the first.
49
+ *
50
+ * Spec of record: `wt-logging-1-collector.md` Section 1.6.
51
+ */
52
+ /**
53
+ * The byte written over a redacted Token Value.
54
+ *
55
+ * Zero, so that a redacted frame is obviously not a token rather than
56
+ * plausibly one. A caller who needs to tell "redacted" from "the peer really
57
+ * sent zeros" has {@link AuthRedaction.redacted}, which counts what was
58
+ * overwritten.
59
+ */
60
+ declare const REDACTION_FILL = 0;
61
+ /**
62
+ * The result of a redaction pass over one control frame.
63
+ */
64
+ interface AuthRedaction {
65
+ /**
66
+ * The frame with every Token Value overwritten, exactly as long as the input.
67
+ *
68
+ * When nothing needed redacting this is the **same reference** as the input,
69
+ * so the common case costs no copy. Callers that retain it must copy for the
70
+ * same reason they would have had to copy the input.
71
+ */
72
+ readonly bytes: Uint8Array;
73
+ /** How many Token Values were overwritten. */
74
+ readonly redacted: number;
75
+ /**
76
+ * A span was recorded that could not be applied to the frame.
77
+ *
78
+ * This means the offset arithmetic and the frame disagree, which is a defect
79
+ * rather than a wire condition. **A caller must not treat {@link bytes} as
80
+ * clean when this is set** — the safe response is to drop the frame's raw
81
+ * bytes rather than ship them, because the one thing that is certain is that
82
+ * a token was seen and its position is not trusted.
83
+ */
84
+ readonly incomplete: boolean;
85
+ /**
86
+ * Whether the message parsed all the way through.
87
+ *
88
+ * A frame can be perfectly legitimate and still not decode: an unknown or
89
+ * extension message codepoint is something a peer is allowed to send, and a
90
+ * collector ships those raw on purpose rather than losing the whole control
91
+ * plane over one of them. But a message that cannot be parsed is a message
92
+ * whose parameters cannot be walked, so `redacted === 0` on such a frame
93
+ * means "nothing was found", not "there is nothing there".
94
+ *
95
+ * That residual is narrow and it is real, and the only dishonest thing to do
96
+ * with it is hide it. Count the frames where this is false, so the gap in the
97
+ * guarantee is a number somebody can look at.
98
+ */
99
+ readonly decoded: boolean;
100
+ }
101
+
102
+ export { type AuthRedaction as A, REDACTION_FILL as R };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Overwriting Authorization Token values at the point of parse.
3
+ *
4
+ * A collector that ships a customer's control plane verbatim is useful — the
5
+ * control plane is the part of a session a player library cannot misreport —
6
+ * right up until it also ships the bearer token sitting in a SETUP option or a
7
+ * SUBSCRIBE parameter. At that point a debugging tool has become a
8
+ * credential-exfiltration path.
9
+ *
10
+ * The fix has to happen **where the parse happens**, not on the way out. Bytes
11
+ * that were merely *masked before upload* still sat in memory in a form a later
12
+ * feature — a dump, an export, a bug — could reach. So this module hangs off
13
+ * the decoders themselves: the one pass that reads a Token Value is the pass
14
+ * that records where it was, and the value is overwritten before the frame is
15
+ * handed to anything that retains it.
16
+ *
17
+ * ── What is overwritten, and what deliberately is not
18
+ *
19
+ * Only the **Token Value** (draft-20 Section 10.2.2, Figure 5). The Alias Type,
20
+ * the Token Alias and the Token Type all stay:
21
+ *
22
+ * - the parameter's *presence* distinguishes a session that failed to
23
+ * authenticate from one that never tried, and losing that distinction blinds
24
+ * the tool at exactly the moment it is most wanted;
25
+ * - the Token Alias is how you see the same credential being reused across
26
+ * messages, which is a real debugging signal and is not itself a secret;
27
+ * - `USE_ALIAS` and `DELETE` carry no value at all, so those frames pass
28
+ * through untouched and it is visible that they did.
29
+ *
30
+ * The overwrite is **length-preserving**. That is not an aesthetic choice: a
31
+ * control frame carries a fixed 16-bit Message Length, and every offset a
32
+ * caller has already computed into the frame stays valid only if the frame does
33
+ * not change size. Preserving the length also preserves the fact that a token
34
+ * of *some* size was sent.
35
+ *
36
+ * ── Why a span sink and not a return value
37
+ *
38
+ * A Token Value is read in `decodeParams` and `decodeSetupOptions`, which sit
39
+ * under a dozen per-message payload decoders per draft. Threading a redaction
40
+ * channel out through all of them would mean changing every one of those
41
+ * signatures, in every draft, to carry something almost none of them use.
42
+ *
43
+ * The sink is module state, which is safe here for one specific reason and it
44
+ * is worth being explicit about it: **decoding is synchronous and single
45
+ * threaded, and no decoder re-enters the redactor.** {@link redactWith} opens
46
+ * the capture, runs one decode to completion, and closes it in a `finally`.
47
+ * There is no `await` between those points, so no second capture can interleave
48
+ * with the first.
49
+ *
50
+ * Spec of record: `wt-logging-1-collector.md` Section 1.6.
51
+ */
52
+ /**
53
+ * The byte written over a redacted Token Value.
54
+ *
55
+ * Zero, so that a redacted frame is obviously not a token rather than
56
+ * plausibly one. A caller who needs to tell "redacted" from "the peer really
57
+ * sent zeros" has {@link AuthRedaction.redacted}, which counts what was
58
+ * overwritten.
59
+ */
60
+ declare const REDACTION_FILL = 0;
61
+ /**
62
+ * The result of a redaction pass over one control frame.
63
+ */
64
+ interface AuthRedaction {
65
+ /**
66
+ * The frame with every Token Value overwritten, exactly as long as the input.
67
+ *
68
+ * When nothing needed redacting this is the **same reference** as the input,
69
+ * so the common case costs no copy. Callers that retain it must copy for the
70
+ * same reason they would have had to copy the input.
71
+ */
72
+ readonly bytes: Uint8Array;
73
+ /** How many Token Values were overwritten. */
74
+ readonly redacted: number;
75
+ /**
76
+ * A span was recorded that could not be applied to the frame.
77
+ *
78
+ * This means the offset arithmetic and the frame disagree, which is a defect
79
+ * rather than a wire condition. **A caller must not treat {@link bytes} as
80
+ * clean when this is set** — the safe response is to drop the frame's raw
81
+ * bytes rather than ship them, because the one thing that is certain is that
82
+ * a token was seen and its position is not trusted.
83
+ */
84
+ readonly incomplete: boolean;
85
+ /**
86
+ * Whether the message parsed all the way through.
87
+ *
88
+ * A frame can be perfectly legitimate and still not decode: an unknown or
89
+ * extension message codepoint is something a peer is allowed to send, and a
90
+ * collector ships those raw on purpose rather than losing the whole control
91
+ * plane over one of them. But a message that cannot be parsed is a message
92
+ * whose parameters cannot be walked, so `redacted === 0` on such a frame
93
+ * means "nothing was found", not "there is nothing there".
94
+ *
95
+ * That residual is narrow and it is real, and the only dishonest thing to do
96
+ * with it is hide it. Count the frames where this is false, so the gap in the
97
+ * guarantee is a number somebody can look at.
98
+ */
99
+ readonly decoded: boolean;
100
+ }
101
+
102
+ export { type AuthRedaction as A, REDACTION_FILL as R };