amiudmodz 4.0.5 → 4.1.2

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.
@@ -68,7 +68,9 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
68
68
  let writeCounter = 0;
69
69
  let isFinished = false;
70
70
  let sentIntro = false;
71
- let inBytes = Buffer.alloc(0);
71
+
72
+ let inChunks = [];
73
+ let inBytesLength = 0;
72
74
  authenticate(NOISE_HEADER);
73
75
  authenticate(publicKey);
74
76
  return {
@@ -128,26 +130,33 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
128
130
  decodeFrame: (newData, onFrame) => {
129
131
  var _a;
130
132
 
133
+ inChunks.push(newData);
134
+ inBytesLength += newData.length;
135
+ logger.trace(`recv ${newData.length} bytes, total recv ${inBytesLength} bytes`);
131
136
 
137
+ while (inBytesLength >= 3) {
132
138
 
133
- const getBytesSize = () => {
134
- if (inBytes.length >= 3) {
135
- return (inBytes.readUInt8() << 16) | inBytes.readUInt16BE(1);
139
+ if (inChunks.length > 1) {
140
+ const combined = Buffer.concat(inChunks);
141
+ inChunks = [combined];
142
+ }
143
+ const inBytes = inChunks[0];
144
+ const size = (inBytes.readUInt8(0) << 16) | inBytes.readUInt16BE(1);
145
+ if (inBytesLength < size + 3) {
146
+ break;
136
147
  }
137
- };
138
- inBytes = Buffer.concat([inBytes, newData]);
139
- logger.trace(`recv ${newData.length} bytes, total recv ${inBytes.length} bytes`);
140
- let size = getBytesSize();
141
- while (size && inBytes.length >= size + 3) {
142
- let frame = inBytes.slice(3, size + 3);
143
- inBytes = inBytes.slice(size + 3);
148
+
149
+ let frame = inBytes.subarray(3, size + 3);
150
+
151
+ const remaining = inBytes.subarray(size + 3);
152
+ inChunks = remaining.length > 0 ? [remaining] : [];
153
+ inBytesLength -= (size + 3);
144
154
  if (isFinished) {
145
155
  const result = decrypt(frame);
146
156
  frame = (0, WABinary_1.decodeBinaryNode)(result);
147
157
  }
148
158
  logger.trace({ msg: (_a = frame === null || frame === void 0 ? void 0 : frame.attrs) === null || _a === void 0 ? void 0 : _a.id }, 'recv frame');
149
159
  onFrame(frame);
150
- size = getBytesSize();
151
160
  }
152
161
  }
153
162
  };
package/package.json CHANGED
@@ -1,6 +1,16 @@
1
1
  {
2
2
  "name": "amiudmodz",
3
- "version": "4.0.5",
3
+ "version": "4.1.2",
4
+ "description": "WhatsApp Baileys mod Powered by UDMODZ",
5
+ "keywords": [
6
+ "whatsapp",
7
+ "baileys",
8
+ "udmodz",
9
+ "bot",
10
+ "whatsapp-api",
11
+ "whatsapp-web",
12
+ "badiys"
13
+ ],
4
14
  "main": "lib/index.js",
5
15
  "types": "lib/index.d.ts",
6
16
  "files": [