@genuxofficial/baileys 1.0.0 → 2.0.0
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.
- package/LICENSE +1 -1
- package/README.md +5 -1
- package/WAProto/index.d.ts +19244 -2787
- package/WAProto/index.js +138202 -74217
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +3 -5
- package/lib/Defaults/index.js +7 -6
- package/lib/Signal/libsignal.js +18 -9
- package/lib/Socket/Client/types.d.ts +0 -2
- package/lib/Socket/Client/websocket.js +1 -1
- package/lib/Socket/business.d.ts +65 -37
- package/lib/Socket/chats.d.ts +22 -18
- package/lib/Socket/chats.js +110 -6
- package/lib/Socket/groups.d.ts +30 -26
- package/lib/Socket/groups.js +20 -6
- package/lib/Socket/index.d.ts +66 -38
- package/lib/Socket/messages-recv.d.ts +63 -33
- package/lib/Socket/messages-recv.js +174 -27
- package/lib/Socket/messages-send.d.ts +55 -29
- package/lib/Socket/messages-send.js +190 -26
- package/lib/Socket/newsletter.d.ts +140 -0
- package/lib/Socket/newsletter.js +252 -0
- package/lib/Socket/socket.d.ts +8 -10
- package/lib/Socket/socket.js +26 -13
- package/lib/Socket/usync.d.ts +10 -12
- package/lib/Socket/usync.js +10 -15
- package/lib/Store/index.d.ts +1 -2
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.d.ts +1 -1
- package/lib/Store/make-in-memory-store.js +14 -5
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +0 -2
- package/lib/Types/Chat.d.ts +7 -0
- package/lib/Types/Contact.d.ts +5 -0
- package/lib/Types/Events.d.ts +27 -0
- package/lib/Types/GroupMetadata.d.ts +7 -0
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +129 -16
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.d.ts +79 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Socket.d.ts +8 -5
- package/lib/Types/index.d.ts +1 -0
- package/lib/Types/index.js +2 -1
- package/lib/Utils/auth-utils.d.ts +1 -1
- package/lib/Utils/auth-utils.js +6 -7
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +8 -10
- package/lib/Utils/chat-utils.js +11 -0
- package/lib/Utils/crypto.d.ts +14 -16
- package/lib/Utils/crypto.js +40 -26
- package/lib/Utils/decode-wa-message.d.ts +5 -3
- package/lib/Utils/decode-wa-message.js +171 -29
- package/lib/Utils/event-buffer.js +1 -3
- package/lib/Utils/generics.d.ts +35 -9
- package/lib/Utils/generics.js +93 -27
- package/lib/Utils/history.d.ts +2 -2
- package/lib/Utils/link-preview.d.ts +1 -1
- package/lib/Utils/link-preview.js +17 -7
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +0 -1
- package/lib/Utils/messages-media.d.ts +35 -16
- package/lib/Utils/messages-media.js +168 -43
- package/lib/Utils/messages.d.ts +6 -9
- package/lib/Utils/messages.js +297 -37
- package/lib/Utils/noise-handler.d.ts +5 -7
- package/lib/Utils/process-message.js +2 -3
- package/lib/Utils/use-multi-file-auth-state.js +44 -13
- package/lib/Utils/validate-connection.d.ts +2 -2
- package/lib/Utils/validate-connection.js +1 -3
- package/lib/WABinary/decode.d.ts +2 -4
- package/lib/WABinary/decode.js +20 -9
- package/lib/WABinary/encode.d.ts +1 -3
- package/lib/WABinary/encode.js +30 -12
- package/lib/WABinary/generic-utils.d.ts +1 -3
- package/lib/WABinary/generic-utils.js +2 -2
- package/lib/WABinary/jid-utils.d.ts +9 -4
- package/lib/WABinary/jid-utils.js +25 -4
- package/lib/WAM/BinaryInfo.d.ts +2 -12
- package/lib/WAM/encode.d.ts +1 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -5
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/USyncQuery.d.ts +2 -0
- package/lib/WAUSync/USyncQuery.js +27 -13
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/WAUSync/USyncUser.js +4 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/package.json +59 -57
- package/WAProto/GenerateStatics.sh +0 -4
- package/WAProto/WAProto.proto +0 -3344
@@ -15,18 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
37
|
};
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.getStatusCodeForMediaRetry = exports.decryptMediaRetryData = exports.decodeMediaRetryNode = exports.encryptMediaRetryRequest = exports.getWAUploadToServer = exports.
|
39
|
+
exports.getStatusCodeForMediaRetry = exports.decryptMediaRetryData = exports.decodeMediaRetryNode = exports.encryptMediaRetryRequest = exports.getWAUploadToServer = exports.downloadEncryptedContent = exports.downloadContentFromMessage = exports.getUrlFromDirectPath = exports.encryptedStream = exports.prepareStream = exports.getHttpStream = exports.getStream = exports.toBuffer = exports.toReadable = exports.mediaMessageSHA256B64 = exports.changeprofileFull = exports.generatePP = exports.generateProfilePictureFP = exports.generateProfilePictureFull = exports.generateProfilePicture = exports.encodeBase64EncodedStringForUpload = exports.extractImageThumb = exports.hkdfInfoKey = void 0;
|
40
|
+
exports.getMediaKeys = getMediaKeys;
|
41
|
+
exports.getAudioDuration = getAudioDuration;
|
42
|
+
exports.getAudioWaveform = getAudioWaveform;
|
43
|
+
exports.generateThumbnail = generateThumbnail;
|
44
|
+
exports.extensionForMediaMessage = extensionForMediaMessage;
|
30
45
|
const boom_1 = require("@hapi/boom");
|
31
46
|
const axios_1 = __importDefault(require("axios"));
|
32
47
|
const child_process_1 = require("child_process");
|
@@ -35,6 +50,7 @@ const events_1 = require("events");
|
|
35
50
|
const fs_1 = require("fs");
|
36
51
|
const os_1 = require("os");
|
37
52
|
const path_1 = require("path");
|
53
|
+
const jimp_1 = __importDefault(require("jimp"));
|
38
54
|
const stream_1 = require("stream");
|
39
55
|
const WAProto_1 = require("../../WAProto");
|
40
56
|
const Defaults_1 = require("../Defaults");
|
@@ -83,7 +99,6 @@ async function getMediaKeys(buffer, mediaType) {
|
|
83
99
|
macKey: expandedMediaKey.slice(48, 80),
|
84
100
|
};
|
85
101
|
}
|
86
|
-
exports.getMediaKeys = getMediaKeys;
|
87
102
|
/** Extracts video thumb using FFMPEG */
|
88
103
|
const extractVideoThumb = async (path, destPath, time, size) => new Promise((resolve, reject) => {
|
89
104
|
const cmd = `ffmpeg -ss ${time} -i ${path} -y -vf scale=${size.width}:-1 -vframes 1 -f image2 ${destPath}`;
|
@@ -144,8 +159,8 @@ const encodeBase64EncodedStringForUpload = (b64) => (encodeURIComponent(b64
|
|
144
159
|
.replace(/\=+$/, '')));
|
145
160
|
exports.encodeBase64EncodedStringForUpload = encodeBase64EncodedStringForUpload;
|
146
161
|
const generateProfilePicture = async (mediaUpload) => {
|
147
|
-
var _a, _b;
|
148
162
|
let bufferOrFilePath;
|
163
|
+
let img;
|
149
164
|
if (Buffer.isBuffer(mediaUpload)) {
|
150
165
|
bufferOrFilePath = mediaUpload;
|
151
166
|
}
|
@@ -155,34 +170,86 @@ const generateProfilePicture = async (mediaUpload) => {
|
|
155
170
|
else {
|
156
171
|
bufferOrFilePath = await (0, exports.toBuffer)(mediaUpload.stream);
|
157
172
|
}
|
158
|
-
const
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
173
|
+
const jimp = await jimp_1.default.read(bufferOrFilePath);
|
174
|
+
const cropped = jimp.getWidth() > jimp.getHeight() ? jimp.resize(550, -1) : jimp.resize(-1, 650);
|
175
|
+
img = cropped
|
176
|
+
.quality(100)
|
177
|
+
.getBufferAsync(jimp_1.default.MIME_JPEG);
|
178
|
+
return {
|
179
|
+
img: await img,
|
180
|
+
};
|
181
|
+
};
|
182
|
+
exports.generateProfilePicture = generateProfilePicture;
|
183
|
+
const generateProfilePictureFull = async (img) => {
|
184
|
+
const Jimp = require('jimp');
|
185
|
+
const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
|
186
|
+
const jimp = await read(img);
|
187
|
+
const min = Math.min(jimp.getWidth(), jimp.getHeight());
|
188
|
+
const cropped = jimp.crop(0, 0, jimp.getWidth(), jimp.getHeight());
|
189
|
+
let width = jimp.getWidth(), hight = jimp.getHeight(), ratio;
|
190
|
+
if (width > hight) {
|
191
|
+
ratio = jimp.getWidth() / 720;
|
167
192
|
}
|
168
|
-
else
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
193
|
+
else {
|
194
|
+
ratio = jimp.getWidth() / 324;
|
195
|
+
}
|
196
|
+
;
|
197
|
+
width = width / ratio;
|
198
|
+
hight = hight / ratio;
|
199
|
+
img = cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG);
|
200
|
+
return {
|
201
|
+
img: await cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG),
|
202
|
+
};
|
203
|
+
};
|
204
|
+
exports.generateProfilePictureFull = generateProfilePictureFull;
|
205
|
+
const generateProfilePictureFP = async (buffer) => {
|
206
|
+
const Jimp = require('jimp');
|
207
|
+
const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
|
208
|
+
const jimp = await Jimp.read(buffer);
|
209
|
+
const min = jimp.getWidth();
|
210
|
+
const max = jimp.getHeight();
|
211
|
+
const cropped = jimp.crop(0, 0, min, max);
|
212
|
+
return {
|
213
|
+
img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG),
|
214
|
+
preview: await cropped.normalize().getBufferAsync(Jimp.MIME_JPEG),
|
215
|
+
};
|
216
|
+
};
|
217
|
+
exports.generateProfilePictureFP = generateProfilePictureFP;
|
218
|
+
const generatePP = async (buffer) => {
|
219
|
+
const Jimp = require('jimp');
|
220
|
+
const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
|
221
|
+
const jimp = await Jimp.read(buffer);
|
222
|
+
const min = jimp.getWidth();
|
223
|
+
const max = jimp.getHeight();
|
224
|
+
const cropped = jimp.crop(0, 0, min, max);
|
225
|
+
return {
|
226
|
+
img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG),
|
227
|
+
preview: await cropped.normalize().getBufferAsync(Jimp.MIME_JPEG),
|
228
|
+
};
|
229
|
+
};
|
230
|
+
exports.generatePP = generatePP;
|
231
|
+
const changeprofileFull = async (img) => {
|
232
|
+
const Jimp = require('jimp');
|
233
|
+
const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
|
234
|
+
const jimp = await read(img);
|
235
|
+
const min = Math.min(jimp.getWidth(), jimp.getHeight());
|
236
|
+
const cropped = jimp.crop(0, 0, jimp.getWidth(), jimp.getHeight());
|
237
|
+
let width = jimp.getWidth(), hight = jimp.getHeight(), ratio;
|
238
|
+
if (width > hight) {
|
239
|
+
ratio = jimp.getWidth() / 720;
|
177
240
|
}
|
178
241
|
else {
|
179
|
-
|
242
|
+
ratio = jimp.getWidth() / 324;
|
180
243
|
}
|
244
|
+
;
|
245
|
+
width = width / ratio;
|
246
|
+
hight = hight / ratio;
|
247
|
+
img = cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG);
|
181
248
|
return {
|
182
|
-
img: await
|
249
|
+
img: await cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG),
|
183
250
|
};
|
184
251
|
};
|
185
|
-
exports.
|
252
|
+
exports.changeprofileFull = changeprofileFull;
|
186
253
|
/** gets the SHA256 of the given media message */
|
187
254
|
const mediaMessageSHA256B64 = (message) => {
|
188
255
|
const media = Object.values(message)[0];
|
@@ -209,7 +276,6 @@ async function getAudioDuration(buffer) {
|
|
209
276
|
}
|
210
277
|
return metadata.format.duration;
|
211
278
|
}
|
212
|
-
exports.getAudioDuration = getAudioDuration;
|
213
279
|
/**
|
214
280
|
referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
|
215
281
|
*/
|
@@ -251,7 +317,6 @@ async function getAudioWaveform(buffer, logger) {
|
|
251
317
|
logger === null || logger === void 0 ? void 0 : logger.debug('Failed to generate waveform: ' + e);
|
252
318
|
}
|
253
319
|
}
|
254
|
-
exports.getAudioWaveform = getAudioWaveform;
|
255
320
|
const toReadable = (buffer) => {
|
256
321
|
const readable = new stream_1.Readable({ read: () => { } });
|
257
322
|
readable.push(buffer);
|
@@ -297,7 +362,7 @@ async function generateThumbnail(file, mediaType, options) {
|
|
297
362
|
}
|
298
363
|
}
|
299
364
|
else if (mediaType === 'video') {
|
300
|
-
const imgFilename = (0, path_1.join)(getTmpFilesDirectory(), (0, generics_1.
|
365
|
+
const imgFilename = (0, path_1.join)(getTmpFilesDirectory(), (0, generics_1.generateMessageIDV2)() + '.jpg');
|
301
366
|
try {
|
302
367
|
await extractVideoThumb(file, imgFilename, '00:00:00', { width: 32, height: 32 });
|
303
368
|
const buff = await fs_1.promises.readFile(imgFilename);
|
@@ -313,12 +378,55 @@ async function generateThumbnail(file, mediaType, options) {
|
|
313
378
|
originalImageDimensions
|
314
379
|
};
|
315
380
|
}
|
316
|
-
exports.generateThumbnail = generateThumbnail;
|
317
381
|
const getHttpStream = async (url, options = {}) => {
|
318
382
|
const fetched = await axios_1.default.get(url.toString(), { ...options, responseType: 'stream' });
|
319
383
|
return fetched.data;
|
320
384
|
};
|
321
385
|
exports.getHttpStream = getHttpStream;
|
386
|
+
const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequired, opts } = {}) => {
|
387
|
+
const { stream, type } = await (0, exports.getStream)(media, opts);
|
388
|
+
logger === null || logger === void 0 ? void 0 : logger.debug('fetched media stream');
|
389
|
+
let bodyPath;
|
390
|
+
let didSaveToTmpPath = false;
|
391
|
+
try {
|
392
|
+
const buffer = await (0, exports.toBuffer)(stream);
|
393
|
+
if (type === 'file') {
|
394
|
+
bodyPath = media.url;
|
395
|
+
}
|
396
|
+
else if (saveOriginalFileIfRequired) {
|
397
|
+
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.generateMessageIDV2)());
|
398
|
+
(0, fs_1.writeFileSync)(bodyPath, buffer);
|
399
|
+
didSaveToTmpPath = true;
|
400
|
+
}
|
401
|
+
const fileLength = buffer.length;
|
402
|
+
const fileSha256 = Crypto.createHash('sha256').update(buffer).digest();
|
403
|
+
stream === null || stream === void 0 ? void 0 : stream.destroy();
|
404
|
+
logger === null || logger === void 0 ? void 0 : logger.debug('prepare stream data successfully');
|
405
|
+
return {
|
406
|
+
mediaKey: undefined,
|
407
|
+
encWriteStream: buffer,
|
408
|
+
fileLength,
|
409
|
+
fileSha256,
|
410
|
+
fileEncSha256: undefined,
|
411
|
+
bodyPath,
|
412
|
+
didSaveToTmpPath
|
413
|
+
};
|
414
|
+
}
|
415
|
+
catch (error) {
|
416
|
+
// destroy all streams with error
|
417
|
+
stream.destroy();
|
418
|
+
if (didSaveToTmpPath) {
|
419
|
+
try {
|
420
|
+
await fs_1.promises.unlink(bodyPath);
|
421
|
+
}
|
422
|
+
catch (err) {
|
423
|
+
logger === null || logger === void 0 ? void 0 : logger.error({ err }, 'failed to save to tmp path');
|
424
|
+
}
|
425
|
+
}
|
426
|
+
throw error;
|
427
|
+
}
|
428
|
+
};
|
429
|
+
exports.prepareStream = prepareStream;
|
322
430
|
const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfRequired, opts } = {}) => {
|
323
431
|
const { stream, type } = await (0, exports.getStream)(media, opts);
|
324
432
|
logger === null || logger === void 0 ? void 0 : logger.debug('fetched media stream');
|
@@ -332,7 +440,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
332
440
|
bodyPath = media.url.toString();
|
333
441
|
}
|
334
442
|
else if (saveOriginalFileIfRequired) {
|
335
|
-
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.
|
443
|
+
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.generateMessageIDV2)());
|
336
444
|
writeStream = (0, fs_1.createWriteStream)(bodyPath);
|
337
445
|
didSaveToTmpPath = true;
|
338
446
|
}
|
@@ -520,23 +628,35 @@ function extensionForMediaMessage(message) {
|
|
520
628
|
}
|
521
629
|
return extension;
|
522
630
|
}
|
523
|
-
exports.extensionForMediaMessage = extensionForMediaMessage;
|
524
631
|
const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options }, refreshMediaConn) => {
|
525
|
-
return async (stream, { mediaType, fileEncSha256B64, timeoutMs }) => {
|
632
|
+
return async (stream, { mediaType, fileEncSha256B64, newsletter, timeoutMs }) => {
|
526
633
|
var _a, _b;
|
527
634
|
// send a query JSON to obtain the url & auth token to upload our media
|
528
635
|
let uploadInfo = await refreshMediaConn(false);
|
529
636
|
let urls;
|
530
637
|
const hosts = [...customUploadHosts, ...uploadInfo.hosts];
|
638
|
+
const chunks = [];
|
639
|
+
if (!Buffer.isBuffer(stream)) {
|
640
|
+
for await (const chunk of stream) {
|
641
|
+
chunks.push(chunk);
|
642
|
+
}
|
643
|
+
}
|
644
|
+
const reqBody = Buffer.isBuffer(stream) ? stream : Buffer.concat(chunks);
|
531
645
|
fileEncSha256B64 = (0, exports.encodeBase64EncodedStringForUpload)(fileEncSha256B64);
|
532
|
-
|
646
|
+
let media = Defaults_1.MEDIA_PATH_MAP[mediaType];
|
647
|
+
if (newsletter) {
|
648
|
+
media = media === null || media === void 0 ? void 0 : media.replace('/mms/', '/newsletter/newsletter-');
|
649
|
+
}
|
650
|
+
for (const { hostname, maxContentLengthBytes } of hosts) {
|
533
651
|
logger.debug(`uploading to "${hostname}"`);
|
534
652
|
const auth = encodeURIComponent(uploadInfo.auth); // the auth token
|
535
|
-
const url = `https://${hostname}${
|
536
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
653
|
+
const url = `https://${hostname}${media}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
|
537
654
|
let result;
|
538
655
|
try {
|
539
|
-
|
656
|
+
if (maxContentLengthBytes && reqBody.length > maxContentLengthBytes) {
|
657
|
+
throw new boom_1.Boom(`Body too large for "${hostname}"`, { statusCode: 413 });
|
658
|
+
}
|
659
|
+
const body = await axios_1.default.post(url, reqBody, {
|
540
660
|
...options,
|
541
661
|
headers: {
|
542
662
|
...options.headers || {},
|
@@ -553,7 +673,8 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
553
673
|
if ((result === null || result === void 0 ? void 0 : result.url) || (result === null || result === void 0 ? void 0 : result.directPath)) {
|
554
674
|
urls = {
|
555
675
|
mediaUrl: result.url,
|
556
|
-
directPath: result.direct_path
|
676
|
+
directPath: result.direct_path,
|
677
|
+
handle: result.handle
|
557
678
|
};
|
558
679
|
break;
|
559
680
|
}
|
@@ -665,3 +786,7 @@ const MEDIA_RETRY_STATUS_MAP = {
|
|
665
786
|
[WAProto_1.proto.MediaRetryNotification.ResultType.NOT_FOUND]: 404,
|
666
787
|
[WAProto_1.proto.MediaRetryNotification.ResultType.GENERAL_ERROR]: 418,
|
667
788
|
};
|
789
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
790
|
+
function __importStar(arg0) {
|
791
|
+
throw new Error('Function not implemented.');
|
792
|
+
}
|
package/lib/Utils/messages.d.ts
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
/// <reference types="node" />
|
3
|
-
/// <reference types="node" />
|
4
1
|
import { type Transform } from 'stream';
|
5
2
|
import { proto } from '../../WAProto';
|
6
|
-
import { AnyMediaMessageContent, AnyMessageContent, MediaGenerationOptions, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAProto } from '../Types';
|
7
3
|
import { ILogger } from './logger';
|
4
|
+
import { AnyMediaMessageContent, AnyMessageContent, MediaGenerationOptions, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAProto } from '../Types';
|
8
5
|
import { MediaDownloadOptions } from './messages-media';
|
9
6
|
/**
|
10
7
|
* Uses a regex to test whether the string contains a URL, and returns the URL if it does.
|
@@ -12,7 +9,7 @@ import { MediaDownloadOptions } from './messages-media';
|
|
12
9
|
* @returns the URL, eg. https://google.com
|
13
10
|
*/
|
14
11
|
export declare const extractUrlFromText: (text: string) => string | undefined;
|
15
|
-
export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions[
|
12
|
+
export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions["getUrlInfo"], logger: MessageGenerationOptions["logger"]) => Promise<import("../Types").WAUrlInfo | undefined>;
|
16
13
|
export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MediaGenerationOptions) => Promise<proto.Message>;
|
17
14
|
export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message;
|
18
15
|
/**
|
@@ -43,11 +40,11 @@ export declare const extractMessageContent: (content: WAMessageContent | undefin
|
|
43
40
|
*/
|
44
41
|
export declare const getDevice: (id: string) => "android" | "unknown" | "web" | "ios" | "desktop";
|
45
42
|
/** Upserts a receipt in the message */
|
46
|
-
export declare const updateMessageWithReceipt: (msg: Pick<WAMessage,
|
43
|
+
export declare const updateMessageWithReceipt: (msg: Pick<WAMessage, "userReceipt">, receipt: MessageUserReceipt) => void;
|
47
44
|
/** Update the message with a new reaction */
|
48
|
-
export declare const updateMessageWithReaction: (msg: Pick<WAMessage,
|
45
|
+
export declare const updateMessageWithReaction: (msg: Pick<WAMessage, "reactions">, reaction: proto.IReaction) => void;
|
49
46
|
/** Update the message with a new poll update */
|
50
|
-
export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage,
|
47
|
+
export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage, "pollUpdates">, update: proto.IPollUpdate) => void;
|
51
48
|
type VoteAggregation = {
|
52
49
|
name: string;
|
53
50
|
voters: string[];
|
@@ -72,7 +69,7 @@ type DownloadMediaMessageContext = {
|
|
72
69
|
/**
|
73
70
|
* Downloads the given message. Throws an error if it's not a media message
|
74
71
|
*/
|
75
|
-
export declare const downloadMediaMessage: <Type extends "
|
72
|
+
export declare const downloadMediaMessage: <Type extends "buffer" | "stream">(message: WAMessage, type: Type, options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Type extends "buffer" ? Buffer<ArrayBufferLike> : Transform>;
|
76
73
|
/** Checks whether the given message is a media message; if it is returns the inner content */
|
77
74
|
export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
78
75
|
export {};
|