amiudmodz 5.1.1 → 5.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.
@@ -587,11 +587,12 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
587
587
  let sha256Plain = Crypto.createHash('sha256');
588
588
  let sha256Enc = Crypto.createHash('sha256');
589
589
  try {
590
+ let plainLength = 0;
590
591
  for await (const data of finalStream) {
591
- fileLength += data.length;
592
+ plainLength += data.length;
592
593
  if (type === 'remote'
593
594
  && (opts?.maxContentLength)
594
- && fileLength > opts.maxContentLength) {
595
+ && plainLength > opts.maxContentLength) {
595
596
  throw new boom_1.Boom(`content length exceeded when encrypting "${type}"`, {
596
597
  data: { media, type }
597
598
  });
@@ -603,6 +604,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
603
604
  }
604
605
  }
605
606
  const encrypted = aes.update(data);
607
+ fileLength += encrypted.length;
606
608
  sha256Enc = sha256Enc.update(encrypted);
607
609
  hmac = hmac.update(encrypted);
608
610
  if (!encTempWriteStream.write(encrypted)) {
@@ -610,6 +612,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
610
612
  }
611
613
  }
612
614
  const finalEnc = aes.final();
615
+ fileLength += finalEnc.length;
613
616
  sha256Enc = sha256Enc.update(finalEnc);
614
617
  hmac = hmac.update(finalEnc);
615
618
  if (!encTempWriteStream.write(finalEnc)) {
@@ -617,6 +620,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
617
620
  }
618
621
 
619
622
  const mac = hmac.digest().slice(0, 10);
623
+ fileLength += mac.length;
620
624
  sha256Enc = sha256Enc.update(mac);
621
625
  if (!encTempWriteStream.write(mac)) {
622
626
  await (0, events_1.once)(encTempWriteStream, 'drain');
@@ -826,7 +830,7 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
826
830
 
827
831
  let result;
828
832
  try {
829
- const bodyLength = fileLength || (Buffer.isBuffer(reqBody) ? reqBody.length : 0);
833
+ const bodyLength = fileLength || (streamPath ? (await fs_1.promises.stat(streamPath)).size : (Buffer.isBuffer(reqBody) ? reqBody.length : 0));
830
834
  if (maxContentLengthBytes && bodyLength > maxContentLengthBytes) {
831
835
  throw new boom_1.Boom(`Body too large for "${hostname}" (${bodyLength} > ${maxContentLengthBytes})`, { statusCode: 413 });
832
836
  }
@@ -836,7 +840,8 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
836
840
  ...options.headers || {},
837
841
  'Content-Type': 'application/octet-stream',
838
842
  'Content-Length': bodyLength.toString(),
839
- 'Origin': Defaults_1.DEFAULT_ORIGIN
843
+ 'Origin': Defaults_1.DEFAULT_ORIGIN,
844
+ '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'
840
845
  },
841
846
  httpsAgent: fetchAgent,
842
847
  timeout: timeoutMs || Defaults_1.UPLOAD_TIMEOUT,
@@ -863,8 +868,8 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
863
868
  if (axios.isAxiosError(error)) {
864
869
  result = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
865
870
  }
866
- const isLast = hostname === ((_b = hosts[uploadInfo.hosts.length - 1]) === null || _b === void 0 ? void 0 : _b.hostname);
867
- logger.warn({ trace: error.stack, uploadResult: result }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`);
871
+ const isLast = hostname === ((_b = hosts[hosts.length - 1]) === null || _b === void 0 ? void 0 : _b.hostname);
872
+ logger.warn({ trace: error.stack, uploadResult: result, message: error.message }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`);
868
873
  }
869
874
  }
870
875
  if (!urls) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amiudmodz",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "description": "WhatsApp Baileys mod Powered by UDMODZ",
5
5
  "keywords": [
6
6
  "whatsapp",