@moqtap/codec 0.9.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 (232) hide show
  1. package/CHANGELOG.md +173 -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-PU2KV7VP.cjs → chunk-27K5BUAG.cjs} +485 -515
  5. package/dist/{chunk-BV6MITLO.js → chunk-3RNQMGKA.js} +365 -390
  6. package/dist/{chunk-2XH6PHXR.js → chunk-5AWIXOLB.js} +442 -467
  7. package/dist/{chunk-4XLYCT5Q.cjs → chunk-5IMHJIAZ.cjs} +52 -2
  8. package/dist/{chunk-TVSFDQYE.cjs → chunk-5JGZCKJO.cjs} +513 -531
  9. package/dist/{chunk-IADVBKEJ.cjs → chunk-73K4OSAN.cjs} +407 -432
  10. package/dist/{chunk-N2V7Z37J.js → chunk-7VQKRGRD.js} +19 -3
  11. package/dist/{chunk-UZO5Z2XT.cjs → chunk-A3UCQOIB.cjs} +490 -515
  12. package/dist/{chunk-JKMYAUGY.js → chunk-A7PDMVXM.js} +35 -11
  13. package/dist/{chunk-VZHL2U2N.cjs → chunk-A7VQO6YC.cjs} +54 -38
  14. package/dist/{chunk-KCH4BQXK.cjs → chunk-ACQHZLRZ.cjs} +73 -47
  15. package/dist/{chunk-H6DTAIWM.js → chunk-BBICOMW6.js} +47 -19
  16. package/dist/{chunk-MAXEHYVB.cjs → chunk-BNIUVOCJ.cjs} +554 -612
  17. package/dist/{chunk-QGIHC6BA.cjs → chunk-CNC6ANS4.cjs} +70 -46
  18. package/dist/{chunk-NH4L6NIY.js → chunk-FDLQSWHK.js} +437 -467
  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-7ENEWAMZ.cjs → chunk-HM7BLRVP.cjs} +305 -305
  22. package/dist/{chunk-XHAP2YST.js → chunk-HZONHFNO.js} +19 -3
  23. package/dist/{chunk-EVCPBFSR.cjs → chunk-ILYABWDK.cjs} +83 -55
  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-UA5XFP4O.cjs → chunk-KTY4LAUV.cjs} +485 -494
  27. package/dist/{chunk-RZTLQAKF.js → chunk-OJNLJT5D.js} +0 -1
  28. package/dist/{chunk-YJGOD3Y4.js → chunk-PJK2ZS3I.js} +492 -550
  29. package/dist/{chunk-TMXRYOBS.js → chunk-PSMZKHOC.js} +444 -453
  30. package/dist/{chunk-7RE6KSIY.cjs → chunk-Q5JQGHWY.cjs} +0 -1
  31. package/dist/{chunk-23KRITJ6.js → chunk-SQTUQY5E.js} +37 -11
  32. package/dist/{chunk-XQGEOFGE.js → chunk-WCRLAKDW.js} +253 -253
  33. package/dist/{chunk-KYVTM5VI.js → chunk-WL2YUEXH.js} +19 -3
  34. package/dist/{chunk-Q7NSUXXB.js → chunk-YCNIVZS7.js} +464 -482
  35. package/dist/{chunk-KLPWJU6W.js → chunk-YRZQVNZO.js} +50 -0
  36. package/dist/{codec-Bym-K2q2.d.cts → codec-76xzrLTL.d.cts} +21 -2
  37. package/dist/{codec-BKsVu3Fr.d.ts → codec-8p40WdLg.d.ts} +21 -2
  38. package/dist/{codec-Dl_QIXMz.d.ts → codec-BN2Bu0KI.d.ts} +20 -1
  39. package/dist/{codec-D4RvFQmu.d.ts → codec-Bb6GKTrv.d.ts} +21 -2
  40. package/dist/{codec-DAyiF5sq.d.cts → codec-BgpfHoAd.d.cts} +21 -2
  41. package/dist/{codec-CA6nbbEk.d.ts → codec-BkheTXO7.d.ts} +21 -2
  42. package/dist/{codec-DchsPfr3.d.cts → codec-BwVDkokh.d.cts} +21 -2
  43. package/dist/{codec-CgZdadPt.d.cts → codec-C5s1eBJX.d.cts} +21 -2
  44. package/dist/codec-CM5yd6n3.d.ts +38 -0
  45. package/dist/{codec-DJmqoIsp.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-CSBFdPgP.d.cts → codec-DELe00w_.d.cts} +21 -2
  50. package/dist/{codec-C_xxsbKy.d.cts → codec-DHzKAUCa.d.cts} +21 -2
  51. package/dist/{codec--CVeqGQv.d.ts → codec-DdVBtvx7.d.ts} +20 -1
  52. package/dist/{codec-CviAa4lp.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-CtvFK4aV.d.cts → codec-GAY4lybi.d.cts} +21 -2
  55. package/dist/{codec-Cfo_z5ET.d.cts → codec-I8u2pfS4.d.cts} +20 -1
  56. package/dist/{codec-vddqy0KY.d.cts → codec-XLrnreeu.d.cts} +21 -2
  57. package/dist/{codec-O-1Js7h4.d.ts → codec-c0YEwwWn.d.ts} +21 -2
  58. package/dist/{codec-Cl73EfRW.d.ts → codec-ejDu-va6.d.ts} +21 -2
  59. package/dist/{codec-C006F75E.d.ts → codec-kaBUzdpV.d.ts} +21 -2
  60. package/dist/{codec-C5evFHL-.d.ts → codec-mVYqkIUF.d.ts} +21 -2
  61. package/dist/{codec-BMwgZIgG.d.ts → codec-qSbO5nOa.d.ts} +21 -2
  62. package/dist/{codec-BQa6Qsav.d.ts → codec-yYKGOipj.d.ts} +21 -2
  63. package/dist/{codec-DzLvG8Wb.d.cts → codec-zfzg9uiy.d.cts} +21 -2
  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-session.d.cts +1 -1
  81. package/dist/draft11-session.d.ts +1 -1
  82. package/dist/draft11.cjs +104 -3
  83. package/dist/draft11.d.cts +100 -4
  84. package/dist/draft11.d.ts +100 -4
  85. package/dist/draft11.js +105 -4
  86. package/dist/draft12-session.d.cts +1 -1
  87. package/dist/draft12-session.d.ts +1 -1
  88. package/dist/draft12.cjs +113 -3
  89. package/dist/draft12.d.cts +109 -4
  90. package/dist/draft12.d.ts +109 -4
  91. package/dist/draft12.js +114 -4
  92. package/dist/draft13-session.d.cts +1 -1
  93. package/dist/draft13-session.d.ts +1 -1
  94. package/dist/draft13.cjs +105 -3
  95. package/dist/draft13.d.cts +101 -4
  96. package/dist/draft13.d.ts +101 -4
  97. package/dist/draft13.js +106 -4
  98. package/dist/draft14-session.d.cts +1 -1
  99. package/dist/draft14-session.d.ts +1 -1
  100. package/dist/draft14.cjs +107 -3
  101. package/dist/draft14.d.cts +103 -30
  102. package/dist/draft14.d.ts +103 -30
  103. package/dist/draft14.js +108 -4
  104. package/dist/draft15-session.d.cts +1 -1
  105. package/dist/draft15-session.d.ts +1 -1
  106. package/dist/draft15.cjs +69 -3
  107. package/dist/draft15.d.cts +65 -22
  108. package/dist/draft15.d.ts +65 -22
  109. package/dist/draft15.js +70 -4
  110. package/dist/draft16-session.cjs +2 -2
  111. package/dist/draft16-session.d.cts +1 -1
  112. package/dist/draft16-session.d.ts +1 -1
  113. package/dist/draft16-session.js +1 -1
  114. package/dist/draft16.cjs +76 -8
  115. package/dist/draft16.d.cts +67 -13
  116. package/dist/draft16.d.ts +67 -13
  117. package/dist/draft16.js +73 -5
  118. package/dist/draft17-session.d.cts +1 -1
  119. package/dist/draft17-session.d.ts +1 -1
  120. package/dist/draft17.cjs +77 -3
  121. package/dist/draft17.d.cts +73 -4
  122. package/dist/draft17.d.ts +73 -4
  123. package/dist/draft17.js +78 -4
  124. package/dist/draft18-session.d.cts +1 -1
  125. package/dist/draft18-session.d.ts +1 -1
  126. package/dist/draft18.cjs +8 -3
  127. package/dist/draft18.d.cts +4 -3
  128. package/dist/draft18.d.ts +4 -3
  129. package/dist/draft18.js +9 -4
  130. package/dist/draft19-session.d.cts +1 -1
  131. package/dist/draft19-session.d.ts +1 -1
  132. package/dist/draft19.cjs +11 -4
  133. package/dist/draft19.d.cts +4 -3
  134. package/dist/draft19.d.ts +4 -3
  135. package/dist/draft19.js +12 -5
  136. package/dist/draft20-session.d.cts +1 -1
  137. package/dist/draft20-session.d.ts +1 -1
  138. package/dist/draft20.cjs +8 -3
  139. package/dist/draft20.d.cts +4 -3
  140. package/dist/draft20.d.ts +4 -3
  141. package/dist/draft20.js +9 -4
  142. package/dist/index.cjs +30 -30
  143. package/dist/index.d.cts +25 -24
  144. package/dist/index.d.ts +25 -24
  145. package/dist/index.js +15 -15
  146. package/dist/session.cjs +2 -2
  147. package/dist/session.d.cts +10 -10
  148. package/dist/session.d.ts +10 -10
  149. package/dist/session.js +1 -1
  150. package/dist/{types-zHgCS6o5.d.cts → types-Btp416jt.d.cts} +15 -7
  151. package/dist/{types-zHgCS6o5.d.ts → types-Btp416jt.d.ts} +15 -7
  152. package/dist/{types-Cm9fjeYC.d.cts → types-BxTL1NXw.d.cts} +9 -2
  153. package/dist/{types-Cm9fjeYC.d.ts → types-BxTL1NXw.d.ts} +9 -2
  154. package/dist/{types-Bio-91Rt.d.cts → types-CI_SX4Xe.d.cts} +2 -2
  155. package/dist/{types-Bio-91Rt.d.ts → types-CI_SX4Xe.d.ts} +2 -2
  156. package/dist/{types-HI_bbXka.d.cts → types-CmqT0jUf.d.cts} +1 -1
  157. package/dist/{types-HI_bbXka.d.ts → types-CmqT0jUf.d.ts} +1 -1
  158. package/dist/{types-CPaYBsMG.d.cts → types-CuibHYcf.d.cts} +9 -2
  159. package/dist/{types-CPaYBsMG.d.ts → types-CuibHYcf.d.ts} +9 -2
  160. package/dist/{types-CWCQwuvy.d.cts → types-CwN7AEoL.d.cts} +24 -12
  161. package/dist/{types-CWCQwuvy.d.ts → types-CwN7AEoL.d.ts} +24 -12
  162. package/dist/{types-Ck45Ex5S.d.cts → types-D0kTgUuL.d.cts} +1 -1
  163. package/dist/{types-Ck45Ex5S.d.ts → types-D0kTgUuL.d.ts} +1 -1
  164. package/dist/{types-D9eiB_9A.d.cts → types-DAnalt5K.d.cts} +9 -2
  165. package/dist/{types-D9eiB_9A.d.ts → types-DAnalt5K.d.ts} +9 -2
  166. package/dist/{types-CXlSn0I9.d.cts → types-DjxexghA.d.cts} +2 -2
  167. package/dist/{types-CXlSn0I9.d.ts → types-DjxexghA.d.ts} +2 -2
  168. package/dist/{types-Cqp10JtB.d.cts → types-DxXNP32l.d.cts} +10 -2
  169. package/dist/{types-Cqp10JtB.d.ts → types-DxXNP32l.d.ts} +10 -2
  170. package/package.json +3 -3
  171. package/src/core/auth-redaction.ts +192 -0
  172. package/src/drafts/draft07/codec.ts +40 -0
  173. package/src/drafts/draft07/error-codes.ts +44 -0
  174. package/src/drafts/draft07/index.ts +15 -0
  175. package/src/drafts/draft08/codec.ts +40 -0
  176. package/src/drafts/draft08/error-codes.ts +76 -0
  177. package/src/drafts/draft08/index.ts +21 -0
  178. package/src/drafts/draft09/codec.ts +40 -0
  179. package/src/drafts/draft09/error-codes.ts +76 -0
  180. package/src/drafts/draft09/index.ts +21 -0
  181. package/src/drafts/draft10/codec.ts +40 -0
  182. package/src/drafts/draft10/error-codes.ts +76 -0
  183. package/src/drafts/draft10/index.ts +21 -0
  184. package/src/drafts/draft11/codec.ts +71 -8
  185. package/src/drafts/draft11/error-codes.ts +106 -0
  186. package/src/drafts/draft11/index.ts +23 -0
  187. package/src/drafts/draft11/types.ts +1 -1
  188. package/src/drafts/draft12/codec.ts +83 -16
  189. package/src/drafts/draft12/error-codes.ts +116 -0
  190. package/src/drafts/draft12/index.ts +25 -0
  191. package/src/drafts/draft12/types.ts +2 -2
  192. package/src/drafts/draft13/codec.ts +75 -11
  193. package/src/drafts/draft13/error-codes.ts +107 -0
  194. package/src/drafts/draft13/index.ts +23 -0
  195. package/src/drafts/draft13/types.ts +3 -3
  196. package/src/drafts/draft14/codec.ts +79 -12
  197. package/src/drafts/draft14/data-streams.ts +331 -259
  198. package/src/drafts/draft14/error-codes.ts +109 -0
  199. package/src/drafts/draft14/index.ts +23 -0
  200. package/src/drafts/draft14/types.ts +1 -1
  201. package/src/drafts/draft15/codec.ts +71 -8
  202. package/src/drafts/draft15/data-streams.ts +489 -444
  203. package/src/drafts/draft15/error-codes.ts +66 -0
  204. package/src/drafts/draft15/index.ts +15 -0
  205. package/src/drafts/draft15/types.ts +9 -2
  206. package/src/drafts/draft16/codec.ts +149 -49
  207. package/src/drafts/draft16/data-streams.ts +513 -442
  208. package/src/drafts/draft16/error-codes.ts +68 -0
  209. package/src/drafts/draft16/index.ts +15 -0
  210. package/src/drafts/draft16/messages.ts +4 -4
  211. package/src/drafts/draft16/session-fsm.ts +0 -1
  212. package/src/drafts/draft16/types.ts +24 -10
  213. package/src/drafts/draft17/codec.ts +77 -10
  214. package/src/drafts/draft17/data-streams.ts +567 -488
  215. package/src/drafts/draft17/index.ts +15 -0
  216. package/src/drafts/draft17/types.ts +9 -2
  217. package/src/drafts/draft18/codec.ts +70 -7
  218. package/src/drafts/draft18/data-streams.ts +570 -482
  219. package/src/drafts/draft18/index.ts +3 -0
  220. package/src/drafts/draft18/types.ts +18 -10
  221. package/src/drafts/draft19/codec.ts +95 -23
  222. package/src/drafts/draft19/data-streams.ts +570 -482
  223. package/src/drafts/draft19/error-codes.ts +3 -1
  224. package/src/drafts/draft19/index.ts +3 -0
  225. package/src/drafts/draft19/messages.ts +3 -1
  226. package/src/drafts/draft19/types.ts +32 -18
  227. package/src/drafts/draft20/codec.ts +115 -36
  228. package/src/drafts/draft20/data-streams.ts +610 -563
  229. package/src/drafts/draft20/index.ts +3 -0
  230. package/src/drafts/draft20/types.ts +31 -13
  231. package/dist/codec-BJ7BHuiZ.d.ts +0 -18
  232. package/dist/codec-C6Mx4bwz.d.cts +0 -18
