werift 0.25.0 → 0.25.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/lib/common/src/binaryData.d.ts +116 -0
- package/lib/common/src/binaryData.js +421 -0
- package/lib/common/src/binaryData.js.map +1 -0
- package/lib/common/src/index.d.ts +1 -0
- package/lib/common/src/index.js +24 -0
- package/lib/common/src/index.js.map +1 -1
- package/lib/dtls/src/cipher/prf.d.ts +2 -2
- package/lib/dtls/src/cipher/prf.js +2 -2
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/context/cipher.js +4 -3
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/handshake/binary.d.ts +12 -8
- package/lib/dtls/src/handshake/binary.js +3 -2
- package/lib/dtls/src/handshake/binary.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/ellipticCurves.d.ts +4 -3
- package/lib/dtls/src/handshake/extensions/ellipticCurves.js +7 -6
- package/lib/dtls/src/handshake/extensions/ellipticCurves.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.d.ts +4 -3
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.js +6 -6
- package/lib/dtls/src/handshake/extensions/renegotiationIndication.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/signature.d.ts +7 -3
- package/lib/dtls/src/handshake/extensions/signature.js +6 -6
- package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +4 -3
- package/lib/dtls/src/handshake/extensions/useSrtp.js +6 -6
- package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.d.ts +4 -3
- package/lib/dtls/src/handshake/message/alert.js +6 -6
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.d.ts +3 -2
- package/lib/dtls/src/handshake/message/certificate.js +5 -5
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.d.ts +3 -2
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +5 -5
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +4 -3
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +6 -6
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.d.ts +14 -10
- package/lib/dtls/src/handshake/message/client/hello.js +9 -9
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.d.ts +3 -2
- package/lib/dtls/src/handshake/message/client/keyExchange.js +5 -5
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +8 -4
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +7 -7
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.d.ts +9 -8
- package/lib/dtls/src/handshake/message/server/hello.js +11 -11
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js +4 -4
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.d.ts +5 -4
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +5 -5
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +10 -9
- package/lib/dtls/src/handshake/message/server/keyExchange.js +11 -10
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +5 -4
- package/lib/dtls/src/handshake/random.js +6 -6
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +8 -7
- package/lib/dtls/src/record/message/fragment.js +10 -10
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.d.ts +8 -7
- package/lib/dtls/src/record/message/header.js +8 -8
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.d.ts +1 -1
- package/lib/dtls/src/socket.d.ts +4 -4
- package/lib/dtls/src/socket.js +6 -6
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/dtls/src/util/binary.d.ts +2 -1
- package/lib/dtls/src/util/binary.js +3 -2
- package/lib/dtls/src/util/binary.js.map +1 -1
- package/lib/index.mjs +517 -210
- package/lib/nonstandard/index.mjs +500 -194
- package/lib/polyfill/dom.mjs +538 -232
- package/lib/polyfill/index.mjs +538 -232
- package/package.json +1 -2
package/lib/index.mjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
// ../common/src/binary.ts
|
|
2
8
|
import { randomBytes } from "crypto";
|
|
3
9
|
function random16() {
|
|
@@ -13,19 +19,19 @@ function bufferXor(a, b) {
|
|
|
13
19
|
);
|
|
14
20
|
}
|
|
15
21
|
const length = a.length;
|
|
16
|
-
const
|
|
22
|
+
const buffer3 = Buffer.allocUnsafe(length);
|
|
17
23
|
for (let i = 0; i < length; i++) {
|
|
18
|
-
|
|
24
|
+
buffer3[i] = a[i] ^ b[i];
|
|
19
25
|
}
|
|
20
|
-
return
|
|
26
|
+
return buffer3;
|
|
21
27
|
}
|
|
22
28
|
function bufferArrayXor(arr) {
|
|
23
29
|
const length = [...arr].sort((a, b) => a.length - b.length).reverse()[0].length;
|
|
24
30
|
const xored = Buffer.allocUnsafe(length);
|
|
25
31
|
for (let i = 0; i < length; i++) {
|
|
26
32
|
xored[i] = 0;
|
|
27
|
-
arr.forEach((
|
|
28
|
-
xored[i] ^=
|
|
33
|
+
arr.forEach((buffer3) => {
|
|
34
|
+
xored[i] ^= buffer3[i] ?? 0;
|
|
29
35
|
});
|
|
30
36
|
}
|
|
31
37
|
return xored;
|
|
@@ -917,11 +923,335 @@ function stripZoneId(address) {
|
|
|
917
923
|
return address.split("%")[0];
|
|
918
924
|
}
|
|
919
925
|
|
|
926
|
+
// ../common/src/binaryData.ts
|
|
927
|
+
var binaryData_exports = {};
|
|
928
|
+
__export(binaryData_exports, {
|
|
929
|
+
BinaryReader: () => BinaryReader,
|
|
930
|
+
BinaryWriter: () => BinaryWriter,
|
|
931
|
+
NotEnoughDataError: () => NotEnoughDataError,
|
|
932
|
+
decode: () => decode,
|
|
933
|
+
encode: () => encode,
|
|
934
|
+
types: () => types
|
|
935
|
+
});
|
|
936
|
+
var NotEnoughDataError = class extends Error {
|
|
937
|
+
constructor(expected, received) {
|
|
938
|
+
super(`requested ${expected} bytes but only ${received} available`);
|
|
939
|
+
this.name = "NotEnoughDataError";
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
var BinaryReader = class {
|
|
943
|
+
constructor(buf) {
|
|
944
|
+
this.buf = buf;
|
|
945
|
+
}
|
|
946
|
+
offset = 0;
|
|
947
|
+
/** The number of unread bytes. */
|
|
948
|
+
get length() {
|
|
949
|
+
return this.buf.length - this.offset;
|
|
950
|
+
}
|
|
951
|
+
/** The number of bytes consumed so far. */
|
|
952
|
+
get bytes() {
|
|
953
|
+
return this.offset;
|
|
954
|
+
}
|
|
955
|
+
readBuffer(size) {
|
|
956
|
+
this.assertSize(size);
|
|
957
|
+
const res = this.buf.subarray(this.offset, this.offset + size);
|
|
958
|
+
this.offset += size;
|
|
959
|
+
return res;
|
|
960
|
+
}
|
|
961
|
+
readUIntBE(size) {
|
|
962
|
+
this.assertSize(size);
|
|
963
|
+
const res = this.buf.readUIntBE(this.offset, size);
|
|
964
|
+
this.offset += size;
|
|
965
|
+
return res;
|
|
966
|
+
}
|
|
967
|
+
assertSize(size) {
|
|
968
|
+
if (size > this.length) {
|
|
969
|
+
throw new NotEnoughDataError(size, this.length);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
var BinaryWriter = class {
|
|
974
|
+
chunks = [];
|
|
975
|
+
written = 0;
|
|
976
|
+
/** The number of bytes written so far. */
|
|
977
|
+
get bytes() {
|
|
978
|
+
return this.written;
|
|
979
|
+
}
|
|
980
|
+
writeBuffer(buf) {
|
|
981
|
+
this.chunks.push(buf);
|
|
982
|
+
this.written += buf.length;
|
|
983
|
+
}
|
|
984
|
+
writeUIntBE(value, size) {
|
|
985
|
+
const buf = Buffer.allocUnsafe(size);
|
|
986
|
+
switch (size) {
|
|
987
|
+
case 1:
|
|
988
|
+
buf.writeUInt8(value, 0);
|
|
989
|
+
break;
|
|
990
|
+
case 2:
|
|
991
|
+
buf.writeUInt16BE(value, 0);
|
|
992
|
+
break;
|
|
993
|
+
case 4:
|
|
994
|
+
buf.writeUInt32BE(value, 0);
|
|
995
|
+
break;
|
|
996
|
+
default:
|
|
997
|
+
buf.writeUIntBE(value, 0, size);
|
|
998
|
+
}
|
|
999
|
+
this.writeBuffer(buf);
|
|
1000
|
+
}
|
|
1001
|
+
toBuffer() {
|
|
1002
|
+
return Buffer.concat(this.chunks, this.written);
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
var isObject = (value) => typeof value === "object" && value !== null;
|
|
1006
|
+
var isType = (value) => isObject(value) && typeof value.encode === "function" && typeof value.decode === "function";
|
|
1007
|
+
var isPlainObject = (value) => {
|
|
1008
|
+
if (!isObject(value)) return false;
|
|
1009
|
+
const proto = Object.getPrototypeOf(value);
|
|
1010
|
+
return proto === Object.prototype || proto === null;
|
|
1011
|
+
};
|
|
1012
|
+
var createContext = () => ({
|
|
1013
|
+
node: void 0,
|
|
1014
|
+
current: void 0
|
|
1015
|
+
});
|
|
1016
|
+
var cloneContext = (context) => ({
|
|
1017
|
+
node: context.node,
|
|
1018
|
+
current: context.current
|
|
1019
|
+
});
|
|
1020
|
+
var assertSchema = (schema, message) => {
|
|
1021
|
+
if (!isPlainObject(schema)) {
|
|
1022
|
+
throw new TypeError(message);
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
var encodeCommon = (value, typeOrSchema, writer, context) => {
|
|
1026
|
+
if (isType(typeOrSchema)) {
|
|
1027
|
+
typeOrSchema.encode(value, writer, context);
|
|
1028
|
+
} else {
|
|
1029
|
+
encodeSchema(value, typeOrSchema, writer, context);
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
var encodeSchema = (obj, schema, writer, context) => {
|
|
1033
|
+
assertSchema(schema, "Argument `schema` should be a plain object.");
|
|
1034
|
+
if (context.node === void 0) {
|
|
1035
|
+
context.node = obj;
|
|
1036
|
+
}
|
|
1037
|
+
context.current = obj;
|
|
1038
|
+
for (const key of Object.keys(schema)) {
|
|
1039
|
+
const type = schema[key];
|
|
1040
|
+
const value = obj[key];
|
|
1041
|
+
if (isType(type)) {
|
|
1042
|
+
type.encode(value, writer, context);
|
|
1043
|
+
} else {
|
|
1044
|
+
encodeSchema(value, type, writer, context);
|
|
1045
|
+
context.current = obj;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
var decodeCommon = (reader, typeOrSchema, context) => {
|
|
1050
|
+
if (isType(typeOrSchema)) {
|
|
1051
|
+
return typeOrSchema.decode(reader, context);
|
|
1052
|
+
}
|
|
1053
|
+
return decodeSchema(reader, typeOrSchema, context);
|
|
1054
|
+
};
|
|
1055
|
+
var decodeSchema = (reader, schema, context) => {
|
|
1056
|
+
assertSchema(schema, "Argument #2 should be a plain object.");
|
|
1057
|
+
const node = /* @__PURE__ */ Object.create(null);
|
|
1058
|
+
if (context.node === void 0) {
|
|
1059
|
+
context.node = node;
|
|
1060
|
+
}
|
|
1061
|
+
context.current = node;
|
|
1062
|
+
for (const key of Object.keys(schema)) {
|
|
1063
|
+
const type = schema[key];
|
|
1064
|
+
if (isType(type)) {
|
|
1065
|
+
node[key] = type.decode(reader, context);
|
|
1066
|
+
} else {
|
|
1067
|
+
node[key] = decodeSchema(reader, type, context);
|
|
1068
|
+
context.current = node;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return node;
|
|
1072
|
+
};
|
|
1073
|
+
function encode(obj, typeOrSchema) {
|
|
1074
|
+
const writer = new BinaryWriter();
|
|
1075
|
+
encodeCommon(obj, typeOrSchema, writer, createContext());
|
|
1076
|
+
return writer.toBuffer();
|
|
1077
|
+
}
|
|
1078
|
+
function decode(buf, typeOrSchema) {
|
|
1079
|
+
return decodeCommon(new BinaryReader(buf), typeOrSchema, createContext());
|
|
1080
|
+
}
|
|
1081
|
+
var createUIntBE = (size) => ({
|
|
1082
|
+
encode: (value, writer) => writer.writeUIntBE(value, size),
|
|
1083
|
+
decode: (reader) => reader.readUIntBE(size)
|
|
1084
|
+
});
|
|
1085
|
+
var assertLengthSpec = (length) => {
|
|
1086
|
+
if (typeof length !== "number" && !isType(length) && typeof length !== "function") {
|
|
1087
|
+
throw new TypeError("Unknown type of argument #1.");
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
var checkLength = (required, having, name) => {
|
|
1091
|
+
if (required !== having) {
|
|
1092
|
+
throw new Error(`${name} required length ${required} instead of ${having}`);
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
var checkLengthType = (length, message) => {
|
|
1096
|
+
if (typeof length !== "number") {
|
|
1097
|
+
throw new TypeError(message);
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
function buffer(length) {
|
|
1101
|
+
assertLengthSpec(length);
|
|
1102
|
+
const lengthTypeError = "Length of a buffer should be a number.";
|
|
1103
|
+
return {
|
|
1104
|
+
encode(buf, writer, context) {
|
|
1105
|
+
if (!Buffer.isBuffer(buf)) {
|
|
1106
|
+
throw new TypeError("Argument 1 should be a Buffer or a BinaryStream.");
|
|
1107
|
+
}
|
|
1108
|
+
if (typeof length === "number") {
|
|
1109
|
+
checkLength(length, buf.length, "Buffer");
|
|
1110
|
+
} else if (isType(length)) {
|
|
1111
|
+
length.encode(buf.length, writer, context);
|
|
1112
|
+
} else {
|
|
1113
|
+
const expected = length(context);
|
|
1114
|
+
checkLengthType(expected, lengthTypeError);
|
|
1115
|
+
checkLength(expected, buf.length, "Buffer");
|
|
1116
|
+
}
|
|
1117
|
+
writer.writeBuffer(buf);
|
|
1118
|
+
},
|
|
1119
|
+
decode(reader, context) {
|
|
1120
|
+
let size;
|
|
1121
|
+
if (typeof length === "number") {
|
|
1122
|
+
size = length;
|
|
1123
|
+
} else if (isType(length)) {
|
|
1124
|
+
size = length.decode(reader, context);
|
|
1125
|
+
} else {
|
|
1126
|
+
size = length(context);
|
|
1127
|
+
}
|
|
1128
|
+
checkLengthType(size, lengthTypeError);
|
|
1129
|
+
return reader.readBuffer(size);
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
function array(type, length, lengthType = "count") {
|
|
1134
|
+
if (!isType(type) && !isPlainObject(type)) {
|
|
1135
|
+
throw new TypeError("Argument #1 should be a valid type.");
|
|
1136
|
+
}
|
|
1137
|
+
assertLengthSpec(length);
|
|
1138
|
+
const isLengthInBytes = lengthType === "bytes";
|
|
1139
|
+
const sizeTypeError = "Length of an array should be a number.";
|
|
1140
|
+
return {
|
|
1141
|
+
encode(items, writer, parent) {
|
|
1142
|
+
if (!Array.isArray(items)) {
|
|
1143
|
+
throw new TypeError("Argument #1 should be an Array.");
|
|
1144
|
+
}
|
|
1145
|
+
const context = cloneContext(parent);
|
|
1146
|
+
let expectedSize = 0;
|
|
1147
|
+
if (typeof length === "number") {
|
|
1148
|
+
expectedSize = length;
|
|
1149
|
+
} else if (isType(length)) {
|
|
1150
|
+
expectedSize = items.length;
|
|
1151
|
+
} else {
|
|
1152
|
+
expectedSize = length(context);
|
|
1153
|
+
checkLengthType(expectedSize, sizeTypeError);
|
|
1154
|
+
}
|
|
1155
|
+
const body = new BinaryWriter();
|
|
1156
|
+
for (const item of items) {
|
|
1157
|
+
encodeCommon(item, type, body, context);
|
|
1158
|
+
}
|
|
1159
|
+
if (isLengthInBytes) {
|
|
1160
|
+
if (isType(length)) {
|
|
1161
|
+
expectedSize = body.bytes;
|
|
1162
|
+
}
|
|
1163
|
+
checkLength(body.bytes, expectedSize, "Argument #1");
|
|
1164
|
+
} else {
|
|
1165
|
+
checkLength(expectedSize, items.length, "Argument #1");
|
|
1166
|
+
}
|
|
1167
|
+
if (isType(length)) {
|
|
1168
|
+
length.encode(expectedSize, writer, context);
|
|
1169
|
+
}
|
|
1170
|
+
writer.writeBuffer(body.toBuffer());
|
|
1171
|
+
},
|
|
1172
|
+
decode(reader, parent) {
|
|
1173
|
+
const context = cloneContext(parent);
|
|
1174
|
+
let expectedSize;
|
|
1175
|
+
if (typeof length === "number") {
|
|
1176
|
+
expectedSize = length;
|
|
1177
|
+
} else if (isType(length)) {
|
|
1178
|
+
expectedSize = length.decode(reader, context);
|
|
1179
|
+
} else {
|
|
1180
|
+
expectedSize = length(context);
|
|
1181
|
+
}
|
|
1182
|
+
checkLengthType(expectedSize, sizeTypeError);
|
|
1183
|
+
const items = [];
|
|
1184
|
+
if (isLengthInBytes) {
|
|
1185
|
+
const before = reader.bytes;
|
|
1186
|
+
let bytes = 0;
|
|
1187
|
+
while (bytes < expectedSize) {
|
|
1188
|
+
items.push(decodeCommon(reader, type, context));
|
|
1189
|
+
bytes = reader.bytes - before;
|
|
1190
|
+
}
|
|
1191
|
+
if (bytes > expectedSize) {
|
|
1192
|
+
throw new Error("Incorrect length of an array.");
|
|
1193
|
+
}
|
|
1194
|
+
} else {
|
|
1195
|
+
for (let i = 0; i < expectedSize; i++) {
|
|
1196
|
+
items.push(decodeCommon(reader, type, context));
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return items;
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
function string(length, encoding = "ascii") {
|
|
1204
|
+
if (!Buffer.isEncoding(encoding)) {
|
|
1205
|
+
throw new Error("Argument #2 should be an encoding name.");
|
|
1206
|
+
}
|
|
1207
|
+
assertLengthSpec(length);
|
|
1208
|
+
const lengthTypeError = "Length of a buffer should be a number.";
|
|
1209
|
+
return {
|
|
1210
|
+
encode(value, writer, context) {
|
|
1211
|
+
const buf = Buffer.from(value.toString(), encoding);
|
|
1212
|
+
if (typeof length === "number") {
|
|
1213
|
+
if (buf.length !== length) {
|
|
1214
|
+
throw new Error(`Size of string should be ${length} in bytes.`);
|
|
1215
|
+
}
|
|
1216
|
+
} else if (isType(length)) {
|
|
1217
|
+
length.encode(buf.length, writer, context);
|
|
1218
|
+
} else {
|
|
1219
|
+
const expected = length(context);
|
|
1220
|
+
checkLengthType(expected, lengthTypeError);
|
|
1221
|
+
checkLength(expected, buf.length, "Buffer");
|
|
1222
|
+
}
|
|
1223
|
+
writer.writeBuffer(buf);
|
|
1224
|
+
},
|
|
1225
|
+
decode(reader, context) {
|
|
1226
|
+
let size;
|
|
1227
|
+
if (typeof length === "number") {
|
|
1228
|
+
size = length;
|
|
1229
|
+
} else if (isType(length)) {
|
|
1230
|
+
size = length.decode(reader, context);
|
|
1231
|
+
checkLengthType(size, "Size of a string should be a number.");
|
|
1232
|
+
} else {
|
|
1233
|
+
size = length(context);
|
|
1234
|
+
checkLengthType(size, lengthTypeError);
|
|
1235
|
+
}
|
|
1236
|
+
return reader.readBuffer(size).toString(encoding);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
var types = {
|
|
1241
|
+
uint8: createUIntBE(1),
|
|
1242
|
+
uint16be: createUIntBE(2),
|
|
1243
|
+
uint24be: createUIntBE(3),
|
|
1244
|
+
uint32be: createUIntBE(4),
|
|
1245
|
+
uint48be: createUIntBE(6),
|
|
1246
|
+
buffer,
|
|
1247
|
+
array,
|
|
1248
|
+
string
|
|
1249
|
+
};
|
|
1250
|
+
|
|
920
1251
|
// ../dtls/src/context/cipher.ts
|
|
921
1252
|
import { createSign, randomBytes as randomBytes2, webcrypto } from "crypto";
|
|
922
1253
|
import { Certificate, PrivateKey } from "@fidm/x509";
|
|
923
1254
|
import * as x509 from "@peculiar/x509";
|
|
924
|
-
import { encode, types } from "@shinyoshiaki/binary-data";
|
|
925
1255
|
|
|
926
1256
|
// ../dtls/src/cipher/const.ts
|
|
927
1257
|
var SignatureAlgorithm = {
|
|
@@ -961,7 +1291,6 @@ var signatures = [
|
|
|
961
1291
|
|
|
962
1292
|
// ../dtls/src/cipher/prf.ts
|
|
963
1293
|
import { createHash, createHmac } from "crypto";
|
|
964
|
-
import { createDecode } from "@shinyoshiaki/binary-data";
|
|
965
1294
|
import nacl from "tweetnacl";
|
|
966
1295
|
|
|
967
1296
|
// ../dtls/src/cipher/ec.ts
|
|
@@ -1063,7 +1392,7 @@ function prfEncryptionKeys(masterSecret, clientRandom, serverRandom, prfKeyLen,
|
|
|
1063
1392
|
size,
|
|
1064
1393
|
algorithm
|
|
1065
1394
|
);
|
|
1066
|
-
const stream =
|
|
1395
|
+
const stream = new binaryData_exports.BinaryReader(keyBlock);
|
|
1067
1396
|
const clientWriteKey = stream.readBuffer(prfKeyLen);
|
|
1068
1397
|
const serverWriteKey = stream.readBuffer(prfKeyLen);
|
|
1069
1398
|
const clientNonceImplicit = stream.readBuffer(prfIvLen);
|
|
@@ -1117,6 +1446,7 @@ var AbstractCipher = class {
|
|
|
1117
1446
|
};
|
|
1118
1447
|
|
|
1119
1448
|
// ../dtls/src/context/cipher.ts
|
|
1449
|
+
var { encode: encode2, types: types2 } = binaryData_exports;
|
|
1120
1450
|
var crypto = webcrypto;
|
|
1121
1451
|
x509.cryptoProvider.set(crypto);
|
|
1122
1452
|
var CipherContext = class {
|
|
@@ -1262,15 +1592,13 @@ var CipherContext = class {
|
|
|
1262
1592
|
this.signatureHashAlgorithm = signatureHash;
|
|
1263
1593
|
}
|
|
1264
1594
|
valueKeySignature(clientRandom, serverRandom, publicKey, namedCurve) {
|
|
1265
|
-
const serverParams =
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
{ type: types.uint8, curve: types.uint16be, len: types.uint8 }
|
|
1273
|
-
).slice()
|
|
1595
|
+
const serverParams = encode2(
|
|
1596
|
+
{
|
|
1597
|
+
type: CurveType.named_curve_3,
|
|
1598
|
+
curve: namedCurve,
|
|
1599
|
+
len: publicKey.length
|
|
1600
|
+
},
|
|
1601
|
+
{ type: types2.uint8, curve: types2.uint16be, len: types2.uint8 }
|
|
1274
1602
|
);
|
|
1275
1603
|
return Buffer.concat([clientRandom, serverRandom, serverParams, publicKey]);
|
|
1276
1604
|
}
|
|
@@ -1286,12 +1614,6 @@ var SrtpContext = class {
|
|
|
1286
1614
|
}
|
|
1287
1615
|
};
|
|
1288
1616
|
|
|
1289
|
-
// ../dtls/src/handshake/message/client/hello.ts
|
|
1290
|
-
import { decode as decode3, encode as encode4, types as types5 } from "@shinyoshiaki/binary-data";
|
|
1291
|
-
|
|
1292
|
-
// ../dtls/src/record/message/fragment.ts
|
|
1293
|
-
import { decode, encode as encode2, types as types2 } from "@shinyoshiaki/binary-data";
|
|
1294
|
-
|
|
1295
1617
|
// ../dtls/src/helper.ts
|
|
1296
1618
|
var dumpBuffer2 = (data) => "0x" + data.toString("hex").replace(/(.)(.)/g, "$1$2 ").split(" ").filter((s) => s != void 0 && s.length > 0).join(",0x");
|
|
1297
1619
|
var getObjectSummary = (obj) => Object.entries({ ...obj }).reduce((acc, [key, value]) => {
|
|
@@ -1305,6 +1627,7 @@ var getObjectSummary = (obj) => Object.entries({ ...obj }).reduce((acc, [key, va
|
|
|
1305
1627
|
}, {});
|
|
1306
1628
|
|
|
1307
1629
|
// ../dtls/src/record/message/fragment.ts
|
|
1630
|
+
var { decode: decode2, encode: encode3, types: types3 } = binaryData_exports;
|
|
1308
1631
|
var FragmentedHandshake = class _FragmentedHandshake {
|
|
1309
1632
|
constructor(msg_type, length, message_seq, fragment_offset, fragment_length, fragment) {
|
|
1310
1633
|
this.msg_type = msg_type;
|
|
@@ -1315,12 +1638,12 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
1315
1638
|
this.fragment = fragment;
|
|
1316
1639
|
}
|
|
1317
1640
|
static spec = {
|
|
1318
|
-
msg_type:
|
|
1319
|
-
length:
|
|
1320
|
-
message_seq:
|
|
1321
|
-
fragment_offset:
|
|
1322
|
-
fragment_length:
|
|
1323
|
-
fragment:
|
|
1641
|
+
msg_type: types3.uint8,
|
|
1642
|
+
length: types3.uint24be,
|
|
1643
|
+
message_seq: types3.uint16be,
|
|
1644
|
+
fragment_offset: types3.uint24be,
|
|
1645
|
+
fragment_length: types3.uint24be,
|
|
1646
|
+
fragment: types3.buffer((context) => context.current.fragment_length)
|
|
1324
1647
|
};
|
|
1325
1648
|
get summary() {
|
|
1326
1649
|
return getObjectSummary(this);
|
|
@@ -1337,12 +1660,11 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
1337
1660
|
}
|
|
1338
1661
|
static deSerialize(buf) {
|
|
1339
1662
|
return new _FragmentedHandshake(
|
|
1340
|
-
...Object.values(
|
|
1663
|
+
...Object.values(decode2(buf, _FragmentedHandshake.spec))
|
|
1341
1664
|
);
|
|
1342
1665
|
}
|
|
1343
1666
|
serialize() {
|
|
1344
|
-
|
|
1345
|
-
return Buffer.from(res);
|
|
1667
|
+
return encode3(this, _FragmentedHandshake.spec);
|
|
1346
1668
|
}
|
|
1347
1669
|
chunk(maxFragmentLength) {
|
|
1348
1670
|
let start = 0;
|
|
@@ -1415,46 +1737,46 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
1415
1737
|
};
|
|
1416
1738
|
|
|
1417
1739
|
// ../dtls/src/handshake/binary.ts
|
|
1418
|
-
|
|
1419
|
-
var { uint16be, uint24be, buffer, array, uint8, string } =
|
|
1740
|
+
var { types: types4 } = binaryData_exports;
|
|
1741
|
+
var { uint16be, uint24be, buffer: buffer2, array: array2, uint8, string: string2 } = types4;
|
|
1420
1742
|
var Extension = {
|
|
1421
1743
|
type: uint16be,
|
|
1422
|
-
data:
|
|
1744
|
+
data: buffer2(uint16be)
|
|
1423
1745
|
};
|
|
1424
|
-
var ExtensionList =
|
|
1425
|
-
var ASN11Cert =
|
|
1746
|
+
var ExtensionList = array2(Extension, uint16be, "bytes");
|
|
1747
|
+
var ASN11Cert = buffer2(uint24be);
|
|
1426
1748
|
var ClientCertificateType = uint8;
|
|
1427
|
-
var DistinguishedName =
|
|
1749
|
+
var DistinguishedName = string2(uint16be);
|
|
1428
1750
|
var SignatureHashAlgorithm = { hash: uint8, signature: uint8 };
|
|
1429
1751
|
var ProtocolVersion = { major: uint8, minor: uint8 };
|
|
1430
1752
|
|
|
1431
1753
|
// ../dtls/src/handshake/random.ts
|
|
1432
1754
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
1433
|
-
|
|
1755
|
+
var { decode: decode3, encode: encode4, types: types5 } = binaryData_exports;
|
|
1434
1756
|
var DtlsRandom = class _DtlsRandom {
|
|
1435
1757
|
constructor(gmt_unix_time = Math.floor(Date.now() / 1e3), random_bytes = randomBytes3(28)) {
|
|
1436
1758
|
this.gmt_unix_time = gmt_unix_time;
|
|
1437
1759
|
this.random_bytes = random_bytes;
|
|
1438
1760
|
}
|
|
1439
1761
|
static spec = {
|
|
1440
|
-
gmt_unix_time:
|
|
1441
|
-
random_bytes:
|
|
1762
|
+
gmt_unix_time: types5.uint32be,
|
|
1763
|
+
random_bytes: types5.buffer(28)
|
|
1442
1764
|
};
|
|
1443
1765
|
static deSerialize(buf) {
|
|
1444
1766
|
return new _DtlsRandom(
|
|
1445
|
-
...Object.values(
|
|
1767
|
+
...Object.values(decode3(buf, _DtlsRandom.spec))
|
|
1446
1768
|
);
|
|
1447
1769
|
}
|
|
1448
1770
|
static from(spec) {
|
|
1449
1771
|
return new _DtlsRandom(...Object.values(spec));
|
|
1450
1772
|
}
|
|
1451
1773
|
serialize() {
|
|
1452
|
-
|
|
1453
|
-
return Buffer.from(res);
|
|
1774
|
+
return encode4(this, _DtlsRandom.spec);
|
|
1454
1775
|
}
|
|
1455
1776
|
};
|
|
1456
1777
|
|
|
1457
1778
|
// ../dtls/src/handshake/message/client/hello.ts
|
|
1779
|
+
var { decode: decode4, encode: encode5, types: types6 } = binaryData_exports;
|
|
1458
1780
|
var ClientHello = class _ClientHello {
|
|
1459
1781
|
constructor(clientVersion, random, sessionId, cookie, cipherSuites2, compressionMethods, extensions) {
|
|
1460
1782
|
this.clientVersion = clientVersion;
|
|
@@ -1468,12 +1790,12 @@ var ClientHello = class _ClientHello {
|
|
|
1468
1790
|
msgType = 1 /* client_hello_1 */;
|
|
1469
1791
|
messageSeq = 0;
|
|
1470
1792
|
static spec = {
|
|
1471
|
-
clientVersion: { major:
|
|
1793
|
+
clientVersion: { major: types6.uint8, minor: types6.uint8 },
|
|
1472
1794
|
random: DtlsRandom.spec,
|
|
1473
|
-
sessionId:
|
|
1474
|
-
cookie:
|
|
1475
|
-
cipherSuites:
|
|
1476
|
-
compressionMethods:
|
|
1795
|
+
sessionId: types6.buffer(types6.uint8),
|
|
1796
|
+
cookie: types6.buffer(types6.uint8),
|
|
1797
|
+
cipherSuites: types6.array(types6.uint16be, types6.uint16be, "bytes"),
|
|
1798
|
+
compressionMethods: types6.array(types6.uint8, types6.uint8, "bytes"),
|
|
1477
1799
|
extensions: ExtensionList
|
|
1478
1800
|
};
|
|
1479
1801
|
static createEmpty() {
|
|
@@ -1489,12 +1811,11 @@ var ClientHello = class _ClientHello {
|
|
|
1489
1811
|
}
|
|
1490
1812
|
static deSerialize(buf) {
|
|
1491
1813
|
return new _ClientHello(
|
|
1492
|
-
...Object.values(
|
|
1814
|
+
...Object.values(decode4(buf, _ClientHello.spec))
|
|
1493
1815
|
);
|
|
1494
1816
|
}
|
|
1495
1817
|
serialize() {
|
|
1496
|
-
|
|
1497
|
-
return Buffer.from(res);
|
|
1818
|
+
return encode5(this, _ClientHello.spec);
|
|
1498
1819
|
}
|
|
1499
1820
|
toFragment() {
|
|
1500
1821
|
const body = this.serialize();
|
|
@@ -1513,7 +1834,7 @@ var ClientHello = class _ClientHello {
|
|
|
1513
1834
|
import { setTimeout as setTimeout2 } from "timers/promises";
|
|
1514
1835
|
|
|
1515
1836
|
// ../dtls/src/record/message/header.ts
|
|
1516
|
-
|
|
1837
|
+
var { decode: decode5, encode: encode6, types: types7 } = binaryData_exports;
|
|
1517
1838
|
var MACHeader = class _MACHeader {
|
|
1518
1839
|
constructor(epoch, sequenceNumber, contentType, protocolVersion, contentLen) {
|
|
1519
1840
|
this.epoch = epoch;
|
|
@@ -1523,11 +1844,11 @@ var MACHeader = class _MACHeader {
|
|
|
1523
1844
|
this.contentLen = contentLen;
|
|
1524
1845
|
}
|
|
1525
1846
|
static spec = {
|
|
1526
|
-
epoch:
|
|
1527
|
-
sequenceNumber:
|
|
1528
|
-
contentType:
|
|
1847
|
+
epoch: types7.uint16be,
|
|
1848
|
+
sequenceNumber: types7.uint48be,
|
|
1849
|
+
contentType: types7.uint8,
|
|
1529
1850
|
protocolVersion: ProtocolVersion,
|
|
1530
|
-
contentLen:
|
|
1851
|
+
contentLen: types7.uint16be
|
|
1531
1852
|
};
|
|
1532
1853
|
static createEmpty() {
|
|
1533
1854
|
return new _MACHeader(
|
|
@@ -1540,12 +1861,11 @@ var MACHeader = class _MACHeader {
|
|
|
1540
1861
|
}
|
|
1541
1862
|
static deSerialize(buf) {
|
|
1542
1863
|
return new _MACHeader(
|
|
1543
|
-
...Object.values(
|
|
1864
|
+
...Object.values(decode5(buf, _MACHeader.spec))
|
|
1544
1865
|
);
|
|
1545
1866
|
}
|
|
1546
1867
|
serialize() {
|
|
1547
|
-
|
|
1548
|
-
return Buffer.from(res);
|
|
1868
|
+
return encode6(this, _MACHeader.spec);
|
|
1549
1869
|
}
|
|
1550
1870
|
};
|
|
1551
1871
|
|
|
@@ -1593,15 +1913,15 @@ var DtlsPlaintext = class _DtlsPlaintext {
|
|
|
1593
1913
|
serialize() {
|
|
1594
1914
|
const fragmentLength = this.fragment.length;
|
|
1595
1915
|
const totalLength = 13 + fragmentLength;
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
this.fragment.copy(
|
|
1604
|
-
return
|
|
1916
|
+
const buffer3 = Buffer.alloc(totalLength);
|
|
1917
|
+
buffer3.writeUInt8(this.recordLayerHeader.contentType, 0);
|
|
1918
|
+
buffer3.writeUInt8(this.recordLayerHeader.protocolVersion.major, 1);
|
|
1919
|
+
buffer3.writeUInt8(this.recordLayerHeader.protocolVersion.minor, 2);
|
|
1920
|
+
buffer3.writeUInt16BE(this.recordLayerHeader.epoch, 3);
|
|
1921
|
+
buffer3.writeUIntBE(this.recordLayerHeader.sequenceNumber, 5, 6);
|
|
1922
|
+
buffer3.writeUInt16BE(fragmentLength, 11);
|
|
1923
|
+
this.fragment.copy(buffer3, 13);
|
|
1924
|
+
return buffer3;
|
|
1605
1925
|
}
|
|
1606
1926
|
computeMACHeader() {
|
|
1607
1927
|
return new MACHeader(
|
|
@@ -2159,12 +2479,12 @@ var ExtendedMasterSecret = class {
|
|
|
2159
2479
|
};
|
|
2160
2480
|
|
|
2161
2481
|
// ../dtls/src/handshake/extensions/renegotiationIndication.ts
|
|
2162
|
-
|
|
2482
|
+
var { decode: decode6, encode: encode7, types: types8 } = binaryData_exports;
|
|
2163
2483
|
var RenegotiationIndication = class _RenegotiationIndication {
|
|
2164
2484
|
static type = 65281;
|
|
2165
2485
|
static spec = {
|
|
2166
|
-
type:
|
|
2167
|
-
data:
|
|
2486
|
+
type: types8.uint16be,
|
|
2487
|
+
data: types8.uint8
|
|
2168
2488
|
};
|
|
2169
2489
|
type = _RenegotiationIndication.type;
|
|
2170
2490
|
data = 0;
|
|
@@ -2177,12 +2497,11 @@ var RenegotiationIndication = class _RenegotiationIndication {
|
|
|
2177
2497
|
}
|
|
2178
2498
|
static deSerialize(buf) {
|
|
2179
2499
|
return new _RenegotiationIndication(
|
|
2180
|
-
|
|
2500
|
+
decode6(buf, _RenegotiationIndication.spec)
|
|
2181
2501
|
);
|
|
2182
2502
|
}
|
|
2183
2503
|
serialize() {
|
|
2184
|
-
|
|
2185
|
-
return Buffer.from(res);
|
|
2504
|
+
return encode7(this, _RenegotiationIndication.spec);
|
|
2186
2505
|
}
|
|
2187
2506
|
get extension() {
|
|
2188
2507
|
return {
|
|
@@ -2193,13 +2512,13 @@ var RenegotiationIndication = class _RenegotiationIndication {
|
|
|
2193
2512
|
};
|
|
2194
2513
|
|
|
2195
2514
|
// ../dtls/src/handshake/extensions/useSrtp.ts
|
|
2196
|
-
|
|
2515
|
+
var { decode: decode7, encode: encode8, types: types9 } = binaryData_exports;
|
|
2197
2516
|
var UseSRTP = class _UseSRTP {
|
|
2198
2517
|
static type = 14;
|
|
2199
2518
|
// 9. IANA Considerations
|
|
2200
2519
|
static spec = {
|
|
2201
|
-
type:
|
|
2202
|
-
data:
|
|
2520
|
+
type: types9.uint16be,
|
|
2521
|
+
data: types9.buffer(types9.uint16be)
|
|
2203
2522
|
};
|
|
2204
2523
|
type = _UseSRTP.type;
|
|
2205
2524
|
data = Buffer.from([]);
|
|
@@ -2216,7 +2535,7 @@ var UseSRTP = class _UseSRTP {
|
|
|
2216
2535
|
return v;
|
|
2217
2536
|
}
|
|
2218
2537
|
static deSerialize(buf) {
|
|
2219
|
-
const useSrtp = new _UseSRTP(
|
|
2538
|
+
const useSrtp = new _UseSRTP(decode7(buf, _UseSRTP.spec));
|
|
2220
2539
|
const profileLength = useSrtp.data.readUInt16BE();
|
|
2221
2540
|
const profiles = new Array(profileLength / 2);
|
|
2222
2541
|
for (let i = 0; i < profiles.length; i++) {
|
|
@@ -2239,8 +2558,7 @@ var UseSRTP = class _UseSRTP {
|
|
|
2239
2558
|
this.mki
|
|
2240
2559
|
]);
|
|
2241
2560
|
this.data = data;
|
|
2242
|
-
|
|
2243
|
-
return Buffer.from(res);
|
|
2561
|
+
return encode8(this, _UseSRTP.spec);
|
|
2244
2562
|
}
|
|
2245
2563
|
static fromData(buf) {
|
|
2246
2564
|
const head = Buffer.alloc(4);
|
|
@@ -2257,7 +2575,7 @@ var UseSRTP = class _UseSRTP {
|
|
|
2257
2575
|
};
|
|
2258
2576
|
|
|
2259
2577
|
// ../dtls/src/handshake/message/certificate.ts
|
|
2260
|
-
|
|
2578
|
+
var { decode: decode8, encode: encode9, types: types10 } = binaryData_exports;
|
|
2261
2579
|
var Certificate2 = class _Certificate {
|
|
2262
2580
|
constructor(certificateList) {
|
|
2263
2581
|
this.certificateList = certificateList;
|
|
@@ -2265,19 +2583,18 @@ var Certificate2 = class _Certificate {
|
|
|
2265
2583
|
msgType = 11 /* certificate_11 */;
|
|
2266
2584
|
messageSeq;
|
|
2267
2585
|
static spec = {
|
|
2268
|
-
certificateList:
|
|
2586
|
+
certificateList: types10.array(ASN11Cert, types10.uint24be, "bytes")
|
|
2269
2587
|
};
|
|
2270
2588
|
static createEmpty() {
|
|
2271
2589
|
return new _Certificate(void 0);
|
|
2272
2590
|
}
|
|
2273
2591
|
static deSerialize(buf) {
|
|
2274
2592
|
return new _Certificate(
|
|
2275
|
-
...Object.values(
|
|
2593
|
+
...Object.values(decode8(buf, _Certificate.spec))
|
|
2276
2594
|
);
|
|
2277
2595
|
}
|
|
2278
2596
|
serialize() {
|
|
2279
|
-
|
|
2280
|
-
return Buffer.from(res);
|
|
2597
|
+
return encode9(this, _Certificate.spec);
|
|
2281
2598
|
}
|
|
2282
2599
|
toFragment() {
|
|
2283
2600
|
const body = this.serialize();
|
|
@@ -2293,30 +2610,29 @@ var Certificate2 = class _Certificate {
|
|
|
2293
2610
|
};
|
|
2294
2611
|
|
|
2295
2612
|
// ../dtls/src/handshake/message/changeCipherSpec.ts
|
|
2296
|
-
|
|
2613
|
+
var { decode: decode9, encode: encode10, types: types11 } = binaryData_exports;
|
|
2297
2614
|
var ChangeCipherSpec = class _ChangeCipherSpec {
|
|
2298
2615
|
constructor(type = 1) {
|
|
2299
2616
|
this.type = type;
|
|
2300
2617
|
}
|
|
2301
2618
|
static spec = {
|
|
2302
|
-
type:
|
|
2619
|
+
type: types11.uint8
|
|
2303
2620
|
};
|
|
2304
2621
|
static createEmpty() {
|
|
2305
2622
|
return new _ChangeCipherSpec();
|
|
2306
2623
|
}
|
|
2307
2624
|
static deSerialize(buf) {
|
|
2308
2625
|
return new _ChangeCipherSpec(
|
|
2309
|
-
...Object.values(
|
|
2626
|
+
...Object.values(decode9(buf, _ChangeCipherSpec.spec))
|
|
2310
2627
|
);
|
|
2311
2628
|
}
|
|
2312
2629
|
serialize() {
|
|
2313
|
-
|
|
2314
|
-
return Buffer.from(res);
|
|
2630
|
+
return encode10(this, _ChangeCipherSpec.spec);
|
|
2315
2631
|
}
|
|
2316
2632
|
};
|
|
2317
2633
|
|
|
2318
2634
|
// ../dtls/src/handshake/message/client/certificateVerify.ts
|
|
2319
|
-
|
|
2635
|
+
var { decode: decode10, encode: encode11, types: types12 } = binaryData_exports;
|
|
2320
2636
|
var CertificateVerify = class _CertificateVerify {
|
|
2321
2637
|
constructor(algorithm, signature) {
|
|
2322
2638
|
this.algorithm = algorithm;
|
|
@@ -2325,21 +2641,20 @@ var CertificateVerify = class _CertificateVerify {
|
|
|
2325
2641
|
msgType = 15 /* certificate_verify_15 */;
|
|
2326
2642
|
messageSeq;
|
|
2327
2643
|
static spec = {
|
|
2328
|
-
algorithm:
|
|
2329
|
-
signature:
|
|
2644
|
+
algorithm: types12.uint16be,
|
|
2645
|
+
signature: types12.buffer(types12.uint16be)
|
|
2330
2646
|
};
|
|
2331
2647
|
static createEmpty() {
|
|
2332
2648
|
return new _CertificateVerify(void 0, void 0);
|
|
2333
2649
|
}
|
|
2334
2650
|
static deSerialize(buf) {
|
|
2335
|
-
const res =
|
|
2651
|
+
const res = decode10(buf, _CertificateVerify.spec);
|
|
2336
2652
|
return new _CertificateVerify(
|
|
2337
2653
|
...Object.values(res)
|
|
2338
2654
|
);
|
|
2339
2655
|
}
|
|
2340
2656
|
serialize() {
|
|
2341
|
-
|
|
2342
|
-
return Buffer.from(res);
|
|
2657
|
+
return encode11(this, _CertificateVerify.spec);
|
|
2343
2658
|
}
|
|
2344
2659
|
toFragment() {
|
|
2345
2660
|
const body = this.serialize();
|
|
@@ -2355,7 +2670,7 @@ var CertificateVerify = class _CertificateVerify {
|
|
|
2355
2670
|
};
|
|
2356
2671
|
|
|
2357
2672
|
// ../dtls/src/handshake/message/client/keyExchange.ts
|
|
2358
|
-
|
|
2673
|
+
var { decode: decode11, encode: encode12, types: types13 } = binaryData_exports;
|
|
2359
2674
|
var ClientKeyExchange = class _ClientKeyExchange {
|
|
2360
2675
|
constructor(publicKey) {
|
|
2361
2676
|
this.publicKey = publicKey;
|
|
@@ -2363,20 +2678,19 @@ var ClientKeyExchange = class _ClientKeyExchange {
|
|
|
2363
2678
|
msgType = 16 /* client_key_exchange_16 */;
|
|
2364
2679
|
messageSeq;
|
|
2365
2680
|
static spec = {
|
|
2366
|
-
publicKey:
|
|
2681
|
+
publicKey: types13.buffer(types13.uint8)
|
|
2367
2682
|
};
|
|
2368
2683
|
static createEmpty() {
|
|
2369
2684
|
return new _ClientKeyExchange(void 0);
|
|
2370
2685
|
}
|
|
2371
2686
|
static deSerialize(buf) {
|
|
2372
|
-
const res =
|
|
2687
|
+
const res = decode11(buf, _ClientKeyExchange.spec);
|
|
2373
2688
|
return new _ClientKeyExchange(
|
|
2374
2689
|
...Object.values(res)
|
|
2375
2690
|
);
|
|
2376
2691
|
}
|
|
2377
2692
|
serialize() {
|
|
2378
|
-
|
|
2379
|
-
return Buffer.from(res);
|
|
2693
|
+
return encode12(this, _ClientKeyExchange.spec);
|
|
2380
2694
|
}
|
|
2381
2695
|
toFragment() {
|
|
2382
2696
|
const body = this.serialize();
|
|
@@ -2421,7 +2735,7 @@ var Finished = class _Finished {
|
|
|
2421
2735
|
};
|
|
2422
2736
|
|
|
2423
2737
|
// ../dtls/src/handshake/message/server/certificateRequest.ts
|
|
2424
|
-
|
|
2738
|
+
var { decode: decode12, encode: encode13, types: types14 } = binaryData_exports;
|
|
2425
2739
|
var ServerCertificateRequest = class _ServerCertificateRequest {
|
|
2426
2740
|
constructor(certificateTypes2, signatures2, authorities) {
|
|
2427
2741
|
this.certificateTypes = certificateTypes2;
|
|
@@ -2431,9 +2745,9 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
|
|
|
2431
2745
|
msgType = 13 /* certificate_request_13 */;
|
|
2432
2746
|
messageSeq;
|
|
2433
2747
|
static spec = {
|
|
2434
|
-
certificateTypes:
|
|
2435
|
-
signatures:
|
|
2436
|
-
authorities:
|
|
2748
|
+
certificateTypes: types14.array(ClientCertificateType, types14.uint8, "bytes"),
|
|
2749
|
+
signatures: types14.array(SignatureHashAlgorithm, types14.uint16be, "bytes"),
|
|
2750
|
+
authorities: types14.array(DistinguishedName, types14.uint16be, "bytes")
|
|
2437
2751
|
};
|
|
2438
2752
|
static createEmpty() {
|
|
2439
2753
|
return new _ServerCertificateRequest(
|
|
@@ -2444,12 +2758,11 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
|
|
|
2444
2758
|
}
|
|
2445
2759
|
static deSerialize(buf) {
|
|
2446
2760
|
return new _ServerCertificateRequest(
|
|
2447
|
-
...Object.values(
|
|
2761
|
+
...Object.values(decode12(buf, _ServerCertificateRequest.spec))
|
|
2448
2762
|
);
|
|
2449
2763
|
}
|
|
2450
2764
|
serialize() {
|
|
2451
|
-
|
|
2452
|
-
return Buffer.from(res);
|
|
2765
|
+
return encode13(this, _ServerCertificateRequest.spec);
|
|
2453
2766
|
}
|
|
2454
2767
|
toFragment() {
|
|
2455
2768
|
const body = this.serialize();
|
|
@@ -2465,7 +2778,7 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
|
|
|
2465
2778
|
};
|
|
2466
2779
|
|
|
2467
2780
|
// ../dtls/src/handshake/message/server/hello.ts
|
|
2468
|
-
|
|
2781
|
+
var { decode: decode13, encode: encode14, types: types15 } = binaryData_exports;
|
|
2469
2782
|
var ServerHello = class _ServerHello {
|
|
2470
2783
|
constructor(serverVersion, random, sessionId, cipherSuite, compressionMethod, extensions) {
|
|
2471
2784
|
this.serverVersion = serverVersion;
|
|
@@ -2480,9 +2793,9 @@ var ServerHello = class _ServerHello {
|
|
|
2480
2793
|
static spec = {
|
|
2481
2794
|
serverVersion: ProtocolVersion,
|
|
2482
2795
|
random: DtlsRandom.spec,
|
|
2483
|
-
sessionId:
|
|
2484
|
-
cipherSuite:
|
|
2485
|
-
compressionMethod:
|
|
2796
|
+
sessionId: types15.buffer(types15.uint8),
|
|
2797
|
+
cipherSuite: types15.uint16be,
|
|
2798
|
+
compressionMethod: types15.uint8
|
|
2486
2799
|
};
|
|
2487
2800
|
static createEmpty() {
|
|
2488
2801
|
return new _ServerHello(
|
|
@@ -2495,7 +2808,7 @@ var ServerHello = class _ServerHello {
|
|
|
2495
2808
|
);
|
|
2496
2809
|
}
|
|
2497
2810
|
static deSerialize(buf) {
|
|
2498
|
-
const res =
|
|
2811
|
+
const res = decode13(buf, _ServerHello.spec);
|
|
2499
2812
|
const cls = new _ServerHello(
|
|
2500
2813
|
...Object.values(res)
|
|
2501
2814
|
);
|
|
@@ -2503,18 +2816,17 @@ var ServerHello = class _ServerHello {
|
|
|
2503
2816
|
if (expect.length < buf.length) {
|
|
2504
2817
|
return new _ServerHello(
|
|
2505
2818
|
...Object.values(
|
|
2506
|
-
|
|
2819
|
+
decode13(buf, { ..._ServerHello.spec, extensions: ExtensionList })
|
|
2507
2820
|
)
|
|
2508
2821
|
);
|
|
2509
2822
|
}
|
|
2510
2823
|
return cls;
|
|
2511
2824
|
}
|
|
2512
2825
|
serialize() {
|
|
2513
|
-
|
|
2826
|
+
return this.extensions === void 0 ? encode14(this, _ServerHello.spec) : encode14(this, {
|
|
2514
2827
|
..._ServerHello.spec,
|
|
2515
2828
|
extensions: ExtensionList
|
|
2516
|
-
})
|
|
2517
|
-
return Buffer.from(res);
|
|
2829
|
+
});
|
|
2518
2830
|
}
|
|
2519
2831
|
toFragment() {
|
|
2520
2832
|
const body = this.serialize();
|
|
@@ -2530,7 +2842,7 @@ var ServerHello = class _ServerHello {
|
|
|
2530
2842
|
};
|
|
2531
2843
|
|
|
2532
2844
|
// ../dtls/src/handshake/message/server/helloDone.ts
|
|
2533
|
-
|
|
2845
|
+
var { decode: decode14, encode: encode15 } = binaryData_exports;
|
|
2534
2846
|
var ServerHelloDone = class _ServerHelloDone {
|
|
2535
2847
|
msgType = 14 /* server_hello_done_14 */;
|
|
2536
2848
|
messageSeq;
|
|
@@ -2540,12 +2852,11 @@ var ServerHelloDone = class _ServerHelloDone {
|
|
|
2540
2852
|
}
|
|
2541
2853
|
static deSerialize(buf) {
|
|
2542
2854
|
return new _ServerHelloDone(
|
|
2543
|
-
...Object.values(
|
|
2855
|
+
...Object.values(decode14(buf, _ServerHelloDone.spec))
|
|
2544
2856
|
);
|
|
2545
2857
|
}
|
|
2546
2858
|
serialize() {
|
|
2547
|
-
|
|
2548
|
-
return Buffer.from(res);
|
|
2859
|
+
return encode15(this, _ServerHelloDone.spec);
|
|
2549
2860
|
}
|
|
2550
2861
|
toFragment() {
|
|
2551
2862
|
const body = this.serialize();
|
|
@@ -2560,16 +2871,14 @@ var ServerHelloDone = class _ServerHelloDone {
|
|
|
2560
2871
|
}
|
|
2561
2872
|
};
|
|
2562
2873
|
|
|
2563
|
-
// ../dtls/src/handshake/message/server/keyExchange.ts
|
|
2564
|
-
import { decode as decode14, types as types15 } from "@shinyoshiaki/binary-data";
|
|
2565
|
-
|
|
2566
2874
|
// ../dtls/src/util/binary.ts
|
|
2567
|
-
|
|
2875
|
+
var { encode: encode16 } = binaryData_exports;
|
|
2568
2876
|
function encodeBuffer(obj, spec) {
|
|
2569
|
-
return
|
|
2877
|
+
return encode16(obj, spec);
|
|
2570
2878
|
}
|
|
2571
2879
|
|
|
2572
2880
|
// ../dtls/src/handshake/message/server/keyExchange.ts
|
|
2881
|
+
var { decode: decode15, types: types16 } = binaryData_exports;
|
|
2573
2882
|
var ServerKeyExchange = class _ServerKeyExchange {
|
|
2574
2883
|
constructor(ellipticCurveType, namedCurve, publicKeyLength, publicKey, hashAlgorithm, signatureAlgorithm, signatureLength, signature) {
|
|
2575
2884
|
this.ellipticCurveType = ellipticCurveType;
|
|
@@ -2584,14 +2893,14 @@ var ServerKeyExchange = class _ServerKeyExchange {
|
|
|
2584
2893
|
msgType = 12 /* server_key_exchange_12 */;
|
|
2585
2894
|
messageSeq;
|
|
2586
2895
|
static spec = {
|
|
2587
|
-
ellipticCurveType:
|
|
2588
|
-
namedCurve:
|
|
2589
|
-
publicKeyLength:
|
|
2590
|
-
publicKey:
|
|
2591
|
-
hashAlgorithm:
|
|
2592
|
-
signatureAlgorithm:
|
|
2593
|
-
signatureLength:
|
|
2594
|
-
signature:
|
|
2896
|
+
ellipticCurveType: types16.uint8,
|
|
2897
|
+
namedCurve: types16.uint16be,
|
|
2898
|
+
publicKeyLength: types16.uint8,
|
|
2899
|
+
publicKey: types16.buffer((ctx) => ctx.current.publicKeyLength),
|
|
2900
|
+
hashAlgorithm: types16.uint8,
|
|
2901
|
+
signatureAlgorithm: types16.uint8,
|
|
2902
|
+
signatureLength: types16.uint16be,
|
|
2903
|
+
signature: types16.buffer((ctx) => ctx.current.signatureLength)
|
|
2595
2904
|
};
|
|
2596
2905
|
static createEmpty() {
|
|
2597
2906
|
return new _ServerKeyExchange(
|
|
@@ -2606,7 +2915,7 @@ var ServerKeyExchange = class _ServerKeyExchange {
|
|
|
2606
2915
|
);
|
|
2607
2916
|
}
|
|
2608
2917
|
static deSerialize(buf) {
|
|
2609
|
-
const res =
|
|
2918
|
+
const res = decode15(buf, _ServerKeyExchange.spec);
|
|
2610
2919
|
return new _ServerKeyExchange(
|
|
2611
2920
|
...Object.values(res)
|
|
2612
2921
|
);
|
|
@@ -5716,7 +6025,7 @@ handlers[14 /* server_hello_done_14 */] = ({ dtls }) => (msg) => {
|
|
|
5716
6025
|
};
|
|
5717
6026
|
|
|
5718
6027
|
// ../dtls/src/handshake/message/server/helloVerifyRequest.ts
|
|
5719
|
-
|
|
6028
|
+
var { decode: decode16, encode: encode17, types: types17 } = binaryData_exports;
|
|
5720
6029
|
var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
|
|
5721
6030
|
constructor(serverVersion, cookie) {
|
|
5722
6031
|
this.serverVersion = serverVersion;
|
|
@@ -5726,19 +6035,18 @@ var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
|
|
|
5726
6035
|
messageSeq;
|
|
5727
6036
|
static spec = {
|
|
5728
6037
|
serverVersion: ProtocolVersion,
|
|
5729
|
-
cookie:
|
|
6038
|
+
cookie: types17.buffer(types17.uint8)
|
|
5730
6039
|
};
|
|
5731
6040
|
static createEmpty() {
|
|
5732
6041
|
return new _ServerHelloVerifyRequest(void 0, void 0);
|
|
5733
6042
|
}
|
|
5734
6043
|
static deSerialize(buf) {
|
|
5735
6044
|
return new _ServerHelloVerifyRequest(
|
|
5736
|
-
...Object.values(
|
|
6045
|
+
...Object.values(decode16(buf, _ServerHelloVerifyRequest.spec))
|
|
5737
6046
|
);
|
|
5738
6047
|
}
|
|
5739
6048
|
serialize() {
|
|
5740
|
-
|
|
5741
|
-
return Buffer.from(res);
|
|
6049
|
+
return encode17(this, _ServerHelloVerifyRequest.spec);
|
|
5742
6050
|
}
|
|
5743
6051
|
get version() {
|
|
5744
6052
|
return {
|
|
@@ -5760,7 +6068,6 @@ var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
|
|
|
5760
6068
|
};
|
|
5761
6069
|
|
|
5762
6070
|
// ../dtls/src/socket.ts
|
|
5763
|
-
import { decode as decode19, types as types20 } from "@shinyoshiaki/binary-data";
|
|
5764
6071
|
import { setTimeout as setTimeout3 } from "timers/promises";
|
|
5765
6072
|
|
|
5766
6073
|
// ../dtls/src/context/dtls.ts
|
|
@@ -5825,12 +6132,12 @@ var TransportContext = class {
|
|
|
5825
6132
|
};
|
|
5826
6133
|
|
|
5827
6134
|
// ../dtls/src/handshake/extensions/ellipticCurves.ts
|
|
5828
|
-
|
|
6135
|
+
var { decode: decode17, encode: encode18, types: types18 } = binaryData_exports;
|
|
5829
6136
|
var EllipticCurves = class _EllipticCurves {
|
|
5830
6137
|
static type = 10;
|
|
5831
6138
|
static spec = {
|
|
5832
|
-
type:
|
|
5833
|
-
data:
|
|
6139
|
+
type: types18.uint16be,
|
|
6140
|
+
data: types18.array(types18.uint16be, types18.uint16be, "bytes")
|
|
5834
6141
|
};
|
|
5835
6142
|
type = _EllipticCurves.type;
|
|
5836
6143
|
data = [];
|
|
@@ -5843,14 +6150,14 @@ var EllipticCurves = class _EllipticCurves {
|
|
|
5843
6150
|
static fromData(buf) {
|
|
5844
6151
|
return new _EllipticCurves({
|
|
5845
6152
|
type: _EllipticCurves.type,
|
|
5846
|
-
data:
|
|
6153
|
+
data: decode17(buf, _EllipticCurves.spec.data)
|
|
5847
6154
|
});
|
|
5848
6155
|
}
|
|
5849
6156
|
static deSerialize(buf) {
|
|
5850
|
-
return new _EllipticCurves(
|
|
6157
|
+
return new _EllipticCurves(decode17(buf, _EllipticCurves.spec));
|
|
5851
6158
|
}
|
|
5852
6159
|
serialize() {
|
|
5853
|
-
return
|
|
6160
|
+
return encode18(this, _EllipticCurves.spec);
|
|
5854
6161
|
}
|
|
5855
6162
|
get extension() {
|
|
5856
6163
|
return {
|
|
@@ -5861,14 +6168,14 @@ var EllipticCurves = class _EllipticCurves {
|
|
|
5861
6168
|
};
|
|
5862
6169
|
|
|
5863
6170
|
// ../dtls/src/handshake/extensions/signature.ts
|
|
5864
|
-
|
|
6171
|
+
var { decode: decode18, encode: encode19, types: types19 } = binaryData_exports;
|
|
5865
6172
|
var Signature = class _Signature {
|
|
5866
6173
|
static type = 13;
|
|
5867
6174
|
static spec = {
|
|
5868
|
-
type:
|
|
5869
|
-
data:
|
|
5870
|
-
{ hash:
|
|
5871
|
-
|
|
6175
|
+
type: types19.uint16be,
|
|
6176
|
+
data: types19.array(
|
|
6177
|
+
{ hash: types19.uint8, signature: types19.uint8 },
|
|
6178
|
+
types19.uint16be,
|
|
5872
6179
|
"bytes"
|
|
5873
6180
|
)
|
|
5874
6181
|
};
|
|
@@ -5882,11 +6189,10 @@ var Signature = class _Signature {
|
|
|
5882
6189
|
return v;
|
|
5883
6190
|
}
|
|
5884
6191
|
static deSerialize(buf) {
|
|
5885
|
-
return new _Signature(
|
|
6192
|
+
return new _Signature(decode18(buf, _Signature.spec));
|
|
5886
6193
|
}
|
|
5887
6194
|
serialize() {
|
|
5888
|
-
|
|
5889
|
-
return Buffer.from(res);
|
|
6195
|
+
return encode19(this, _Signature.spec);
|
|
5890
6196
|
}
|
|
5891
6197
|
static fromData(buf) {
|
|
5892
6198
|
const type = Buffer.alloc(2);
|
|
@@ -5902,24 +6208,23 @@ var Signature = class _Signature {
|
|
|
5902
6208
|
};
|
|
5903
6209
|
|
|
5904
6210
|
// ../dtls/src/handshake/message/alert.ts
|
|
5905
|
-
|
|
6211
|
+
var { decode: decode19, encode: encode20, types: types20 } = binaryData_exports;
|
|
5906
6212
|
var Alert = class _Alert {
|
|
5907
6213
|
constructor(level, description) {
|
|
5908
6214
|
this.level = level;
|
|
5909
6215
|
this.description = description;
|
|
5910
6216
|
}
|
|
5911
6217
|
static spec = {
|
|
5912
|
-
level:
|
|
5913
|
-
description:
|
|
6218
|
+
level: types20.uint8,
|
|
6219
|
+
description: types20.uint8
|
|
5914
6220
|
};
|
|
5915
6221
|
static deSerialize(buf) {
|
|
5916
6222
|
return new _Alert(
|
|
5917
|
-
...Object.values(
|
|
6223
|
+
...Object.values(decode19(buf, _Alert.spec))
|
|
5918
6224
|
);
|
|
5919
6225
|
}
|
|
5920
6226
|
serialize() {
|
|
5921
|
-
|
|
5922
|
-
return Buffer.from(res);
|
|
6227
|
+
return encode20(this, _Alert.spec);
|
|
5923
6228
|
}
|
|
5924
6229
|
};
|
|
5925
6230
|
|
|
@@ -6015,6 +6320,7 @@ var parsePlainText = (dtls, cipher) => (plain) => {
|
|
|
6015
6320
|
};
|
|
6016
6321
|
|
|
6017
6322
|
// ../dtls/src/socket.ts
|
|
6323
|
+
var { decode: decode20, types: types21 } = binaryData_exports;
|
|
6018
6324
|
var log12 = debug("werift-dtls : packages/dtls/src/socket.ts : log");
|
|
6019
6325
|
var err4 = debug("werift-dtls : packages/dtls/src/socket.ts : err");
|
|
6020
6326
|
var DtlsSocket = class {
|
|
@@ -6174,13 +6480,13 @@ var DtlsSocket = class {
|
|
|
6174
6480
|
"EXTRACTOR-dtls_srtp",
|
|
6175
6481
|
keyLength2 * 2 + saltLength2 * 2
|
|
6176
6482
|
);
|
|
6177
|
-
const { clientKey, serverKey, clientSalt, serverSalt } =
|
|
6483
|
+
const { clientKey, serverKey, clientSalt, serverSalt } = decode20(
|
|
6178
6484
|
keyingMaterial,
|
|
6179
6485
|
{
|
|
6180
|
-
clientKey:
|
|
6181
|
-
serverKey:
|
|
6182
|
-
clientSalt:
|
|
6183
|
-
serverSalt:
|
|
6486
|
+
clientKey: types21.buffer(keyLength2),
|
|
6487
|
+
serverKey: types21.buffer(keyLength2),
|
|
6488
|
+
clientSalt: types21.buffer(saltLength2),
|
|
6489
|
+
serverSalt: types21.buffer(saltLength2)
|
|
6184
6490
|
}
|
|
6185
6491
|
);
|
|
6186
6492
|
if (this.sessionType === SessionType.CLIENT) {
|
|
@@ -6788,20 +7094,20 @@ function encodeTcpFrame(data) {
|
|
|
6788
7094
|
header.writeUInt16BE(data.length, 0);
|
|
6789
7095
|
return Buffer.concat([header, data]);
|
|
6790
7096
|
}
|
|
6791
|
-
function splitTcpFrames(
|
|
7097
|
+
function splitTcpFrames(buffer3) {
|
|
6792
7098
|
const frames = [];
|
|
6793
7099
|
let offset = 0;
|
|
6794
|
-
while (
|
|
6795
|
-
const length =
|
|
6796
|
-
if (
|
|
7100
|
+
while (buffer3.length - offset >= 2) {
|
|
7101
|
+
const length = buffer3.readUInt16BE(offset);
|
|
7102
|
+
if (buffer3.length - offset < length + 2) {
|
|
6797
7103
|
break;
|
|
6798
7104
|
}
|
|
6799
|
-
frames.push(
|
|
7105
|
+
frames.push(buffer3.subarray(offset + 2, offset + 2 + length));
|
|
6800
7106
|
offset += 2 + length;
|
|
6801
7107
|
}
|
|
6802
7108
|
return {
|
|
6803
7109
|
frames,
|
|
6804
|
-
rest:
|
|
7110
|
+
rest: buffer3.subarray(offset)
|
|
6805
7111
|
};
|
|
6806
7112
|
}
|
|
6807
7113
|
|
|
@@ -6882,11 +7188,11 @@ function isIpV4Address(address) {
|
|
|
6882
7188
|
function packAddress(value) {
|
|
6883
7189
|
const [address] = value;
|
|
6884
7190
|
const protocol = isIpV4Address(address) ? IPV4_PROTOCOL : IPV6_PROTOCOL;
|
|
6885
|
-
const
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
return Buffer.concat([
|
|
7191
|
+
const buffer3 = Buffer.alloc(4);
|
|
7192
|
+
buffer3.writeUInt8(0, 0);
|
|
7193
|
+
buffer3.writeUInt8(protocol, 1);
|
|
7194
|
+
buffer3.writeUInt16BE(value[1], 2);
|
|
7195
|
+
return Buffer.concat([buffer3, ipAddressToBuffer(address)]);
|
|
6890
7196
|
}
|
|
6891
7197
|
function unpackErrorCode(data) {
|
|
6892
7198
|
if (data.length < 4) {
|
|
@@ -6937,19 +7243,19 @@ function unpackXorAddress(data, transactionId) {
|
|
|
6937
7243
|
return unpackAddress(xorAddress(data, transactionId));
|
|
6938
7244
|
}
|
|
6939
7245
|
function packErrorCode(value) {
|
|
6940
|
-
const
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
7246
|
+
const buffer3 = Buffer.alloc(4);
|
|
7247
|
+
buffer3.writeUInt16BE(0, 0);
|
|
7248
|
+
buffer3.writeUInt8(Math.floor(value[0] / 100), 2);
|
|
7249
|
+
buffer3.writeUInt8(value[0] % 100, 3);
|
|
6944
7250
|
const encoded = Buffer.from(value[1], "utf8");
|
|
6945
|
-
return Buffer.concat([
|
|
7251
|
+
return Buffer.concat([buffer3, encoded]);
|
|
6946
7252
|
}
|
|
6947
7253
|
function packUnknownAttributes(value) {
|
|
6948
|
-
const
|
|
7254
|
+
const buffer3 = Buffer.alloc(value.length * 2);
|
|
6949
7255
|
value.forEach((attributeType, index) => {
|
|
6950
|
-
|
|
7256
|
+
buffer3.writeUInt16BE(attributeType, index * 2);
|
|
6951
7257
|
});
|
|
6952
|
-
return
|
|
7258
|
+
return buffer3;
|
|
6953
7259
|
}
|
|
6954
7260
|
function unpackUnknownAttributes(data) {
|
|
6955
7261
|
if (data.length % 2 !== 0) {
|
|
@@ -6965,21 +7271,21 @@ function packXorAddress(value, transactionId) {
|
|
|
6965
7271
|
return xorAddress(packAddress(value), transactionId);
|
|
6966
7272
|
}
|
|
6967
7273
|
var packUnsigned = (value) => {
|
|
6968
|
-
const
|
|
6969
|
-
|
|
6970
|
-
return
|
|
7274
|
+
const buffer3 = Buffer.alloc(4);
|
|
7275
|
+
buffer3.writeUInt32BE(value, 0);
|
|
7276
|
+
return buffer3;
|
|
6971
7277
|
};
|
|
6972
7278
|
var unpackUnsigned = (data) => data.readUInt32BE(0);
|
|
6973
7279
|
var packUnsignedShort = (value) => {
|
|
6974
|
-
const
|
|
6975
|
-
|
|
6976
|
-
return
|
|
7280
|
+
const buffer3 = Buffer.alloc(4);
|
|
7281
|
+
buffer3.writeUInt16BE(value, 0);
|
|
7282
|
+
return buffer3;
|
|
6977
7283
|
};
|
|
6978
7284
|
var unpackUnsignedShort = (data) => data.readUInt16BE(0);
|
|
6979
7285
|
var packUnsigned64 = (value) => {
|
|
6980
|
-
const
|
|
6981
|
-
|
|
6982
|
-
return
|
|
7286
|
+
const buffer3 = Buffer.allocUnsafe(8);
|
|
7287
|
+
buffer3.writeBigUInt64BE(value, 0);
|
|
7288
|
+
return buffer3;
|
|
6983
7289
|
};
|
|
6984
7290
|
var unpackUnsigned64 = (data) => data.readBigUInt64BE(0);
|
|
6985
7291
|
var packString = (value) => Buffer.from(value, "utf8");
|
|
@@ -8012,35 +8318,35 @@ function padTurnFrame(data) {
|
|
|
8012
8318
|
const padding = paddingLength(data.length);
|
|
8013
8319
|
return padding > 0 ? Buffer.concat([data, Buffer.alloc(padding)]) : data;
|
|
8014
8320
|
}
|
|
8015
|
-
function splitTurnTcpFrames(
|
|
8321
|
+
function splitTurnTcpFrames(buffer3) {
|
|
8016
8322
|
const frames = [];
|
|
8017
8323
|
let offset = 0;
|
|
8018
8324
|
let malformed = false;
|
|
8019
|
-
while (
|
|
8325
|
+
while (buffer3.length - offset >= 4) {
|
|
8020
8326
|
let frameLength;
|
|
8021
|
-
if (isChannelData(
|
|
8022
|
-
const payloadLength =
|
|
8327
|
+
if (isChannelData(buffer3.subarray(offset))) {
|
|
8328
|
+
const payloadLength = buffer3.readUInt16BE(offset + 2);
|
|
8023
8329
|
frameLength = 4 + payloadLength + paddingLength(payloadLength);
|
|
8024
|
-
} else if ((
|
|
8025
|
-
if (
|
|
8330
|
+
} else if ((buffer3[offset] & 192) === 0) {
|
|
8331
|
+
if (buffer3.length - offset < 20) {
|
|
8026
8332
|
break;
|
|
8027
8333
|
}
|
|
8028
|
-
const stunBodyLength =
|
|
8334
|
+
const stunBodyLength = buffer3.readUInt16BE(offset + 2);
|
|
8029
8335
|
frameLength = 20 + stunBodyLength + paddingLength(stunBodyLength);
|
|
8030
8336
|
} else {
|
|
8031
8337
|
malformed = true;
|
|
8032
8338
|
break;
|
|
8033
8339
|
}
|
|
8034
|
-
if (
|
|
8340
|
+
if (buffer3.length - offset < frameLength) {
|
|
8035
8341
|
break;
|
|
8036
8342
|
}
|
|
8037
|
-
frames.push(
|
|
8343
|
+
frames.push(buffer3.subarray(offset, offset + frameLength));
|
|
8038
8344
|
offset += frameLength;
|
|
8039
8345
|
}
|
|
8040
8346
|
return {
|
|
8041
8347
|
frames,
|
|
8042
8348
|
malformed,
|
|
8043
|
-
rest:
|
|
8349
|
+
rest: buffer3.subarray(offset)
|
|
8044
8350
|
};
|
|
8045
8351
|
}
|
|
8046
8352
|
|
|
@@ -16166,11 +16472,11 @@ var RtpRouter = class {
|
|
|
16166
16472
|
}
|
|
16167
16473
|
registerRtpReceiverBySsrc(transceiver, params) {
|
|
16168
16474
|
log33("registerRtpReceiverBySsrc", params);
|
|
16169
|
-
params.encodings.filter((e) => e.ssrc != void 0).forEach((
|
|
16170
|
-
this.registerRtpReceiver(transceiver.receiver,
|
|
16475
|
+
params.encodings.filter((e) => e.ssrc != void 0).forEach((encode21, i) => {
|
|
16476
|
+
this.registerRtpReceiver(transceiver.receiver, encode21.ssrc);
|
|
16171
16477
|
transceiver.addTrack(
|
|
16172
16478
|
new MediaStreamTrack({
|
|
16173
|
-
ssrc:
|
|
16479
|
+
ssrc: encode21.ssrc,
|
|
16174
16480
|
kind: transceiver.kind,
|
|
16175
16481
|
id: transceiver.sender.trackId,
|
|
16176
16482
|
remote: true,
|
|
@@ -16181,8 +16487,8 @@ var RtpRouter = class {
|
|
|
16181
16487
|
)
|
|
16182
16488
|
})
|
|
16183
16489
|
);
|
|
16184
|
-
if (
|
|
16185
|
-
this.registerRtpReceiver(transceiver.receiver,
|
|
16490
|
+
if (encode21.rtx) {
|
|
16491
|
+
this.registerRtpReceiver(transceiver.receiver, encode21.rtx.ssrc);
|
|
16186
16492
|
}
|
|
16187
16493
|
});
|
|
16188
16494
|
params.headerExtensions.forEach((extension) => {
|
|
@@ -20673,6 +20979,7 @@ export {
|
|
|
20673
20979
|
andDirection,
|
|
20674
20980
|
applyCodecPreferences,
|
|
20675
20981
|
assertCodecsSupported,
|
|
20982
|
+
binaryData_exports as binaryData,
|
|
20676
20983
|
buffer2ArrayBuffer,
|
|
20677
20984
|
bufferArrayXor,
|
|
20678
20985
|
bufferReader,
|