amiudmodz 5.0.5 → 5.0.8

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.
@@ -141,7 +141,7 @@ exports.MEDIA_HKDF_KEY_MAPPING = {
141
141
  exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
142
142
  exports.MIN_PREKEY_COUNT = 5;
143
143
  exports.INITIAL_PREKEY_COUNT = 30;
144
- exports.UPLOAD_TIMEOUT = 7200000; // 2 hours in ms
144
+ exports.UPLOAD_TIMEOUT = 7200000;
145
145
  exports.MIN_UPLOAD_INTERVAL = 5000;
146
146
 
147
147
  exports.TimeMs = {
@@ -22,7 +22,7 @@ class WebSocketClient extends abstract_socket_client_1.AbstractSocketClient {
22
22
  }
23
23
  get isClosing() {
24
24
  var _a;
25
- // Only report closing when socket exists and is in CLOSING state
25
+
26
26
  return this.socket !== null && ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSING;
27
27
  }
28
28
  get isConnecting() {
@@ -55,10 +55,10 @@ class WebSocketClient extends abstract_socket_client_1.AbstractSocketClient {
55
55
  return;
56
56
  }
57
57
  const socketToClose = this.socket;
58
- this.socket = null; // Immediately null to prevent double-close
58
+ this.socket = null;
59
59
  const closePromise = new Promise((resolve) => {
60
60
  socketToClose.once('close', resolve);
61
- // Fallback timeout in case 'close' event never fires
61
+
62
62
  setTimeout(resolve, 5000);
63
63
  });
64
64
  socketToClose.close();
@@ -355,7 +355,7 @@ const makeChatsSocket = (config) => {
355
355
  status: error
356
356
  });
357
357
  }
358
- // Small delay to avoid hammering the server
358
+
359
359
  await (0, Utils_1.delay)(50);
360
360
  }
361
361
  return verifiedResults;
@@ -378,7 +378,7 @@ const makeSocket = (config) => {
378
378
  }, PING_TIMEOUT_MS)
