werift 0.25.0-alpha.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.
Files changed (80) hide show
  1. package/lib/common/src/binaryData.d.ts +116 -0
  2. package/lib/common/src/binaryData.js +421 -0
  3. package/lib/common/src/binaryData.js.map +1 -0
  4. package/lib/common/src/index.d.ts +1 -0
  5. package/lib/common/src/index.js +24 -0
  6. package/lib/common/src/index.js.map +1 -1
  7. package/lib/dtls/src/cipher/prf.d.ts +2 -2
  8. package/lib/dtls/src/cipher/prf.js +2 -2
  9. package/lib/dtls/src/cipher/prf.js.map +1 -1
  10. package/lib/dtls/src/context/cipher.js +4 -3
  11. package/lib/dtls/src/context/cipher.js.map +1 -1
  12. package/lib/dtls/src/handshake/binary.d.ts +12 -8
  13. package/lib/dtls/src/handshake/binary.js +3 -2
  14. package/lib/dtls/src/handshake/binary.js.map +1 -1
  15. package/lib/dtls/src/handshake/extensions/ellipticCurves.d.ts +4 -3
  16. package/lib/dtls/src/handshake/extensions/ellipticCurves.js +7 -6
  17. package/lib/dtls/src/handshake/extensions/ellipticCurves.js.map +1 -1
  18. package/lib/dtls/src/handshake/extensions/renegotiationIndication.d.ts +4 -3
  19. package/lib/dtls/src/handshake/extensions/renegotiationIndication.js +6 -6
  20. package/lib/dtls/src/handshake/extensions/renegotiationIndication.js.map +1 -1
  21. package/lib/dtls/src/handshake/extensions/signature.d.ts +7 -3
  22. package/lib/dtls/src/handshake/extensions/signature.js +6 -6
  23. package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
  24. package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +4 -3
  25. package/lib/dtls/src/handshake/extensions/useSrtp.js +6 -6
  26. package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
  27. package/lib/dtls/src/handshake/message/alert.d.ts +4 -3
  28. package/lib/dtls/src/handshake/message/alert.js +6 -6
  29. package/lib/dtls/src/handshake/message/alert.js.map +1 -1
  30. package/lib/dtls/src/handshake/message/certificate.d.ts +3 -2
  31. package/lib/dtls/src/handshake/message/certificate.js +5 -5
  32. package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
  33. package/lib/dtls/src/handshake/message/changeCipherSpec.d.ts +3 -2
  34. package/lib/dtls/src/handshake/message/changeCipherSpec.js +5 -5
  35. package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
  36. package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +4 -3
  37. package/lib/dtls/src/handshake/message/client/certificateVerify.js +6 -6
  38. package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
  39. package/lib/dtls/src/handshake/message/client/hello.d.ts +14 -10
  40. package/lib/dtls/src/handshake/message/client/hello.js +9 -9
  41. package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
  42. package/lib/dtls/src/handshake/message/client/keyExchange.d.ts +3 -2
  43. package/lib/dtls/src/handshake/message/client/keyExchange.js +5 -5
  44. package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
  45. package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +8 -4
  46. package/lib/dtls/src/handshake/message/server/certificateRequest.js +7 -7
  47. package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
  48. package/lib/dtls/src/handshake/message/server/hello.d.ts +9 -8
  49. package/lib/dtls/src/handshake/message/server/hello.js +11 -11
  50. package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
  51. package/lib/dtls/src/handshake/message/server/helloDone.d.ts +1 -1
  52. package/lib/dtls/src/handshake/message/server/helloDone.js +4 -4
  53. package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
  54. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.d.ts +5 -4
  55. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +5 -5
  56. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
  57. package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +10 -9
  58. package/lib/dtls/src/handshake/message/server/keyExchange.js +11 -10
  59. package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
  60. package/lib/dtls/src/handshake/random.d.ts +5 -4
  61. package/lib/dtls/src/handshake/random.js +6 -6
  62. package/lib/dtls/src/handshake/random.js.map +1 -1
  63. package/lib/dtls/src/record/message/fragment.d.ts +8 -7
  64. package/lib/dtls/src/record/message/fragment.js +10 -10
  65. package/lib/dtls/src/record/message/fragment.js.map +1 -1
  66. package/lib/dtls/src/record/message/header.d.ts +8 -7
  67. package/lib/dtls/src/record/message/header.js +8 -8
  68. package/lib/dtls/src/record/message/header.js.map +1 -1
  69. package/lib/dtls/src/record/message/plaintext.d.ts +1 -1
  70. package/lib/dtls/src/socket.d.ts +4 -4
  71. package/lib/dtls/src/socket.js +6 -6
  72. package/lib/dtls/src/socket.js.map +1 -1
  73. package/lib/dtls/src/util/binary.d.ts +2 -1
  74. package/lib/dtls/src/util/binary.js +3 -2
  75. package/lib/dtls/src/util/binary.js.map +1 -1
  76. package/lib/index.mjs +517 -210
  77. package/lib/nonstandard/index.mjs +500 -194
  78. package/lib/polyfill/dom.mjs +538 -232
  79. package/lib/polyfill/index.mjs +538 -232
  80. package/package.json +1 -2
@@ -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
  // ../rtp/src/extra/container/mp4/container.ts
2
8
  import {
3
9
  EncodedAudioPacketSource,
@@ -23,19 +29,19 @@ function bufferXor(a, b) {
23
29
  );
24
30
  }
25
31
  const length = a.length;
26
- const buffer2 = Buffer.allocUnsafe(length);
32
+ const buffer3 = Buffer.allocUnsafe(length);
27
33
  for (let i = 0; i < length; i++) {
28
- buffer2[i] = a[i] ^ b[i];
34
+ buffer3[i] = a[i] ^ b[i];
29
35
  }
30
- return buffer2;
36
+ return buffer3;
31
37
  }
