@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,12 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
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,
|
|
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) {
|
|
@@ -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 =
|
|
442
|
-
const tmpReader = new (0,
|
|
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 =
|
|
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,
|
|
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:
|
|
473
|
+
raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, raw)
|
|
472
474
|
});
|
|
473
475
|
}
|
|
474
476
|
} else {
|
|
@@ -477,16 +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
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
];
|
|
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];
|
|
484
486
|
} else {
|
|
485
487
|
const bytes = r.readBytes(length);
|
|
486
488
|
unknown.push({
|
|
487
489
|
id: `0x${paramType.toString(16)}`,
|
|
488
490
|
length,
|
|
489
|
-
raw_hex:
|
|
491
|
+
raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, bytes)
|
|
490
492
|
});
|
|
491
493
|
}
|
|
492
494
|
}
|
|
@@ -517,11 +519,11 @@ function encodeParams(params, w) {
|
|
|
517
519
|
const id = BigInt(u.id);
|
|
518
520
|
w.writeVarInt(id);
|
|
519
521
|
if (id % 2n === 0n) {
|
|
520
|
-
const raw =
|
|
521
|
-
const tmpReader = new (0,
|
|
522
|
+
const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
523
|
+
const tmpReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(raw);
|
|
522
524
|
w.writeVarInt(tmpReader.readVarInt());
|
|
523
525
|
} else {
|
|
524
|
-
const raw =
|
|
526
|
+
const raw = _chunk5IMHJIAZcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
525
527
|
w.writeVarInt(raw.byteLength);
|
|
526
528
|
w.writeBytes(raw);
|
|
527
529
|
}
|
|
@@ -541,28 +543,28 @@ function decodeParams(r) {
|
|
|
541
543
|
} else if (paramType === PARAM_MAX_CACHE_DURATION) {
|
|
542
544
|
result.max_cache_duration = value;
|
|
543
545
|
} else {
|
|
544
|
-
const tmpW = new (0,
|
|
546
|
+
const tmpW = new (0, _chunk5IMHJIAZcjs.BufferWriter)(16);
|
|
545
547
|
tmpW.writeVarInt(value);
|
|
546
548
|
const raw = tmpW.finish();
|
|
547
549
|
unknown.push({
|
|
548
550
|
id: `0x${paramType.toString(16)}`,
|
|
549
551
|
length: raw.byteLength,
|
|
550
|
-
raw_hex:
|
|
552
|
+
raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, raw)
|
|
551
553
|
});
|
|
552
554
|
}
|
|
553
555
|
} else {
|
|
554
556
|
const length = Number(r.readVarInt());
|
|
555
557
|
if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
];
|
|
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];
|
|
560
562
|
} else {
|
|
561
563
|
const bytes = r.readBytes(length);
|
|
562
564
|
unknown.push({
|
|
563
565
|
id: `0x${paramType.toString(16)}`,
|
|
564
566
|
length,
|
|
565
|
-
raw_hex:
|
|
567
|
+
raw_hex: _chunk5IMHJIAZcjs.bytesToHex.call(void 0, bytes)
|
|
566
568
|
});
|
|
567
569
|
}
|
|
568
570
|
}
|
|
@@ -786,7 +788,7 @@ function encodeRequestsBlockedPayload(msg, w) {
|
|
|
786
788
|
function decodeClientSetupPayload(r) {
|
|
787
789
|
const numVersions = Number(r.readVarInt());
|
|
788
790
|
if (numVersions === 0) {
|
|
789
|
-
throw new (0,
|
|
791
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", "supported_versions must not be empty", r.offset);
|
|
790
792
|
}
|
|
791
793
|
const supported_versions = [];
|
|
792
794
|
for (let i = 0; i < numVersions; i++) supported_versions.push(r.readVarInt());
|
|
@@ -808,7 +810,7 @@ function decodeSubscribePayload(r) {
|
|
|
808
810
|
const filter_type = r.readVarInt();
|
|
809
811
|
const ft = Number(filter_type);
|
|
810
812
|
if (ft < 1 || ft > 4) {
|
|
811
|
-
throw new (0,
|
|
813
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid filter_type: ${ft}`, r.offset);
|
|
812
814
|
}
|
|
813
815
|
let start_group;
|
|
814
816
|
let start_object;
|
|
@@ -1034,7 +1036,7 @@ function decodeFetchPayload(r) {
|
|
|
1034
1036
|
const fetch_type = r.readVarInt();
|
|
1035
1037
|
const ft = Number(fetch_type);
|
|
1036
1038
|
if (ft < 1 || ft > 3) {
|
|
1037
|
-
throw new (0,
|
|
1039
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid fetch_type: ${ft}`, r.offset);
|
|
1038
1040
|
}
|
|
1039
1041
|
let standalone;
|
|
1040
1042
|
let joining;
|
|
@@ -1106,7 +1108,7 @@ function decodeTrackStatusPayload(r) {
|
|
|
1106
1108
|
const filter_type = r.readVarInt();
|
|
1107
1109
|
const ft = Number(filter_type);
|
|
1108
1110
|
if (ft < 1 || ft > 4) {
|
|
1109
|
-
throw new (0,
|
|
1111
|
+
throw new (0, _chunk5IMHJIAZcjs.DecodeError)("CONSTRAINT_VIOLATION", `Invalid filter_type: ${ft}`, r.offset);
|
|
1110
1112
|
}
|
|
1111
1113
|
let start_group;
|
|
1112
1114
|
let start_object;
|
|
@@ -1213,10 +1215,10 @@ var payloadDecoders = /* @__PURE__ */ new Map([
|
|
|
1213
1215
|
function encodeMessage(message) {
|
|
1214
1216
|
const typeId = MESSAGE_ID_MAP.get(message.type);
|
|
1215
1217
|
if (typeId === void 0) throw new Error(`Unknown message type: ${message.type}`);
|
|
1216
|
-
const payloadWriter = new (0,
|
|
1218
|
+
const payloadWriter = new (0, _chunk5IMHJIAZcjs.BufferWriter)();
|
|
1217
1219
|
encodePayload(message, payloadWriter);
|
|
1218
1220
|
const payload = payloadWriter.finishView();
|
|
1219
|
-
const writer = new (0,
|
|
1221
|
+
const writer = new (0, _chunk5IMHJIAZcjs.BufferWriter)(payload.byteLength + 16);
|
|
1220
1222
|
writer.writeVarInt(typeId);
|
|
1221
1223
|
if (payload.byteLength > 65535) {
|
|
1222
1224
|
throw new Error(`Payload too large for 16-bit length: ${payload.byteLength}`);
|
|
@@ -1296,18 +1298,18 @@ function encodePayload(msg, w) {
|
|
|
1296
1298
|
}
|
|
1297
1299
|
function decodeMessage(bytes) {
|
|
1298
1300
|
try {
|
|
1299
|
-
const reader = new (0,
|
|
1301
|
+
const reader = new (0, _chunk5IMHJIAZcjs.BufferReader)(bytes);
|
|
1300
1302
|
const typeId = reader.readVarInt();
|
|
1301
1303
|
const lenHi = reader.readUint8();
|
|
1302
1304
|
const lenLo = reader.readUint8();
|
|
1303
1305
|
const payloadLength = lenHi << 8 | lenLo;
|
|
1304
1306
|
const payloadBytes = reader.readBytes(payloadLength);
|
|
1305
|
-
const payloadReader = new (0,
|
|
1307
|
+
const payloadReader = new (0, _chunk5IMHJIAZcjs.BufferReader)(payloadBytes);
|
|
1306
1308
|
const decoder = payloadDecoders.get(typeId);
|
|
1307
1309
|
if (!decoder) {
|
|
1308
1310
|
return {
|
|
1309
1311
|
ok: false,
|
|
1310
|
-
error: new (0,
|
|
1312
|
+
error: new (0, _chunk5IMHJIAZcjs.DecodeError)(
|
|
1311
1313
|
"UNKNOWN_MESSAGE_TYPE",
|
|
1312
1314
|
`Unknown message type ID: 0x${typeId.toString(16)}`,
|
|
1313
1315
|
0
|
|
@@ -1317,7 +1319,7 @@ function decodeMessage(bytes) {
|
|
|
1317
1319
|
const message = decoder(payloadReader);
|
|
1318
1320
|
return { ok: true, value: message, bytesRead: reader.offset };
|
|
1319
1321
|
} catch (e) {
|
|
1320
|
-
if (e instanceof
|
|
1322
|
+
if (e instanceof _chunk5IMHJIAZcjs.DecodeError) return { ok: false, error: e };
|
|
1321
1323
|
throw e;
|
|
1322
1324
|
}
|
|
1323
1325
|
}
|
|
@@ -1347,7 +1349,7 @@ function createStreamDecoder() {
|
|
|
1347
1349
|
},
|
|
1348
1350
|
flush(controller) {
|
|
1349
1351
|
if (offset < buffer.length)
|
|
1350
|
-
controller.error(new (0,
|
|
1352
|
+
controller.error(new (0, _chunk5IMHJIAZcjs.DecodeError)("UNEXPECTED_END", "Stream ended with incomplete data", 0));
|
|
1351
1353
|
}
|
|
1352
1354
|
});
|
|
1353
1355
|
}
|
|
@@ -1366,6 +1368,24 @@ function createDraft13Codec() {
|
|
|
1366
1368
|
createStreamDecoder
|
|
1367
1369
|
};
|
|
1368
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
|
+
|
|
1369
1389
|
|
|
1370
1390
|
|
|
1371
1391
|
|
|
@@ -1416,4 +1436,4 @@ function createDraft13Codec() {
|
|
|
1416
1436
|
|
|
1417
1437
|
|
|
1418
1438
|
|
|
1419
|
-
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
|
-
|
|
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;
|
|
@@ -447,6 +449,7 @@ 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);
|
|
452
|
+
noteAuthTokenValue(startOff, length, tokenBytes);
|
|
450
453
|
result.authorization_token = [
|
|
451
454
|
...result.authorization_token ?? [],
|
|
452
455
|
{
|
|
@@ -539,6 +542,7 @@ function decodeParams(r) {
|
|
|
539
542
|
const token_type = r.readVarInt();
|
|
540
543
|
const tokenBytesLen = length - (r.offset - startOff);
|
|
541
544
|
const tokenBytes = r.readBytes(tokenBytesLen);
|
|
545
|
+
noteAuthTokenValue(startOff, length, tokenBytes);
|
|
542
546
|
result.authorization_token = [
|
|
543
547
|
...result.authorization_token ?? [],
|
|
544
548
|
{
|
|
@@ -1288,6 +1292,23 @@ function createDraft12Codec() {
|
|
|
1288
1292
|
createStreamDecoder
|
|
1289
1293
|
};
|
|
1290
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
|
+
}
|
|
1291
1312
|
|
|
1292
1313
|
export {
|
|
1293
1314
|
encodeSubgroupStream,
|
|
@@ -1336,5 +1357,6 @@ export {
|
|
|
1336
1357
|
encodeMessage,
|
|
1337
1358
|
decodeMessage,
|
|
1338
1359
|
createStreamDecoder,
|
|
1339
|
-
createDraft12Codec
|
|
1360
|
+
createDraft12Codec,
|
|
1361
|
+
redactAuthTokens
|
|
1340
1362
|
};
|