@moqtap/codec 0.8.0 → 0.8.1
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/dist/{chunk-5XZKO2U5.js → chunk-2XH6PHXR.js} +62 -51
- package/dist/{chunk-APTV6F72.js → chunk-3YAR3I3S.js} +67 -51
- package/dist/{chunk-BQHLUT37.cjs → chunk-7ENEWAMZ.cjs} +2 -6
- package/dist/{chunk-MD2OA7SE.js → chunk-BV6MITLO.js} +15 -8
- package/dist/{chunk-B56AG5HU.cjs → chunk-EVCPBFSR.cjs} +6 -4
- package/dist/{chunk-KNLPX3YA.js → chunk-H6DTAIWM.js} +6 -4
- package/dist/{chunk-J3ASFPCX.cjs → chunk-IADVBKEJ.cjs} +15 -8
- package/dist/{chunk-I55J3KXD.js → chunk-NH4L6NIY.js} +48 -33
- package/dist/{chunk-EQAYMCXO.cjs → chunk-PU2KV7VP.cjs} +48 -33
- package/dist/{chunk-HEO2JG6C.js → chunk-TMXRYOBS.js} +100 -92
- package/dist/{chunk-IEJULBKB.cjs → chunk-UA5XFP4O.cjs} +100 -92
- package/dist/{chunk-KTVN4P6J.cjs → chunk-UZO5Z2XT.cjs} +62 -51
- package/dist/{chunk-MH7537FB.cjs → chunk-VWXUT5R2.cjs} +67 -51
- package/dist/{chunk-JJEN2VG5.js → chunk-XQGEOFGE.js} +2 -6
- package/dist/{codec-BnamSx7L.d.cts → codec-N3g1lxQQ.d.cts} +1 -1
- package/dist/{codec-CFhUGTu2.d.ts → codec-v6Vloc7H.d.ts} +1 -1
- package/dist/draft12.cjs +2 -2
- package/dist/draft12.js +1 -1
- package/dist/draft14-session.d.cts +1 -1
- package/dist/draft14-session.d.ts +1 -1
- package/dist/draft14.cjs +2 -2
- package/dist/draft14.d.cts +3 -3
- package/dist/draft14.d.ts +3 -3
- package/dist/draft14.js +1 -1
- package/dist/draft15.cjs +2 -2
- package/dist/draft15.js +1 -1
- package/dist/draft16.cjs +2 -2
- package/dist/draft16.js +1 -1
- package/dist/draft17.cjs +2 -2
- package/dist/draft17.js +1 -1
- package/dist/draft18.cjs +2 -2
- package/dist/draft18.js +1 -1
- package/dist/draft19.cjs +2 -2
- package/dist/draft19.js +1 -1
- package/dist/index.cjs +14 -14
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/session.d.cts +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/{types-CVeKIk7A.d.cts → types-HI_bbXka.d.cts} +0 -2
- package/dist/{types-CVeKIk7A.d.ts → types-HI_bbXka.d.ts} +0 -2
- package/package.json +2 -2
- package/src/drafts/draft12/data-streams.ts +13 -4
- package/src/drafts/draft14/codec.ts +2 -6
- package/src/drafts/draft14/types.ts +0 -2
- package/src/drafts/draft15/data-streams.ts +30 -16
- package/src/drafts/draft16/codec.ts +116 -93
- package/src/drafts/draft17/codec.ts +72 -35
- package/src/drafts/draft18/codec.ts +89 -53
- package/src/drafts/draft19/codec.ts +94 -53
|
@@ -987,112 +987,135 @@ function decodeTrackExtensions(reader) {
|
|
|
987
987
|
return result;
|
|
988
988
|
}
|
|
989
989
|
function encodeParams(params, writer) {
|
|
990
|
-
|
|
991
|
-
if (params.delivery_timeout !== void 0) count++;
|
|
992
|
-
if (params.authorization_token !== void 0) count++;
|
|
993
|
-
if (params.max_cache_duration !== void 0) count++;
|
|
994
|
-
if (params.expires !== void 0) count++;
|
|
995
|
-
if (params.largest_object !== void 0) count++;
|
|
996
|
-
if (params.publisher_priority !== void 0) count++;
|
|
997
|
-
if (params.forward !== void 0) count++;
|
|
998
|
-
if (params.subscriber_priority !== void 0) count++;
|
|
999
|
-
if (params.subscription_filter !== void 0) count++;
|
|
1000
|
-
if (params.group_order !== void 0) count++;
|
|
1001
|
-
if (params.dynamic_groups !== void 0) count++;
|
|
1002
|
-
if (params.new_group_request !== void 0) count++;
|
|
1003
|
-
writer.writeVarInt(count);
|
|
990
|
+
const entries = [];
|
|
1004
991
|
if (params.delivery_timeout !== void 0) {
|
|
1005
|
-
|
|
1006
|
-
|
|
992
|
+
entries.push({
|
|
993
|
+
type: PARAM_DELIVERY_TIMEOUT,
|
|
994
|
+
encode: (w) => w.writeVarInt(params.delivery_timeout)
|
|
995
|
+
});
|
|
1007
996
|
}
|
|
1008
997
|
if (params.authorization_token !== void 0) {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
998
|
+
entries.push({
|
|
999
|
+
type: PARAM_AUTHORIZATION_TOKEN,
|
|
1000
|
+
encode: (w) => {
|
|
1001
|
+
const tmpW = new BufferWriter(64);
|
|
1002
|
+
encodeAuthorizationToken(params.authorization_token, tmpW);
|
|
1003
|
+
const raw = tmpW.finish();
|
|
1004
|
+
w.writeVarInt(raw.byteLength);
|
|
1005
|
+
w.writeBytes(raw);
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1015
1008
|
}
|
|
1016
1009
|
if (params.max_cache_duration !== void 0) {
|
|
1017
|
-
|
|
1018
|
-
|
|
1010
|
+
entries.push({
|
|
1011
|
+
type: PARAM_MAX_CACHE_DURATION,
|
|
1012
|
+
encode: (w) => w.writeVarInt(params.max_cache_duration)
|
|
1013
|
+
});
|
|
1019
1014
|
}
|
|
1020
1015
|
if (params.expires !== void 0) {
|
|
1021
|
-
|
|
1022
|
-
writer.writeVarInt(params.expires);
|
|
1016
|
+
entries.push({ type: PARAM_EXPIRES, encode: (w) => w.writeVarInt(params.expires) });
|
|
1023
1017
|
}
|
|
1024
1018
|
if (params.largest_object !== void 0) {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1019
|
+
entries.push({
|
|
1020
|
+
type: PARAM_LARGEST_OBJECT,
|
|
1021
|
+
// Draft-16 has no per-parameter value encoding: a Key-Value-Pair whose
|
|
1022
|
+
// Type is odd carries a Length, and 0x09 is odd. Drafts 17 and later
|
|
1023
|
+
// replaced that with "the encoding is specified by each parameter
|
|
1024
|
+
// definition", which is where the same field loses its length.
|
|
1025
|
+
encode: (w) => {
|
|
1026
|
+
const tmpW = new BufferWriter(16);
|
|
1027
|
+
tmpW.writeVarInt(params.largest_object.group);
|
|
1028
|
+
tmpW.writeVarInt(params.largest_object.object);
|
|
1029
|
+
const raw = tmpW.finish();
|
|
1030
|
+
w.writeVarInt(raw.byteLength);
|
|
1031
|
+
w.writeBytes(raw);
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1032
1034
|
}
|
|
1033
1035
|
if (params.publisher_priority !== void 0) {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
+
entries.push({
|
|
1037
|
+
type: PARAM_PUBLISHER_PRIORITY,
|
|
1038
|
+
encode: (w) => w.writeVarInt(params.publisher_priority)
|
|
1039
|
+
});
|
|
1036
1040
|
}
|
|
1037
1041
|
if (params.forward !== void 0) {
|
|
1038
|
-
|
|
1039
|
-
writer.writeVarInt(params.forward);
|
|
1042
|
+
entries.push({ type: PARAM_FORWARD, encode: (w) => w.writeVarInt(params.forward) });
|
|
1040
1043
|
}
|
|
1041
1044
|
if (params.subscriber_priority !== void 0) {
|
|
1042
|
-
|
|
1043
|
-
|
|
1045
|
+
entries.push({
|
|
1046
|
+
type: PARAM_SUBSCRIBER_PRIORITY,
|
|
1047
|
+
encode: (w) => w.writeVarInt(params.subscriber_priority)
|
|
1048
|
+
});
|
|
1044
1049
|
}
|
|
1045
1050
|
if (params.subscription_filter !== void 0) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1051
|
+
entries.push({
|
|
1052
|
+
type: PARAM_SUBSCRIPTION_FILTER,
|
|
1053
|
+
encode: (w) => {
|
|
1054
|
+
const tmpW = new BufferWriter(32);
|
|
1055
|
+
const f = params.subscription_filter;
|
|
1056
|
+
tmpW.writeVarInt(f.filter_type);
|
|
1057
|
+
if (f.filter_type === 3n || f.filter_type === 4n) {
|
|
1058
|
+
tmpW.writeVarInt(f.start_group);
|
|
1059
|
+
tmpW.writeVarInt(f.start_object);
|
|
1060
|
+
}
|
|
1061
|
+
if (f.filter_type === 4n) {
|
|
1062
|
+
tmpW.writeVarInt(f.end_group);
|
|
1063
|
+
}
|
|
1064
|
+
const raw = tmpW.finish();
|
|
1065
|
+
w.writeVarInt(raw.byteLength);
|
|
1066
|
+
w.writeBytes(raw);
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1060
1069
|
}
|
|
1061
1070
|
if (params.group_order !== void 0) {
|
|
1062
|
-
|
|
1063
|
-
writer.writeVarInt(params.group_order);
|
|
1071
|
+
entries.push({ type: PARAM_GROUP_ORDER, encode: (w) => w.writeVarInt(params.group_order) });
|
|
1064
1072
|
}
|
|
1065
1073
|
if (params.dynamic_groups !== void 0) {
|
|
1066
|
-
|
|
1067
|
-
|
|
1074
|
+
entries.push({
|
|
1075
|
+
type: PARAM_DYNAMIC_GROUPS,
|
|
1076
|
+
encode: (w) => w.writeVarInt(params.dynamic_groups)
|
|
1077
|
+
});
|
|
1068
1078
|
}
|
|
1069
1079
|
if (params.new_group_request !== void 0) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1080
|
+
entries.push({
|
|
1081
|
+
type: PARAM_NEW_GROUP_REQUEST,
|
|
1082
|
+
encode: (w) => w.writeVarInt(params.new_group_request)
|
|
1083
|
+
});
|
|
1072
1084
|
}
|
|
1073
1085
|
if (params.unknown) {
|
|
1074
1086
|
for (const u of params.unknown) {
|
|
1075
1087
|
const id = BigInt(u.id);
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1088
|
+
entries.push({
|
|
1089
|
+
type: id,
|
|
1090
|
+
encode: (w) => {
|
|
1091
|
+
const raw = hexToBytes(u.raw_hex);
|
|
1092
|
+
if (id % 2n === 0n) {
|
|
1093
|
+
w.writeVarInt(new BufferReader(raw).readVarInt());
|
|
1094
|
+
} else {
|
|
1095
|
+
w.writeVarInt(raw.byteLength);
|
|
1096
|
+
w.writeBytes(raw);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1087
1100
|
}
|
|
1088
1101
|
}
|
|
1102
|
+
entries.sort((a, b) => a.type < b.type ? -1 : a.type > b.type ? 1 : 0);
|
|
1103
|
+
writer.writeVarInt(entries.length);
|
|
1104
|
+
let prevType = 0n;
|
|
1105
|
+
for (const entry of entries) {
|
|
1106
|
+
writer.writeVarInt(entry.type - prevType);
|
|
1107
|
+
entry.encode(writer);
|
|
1108
|
+
prevType = entry.type;
|
|
1109
|
+
}
|
|
1089
1110
|
}
|
|
1090
1111
|
function decodeParams(reader) {
|
|
1091
1112
|
const count = Number(reader.readVarInt());
|
|
1092
1113
|
const result = {};
|
|
1093
|
-
|
|
1114
|
+
let prevType = 0n;
|
|
1094
1115
|
for (let i = 0; i < count; i++) {
|
|
1095
|
-
const
|
|
1116
|
+
const delta = reader.readVarInt();
|
|
1117
|
+
const paramType = prevType + delta;
|
|
1118
|
+
prevType = paramType;
|
|
1096
1119
|
if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
1097
1120
|
result.delivery_timeout = reader.readVarInt();
|
|
1098
1121
|
} else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
@@ -1138,29 +1161,14 @@ function decodeParams(reader) {
|
|
|
1138
1161
|
const consumed = reader.offset - startOff;
|
|
1139
1162
|
if (consumed < length) reader.readBytes(length - consumed);
|
|
1140
1163
|
result.subscription_filter = filter;
|
|
1141
|
-
} else if (paramType % 2n === 0n) {
|
|
1142
|
-
const value = reader.readVarInt();
|
|
1143
|
-
const tmpWriter = new BufferWriter(16);
|
|
1144
|
-
tmpWriter.writeVarInt(value);
|
|
1145
|
-
const raw = tmpWriter.finish();
|
|
1146
|
-
unknown.push({
|
|
1147
|
-
id: `0x${paramType.toString(16)}`,
|
|
1148
|
-
length: raw.byteLength,
|
|
1149
|
-
raw_hex: bytesToHex(raw)
|
|
1150
|
-
});
|
|
1151
1164
|
} else {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
raw_hex: bytesToHex(bytes)
|
|
1158
|
-
});
|
|
1165
|
+
throw new DecodeError(
|
|
1166
|
+
"INVALID_PARAMETER",
|
|
1167
|
+
`Unknown Message Parameter type 0x${paramType.toString(16)}`,
|
|
1168
|
+
reader.offset
|
|
1169
|
+
);
|
|
1159
1170
|
}
|
|
1160
1171
|
}
|
|
1161
|
-
if (unknown.length > 0) {
|
|
1162
|
-
result.unknown = unknown;
|
|
1163
|
-
}
|
|
1164
1172
|
return result;
|
|
1165
1173
|
}
|
|
1166
1174
|
function encodeClientSetupPayload(msg, w) {
|
|
@@ -987,112 +987,135 @@ function decodeTrackExtensions(reader) {
|
|
|
987
987
|
return result;
|
|
988
988
|
}
|
|
989
989
|
function encodeParams(params, writer) {
|
|
990
|
-
|
|
991
|
-
if (params.delivery_timeout !== void 0) count++;
|
|
992
|
-
if (params.authorization_token !== void 0) count++;
|
|
993
|
-
if (params.max_cache_duration !== void 0) count++;
|
|
994
|
-
if (params.expires !== void 0) count++;
|
|
995
|
-
if (params.largest_object !== void 0) count++;
|
|
996
|
-
if (params.publisher_priority !== void 0) count++;
|
|
997
|
-
if (params.forward !== void 0) count++;
|
|
998
|
-
if (params.subscriber_priority !== void 0) count++;
|
|
999
|
-
if (params.subscription_filter !== void 0) count++;
|
|
1000
|
-
if (params.group_order !== void 0) count++;
|
|
1001
|
-
if (params.dynamic_groups !== void 0) count++;
|
|
1002
|
-
if (params.new_group_request !== void 0) count++;
|
|
1003
|
-
writer.writeVarInt(count);
|
|
990
|
+
const entries = [];
|
|
1004
991
|
if (params.delivery_timeout !== void 0) {
|
|
1005
|
-
|
|
1006
|
-
|
|
992
|
+
entries.push({
|
|
993
|
+
type: PARAM_DELIVERY_TIMEOUT,
|
|
994
|
+
encode: (w) => w.writeVarInt(params.delivery_timeout)
|
|
995
|
+
});
|
|
1007
996
|
}
|
|
1008
997
|
if (params.authorization_token !== void 0) {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
998
|
+
entries.push({
|
|
999
|
+
type: PARAM_AUTHORIZATION_TOKEN,
|
|
1000
|
+
encode: (w) => {
|
|
1001
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(64);
|
|
1002
|
+
encodeAuthorizationToken(params.authorization_token, tmpW);
|
|
1003
|
+
const raw = tmpW.finish();
|
|
1004
|
+
w.writeVarInt(raw.byteLength);
|
|
1005
|
+
w.writeBytes(raw);
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1015
1008
|
}
|
|
1016
1009
|
if (params.max_cache_duration !== void 0) {
|
|
1017
|
-
|
|
1018
|
-
|
|
1010
|
+
entries.push({
|
|
1011
|
+
type: PARAM_MAX_CACHE_DURATION,
|
|
1012
|
+
encode: (w) => w.writeVarInt(params.max_cache_duration)
|
|
1013
|
+
});
|
|
1019
1014
|
}
|
|
1020
1015
|
if (params.expires !== void 0) {
|
|
1021
|
-
|
|
1022
|
-
writer.writeVarInt(params.expires);
|
|
1016
|
+
entries.push({ type: PARAM_EXPIRES, encode: (w) => w.writeVarInt(params.expires) });
|
|
1023
1017
|
}
|
|
1024
1018
|
if (params.largest_object !== void 0) {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1019
|
+
entries.push({
|
|
1020
|
+
type: PARAM_LARGEST_OBJECT,
|
|
1021
|
+
// Draft-16 has no per-parameter value encoding: a Key-Value-Pair whose
|
|
1022
|
+
// Type is odd carries a Length, and 0x09 is odd. Drafts 17 and later
|
|
1023
|
+
// replaced that with "the encoding is specified by each parameter
|
|
1024
|
+
// definition", which is where the same field loses its length.
|
|
1025
|
+
encode: (w) => {
|
|
1026
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
|
|
1027
|
+
tmpW.writeVarInt(params.largest_object.group);
|
|
1028
|
+
tmpW.writeVarInt(params.largest_object.object);
|
|
1029
|
+
const raw = tmpW.finish();
|
|
1030
|
+
w.writeVarInt(raw.byteLength);
|
|
1031
|
+
w.writeBytes(raw);
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1032
1034
|
}
|
|
1033
1035
|
if (params.publisher_priority !== void 0) {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
+
entries.push({
|
|
1037
|
+
type: PARAM_PUBLISHER_PRIORITY,
|
|
1038
|
+
encode: (w) => w.writeVarInt(params.publisher_priority)
|
|
1039
|
+
});
|
|
1036
1040
|
}
|
|
1037
1041
|
if (params.forward !== void 0) {
|
|
1038
|
-
|
|
1039
|
-
writer.writeVarInt(params.forward);
|
|
1042
|
+
entries.push({ type: PARAM_FORWARD, encode: (w) => w.writeVarInt(params.forward) });
|
|
1040
1043
|
}
|
|
1041
1044
|
if (params.subscriber_priority !== void 0) {
|
|
1042
|
-
|
|
1043
|
-
|
|
1045
|
+
entries.push({
|
|
1046
|
+
type: PARAM_SUBSCRIBER_PRIORITY,
|
|
1047
|
+
encode: (w) => w.writeVarInt(params.subscriber_priority)
|
|
1048
|
+
});
|
|
1044
1049
|
}
|
|
1045
1050
|
if (params.subscription_filter !== void 0) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1051
|
+
entries.push({
|
|
1052
|
+
type: PARAM_SUBSCRIPTION_FILTER,
|
|
1053
|
+
encode: (w) => {
|
|
1054
|
+
const tmpW = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(32);
|
|
1055
|
+
const f = params.subscription_filter;
|
|
1056
|
+
tmpW.writeVarInt(f.filter_type);
|
|
1057
|
+
if (f.filter_type === 3n || f.filter_type === 4n) {
|
|
1058
|
+
tmpW.writeVarInt(f.start_group);
|
|
1059
|
+
tmpW.writeVarInt(f.start_object);
|
|
1060
|
+
}
|
|
1061
|
+
if (f.filter_type === 4n) {
|
|
1062
|
+
tmpW.writeVarInt(f.end_group);
|
|
1063
|
+
}
|
|
1064
|
+
const raw = tmpW.finish();
|
|
1065
|
+
w.writeVarInt(raw.byteLength);
|
|
1066
|
+
w.writeBytes(raw);
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1060
1069
|
}
|
|
1061
1070
|
if (params.group_order !== void 0) {
|
|
1062
|
-
|
|
1063
|
-
writer.writeVarInt(params.group_order);
|
|
1071
|
+
entries.push({ type: PARAM_GROUP_ORDER, encode: (w) => w.writeVarInt(params.group_order) });
|
|
1064
1072
|
}
|
|
1065
1073
|
if (params.dynamic_groups !== void 0) {
|
|
1066
|
-
|
|
1067
|
-
|
|
1074
|
+
entries.push({
|
|
1075
|
+
type: PARAM_DYNAMIC_GROUPS,
|
|
1076
|
+
encode: (w) => w.writeVarInt(params.dynamic_groups)
|
|
1077
|
+
});
|
|
1068
1078
|
}
|
|
1069
1079
|
if (params.new_group_request !== void 0) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1080
|
+
entries.push({
|
|
1081
|
+
type: PARAM_NEW_GROUP_REQUEST,
|
|
1082
|
+
encode: (w) => w.writeVarInt(params.new_group_request)
|
|
1083
|
+
});
|
|
1072
1084
|
}
|
|
1073
1085
|
if (params.unknown) {
|
|
1074
1086
|
for (const u of params.unknown) {
|
|
1075
1087
|
const id = BigInt(u.id);
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1088
|
+
entries.push({
|
|
1089
|
+
type: id,
|
|
1090
|
+
encode: (w) => {
|
|
1091
|
+
const raw = _chunk4XLYCT5Qcjs.hexToBytes.call(void 0, u.raw_hex);
|
|
1092
|
+
if (id % 2n === 0n) {
|
|
1093
|
+
w.writeVarInt(new (0, _chunk4XLYCT5Qcjs.BufferReader)(raw).readVarInt());
|
|
1094
|
+
} else {
|
|
1095
|
+
w.writeVarInt(raw.byteLength);
|
|
1096
|
+
w.writeBytes(raw);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1087
1100
|
}
|
|
1088
1101
|
}
|
|
1102
|
+
entries.sort((a, b) => a.type < b.type ? -1 : a.type > b.type ? 1 : 0);
|
|
1103
|
+
writer.writeVarInt(entries.length);
|
|
1104
|
+
let prevType = 0n;
|
|
1105
|
+
for (const entry of entries) {
|
|
1106
|
+
writer.writeVarInt(entry.type - prevType);
|
|
1107
|
+
entry.encode(writer);
|
|
1108
|
+
prevType = entry.type;
|
|
1109
|
+
}
|
|
1089
1110
|
}
|
|
1090
1111
|
function decodeParams(reader) {
|
|
1091
1112
|
const count = Number(reader.readVarInt());
|
|
1092
1113
|
const result = {};
|
|
1093
|
-
|
|
1114
|
+
let prevType = 0n;
|
|
1094
1115
|
for (let i = 0; i < count; i++) {
|
|
1095
|
-
const
|
|
1116
|
+
const delta = reader.readVarInt();
|
|
1117
|
+
const paramType = prevType + delta;
|
|
1118
|
+
prevType = paramType;
|
|
1096
1119
|
if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
1097
1120
|
result.delivery_timeout = reader.readVarInt();
|
|
1098
1121
|
} else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
@@ -1138,29 +1161,14 @@ function decodeParams(reader) {
|
|
|
1138
1161
|
const consumed = reader.offset - startOff;
|
|
1139
1162
|
if (consumed < length) reader.readBytes(length - consumed);
|
|
1140
1163
|
result.subscription_filter = filter;
|
|
1141
|
-
} else if (paramType % 2n === 0n) {
|
|
1142
|
-
const value = reader.readVarInt();
|
|
1143
|
-
const tmpWriter = new (0, _chunk4XLYCT5Qcjs.BufferWriter)(16);
|
|
1144
|
-
tmpWriter.writeVarInt(value);
|
|
1145
|
-
const raw = tmpWriter.finish();
|
|
1146
|
-
unknown.push({
|
|
1147
|
-
id: `0x${paramType.toString(16)}`,
|
|
1148
|
-
length: raw.byteLength,
|
|
1149
|
-
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, raw)
|
|
1150
|
-
});
|
|
1151
1164
|
} else {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
raw_hex: _chunk4XLYCT5Qcjs.bytesToHex.call(void 0, bytes)
|
|
1158
|
-
});
|
|
1165
|
+
throw new (0, _chunk4XLYCT5Qcjs.DecodeError)(
|
|
1166
|
+
"INVALID_PARAMETER",
|
|
1167
|
+
`Unknown Message Parameter type 0x${paramType.toString(16)}`,
|
|
1168
|
+
reader.offset
|
|
1169
|
+
);
|
|
1159
1170
|
}
|
|
1160
1171
|
}
|
|
1161
|
-
if (unknown.length > 0) {
|
|
1162
|
-
result.unknown = unknown;
|
|
1163
|
-
}
|
|
1164
1172
|
return result;
|
|
1165
1173
|
}
|
|
1166
1174
|
function encodeClientSetupPayload(msg, w) {
|