@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.
- package/CHANGELOG.md +147 -0
- package/dist/auth-redaction-DsdLq4Qs.d.cts +102 -0
- package/dist/auth-redaction-DsdLq4Qs.d.ts +102 -0
- package/dist/{chunk-RYKQXBG6.cjs → chunk-27K5BUAG.cjs} +481 -517
- package/dist/{chunk-WCPENYNE.js → chunk-3RNQMGKA.js} +359 -390
- package/dist/{chunk-TSUZ6GJV.js → chunk-5AWIXOLB.js} +438 -469
- package/dist/{chunk-4XLYCT5Q.cjs → chunk-5IMHJIAZ.cjs} +52 -2
- package/dist/{chunk-KTNERCTZ.cjs → chunk-5JGZCKJO.cjs} +488 -518
- package/dist/{chunk-WCTMPDUX.cjs → chunk-73K4OSAN.cjs} +401 -432
- package/dist/{chunk-N2V7Z37J.js → chunk-7VQKRGRD.js} +19 -3
- package/dist/{chunk-BIBMDTU5.cjs → chunk-A3UCQOIB.cjs} +486 -517
- package/dist/{chunk-K2B3OVFK.js → chunk-A7PDMVXM.js} +24 -3
- package/dist/{chunk-VZHL2U2N.cjs → chunk-A7VQO6YC.cjs} +54 -38
- package/dist/{chunk-AQ445VV7.cjs → chunk-ACQHZLRZ.cjs} +66 -46
- package/dist/{chunk-L5DRACXS.js → chunk-BBICOMW6.js} +25 -3
- package/dist/{chunk-T4VWPKDG.cjs → chunk-BNIUVOCJ.cjs} +529 -599
- package/dist/{chunk-UKKDOOUO.cjs → chunk-CNC6ANS4.cjs} +58 -37
- package/dist/{chunk-OZRK73NQ.js → chunk-FDLQSWHK.js} +433 -469
- package/dist/{chunk-IJAF6PAY.js → chunk-FFNOE4UR.js} +19 -3
- package/dist/{chunk-CZNW3R5E.cjs → chunk-GMENT63T.cjs} +54 -38
- package/dist/{chunk-XCRCAUGI.cjs → chunk-HM7BLRVP.cjs} +291 -297
- package/dist/{chunk-XHAP2YST.js → chunk-HZONHFNO.js} +19 -3
- package/dist/{chunk-SDJTSMOW.cjs → chunk-ILYABWDK.cjs} +60 -38
- package/dist/{chunk-IDV2JYJ6.cjs → chunk-KRSFTZVO.cjs} +56 -40
- package/dist/{chunk-RIIA4ALQ.cjs → chunk-KSPH6KMH.cjs} +54 -38
- package/dist/{chunk-OUNN4IQB.cjs → chunk-KTY4LAUV.cjs} +482 -497
- package/dist/{chunk-RZTLQAKF.js → chunk-OJNLJT5D.js} +0 -1
- package/dist/{chunk-FT3HDNIB.js → chunk-PJK2ZS3I.js} +467 -537
- package/dist/{chunk-G53WYUXL.js → chunk-PSMZKHOC.js} +441 -456
- package/dist/{chunk-7RE6KSIY.cjs → chunk-Q5JQGHWY.cjs} +0 -1
- package/dist/{chunk-BX2N7TZM.js → chunk-SQTUQY5E.js} +31 -11
- package/dist/{chunk-CF5DDD3Q.js → chunk-WCRLAKDW.js} +239 -245
- package/dist/{chunk-KYVTM5VI.js → chunk-WL2YUEXH.js} +19 -3
- package/dist/{chunk-KGDVC4O6.js → chunk-YCNIVZS7.js} +439 -469
- package/dist/{chunk-KLPWJU6W.js → chunk-YRZQVNZO.js} +50 -0
- package/dist/{codec-CFWu5KVT.d.cts → codec-76xzrLTL.d.cts} +21 -2
- package/dist/{codec-gl4_QEva.d.ts → codec-8p40WdLg.d.ts} +20 -1
- package/dist/{codec-Dl_QIXMz.d.ts → codec-BN2Bu0KI.d.ts} +20 -1
- package/dist/{codec-Bux_Q40X.d.ts → codec-Bb6GKTrv.d.ts} +21 -2
- package/dist/{codec-EvybrBuY.d.cts → codec-BgpfHoAd.d.cts} +20 -1
- package/dist/{codec-alVA27Uc.d.ts → codec-BkheTXO7.d.ts} +20 -1
- package/dist/{codec-Czejcmxr.d.cts → codec-BwVDkokh.d.cts} +21 -2
- package/dist/{codec-BrTi4K7r.d.cts → codec-C5s1eBJX.d.cts} +21 -2
- package/dist/codec-CM5yd6n3.d.ts +38 -0
- package/dist/{codec-CWnf8mn_.d.cts → codec-Cb8HC3XV.d.cts} +21 -2
- package/dist/codec-Clu_skx8.d.cts +38 -0
- package/dist/{codec-DzkdW4kO.d.cts → codec-CpOpemR8.d.cts} +20 -1
- package/dist/{codec-CXCjya_G.d.cts → codec-Cshdl9Tt.d.cts} +20 -1
- package/dist/{codec-f7vxeVIS.d.cts → codec-DELe00w_.d.cts} +21 -2
- package/dist/{codec-DNmiG2e0.d.cts → codec-DHzKAUCa.d.cts} +20 -1
- package/dist/{codec--CVeqGQv.d.ts → codec-DdVBtvx7.d.ts} +20 -1
- package/dist/{codec-CBdOIfMY.d.ts → codec-DlxGuYMv.d.ts} +21 -2
- package/dist/{codec-BNy5syCU.d.ts → codec-DxtgPxJS.d.ts} +20 -1
- package/dist/{codec-guzqtfMk.d.cts → codec-GAY4lybi.d.cts} +20 -1
- package/dist/{codec-Cfo_z5ET.d.cts → codec-I8u2pfS4.d.cts} +20 -1
- package/dist/{codec-BxQTybUX.d.cts → codec-XLrnreeu.d.cts} +21 -2
- package/dist/{codec-DOmAmFkI.d.ts → codec-c0YEwwWn.d.ts} +20 -1
- package/dist/{codec-DaXjRrOV.d.ts → codec-ejDu-va6.d.ts} +21 -2
- package/dist/{codec-C3mdsGx3.d.ts → codec-kaBUzdpV.d.ts} +21 -2
- package/dist/{codec-CwZ6OCPP.d.ts → codec-mVYqkIUF.d.ts} +21 -2
- package/dist/{codec-08ZOr5wI.d.ts → codec-qSbO5nOa.d.ts} +21 -2
- package/dist/{codec-Cm3D261p.d.ts → codec-yYKGOipj.d.ts} +20 -1
- package/dist/{codec-Bd60SGKH.d.cts → codec-zfzg9uiy.d.cts} +20 -1
- package/dist/draft07.cjs +48 -4
- package/dist/draft07.d.cts +42 -2
- package/dist/draft07.d.ts +42 -2
- package/dist/draft07.js +49 -5
- package/dist/draft08.cjs +76 -3
- package/dist/draft08.d.cts +70 -2
- package/dist/draft08.d.ts +70 -2
- package/dist/draft08.js +77 -4
- package/dist/draft09.cjs +76 -3
- package/dist/draft09.d.cts +70 -2
- package/dist/draft09.d.ts +70 -2
- package/dist/draft09.js +77 -4
- package/dist/draft10.cjs +76 -3
- package/dist/draft10.d.cts +70 -2
- package/dist/draft10.d.ts +70 -2
- package/dist/draft10.js +77 -4
- package/dist/draft11.cjs +104 -3
- package/dist/draft11.d.cts +98 -2
- package/dist/draft11.d.ts +98 -2
- package/dist/draft11.js +105 -4
- package/dist/draft12.cjs +113 -3
- package/dist/draft12.d.cts +107 -2
- package/dist/draft12.d.ts +107 -2
- package/dist/draft12.js +114 -4
- package/dist/draft13.cjs +105 -3
- package/dist/draft13.d.cts +99 -2
- package/dist/draft13.d.ts +99 -2
- package/dist/draft13.js +106 -4
- package/dist/draft14.cjs +107 -3
- package/dist/draft14.d.cts +101 -28
- package/dist/draft14.d.ts +101 -28
- package/dist/draft14.js +108 -4
- package/dist/draft15-session.d.cts +1 -1
- package/dist/draft15-session.d.ts +1 -1
- package/dist/draft15.cjs +69 -3
- package/dist/draft15.d.cts +65 -22
- package/dist/draft15.d.ts +65 -22
- package/dist/draft15.js +70 -4
- package/dist/draft16-session.cjs +2 -2
- package/dist/draft16-session.d.cts +1 -1
- package/dist/draft16-session.d.ts +1 -1
- package/dist/draft16-session.js +1 -1
- package/dist/draft16.cjs +76 -8
- package/dist/draft16.d.cts +67 -13
- package/dist/draft16.d.ts +67 -13
- package/dist/draft16.js +73 -5
- package/dist/draft17-session.d.cts +1 -1
- package/dist/draft17-session.d.ts +1 -1
- package/dist/draft17.cjs +77 -3
- package/dist/draft17.d.cts +73 -4
- package/dist/draft17.d.ts +73 -4
- package/dist/draft17.js +78 -4
- package/dist/draft18-session.d.cts +1 -1
- package/dist/draft18-session.d.ts +1 -1
- package/dist/draft18.cjs +8 -3
- package/dist/draft18.d.cts +4 -3
- package/dist/draft18.d.ts +4 -3
- package/dist/draft18.js +9 -4
- package/dist/draft19-session.d.cts +1 -1
- package/dist/draft19-session.d.ts +1 -1
- package/dist/draft19.cjs +11 -4
- package/dist/draft19.d.cts +4 -3
- package/dist/draft19.d.ts +4 -3
- package/dist/draft19.js +12 -5
- package/dist/draft20-session.d.cts +1 -1
- package/dist/draft20-session.d.ts +1 -1
- package/dist/draft20.cjs +8 -3
- package/dist/draft20.d.cts +4 -3
- package/dist/draft20.d.ts +4 -3
- package/dist/draft20.js +9 -4
- package/dist/index.cjs +30 -30
- package/dist/index.d.cts +21 -20
- package/dist/index.d.ts +21 -20
- package/dist/index.js +15 -15
- package/dist/session.cjs +2 -2
- package/dist/session.d.cts +6 -6
- package/dist/session.d.ts +6 -6
- package/dist/session.js +1 -1
- package/dist/{types-C1rxh-id.d.cts → types-Btp416jt.d.cts} +8 -0
- package/dist/{types-C1rxh-id.d.ts → types-Btp416jt.d.ts} +8 -0
- package/dist/{types-CZTzbIzQ.d.cts → types-BxTL1NXw.d.cts} +7 -0
- package/dist/{types-CZTzbIzQ.d.ts → types-BxTL1NXw.d.ts} +7 -0
- package/dist/{types-pShrs3fN.d.cts → types-CuibHYcf.d.cts} +7 -0
- package/dist/{types-pShrs3fN.d.ts → types-CuibHYcf.d.ts} +7 -0
- package/dist/{types-CY-QWxd-.d.cts → types-CwN7AEoL.d.cts} +13 -1
- package/dist/{types-CY-QWxd-.d.ts → types-CwN7AEoL.d.ts} +13 -1
- package/dist/{types-D4bmW8rY.d.cts → types-DAnalt5K.d.cts} +7 -0
- package/dist/{types-D4bmW8rY.d.ts → types-DAnalt5K.d.ts} +7 -0
- package/dist/{types-Bg86GGVZ.d.cts → types-DxXNP32l.d.cts} +8 -0
- package/dist/{types-Bg86GGVZ.d.ts → types-DxXNP32l.d.ts} +8 -0
- package/package.json +3 -3
- package/src/core/auth-redaction.ts +192 -0
- package/src/drafts/draft07/codec.ts +40 -0
- package/src/drafts/draft07/error-codes.ts +44 -0
- package/src/drafts/draft07/index.ts +15 -0
- package/src/drafts/draft08/codec.ts +40 -0
- package/src/drafts/draft08/error-codes.ts +76 -0
- package/src/drafts/draft08/index.ts +21 -0
- package/src/drafts/draft09/codec.ts +40 -0
- package/src/drafts/draft09/error-codes.ts +76 -0
- package/src/drafts/draft09/index.ts +21 -0
- package/src/drafts/draft10/codec.ts +40 -0
- package/src/drafts/draft10/error-codes.ts +76 -0
- package/src/drafts/draft10/index.ts +21 -0
- package/src/drafts/draft11/codec.ts +60 -0
- package/src/drafts/draft11/error-codes.ts +106 -0
- package/src/drafts/draft11/index.ts +23 -0
- package/src/drafts/draft12/codec.ts +61 -0
- package/src/drafts/draft12/error-codes.ts +116 -0
- package/src/drafts/draft12/index.ts +25 -0
- package/src/drafts/draft13/codec.ts +69 -11
- package/src/drafts/draft13/error-codes.ts +107 -0
- package/src/drafts/draft13/index.ts +23 -0
- package/src/drafts/draft13/types.ts +1 -1
- package/src/drafts/draft14/codec.ts +65 -4
- package/src/drafts/draft14/data-streams.ts +331 -259
- package/src/drafts/draft14/error-codes.ts +109 -0
- package/src/drafts/draft14/index.ts +23 -0
- package/src/drafts/draft15/codec.ts +65 -8
- package/src/drafts/draft15/data-streams.ts +489 -444
- package/src/drafts/draft15/error-codes.ts +66 -0
- package/src/drafts/draft15/index.ts +15 -0
- package/src/drafts/draft15/types.ts +7 -0
- package/src/drafts/draft16/codec.ts +146 -52
- package/src/drafts/draft16/data-streams.ts +513 -442
- package/src/drafts/draft16/error-codes.ts +68 -0
- package/src/drafts/draft16/index.ts +15 -0
- package/src/drafts/draft16/messages.ts +4 -4
- package/src/drafts/draft16/session-fsm.ts +0 -1
- package/src/drafts/draft16/types.ts +22 -8
- package/src/drafts/draft17/codec.ts +73 -12
- package/src/drafts/draft17/data-streams.ts +567 -488
- package/src/drafts/draft17/index.ts +15 -0
- package/src/drafts/draft17/types.ts +7 -0
- package/src/drafts/draft18/codec.ts +66 -9
- package/src/drafts/draft18/data-streams.ts +570 -482
- package/src/drafts/draft18/index.ts +3 -0
- package/src/drafts/draft18/types.ts +16 -8
- package/src/drafts/draft19/codec.ts +70 -10
- package/src/drafts/draft19/data-streams.ts +570 -482
- package/src/drafts/draft19/error-codes.ts +3 -1
- package/src/drafts/draft19/index.ts +3 -0
- package/src/drafts/draft19/messages.ts +3 -1
- package/src/drafts/draft19/types.ts +22 -11
- package/src/drafts/draft20/codec.ts +90 -23
- package/src/drafts/draft20/data-streams.ts +610 -563
- package/src/drafts/draft20/index.ts +3 -0
- package/src/drafts/draft20/types.ts +14 -2
- package/dist/codec-BJ7BHuiZ.d.ts +0 -18
- package/dist/codec-C6Mx4bwz.d.cts +0 -18
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk5IMHJIAZcjs = require('./chunk-5IMHJIAZ.cjs');
|
|
8
10
|
|
|
9
11
|
// src/drafts/draft07/messages.ts
|
|
10
12
|
var MSG_SUBSCRIBE_UPDATE = 0x02n;
|
|
@@ -108,11 +110,11 @@ function encodeVarInt(value) {
|
|
|
108
110
|
}
|
|
109
111
|
function decodeVarInt(bytes, offset = 0) {
|
|
110
112
|
try {
|
|
111
|
-
const reader = new (0,
|
|
113
|
+
const reader = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes, offset);
|
|
112
114
|
const value = reader.readVarInt();
|
|
113
115
|
return { ok: true, value, bytesRead: reader.offset - offset };
|
|
114
116
|
} catch (e) {
|
|
115
|
-
if (e instanceof
|
|
117
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) {
|
|
116
118
|
return { ok: false, error: e };
|
|
117
119
|
}
|
|
118
120
|
throw e;
|
|
@@ -124,7 +126,7 @@ var SUBGROUP_STREAM_TYPE = 0x04n;
|
|
|
124
126
|
var FETCH_STREAM_TYPE = 0x05n;
|
|
125
127
|
var DATAGRAM_TYPE = 0x01n;
|
|
126
128
|
function encodeSubgroupStream(stream) {
|
|
127
|
-
const w = new (0,
|
|
129
|
+
const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
128
130
|
w.writeVarInt(SUBGROUP_STREAM_TYPE);
|
|
129
131
|
w.writeVarInt(stream.trackAlias);
|
|
130
132
|
w.writeVarInt(stream.groupId);
|
|
@@ -142,7 +144,7 @@ function encodeSubgroupStream(stream) {
|
|
|
142
144
|
return w.finish();
|
|
143
145
|
}
|
|
144
146
|
function encodeDatagram(dg) {
|
|
145
|
-
const w = new (0,
|
|
147
|
+
const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
146
148
|
w.writeVarInt(DATAGRAM_TYPE);
|
|
147
149
|
w.writeVarInt(dg.trackAlias);
|
|
148
150
|
w.writeVarInt(dg.groupId);
|
|
@@ -157,7 +159,7 @@ function encodeDatagram(dg) {
|
|
|
157
159
|
return w.finish();
|
|
158
160
|
}
|
|
159
161
|
function encodeFetchStream(stream) {
|
|
160
|
-
const w = new (0,
|
|
162
|
+
const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
161
163
|
w.writeVarInt(FETCH_STREAM_TYPE);
|
|
162
164
|
w.writeVarInt(stream.subscribeId);
|
|
163
165
|
for (const obj of stream.objects) {
|
|
@@ -176,12 +178,12 @@ function encodeFetchStream(stream) {
|
|
|
176
178
|
}
|
|
177
179
|
function decodeSubgroupStream(bytes) {
|
|
178
180
|
try {
|
|
179
|
-
const r = new (0,
|
|
181
|
+
const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
180
182
|
const streamType = Number(r.readVarInt());
|
|
181
183
|
if (streamType !== 4) {
|
|
182
184
|
return {
|
|
183
185
|
ok: false,
|
|
184
|
-
error: new (0,
|
|
186
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
185
187
|
"CONSTRAINT_VIOLATION",
|
|
186
188
|
`Expected subgroup type 0x04, got 0x${streamType.toString(16)}`,
|
|
187
189
|
0
|
|
@@ -233,18 +235,18 @@ function decodeSubgroupStream(bytes) {
|
|
|
233
235
|
bytesRead: r.offset
|
|
234
236
|
};
|
|
235
237
|
} catch (e) {
|
|
236
|
-
if (e instanceof
|
|
238
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
237
239
|
throw e;
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
242
|
function decodeDatagram(bytes) {
|
|
241
243
|
try {
|
|
242
|
-
const r = new (0,
|
|
244
|
+
const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
243
245
|
const streamType = Number(r.readVarInt());
|
|
244
246
|
if (streamType !== 1) {
|
|
245
247
|
return {
|
|
246
248
|
ok: false,
|
|
247
|
-
error: new (0,
|
|
249
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
248
250
|
"CONSTRAINT_VIOLATION",
|
|
249
251
|
`Expected datagram type 0x01, got 0x${streamType.toString(16)}`,
|
|
250
252
|
0
|
|
@@ -277,18 +279,18 @@ function decodeDatagram(bytes) {
|
|
|
277
279
|
if (status !== void 0) result.status = status;
|
|
278
280
|
return { ok: true, value: result, bytesRead: r.offset };
|
|
279
281
|
} catch (e) {
|
|
280
|
-
if (e instanceof
|
|
282
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
281
283
|
throw e;
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
286
|
function decodeFetchStream(bytes) {
|
|
285
287
|
try {
|
|
286
|
-
const r = new (0,
|
|
288
|
+
const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
287
289
|
const streamType = Number(r.readVarInt());
|
|
288
290
|
if (streamType !== 5) {
|
|
289
291
|
return {
|
|
290
292
|
ok: false,
|
|
291
|
-
error: new (0,
|
|
293
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
292
294
|
"CONSTRAINT_VIOLATION",
|
|
293
295
|
`Expected fetch type 0x05, got 0x${streamType.toString(16)}`,
|
|
294
296
|
0
|
|
@@ -335,7 +337,7 @@ function decodeFetchStream(bytes) {
|
|
|
335
337
|
bytesRead: r.offset
|
|
336
338
|
};
|
|
337
339
|
} catch (e) {
|
|
338
|
-
if (e instanceof
|
|
340
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
339
341
|
throw e;
|
|
340
342
|
}
|
|
341
343
|
}
|
|
@@ -353,7 +355,7 @@ function encodeSetupParams(params, w) {
|
|
|
353
355
|
w.writeVarInt(count);
|
|
354
356
|
if (params.role !== void 0) {
|
|
355
357
|
w.writeVarInt(SETUP_PARAM_ROLE);
|
|
356
|
-
const tmpW = new (0,
|
|
358
|
+
const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
|
|
357
359
|
tmpW.writeVarInt(params.role);
|
|
358
360
|
const raw = tmpW.finish();
|
|
359
361
|
w.writeVarInt(raw.byteLength);
|
|
@@ -367,7 +369,7 @@ function encodeSetupParams(params, w) {
|
|
|
367
369
|
}
|
|
368
370
|
if (params.max_subscribe_id !== void 0) {
|
|
369
371
|
w.writeVarInt(SETUP_PARAM_MAX_SUBSCRIBE_ID);
|
|
370
|
-
const tmpW = new (0,
|
|
372
|
+
const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
|
|
371
373
|
tmpW.writeVarInt(params.max_subscribe_id);
|
|
372
374
|
const raw = tmpW.finish();
|
|
373
375
|
w.writeVarInt(raw.byteLength);
|
|
@@ -376,7 +378,7 @@ function encodeSetupParams(params, w) {
|
|
|
376
378
|
if (params.unknown) {
|
|
377
379
|
for (const u of params.unknown) {
|
|
378
380
|
w.writeVarInt(BigInt(u.id));
|
|
379
|
-
const raw =
|
|
381
|
+
const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
380
382
|
w.writeVarInt(raw.byteLength);
|
|
381
383
|
w.writeBytes(raw);
|
|
382
384
|
}
|
|
@@ -391,21 +393,21 @@ function decodeSetupParams(r) {
|
|
|
391
393
|
const length = Number(r.readVarInt());
|
|
392
394
|
if (paramType === SETUP_PARAM_ROLE) {
|
|
393
395
|
const blob = r.readBytes(length);
|
|
394
|
-
const tmpReader = new (0,
|
|
396
|
+
const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(blob);
|
|
395
397
|
result.role = tmpReader.readVarInt();
|
|
396
398
|
} else if (paramType === SETUP_PARAM_PATH) {
|
|
397
399
|
const bytes = r.readBytes(length);
|
|
398
400
|
result.path = textDecoder.decode(bytes);
|
|
399
401
|
} else if (paramType === SETUP_PARAM_MAX_SUBSCRIBE_ID) {
|
|
400
402
|
const blob = r.readBytes(length);
|
|
401
|
-
const tmpReader = new (0,
|
|
403
|
+
const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(blob);
|
|
402
404
|
result.max_subscribe_id = tmpReader.readVarInt();
|
|
403
405
|
} else {
|
|
404
406
|
const bytes = r.readBytes(length);
|
|
405
407
|
unknown.push({
|
|
406
408
|
id: `0x${paramType.toString(16)}`,
|
|
407
409
|
length,
|
|
408
|
-
raw_hex:
|
|
410
|
+
raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, bytes)
|
|
409
411
|
});
|
|
410
412
|
}
|
|
411
413
|
}
|
|
@@ -426,7 +428,7 @@ function encodeParams(params, w) {
|
|
|
426
428
|
}
|
|
427
429
|
if (params.delivery_timeout !== void 0) {
|
|
428
430
|
w.writeVarInt(PARAM_DELIVERY_TIMEOUT);
|
|
429
|
-
const tmpW = new (0,
|
|
431
|
+
const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
|
|
430
432
|
tmpW.writeVarInt(params.delivery_timeout);
|
|
431
433
|
const raw = tmpW.finish();
|
|
432
434
|
w.writeVarInt(raw.byteLength);
|
|
@@ -434,7 +436,7 @@ function encodeParams(params, w) {
|
|
|
434
436
|
}
|
|
435
437
|
if (params.max_cache_duration !== void 0) {
|
|
436
438
|
w.writeVarInt(PARAM_MAX_CACHE_DURATION);
|
|
437
|
-
const tmpW = new (0,
|
|
439
|
+
const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
|
|
438
440
|
tmpW.writeVarInt(params.max_cache_duration);
|
|
439
441
|
const raw = tmpW.finish();
|
|
440
442
|
w.writeVarInt(raw.byteLength);
|
|
@@ -443,7 +445,7 @@ function encodeParams(params, w) {
|
|
|
443
445
|
if (params.unknown) {
|
|
444
446
|
for (const u of params.unknown) {
|
|
445
447
|
w.writeVarInt(BigInt(u.id));
|
|
446
|
-
const raw =
|
|
448
|
+
const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
447
449
|
w.writeVarInt(raw.byteLength);
|
|
448
450
|
w.writeBytes(raw);
|
|
449
451
|
}
|
|
@@ -458,21 +460,22 @@ function decodeParams(r) {
|
|
|
458
460
|
const length = Number(r.readVarInt());
|
|
459
461
|
if (paramType === PARAM_AUTHORIZATION_INFO) {
|
|
460
462
|
const bytes = r.readBytes(length);
|
|
463
|
+
_chunk5IMHJIAZcjs.recordAuthValueSpan.call(void 0, r.offset - length, length);
|
|
461
464
|
result.authorization_info = textDecoder.decode(bytes);
|
|
462
465
|
} else if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
463
466
|
const blob = r.readBytes(length);
|
|
464
|
-
const tmpReader = new (0,
|
|
467
|
+
const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(blob);
|
|
465
468
|
result.delivery_timeout = tmpReader.readVarInt();
|
|
466
469
|
} else if (paramType === PARAM_MAX_CACHE_DURATION) {
|
|
467
470
|
const blob = r.readBytes(length);
|
|
468
|
-
const tmpReader = new (0,
|
|
471
|
+
const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(blob);
|
|
469
472
|
result.max_cache_duration = tmpReader.readVarInt();
|
|
470
473
|
} else {
|
|
471
474
|
const bytes = r.readBytes(length);
|
|
472
475
|
unknown.push({
|
|
473
476
|
id: `0x${paramType.toString(16)}`,
|
|
474
477
|
length,
|
|
475
|
-
raw_hex:
|
|
478
|
+
raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, bytes)
|
|
476
479
|
});
|
|
477
480
|
}
|
|
478
481
|
}
|
|
@@ -703,7 +706,7 @@ function encodePayload(msg, w) {
|
|
|
703
706
|
function decodeClientSetupPayload(reader) {
|
|
704
707
|
const numVersions = reader.readVarInt();
|
|
705
708
|
if (numVersions === 0n) {
|
|
706
|
-
throw new (0,
|
|
709
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
707
710
|
"CONSTRAINT_VIOLATION",
|
|
708
711
|
"supported_versions must not be empty",
|
|
709
712
|
reader.offset
|
|
@@ -730,7 +733,7 @@ function decodeSubscribePayload(reader) {
|
|
|
730
733
|
const group_order = reader.readUint8();
|
|
731
734
|
const filter_type = reader.readVarInt();
|
|
732
735
|
if (filter_type < 1n || filter_type > 4n) {
|
|
733
|
-
throw new (0,
|
|
736
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
734
737
|
"CONSTRAINT_VIOLATION",
|
|
735
738
|
`Invalid filter type: ${filter_type}`,
|
|
736
739
|
reader.offset
|
|
@@ -1043,7 +1046,7 @@ var payloadDecoders = /* @__PURE__ */ new Map([
|
|
|
1043
1046
|
var dataStreamDecoders = /* @__PURE__ */ new Map([[MSG_OBJECT_DATAGRAM, decodeObjectDatagram]]);
|
|
1044
1047
|
function encodeMessage(message) {
|
|
1045
1048
|
if (message.type === "object_datagram") {
|
|
1046
|
-
const writer2 = new (0,
|
|
1049
|
+
const writer2 = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
1047
1050
|
encodeObjectDatagram(message, writer2);
|
|
1048
1051
|
return writer2.finish();
|
|
1049
1052
|
}
|
|
@@ -1051,10 +1054,10 @@ function encodeMessage(message) {
|
|
|
1051
1054
|
if (typeId === void 0) {
|
|
1052
1055
|
throw new Error(`Unknown message type: ${message.type}`);
|
|
1053
1056
|
}
|
|
1054
|
-
const payloadWriter = new (0,
|
|
1057
|
+
const payloadWriter = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
1055
1058
|
encodePayload(message, payloadWriter);
|
|
1056
1059
|
const payload = payloadWriter.finishView();
|
|
1057
|
-
const writer = new (0,
|
|
1060
|
+
const writer = new (0, _chunk5IMHJIAZcjs.BufferWriter)(payload.byteLength + 16);
|
|
1058
1061
|
writer.writeVarInt(typeId);
|
|
1059
1062
|
writer.writeVarInt(payload.byteLength);
|
|
1060
1063
|
writer.writeBytes(payload);
|
|
@@ -1062,14 +1065,14 @@ function encodeMessage(message) {
|
|
|
1062
1065
|
}
|
|
1063
1066
|
function decodeMessage(bytes) {
|
|
1064
1067
|
try {
|
|
1065
|
-
const reader = new (0,
|
|
1068
|
+
const reader = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes, 0);
|
|
1066
1069
|
const typeId = reader.readVarInt();
|
|
1067
1070
|
if (DATA_STREAM_TYPE_IDS.has(typeId)) {
|
|
1068
1071
|
const decoder2 = dataStreamDecoders.get(typeId);
|
|
1069
1072
|
if (!decoder2) {
|
|
1070
1073
|
return {
|
|
1071
1074
|
ok: false,
|
|
1072
|
-
error: new (0,
|
|
1075
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
1073
1076
|
"UNKNOWN_MESSAGE_TYPE",
|
|
1074
1077
|
`Unknown data stream type ID: 0x${typeId.toString(16)}`,
|
|
1075
1078
|
0
|
|
@@ -1083,7 +1086,7 @@ function decodeMessage(bytes) {
|
|
|
1083
1086
|
if (reader.remaining < payloadLength) {
|
|
1084
1087
|
return {
|
|
1085
1088
|
ok: false,
|
|
1086
|
-
error: new (0,
|
|
1089
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
1087
1090
|
"UNEXPECTED_END",
|
|
1088
1091
|
`Not enough bytes for payload: need ${payloadLength}, have ${reader.remaining}`,
|
|
1089
1092
|
reader.offset
|
|
@@ -1096,18 +1099,18 @@ function decodeMessage(bytes) {
|
|
|
1096
1099
|
if (!decoder) {
|
|
1097
1100
|
return {
|
|
1098
1101
|
ok: false,
|
|
1099
|
-
error: new (0,
|
|
1102
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
1100
1103
|
"UNKNOWN_MESSAGE_TYPE",
|
|
1101
1104
|
`Unknown message type ID: 0x${typeId.toString(16)}`,
|
|
1102
1105
|
0
|
|
1103
1106
|
)
|
|
1104
1107
|
};
|
|
1105
1108
|
}
|
|
1106
|
-
const payloadReader = new (0,
|
|
1109
|
+
const payloadReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(payloadBytes, 0);
|
|
1107
1110
|
const message = decoder(payloadReader);
|
|
1108
1111
|
return { ok: true, value: message, bytesRead: totalBytesRead };
|
|
1109
1112
|
} catch (e) {
|
|
1110
|
-
if (e instanceof
|
|
1113
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) {
|
|
1111
1114
|
return { ok: false, error: e };
|
|
1112
1115
|
}
|
|
1113
1116
|
throw e;
|
|
@@ -1140,7 +1143,7 @@ function createStreamDecoder() {
|
|
|
1140
1143
|
flush(controller) {
|
|
1141
1144
|
if (offset < buffer.length) {
|
|
1142
1145
|
controller.error(
|
|
1143
|
-
new (0,
|
|
1146
|
+
new (0, _chunk5IMHJIAZcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete message data", 0)
|
|
1144
1147
|
);
|
|
1145
1148
|
}
|
|
1146
1149
|
}
|
|
@@ -1162,6 +1165,19 @@ function createDraft07Codec() {
|
|
|
1162
1165
|
decodeFetchStream
|
|
1163
1166
|
};
|
|
1164
1167
|
}
|
|
1168
|
+
function redactAuthTokens(bytes) {
|
|
1169
|
+
let payloadStart;
|
|
1170
|
+
try {
|
|
1171
|
+
const probe = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
1172
|
+
probe.readVarInt();
|
|
1173
|
+
probe.readVarInt();
|
|
1174
|
+
payloadStart = probe.offset;
|
|
1175
|
+
} catch (e2) {
|
|
1176
|
+
return { bytes, redacted: 0, incomplete: false, decoded: false };
|
|
1177
|
+
}
|
|
1178
|
+
return _chunk5IMHJIAZcjs.redactWith.call(void 0, bytes, payloadStart, () => decodeMessage(bytes).ok);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1165
1181
|
|
|
1166
1182
|
|
|
1167
1183
|
|
|
@@ -1209,4 +1225,4 @@ function createDraft07Codec() {
|
|
|
1209
1225
|
|
|
1210
1226
|
|
|
1211
1227
|
|
|
1212
|
-
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_REQUEST = MSG_TRACK_STATUS_REQUEST; exports.MSG_TRACK_STATUS = MSG_TRACK_STATUS; exports.MSG_GOAWAY = MSG_GOAWAY; exports.MSG_SUBSCRIBE_ANNOUNCES = MSG_SUBSCRIBE_ANNOUNCES; exports.MSG_SUBSCRIBE_ANNOUNCES_OK = MSG_SUBSCRIBE_ANNOUNCES_OK; exports.MSG_SUBSCRIBE_ANNOUNCES_ERROR = MSG_SUBSCRIBE_ANNOUNCES_ERROR; exports.MSG_UNSUBSCRIBE_ANNOUNCES = MSG_UNSUBSCRIBE_ANNOUNCES; exports.MSG_MAX_SUBSCRIBE_ID = MSG_MAX_SUBSCRIBE_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_CLIENT_SETUP = MSG_CLIENT_SETUP; exports.MSG_SERVER_SETUP = MSG_SERVER_SETUP; exports.SETUP_PARAM_ROLE = SETUP_PARAM_ROLE; exports.SETUP_PARAM_PATH = SETUP_PARAM_PATH; exports.SETUP_PARAM_MAX_SUBSCRIBE_ID = SETUP_PARAM_MAX_SUBSCRIBE_ID; exports.PARAM_AUTHORIZATION_INFO = PARAM_AUTHORIZATION_INFO; exports.PARAM_DELIVERY_TIMEOUT = PARAM_DELIVERY_TIMEOUT; exports.PARAM_MAX_CACHE_DURATION = PARAM_MAX_CACHE_DURATION; exports.MSG_OBJECT_DATAGRAM = MSG_OBJECT_DATAGRAM; exports.MSG_STREAM_HEADER_SUBGROUP = MSG_STREAM_HEADER_SUBGROUP; exports.MSG_FETCH_HEADER = MSG_FETCH_HEADER; exports.MESSAGE_TYPE_MAP = MESSAGE_TYPE_MAP; exports.MESSAGE_ID_MAP = MESSAGE_ID_MAP; exports.encodeVarInt = encodeVarInt; exports.decodeVarInt = decodeVarInt; exports.encodeSubgroupStream = encodeSubgroupStream; exports.encodeDatagram = encodeDatagram; exports.encodeFetchStream = encodeFetchStream; exports.decodeSubgroupStream = decodeSubgroupStream; exports.decodeDatagram = decodeDatagram; exports.decodeFetchStream = decodeFetchStream; exports.createDraft07Codec = createDraft07Codec;
|
|
1228
|
+
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_REQUEST = MSG_TRACK_STATUS_REQUEST; exports.MSG_TRACK_STATUS = MSG_TRACK_STATUS; exports.MSG_GOAWAY = MSG_GOAWAY; exports.MSG_SUBSCRIBE_ANNOUNCES = MSG_SUBSCRIBE_ANNOUNCES; exports.MSG_SUBSCRIBE_ANNOUNCES_OK = MSG_SUBSCRIBE_ANNOUNCES_OK; exports.MSG_SUBSCRIBE_ANNOUNCES_ERROR = MSG_SUBSCRIBE_ANNOUNCES_ERROR; exports.MSG_UNSUBSCRIBE_ANNOUNCES = MSG_UNSUBSCRIBE_ANNOUNCES; exports.MSG_MAX_SUBSCRIBE_ID = MSG_MAX_SUBSCRIBE_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_CLIENT_SETUP = MSG_CLIENT_SETUP; exports.MSG_SERVER_SETUP = MSG_SERVER_SETUP; exports.SETUP_PARAM_ROLE = SETUP_PARAM_ROLE; exports.SETUP_PARAM_PATH = SETUP_PARAM_PATH; exports.SETUP_PARAM_MAX_SUBSCRIBE_ID = SETUP_PARAM_MAX_SUBSCRIBE_ID; exports.PARAM_AUTHORIZATION_INFO = PARAM_AUTHORIZATION_INFO; exports.PARAM_DELIVERY_TIMEOUT = PARAM_DELIVERY_TIMEOUT; exports.PARAM_MAX_CACHE_DURATION = PARAM_MAX_CACHE_DURATION; exports.MSG_OBJECT_DATAGRAM = MSG_OBJECT_DATAGRAM; exports.MSG_STREAM_HEADER_SUBGROUP = MSG_STREAM_HEADER_SUBGROUP; exports.MSG_FETCH_HEADER = MSG_FETCH_HEADER; exports.MESSAGE_TYPE_MAP = MESSAGE_TYPE_MAP; exports.MESSAGE_ID_MAP = MESSAGE_ID_MAP; exports.encodeVarInt = encodeVarInt; exports.decodeVarInt = decodeVarInt; exports.encodeSubgroupStream = encodeSubgroupStream; exports.encodeDatagram = encodeDatagram; exports.encodeFetchStream = encodeFetchStream; exports.decodeSubgroupStream = decodeSubgroupStream; exports.decodeDatagram = decodeDatagram; exports.decodeFetchStream = decodeFetchStream; exports.createDraft07Codec = createDraft07Codec; exports.redactAuthTokens = redactAuthTokens;
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk5IMHJIAZcjs = require('./chunk-5IMHJIAZ.cjs');
|
|
8
10
|
|
|
9
11
|
// src/drafts/draft10/data-streams.ts
|
|
10
12
|
var SUBGROUP_STREAM_TYPE = 0x04n;
|
|
@@ -12,7 +14,7 @@ var DATAGRAM_TYPE = 0x01n;
|
|
|
12
14
|
var DATAGRAM_STATUS_TYPE = 0x02n;
|
|
13
15
|
var FETCH_STREAM_TYPE = 0x05n;
|
|
14
16
|
function encodeSubgroupStream(stream) {
|
|
15
|
-
const w = new (0,
|
|
17
|
+
const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
16
18
|
w.writeVarInt(SUBGROUP_STREAM_TYPE);
|
|
17
19
|
w.writeVarInt(stream.trackAlias);
|
|
18
20
|
w.writeVarInt(stream.groupId);
|
|
@@ -32,7 +34,7 @@ function encodeSubgroupStream(stream) {
|
|
|
32
34
|
return w.finish();
|
|
33
35
|
}
|
|
34
36
|
function encodeDatagram(dg) {
|
|
35
|
-
const w = new (0,
|
|
37
|
+
const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
36
38
|
w.writeVarInt(DATAGRAM_TYPE);
|
|
37
39
|
w.writeVarInt(dg.trackAlias);
|
|
38
40
|
w.writeVarInt(dg.groupId);
|
|
@@ -44,7 +46,7 @@ function encodeDatagram(dg) {
|
|
|
44
46
|
return w.finish();
|
|
45
47
|
}
|
|
46
48
|
function encodeDatagramStatus(dg) {
|
|
47
|
-
const w = new (0,
|
|
49
|
+
const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
48
50
|
w.writeVarInt(DATAGRAM_STATUS_TYPE);
|
|
49
51
|
w.writeVarInt(dg.trackAlias);
|
|
50
52
|
w.writeVarInt(dg.groupId);
|
|
@@ -56,7 +58,7 @@ function encodeDatagramStatus(dg) {
|
|
|
56
58
|
return w.finish();
|
|
57
59
|
}
|
|
58
60
|
function encodeFetchStream(stream) {
|
|
59
|
-
const w = new (0,
|
|
61
|
+
const w = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
60
62
|
w.writeVarInt(FETCH_STREAM_TYPE);
|
|
61
63
|
w.writeVarInt(stream.subscribeId);
|
|
62
64
|
for (const obj of stream.objects) {
|
|
@@ -77,12 +79,12 @@ function encodeFetchStream(stream) {
|
|
|
77
79
|
}
|
|
78
80
|
function decodeSubgroupStream(bytes) {
|
|
79
81
|
try {
|
|
80
|
-
const r = new (0,
|
|
82
|
+
const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
81
83
|
const streamType = Number(r.readVarInt());
|
|
82
84
|
if (streamType !== 4) {
|
|
83
85
|
return {
|
|
84
86
|
ok: false,
|
|
85
|
-
error: new (0,
|
|
87
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
86
88
|
"CONSTRAINT_VIOLATION",
|
|
87
89
|
`Expected subgroup type 0x04, got 0x${streamType.toString(16)}`,
|
|
88
90
|
0
|
|
@@ -138,18 +140,18 @@ function decodeSubgroupStream(bytes) {
|
|
|
138
140
|
bytesRead: r.offset
|
|
139
141
|
};
|
|
140
142
|
} catch (e) {
|
|
141
|
-
if (e instanceof
|
|
143
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
142
144
|
throw e;
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
function decodeDatagram(bytes) {
|
|
146
148
|
try {
|
|
147
|
-
const r = new (0,
|
|
149
|
+
const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
148
150
|
const streamType = Number(r.readVarInt());
|
|
149
151
|
if (streamType !== 1) {
|
|
150
152
|
return {
|
|
151
153
|
ok: false,
|
|
152
|
-
error: new (0,
|
|
154
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
153
155
|
"CONSTRAINT_VIOLATION",
|
|
154
156
|
`Expected datagram type 0x01, got 0x${streamType.toString(16)}`,
|
|
155
157
|
0
|
|
@@ -179,18 +181,18 @@ function decodeDatagram(bytes) {
|
|
|
179
181
|
bytesRead: r.offset
|
|
180
182
|
};
|
|
181
183
|
} catch (e) {
|
|
182
|
-
if (e instanceof
|
|
184
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
183
185
|
throw e;
|
|
184
186
|
}
|
|
185
187
|
}
|
|
186
188
|
function decodeDatagramStatus(bytes) {
|
|
187
189
|
try {
|
|
188
|
-
const r = new (0,
|
|
190
|
+
const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
189
191
|
const streamType = Number(r.readVarInt());
|
|
190
192
|
if (streamType !== 2) {
|
|
191
193
|
return {
|
|
192
194
|
ok: false,
|
|
193
|
-
error: new (0,
|
|
195
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
194
196
|
"CONSTRAINT_VIOLATION",
|
|
195
197
|
`Expected datagram_status type 0x02, got 0x${streamType.toString(16)}`,
|
|
196
198
|
0
|
|
@@ -220,18 +222,18 @@ function decodeDatagramStatus(bytes) {
|
|
|
220
222
|
bytesRead: r.offset
|
|
221
223
|
};
|
|
222
224
|
} catch (e) {
|
|
223
|
-
if (e instanceof
|
|
225
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
224
226
|
throw e;
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
229
|
function decodeFetchStream(bytes) {
|
|
228
230
|
try {
|
|
229
|
-
const r = new (0,
|
|
231
|
+
const r = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
230
232
|
const streamType = r.readVarInt();
|
|
231
233
|
if (streamType !== FETCH_STREAM_TYPE) {
|
|
232
234
|
return {
|
|
233
235
|
ok: false,
|
|
234
|
-
error: new (0,
|
|
236
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
235
237
|
"CONSTRAINT_VIOLATION",
|
|
236
238
|
`Expected fetch type 0x05, got 0x${streamType.toString(16)}`,
|
|
237
239
|
0
|
|
@@ -282,7 +284,7 @@ function decodeFetchStream(bytes) {
|
|
|
282
284
|
bytesRead: r.offset
|
|
283
285
|
};
|
|
284
286
|
} catch (e) {
|
|
285
|
-
if (e instanceof
|
|
287
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
286
288
|
throw e;
|
|
287
289
|
}
|
|
288
290
|
}
|
|
@@ -384,7 +386,7 @@ function encodeSetupParams(params, w) {
|
|
|
384
386
|
}
|
|
385
387
|
if (params.max_subscribe_id !== void 0) {
|
|
386
388
|
w.writeVarInt(SETUP_PARAM_MAX_SUBSCRIBE_ID);
|
|
387
|
-
const tmpW = new (0,
|
|
389
|
+
const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
|
|
388
390
|
tmpW.writeVarInt(params.max_subscribe_id);
|
|
389
391
|
const raw = tmpW.finish();
|
|
390
392
|
w.writeVarInt(raw.byteLength);
|
|
@@ -393,7 +395,7 @@ function encodeSetupParams(params, w) {
|
|
|
393
395
|
if (params.unknown) {
|
|
394
396
|
for (const u of params.unknown) {
|
|
395
397
|
w.writeVarInt(BigInt(u.id));
|
|
396
|
-
const raw =
|
|
398
|
+
const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
397
399
|
w.writeVarInt(raw.byteLength);
|
|
398
400
|
w.writeBytes(raw);
|
|
399
401
|
}
|
|
@@ -411,14 +413,14 @@ function decodeSetupParams(r) {
|
|
|
411
413
|
result.path = textDecoder.decode(bytes);
|
|
412
414
|
} else if (paramType === SETUP_PARAM_MAX_SUBSCRIBE_ID) {
|
|
413
415
|
const blob = r.readBytes(length);
|
|
414
|
-
const tmpReader = new (0,
|
|
416
|
+
const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(blob);
|
|
415
417
|
result.max_subscribe_id = tmpReader.readVarInt();
|
|
416
418
|
} else {
|
|
417
419
|
const bytes = r.readBytes(length);
|
|
418
420
|
unknown.push({
|
|
419
421
|
id: `0x${paramType.toString(16)}`,
|
|
420
422
|
length,
|
|
421
|
-
raw_hex:
|
|
423
|
+
raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, bytes)
|
|
422
424
|
});
|
|
423
425
|
}
|
|
424
426
|
}
|
|
@@ -439,7 +441,7 @@ function encodeParams(params, w) {
|
|
|
439
441
|
}
|
|
440
442
|
if (params.delivery_timeout !== void 0) {
|
|
441
443
|
w.writeVarInt(PARAM_DELIVERY_TIMEOUT);
|
|
442
|
-
const tmpW = new (0,
|
|
444
|
+
const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
|
|
443
445
|
tmpW.writeVarInt(params.delivery_timeout);
|
|
444
446
|
const raw = tmpW.finish();
|
|
445
447
|
w.writeVarInt(raw.byteLength);
|
|
@@ -447,7 +449,7 @@ function encodeParams(params, w) {
|
|
|
447
449
|
}
|
|
448
450
|
if (params.max_cache_duration !== void 0) {
|
|
449
451
|
w.writeVarInt(PARAM_MAX_CACHE_DURATION);
|
|
450
|
-
const tmpW = new (0,
|
|
452
|
+
const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
|
|
451
453
|
tmpW.writeVarInt(params.max_cache_duration);
|
|
452
454
|
const raw = tmpW.finish();
|
|
453
455
|
w.writeVarInt(raw.byteLength);
|
|
@@ -456,7 +458,7 @@ function encodeParams(params, w) {
|
|
|
456
458
|
if (params.unknown) {
|
|
457
459
|
for (const u of params.unknown) {
|
|
458
460
|
w.writeVarInt(BigInt(u.id));
|
|
459
|
-
const raw =
|
|
461
|
+
const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
460
462
|
w.writeVarInt(raw.byteLength);
|
|
461
463
|
w.writeBytes(raw);
|
|
462
464
|
}
|
|
@@ -471,21 +473,22 @@ function decodeParams(r) {
|
|
|
471
473
|
const length = Number(r.readVarInt());
|
|
472
474
|
if (paramType === PARAM_AUTHORIZATION_INFO) {
|
|
473
475
|
const bytes = r.readBytes(length);
|
|
476
|
+
_chunk5IMHJIAZcjs.recordAuthValueSpan.call(void 0, r.offset - length, length);
|
|
474
477
|
result.authorization_info = textDecoder.decode(bytes);
|
|
475
478
|
} else if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
476
479
|
const blob = r.readBytes(length);
|
|
477
|
-
const tmpReader = new (0,
|
|
480
|
+
const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(blob);
|
|
478
481
|
result.delivery_timeout = tmpReader.readVarInt();
|
|
479
482
|
} else if (paramType === PARAM_MAX_CACHE_DURATION) {
|
|
480
483
|
const blob = r.readBytes(length);
|
|
481
|
-
const tmpReader = new (0,
|
|
484
|
+
const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(blob);
|
|
482
485
|
result.max_cache_duration = tmpReader.readVarInt();
|
|
483
486
|
} else {
|
|
484
487
|
const bytes = r.readBytes(length);
|
|
485
488
|
unknown.push({
|
|
486
489
|
id: `0x${paramType.toString(16)}`,
|
|
487
490
|
length,
|
|
488
|
-
raw_hex:
|
|
491
|
+
raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, bytes)
|
|
489
492
|
});
|
|
490
493
|
}
|
|
491
494
|
}
|
|
@@ -646,7 +649,7 @@ function encodeSubscribesBlockedPayload(msg, w) {
|
|
|
646
649
|
function decodeClientSetupPayload(r) {
|
|
647
650
|
const numVersions = Number(r.readVarInt());
|
|
648
651
|
if (numVersions === 0) {
|
|
649
|
-
throw new (0,
|
|
652
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", "supported_versions must not be empty", r.offset);
|
|
650
653
|
}
|
|
651
654
|
const supported_versions = [];
|
|
652
655
|
for (let i = 0; i < numVersions; i++) supported_versions.push(r.readVarInt());
|
|
@@ -668,7 +671,7 @@ function decodeSubscribePayload(r) {
|
|
|
668
671
|
const filter_type = r.readVarInt();
|
|
669
672
|
const ft = Number(filter_type);
|
|
670
673
|
if (ft < 2 || ft > 4) {
|
|
671
|
-
throw new (0,
|
|
674
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid filter_type: ${ft}`, r.offset);
|
|
672
675
|
}
|
|
673
676
|
let start_group;
|
|
674
677
|
let start_object;
|
|
@@ -824,7 +827,7 @@ function decodeFetchPayload(r) {
|
|
|
824
827
|
const fetch_type = r.readVarInt();
|
|
825
828
|
const ft = Number(fetch_type);
|
|
826
829
|
if (ft < 1 || ft > 2) {
|
|
827
|
-
throw new (0,
|
|
830
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${ft}`, r.offset);
|
|
828
831
|
}
|
|
829
832
|
let standalone;
|
|
830
833
|
let joining;
|
|
@@ -950,10 +953,10 @@ var payloadDecoders = /* @__PURE__ */ new Map([
|
|
|
950
953
|
function encodeMessage(message) {
|
|
951
954
|
const typeId = MESSAGE_ID_MAP.get(message.type);
|
|
952
955
|
if (typeId === void 0) throw new Error(`Unknown message type: ${message.type}`);
|
|
953
|
-
const payloadWriter = new (0,
|
|
956
|
+
const payloadWriter = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
954
957
|
encodePayload(message, payloadWriter);
|
|
955
958
|
const payload = payloadWriter.finishView();
|
|
956
|
-
const writer = new (0,
|
|
959
|
+
const writer = new (0, _chunk5IMHJIAZcjs.BufferWriter)(payload.byteLength + 16);
|
|
957
960
|
writer.writeVarInt(typeId);
|
|
958
961
|
writer.writeVarInt(payload.byteLength);
|
|
959
962
|
writer.writeBytes(payload);
|
|
@@ -1021,16 +1024,16 @@ function encodePayload(msg, w) {
|
|
|
1021
1024
|
}
|
|
1022
1025
|
function decodeMessage(bytes) {
|
|
1023
1026
|
try {
|
|
1024
|
-
const reader = new (0,
|
|
1027
|
+
const reader = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
1025
1028
|
const typeId = reader.readVarInt();
|
|
1026
1029
|
const payloadLength = Number(reader.readVarInt());
|
|
1027
1030
|
const payloadBytes = reader.readBytes(payloadLength);
|
|
1028
|
-
const payloadReader = new (0,
|
|
1031
|
+
const payloadReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(payloadBytes);
|
|
1029
1032
|
const decoder = payloadDecoders.get(typeId);
|
|
1030
1033
|
if (!decoder) {
|
|
1031
1034
|
return {
|
|
1032
1035
|
ok: false,
|
|
1033
|
-
error: new (0,
|
|
1036
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
1034
1037
|
"UNKNOWN_MESSAGE_TYPE",
|
|
1035
1038
|
`Unknown message type ID: 0x${typeId.toString(16)}`,
|
|
1036
1039
|
0
|
|
@@ -1040,7 +1043,7 @@ function decodeMessage(bytes) {
|
|
|
1040
1043
|
const message = decoder(payloadReader);
|
|
1041
1044
|
return { ok: true, value: message, bytesRead: reader.offset };
|
|
1042
1045
|
} catch (e) {
|
|
1043
|
-
if (e instanceof
|
|
1046
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
1044
1047
|
throw e;
|
|
1045
1048
|
}
|
|
1046
1049
|
}
|
|
@@ -1070,7 +1073,7 @@ function createStreamDecoder() {
|
|
|
1070
1073
|
},
|
|
1071
1074
|
flush(controller) {
|
|
1072
1075
|
if (offset < buffer.length)
|
|
1073
|
-
controller.error(new (0,
|
|
1076
|
+
controller.error(new (0, _chunk5IMHJIAZcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
1074
1077
|
}
|
|
1075
1078
|
});
|
|
1076
1079
|
}
|
|
@@ -1091,6 +1094,19 @@ function createDraft10Codec() {
|
|
|
1091
1094
|
createStreamDecoder
|
|
1092
1095
|
};
|
|
1093
1096
|
}
|
|
1097
|
+
function redactAuthTokens(bytes) {
|
|
1098
|
+
let payloadStart;
|
|
1099
|
+
try {
|
|
1100
|
+
const probe = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
1101
|
+
probe.readVarInt();
|
|
1102
|
+
probe.readVarInt();
|
|
1103
|
+
payloadStart = probe.offset;
|
|
1104
|
+
} catch (e2) {
|
|
1105
|
+
return { bytes, redacted: 0, incomplete: false, decoded: false };
|
|
1106
|
+
}
|
|
1107
|
+
return _chunk5IMHJIAZcjs.redactWith.call(void 0, bytes, payloadStart, () => decodeMessage(bytes).ok);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1094
1110
|
|
|
1095
1111
|
|
|
1096
1112
|
|
|
@@ -1139,4 +1155,4 @@ function createDraft10Codec() {
|
|
|
1139
1155
|
|
|
1140
1156
|
|
|
1141
1157
|
|
|
1142
|
-
exports.encodeSubgroupStream = encodeSubgroupStream; exports.encodeDatagram = encodeDatagram; exports.encodeDatagramStatus = encodeDatagramStatus; exports.encodeFetchStream = encodeFetchStream; exports.decodeSubgroupStream = decodeSubgroupStream; exports.decodeDatagram = decodeDatagram; exports.decodeDatagramStatus = decodeDatagramStatus; 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_REQUEST = MSG_TRACK_STATUS_REQUEST; exports.MSG_TRACK_STATUS = MSG_TRACK_STATUS; exports.MSG_GOAWAY = MSG_GOAWAY; exports.MSG_SUBSCRIBE_ANNOUNCES = MSG_SUBSCRIBE_ANNOUNCES; exports.MSG_SUBSCRIBE_ANNOUNCES_OK = MSG_SUBSCRIBE_ANNOUNCES_OK; exports.MSG_SUBSCRIBE_ANNOUNCES_ERROR = MSG_SUBSCRIBE_ANNOUNCES_ERROR; exports.MSG_UNSUBSCRIBE_ANNOUNCES = MSG_UNSUBSCRIBE_ANNOUNCES; exports.MSG_MAX_SUBSCRIBE_ID = MSG_MAX_SUBSCRIBE_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_SUBSCRIBES_BLOCKED = MSG_SUBSCRIBES_BLOCKED; 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_SUBSCRIBE_ID = SETUP_PARAM_MAX_SUBSCRIBE_ID; exports.PARAM_AUTHORIZATION_INFO = PARAM_AUTHORIZATION_INFO; exports.PARAM_DELIVERY_TIMEOUT = PARAM_DELIVERY_TIMEOUT; exports.PARAM_MAX_CACHE_DURATION = PARAM_MAX_CACHE_DURATION; exports.MESSAGE_TYPE_MAP = MESSAGE_TYPE_MAP; exports.MESSAGE_ID_MAP = MESSAGE_ID_MAP; exports.encodeMessage = encodeMessage; exports.decodeMessage = decodeMessage; exports.createStreamDecoder = createStreamDecoder; exports.createDraft10Codec = createDraft10Codec;
|
|
1158
|
+
exports.encodeSubgroupStream = encodeSubgroupStream; exports.encodeDatagram = encodeDatagram; exports.encodeDatagramStatus = encodeDatagramStatus; exports.encodeFetchStream = encodeFetchStream; exports.decodeSubgroupStream = decodeSubgroupStream; exports.decodeDatagram = decodeDatagram; exports.decodeDatagramStatus = decodeDatagramStatus; 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_REQUEST = MSG_TRACK_STATUS_REQUEST; exports.MSG_TRACK_STATUS = MSG_TRACK_STATUS; exports.MSG_GOAWAY = MSG_GOAWAY; exports.MSG_SUBSCRIBE_ANNOUNCES = MSG_SUBSCRIBE_ANNOUNCES; exports.MSG_SUBSCRIBE_ANNOUNCES_OK = MSG_SUBSCRIBE_ANNOUNCES_OK; exports.MSG_SUBSCRIBE_ANNOUNCES_ERROR = MSG_SUBSCRIBE_ANNOUNCES_ERROR; exports.MSG_UNSUBSCRIBE_ANNOUNCES = MSG_UNSUBSCRIBE_ANNOUNCES; exports.MSG_MAX_SUBSCRIBE_ID = MSG_MAX_SUBSCRIBE_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_SUBSCRIBES_BLOCKED = MSG_SUBSCRIBES_BLOCKED; 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_SUBSCRIBE_ID = SETUP_PARAM_MAX_SUBSCRIBE_ID; exports.PARAM_AUTHORIZATION_INFO = PARAM_AUTHORIZATION_INFO; exports.PARAM_DELIVERY_TIMEOUT = PARAM_DELIVERY_TIMEOUT; exports.PARAM_MAX_CACHE_DURATION = PARAM_MAX_CACHE_DURATION; exports.MESSAGE_TYPE_MAP = MESSAGE_TYPE_MAP; exports.MESSAGE_ID_MAP = MESSAGE_ID_MAP; exports.encodeMessage = encodeMessage; exports.decodeMessage = decodeMessage; exports.createStreamDecoder = createStreamDecoder; exports.createDraft10Codec = createDraft10Codec; exports.redactAuthTokens = redactAuthTokens;
|