32
38
  function bufferArrayXor(arr) {
33
39
  const length = [...arr].sort((a, b) => a.length - b.length).reverse()[0].length;
34
40
  const xored = Buffer.allocUnsafe(length);
35
41
  for (let i = 0; i < length; i++) {
36
42
  xored[i] = 0;
37
- arr.forEach((buffer2) => {
38
- xored[i] ^= buffer2[i] ?? 0;
43
+ arr.forEach((buffer3) => {
44
+ xored[i] ^= buffer3[i] ?? 0;
39
45
  });
40
46
  }
41
47
  return xored;
@@ -927,6 +933,331 @@ function stripZoneId(address) {
927
933
  return address.split("%")[0];
928
934
  }
929
935
 
936
+ // ../common/src/binaryData.ts
937
+ var binaryData_exports = {};
938
+ __export(binaryData_exports, {
939
+ BinaryReader: () => BinaryReader,
940
+ BinaryWriter: () => BinaryWriter,
941
+ NotEnoughDataError: () => NotEnoughDataError,
942
+ decode: () => decode,
943
+ encode: () => encode,
944
+ types: () => types
945
+ });
946
+ var NotEnoughDataError = class extends Error {
947
+ constructor(expected, received) {
948
+ super(`requested ${expected} bytes but only ${received} available`);
949
+ this.name = "NotEnoughDataError";
950
+ }
951
+ };
952
+ var BinaryReader = class {
953
+ constructor(buf) {
954
+ this.buf = buf;
955
+ }
956
+ offset = 0;
957
+ /** The number of unread bytes. */
958
+ get length() {
959
+ return this.buf.length - this.offset;
960
+ }
961
+ /** The number of bytes consumed so far. */
962
+ get bytes() {
963
+ return this.offset;
964
+ }
965
+ readBuffer(size) {
966
+ this.assertSize(size);
967
+ const res = this.buf.subarray(this.offset, this.offset + size);
968
+ this.offset += size;
969
+ return res;
970
+ }
971
+ readUIntBE(size) {
972
+ this.assertSize(size);
973
+ const res = this.buf.readUIntBE(this.offset, size);
974
+ this.offset += size;
975
+ return res;
976
+ }
977
+ assertSize(size) {
978
+ if (size > this.length) {
979
+ throw new NotEnoughDataError(size, this.length);
980
+ }
981
+ }
982
+ };
983
+ var BinaryWriter = class {
984
+ chunks = [];
985
+ written = 0;
986
+ /** The number of bytes written so far. */
987
+ get bytes() {
988
+ return this.written;
989
+ }
990
+ writeBuffer(buf) {
991
+ this.chunks.push(buf);
992
+ this.written += buf.length;
993
+ }
994
+ writeUIntBE(value, size) {
995
+ const buf = Buffer.allocUnsafe(size);
996
+ switch (size) {
997
+ case 1:
998
+ buf.writeUInt8(value, 0);
999
+ break;
1000
+ case 2:
1001
+ buf.writeUInt16BE(value, 0);
1002
+ break;
1003
+ case 4:
1004
+ buf.writeUInt32BE(value, 0);
1005
+ break;
1006
+ default:
1007
+ buf.writeUIntBE(value, 0, size);
1008
+ }
1009
+ this.writeBuffer(buf);
1010
+ }
1011
+ toBuffer() {
1012
+ return Buffer.concat(this.chunks, this.written);
1013
+ }
1014
+ };
1015
+ var isObject = (value) => typeof value === "object" && value !== null;
1016
+ var isType = (value) => isObject(value) && typeof value.encode === "function" && typeof value.decode === "function";
1017
+ var isPlainObject = (value) => {
1018
+ if (!isObject(value)) return false;
1019
+ const proto = Object.getPrototypeOf(value);
1020
+ return proto === Object.prototype || proto === null;
1021
+ };
1022
+ var createContext = () => ({
1023
+ node: void 0,
1024
+ current: void 0
1025
+ });
1026
+ var cloneContext = (context) => ({
1027
+ node: context.node,
1028
+ current: context.current
1029
+ });
1030
+ var assertSchema = (schema, message) => {
1031
+ if (!isPlainObject(schema)) {
1032
+ throw new TypeError(message);
1033
+ }
1034
+ };
1035
+ var encodeCommon = (value, typeOrSchema, writer, context) => {
1036
+ if (isType(typeOrSchema)) {
1037
+ typeOrSchema.encode(value, writer, context);
1038
+ } else {
1039
+ encodeSchema(value, typeOrSchema, writer, context);
1040
+ }
1041
+ };
1042
+ var encodeSchema = (obj, schema, writer, context) => {
1043
+ assertSchema(schema, "Argument `schema` should be a plain object.");
1044
+ if (context.node === void 0) {
1045
+ context.node = obj;
1046
+ }
1047
+ context.current = obj;
1048
+ for (const key of Object.keys(schema)) {
1049
+ const type = schema[key];
1050
+ const value = obj[key];
1051
+ if (isType(type)) {
1052
+ type.encode(value, writer, context);
1053
+ } else {
1054
+ encodeSchema(value, type, writer, context);
1055
+ context.current = obj;
1056
+ }
1057
+ }
1058
+ };
1059
+ var decodeCommon = (reader, typeOrSchema, context) => {
1060
+ if (isType(typeOrSchema)) {
1061
+ return typeOrSchema.decode(reader, context);
1062
+ }
1063
+ return decodeSchema(reader, typeOrSchema, context);
1064
+ };
1065
+ var decodeSchema = (reader, schema, context) => {
1066
+ assertSchema(schema, "Argument #2 should be a plain object.");
1067
+ const node = /* @__PURE__ */ Object.create(null);
1068
+ if (context.node === void 0) {
1069
+ context.node = node;
1070
+ }
1071
+ context.current = node;
1072
+ for (const key of Object.keys(schema)) {
1073
+ const type = schema[key];
1074
+ if (isType(type)) {
1075
+ node[key] = type.decode(reader, context);
1076
+ } else {
1077
+ node[key] = decodeSchema(reader, type, context);
1078
+ context.current = node;
1079
+ }
1080
+ }
1081
+ return node;
1082
+ };
1083
+ function encode(obj, typeOrSchema) {
1084
+ const writer = new BinaryWriter();
1085
+ encodeCommon(obj, typeOrSchema, writer, createContext());
1086
+ return writer.toBuffer();
1087
+ }
1088
+ function decode(buf, typeOrSchema) {
1089
+ return decodeCommon(new BinaryReader(buf), typeOrSchema, createContext());
1090
+ }
1091
+ var createUIntBE = (size) => ({
1092
+ encode: (value, writer) => writer.writeUIntBE(value, size),
1093
+ decode: (reader) => reader.readUIntBE(size)
1094
+ });
1095
+ var assertLengthSpec = (length) => {
1096
+ if (typeof length !== "number" && !isType(length) && typeof length !== "function") {
1097
+ throw new TypeError("Unknown type of argument #1.");
1098
+ }
1099
+ };
1100
+ var checkLength = (required, having, name) => {
1101
+ if (required !== having) {
1102
+ throw new Error(`${name} required length ${required} instead of ${having}`);
1103
+ }
1104
+ };
1105
+ var checkLengthType = (length, message) => {
1106
+ if (typeof length !== "number") {
1107
+ throw new TypeError(message);
1108
+ }
1109
+ };
1110
+ function buffer(length) {
1111
+ assertLengthSpec(length);
1112
+ const lengthTypeError = "Length of a buffer should be a number.";
1113
+ return {
1114
+ encode(buf, writer, context) {
1115
+ if (!Buffer.isBuffer(buf)) {
1116
+ throw new TypeError("Argument 1 should be a Buffer or a BinaryStream.");
1117
+ }
1118
+ if (typeof length === "number") {
1119
+ checkLength(length, buf.length, "Buffer");
1120
+ } else if (isType(length)) {
1121
+ length.encode(buf.length, writer, context);
1122
+ } else {
1123
+ const expected = length(context);
1124
+ checkLengthType(expected, lengthTypeError);
1125
+ checkLength(expected, buf.length, "Buffer");
1126
+ }
1127
+ writer.writeBuffer(buf);
1128
+ },
1129
+ decode(reader, context) {
1130
+ let size;
1131
+ if (typeof length === "number") {
1132
+ size = length;
1133
+ } else if (isType(length)) {
1134
+ size = length.decode(reader, context);
1135
+ } else {
1136
+ size = length(context);
1137
+ }
1138
+ checkLengthType(size, lengthTypeError);
1139
+ return reader.readBuffer(size);
1140
+ }
1141
+ };
1142
+ }
1143
+ function array(type, length, lengthType = "count") {
1144
+ if (!isType(type) && !isPlainObject(type)) {
1145
+ throw new TypeError("Argument #1 should be a valid type.");
1146
+ }
1147
+ assertLengthSpec(length);
1148
+ const isLengthInBytes = lengthType === "bytes";
1149
+ const sizeTypeError = "Length of an array should be a number.";
1150
+ return {
1151
+ encode(items, writer, parent) {
1152
+ if (!Array.isArray(items)) {
1153
+ throw new TypeError("Argument #1 should be an Array.");
1154
+ }
1155
+ const context = cloneContext(parent);
1156
+ let expectedSize = 0;
1157
+ if (typeof length === "number") {
1158
+ expectedSize = length;
1159
+ } else if (isType(length)) {
1160
+ expectedSize = items.length;
1161
+ } else {
1162
+ expectedSize = length(context);
1163
+ checkLengthType(expectedSize, sizeTypeError);
1164
+ }
1165
+ const body = new BinaryWriter();
1166
+ for (const item of items) {
1167
+ encodeCommon(item, type, body, context);
1168
+ }
1169
+ if (isLengthInBytes) {
1170
+ if (isType(length)) {
1171
+ expectedSize = body.bytes;
1172
+ }
1173
+ checkLength(body.bytes, expectedSize, "Argument #1");
1174
+ } else {
1175
+ checkLength(expectedSize, items.length, "Argument #1");
1176
+ }
1177
+ if (isType(length)) {
1178
+ length.encode(expectedSize, writer, context);
1179
+ }
1180
+ writer.writeBuffer(body.toBuffer());
1181
+ },
1182
+ decode(reader, parent) {
1183
+ const context = cloneContext(parent);
1184
+ let expectedSize;
1185
+ if (typeof length === "number") {
1186
+ expectedSize = length;
1187
+ } else if (isType(length)) {
1188
+ expectedSize = length.decode(reader, context);
1189
+ } else {
1190
+ expectedSize = length(context);
1191
+ }
1192
+ checkLengthType(expectedSize, sizeTypeError);
1193
+ const items = [];
1194
+ if (isLengthInBytes) {
1195
+ const before = reader.bytes;
1196
+ let bytes2 = 0;
1197
+ while (bytes2 < expectedSize) {
1198
+ items.push(decodeCommon(reader, type, context));
1199
+ bytes2 = reader.bytes - before;
1200
+ }
1201
+ if (bytes2 > expectedSize) {
1202
+ throw new Error("Incorrect length of an array.");
1203
+ }
1204
+ } else {
1205
+ for (let i = 0; i < expectedSize; i++) {
1206
+ items.push(decodeCommon(reader, type, context));
1207
+ }
1208
+ }
1209
+ return items;
1210
+ }
1211
+ };
1212
+ }
1213
+ function string(length, encoding = "ascii") {
1214
+ if (!Buffer.isEncoding(encoding)) {
1215
+ throw new Error("Argument #2 should be an encoding name.");
1216
+ }
1217
+ assertLengthSpec(length);
1218
+ const lengthTypeError = "Length of a buffer should be a number.";
1219
+ return {
1220
+ encode(value, writer, context) {
1221
+ const buf = Buffer.from(value.toString(), encoding);
1222
+ if (typeof length === "number") {
1223
+ if (buf.length !== length) {
1224
+ throw new Error(`Size of string should be ${length} in bytes.`);
1225
+ }
1226
+ } else if (isType(length)) {
1227
+ length.encode(buf.length, writer, context);
1228
+ } else {
1229
+ const expected = length(context);
1230
+ checkLengthType(expected, lengthTypeError);
1231
+ checkLength(expected, buf.length, "Buffer");
1232
+ }
1233
+ writer.writeBuffer(buf);
1234
+ },
1235
+ decode(reader, context) {
1236
+ let size;
1237
+ if (typeof length === "number") {
1238
+ size = length;
1239
+ } else if (isType(length)) {
1240
+ size = length.decode(reader, context);
1241
+ checkLengthType(size, "Size of a string should be a number.");
1242
+ } else {
1243
+ size = length(context);
1244
+ checkLengthType(size, lengthTypeError);
1245
+ }
1246
+ return reader.readBuffer(size).toString(encoding);
1247
+ }
1248
+ };
1249
+ }
1250
+ var types = {
1251
+ uint8: createUIntBE(1),
1252
+ uint16be: createUIntBE(2),
1253
+ uint24be: createUIntBE(3),
1254
+ uint32be: createUIntBE(4),
1255
+ uint48be: createUIntBE(6),
1256
+ buffer,
1257
+ array,
1258
+ string
1259
+ };
1260
+
930
1261
  // ../rtp/src/extra/container/mp4/container.ts
931
1262
  var Mp4Container = class {
932
1263
  constructor(props) {
@@ -2629,7 +2960,7 @@ var decodeVintEncodedNumber = (buf, offset = 0) => {
2629
2960
  }
2630
2961
  return { value, length };
2631
2962
  };
2632
- var string = (str) => {
2963
+ var string2 = (str) => {
2633
2964
  return bytes(stringToByteArray(str));
2634
2965
  };
2635
2966
  var element = (id, child) => {
@@ -2961,7 +3292,7 @@ var WEBMContainer = class {
2961
3292
  element(ID.EBMLReadVersion, number(1)),
2962
3293
  element(ID.EBMLMaxIDLength, number(4)),
2963
3294
  element(ID.EBMLMaxSizeLength, number(8)),
2964
- element(ID.DocType, string("webm")),
3295
+ element(ID.DocType, string2("webm")),
2965
3296
  element(ID.DocTypeVersion, number(2)),
2966
3297
  element(ID.DocTypeReadVersion, number(2))
2967
3298
  ])
@@ -3051,11 +3382,11 @@ var WEBMContainer = class {
3051
3382
  const trackEntry = element(ID.TrackEntry, [
3052
3383
  element(ID.TrackNumber, number(trackNumber)),
3053
3384
  element(ID.TrackUID, number(trackNumber)),
3054
- element(ID.CodecName, string(codec)),
3385
+ element(ID.CodecName, string2(codec)),
3055
3386
  element(ID.TrackType, number(kind === "video" ? 1 : 2)),
3056
3387
  element(
3057
3388
  ID.CodecID,
3058
- string(`${kind === "video" ? "V" : "A"}_${codec}`)
3389
+ string2(`${kind === "video" ? "V" : "A"}_${codec}`)
3059
3390
  ),
3060
3391
  ...trackElements
3061
3392
  ]);
@@ -3064,8 +3395,8 @@ var WEBMContainer = class {
3064
3395
  createSegment(duration) {
3065
3396
  const elements = [
3066
3397
  element(ID.TimecodeScale, number(millisecond)),
3067
- element(ID.MuxingApp, string("webrtc")),
3068
- element(ID.WritingApp, string("webrtc"))
3398
+ element(ID.MuxingApp, string2("webrtc")),
3399
+ element(ID.WritingApp, string2("webrtc"))
3069
3400
  ];
3070
3401
  if (duration != void 0) {
3071
3402
  elements.push(element(ID.Duration, float(duration)));
@@ -5878,18 +6209,18 @@ var JitterBufferBase = class {
5878
6209
  return resolve;
5879
6210
  }
5880
6211
  sortAndClearBuffer(rtpBuffer) {
5881
- const buffer2 = [];
6212
+ const buffer3 = [];
5882
6213
  for (let index = this.presentSeqNum ?? 0; ; index = uint16Add(index, 1)) {
5883
6214
  const rtp = rtpBuffer[index];
5884
6215
  if (rtp) {
5885
- buffer2.push(rtp);
6216
+ buffer3.push(rtp);
5886
6217
  delete rtpBuffer[index];
5887
6218
  }
5888
6219
  if (Object.values(rtpBuffer).length === 0) {
5889
6220
  break;
5890
6221
  }
5891
6222
  }
5892
- return buffer2;
6223
+ return buffer3;
5893
6224
  }
5894
6225
  disposeTimeoutPackets(baseTimestamp) {
5895
6226
  let latestTimeoutSeqNum;
@@ -6066,7 +6397,7 @@ var LipsyncBase = class {
6066
6397
  }
6067
6398
  this.processInput(frame, this.videoBuffer, "video");
6068
6399
  };
6069
- processInput = (frame, buffer2, kind) => {
6400
+ processInput = (frame, buffer3, kind) => {
6070
6401
  if (this.stopped) {
6071
6402
  return;
6072
6403
  }
@@ -6096,7 +6427,7 @@ var LipsyncBase = class {
6096
6427
  this.lastFrameReceivedAt = now;
6097
6428
  const elapsed = frame.time - this.baseTime;
6098
6429
  const index = int(elapsed / this.bufferDuration) % this.bufferLength;
6099
- buffer2[index].push({
6430
+ buffer3[index].push({
6100
6431
  frame,
6101
6432
  kind
6102
6433
  });
@@ -6318,10 +6649,10 @@ function avccToCodecString(avcc) {
6318
6649
  function toHex(value) {
6319
6650
  return value.toString(16).padStart(2, "0");
6320
6651
  }
6321
- function toArrayBuffer(buffer2) {
6322
- return buffer2.buffer.slice(
6323
- buffer2.byteOffset,
6324
- buffer2.byteOffset + buffer2.byteLength
6652
+ function toArrayBuffer(buffer3) {
6653
+ return buffer3.buffer.slice(
6654
+ buffer3.byteOffset,
6655
+ buffer3.byteOffset + buffer3.byteLength
6325
6656
  );
6326
6657
  }
6327
6658
 
@@ -6403,13 +6734,13 @@ var MuteHandlerBase = class {
6403
6734
  }
6404
6735
  executeTask() {
6405
6736
  const { ptime, dummyPacket } = this.props;
6406
- const buffer2 = this.buffer[this.index].sort((a, b) => a.time - b.time);
6407
- const last = buffer2.at(-1);
6737
+ const buffer3 = this.buffer[this.index].sort((a, b) => a.time - b.time);
6738
+ const last = buffer3.at(-1);
6408
6739
  const expect = last ? last.time + // offset
6409
6740
  ptime : this.currentTimestamp;
6410
6741
  if (expect < this.currentTimestamp + this.bufferDuration) {
6411
6742
  for (let time = expect; time < this.currentTimestamp + this.bufferDuration; time += ptime) {
6412
- buffer2.push({
6743
+ buffer3.push({
6413
6744
  time,
6414
6745
  data: dummyPacket,
6415
6746
  isKeyframe: true
@@ -6419,7 +6750,7 @@ var MuteHandlerBase = class {
6419
6750
  this.currentTimestamp += this.bufferDuration;
6420
6751
  this.internalStats["mute"] = (/* @__PURE__ */ new Date()).toISOString();
6421
6752
  this.buffer[this.index] = [];
6422
- buffer2.forEach((frame) => {
6753
+ buffer3.forEach((frame) => {
6423
6754
  this.output({ frame });
6424
6755
  this.lastCommittedTime = frame.time;
6425
6756
  });
@@ -7345,7 +7676,6 @@ import { createSocket as createSocket3 } from "dgram";
7345
7676
  import { createSign, randomBytes as randomBytes3, webcrypto } from "crypto";
7346
7677
  import { Certificate, PrivateKey } from "@fidm/x509";
7347
7678
  import * as x509 from "@peculiar/x509";
7348
- import { encode, types } from "@shinyoshiaki/binary-data";
7349
7679
 
7350
7680
  // ../dtls/src/cipher/const.ts
7351
7681
  var SignatureAlgorithm = {
@@ -7375,7 +7705,6 @@ var signatures = [
7375
7705
 
7376
7706
  // ../dtls/src/cipher/prf.ts
7377
7707
  import { createHash, createHmac as createHmac3 } from "crypto";
7378
- import { createDecode } from "@shinyoshiaki/binary-data";
7379
7708
  import nacl from "tweetnacl";
7380
7709
 
7381
7710
  // ../dtls/src/cipher/ec.ts
@@ -7471,7 +7800,7 @@ function prfEncryptionKeys(masterSecret, clientRandom, serverRandom, prfKeyLen,
7471
7800
  size,
7472
7801
  algorithm
7473
7802
  );
7474
- const stream = createDecode(keyBlock);
7803
+ const stream = new binaryData_exports.BinaryReader(keyBlock);
7475
7804
  const clientWriteKey = stream.readBuffer(prfKeyLen);
7476
7805
  const serverWriteKey = stream.readBuffer(prfKeyLen);
7477
7806
  const clientNonceImplicit = stream.readBuffer(prfIvLen);
@@ -7525,6 +7854,7 @@ var AbstractCipher = class {
7525
7854
  };
7526
7855
 
7527
7856
  // ../dtls/src/context/cipher.ts
7857
+ var { encode: encode2, types: types2 } = binaryData_exports;
7528
7858
  var crypto = webcrypto;
7529
7859
  x509.cryptoProvider.set(crypto);
7530
7860
  var CipherContext = class {
@@ -7670,15 +8000,13 @@ var CipherContext = class {
7670
8000
  this.signatureHashAlgorithm = signatureHash;
7671
8001
  }
7672
8002
  valueKeySignature(clientRandom, serverRandom, publicKey, namedCurve) {
7673
- const serverParams = Buffer.from(
7674
- encode(
7675
- {
7676
- type: CurveType.named_curve_3,
7677
- curve: namedCurve,
7678
- len: publicKey.length
7679
- },
7680
- { type: types.uint8, curve: types.uint16be, len: types.uint8 }
7681
- ).slice()
8003
+ const serverParams = encode2(
8004
+ {
8005
+ type: CurveType.named_curve_3,
8006
+ curve: namedCurve,
8007
+ len: publicKey.length
8008
+ },
8009
+ { type: types2.uint8, curve: types2.uint16be, len: types2.uint8 }
7682
8010
  );
7683
8011
  return Buffer.concat([clientRandom, serverRandom, serverParams, publicKey]);
7684
8012
  }
@@ -7694,12 +8022,6 @@ var SrtpContext2 = class {
7694
8022
  }
7695
8023
  };
7696
8024
 
7697
- // ../dtls/src/handshake/message/client/hello.ts
7698
- import { decode as decode3, encode as encode4, types as types5 } from "@shinyoshiaki/binary-data";
7699
-
7700
- // ../dtls/src/record/message/fragment.ts
7701
- import { decode, encode as encode2, types as types2 } from "@shinyoshiaki/binary-data";
7702
-
7703
8025
  // ../dtls/src/helper.ts
7704
8026
  var dumpBuffer2 = (data) => "0x" + data.toString("hex").replace(/(.)(.)/g, "$1$2 ").split(" ").filter((s) => s != void 0 && s.length > 0).join(",0x");
7705
8027
  var getObjectSummary = (obj) => Object.entries({ ...obj }).reduce((acc, [key, value]) => {
@@ -7713,6 +8035,7 @@ var getObjectSummary = (obj) => Object.entries({ ...obj }).reduce((acc, [key, va
7713
8035
  }, {});
7714
8036
 
7715
8037
  // ../dtls/src/record/message/fragment.ts
8038
+ var { decode: decode2, encode: encode3, types: types3 } = binaryData_exports;
7716
8039
  var FragmentedHandshake = class _FragmentedHandshake {
7717
8040
  constructor(msg_type, length, message_seq, fragment_offset, fragment_length, fragment) {
7718
8041
  this.msg_type = msg_type;
@@ -7723,12 +8046,12 @@ var FragmentedHandshake = class _FragmentedHandshake {
7723
8046
  this.fragment = fragment;
7724
8047
  }
7725
8048
  static spec = {
7726
- msg_type: types2.uint8,
7727
- length: types2.uint24be,
7728
- message_seq: types2.uint16be,
7729
- fragment_offset: types2.uint24be,
7730
- fragment_length: types2.uint24be,
7731
- fragment: types2.buffer((context) => context.current.fragment_length)
8049
+ msg_type: types3.uint8,
8050
+ length: types3.uint24be,
8051
+ message_seq: types3.uint16be,
8052
+ fragment_offset: types3.uint24be,
8053
+ fragment_length: types3.uint24be,
8054
+ fragment: types3.buffer((context) => context.current.fragment_length)
7732
8055
  };
7733
8056
  get summary() {
7734
8057
  return getObjectSummary(this);
@@ -7745,12 +8068,11 @@ var FragmentedHandshake = class _FragmentedHandshake {
7745
8068
  }
7746
8069
  static deSerialize(buf) {
7747
8070
  return new _FragmentedHandshake(
7748
- ...Object.values(decode(buf, _FragmentedHandshake.spec))
8071
+ ...Object.values(decode2(buf, _FragmentedHandshake.spec))
7749
8072
  );
7750
8073
  }
7751
8074
  serialize() {
7752
- const res = encode2(this, _FragmentedHandshake.spec).slice();
7753
- return Buffer.from(res);
8075
+ return encode3(this, _FragmentedHandshake.spec);
7754
8076
  }
7755
8077
  chunk(maxFragmentLength) {
7756
8078
  let start = 0;
@@ -7823,46 +8145,46 @@ var FragmentedHandshake = class _FragmentedHandshake {
7823
8145
  };
7824
8146
 
7825
8147
  // ../dtls/src/handshake/binary.ts
7826
- import { types as types3 } from "@shinyoshiaki/binary-data";
7827
- var { uint16be, uint24be, buffer, array, uint8, string: string2 } = types3;
8148
+ var { types: types4 } = binaryData_exports;
8149
+ var { uint16be, uint24be, buffer: buffer2, array: array2, uint8, string: string3 } = types4;
7828
8150
  var Extension = {
7829
8151
  type: uint16be,
7830
- data: buffer(uint16be)
8152
+ data: buffer2(uint16be)
7831
8153
  };
7832
- var ExtensionList = array(Extension, uint16be, "bytes");
7833
- var ASN11Cert = buffer(uint24be);
8154
+ var ExtensionList = array2(Extension, uint16be, "bytes");
8155
+ var ASN11Cert = buffer2(uint24be);
7834
8156
  var ClientCertificateType = uint8;
7835
- var DistinguishedName = string2(uint16be);
8157
+ var DistinguishedName = string3(uint16be);
7836
8158
  var SignatureHashAlgorithm = { hash: uint8, signature: uint8 };
7837
8159
  var ProtocolVersion = { major: uint8, minor: uint8 };
7838
8160
 
7839
8161
  // ../dtls/src/handshake/random.ts
7840
8162
  import { randomBytes as randomBytes4 } from "crypto";
7841
- import { decode as decode2, encode as encode3, types as types4 } from "@shinyoshiaki/binary-data";
8163
+ var { decode: decode3, encode: encode4, types: types5 } = binaryData_exports;
7842
8164
  var DtlsRandom = class _DtlsRandom {
7843
8165
  constructor(gmt_unix_time = Math.floor(Date.now() / 1e3), random_bytes = randomBytes4(28)) {
7844
8166
  this.gmt_unix_time = gmt_unix_time;
7845
8167
  this.random_bytes = random_bytes;
7846
8168
  }
7847
8169
  static spec = {
7848
- gmt_unix_time: types4.uint32be,
7849
- random_bytes: types4.buffer(28)
8170
+ gmt_unix_time: types5.uint32be,
8171
+ random_bytes: types5.buffer(28)
7850
8172
  };
7851
8173
  static deSerialize(buf) {
7852
8174
  return new _DtlsRandom(
7853
- ...Object.values(decode2(buf, _DtlsRandom.spec))
8175
+ ...Object.values(decode3(buf, _DtlsRandom.spec))
7854
8176
  );
7855
8177
  }
7856
8178
  static from(spec) {
7857
8179
  return new _DtlsRandom(...Object.values(spec));
7858
8180
  }
7859
8181
  serialize() {
7860
- const res = encode3(this, _DtlsRandom.spec).slice();
7861
- return Buffer.from(res);
8182
+ return encode4(this, _DtlsRandom.spec);
7862
8183
  }
7863
8184
  };
7864
8185
 
7865
8186
  // ../dtls/src/handshake/message/client/hello.ts
8187
+ var { decode: decode4, encode: encode5, types: types6 } = binaryData_exports;
7866
8188
  var ClientHello = class _ClientHello {
7867
8189
  constructor(clientVersion, random, sessionId, cookie, cipherSuites2, compressionMethods, extensions) {
7868
8190
  this.clientVersion = clientVersion;
@@ -7876,12 +8198,12 @@ var ClientHello = class _ClientHello {
7876
8198
  msgType = 1 /* client_hello_1 */;
7877
8199
  messageSeq = 0;
7878
8200
  static spec = {
7879
- clientVersion: { major: types5.uint8, minor: types5.uint8 },
8201
+ clientVersion: { major: types6.uint8, minor: types6.uint8 },
7880
8202
  random: DtlsRandom.spec,
7881
- sessionId: types5.buffer(types5.uint8),
7882
- cookie: types5.buffer(types5.uint8),
7883
- cipherSuites: types5.array(types5.uint16be, types5.uint16be, "bytes"),
7884
- compressionMethods: types5.array(types5.uint8, types5.uint8, "bytes"),
8203
+ sessionId: types6.buffer(types6.uint8),
8204
+ cookie: types6.buffer(types6.uint8),
8205
+ cipherSuites: types6.array(types6.uint16be, types6.uint16be, "bytes"),
8206
+ compressionMethods: types6.array(types6.uint8, types6.uint8, "bytes"),
7885
8207
  extensions: ExtensionList
7886
8208
  };
7887
8209
  static createEmpty() {
@@ -7897,12 +8219,11 @@ var ClientHello = class _ClientHello {
7897
8219
  }
7898
8220
  static deSerialize(buf) {
7899
8221
  return new _ClientHello(
7900
- ...Object.values(decode3(buf, _ClientHello.spec))
8222
+ ...Object.values(decode4(buf, _ClientHello.spec))
7901
8223
  );
7902
8224
  }
7903
8225
  serialize() {
7904
- const res = encode4(this, _ClientHello.spec).slice();
7905
- return Buffer.from(res);
8226
+ return encode5(this, _ClientHello.spec);
7906
8227
  }
7907
8228
  toFragment() {
7908
8229
  const body = this.serialize();
@@ -7918,7 +8239,7 @@ var ClientHello = class _ClientHello {
7918
8239
  };
7919
8240
 
7920
8241
  // ../dtls/src/record/message/header.ts
7921
- import { decode as decode4, encode as encode5, types as types6 } from "@shinyoshiaki/binary-data";
8242
+ var { decode: decode5, encode: encode6, types: types7 } = binaryData_exports;
7922
8243
  var MACHeader = class _MACHeader {
7923
8244
  constructor(epoch, sequenceNumber, contentType, protocolVersion, contentLen) {
7924
8245
  this.epoch = epoch;
@@ -7928,11 +8249,11 @@ var MACHeader = class _MACHeader {
7928
8249
  this.contentLen = contentLen;
7929
8250
  }
7930
8251
  static spec = {
7931
- epoch: types6.uint16be,
7932
- sequenceNumber: types6.uint48be,
7933
- contentType: types6.uint8,
8252
+ epoch: types7.uint16be,
8253
+ sequenceNumber: types7.uint48be,
8254
+ contentType: types7.uint8,
7934
8255
  protocolVersion: ProtocolVersion,
7935
- contentLen: types6.uint16be
8256
+ contentLen: types7.uint16be
7936
8257
  };
7937
8258
  static createEmpty() {
7938
8259
  return new _MACHeader(
@@ -7945,12 +8266,11 @@ var MACHeader = class _MACHeader {
7945
8266
  }
7946
8267
  static deSerialize(buf) {
7947
8268
  return new _MACHeader(
7948
- ...Object.values(decode4(buf, _MACHeader.spec))
8269
+ ...Object.values(decode5(buf, _MACHeader.spec))
7949
8270
  );
7950
8271
  }
7951
8272
  serialize() {
7952
- const res = encode5(this, _MACHeader.spec).slice();
7953
- return Buffer.from(res);
8273
+ return encode6(this, _MACHeader.spec);
7954
8274
  }
7955
8275
  };
7956
8276
 
@@ -8341,12 +8661,12 @@ var ExtendedMasterSecret = class {
8341
8661
  };
8342
8662
 
8343
8663
  // ../dtls/src/handshake/extensions/renegotiationIndication.ts
8344
- import { decode as decode5, encode as encode6, types as types7 } from "@shinyoshiaki/binary-data";
8664
+ var { decode: decode6, encode: encode7, types: types8 } = binaryData_exports;
8345
8665
  var RenegotiationIndication = class _RenegotiationIndication {
8346
8666
  static type = 65281;
8347
8667
  static spec = {
8348
- type: types7.uint16be,
8349
- data: types7.uint8
8668
+ type: types8.uint16be,
8669
+ data: types8.uint8
8350
8670
  };
8351
8671
  type = _RenegotiationIndication.type;
8352
8672
  data = 0;
@@ -8359,12 +8679,11 @@ var RenegotiationIndication = class _RenegotiationIndication {
8359
8679
  }
8360
8680
  static deSerialize(buf) {
8361
8681
  return new _RenegotiationIndication(
8362
- decode5(buf, _RenegotiationIndication.spec)
8682
+ decode6(buf, _RenegotiationIndication.spec)
8363
8683
  );
8364
8684
  }
8365
8685
  serialize() {
8366
- const res = encode6(this, _RenegotiationIndication.spec).slice();
8367
- return Buffer.from(res);
8686
+ return encode7(this, _RenegotiationIndication.spec);
8368
8687
  }
8369
8688
  get extension() {
8370
8689
  return {
@@ -8375,13 +8694,13 @@ var RenegotiationIndication = class _RenegotiationIndication {
8375
8694
  };
8376
8695
 
8377
8696
  // ../dtls/src/handshake/extensions/useSrtp.ts
8378
- import { decode as decode6, encode as encode7, types as types8 } from "@shinyoshiaki/binary-data";
8697
+ var { decode: decode7, encode: encode8, types: types9 } = binaryData_exports;
8379
8698
  var UseSRTP = class _UseSRTP {
8380
8699
  static type = 14;
8381
8700
  // 9. IANA Considerations
8382
8701
  static spec = {
8383
- type: types8.uint16be,
8384
- data: types8.buffer(types8.uint16be)
8702
+ type: types9.uint16be,
8703
+ data: types9.buffer(types9.uint16be)
8385
8704
  };
8386
8705
  type = _UseSRTP.type;
8387
8706
  data = Buffer.from([]);
@@ -8398,7 +8717,7 @@ var UseSRTP = class _UseSRTP {
8398
8717
  return v;
8399
8718
  }
8400
8719
  static deSerialize(buf) {
8401
- const useSrtp = new _UseSRTP(decode6(buf, _UseSRTP.spec));
8720
+ const useSrtp = new _UseSRTP(decode7(buf, _UseSRTP.spec));
8402
8721
  const profileLength = useSrtp.data.readUInt16BE();
8403
8722
  const profiles = new Array(profileLength / 2);
8404
8723
  for (let i = 0; i < profiles.length; i++) {
@@ -8421,8 +8740,7 @@ var UseSRTP = class _UseSRTP {
8421
8740
  this.mki
8422
8741
  ]);
8423
8742
  this.data = data;
8424
- const res = encode7(this, _UseSRTP.spec).slice();
8425
- return Buffer.from(res);
8743
+ return encode8(this, _UseSRTP.spec);
8426
8744
  }
8427
8745
  static fromData(buf) {
8428
8746
  const head = Buffer.alloc(4);
@@ -8439,7 +8757,7 @@ var UseSRTP = class _UseSRTP {
8439
8757
  };
8440
8758
 
8441
8759
  // ../dtls/src/handshake/message/certificate.ts
8442
- import { decode as decode7, encode as encode8, types as types9 } from "@shinyoshiaki/binary-data";
8760
+ var { decode: decode8, encode: encode9, types: types10 } = binaryData_exports;
8443
8761
  var Certificate2 = class _Certificate {
8444
8762
  constructor(certificateList) {
8445
8763
  this.certificateList = certificateList;
@@ -8447,19 +8765,18 @@ var Certificate2 = class _Certificate {
8447
8765
  msgType = 11 /* certificate_11 */;
8448
8766
  messageSeq;
8449
8767
  static spec = {
8450
- certificateList: types9.array(ASN11Cert, types9.uint24be, "bytes")
8768
+ certificateList: types10.array(ASN11Cert, types10.uint24be, "bytes")
8451
8769
  };
8452
8770
  static createEmpty() {
8453
8771
  return new _Certificate(void 0);
8454
8772
  }
8455
8773
  static deSerialize(buf) {
8456
8774
  return new _Certificate(
8457
- ...Object.values(decode7(buf, _Certificate.spec))
8775
+ ...Object.values(decode8(buf, _Certificate.spec))
8458
8776
  );
8459
8777
  }
8460
8778
  serialize() {
8461
- const res = encode8(this, _Certificate.spec).slice();
8462
- return Buffer.from(res);
8779
+ return encode9(this, _Certificate.spec);
8463
8780
  }
8464
8781
  toFragment() {
8465
8782
  const body = this.serialize();
@@ -8475,30 +8792,29 @@ var Certificate2 = class _Certificate {
8475
8792
  };
8476
8793
 
8477
8794
  // ../dtls/src/handshake/message/changeCipherSpec.ts
8478
- import { decode as decode8, encode as encode9, types as types10 } from "@shinyoshiaki/binary-data";
8795
+ var { decode: decode9, encode: encode10, types: types11 } = binaryData_exports;
8479
8796
  var ChangeCipherSpec = class _ChangeCipherSpec {
8480
8797
  constructor(type = 1) {
8481
8798
  this.type = type;
8482
8799
  }
8483
8800
  static spec = {
8484
- type: types10.uint8
8801
+ type: types11.uint8
8485
8802
  };
8486
8803
  static createEmpty() {
8487
8804
  return new _ChangeCipherSpec();
8488
8805
  }
8489
8806
  static deSerialize(buf) {
8490
8807
  return new _ChangeCipherSpec(
8491
- ...Object.values(decode8(buf, _ChangeCipherSpec.spec))
8808
+ ...Object.values(decode9(buf, _ChangeCipherSpec.spec))
8492
8809
  );
8493
8810
  }
8494
8811
  serialize() {
8495
- const res = encode9(this, _ChangeCipherSpec.spec).slice();
8496
- return Buffer.from(res);
8812
+ return encode10(this, _ChangeCipherSpec.spec);
8497
8813
  }
8498
8814
  };
8499
8815
 
8500
8816
  // ../dtls/src/handshake/message/client/certificateVerify.ts
8501
- import { decode as decode9, encode as encode10, types as types11 } from "@shinyoshiaki/binary-data";
8817
+ var { decode: decode10, encode: encode11, types: types12 } = binaryData_exports;
8502
8818
  var CertificateVerify = class _CertificateVerify {
8503
8819
  constructor(algorithm, signature) {
8504
8820
  this.algorithm = algorithm;
@@ -8507,21 +8823,20 @@ var CertificateVerify = class _CertificateVerify {
8507
8823
  msgType = 15 /* certificate_verify_15 */;
8508
8824
  messageSeq;
8509
8825
  static spec = {
8510
- algorithm: types11.uint16be,
8511
- signature: types11.buffer(types11.uint16be)
8826
+ algorithm: types12.uint16be,
8827
+ signature: types12.buffer(types12.uint16be)
8512
8828
  };
8513
8829
  static createEmpty() {
8514
8830
  return new _CertificateVerify(void 0, void 0);
8515
8831
  }
8516
8832
  static deSerialize(buf) {
8517
- const res = decode9(buf, _CertificateVerify.spec);
8833
+ const res = decode10(buf, _CertificateVerify.spec);
8518
8834
  return new _CertificateVerify(
8519
8835
  ...Object.values(res)
8520
8836
  );
8521
8837
  }
8522
8838
  serialize() {
8523
- const res = encode10(this, _CertificateVerify.spec).slice();
8524
- return Buffer.from(res);
8839
+ return encode11(this, _CertificateVerify.spec);
8525
8840
  }
8526
8841
  toFragment() {
8527
8842
  const body = this.serialize();
@@ -8537,7 +8852,7 @@ var CertificateVerify = class _CertificateVerify {
8537
8852
  };
8538
8853
 
8539
8854
  // ../dtls/src/handshake/message/client/keyExchange.ts
8540
- import { decode as decode10, encode as encode11, types as types12 } from "@shinyoshiaki/binary-data";
8855
+ var { decode: decode11, encode: encode12, types: types13 } = binaryData_exports;
8541
8856
  var ClientKeyExchange = class _ClientKeyExchange {
8542
8857
  constructor(publicKey) {
8543
8858
  this.publicKey = publicKey;
@@ -8545,20 +8860,19 @@ var ClientKeyExchange = class _ClientKeyExchange {
8545
8860
  msgType = 16 /* client_key_exchange_16 */;
8546
8861
  messageSeq;
8547
8862
  static spec = {
8548
- publicKey: types12.buffer(types12.uint8)
8863
+ publicKey: types13.buffer(types13.uint8)
8549
8864
  };
8550
8865
  static createEmpty() {
8551
8866
  return new _ClientKeyExchange(void 0);
8552
8867
  }
8553
8868
  static deSerialize(buf) {
8554
- const res = decode10(buf, _ClientKeyExchange.spec);
8869
+ const res = decode11(buf, _ClientKeyExchange.spec);
8555
8870
  return new _ClientKeyExchange(
8556
8871
  ...Object.values(res)
8557
8872
  );
8558
8873
  }
8559
8874
  serialize() {
8560
- const res = encode11(this, _ClientKeyExchange.spec).slice();
8561
- return Buffer.from(res);
8875
+ return encode12(this, _ClientKeyExchange.spec);
8562
8876
  }
8563
8877
  toFragment() {
8564
8878
  const body = this.serialize();
@@ -8574,7 +8888,7 @@ var ClientKeyExchange = class _ClientKeyExchange {
8574
8888
  };
8575
8889
 
8576
8890
  // ../dtls/src/handshake/message/server/certificateRequest.ts
8577
- import { decode as decode11, encode as encode12, types as types13 } from "@shinyoshiaki/binary-data";
8891
+ var { decode: decode12, encode: encode13, types: types14 } = binaryData_exports;
8578
8892
  var ServerCertificateRequest = class _ServerCertificateRequest {
8579
8893
  constructor(certificateTypes2, signatures2, authorities) {
8580
8894
  this.certificateTypes = certificateTypes2;
@@ -8584,9 +8898,9 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
8584
8898
  msgType = 13 /* certificate_request_13 */;
8585
8899
  messageSeq;
8586
8900
  static spec = {
8587
- certificateTypes: types13.array(ClientCertificateType, types13.uint8, "bytes"),
8588
- signatures: types13.array(SignatureHashAlgorithm, types13.uint16be, "bytes"),
8589
- authorities: types13.array(DistinguishedName, types13.uint16be, "bytes")
8901
+ certificateTypes: types14.array(ClientCertificateType, types14.uint8, "bytes"),
8902
+ signatures: types14.array(SignatureHashAlgorithm, types14.uint16be, "bytes"),
8903
+ authorities: types14.array(DistinguishedName, types14.uint16be, "bytes")
8590
8904
  };
8591
8905
  static createEmpty() {
8592
8906
  return new _ServerCertificateRequest(
@@ -8597,12 +8911,11 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
8597
8911
  }
8598
8912
  static deSerialize(buf) {
8599
8913
  return new _ServerCertificateRequest(
8600
- ...Object.values(decode11(buf, _ServerCertificateRequest.spec))
8914
+ ...Object.values(decode12(buf, _ServerCertificateRequest.spec))
8601
8915
  );
8602
8916
  }
8603
8917
  serialize() {
8604
- const res = encode12(this, _ServerCertificateRequest.spec).slice();
8605
- return Buffer.from(res);
8918
+ return encode13(this, _ServerCertificateRequest.spec);
8606
8919
  }
8607
8920
  toFragment() {
8608
8921
  const body = this.serialize();
@@ -8618,7 +8931,7 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
8618
8931
  };
8619
8932
 
8620
8933
  // ../dtls/src/handshake/message/server/hello.ts
8621
- import { decode as decode12, encode as encode13, types as types14 } from "@shinyoshiaki/binary-data";
8934
+ var { decode: decode13, encode: encode14, types: types15 } = binaryData_exports;
8622
8935
  var ServerHello = class _ServerHello {
8623
8936
  constructor(serverVersion, random, sessionId, cipherSuite, compressionMethod, extensions) {
8624
8937
  this.serverVersion = serverVersion;
@@ -8633,9 +8946,9 @@ var ServerHello = class _ServerHello {
8633
8946
  static spec = {
8634
8947
  serverVersion: ProtocolVersion,
8635
8948
  random: DtlsRandom.spec,
8636
- sessionId: types14.buffer(types14.uint8),
8637
- cipherSuite: types14.uint16be,
8638
- compressionMethod: types14.uint8
8949
+ sessionId: types15.buffer(types15.uint8),
8950
+ cipherSuite: types15.uint16be,
8951
+ compressionMethod: types15.uint8
8639
8952
  };
8640
8953
  static createEmpty() {
8641
8954
  return new _ServerHello(
@@ -8648,7 +8961,7 @@ var ServerHello = class _ServerHello {
8648
8961
  );
8649
8962
  }
8650
8963
  static deSerialize(buf) {
8651
- const res = decode12(buf, _ServerHello.spec);
8964
+ const res = decode13(buf, _ServerHello.spec);
8652
8965
  const cls = new _ServerHello(
8653
8966
  ...Object.values(res)
8654
8967
  );
@@ -8656,18 +8969,17 @@ var ServerHello = class _ServerHello {
8656
8969
  if (expect.length < buf.length) {
8657
8970
  return new _ServerHello(
8658
8971
  ...Object.values(
8659
- decode12(buf, { ..._ServerHello.spec, extensions: ExtensionList })
8972
+ decode13(buf, { ..._ServerHello.spec, extensions: ExtensionList })
8660
8973
  )
8661
8974
  );
8662
8975
  }
8663
8976
  return cls;
8664
8977
  }
8665
8978
  serialize() {
8666
- const res = this.extensions === void 0 ? encode13(this, _ServerHello.spec).slice() : encode13(this, {
8979
+ return this.extensions === void 0 ? encode14(this, _ServerHello.spec) : encode14(this, {
8667
8980
  ..._ServerHello.spec,
8668
8981
  extensions: ExtensionList
8669
- }).slice();
8670
- return Buffer.from(res);
8982
+ });
8671
8983
  }
8672
8984
  toFragment() {
8673
8985
  const body = this.serialize();
@@ -8683,18 +8995,16 @@ var ServerHello = class _ServerHello {
8683
8995
  };
8684
8996
 
8685
8997
  // ../dtls/src/handshake/message/server/helloDone.ts
8686
- import { decode as decode13, encode as encode14 } from "@shinyoshiaki/binary-data";
8687
-
8688
- // ../dtls/src/handshake/message/server/keyExchange.ts
8689
- import { decode as decode14, types as types15 } from "@shinyoshiaki/binary-data";
8998
+ var { decode: decode14, encode: encode15 } = binaryData_exports;
8690
8999
 
8691
9000
  // ../dtls/src/util/binary.ts
8692
- import { encode as encode15 } from "@shinyoshiaki/binary-data";
9001
+ var { encode: encode16 } = binaryData_exports;
8693
9002
  function encodeBuffer(obj, spec) {
8694
- return Buffer.from(encode15(obj, spec).slice());
9003
+ return encode16(obj, spec);
8695
9004
  }
8696
9005
 
8697
9006
  // ../dtls/src/handshake/message/server/keyExchange.ts
9007
+ var { decode: decode15, types: types16 } = binaryData_exports;
8698
9008
  var ServerKeyExchange = class _ServerKeyExchange {
8699
9009
  constructor(ellipticCurveType, namedCurve, publicKeyLength, publicKey, hashAlgorithm, signatureAlgorithm, signatureLength, signature) {
8700
9010
  this.ellipticCurveType = ellipticCurveType;
@@ -8709,14 +9019,14 @@ var ServerKeyExchange = class _ServerKeyExchange {
8709
9019
  msgType = 12 /* server_key_exchange_12 */;
8710
9020
  messageSeq;
8711
9021
  static spec = {
8712
- ellipticCurveType: types15.uint8,
8713
- namedCurve: types15.uint16be,
8714
- publicKeyLength: types15.uint8,
8715
- publicKey: types15.buffer((ctx) => ctx.current.publicKeyLength),
8716
- hashAlgorithm: types15.uint8,
8717
- signatureAlgorithm: types15.uint8,
8718
- signatureLength: types15.uint16be,
8719
- signature: types15.buffer((ctx) => ctx.current.signatureLength)
9022
+ ellipticCurveType: types16.uint8,
9023
+ namedCurve: types16.uint16be,
9024
+ publicKeyLength: types16.uint8,
9025
+ publicKey: types16.buffer((ctx) => ctx.current.publicKeyLength),
9026
+ hashAlgorithm: types16.uint8,
9027
+ signatureAlgorithm: types16.uint8,
9028
+ signatureLength: types16.uint16be,
9029
+ signature: types16.buffer((ctx) => ctx.current.signatureLength)
8720
9030
  };
8721
9031
  static createEmpty() {
8722
9032
  return new _ServerKeyExchange(
@@ -8731,7 +9041,7 @@ var ServerKeyExchange = class _ServerKeyExchange {
8731
9041
  );
8732
9042
  }
8733
9043
  static deSerialize(buf) {
8734
- const res = decode14(buf, _ServerKeyExchange.spec);
9044
+ const res = decode15(buf, _ServerKeyExchange.spec);
8735
9045
  return new _ServerKeyExchange(
8736
9046
  ...Object.values(res)
8737
9047
  );
@@ -8812,7 +9122,7 @@ handlers[14 /* server_hello_done_14 */] = ({ dtls }) => (msg) => {
8812
9122
  };
8813
9123
 
8814
9124
  // ../dtls/src/handshake/message/server/helloVerifyRequest.ts
8815
- import { decode as decode15, encode as encode16, types as types16 } from "@shinyoshiaki/binary-data";
9125
+ var { decode: decode16, encode: encode17, types: types17 } = binaryData_exports;
8816
9126
  var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
8817
9127
  constructor(serverVersion, cookie) {
8818
9128
  this.serverVersion = serverVersion;
@@ -8822,19 +9132,18 @@ var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
8822
9132
  messageSeq;
8823
9133
  static spec = {
8824
9134
  serverVersion: ProtocolVersion,
8825
- cookie: types16.buffer(types16.uint8)
9135
+ cookie: types17.buffer(types17.uint8)
8826
9136
  };
8827
9137
  static createEmpty() {
8828
9138
  return new _ServerHelloVerifyRequest(void 0, void 0);
8829
9139
  }
8830
9140
  static deSerialize(buf) {
8831
9141
  return new _ServerHelloVerifyRequest(
8832
- ...Object.values(decode15(buf, _ServerHelloVerifyRequest.spec))
9142
+ ...Object.values(decode16(buf, _ServerHelloVerifyRequest.spec))
8833
9143
  );
8834
9144
  }
8835
9145
  serialize() {
8836
- const res = encode16(this, _ServerHelloVerifyRequest.spec).slice();
8837
- return Buffer.from(res);
9146
+ return encode17(this, _ServerHelloVerifyRequest.spec);
8838
9147
  }
8839
9148
  get version() {
8840
9149
  return {
@@ -8855,19 +9164,16 @@ var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
8855
9164
  }
8856
9165
  };
8857
9166
 
8858
- // ../dtls/src/socket.ts
8859
- import { decode as decode19, types as types20 } from "@shinyoshiaki/binary-data";
8860
-
8861
9167
  // ../dtls/src/context/dtls.ts
8862
9168
  var log12 = debug("werift-dtls : packages/dtls/src/context/dtls.ts : log");
8863
9169
 
8864
9170
  // ../dtls/src/handshake/extensions/ellipticCurves.ts
8865
- import { decode as decode16, encode as encode17, types as types17 } from "@shinyoshiaki/binary-data";
9171
+ var { decode: decode17, encode: encode18, types: types18 } = binaryData_exports;
8866
9172
  var EllipticCurves = class _EllipticCurves {
8867
9173
  static type = 10;
8868
9174
  static spec = {
8869
- type: types17.uint16be,
8870
- data: types17.array(types17.uint16be, types17.uint16be, "bytes")
9175
+ type: types18.uint16be,
9176
+ data: types18.array(types18.uint16be, types18.uint16be, "bytes")
8871
9177
  };
8872
9178
  type = _EllipticCurves.type;
8873
9179
  data = [];
@@ -8880,14 +9186,14 @@ var EllipticCurves = class _EllipticCurves {
8880
9186
  static fromData(buf) {
8881
9187
  return new _EllipticCurves({
8882
9188
  type: _EllipticCurves.type,
8883
- data: decode16(buf, _EllipticCurves.spec.data)
9189
+ data: decode17(buf, _EllipticCurves.spec.data)
8884
9190
  });
8885
9191
  }
8886
9192
  static deSerialize(buf) {
8887
- return new _EllipticCurves(decode16(buf, _EllipticCurves.spec));
9193
+ return new _EllipticCurves(decode17(buf, _EllipticCurves.spec));
8888
9194
  }
8889
9195
  serialize() {
8890
- return Buffer.from(encode17(this, _EllipticCurves.spec).slice());
9196
+ return encode18(this, _EllipticCurves.spec);
8891
9197
  }
8892
9198
  get extension() {
8893
9199
  return {
@@ -8898,14 +9204,14 @@ var EllipticCurves = class _EllipticCurves {
8898
9204
  };
8899
9205
 
8900
9206
  // ../dtls/src/handshake/extensions/signature.ts
8901
- import { decode as decode17, encode as encode18, types as types18 } from "@shinyoshiaki/binary-data";
9207
+ var { decode: decode18, encode: encode19, types: types19 } = binaryData_exports;
8902
9208
  var Signature = class _Signature {
8903
9209
  static type = 13;
8904
9210
  static spec = {
8905
- type: types18.uint16be,
8906
- data: types18.array(
8907
- { hash: types18.uint8, signature: types18.uint8 },
8908
- types18.uint16be,
9211
+ type: types19.uint16be,
9212
+ data: types19.array(
9213
+ { hash: types19.uint8, signature: types19.uint8 },
9214
+ types19.uint16be,
8909
9215
  "bytes"
8910
9216
  )
8911
9217
  };
@@ -8919,11 +9225,10 @@ var Signature = class _Signature {
8919
9225
  return v;
8920
9226
  }
8921
9227
  static deSerialize(buf) {
8922
- return new _Signature(decode17(buf, _Signature.spec));
9228
+ return new _Signature(decode18(buf, _Signature.spec));
8923
9229
  }
8924
9230
  serialize() {
8925
- const res = encode18(this, _Signature.spec).slice();
8926
- return Buffer.from(res);
9231
+ return encode19(this, _Signature.spec);
8927
9232
  }
8928
9233
  static fromData(buf) {
8929
9234
  const type = Buffer.alloc(2);
@@ -8939,24 +9244,23 @@ var Signature = class _Signature {
8939
9244
  };
8940
9245
 
8941
9246
  // ../dtls/src/handshake/message/alert.ts
8942
- import { decode as decode18, encode as encode19, types as types19 } from "@shinyoshiaki/binary-data";
9247
+ var { decode: decode19, encode: encode20, types: types20 } = binaryData_exports;
8943
9248
  var Alert = class _Alert {
8944
9249
  constructor(level, description) {
8945
9250
  this.level = level;
8946
9251
  this.description = description;
8947
9252
  }
8948
9253
  static spec = {
8949
- level: types19.uint8,
8950
- description: types19.uint8
9254
+ level: types20.uint8,
9255
+ description: types20.uint8
8951
9256
  };
8952
9257
  static deSerialize(buf) {
8953
9258
  return new _Alert(
8954
- ...Object.values(decode18(buf, _Alert.spec))
9259
+ ...Object.values(decode19(buf, _Alert.spec))
8955
9260
  );
8956
9261
  }
8957
9262
  serialize() {
8958
- const res = encode19(this, _Alert.spec).slice();
8959
- return Buffer.from(res);
9263
+ return encode20(this, _Alert.spec);
8960
9264
  }
8961
9265
  };
8962
9266
 
@@ -8965,6 +9269,7 @@ var log13 = debug("werift-dtls : packages/dtls/record/receive.ts : log");
8965
9269
  var err3 = debug("werift-dtls : packages/dtls/record/receive.ts : err");
8966
9270
 
8967
9271
  // ../dtls/src/socket.ts
9272
+ var { decode: decode20, types: types21 } = binaryData_exports;
8968
9273
  var log14 = debug("werift-dtls : packages/dtls/src/socket.ts : log");
8969
9274
  var err4 = debug("werift-dtls : packages/dtls/src/socket.ts : err");
8970
9275
 
@@ -9107,11 +9412,11 @@ function isIpV4Address(address) {
9107
9412
  function packAddress(value) {
9108
9413
  const [address] = value;
9109
9414
  const protocol = isIpV4Address(address) ? IPV4_PROTOCOL : IPV6_PROTOCOL;
9110
- const buffer2 = Buffer.alloc(4);
9111
- buffer2.writeUInt8(0, 0);
9112
- buffer2.writeUInt8(protocol, 1);
9113
- buffer2.writeUInt16BE(value[1], 2);
9114
- return Buffer.concat([buffer2, ipAddressToBuffer(address)]);
9415
+ const buffer3 = Buffer.alloc(4);
9416
+ buffer3.writeUInt8(0, 0);
9417
+ buffer3.writeUInt8(protocol, 1);
9418
+ buffer3.writeUInt16BE(value[1], 2);
9419
+ return Buffer.concat([buffer3, ipAddressToBuffer(address)]);
9115
9420
  }
9116
9421
  function unpackErrorCode(data) {
9117
9422
  if (data.length < 4) {
@@ -9162,19 +9467,19 @@ function unpackXorAddress(data, transactionId) {
9162
9467
  return unpackAddress(xorAddress(data, transactionId));
9163
9468
  }
9164
9469
  function packErrorCode(value) {
9165
- const buffer2 = Buffer.alloc(4);
9166
- buffer2.writeUInt16BE(0, 0);
9167
- buffer2.writeUInt8(Math.floor(value[0] / 100), 2);
9168
- buffer2.writeUInt8(value[0] % 100, 3);
9470
+ const buffer3 = Buffer.alloc(4);
9471
+ buffer3.writeUInt16BE(0, 0);
9472
+ buffer3.writeUInt8(Math.floor(value[0] / 100), 2);
9473
+ buffer3.writeUInt8(value[0] % 100, 3);
9169
9474
  const encoded = Buffer.from(value[1], "utf8");
9170
- return Buffer.concat([buffer2, encoded]);
9475
+ return Buffer.concat([buffer3, encoded]);
9171
9476
  }
9172
9477
  function packUnknownAttributes(value) {
9173
- const buffer2 = Buffer.alloc(value.length * 2);
9478
+ const buffer3 = Buffer.alloc(value.length * 2);
9174
9479
  value.forEach((attributeType, index) => {
9175
- buffer2.writeUInt16BE(attributeType, index * 2);
9480
+ buffer3.writeUInt16BE(attributeType, index * 2);
9176
9481
  });
9177
- return buffer2;
9482
+ return buffer3;
9178
9483
  }
9179
9484
  function unpackUnknownAttributes(data) {
9180
9485
  if (data.length % 2 !== 0) {
@@ -9190,21 +9495,21 @@ function packXorAddress(value, transactionId) {
9190
9495
  return xorAddress(packAddress(value), transactionId);
9191
9496
  }
9192
9497
  var packUnsigned = (value) => {
9193
- const buffer2 = Buffer.alloc(4);
9194
- buffer2.writeUInt32BE(value, 0);
9195
- return buffer2;
9498
+ const buffer3 = Buffer.alloc(4);
9499
+ buffer3.writeUInt32BE(value, 0);
9500
+ return buffer3;
9196
9501
  };
9197
9502
  var unpackUnsigned = (data) => data.readUInt32BE(0);
9198
9503
  var packUnsignedShort = (value) => {
9199
- const buffer2 = Buffer.alloc(4);
9200
- buffer2.writeUInt16BE(value, 0);
9201
- return buffer2;
9504
+ const buffer3 = Buffer.alloc(4);
9505
+ buffer3.writeUInt16BE(value, 0);
9506
+ return buffer3;
9202
9507
  };
9203
9508
  var unpackUnsignedShort = (data) => data.readUInt16BE(0);
9204
9509
  var packUnsigned64 = (value) => {
9205
- const buffer2 = Buffer.allocUnsafe(8);
9206
- buffer2.writeBigUInt64BE(value, 0);
9207
- return buffer2;
9510
+ const buffer3 = Buffer.allocUnsafe(8);
9511
+ buffer3.writeBigUInt64BE(value, 0);
9512
+ return buffer3;
9208
9513
  };
9209
9514
  var unpackUnsigned64 = (data) => data.readBigUInt64BE(0);
9210
9515
  var packString = (value) => Buffer.from(value, "utf8");
@@ -10701,6 +11006,7 @@ export {
10701
11006
  WeriftError,
10702
11007
  annexb2avcSample,
10703
11008
  annexb2avcc,
11009
+ binaryData_exports as binaryData,
10704
11010
  buffer2ArrayBuffer,
10705
11011
  bufferArrayXor,
10706
11012
  bufferReader,
@@ -10767,7 +11073,7 @@ export {
10767
11073
  serializeSdesRTPStreamID,
10768
11074
  serializeSimpleBlock,
10769
11075
  serializeTransportWideCC,
10770
- string,
11076
+ string2 as string,
10771
11077
  stringToByteArray,
10772
11078
  timer,
10773
11079
  uint16Add,