amiudmodz 5.1.1 → 5.1.5
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.
|
@@ -444,6 +444,7 @@ const getHttpStream = async (url, options = {}) => {
|
|
|
444
444
|
exports.getHttpStream = getHttpStream;
|
|
445
445
|
const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequired, opts } = {}) => {
|
|
446
446
|
const { stream, type } = await (0, exports.getStream)(media, opts);
|
|
447
|
+
media = undefined; // Help GC
|
|
447
448
|
logger === null || logger === void 0 ? void 0 : logger.debug('fetched media stream');
|
|
448
449
|
let bodyPath;
|
|
449
450
|
let didSaveToTmpPath = false;
|
|
@@ -515,6 +516,7 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
|
|
|
515
516
|
exports.prepareStream = prepareStream;
|
|
516
517
|
const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfRequired, opts, isPtt, forceOpus } = {}) => {
|
|
517
518
|
const { stream, type, spilledPath } = await (0, exports.getStream)(media, opts);
|
|
519
|
+
media = undefined; // Help GC
|
|
518
520
|
let finalStream = stream;
|
|
519
521
|
let opusConverted = false;
|
|
520
522
|
let opusSpillPath;
|
|
@@ -587,11 +589,12 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
587
589
|
let sha256Plain = Crypto.createHash('sha256');
|
|
588
590
|
let sha256Enc = Crypto.createHash('sha256');
|
|
589
591
|
try {
|
|
592
|
+
let plainLength = 0;
|
|
590
593
|
for await (const data of finalStream) {
|
|
591
|
-
|
|
594
|
+
plainLength += data.length;
|
|
592
595
|
if (type === 'remote'
|
|
593
596
|
&& (opts?.maxContentLength)
|
|
594
|
-
&&
|
|
597
|
+
&& plainLength > opts.maxContentLength) {
|
|
595
598
|
throw new boom_1.Boom(`content length exceeded when encrypting "${type}"`, {
|
|
596
599
|
data: { media, type }
|
|
597
600
|
});
|
|
@@ -603,6 +606,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
603
606
|
}
|
|
604
607
|
}
|
|
605
608
|
const encrypted = aes.update(data);
|
|
609
|
+
fileLength += encrypted.length;
|
|
606
610
|
sha256Enc = sha256Enc.update(encrypted);
|
|
607
611
|
hmac = hmac.update(encrypted);
|
|
608
612
|
if (!encTempWriteStream.write(encrypted)) {
|
|
@@ -610,6 +614,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
610
614
|
}
|
|
611
615
|
}
|
|
612
616
|
const finalEnc = aes.final();
|
|
617
|
+
fileLength += finalEnc.length;
|
|
613
618
|
sha256Enc = sha256Enc.update(finalEnc);
|
|
614
619
|
hmac = hmac.update(finalEnc);
|
|
615
620
|
if (!encTempWriteStream.write(finalEnc)) {
|
|
@@ -617,6 +622,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
617
622
|
}
|
|
618
623
|
|
|
619
624
|
const mac = hmac.digest().slice(0, 10);
|
|
625
|
+
fileLength += mac.length;
|
|
620
626
|
sha256Enc = sha256Enc.update(mac);
|
|
621
627
|
if (!encTempWriteStream.write(mac)) {
|
|
622
628
|
await (0, events_1.once)(encTempWriteStream, 'drain');
|
|
@@ -822,11 +828,14 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
822
828
|
|
|
823
829
|
|
|
824
830
|
|
|
831
|
+
if (streamPath && stream && typeof stream.destroy === 'function') {
|
|
832
|
+
stream.destroy();
|
|
833
|
+
}
|
|
825
834
|
const reqBody = streamPath ? createReadStream(streamPath) : stream;
|
|
826
835
|
|
|
827
836
|
let result;
|
|
828
837
|
try {
|
|
829
|
-
const bodyLength = fileLength || (Buffer.isBuffer(reqBody) ? reqBody.length : 0);
|
|
838
|
+
const bodyLength = fileLength || (streamPath ? (await fs_1.promises.stat(streamPath)).size : (Buffer.isBuffer(reqBody) ? reqBody.length : (stream.size || 0)));
|
|
830
839
|
if (maxContentLengthBytes && bodyLength > maxContentLengthBytes) {
|
|
831
840
|
throw new boom_1.Boom(`Body too large for "${hostname}" (${bodyLength} > ${maxContentLengthBytes})`, { statusCode: 413 });
|
|
832
841
|
}
|
|
@@ -836,7 +845,8 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
836
845
|
...options.headers || {},
|
|
837
846
|
'Content-Type': 'application/octet-stream',
|
|
838
847
|
'Content-Length': bodyLength.toString(),
|
|
839
|
-
'Origin': Defaults_1.DEFAULT_ORIGIN
|
|
848
|
+
'Origin': Defaults_1.DEFAULT_ORIGIN,
|
|
849
|
+
'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
850
|
},
|
|
841
851
|
httpsAgent: fetchAgent,
|
|
842
852
|
timeout: timeoutMs || Defaults_1.UPLOAD_TIMEOUT,
|
|
@@ -863,8 +873,8 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
863
873
|
if (axios.isAxiosError(error)) {
|
|
864
874
|
result = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
865
875
|
}
|
|
866
|
-
const isLast = hostname === ((_b = hosts[
|
|
867
|
-
logger.warn({ trace: error.stack, uploadResult: result }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`);
|
|
876
|
+
const isLast = hostname === ((_b = hosts[hosts.length - 1]) === null || _b === void 0 ? void 0 : _b.hostname);
|
|
877
|
+
logger.warn({ trace: error.stack, uploadResult: result, message: error.message, statusCode: error.response?.status }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`);
|
|
868
878
|
}
|
|
869
879
|
}
|
|
870
880
|
if (!urls) {
|
package/lib/Utils/messages.js
CHANGED
|
@@ -149,7 +149,10 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
149
149
|
const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true;
|
|
150
150
|
const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation;
|
|
151
151
|
|
|
152
|
-
const
|
|
152
|
+
const media = uploadData.media;
|
|
153
|
+
uploadData.media = undefined;
|
|
154
|
+
|
|
155
|
+
const { mediaKey, encWriteStream, bodyPath, streamPath, spilledPath, fileEncSha256, fileSha256, fileLength, didSaveToTmpPath, opusConverted } = await (options.newsletter ? messages_media_1.prepareStream : messages_media_1.encryptedStream)(media, options.mediaTypeOverride || mediaType, {
|
|
153
156
|
logger,
|
|
154
157
|
saveOriginalFileIfRequired: requiresOriginalForSomeProcessing,
|
|
155
158
|
opts: options.options,
|
|
@@ -157,9 +160,6 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
157
160
|
forceOpus: (mediaType === "audio" && uploadData.mimetype && uploadData.mimetype.includes('opus'))
|
|
158
161
|
});
|
|
159
162
|
|
|
160
|
-
// Nullify the media reference to help GC free the memory if it's a large Buffer
|
|
161
|
-
uploadData.media = undefined;
|
|
162
|
-
|
|
163
163
|
if (mediaType === 'audio' && opusConverted) {
|
|
164
164
|
uploadData.mimetype = 'audio/ogg; codecs=opus';
|
|
165
165
|
}
|
|
@@ -22,7 +22,8 @@ const jidDecode = (jid) => {
|
|
|
22
22
|
return {
|
|
23
23
|
server,
|
|
24
24
|
user,
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
domainType: (server === 'lid' || server === 'hosted.lid') ? 1 : 0,
|
|
26
27
|
device: device ? +device : undefined
|
|
27
28
|
};
|
|
28
29
|
};
|
|
@@ -36,8 +37,8 @@ exports.areJidsSameUser = areJidsSameUser;
|
|
|
36
37
|
/** is the jid a user */
|
|
37
38
|
const isJidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
|
|
38
39
|
exports.isJidUser = isJidUser;
|
|
39
|
-
/** is the jid a
|
|
40
|
-
const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid'));
|
|
40
|
+
/** is the jid a user */
|
|
41
|
+
const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid') || jid.endsWith('@hosted.lid'));
|
|
41
42
|
exports.isLidUser = isLidUser;
|
|
42
43
|
/** is the jid a broadcast */
|
|
43
44
|
const isJidBroadcast = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amiudmodz",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5",
|
|
4
4
|
"description": "WhatsApp Baileys mod Powered by UDMODZ",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"chalk": "^4.1.2",
|
|
45
45
|
"futoin-hkdf": "^1.5.1",
|
|
46
46
|
"libphonenumber-js": "^1.10.20",
|
|
47
|
-
"libsignal": "git+https://github.com/xhclintohn/libsignal-node",
|
|
47
|
+
"libsignal": "git+https://github.com/xhclintohn/libsignal-node.git",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
49
49
|
"lru-cache": "^11.1.0",
|
|
50
50
|
"music-metadata": "^11.12.3",
|
|
@@ -106,4 +106,4 @@
|
|
|
106
106
|
"engines": {
|
|
107
107
|
"node": ">=20.0.0"
|
|
108
108
|
}
|
|
109
|
-
}
|
|
109
|
+
}
|