379
379
  .catch(err => {
380
380
  logger.error({ trace: err?.stack }, 'error in keep-alive ping');
381
- // If ping timed out, the connection is likely dead — force reconnect
381
+
382
382
  if (err?.output?.statusCode === Types_1.DisconnectReason.timedOut ||
383
383
  err?.message?.includes('timed out') ||
384
384
  err?.message?.includes('Connection Closed')) {
@@ -48,7 +48,7 @@ const makeEventBuffer = (logger) => {
48
48
  if (totalEvents > MAX_BUFFER_SIZE) {
49
49
  logger.warn({ totalEvents }, 'buffer too large, auto-flushing');
50
50
  flush(true);
51
- // After force-flush, start a fresh buffer count
51
+
52
52
  buffersInProgress = 1;
53
53
  } else {
54
54
  buffersInProgress += 1;
@@ -36,7 +36,7 @@ const makeKeyedMutex = () => {
36
36
  }
37
37
  const mtx = map.get(key);
38
38
  return mtx.mutex(task).finally(() => {
39
- // Only delete entry when no more pending tasks remain
39
+
40
40
  if (mtx.pendingCount === 0) {
41
41
  map.delete(key);
42
42
  }
@@ -391,7 +391,19 @@ async function generateThumbnail(file, mediaType, options) {
391
391
  exports.generateThumbnail = generateThumbnail;
392
392
  const getHttpStream = async (url, options = {}) => {
393
393
  const { default: axios } = await import('axios');
394
- const fetched = await axios.get(url.toString(), { ...options, responseType: 'stream' });
394
+ const fetched = await axios.get(url.toString(), {
395
+ ...options,
396
+ responseType: 'stream',
397
+ maxContentLength: Infinity,
398
+ maxBodyLength: Infinity,
399
+ decompress: false,
400
+ headers: {
401
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
402
+ 'Accept': '*/*',
403
+ 'Accept-Encoding': 'identity',
404
+ ...options.headers,
405
+ }
406
+ });
395
407
  return fetched.data;
396
408
  };
397
409
  exports.getHttpStream = getHttpStream;
@@ -402,11 +414,11 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
402
414
  let didSaveToTmpPath = false;
403
415
  let fileLength = 0;
404
416
  const sha256 = Crypto.createHash('sha256');
405
-
406
- // Always save prepared data to a temp file for large files support and retries
417
+
418
+
407
419
  const preparedPath = (0, path_1.join)(getTmpFilesDirectory(), `prepared-${mediaType}-${(0, generics_1.generateMessageID)()}`);
408
420
  const preparedWriteStream = (0, fs_1.createWriteStream)(preparedPath);
409
-
421
+
410
422
  if (type === 'file') {
411
423
  bodyPath = media.url;
412
424
  } else if (saveOriginalFileIfRequired) {
@@ -414,7 +426,7 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
414
426
  didSaveToTmpPath = true;
415
427
  }
416
428
 
417
- const writeStream = bodyPath && !media.url ? (0, fs_1.createWriteStream)(bodyPath) : undefined;
429
+ const writeStream = didSaveToTmpPath ? (0, fs_1.createWriteStream)(bodyPath) : undefined;
418
430
 
419
431
  try {
420
432
  for await (const chunk of stream) {
@@ -435,7 +447,7 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
435
447
 
436
448
  const fileSha256 = sha256.digest();
437
449
  logger === null || logger === void 0 ? void 0 : logger.debug('prepare stream data successfully');
438
-
450
+
439
451
  return {
440
452
  mediaKey: undefined,
441
453
  encWriteStream: (0, fs_1.createReadStream)(preparedPath),
@@ -453,7 +465,7 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
453
465
  writeStream?.destroy();
454
466
  try {
455
467
  await fs_1.promises.unlink(preparedPath);
456
- } catch {}
468
+ } catch { }
457
469
  if (didSaveToTmpPath) {
458
470
  try {
459
471
  await fs_1.promises.unlink(bodyPath);
@@ -484,11 +496,11 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
484
496
  }
485
497
  const mediaKey = Crypto.randomBytes(32);
486
498
  const { cipherKey, iv, macKey } = getMediaKeys(mediaKey, mediaType);
487
-
488
- // Always save encrypted data to a temp file for 2GB support and retries
499
+
500
+
489
501
  const encPath = (0, path_1.join)(getTmpFilesDirectory(), `enc-${mediaType}-${(0, generics_1.generateMessageID)()}`);
490
502
  const encTempWriteStream = (0, fs_1.createWriteStream)(encPath);
491
-
503
+
492
504
  let bodyPath;
493
505
  let writeStream;
494
506
  let didSaveToTmpPath = false;
@@ -543,7 +555,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
543
555
 
544
556
  const fileSha256 = sha256Plain.digest();
545
557
  const fileEncSha256 = sha256Enc.digest();
546
-
558
+
547
559
  encTempWriteStream.end();
548
560
  writeStream === null || writeStream === void 0 ? void 0 : writeStream.end();
549
561
  finalStream.destroy();
@@ -571,7 +583,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
571
583
  finalStream.destroy();
572
584
  try {
573
585
  await fs_1.promises.unlink(encPath);
574
- } catch {}
586
+ } catch { }
575
587
  if (didSaveToTmpPath) {
576
588
  try {
577
589
  await fs_1.promises.unlink(bodyPath);
@@ -718,9 +730,9 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
718
730
  logger.debug(`uploading to "${hostname}"`);
719
731
  const auth = encodeURIComponent(uploadInfo.auth);
720
732
  const url = `https://${hostname}${media}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
721
-
722
- // Re-create stream if retrying and we have a path
723
- // This is essential for large files (2GB) as the first stream will be consumed
733
+
734
+
735
+
724
736
  const reqBody = streamPath ? createReadStream(streamPath) : stream;
725
737
 
726
738
  let result;
@@ -737,10 +749,11 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
737
749
  'Origin': Defaults_1.DEFAULT_ORIGIN
738
750
  },
739
751
  httpsAgent: fetchAgent,
740
- timeout: timeoutMs,
752
+ timeout: timeoutMs || Defaults_1.UPLOAD_TIMEOUT,
741
753
  responseType: 'json',
742
754
  maxBodyLength: Infinity,
743
755
  maxContentLength: Infinity,
756
+ decompress: false
744
757
  });
745
758
  result = body.data;
746
759
  if ((result === null || result === void 0 ? void 0 : result.url) || (result === null || result === void 0 ? void 0 : result.directPath)) {
@@ -135,7 +135,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
135
135
  logger.trace(`recv ${newData.length} bytes, total recv ${inBytesLength} bytes`);
136
136
 
137
137
  while (inBytesLength >= 3) {
138
- // Only concat when necessary
138
+
139
139
  if (inChunks.length > 1) {
140
140
  const combined = Buffer.concat(inChunks);
141
141
  inChunks = [combined];
@@ -149,7 +149,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
149
149
  let frame = inBytes.subarray(3, size + 3);
150
150
 
151
151
  const remaining = inBytes.subarray(size + 3);
152
- // Reuse existing buffer reference when possible
152
+
153
153
  if (remaining.length > 0) {
154
154
  inChunks = [remaining];
155
155
  } else {
@@ -18,7 +18,7 @@ const useMultiFileAuthState = async (folder) => {
18
18
  return mutex;
19
19
  };
20
20
  const releaseFileLock = (path) => {
21
- // Clean up mutex if no more waiters to prevent memory leak
21
+
22
22
  const mutex = fileLocks.get(path);
23
23
  if (mutex && !mutex.isLocked()) {
24
24
  fileLocks.delete(path);
package/lib/index.d.ts CHANGED
@@ -0,0 +1,12 @@
1
+ import makeWASocket from './Socket';
2
+ export * from './Defaults';
3
+ export * from './Utils';
4
+ export * from '../WAProto';
5
+ export * from './Types';
6
+ export * from './Store';
7
+ export * from './WAUSync';
8
+ export * from './WABinary';
9
+ export * from './WAM';
10
+ export * from './Socket';
11
+ export { makeWASocket };
12
+ export default makeWASocket;
package/lib/index.js CHANGED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.makeWASocket = void 0;
23
+ const Socket_1 = __importDefault(require("./Socket"));
24
+ exports.makeWASocket = Socket_1.default;
25
+ __exportStar(require("../WAProto"), exports);
26
+ __exportStar(require("./Utils"), exports);
27
+ __exportStar(require("./Types"), exports);
28
+ __exportStar(require("./Store"), exports);
29
+ __exportStar(require("./Defaults"), exports);
30
+ __exportStar(require("./WABinary"), exports);
31
+ __exportStar(require("./WAM"), exports);
32
+ __exportStar(require("./WAUSync"), exports);
33
+
34
+ exports.default = Socket_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amiudmodz",
3
- "version": "5.0.5",
3
+ "version": "5.0.8",
4
4
  "description": "WhatsApp Baileys mod Powered by UDMODZ",
5
5
  "keywords": [
6
6
  "whatsapp",