@@ -1,15 +1,17 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
4
 
5
5
 
6
6
 
7
- var _chunk4XLYCT5Qcjs = require('./chunk-4XLYCT5Q.cjs');
7
+
8
+
9
+ var _chunk5IMHJIAZcjs = require('./chunk-5IMHJIAZ.cjs');
8
10
 
9
11
  // src/drafts/draft13/data-streams.ts
10
12
  var FETCH_STREAM_TYPE = 0x05n;
11
13
  function encodeSubgroupStream(stream) {
12
- const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
14
+ const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
13
15
  const typeId = stream.streamTypeId;
14
16
  w.writeVarInt(BigInt(typeId));
15
17
  const extensionsPresent = (typeId & 1) !== 0;
@@ -34,7 +36,7 @@ function encodeSubgroupStream(stream) {
34
36
  return w.finish();
35
37
  }
36
38
  function encodeDatagram(dg) {
37
- const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
39
+ const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
38
40
  w.writeVarInt(BigInt(dg.streamTypeId));
39
41
  w.writeVarInt(dg.trackAlias);
40
42
  w.writeVarInt(dg.groupId);
@@ -55,7 +57,7 @@ function encodeDatagram(dg) {
55
57
  return w.finish();
56
58
  }
57
59
  function encodeFetchStream(stream) {
58
- const w = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
60
+ const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
59
61
  w.writeVarInt(FETCH_STREAM_TYPE);
60
62
  w.writeVarInt(stream.requestId);
61
63
  for (const obj of stream.objects) {
@@ -77,14 +79,14 @@ function encodeFetchStream(stream) {
77
79
  }
78
80
  function decodeSubgroupStream(bytes) {
79
81
  try {
80
- const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
82
+ const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
81
83
  const streamTypeId = Number(r.readVarInt());
82
84
  const validRange1 = streamTypeId >= 16 && streamTypeId <= 21;
83
85
  const validRange2 = streamTypeId >= 24 && streamTypeId <= 29;
84
86
  if (!validRange1 && !validRange2) {
85
87
  return {
86
88
  ok: false,
87
- error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
89
+ error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
88
90
  "CONSTRAINT_VIOLATION",
89
91
  `Expected subgroup type 0x10-0x15 or 0x18-0x1D, got 0x${streamTypeId.toString(16)}`,
90
92
  0
@@ -154,18 +156,18 @@ function decodeSubgroupStream(bytes) {
154
156
  bytesRead: r.offset
155
157
  };
156
158
  } catch (e) {
157
- if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
159
+ if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
158
160
  throw e;
159
161
  }
160
162
  }
161
163
  function decodeDatagram(bytes) {
162
164
  try {
163
- const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
165
+ const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
164
166
  const streamTypeId = Number(r.readVarInt());
165
167
  if (streamTypeId < 0 || streamTypeId > 5) {
166
168
  return {
167
169
  ok: false,
168
- error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
170
+ error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
169
171
  "CONSTRAINT_VIOLATION",
170
172
  `Expected datagram type 0x00-0x05, got 0x${streamTypeId.toString(16)}`,
171
173
  0
@@ -212,18 +214,18 @@ function decodeDatagram(bytes) {
212
214
  result.objectStatus = objectStatus;
213
215
  return { ok: true, value: result, bytesRead: r.offset };
214
216
  } catch (e) {
215
- if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
217
+ if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
216
218
  throw e;
217
219
  }
218
220
  }
219
221
  function decodeFetchStream(bytes) {
220
222
  try {
221
- const r = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
223
+ const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
222
224
  const streamType = r.readVarInt();
223
225
  if (streamType !== FETCH_STREAM_TYPE) {
224
226
  return {
225
227
  ok: false,
226
- error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
228
+ error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
227
229
  "CONSTRAINT_VIOLATION",
228
230
  `Expected fetch type 0x05, got 0x${streamType.toString(16)}`,
229
231
  0
@@ -275,7 +277,7 @@ function decodeFetchStream(bytes) {
275
277
  bytesRead: r.offset
276
278
  };
277
279
  } catch (e) {
278
- if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
280
+ if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
279
281
  throw e;
280
282
  }
281
283
  }
@@ -377,7 +379,7 @@ var MESSAGE_ID_MAP = new Map(
377
379
  var textEncoder = /* @__PURE__ */ new TextEncoder();
378
380
  var textDecoder = /* @__PURE__ */ new TextDecoder();
379
381
  function encodeAuthorizationToken(at, w) {
380
- const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
382
+ const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(64);
381
383
  tmpW.writeVarInt(at.alias_type);
382
384
  const aliasType = Number(at.alias_type);
383
385
  if (aliasType === 0 || aliasType === 1 || aliasType === 2) {
@@ -411,7 +413,7 @@ function encodeSetupParams(params, w) {
411
413
  let count = 0;
412
414
  if (params.path !== void 0) count++;
413
415
  if (params.max_request_id !== void 0) count++;
414
- if (params.authorization_token !== void 0) count++;
416
+ count += _nullishCoalesce(_optionalChain([params, 'access', _2 => _2.authorization_token, 'optionalAccess', _3 => _3.length]), () => ( 0));
415
417
  if (params.max_auth_token_cache_size !== void 0) count++;
416
418
  if (params.unknown) count += params.unknown.length;
417
419
  w.writeVarInt(count);
@@ -425,9 +427,9 @@ function encodeSetupParams(params, w) {
425
427
  w.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID);
426
428
  w.writeVarInt(params.max_request_id);
427
429
  }
428
- if (params.authorization_token !== void 0) {
430
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
429
431
  w.writeVarInt(SETUP_PARAM_AUTHORIZATION_TOKEN);
430
- encodeAuthorizationToken(params.authorization_token, w);
432
+ encodeAuthorizationToken(token, w);
431
433
  }
432
434
  if (params.max_auth_token_cache_size !== void 0) {
433
435
  w.writeVarInt(SETUP_PARAM_MAX_AUTH_TOKEN_CACHE_SIZE);
@@ -438,11 +440,11 @@ function encodeSetupParams(params, w) {
438
440
  const id = BigInt(u.id);
439
441
  w.writeVarInt(id);
440
442
  if (id % 2n === 0n) {
441
- const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
442
- const tmpReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(raw);
443
+ const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
444
+ const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(raw);
443
445
  w.writeVarInt(tmpReader.readVarInt());
444
446
  } else {
445
- const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
447
+ const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
446
448
  w.writeVarInt(raw.byteLength);
447
449
  w.writeBytes(raw);
448
450
  }
@@ -462,13 +464,13 @@ function decodeSetupParams(r) {
462
464
  } else if (paramType === SETUP_PARAM_MAX_AUTH_TOKEN_CACHE_SIZE) {
463
465
  result.max_auth_token_cache_size = value;
464
466
  } else {
465
- const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
467
+ const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
466
468
  tmpW.writeVarInt(value);
467
469
  const raw = tmpW.finish();
468
470
  unknown.push({
469
471
  id: `0x${paramType.toString(16)}`,
470
472
  length: raw.byteLength,
471
- raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
473
+ raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, raw)
472
474
  });
473
475
  }
474
476
  } else {
@@ -477,13 +479,16 @@ function decodeSetupParams(r) {
477
479
  const bytes = r.readBytes(length);
478
480
  result.path = textDecoder.decode(bytes);
479
481
  } else if (paramType === SETUP_PARAM_AUTHORIZATION_TOKEN) {
480
- result.authorization_token = decodeAuthorizationToken(r, length);
482
+ const valueStart = r.offset;
483
+ const token = decodeAuthorizationToken(r, length);
484
+ noteAuthTokenValue(valueStart, length, token.token_value);
485
+ result.authorization_token = [..._nullishCoalesce(result.authorization_token, () => ( [])), token];
481
486
  } else {
482
487
  const bytes = r.readBytes(length);
483
488
  unknown.push({
484
489
  id: `0x${paramType.toString(16)}`,
485
490
  length,
486
- raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
491
+ raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, bytes)
487
492
  });
488
493
  }
489
494
  }
@@ -494,16 +499,16 @@ function decodeSetupParams(r) {
494
499
  function encodeParams(params, w) {
495
500
  let count = params.unknown ? params.unknown.length : 0;
496
501
  if (params.delivery_timeout !== void 0) count++;
497
- if (params.authorization_token !== void 0) count++;
502
+ count += _nullishCoalesce(_optionalChain([params, 'access', _4 => _4.authorization_token, 'optionalAccess', _5 => _5.length]), () => ( 0));
498
503
  if (params.max_cache_duration !== void 0) count++;
499
504
  w.writeVarInt(count);
500
505
  if (params.delivery_timeout !== void 0) {
501
506
  w.writeVarInt(PARAM_DELIVERY_TIMEOUT);
502
507
  w.writeVarInt(params.delivery_timeout);
503
508
  }
504
- if (params.authorization_token !== void 0) {
509
+ for (const token of _nullishCoalesce(params.authorization_token, () => ( []))) {
505
510
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
506
- encodeAuthorizationToken(params.authorization_token, w);
511
+ encodeAuthorizationToken(token, w);
507
512
  }
508
513
  if (params.max_cache_duration !== void 0) {
509
514
  w.writeVarInt(PARAM_MAX_CACHE_DURATION);
@@ -514,11 +519,11 @@ function encodeParams(params, w) {
514
519
  const id = BigInt(u.id);
515
520
  w.writeVarInt(id);
516
521
  if (id % 2n === 0n) {
517
- const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
518
- const tmpReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(raw);
522
+ const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
523
+ const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(raw);
519
524
  w.writeVarInt(tmpReader.readVarInt());
520
525
  } else {
521
- const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
526
+ const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
522
527
  w.writeVarInt(raw.byteLength);
523
528
  w.writeBytes(raw);
524
529
  }
@@ -538,25 +543,28 @@ function decodeParams(r) {
538
543
  } else if (paramType === PARAM_MAX_CACHE_DURATION) {
539
544
  result.max_cache_duration = value;
540
545
  } else {
541
- const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
546
+ const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
542
547
  tmpW.writeVarInt(value);
543
548
  const raw = tmpW.finish();
544
549
  unknown.push({
545
550
  id: `0x${paramType.toString(16)}`,
546
551
  length: raw.byteLength,
547
- raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
552
+ raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, raw)
548
553
  });
549
554
  }
550
555
  } else {
551
556
  const length = Number(r.readVarInt());
552
557
  if (paramType === PARAM_AUTHORIZATION_TOKEN) {
553
- result.authorization_token = decodeAuthorizationToken(r, length);
558
+ const valueStart = r.offset;
559
+ const token = decodeAuthorizationToken(r, length);
560
+ noteAuthTokenValue(valueStart, length, token.token_value);
561
+ result.authorization_token = [..._nullishCoalesce(result.authorization_token, () => ( [])), token];
554
562
  } else {
555
563
  const bytes = r.readBytes(length);
556
564
  unknown.push({
557
565
  id: `0x${paramType.toString(16)}`,
558
566
  length,
559
- raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
567
+ raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, bytes)
560
568
  });
561
569
  }
562
570
  }
@@ -780,7 +788,7 @@ function encodeRequestsBlockedPayload(msg, w) {
780
788
  function decodeClientSetupPayload(r) {
781
789
  const numVersions = Number(r.readVarInt());
782
790
  if (numVersions === 0) {
783
- throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", "supported_versions must not be empty", r.offset);
791
+ throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", "supported_versions must not be empty", r.offset);
784
792
  }
785
793
  const supported_versions = [];
786
794
  for (let i = 0; i < numVersions; i++) supported_versions.push(r.readVarInt());
@@ -802,7 +810,7 @@ function decodeSubscribePayload(r) {
802
810
  const filter_type = r.readVarInt();
803
811
  const ft = Number(filter_type);
804
812
  if (ft < 1 || ft > 4) {
805
- throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid filter_type: ${ft}`, r.offset);
813
+ throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid filter_type: ${ft}`, r.offset);
806
814
  }
807
815
  let start_group;
808
816
  let start_object;
@@ -1028,7 +1036,7 @@ function decodeFetchPayload(r) {
1028
1036
  const fetch_type = r.readVarInt();
1029
1037
  const ft = Number(fetch_type);
1030
1038
  if (ft < 1 || ft > 3) {
1031
- throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${ft}`, r.offset);
1039
+ throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${ft}`, r.offset);
1032
1040
  }
1033
1041
  let standalone;
1034
1042
  let joining;
@@ -1100,7 +1108,7 @@ function decodeTrackStatusPayload(r) {
1100
1108
  const filter_type = r.readVarInt();
1101
1109
  const ft = Number(filter_type);
1102
1110
  if (ft < 1 || ft > 4) {
1103
- throw new (0, _chunk4XLYCT5Qcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid filter_type: ${ft}`, r.offset);
1111
+ throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid filter_type: ${ft}`, r.offset);
1104
1112
  }
1105
1113
  let start_group;
1106
1114
  let start_object;
@@ -1207,10 +1215,10 @@ var payloadDecoders = /* @__PURE__ */ new Map([
1207
1215
  function encodeMessage(message) {
1208
1216
  const typeId = MESSAGE_ID_MAP.get(message.type);
1209
1217
  if (typeId === void 0) throw new Error(`Unknown message type: ${message.type}`);
1210
- const payloadWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)();
1218
+ const payloadWriter = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
1211
1219
  encodePayload(message, payloadWriter);
1212
1220
  const payload = payloadWriter.finishView();
1213
- const writer = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(payload.byteLength + 16);
1221
+ const writer = new (0, _chunk5IMHJIAZcjs.BufferWriter)(payload.byteLength + 16);
1214
1222
  writer.writeVarInt(typeId);
1215
1223
  if (payload.byteLength > 65535) {
1216
1224
  throw new Error(`Payload too large for 16-bit length: ${payload.byteLength}`);
@@ -1290,18 +1298,18 @@ function encodePayload(msg, w) {
1290
1298
  }
1291
1299
  function decodeMessage(bytes) {
1292
1300
  try {
1293
- const reader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(bytes);
1301
+ const reader = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
1294
1302
  const typeId = reader.readVarInt();
1295
1303
  const lenHi = reader.readUint8();
1296
1304
  const lenLo = reader.readUint8();
1297
1305
  const payloadLength = lenHi << 8 | lenLo;
1298
1306
  const payloadBytes = reader.readBytes(payloadLength);
1299
- const payloadReader = new (0, _chunk4XLYCT5Qcjs.BufferReader)(payloadBytes);
1307
+ const payloadReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(payloadBytes);
1300
1308
  const decoder = payloadDecoders.get(typeId);
1301
1309
  if (!decoder) {
1302
1310
  return {
1303
1311
  ok: false,
1304
- error: new (0, _chunk4XLYCT5Qcjs.DecodeError)(
1312
+ error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
1305
1313
  "UNKNOWN_MESSAGE_TYPE",
1306
1314
  `Unknown message type ID: 0x${typeId.toString(16)}`,
1307
1315
  0
@@ -1311,7 +1319,7 @@ function decodeMessage(bytes) {
1311
1319
  const message = decoder(payloadReader);
1312
1320
  return { ok: true, value: message, bytesRead: reader.offset };
1313
1321
  } catch (e) {
1314
- if (e instanceof _chunk4XLYCT5Qcjs.DecodeError) return { ok: false, error: e };
1322
+ if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
1315
1323
  throw e;
1316
1324
  }
1317
1325
  }
@@ -1341,7 +1349,7 @@ function createStreamDecoder() {
1341
1349
  },
1342
1350
  flush(controller) {
1343
1351
  if (offset < buffer.length)
1344
- controller.error(new (0, _chunk4XLYCT5Qcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
1352
+ controller.error(new (0, _chunk5IMHJIAZcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
1345
1353
  }
1346
1354
  });
1347
1355
  }
@@ -1360,6 +1368,24 @@ function createDraft13Codec() {
1360
1368
  createStreamDecoder
1361
1369
  };
1362
1370
  }
1371
+ function noteAuthTokenValue(valueStart, valueLength, value) {
1372
+ if (value === void 0 || value.byteLength === 0) return;
1373
+ _chunk5IMHJIAZcjs.recordAuthValueSpan.call(void 0, valueStart + valueLength - value.byteLength, value.byteLength);
1374
+ }
1375
+ function redactAuthTokens(bytes) {
1376
+ let payloadStart;
1377
+ try {
1378
+ const probe = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
1379
+ probe.readVarInt();
1380
+ probe.readUint8();
1381
+ probe.readUint8();
1382
+ payloadStart = probe.offset;
1383
+ } catch (e2) {
1384
+ return { bytes, redacted: 0, incomplete: false, decoded: false };
1385
+ }
1386
+ return _chunk5IMHJIAZcjs.redactWith.call(void 0, bytes, payloadStart, () => decodeMessage(bytes).ok);
1387
+ }
1388
+
1363
1389
 
1364
1390
 
1365
1391
 
@@ -1410,4 +1436,4 @@ function createDraft13Codec() {
1410
1436
 
1411
1437
 
1412
1438
 
1413
- exports.encodeSubgroupStream = encodeSubgroupStream; exports.encodeDatagram = encodeDatagram; exports.encodeFetchStream = encodeFetchStream; exports.decodeSubgroupStream = decodeSubgroupStream; exports.decodeDatagram = decodeDatagram; exports.decodeFetchStream = decodeFetchStream; exports.decodeDataStream = decodeDataStream; exports.MSG_SUBSCRIBE_UPDATE = MSG_SUBSCRIBE_UPDATE; exports.MSG_SUBSCRIBE = MSG_SUBSCRIBE; exports.MSG_SUBSCRIBE_OK = MSG_SUBSCRIBE_OK; exports.MSG_SUBSCRIBE_ERROR = MSG_SUBSCRIBE_ERROR; exports.MSG_ANNOUNCE = MSG_ANNOUNCE; exports.MSG_ANNOUNCE_OK = MSG_ANNOUNCE_OK; exports.MSG_ANNOUNCE_ERROR = MSG_ANNOUNCE_ERROR; exports.MSG_UNANNOUNCE = MSG_UNANNOUNCE; exports.MSG_UNSUBSCRIBE = MSG_UNSUBSCRIBE; exports.MSG_SUBSCRIBE_DONE = MSG_SUBSCRIBE_DONE; exports.MSG_ANNOUNCE_CANCEL = MSG_ANNOUNCE_CANCEL; exports.MSG_TRACK_STATUS = MSG_TRACK_STATUS; exports.MSG_TRACK_STATUS_OK = MSG_TRACK_STATUS_OK; exports.MSG_TRACK_STATUS_ERROR = MSG_TRACK_STATUS_ERROR; exports.MSG_GOAWAY = MSG_GOAWAY; exports.MSG_SUBSCRIBE_NAMESPACE = MSG_SUBSCRIBE_NAMESPACE; exports.MSG_SUBSCRIBE_NAMESPACE_OK = MSG_SUBSCRIBE_NAMESPACE_OK; exports.MSG_SUBSCRIBE_NAMESPACE_ERROR = MSG_SUBSCRIBE_NAMESPACE_ERROR; exports.MSG_UNSUBSCRIBE_NAMESPACE = MSG_UNSUBSCRIBE_NAMESPACE; exports.MSG_MAX_REQUEST_ID = MSG_MAX_REQUEST_ID; exports.MSG_FETCH = MSG_FETCH; exports.MSG_FETCH_CANCEL = MSG_FETCH_CANCEL; exports.MSG_FETCH_OK = MSG_FETCH_OK; exports.MSG_FETCH_ERROR = MSG_FETCH_ERROR; exports.MSG_REQUESTS_BLOCKED = MSG_REQUESTS_BLOCKED; exports.MSG_PUBLISH = MSG_PUBLISH; exports.MSG_PUBLISH_OK = MSG_PUBLISH_OK; exports.MSG_PUBLISH_ERROR = MSG_PUBLISH_ERROR; exports.MSG_CLIENT_SETUP = MSG_CLIENT_SETUP; exports.MSG_SERVER_SETUP = MSG_SERVER_SETUP; exports.SETUP_PARAM_PATH = SETUP_PARAM_PATH; exports.SETUP_PARAM_MAX_REQUEST_ID = SETUP_PARAM_MAX_REQUEST_ID; exports.PARAM_DELIVERY_TIMEOUT = PARAM_DELIVERY_TIMEOUT; exports.PARAM_AUTHORIZATION_TOKEN = PARAM_AUTHORIZATION_TOKEN; exports.VARINT_FRAMED_MESSAGES = VARINT_FRAMED_MESSAGES; exports.MESSAGE_TYPE_MAP = MESSAGE_TYPE_MAP; exports.MESSAGE_ID_MAP = MESSAGE_ID_MAP; exports.encodeMessage = encodeMessage; exports.decodeMessage = decodeMessage; exports.createStreamDecoder = createStreamDecoder; exports.createDraft13Codec = createDraft13Codec;
1439
+ exports.encodeSubgroupStream = encodeSubgroupStream; exports.encodeDatagram = encodeDatagram; exports.encodeFetchStream = encodeFetchStream; exports.decodeSubgroupStream = decodeSubgroupStream; exports.decodeDatagram = decodeDatagram; exports.decodeFetchStream = decodeFetchStream; exports.decodeDataStream = decodeDataStream; exports.MSG_SUBSCRIBE_UPDATE = MSG_SUBSCRIBE_UPDATE; exports.MSG_SUBSCRIBE = MSG_SUBSCRIBE; exports.MSG_SUBSCRIBE_OK = MSG_SUBSCRIBE_OK; exports.MSG_SUBSCRIBE_ERROR = MSG_SUBSCRIBE_ERROR; exports.MSG_ANNOUNCE = MSG_ANNOUNCE; exports.MSG_ANNOUNCE_OK = MSG_ANNOUNCE_OK; exports.MSG_ANNOUNCE_ERROR = MSG_ANNOUNCE_ERROR; exports.MSG_UNANNOUNCE = MSG_UNANNOUNCE; exports.MSG_UNSUBSCRIBE = MSG_UNSUBSCRIBE; exports.MSG_SUBSCRIBE_DONE = MSG_SUBSCRIBE_DONE; exports.MSG_ANNOUNCE_CANCEL = MSG_ANNOUNCE_CANCEL; exports.MSG_TRACK_STATUS = MSG_TRACK_STATUS; exports.MSG_TRACK_STATUS_OK = MSG_TRACK_STATUS_OK; exports.MSG_TRACK_STATUS_ERROR = MSG_TRACK_STATUS_ERROR; exports.MSG_GOAWAY = MSG_GOAWAY; exports.MSG_SUBSCRIBE_NAMESPACE = MSG_SUBSCRIBE_NAMESPACE; exports.MSG_SUBSCRIBE_NAMESPACE_OK = MSG_SUBSCRIBE_NAMESPACE_OK; exports.MSG_SUBSCRIBE_NAMESPACE_ERROR = MSG_SUBSCRIBE_NAMESPACE_ERROR; exports.MSG_UNSUBSCRIBE_NAMESPACE = MSG_UNSUBSCRIBE_NAMESPACE; exports.MSG_MAX_REQUEST_ID = MSG_MAX_REQUEST_ID; exports.MSG_FETCH = MSG_FETCH; exports.MSG_FETCH_CANCEL = MSG_FETCH_CANCEL; exports.MSG_FETCH_OK = MSG_FETCH_OK; exports.MSG_FETCH_ERROR = MSG_FETCH_ERROR; exports.MSG_REQUESTS_BLOCKED = MSG_REQUESTS_BLOCKED; exports.MSG_PUBLISH = MSG_PUBLISH; exports.MSG_PUBLISH_OK = MSG_PUBLISH_OK; exports.MSG_PUBLISH_ERROR = MSG_PUBLISH_ERROR; exports.MSG_CLIENT_SETUP = MSG_CLIENT_SETUP; exports.MSG_SERVER_SETUP = MSG_SERVER_SETUP; exports.SETUP_PARAM_PATH = SETUP_PARAM_PATH; exports.SETUP_PARAM_MAX_REQUEST_ID = SETUP_PARAM_MAX_REQUEST_ID; exports.PARAM_DELIVERY_TIMEOUT = PARAM_DELIVERY_TIMEOUT; exports.PARAM_AUTHORIZATION_TOKEN = PARAM_AUTHORIZATION_TOKEN; exports.VARINT_FRAMED_MESSAGES = VARINT_FRAMED_MESSAGES; exports.MESSAGE_TYPE_MAP = MESSAGE_TYPE_MAP; exports.MESSAGE_ID_MAP = MESSAGE_ID_MAP; exports.encodeMessage = encodeMessage; exports.decodeMessage = decodeMessage; exports.createStreamDecoder = createStreamDecoder; exports.createDraft13Codec = createDraft13Codec; exports.redactAuthTokens = redactAuthTokens;
@@ -3,8 +3,10 @@ import {
3
3
  BufferWriter,
4
4
  DecodeError,
5
5
  bytesToHex,
6
- hexToBytes
7
- } from "./chunk-KLPWJU6W.js";
6
+ hexToBytes,
7
+ recordAuthValueSpan,
8
+ redactWith
9
+ } from "./chunk-YRZQVNZO.js";
8
10
 
9
11
  // src/drafts/draft12/data-streams.ts
10
12
  var FETCH_STREAM_TYPE = 0x05n;
@@ -376,7 +378,7 @@ function encodeSetupParams(params, w) {
376
378
  let count = 0;
377
379
  if (params.path !== void 0) count++;
378
380
  if (params.max_request_id !== void 0) count++;
379
- if (params.authorization_token !== void 0) count++;
381
+ count += params.authorization_token?.length ?? 0;
380
382
  if (params.unknown) count += params.unknown.length;
381
383
  w.writeVarInt(count);
382
384
  if (params.path !== void 0) {
@@ -389,9 +391,9 @@ function encodeSetupParams(params, w) {
389
391
  w.writeVarInt(SETUP_PARAM_MAX_REQUEST_ID);
390
392
  w.writeVarInt(params.max_request_id);
391
393
  }
392
- if (params.authorization_token !== void 0) {
394
+ for (const token of params.authorization_token ?? []) {
393
395
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
394
- const at = params.authorization_token;
396
+ const at = token;
395
397
  const tmpW = new BufferWriter(64);
396
398
  tmpW.writeVarInt(at.alias_type);
397
399
  tmpW.writeVarInt(at.token_type);
@@ -447,11 +449,15 @@ function decodeSetupParams(r) {
447
449
  const token_type = r.readVarInt();
448
450
  const tokenBytesLen = length - (r.offset - startOff);
449
451
  const tokenBytes = r.readBytes(tokenBytesLen);
450
- result.authorization_token = {
451
- alias_type,
452
- token_type,
453
- token_value: tokenBytes
454
- };
452
+ noteAuthTokenValue(startOff, length, tokenBytes);
453
+ result.authorization_token = [
454
+ ...result.authorization_token ?? [],
455
+ {
456
+ alias_type,
457
+ token_type,
458
+ token_value: tokenBytes
459
+ }
460
+ ];
455
461
  } else {
456
462
  const bytes = r.readBytes(length);
457
463
  unknown.push({
@@ -468,16 +474,16 @@ function decodeSetupParams(r) {
468
474
  function encodeParams(params, w) {
469
475
  let count = params.unknown ? params.unknown.length : 0;
470
476
  if (params.delivery_timeout !== void 0) count++;
471
- if (params.authorization_token !== void 0) count++;
477
+ count += params.authorization_token?.length ?? 0;
472
478
  if (params.max_cache_duration !== void 0) count++;
473
479
  w.writeVarInt(count);
474
480
  if (params.delivery_timeout !== void 0) {
475
481
  w.writeVarInt(PARAM_DELIVERY_TIMEOUT);
476
482
  w.writeVarInt(params.delivery_timeout);
477
483
  }
478
- if (params.authorization_token !== void 0) {
484
+ for (const token of params.authorization_token ?? []) {
479
485
  w.writeVarInt(PARAM_AUTHORIZATION_TOKEN);
480
- const at = params.authorization_token;
486
+ const at = token;
481
487
  const tmpW = new BufferWriter(64);
482
488
  tmpW.writeVarInt(at.alias_type);
483
489
  tmpW.writeVarInt(at.token_type);
@@ -536,11 +542,15 @@ function decodeParams(r) {
536
542
  const token_type = r.readVarInt();
537
543
  const tokenBytesLen = length - (r.offset - startOff);
538
544
  const tokenBytes = r.readBytes(tokenBytesLen);
539
- result.authorization_token = {
540
- alias_type,
541
- token_type,
542
- token_value: tokenBytes
543
- };
545
+ noteAuthTokenValue(startOff, length, tokenBytes);
546
+ result.authorization_token = [
547
+ ...result.authorization_token ?? [],
548
+ {
549
+ alias_type,
550
+ token_type,
551
+ token_value: tokenBytes
552
+ }
553
+ ];
544
554
  } else {
545
555
  const bytes = r.readBytes(length);
546
556
  unknown.push({
@@ -1282,6 +1292,23 @@ function createDraft12Codec() {
1282
1292
  createStreamDecoder
1283
1293
  };
1284
1294
  }
1295
+ function noteAuthTokenValue(valueStart, valueLength, value) {
1296
+ if (value === void 0 || value.byteLength === 0) return;
1297
+ recordAuthValueSpan(valueStart + valueLength - value.byteLength, value.byteLength);
1298
+ }
1299
+ function redactAuthTokens(bytes) {
1300
+ let payloadStart;
1301
+ try {
1302
+ const probe = new BufferReader(bytes);
1303
+ probe.readVarInt();
1304
+ probe.readUint8();
1305
+ probe.readUint8();
1306
+ payloadStart = probe.offset;
1307
+ } catch {
1308
+ return { bytes, redacted: 0, incomplete: false, decoded: false };
1309
+ }
1310
+ return redactWith(bytes, payloadStart, () => decodeMessage(bytes).ok);
1311
+ }
1285
1312
 
1286
1313
  export {
1287
1314
  encodeSubgroupStream,
@@ -1330,5 +1357,6 @@ export {
1330
1357
  encodeMessage,
1331
1358
  decodeMessage,
1332
1359
  createStreamDecoder,
1333
- createDraft12Codec
1360
+ createDraft12Codec,
1361
+ redactAuthTokens
1334
1362
  };