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
  // src/errors.ts
2
8
  function createWebRtcDomException(name, message = name) {
3
9
  return new DOMException(message, name);
@@ -822,6 +828,331 @@ function stripZoneId(address) {
822
828
  return address.split("%")[0];
823
829
  }
824
830
 
831
+ // ../common/src/binaryData.ts
832
+ var binaryData_exports = {};
833
+ __export(binaryData_exports, {
834
+ BinaryReader: () => BinaryReader,
835
+ BinaryWriter: () => BinaryWriter,
836
+ NotEnoughDataError: () => NotEnoughDataError,
837
+ decode: () => decode,
838
+ encode: () => encode,
839
+ types: () => types
840
+ });
841
+ var NotEnoughDataError = class extends Error {
842
+ constructor(expected, received) {
843
+ super(`requested ${expected} bytes but only ${received} available`);
844
+ this.name = "NotEnoughDataError";
845
+ }
846
+ };
847
+ var BinaryReader = class {
848
+ constructor(buf) {
849
+ this.buf = buf;
850
+ }
851
+ offset = 0;
852
+ /** The number of unread bytes. */
853
+ get length() {
854
+ return this.buf.length - this.offset;
855
+ }
856
+ /** The number of bytes consumed so far. */
857
+ get bytes() {
858
+ return this.offset;
859
+ }
860
+ readBuffer(size) {
861
+ this.assertSize(size);
862
+ const res = this.buf.subarray(this.offset, this.offset + size);
863
+ this.offset += size;
864
+ return res;
865
+ }
866
+ readUIntBE(size) {
867
+ this.assertSize(size);
868
+ const res = this.buf.readUIntBE(this.offset, size);
869
+ this.offset += size;
870
+ return res;
871
+ }
872
+ assertSize(size) {
873
+ if (size > this.length) {
874
+ throw new NotEnoughDataError(size, this.length);
875
+ }
876
+ }
877
+ };
878
+ var BinaryWriter = class {
879
+ chunks = [];
880
+ written = 0;
881
+ /** The number of bytes written so far. */
882
+ get bytes() {
883
+ return this.written;
884
+ }
885
+ writeBuffer(buf) {
886
+ this.chunks.push(buf);
887
+ this.written += buf.length;
888
+ }
889
+ writeUIntBE(value, size) {
890
+ const buf = Buffer.allocUnsafe(size);
891
+ switch (size) {
892
+ case 1:
893
+ buf.writeUInt8(value, 0);
894
+ break;
895
+ case 2:
896
+ buf.writeUInt16BE(value, 0);
897
+ break;
898
+ case 4:
899
+ buf.writeUInt32BE(value, 0);
900
+ break;
901
+ default:
902
+ buf.writeUIntBE(value, 0, size);
903
+ }
904
+ this.writeBuffer(buf);
905
+ }
906
+ toBuffer() {
907
+ return Buffer.concat(this.chunks, this.written);
908
+ }
909
+ };
910
+ var isObject = (value) => typeof value === "object" && value !== null;
911
+ var isType = (value) => isObject(value) && typeof value.encode === "function" && typeof value.decode === "function";
912
+ var isPlainObject = (value) => {
913
+ if (!isObject(value)) return false;
914
+ const proto = Object.getPrototypeOf(value);
915
+ return proto === Object.prototype || proto === null;
916
+ };
917
+ var createContext = () => ({
918
+ node: void 0,
919
+ current: void 0
920
+ });
921
+ var cloneContext = (context) => ({
922
+ node: context.node,
923
+ current: context.current
924
+ });
925
+ var assertSchema = (schema, message) => {
926
+ if (!isPlainObject(schema)) {
927
+ throw new TypeError(message);
928
+ }
929
+ };
930
+ var encodeCommon = (value, typeOrSchema, writer, context) => {
931
+ if (isType(typeOrSchema)) {
932
+ typeOrSchema.encode(value, writer, context);
933
+ } else {
934
+ encodeSchema(value, typeOrSchema, writer, context);
935
+ }
936
+ };
937
+ var encodeSchema = (obj, schema, writer, context) => {
938
+ assertSchema(schema, "Argument `schema` should be a plain object.");
939
+ if (context.node === void 0) {
940
+ context.node = obj;
941
+ }
942
+ context.current = obj;
943
+ for (const key of Object.keys(schema)) {
944
+ const type = schema[key];
945
+ const value = obj[key];
946
+ if (isType(type)) {
947
+ type.encode(value, writer, context);
948
+ } else {
949
+ encodeSchema(value, type, writer, context);
950
+ context.current = obj;
951
+ }
952
+ }
953
+ };
954
+ var decodeCommon = (reader, typeOrSchema, context) => {
955
+ if (isType(typeOrSchema)) {
956
+ return typeOrSchema.decode(reader, context);
957
+ }
958
+ return decodeSchema(reader, typeOrSchema, context);
959
+ };
960
+ var decodeSchema = (reader, schema, context) => {
961
+ assertSchema(schema, "Argument #2 should be a plain object.");
962
+ const node = /* @__PURE__ */ Object.create(null);
963
+ if (context.node === void 0) {
964
+ context.node = node;
965
+ }
966
+ context.current = node;
967
+ for (const key of Object.keys(schema)) {
968
+ const type = schema[key];
969
+ if (isType(type)) {
970
+ node[key] = type.decode(reader, context);
971
+ } else {
972
+ node[key] = decodeSchema(reader, type, context);
973
+ context.current = node;
974
+ }
975
+ }
976
+ return node;
977
+ };
978
+ function encode(obj, typeOrSchema) {
979
+ const writer = new BinaryWriter();
980
+ encodeCommon(obj, typeOrSchema, writer, createContext());
981
+ return writer.toBuffer();
982
+ }
983
+ function decode(buf, typeOrSchema) {
984
+ return decodeCommon(new BinaryReader(buf), typeOrSchema, createContext());
985
+ }
986
+ var createUIntBE = (size) => ({
987
+ encode: (value, writer) => writer.writeUIntBE(value, size),
988
+ decode: (reader) => reader.readUIntBE(size)
989
+ });
990
+ var assertLengthSpec = (length) => {
991
+ if (typeof length !== "number" && !isType(length) && typeof length !== "function") {
992
+ throw new TypeError("Unknown type of argument #1.");
993
+ }
994
+ };
995
+ var checkLength = (required, having, name) => {
996
+ if (required !== having) {
997
+ throw new Error(`${name} required length ${required} instead of ${having}`);
998
+ }
999
+ };
1000
+ var checkLengthType = (length, message) => {
1001
+ if (typeof length !== "number") {
1002
+ throw new TypeError(message);
1003
+ }
1004
+ };
1005
+ function buffer(length) {
1006
+ assertLengthSpec(length);
1007
+ const lengthTypeError = "Length of a buffer should be a number.";
1008
+ return {
1009
+ encode(buf, writer, context) {
1010
+ if (!Buffer.isBuffer(buf)) {
1011
+ throw new TypeError("Argument 1 should be a Buffer or a BinaryStream.");
1012
+ }
1013
+ if (typeof length === "number") {
1014
+ checkLength(length, buf.length, "Buffer");
1015
+ } else if (isType(length)) {
1016
+ length.encode(buf.length, writer, context);
1017
+ } else {
1018
+ const expected = length(context);
1019
+ checkLengthType(expected, lengthTypeError);
1020
+ checkLength(expected, buf.length, "Buffer");
1021
+ }
1022
+ writer.writeBuffer(buf);
1023
+ },
1024
+ decode(reader, context) {
1025
+ let size;
1026
+ if (typeof length === "number") {
1027
+ size = length;
1028
+ } else if (isType(length)) {
1029
+ size = length.decode(reader, context);
1030
+ } else {
1031
+ size = length(context);
1032
+ }
1033
+ checkLengthType(size, lengthTypeError);
1034
+ return reader.readBuffer(size);
1035
+ }
1036
+ };
1037
+ }
1038
+ function array(type, length, lengthType = "count") {
1039
+ if (!isType(type) && !isPlainObject(type)) {
1040
+ throw new TypeError("Argument #1 should be a valid type.");
1041
+ }
1042
+ assertLengthSpec(length);
1043
+ const isLengthInBytes = lengthType === "bytes";
1044
+ const sizeTypeError = "Length of an array should be a number.";
1045
+ return {
1046
+ encode(items, writer, parent) {
1047
+ if (!Array.isArray(items)) {
1048
+ throw new TypeError("Argument #1 should be an Array.");
1049
+ }
1050
+ const context = cloneContext(parent);
1051
+ let expectedSize = 0;
1052
+ if (typeof length === "number") {
1053
+ expectedSize = length;
1054
+ } else if (isType(length)) {
1055
+ expectedSize = items.length;
1056
+ } else {
1057
+ expectedSize = length(context);
1058
+ checkLengthType(expectedSize, sizeTypeError);
1059
+ }
1060
+ const body = new BinaryWriter();
1061
+ for (const item of items) {
1062
+ encodeCommon(item, type, body, context);
1063
+ }
1064
+ if (isLengthInBytes) {
1065
+ if (isType(length)) {
1066
+ expectedSize = body.bytes;
1067
+ }
1068
+ checkLength(body.bytes, expectedSize, "Argument #1");
1069
+ } else {
1070
+ checkLength(expectedSize, items.length, "Argument #1");
1071
+ }
1072
+ if (isType(length)) {
1073
+ length.encode(expectedSize, writer, context);
1074
+ }
1075
+ writer.writeBuffer(body.toBuffer());
1076
+ },
1077
+ decode(reader, parent) {
1078
+ const context = cloneContext(parent);
1079
+ let expectedSize;
1080
+ if (typeof length === "number") {
1081
+ expectedSize = length;
1082
+ } else if (isType(length)) {
1083
+ expectedSize = length.decode(reader, context);
1084
+ } else {
1085
+ expectedSize = length(context);
1086
+ }
1087
+ checkLengthType(expectedSize, sizeTypeError);
1088
+ const items = [];
1089
+ if (isLengthInBytes) {
1090
+ const before = reader.bytes;
1091
+ let bytes2 = 0;
1092
+ while (bytes2 < expectedSize) {
1093
+ items.push(decodeCommon(reader, type, context));
1094
+ bytes2 = reader.bytes - before;
1095
+ }
1096
+ if (bytes2 > expectedSize) {
1097
+ throw new Error("Incorrect length of an array.");
1098
+ }
1099
+ } else {
1100
+ for (let i = 0; i < expectedSize; i++) {
1101
+ items.push(decodeCommon(reader, type, context));
1102
+ }
1103
+ }
1104
+ return items;
1105
+ }
1106
+ };
1107
+ }
1108
+ function string(length, encoding = "ascii") {
1109
+ if (!Buffer.isEncoding(encoding)) {
1110
+ throw new Error("Argument #2 should be an encoding name.");
1111
+ }
1112
+ assertLengthSpec(length);
1113
+ const lengthTypeError = "Length of a buffer should be a number.";
1114
+ return {
1115
+ encode(value, writer, context) {
1116
+ const buf = Buffer.from(value.toString(), encoding);
1117
+ if (typeof length === "number") {
1118
+ if (buf.length !== length) {
1119
+ throw new Error(`Size of string should be ${length} in bytes.`);
1120
+ }
1121
+ } else if (isType(length)) {
1122
+ length.encode(buf.length, writer, context);
1123
+ } else {
1124
+ const expected = length(context);
1125
+ checkLengthType(expected, lengthTypeError);
1126
+ checkLength(expected, buf.length, "Buffer");
1127
+ }
1128
+ writer.writeBuffer(buf);
1129
+ },
1130
+ decode(reader, context) {
1131
+ let size;
1132
+ if (typeof length === "number") {
1133
+ size = length;
1134
+ } else if (isType(length)) {
1135
+ size = length.decode(reader, context);
1136
+ checkLengthType(size, "Size of a string should be a number.");
1137
+ } else {
1138
+ size = length(context);
1139
+ checkLengthType(size, lengthTypeError);
1140
+ }
1141
+ return reader.readBuffer(size).toString(encoding);
1142
+ }
1143
+ };
1144
+ }
1145
+ var types = {
1146
+ uint8: createUIntBE(1),
1147
+ uint16be: createUIntBE(2),
1148
+ uint24be: createUIntBE(3),
1149
+ uint32be: createUIntBE(4),
1150
+ uint48be: createUIntBE(6),
1151
+ buffer,
1152
+ array,
1153
+ string
1154
+ };
1155
+
825
1156
  // src/helper.ts
826
1157
  import { EventEmitter } from "node:events";
827
1158
  function enumerate(arr) {
@@ -1148,7 +1479,6 @@ import { isIPv4 as isIPv44 } from "net";
1148
1479
  import { createSign, randomBytes as randomBytes2, webcrypto } from "crypto";
1149
1480
  import { Certificate, PrivateKey } from "@fidm/x509";
1150
1481
  import * as x509 from "@peculiar/x509";
1151
- import { encode, types } from "@shinyoshiaki/binary-data";
1152
1482
 
1153
1483
  // ../dtls/src/cipher/const.ts
1154
1484
  var SignatureAlgorithm = {
@@ -1188,7 +1518,6 @@ var signatures = [
1188
1518
 
1189
1519
  // ../dtls/src/cipher/prf.ts
1190
1520
  import { createHash, createHmac } from "crypto";
1191
- import { createDecode } from "@shinyoshiaki/binary-data";
1192
1521
  import nacl from "tweetnacl";
1193
1522
 
1194
1523
  // ../dtls/src/cipher/ec.ts
@@ -1290,7 +1619,7 @@ function prfEncryptionKeys(masterSecret, clientRandom, serverRandom, prfKeyLen,
1290
1619
  size,
1291
1620
  algorithm
1292
1621
  );
1293
- const stream = createDecode(keyBlock);
1622
+ const stream = new binaryData_exports.BinaryReader(keyBlock);
1294
1623
  const clientWriteKey = stream.readBuffer(prfKeyLen);
1295
1624
  const serverWriteKey = stream.readBuffer(prfKeyLen);
1296
1625
  const clientNonceImplicit = stream.readBuffer(prfIvLen);
@@ -1344,6 +1673,7 @@ var AbstractCipher = class {
1344
1673
  };
1345
1674
 
1346
1675
  // ../dtls/src/context/cipher.ts
1676
+ var { encode: encode2, types: types2 } = binaryData_exports;
1347
1677
  var crypto = webcrypto;
1348
1678
  x509.cryptoProvider.set(crypto);
1349
1679
  var CipherContext = class {
@@ -1489,15 +1819,13 @@ var CipherContext = class {
1489
1819
  this.signatureHashAlgorithm = signatureHash;
1490
1820
  }
1491
1821
  valueKeySignature(clientRandom, serverRandom, publicKey, namedCurve) {
1492
- const serverParams = Buffer.from(
1493
- encode(
1494
- {
1495
- type: CurveType.named_curve_3,
1496
- curve: namedCurve,
1497
- len: publicKey.length
1498
- },
1499
- { type: types.uint8, curve: types.uint16be, len: types.uint8 }
1500
- ).slice()
1822
+ const serverParams = encode2(
1823
+ {
1824
+ type: CurveType.named_curve_3,
1825
+ curve: namedCurve,
1826
+ len: publicKey.length
1827
+ },
1828
+ { type: types2.uint8, curve: types2.uint16be, len: types2.uint8 }
1501
1829
  );
1502
1830
  return Buffer.concat([clientRandom, serverRandom, serverParams, publicKey]);
1503
1831
  }
@@ -1513,12 +1841,6 @@ var SrtpContext = class {
1513
1841
  }
1514
1842
  };
1515
1843
 
1516
- // ../dtls/src/handshake/message/client/hello.ts
1517
- import { decode as decode3, encode as encode4, types as types5 } from "@shinyoshiaki/binary-data";
1518
-
1519
- // ../dtls/src/record/message/fragment.ts
1520
- import { decode, encode as encode2, types as types2 } from "@shinyoshiaki/binary-data";
1521
-
1522
1844
  // ../dtls/src/helper.ts
1523
1845
  var dumpBuffer = (data) => "0x" + data.toString("hex").replace(/(.)(.)/g, "$1$2 ").split(" ").filter((s) => s != void 0 && s.length > 0).join(",0x");
1524
1846
  var getObjectSummary = (obj) => Object.entries({ ...obj }).reduce((acc, [key, value]) => {
@@ -1532,6 +1854,7 @@ var getObjectSummary = (obj) => Object.entries({ ...obj }).reduce((acc, [key, va
1532
1854
  }, {});
1533
1855
 
1534
1856
  // ../dtls/src/record/message/fragment.ts
1857
+ var { decode: decode2, encode: encode3, types: types3 } = binaryData_exports;
1535
1858
  var FragmentedHandshake = class _FragmentedHandshake {
1536
1859
  constructor(msg_type, length, message_seq, fragment_offset, fragment_length, fragment) {
1537
1860
  this.msg_type = msg_type;
@@ -1542,12 +1865,12 @@ var FragmentedHandshake = class _FragmentedHandshake {
1542
1865
  this.fragment = fragment;
1543
1866
  }
1544
1867
  static spec = {
1545
- msg_type: types2.uint8,
1546
- length: types2.uint24be,
1547
- message_seq: types2.uint16be,
1548
- fragment_offset: types2.uint24be,
1549
- fragment_length: types2.uint24be,
1550
- fragment: types2.buffer((context) => context.current.fragment_length)
1868
+ msg_type: types3.uint8,
1869
+ length: types3.uint24be,
1870
+ message_seq: types3.uint16be,
1871
+ fragment_offset: types3.uint24be,
1872
+ fragment_length: types3.uint24be,
1873
+ fragment: types3.buffer((context) => context.current.fragment_length)
1551
1874
  };
1552
1875
  get summary() {
1553
1876
  return getObjectSummary(this);
@@ -1564,12 +1887,11 @@ var FragmentedHandshake = class _FragmentedHandshake {
1564
1887
  }
1565
1888
  static deSerialize(buf) {
1566
1889
  return new _FragmentedHandshake(
1567
- ...Object.values(decode(buf, _FragmentedHandshake.spec))
1890
+ ...Object.values(decode2(buf, _FragmentedHandshake.spec))
1568
1891
  );
1569
1892
  }
1570
1893
  serialize() {
1571
- const res = encode2(this, _FragmentedHandshake.spec).slice();
1572
- return Buffer.from(res);
1894
+ return encode3(this, _FragmentedHandshake.spec);
1573
1895
  }
1574
1896
  chunk(maxFragmentLength) {
1575
1897
  let start = 0;
@@ -1642,46 +1964,46 @@ var FragmentedHandshake = class _FragmentedHandshake {
1642
1964
  };
1643
1965
 
1644
1966
  // ../dtls/src/handshake/binary.ts
1645
- import { types as types3 } from "@shinyoshiaki/binary-data";
1646
- var { uint16be, uint24be, buffer, array, uint8, string } = types3;
1967
+ var { types: types4 } = binaryData_exports;
1968
+ var { uint16be, uint24be, buffer: buffer2, array: array2, uint8, string: string2 } = types4;
1647
1969
  var Extension = {
1648
1970
  type: uint16be,
1649
- data: buffer(uint16be)
1971
+ data: buffer2(uint16be)
1650
1972
  };
1651
- var ExtensionList = array(Extension, uint16be, "bytes");
1652
- var ASN11Cert = buffer(uint24be);
1973
+ var ExtensionList = array2(Extension, uint16be, "bytes");
1974
+ var ASN11Cert = buffer2(uint24be);
1653
1975
  var ClientCertificateType = uint8;
1654
- var DistinguishedName = string(uint16be);
1976
+ var DistinguishedName = string2(uint16be);
1655
1977
  var SignatureHashAlgorithm = { hash: uint8, signature: uint8 };
1656
1978
  var ProtocolVersion = { major: uint8, minor: uint8 };
1657
1979
 
1658
1980
  // ../dtls/src/handshake/random.ts
1659
1981
  import { randomBytes as randomBytes3 } from "crypto";
1660
- import { decode as decode2, encode as encode3, types as types4 } from "@shinyoshiaki/binary-data";
1982
+ var { decode: decode3, encode: encode4, types: types5 } = binaryData_exports;
1661
1983
  var DtlsRandom = class _DtlsRandom {
1662
1984
  constructor(gmt_unix_time = Math.floor(Date.now() / 1e3), random_bytes = randomBytes3(28)) {
1663
1985
  this.gmt_unix_time = gmt_unix_time;
1664
1986
  this.random_bytes = random_bytes;
1665
1987
  }
1666
1988
  static spec = {
1667
- gmt_unix_time: types4.uint32be,
1668
- random_bytes: types4.buffer(28)
1989
+ gmt_unix_time: types5.uint32be,
1990
+ random_bytes: types5.buffer(28)
1669
1991
  };
1670
1992
  static deSerialize(buf) {
1671
1993
  return new _DtlsRandom(
1672
- ...Object.values(decode2(buf, _DtlsRandom.spec))
1994
+ ...Object.values(decode3(buf, _DtlsRandom.spec))
1673
1995
  );
1674
1996
  }
1675
1997
  static from(spec) {
1676
1998
  return new _DtlsRandom(...Object.values(spec));
1677
1999
  }
1678
2000
  serialize() {
1679
- const res = encode3(this, _DtlsRandom.spec).slice();
1680
- return Buffer.from(res);
2001
+ return encode4(this, _DtlsRandom.spec);
1681
2002
  }
1682
2003
  };
1683
2004
 
1684
2005
  // ../dtls/src/handshake/message/client/hello.ts
2006
+ var { decode: decode4, encode: encode5, types: types6 } = binaryData_exports;
1685
2007
  var ClientHello = class _ClientHello {
1686
2008
  constructor(clientVersion, random, sessionId, cookie, cipherSuites2, compressionMethods, extensions) {
1687
2009
  this.clientVersion = clientVersion;
@@ -1695,12 +2017,12 @@ var ClientHello = class _ClientHello {
1695
2017
  msgType = 1 /* client_hello_1 */;
1696
2018
  messageSeq = 0;
1697
2019
  static spec = {
1698
- clientVersion: { major: types5.uint8, minor: types5.uint8 },
2020
+ clientVersion: { major: types6.uint8, minor: types6.uint8 },
1699
2021
  random: DtlsRandom.spec,
1700
- sessionId: types5.buffer(types5.uint8),
1701
- cookie: types5.buffer(types5.uint8),
1702
- cipherSuites: types5.array(types5.uint16be, types5.uint16be, "bytes"),
1703
- compressionMethods: types5.array(types5.uint8, types5.uint8, "bytes"),
2022
+ sessionId: types6.buffer(types6.uint8),
2023
+ cookie: types6.buffer(types6.uint8),
2024
+ cipherSuites: types6.array(types6.uint16be, types6.uint16be, "bytes"),
2025
+ compressionMethods: types6.array(types6.uint8, types6.uint8, "bytes"),
1704
2026
  extensions: ExtensionList
1705
2027
  };
1706
2028
  static createEmpty() {
@@ -1716,12 +2038,11 @@ var ClientHello = class _ClientHello {
1716
2038
  }
1717
2039
  static deSerialize(buf) {
1718
2040
  return new _ClientHello(
1719
- ...Object.values(decode3(buf, _ClientHello.spec))
2041
+ ...Object.values(decode4(buf, _ClientHello.spec))
1720
2042
  );
1721
2043
  }
1722
2044
  serialize() {
1723
- const res = encode4(this, _ClientHello.spec).slice();
1724
- return Buffer.from(res);
2045
+ return encode5(this, _ClientHello.spec);
1725
2046
  }
1726
2047
  toFragment() {
1727
2048
  const body = this.serialize();
@@ -1740,7 +2061,7 @@ var ClientHello = class _ClientHello {
1740
2061
  import { setTimeout as setTimeout2 } from "timers/promises";
1741
2062
 
1742
2063
  // ../dtls/src/record/message/header.ts
1743
- import { decode as decode4, encode as encode5, types as types6 } from "@shinyoshiaki/binary-data";
2064
+ var { decode: decode5, encode: encode6, types: types7 } = binaryData_exports;
1744
2065
  var MACHeader = class _MACHeader {
1745
2066
  constructor(epoch, sequenceNumber, contentType, protocolVersion, contentLen) {
1746
2067
  this.epoch = epoch;
@@ -1750,11 +2071,11 @@ var MACHeader = class _MACHeader {
1750
2071
  this.contentLen = contentLen;
1751
2072
  }
1752
2073
  static spec = {
1753
- epoch: types6.uint16be,
1754
- sequenceNumber: types6.uint48be,
1755
- contentType: types6.uint8,
2074
+ epoch: types7.uint16be,
2075
+ sequenceNumber: types7.uint48be,
2076
+ contentType: types7.uint8,
1756
2077
  protocolVersion: ProtocolVersion,
1757
- contentLen: types6.uint16be
2078
+ contentLen: types7.uint16be
1758
2079
  };
1759
2080
  static createEmpty() {
1760
2081
  return new _MACHeader(
@@ -1767,12 +2088,11 @@ var MACHeader = class _MACHeader {
1767
2088
  }
1768
2089
  static deSerialize(buf) {
1769
2090
  return new _MACHeader(
1770
- ...Object.values(decode4(buf, _MACHeader.spec))
2091
+ ...Object.values(decode5(buf, _MACHeader.spec))
1771
2092
  );
1772
2093
  }
1773
2094
  serialize() {
1774
- const res = encode5(this, _MACHeader.spec).slice();
1775
- return Buffer.from(res);
2095
+ return encode6(this, _MACHeader.spec);
1776
2096
  }
1777
2097
  };
1778
2098
 
@@ -1820,15 +2140,15 @@ var DtlsPlaintext = class _DtlsPlaintext {
1820
2140
  serialize() {
1821
2141
  const fragmentLength = this.fragment.length;
1822
2142
  const totalLength = 13 + fragmentLength;
1823
- const buffer2 = Buffer.alloc(totalLength);
1824
- buffer2.writeUInt8(this.recordLayerHeader.contentType, 0);
1825
- buffer2.writeUInt8(this.recordLayerHeader.protocolVersion.major, 1);
1826
- buffer2.writeUInt8(this.recordLayerHeader.protocolVersion.minor, 2);
1827
- buffer2.writeUInt16BE(this.recordLayerHeader.epoch, 3);
1828
- buffer2.writeUIntBE(this.recordLayerHeader.sequenceNumber, 5, 6);
1829
- buffer2.writeUInt16BE(fragmentLength, 11);
1830
- this.fragment.copy(buffer2, 13);
1831
- return buffer2;
2143
+ const buffer3 = Buffer.alloc(totalLength);
2144
+ buffer3.writeUInt8(this.recordLayerHeader.contentType, 0);
2145
+ buffer3.writeUInt8(this.recordLayerHeader.protocolVersion.major, 1);
2146
+ buffer3.writeUInt8(this.recordLayerHeader.protocolVersion.minor, 2);
2147
+ buffer3.writeUInt16BE(this.recordLayerHeader.epoch, 3);
2148
+ buffer3.writeUIntBE(this.recordLayerHeader.sequenceNumber, 5, 6);
2149
+ buffer3.writeUInt16BE(fragmentLength, 11);
2150
+ this.fragment.copy(buffer3, 13);
2151
+ return buffer3;
1832
2152
  }
1833
2153
  computeMACHeader() {
1834
2154
  return new MACHeader(
@@ -2386,12 +2706,12 @@ var ExtendedMasterSecret = class {
2386
2706
  };
2387
2707
 
2388
2708
  // ../dtls/src/handshake/extensions/renegotiationIndication.ts
2389
- import { decode as decode5, encode as encode6, types as types7 } from "@shinyoshiaki/binary-data";
2709
+ var { decode: decode6, encode: encode7, types: types8 } = binaryData_exports;
2390
2710
  var RenegotiationIndication = class _RenegotiationIndication {
2391
2711
  static type = 65281;
2392
2712
  static spec = {
2393
- type: types7.uint16be,
2394
- data: types7.uint8
2713
+ type: types8.uint16be,
2714
+ data: types8.uint8
2395
2715
  };
2396
2716
  type = _RenegotiationIndication.type;
2397
2717
  data = 0;
@@ -2404,12 +2724,11 @@ var RenegotiationIndication = class _RenegotiationIndication {
2404
2724
  }
2405
2725
  static deSerialize(buf) {
2406
2726
  return new _RenegotiationIndication(
2407
- decode5(buf, _RenegotiationIndication.spec)
2727
+ decode6(buf, _RenegotiationIndication.spec)
2408
2728
  );
2409
2729
  }
2410
2730
  serialize() {
2411
- const res = encode6(this, _RenegotiationIndication.spec).slice();
2412
- return Buffer.from(res);
2731
+ return encode7(this, _RenegotiationIndication.spec);
2413
2732
  }
2414
2733
  get extension() {
2415
2734
  return {
@@ -2420,13 +2739,13 @@ var RenegotiationIndication = class _RenegotiationIndication {
2420
2739
  };
2421
2740
 
2422
2741
  // ../dtls/src/handshake/extensions/useSrtp.ts
2423
- import { decode as decode6, encode as encode7, types as types8 } from "@shinyoshiaki/binary-data";
2742
+ var { decode: decode7, encode: encode8, types: types9 } = binaryData_exports;
2424
2743
  var UseSRTP = class _UseSRTP {
2425
2744
  static type = 14;
2426
2745
  // 9. IANA Considerations
2427
2746
  static spec = {
2428
- type: types8.uint16be,
2429
- data: types8.buffer(types8.uint16be)
2747
+ type: types9.uint16be,
2748
+ data: types9.buffer(types9.uint16be)
2430
2749
  };
2431
2750
  type = _UseSRTP.type;
2432
2751
  data = Buffer.from([]);
@@ -2443,7 +2762,7 @@ var UseSRTP = class _UseSRTP {
2443
2762
  return v;
2444
2763
  }
2445
2764
  static deSerialize(buf) {
2446
- const useSrtp = new _UseSRTP(decode6(buf, _UseSRTP.spec));
2765
+ const useSrtp = new _UseSRTP(decode7(buf, _UseSRTP.spec));
2447
2766
  const profileLength = useSrtp.data.readUInt16BE();
2448
2767
  const profiles = new Array(profileLength / 2);
2449
2768
  for (let i = 0; i < profiles.length; i++) {
@@ -2466,8 +2785,7 @@ var UseSRTP = class _UseSRTP {
2466
2785
  this.mki
2467
2786
  ]);
2468
2787
  this.data = data;
2469
- const res = encode7(this, _UseSRTP.spec).slice();
2470
- return Buffer.from(res);
2788
+ return encode8(this, _UseSRTP.spec);
2471
2789
  }
2472
2790
  static fromData(buf) {
2473
2791
  const head = Buffer.alloc(4);
@@ -2484,7 +2802,7 @@ var UseSRTP = class _UseSRTP {
2484
2802
  };
2485
2803
 
2486
2804
  // ../dtls/src/handshake/message/certificate.ts
2487
- import { decode as decode7, encode as encode8, types as types9 } from "@shinyoshiaki/binary-data";
2805
+ var { decode: decode8, encode: encode9, types: types10 } = binaryData_exports;
2488
2806
  var Certificate2 = class _Certificate {
2489
2807
  constructor(certificateList) {
2490
2808
  this.certificateList = certificateList;
@@ -2492,19 +2810,18 @@ var Certificate2 = class _Certificate {
2492
2810
  msgType = 11 /* certificate_11 */;
2493
2811
  messageSeq;
2494
2812
  static spec = {
2495
- certificateList: types9.array(ASN11Cert, types9.uint24be, "bytes")
2813
+ certificateList: types10.array(ASN11Cert, types10.uint24be, "bytes")
2496
2814
  };
2497
2815
  static createEmpty() {
2498
2816
  return new _Certificate(void 0);
2499
2817
  }
2500
2818
  static deSerialize(buf) {
2501
2819
  return new _Certificate(
2502
- ...Object.values(decode7(buf, _Certificate.spec))
2820
+ ...Object.values(decode8(buf, _Certificate.spec))
2503
2821
  );
2504
2822
  }
2505
2823
  serialize() {
2506
- const res = encode8(this, _Certificate.spec).slice();
2507
- return Buffer.from(res);
2824
+ return encode9(this, _Certificate.spec);
2508
2825
  }
2509
2826
  toFragment() {
2510
2827
  const body = this.serialize();
@@ -2520,30 +2837,29 @@ var Certificate2 = class _Certificate {
2520
2837
  };
2521
2838
 
2522
2839
  // ../dtls/src/handshake/message/changeCipherSpec.ts
2523
- import { decode as decode8, encode as encode9, types as types10 } from "@shinyoshiaki/binary-data";
2840
+ var { decode: decode9, encode: encode10, types: types11 } = binaryData_exports;
2524
2841
  var ChangeCipherSpec = class _ChangeCipherSpec {
2525
2842
  constructor(type = 1) {
2526
2843
  this.type = type;
2527
2844
  }
2528
2845
  static spec = {
2529
- type: types10.uint8
2846
+ type: types11.uint8
2530
2847
  };
2531
2848
  static createEmpty() {
2532
2849
  return new _ChangeCipherSpec();
2533
2850
  }
2534
2851
  static deSerialize(buf) {
2535
2852
  return new _ChangeCipherSpec(
2536
- ...Object.values(decode8(buf, _ChangeCipherSpec.spec))
2853
+ ...Object.values(decode9(buf, _ChangeCipherSpec.spec))
2537
2854
  );
2538
2855
  }
2539
2856
  serialize() {
2540
- const res = encode9(this, _ChangeCipherSpec.spec).slice();
2541
- return Buffer.from(res);
2857
+ return encode10(this, _ChangeCipherSpec.spec);
2542
2858
  }
2543
2859
  };
2544
2860
 
2545
2861
  // ../dtls/src/handshake/message/client/certificateVerify.ts
2546
- import { decode as decode9, encode as encode10, types as types11 } from "@shinyoshiaki/binary-data";
2862
+ var { decode: decode10, encode: encode11, types: types12 } = binaryData_exports;
2547
2863
  var CertificateVerify = class _CertificateVerify {
2548
2864
  constructor(algorithm, signature) {
2549
2865
  this.algorithm = algorithm;
@@ -2552,21 +2868,20 @@ var CertificateVerify = class _CertificateVerify {
2552
2868
  msgType = 15 /* certificate_verify_15 */;
2553
2869
  messageSeq;
2554
2870
  static spec = {
2555
- algorithm: types11.uint16be,
2556
- signature: types11.buffer(types11.uint16be)
2871
+ algorithm: types12.uint16be,
2872
+ signature: types12.buffer(types12.uint16be)
2557
2873
  };
2558
2874
  static createEmpty() {
2559
2875
  return new _CertificateVerify(void 0, void 0);
2560
2876
  }
2561
2877
  static deSerialize(buf) {
2562
- const res = decode9(buf, _CertificateVerify.spec);
2878
+ const res = decode10(buf, _CertificateVerify.spec);
2563
2879
  return new _CertificateVerify(
2564
2880
  ...Object.values(res)
2565
2881
  );
2566
2882
  }
2567
2883
  serialize() {
2568
- const res = encode10(this, _CertificateVerify.spec).slice();
2569
- return Buffer.from(res);
2884
+ return encode11(this, _CertificateVerify.spec);
2570
2885
  }
2571
2886
  toFragment() {
2572
2887
  const body = this.serialize();
@@ -2582,7 +2897,7 @@ var CertificateVerify = class _CertificateVerify {
2582
2897
  };
2583
2898
 
2584
2899
  // ../dtls/src/handshake/message/client/keyExchange.ts
2585
- import { decode as decode10, encode as encode11, types as types12 } from "@shinyoshiaki/binary-data";
2900
+ var { decode: decode11, encode: encode12, types: types13 } = binaryData_exports;
2586
2901
  var ClientKeyExchange = class _ClientKeyExchange {
2587
2902
  constructor(publicKey) {
2588
2903
  this.publicKey = publicKey;
@@ -2590,20 +2905,19 @@ var ClientKeyExchange = class _ClientKeyExchange {
2590
2905
  msgType = 16 /* client_key_exchange_16 */;
2591
2906
  messageSeq;
2592
2907
  static spec = {
2593
- publicKey: types12.buffer(types12.uint8)
2908
+ publicKey: types13.buffer(types13.uint8)
2594
2909
  };
2595
2910
  static createEmpty() {
2596
2911
  return new _ClientKeyExchange(void 0);
2597
2912
  }
2598
2913
  static deSerialize(buf) {
2599
- const res = decode10(buf, _ClientKeyExchange.spec);
2914
+ const res = decode11(buf, _ClientKeyExchange.spec);
2600
2915
  return new _ClientKeyExchange(
2601
2916
  ...Object.values(res)
2602
2917
  );
2603
2918
  }
2604
2919
  serialize() {
2605
- const res = encode11(this, _ClientKeyExchange.spec).slice();
2606
- return Buffer.from(res);
2920
+ return encode12(this, _ClientKeyExchange.spec);
2607
2921
  }
2608
2922
  toFragment() {
2609
2923
  const body = this.serialize();
@@ -2648,7 +2962,7 @@ var Finished = class _Finished {
2648
2962
  };
2649
2963
 
2650
2964
  // ../dtls/src/handshake/message/server/certificateRequest.ts
2651
- import { decode as decode11, encode as encode12, types as types13 } from "@shinyoshiaki/binary-data";
2965
+ var { decode: decode12, encode: encode13, types: types14 } = binaryData_exports;
2652
2966
  var ServerCertificateRequest = class _ServerCertificateRequest {
2653
2967
  constructor(certificateTypes2, signatures2, authorities) {
2654
2968
  this.certificateTypes = certificateTypes2;
@@ -2658,9 +2972,9 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
2658
2972
  msgType = 13 /* certificate_request_13 */;
2659
2973
  messageSeq;
2660
2974
  static spec = {
2661
- certificateTypes: types13.array(ClientCertificateType, types13.uint8, "bytes"),
2662
- signatures: types13.array(SignatureHashAlgorithm, types13.uint16be, "bytes"),
2663
- authorities: types13.array(DistinguishedName, types13.uint16be, "bytes")
2975
+ certificateTypes: types14.array(ClientCertificateType, types14.uint8, "bytes"),
2976
+ signatures: types14.array(SignatureHashAlgorithm, types14.uint16be, "bytes"),
2977
+ authorities: types14.array(DistinguishedName, types14.uint16be, "bytes")
2664
2978
  };
2665
2979
  static createEmpty() {
2666
2980
  return new _ServerCertificateRequest(
@@ -2671,12 +2985,11 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
2671
2985
  }
2672
2986
  static deSerialize(buf) {
2673
2987
  return new _ServerCertificateRequest(
2674
- ...Object.values(decode11(buf, _ServerCertificateRequest.spec))
2988
+ ...Object.values(decode12(buf, _ServerCertificateRequest.spec))
2675
2989
  );
2676
2990
  }
2677
2991
  serialize() {
2678
- const res = encode12(this, _ServerCertificateRequest.spec).slice();
2679
- return Buffer.from(res);
2992
+ return encode13(this, _ServerCertificateRequest.spec);
2680
2993
  }
2681
2994
  toFragment() {
2682
2995
  const body = this.serialize();
@@ -2692,7 +3005,7 @@ var ServerCertificateRequest = class _ServerCertificateRequest {
2692
3005
  };
2693
3006
 
2694
3007
  // ../dtls/src/handshake/message/server/hello.ts
2695
- import { decode as decode12, encode as encode13, types as types14 } from "@shinyoshiaki/binary-data";
3008
+ var { decode: decode13, encode: encode14, types: types15 } = binaryData_exports;
2696
3009
  var ServerHello = class _ServerHello {
2697
3010
  constructor(serverVersion, random, sessionId, cipherSuite, compressionMethod, extensions) {
2698
3011
  this.serverVersion = serverVersion;
@@ -2707,9 +3020,9 @@ var ServerHello = class _ServerHello {
2707
3020
  static spec = {
2708
3021
  serverVersion: ProtocolVersion,
2709
3022
  random: DtlsRandom.spec,
2710
- sessionId: types14.buffer(types14.uint8),
2711
- cipherSuite: types14.uint16be,
2712
- compressionMethod: types14.uint8
3023
+ sessionId: types15.buffer(types15.uint8),
3024
+ cipherSuite: types15.uint16be,
3025
+ compressionMethod: types15.uint8
2713
3026
  };
2714
3027
  static createEmpty() {
2715
3028
  return new _ServerHello(
@@ -2722,7 +3035,7 @@ var ServerHello = class _ServerHello {
2722
3035
  );
2723
3036
  }
2724
3037
  static deSerialize(buf) {
2725
- const res = decode12(buf, _ServerHello.spec);
3038
+ const res = decode13(buf, _ServerHello.spec);
2726
3039
  const cls = new _ServerHello(
2727
3040
  ...Object.values(res)
2728
3041
  );
@@ -2730,18 +3043,17 @@ var ServerHello = class _ServerHello {
2730
3043
  if (expect.length < buf.length) {
2731
3044
  return new _ServerHello(
2732
3045
  ...Object.values(
2733
- decode12(buf, { ..._ServerHello.spec, extensions: ExtensionList })
3046
+ decode13(buf, { ..._ServerHello.spec, extensions: ExtensionList })
2734
3047
  )
2735
3048
  );
2736
3049
  }
2737
3050
  return cls;
2738
3051
  }
2739
3052
  serialize() {
2740
- const res = this.extensions === void 0 ? encode13(this, _ServerHello.spec).slice() : encode13(this, {
3053
+ return this.extensions === void 0 ? encode14(this, _ServerHello.spec) : encode14(this, {
2741
3054
  ..._ServerHello.spec,
2742
3055
  extensions: ExtensionList
2743
- }).slice();
2744
- return Buffer.from(res);
3056
+ });
2745
3057
  }
2746
3058
  toFragment() {
2747
3059
  const body = this.serialize();
@@ -2757,7 +3069,7 @@ var ServerHello = class _ServerHello {
2757
3069
  };
2758
3070
 
2759
3071
  // ../dtls/src/handshake/message/server/helloDone.ts
2760
- import { decode as decode13, encode as encode14 } from "@shinyoshiaki/binary-data";
3072
+ var { decode: decode14, encode: encode15 } = binaryData_exports;
2761
3073
  var ServerHelloDone = class _ServerHelloDone {
2762
3074
  msgType = 14 /* server_hello_done_14 */;
2763
3075
  messageSeq;
@@ -2767,12 +3079,11 @@ var ServerHelloDone = class _ServerHelloDone {
2767
3079
  }
2768
3080
  static deSerialize(buf) {
2769
3081
  return new _ServerHelloDone(
2770
- ...Object.values(decode13(buf, _ServerHelloDone.spec))
3082
+ ...Object.values(decode14(buf, _ServerHelloDone.spec))
2771
3083
  );
2772
3084
  }
2773
3085
  serialize() {
2774
- const res = encode14(this, _ServerHelloDone.spec).slice();
2775
- return Buffer.from(res);
3086
+ return encode15(this, _ServerHelloDone.spec);
2776
3087
  }
2777
3088
  toFragment() {
2778
3089
  const body = this.serialize();
@@ -2787,16 +3098,14 @@ var ServerHelloDone = class _ServerHelloDone {
2787
3098
  }
2788
3099
  };
2789
3100
 
2790
- // ../dtls/src/handshake/message/server/keyExchange.ts
2791
- import { decode as decode14, types as types15 } from "@shinyoshiaki/binary-data";
2792
-
2793
3101
  // ../dtls/src/util/binary.ts
2794
- import { encode as encode15 } from "@shinyoshiaki/binary-data";
3102
+ var { encode: encode16 } = binaryData_exports;
2795
3103
  function encodeBuffer(obj, spec) {
2796
- return Buffer.from(encode15(obj, spec).slice());
3104
+ return encode16(obj, spec);
2797
3105
  }
2798
3106
 
2799
3107
  // ../dtls/src/handshake/message/server/keyExchange.ts
3108
+ var { decode: decode15, types: types16 } = binaryData_exports;
2800
3109
  var ServerKeyExchange = class _ServerKeyExchange {
2801
3110
  constructor(ellipticCurveType, namedCurve, publicKeyLength, publicKey, hashAlgorithm, signatureAlgorithm, signatureLength, signature) {
2802
3111
  this.ellipticCurveType = ellipticCurveType;
@@ -2811,14 +3120,14 @@ var ServerKeyExchange = class _ServerKeyExchange {
2811
3120
  msgType = 12 /* server_key_exchange_12 */;
2812
3121
  messageSeq;
2813
3122
  static spec = {
2814
- ellipticCurveType: types15.uint8,
2815
- namedCurve: types15.uint16be,
2816
- publicKeyLength: types15.uint8,
2817
- publicKey: types15.buffer((ctx) => ctx.current.publicKeyLength),
2818
- hashAlgorithm: types15.uint8,
2819
- signatureAlgorithm: types15.uint8,
2820
- signatureLength: types15.uint16be,
2821
- signature: types15.buffer((ctx) => ctx.current.signatureLength)
3123
+ ellipticCurveType: types16.uint8,
3124
+ namedCurve: types16.uint16be,
3125
+ publicKeyLength: types16.uint8,
3126
+ publicKey: types16.buffer((ctx) => ctx.current.publicKeyLength),
3127
+ hashAlgorithm: types16.uint8,
3128
+ signatureAlgorithm: types16.uint8,
3129
+ signatureLength: types16.uint16be,
3130
+ signature: types16.buffer((ctx) => ctx.current.signatureLength)
2822
3131
  };
2823
3132
  static createEmpty() {
2824
3133
  return new _ServerKeyExchange(
@@ -2833,7 +3142,7 @@ var ServerKeyExchange = class _ServerKeyExchange {
2833
3142
  );
2834
3143
  }
2835
3144
  static deSerialize(buf) {
2836
- const res = decode14(buf, _ServerKeyExchange.spec);
3145
+ const res = decode15(buf, _ServerKeyExchange.spec);
2837
3146
  return new _ServerKeyExchange(
2838
3147
  ...Object.values(res)
2839
3148
  );
@@ -5874,7 +6183,7 @@ handlers[14 /* server_hello_done_14 */] = ({ dtls }) => (msg) => {
5874
6183
  };
5875
6184
 
5876
6185
  // ../dtls/src/handshake/message/server/helloVerifyRequest.ts
5877
- import { decode as decode15, encode as encode16, types as types16 } from "@shinyoshiaki/binary-data";
6186
+ var { decode: decode16, encode: encode17, types: types17 } = binaryData_exports;
5878
6187
  var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
5879
6188
  constructor(serverVersion, cookie) {
5880
6189
  this.serverVersion = serverVersion;
@@ -5884,19 +6193,18 @@ var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
5884
6193
  messageSeq;
5885
6194
  static spec = {
5886
6195
  serverVersion: ProtocolVersion,
5887
- cookie: types16.buffer(types16.uint8)
6196
+ cookie: types17.buffer(types17.uint8)
5888
6197
  };
5889
6198
  static createEmpty() {
5890
6199
  return new _ServerHelloVerifyRequest(void 0, void 0);
5891
6200
  }
5892
6201
  static deSerialize(buf) {
5893
6202
  return new _ServerHelloVerifyRequest(
5894
- ...Object.values(decode15(buf, _ServerHelloVerifyRequest.spec))
6203
+ ...Object.values(decode16(buf, _ServerHelloVerifyRequest.spec))
5895
6204
  );
5896
6205
  }
5897
6206
  serialize() {
5898
- const res = encode16(this, _ServerHelloVerifyRequest.spec).slice();
5899
- return Buffer.from(res);
6207
+ return encode17(this, _ServerHelloVerifyRequest.spec);
5900
6208
  }
5901
6209
  get version() {
5902
6210
  return {
@@ -5918,7 +6226,6 @@ var ServerHelloVerifyRequest = class _ServerHelloVerifyRequest {
5918
6226
  };
5919
6227
 
5920
6228
  // ../dtls/src/socket.ts
5921
- import { decode as decode19, types as types20 } from "@shinyoshiaki/binary-data";
5922
6229
  import { setTimeout as setTimeout3 } from "timers/promises";
5923
6230
 
5924
6231
  // ../dtls/src/context/dtls.ts
@@ -5983,12 +6290,12 @@ var TransportContext = class {
5983
6290
  };
5984
6291
 
5985
6292
  // ../dtls/src/handshake/extensions/ellipticCurves.ts
5986
- import { decode as decode16, encode as encode17, types as types17 } from "@shinyoshiaki/binary-data";
6293
+ var { decode: decode17, encode: encode18, types: types18 } = binaryData_exports;
5987
6294
  var EllipticCurves = class _EllipticCurves {
5988
6295
  static type = 10;
5989
6296
  static spec = {
5990
- type: types17.uint16be,
5991
- data: types17.array(types17.uint16be, types17.uint16be, "bytes")
6297
+ type: types18.uint16be,
6298
+ data: types18.array(types18.uint16be, types18.uint16be, "bytes")
5992
6299
  };
5993
6300
  type = _EllipticCurves.type;
5994
6301
  data = [];
@@ -6001,14 +6308,14 @@ var EllipticCurves = class _EllipticCurves {
6001
6308
  static fromData(buf) {
6002
6309
  return new _EllipticCurves({
6003
6310
  type: _EllipticCurves.type,
6004
- data: decode16(buf, _EllipticCurves.spec.data)
6311
+ data: decode17(buf, _EllipticCurves.spec.data)
6005
6312
  });
6006
6313
  }
6007
6314
  static deSerialize(buf) {
6008
- return new _EllipticCurves(decode16(buf, _EllipticCurves.spec));
6315
+ return new _EllipticCurves(decode17(buf, _EllipticCurves.spec));
6009
6316
  }
6010
6317
  serialize() {
6011
- return Buffer.from(encode17(this, _EllipticCurves.spec).slice());
6318
+ return encode18(this, _EllipticCurves.spec);
6012
6319
  }
6013
6320
  get extension() {
6014
6321
  return {
@@ -6019,14 +6326,14 @@ var EllipticCurves = class _EllipticCurves {
6019
6326
  };
6020
6327
 
6021
6328
  // ../dtls/src/handshake/extensions/signature.ts
6022
- import { decode as decode17, encode as encode18, types as types18 } from "@shinyoshiaki/binary-data";
6329
+ var { decode: decode18, encode: encode19, types: types19 } = binaryData_exports;
6023
6330
  var Signature = class _Signature {
6024
6331
  static type = 13;
6025
6332
  static spec = {
6026
- type: types18.uint16be,
6027
- data: types18.array(
6028
- { hash: types18.uint8, signature: types18.uint8 },
6029
- types18.uint16be,
6333
+ type: types19.uint16be,
6334
+ data: types19.array(
6335
+ { hash: types19.uint8, signature: types19.uint8 },
6336
+ types19.uint16be,
6030
6337
  "bytes"
6031
6338
  )
6032
6339
  };
@@ -6040,11 +6347,10 @@ var Signature = class _Signature {
6040
6347
  return v;
6041
6348
  }
6042
6349
  static deSerialize(buf) {
6043
- return new _Signature(decode17(buf, _Signature.spec));
6350
+ return new _Signature(decode18(buf, _Signature.spec));
6044
6351
  }
6045
6352
  serialize() {
6046
- const res = encode18(this, _Signature.spec).slice();
6047
- return Buffer.from(res);
6353
+ return encode19(this, _Signature.spec);
6048
6354
  }
6049
6355
  static fromData(buf) {
6050
6356
  const type = Buffer.alloc(2);
@@ -6060,24 +6366,23 @@ var Signature = class _Signature {
6060
6366
  };
6061
6367
 
6062
6368
  // ../dtls/src/handshake/message/alert.ts
6063
- import { decode as decode18, encode as encode19, types as types19 } from "@shinyoshiaki/binary-data";
6369
+ var { decode: decode19, encode: encode20, types: types20 } = binaryData_exports;
6064
6370
  var Alert = class _Alert {
6065
6371
  constructor(level, description) {
6066
6372
  this.level = level;
6067
6373
  this.description = description;
6068
6374
  }
6069
6375
  static spec = {
6070
- level: types19.uint8,
6071
- description: types19.uint8
6376
+ level: types20.uint8,
6377
+ description: types20.uint8
6072
6378
  };
6073
6379
  static deSerialize(buf) {
6074
6380
  return new _Alert(
6075
- ...Object.values(decode18(buf, _Alert.spec))
6381
+ ...Object.values(decode19(buf, _Alert.spec))
6076
6382
  );
6077
6383
  }
6078
6384
  serialize() {
6079
- const res = encode19(this, _Alert.spec).slice();
6080
- return Buffer.from(res);
6385
+ return encode20(this, _Alert.spec);
6081
6386
  }
6082
6387
  };
6083
6388
 
@@ -6173,6 +6478,7 @@ var parsePlainText = (dtls, cipher) => (plain) => {
6173
6478
  };
6174
6479
 
6175
6480
  // ../dtls/src/socket.ts
6481
+ var { decode: decode20, types: types21 } = binaryData_exports;
6176
6482
  var log13 = debug("werift-dtls : packages/dtls/src/socket.ts : log");
6177
6483
  var err4 = debug("werift-dtls : packages/dtls/src/socket.ts : err");
6178
6484
  var DtlsSocket = class {
@@ -6332,13 +6638,13 @@ var DtlsSocket = class {
6332
6638
  "EXTRACTOR-dtls_srtp",
6333
6639
  keyLength2 * 2 + saltLength2 * 2
6334
6640
  );
6335
- const { clientKey, serverKey, clientSalt, serverSalt } = decode19(
6641
+ const { clientKey, serverKey, clientSalt, serverSalt } = decode20(
6336
6642
  keyingMaterial,
6337
6643
  {
6338
- clientKey: types20.buffer(keyLength2),
6339
- serverKey: types20.buffer(keyLength2),
6340
- clientSalt: types20.buffer(saltLength2),
6341
- serverSalt: types20.buffer(saltLength2)
6644
+ clientKey: types21.buffer(keyLength2),
6645
+ serverKey: types21.buffer(keyLength2),
6646
+ clientSalt: types21.buffer(saltLength2),
6647
+ serverSalt: types21.buffer(saltLength2)
6342
6648
  }
6343
6649
  );
6344
6650
  if (this.sessionType === SessionType.CLIENT) {
@@ -6931,20 +7237,20 @@ function encodeTcpFrame(data) {
6931
7237
  header.writeUInt16BE(data.length, 0);
6932
7238
  return Buffer.concat([header, data]);
6933
7239
  }
6934
- function splitTcpFrames(buffer2) {
7240
+ function splitTcpFrames(buffer3) {
6935
7241
  const frames = [];
6936
7242
  let offset = 0;
6937
- while (buffer2.length - offset >= 2) {
6938
- const length = buffer2.readUInt16BE(offset);
6939
- if (buffer2.length - offset < length + 2) {
7243
+ while (buffer3.length - offset >= 2) {
7244
+ const length = buffer3.readUInt16BE(offset);
7245
+ if (buffer3.length - offset < length + 2) {
6940
7246
  break;
6941
7247
  }
6942
- frames.push(buffer2.subarray(offset + 2, offset + 2 + length));
7248
+ frames.push(buffer3.subarray(offset + 2, offset + 2 + length));
6943
7249
  offset += 2 + length;
6944
7250
  }
6945
7251
  return {
6946
7252
  frames,
6947
- rest: buffer2.subarray(offset)
7253
+ rest: buffer3.subarray(offset)
6948
7254
  };
6949
7255
  }
6950
7256
 
@@ -7025,11 +7331,11 @@ function isIpV4Address(address) {
7025
7331
  function packAddress(value) {
7026
7332
  const [address] = value;
7027
7333
  const protocol = isIpV4Address(address) ? IPV4_PROTOCOL : IPV6_PROTOCOL;
7028
- const buffer2 = Buffer.alloc(4);
7029
- buffer2.writeUInt8(0, 0);
7030
- buffer2.writeUInt8(protocol, 1);
7031
- buffer2.writeUInt16BE(value[1], 2);
7032
- return Buffer.concat([buffer2, ipAddressToBuffer(address)]);
7334
+ const buffer3 = Buffer.alloc(4);
7335
+ buffer3.writeUInt8(0, 0);
7336
+ buffer3.writeUInt8(protocol, 1);
7337
+ buffer3.writeUInt16BE(value[1], 2);
7338
+ return Buffer.concat([buffer3, ipAddressToBuffer(address)]);
7033
7339
  }
7034
7340
  function unpackErrorCode(data) {
7035
7341
  if (data.length < 4) {
@@ -7080,19 +7386,19 @@ function unpackXorAddress(data, transactionId) {
7080
7386
  return unpackAddress(xorAddress(data, transactionId));
7081
7387
  }
7082
7388
  function packErrorCode(value) {
7083
- const buffer2 = Buffer.alloc(4);
7084
- buffer2.writeUInt16BE(0, 0);
7085
- buffer2.writeUInt8(Math.floor(value[0] / 100), 2);
7086
- buffer2.writeUInt8(value[0] % 100, 3);
7389
+ const buffer3 = Buffer.alloc(4);
7390
+ buffer3.writeUInt16BE(0, 0);
7391
+ buffer3.writeUInt8(Math.floor(value[0] / 100), 2);
7392
+ buffer3.writeUInt8(value[0] % 100, 3);
7087
7393
  const encoded = Buffer.from(value[1], "utf8");
7088
- return Buffer.concat([buffer2, encoded]);
7394
+ return Buffer.concat([buffer3, encoded]);
7089
7395
  }
7090
7396
  function packUnknownAttributes(value) {
7091
- const buffer2 = Buffer.alloc(value.length * 2);
7397
+ const buffer3 = Buffer.alloc(value.length * 2);
7092
7398
  value.forEach((attributeType, index) => {
7093
- buffer2.writeUInt16BE(attributeType, index * 2);
7399
+ buffer3.writeUInt16BE(attributeType, index * 2);
7094
7400
  });
7095
- return buffer2;
7401
+ return buffer3;
7096
7402
  }
7097
7403
  function unpackUnknownAttributes(data) {
7098
7404
  if (data.length % 2 !== 0) {
@@ -7108,21 +7414,21 @@ function packXorAddress(value, transactionId) {
7108
7414
  return xorAddress(packAddress(value), transactionId);
7109
7415
  }
7110
7416
  var packUnsigned = (value) => {
7111
- const buffer2 = Buffer.alloc(4);
7112
- buffer2.writeUInt32BE(value, 0);
7113
- return buffer2;
7417
+ const buffer3 = Buffer.alloc(4);
7418
+ buffer3.writeUInt32BE(value, 0);
7419
+ return buffer3;
7114
7420
  };
7115
7421
  var unpackUnsigned = (data) => data.readUInt32BE(0);
7116
7422
  var packUnsignedShort = (value) => {
7117
- const buffer2 = Buffer.alloc(4);
7118
- buffer2.writeUInt16BE(value, 0);
7119
- return buffer2;
7423
+ const buffer3 = Buffer.alloc(4);
7424
+ buffer3.writeUInt16BE(value, 0);
7425
+ return buffer3;
7120
7426
  };
7121
7427
  var unpackUnsignedShort = (data) => data.readUInt16BE(0);
7122
7428
  var packUnsigned64 = (value) => {
7123
- const buffer2 = Buffer.allocUnsafe(8);
7124
- buffer2.writeBigUInt64BE(value, 0);
7125
- return buffer2;
7429
+ const buffer3 = Buffer.allocUnsafe(8);
7430
+ buffer3.writeBigUInt64BE(value, 0);
7431
+ return buffer3;
7126
7432
  };
7127
7433
  var unpackUnsigned64 = (data) => data.readBigUInt64BE(0);
7128
7434
  var packString = (value) => Buffer.from(value, "utf8");
@@ -8155,35 +8461,35 @@ function padTurnFrame(data) {
8155
8461
  const padding = paddingLength(data.length);
8156
8462
  return padding > 0 ? Buffer.concat([data, Buffer.alloc(padding)]) : data;
8157
8463
  }
8158
- function splitTurnTcpFrames(buffer2) {
8464
+ function splitTurnTcpFrames(buffer3) {
8159
8465
  const frames = [];
8160
8466
  let offset = 0;
8161
8467
  let malformed = false;
8162
- while (buffer2.length - offset >= 4) {
8468
+ while (buffer3.length - offset >= 4) {
8163
8469
  let frameLength;
8164
- if (isChannelData(buffer2.subarray(offset))) {
8165
- const payloadLength = buffer2.readUInt16BE(offset + 2);
8470
+ if (isChannelData(buffer3.subarray(offset))) {
8471
+ const payloadLength = buffer3.readUInt16BE(offset + 2);
8166
8472
  frameLength = 4 + payloadLength + paddingLength(payloadLength);
8167
- } else if ((buffer2[offset] & 192) === 0) {
8168
- if (buffer2.length - offset < 20) {
8473
+ } else if ((buffer3[offset] & 192) === 0) {
8474
+ if (buffer3.length - offset < 20) {
8169
8475
  break;
8170
8476
  }
8171
- const stunBodyLength = buffer2.readUInt16BE(offset + 2);
8477
+ const stunBodyLength = buffer3.readUInt16BE(offset + 2);
8172
8478
  frameLength = 20 + stunBodyLength + paddingLength(stunBodyLength);
8173
8479
  } else {
8174
8480
  malformed = true;
8175
8481
  break;
8176
8482
  }
8177
- if (buffer2.length - offset < frameLength) {
8483
+ if (buffer3.length - offset < frameLength) {
8178
8484
  break;
8179
8485
  }
8180
- frames.push(buffer2.subarray(offset, offset + frameLength));
8486
+ frames.push(buffer3.subarray(offset, offset + frameLength));
8181
8487
  offset += frameLength;
8182
8488
  }
8183
8489
  return {
8184
8490
  frames,
8185
8491
  malformed,
8186
- rest: buffer2.subarray(offset)
8492
+ rest: buffer3.subarray(offset)
8187
8493
  };
8188
8494
  }
8189
8495
 
@@ -15801,11 +16107,11 @@ var RtpRouter = class {
15801
16107
  }
15802
16108
  registerRtpReceiverBySsrc(transceiver, params) {
15803
16109
  log33("registerRtpReceiverBySsrc", params);
15804
- params.encodings.filter((e) => e.ssrc != void 0).forEach((encode20, i) => {
15805
- this.registerRtpReceiver(transceiver.receiver, encode20.ssrc);
16110
+ params.encodings.filter((e) => e.ssrc != void 0).forEach((encode21, i) => {
16111
+ this.registerRtpReceiver(transceiver.receiver, encode21.ssrc);
15806
16112
  transceiver.addTrack(
15807
16113
  new MediaStreamTrack({
15808
- ssrc: encode20.ssrc,
16114
+ ssrc: encode21.ssrc,
15809
16115
  kind: transceiver.kind,
15810
16116
  id: transceiver.sender.trackId,
15811
16117
  remote: true,
@@ -15816,8 +16122,8 @@ var RtpRouter = class {
15816
16122
  )
15817
16123
  })
15818
16124
  );
15819
- if (encode20.rtx) {
15820
- this.registerRtpReceiver(transceiver.receiver, encode20.rtx.ssrc);
16125
+ if (encode21.rtx) {
16126
+ this.registerRtpReceiver(transceiver.receiver, encode21.rtx.ssrc);
15821
16127
  }
15822
16128
  });
15823
16129
  params.headerExtensions.forEach((extension) => {
@@ -21845,18 +22151,18 @@ var JitterBufferBase = class {
21845
22151
  return resolve2;
21846
22152
  }
21847
22153
  sortAndClearBuffer(rtpBuffer) {
21848
- const buffer2 = [];
22154
+ const buffer3 = [];
21849
22155
  for (let index = this.presentSeqNum ?? 0; ; index = uint16Add(index, 1)) {
21850
22156
  const rtp = rtpBuffer[index];
21851
22157
  if (rtp) {
21852
- buffer2.push(rtp);
22158
+ buffer3.push(rtp);
21853
22159
  delete rtpBuffer[index];
21854
22160
  }
21855
22161
  if (Object.values(rtpBuffer).length === 0) {
21856
22162
  break;
21857
22163
  }
21858
22164
  }
21859
- return buffer2;
22165
+ return buffer3;
21860
22166
  }
21861
22167
  disposeTimeoutPackets(baseTimestamp) {
21862
22168
  let latestTimeoutSeqNum;
@@ -22527,16 +22833,16 @@ function containsH264ParameterSets(nalUnits) {
22527
22833
  function looksLikeAnnexB(sample) {
22528
22834
  return sample.length >= 4 && sample[0] === 0 && sample[1] === 0 && (sample[2] === 0 && sample[3] === 1 || sample[2] === 1);
22529
22835
  }
22530
- function readUintLength(buffer2, offset, length) {
22836
+ function readUintLength(buffer3, offset, length) {
22531
22837
  switch (length) {
22532
22838
  case 1:
22533
- return buffer2.readUInt8(offset);
22839
+ return buffer3.readUInt8(offset);
22534
22840
  case 2:
22535
- return buffer2.readUInt16BE(offset);
22841
+ return buffer3.readUInt16BE(offset);
22536
22842
  case 3:
22537
- return buffer2.readUIntBE(offset, 3);
22843
+ return buffer3.readUIntBE(offset, 3);
22538
22844
  case 4:
22539
- return buffer2.readUInt32BE(offset);
22845
+ return buffer3.readUInt32BE(offset);
22540
22846
  default:
22541
22847
  throw new Error(`unsupported H264 NALU length size: ${length}`);
22542
22848
  }
@@ -22909,14 +23215,14 @@ async function createReplayableSource(options) {
22909
23215
  if (typeof options.path === "string") {
22910
23216
  return { path: options.path };
22911
23217
  }
22912
- const buffer2 = options.buffer != void 0 ? toBuffer2(options.buffer) : await readStreamToBuffer(options.stream);
22913
- return { buffer: buffer2 };
23218
+ const buffer3 = options.buffer != void 0 ? toBuffer2(options.buffer) : await readStreamToBuffer(options.stream);
23219
+ return { buffer: buffer3 };
22914
23220
  }
22915
23221
  async function createInput(options) {
22916
23222
  if (typeof options.path === "string") {
22917
- const buffer2 = await readFile(resolveUserMediaPath(options.path));
23223
+ const buffer3 = await readFile(resolveUserMediaPath(options.path));
22918
23224
  return new Input({
22919
- source: new BufferSource(buffer2),
23225
+ source: new BufferSource(buffer3),
22920
23226
  formats: [MP4, WEBM]
22921
23227
  });
22922
23228
  }
@@ -23377,8 +23683,8 @@ async function readEntireStream(stream, signal = new AbortController().signal) {
23377
23683
  }
23378
23684
  return Buffer.concat(chunks);
23379
23685
  }
23380
- function isWebmContainer(buffer2) {
23381
- return buffer2.length >= 4 && buffer2[0] === 26 && buffer2[1] === 69 && buffer2[2] === 223 && buffer2[3] === 163;
23686
+ function isWebmContainer(buffer3) {
23687
+ return buffer3.length >= 4 && buffer3[0] === 26 && buffer3[1] === 69 && buffer3[2] === 223 && buffer3[3] === 163;
23382
23688
  }
23383
23689
 
23384
23690
  // src/polyfill/registers/mp4Webm.ts
@@ -23497,9 +23803,9 @@ function initialMimeType(options) {
23497
23803
  const kinds = initialKinds(options);
23498
23804
  return mimeTypeFromContainer(containerOf(options), kinds);
23499
23805
  }
23500
- function containerOf(options, buffer2) {
23501
- if (buffer2) {
23502
- return isWebmContainer(buffer2) ? "webm" : "mp4";
23806
+ function containerOf(options, buffer3) {
23807
+ if (buffer3) {
23808
+ return isWebmContainer(buffer3) ? "webm" : "mp4";
23503
23809
  }
23504
23810
  if ("path" in options && options.path != void 0) {
23505
23811
  return containerFromPath(options.path);
@@ -23542,21 +23848,21 @@ function mimeTypeFromContainer(container, kinds) {
23542
23848
  }
23543
23849
  return hasVideo ? "video/mp4" : "audio/mp4";
23544
23850
  }
23545
- function inspectKindsFromBuffer(buffer2) {
23851
+ function inspectKindsFromBuffer(buffer3) {
23546
23852
  try {
23547
- const kinds = isWebmContainer(buffer2) ? inspectWebmKinds(buffer2) : inspectMp4Kinds(buffer2);
23853
+ const kinds = isWebmContainer(buffer3) ? inspectWebmKinds(buffer3) : inspectMp4Kinds(buffer3);
23548
23854
  return kinds.length > 0 ? kinds : void 0;
23549
23855
  } catch {
23550
23856
  return void 0;
23551
23857
  }
23552
23858
  }
23553
- function inspectMp4Kinds(buffer2) {
23859
+ function inspectMp4Kinds(buffer3) {
23554
23860
  const found = /* @__PURE__ */ new Set();
23555
- for (let index = 4; index < buffer2.length - 16; index++) {
23556
- if (buffer2.toString("ascii", index, index + 4) !== "hdlr") {
23861
+ for (let index = 4; index < buffer3.length - 16; index++) {
23862
+ if (buffer3.toString("ascii", index, index + 4) !== "hdlr") {
23557
23863
  continue;
23558
23864
  }
23559
- const handler = buffer2.toString("ascii", index + 12, index + 16);
23865
+ const handler = buffer3.toString("ascii", index + 12, index + 16);
23560
23866
  if (handler === "soun") {
23561
23867
  found.add("audio");
23562
23868
  } else if (handler === "vide") {
@@ -23565,13 +23871,13 @@ function inspectMp4Kinds(buffer2) {
23565
23871
  }
23566
23872
  return [...found];
23567
23873
  }
23568
- function inspectWebmKinds(buffer2) {
23874
+ function inspectWebmKinds(buffer3) {
23569
23875
  const found = /* @__PURE__ */ new Set();
23570
- for (let index = 0; index < buffer2.length - 2; index++) {
23571
- if (buffer2[index] !== 131 || buffer2[index + 1] !== 129) {
23876
+ for (let index = 0; index < buffer3.length - 2; index++) {
23877
+ if (buffer3[index] !== 131 || buffer3[index + 1] !== 129) {
23572
23878
  continue;
23573
23879
  }
23574
- const trackType = buffer2[index + 2];
23880
+ const trackType = buffer3[index + 2];
23575
23881
  if (trackType === 1) {
23576
23882
  found.add("video");
23577
23883
  } else if (trackType === 2) {