@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.
Files changed (99) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -1
  3. package/WAProto/index.d.ts +19244 -2787
  4. package/WAProto/index.js +138202 -74217
  5. package/engine-requirements.js +10 -0
  6. package/lib/Defaults/baileys-version.json +1 -1
  7. package/lib/Defaults/index.d.ts +3 -5
  8. package/lib/Defaults/index.js +7 -6
  9. package/lib/Signal/libsignal.js +18 -9
  10. package/lib/Socket/Client/types.d.ts +0 -2
  11. package/lib/Socket/Client/websocket.js +1 -1
  12. package/lib/Socket/business.d.ts +65 -37
  13. package/lib/Socket/chats.d.ts +22 -18
  14. package/lib/Socket/chats.js +110 -6
  15. package/lib/Socket/groups.d.ts +30 -26
  16. package/lib/Socket/groups.js +20 -6
  17. package/lib/Socket/index.d.ts +66 -38
  18. package/lib/Socket/messages-recv.d.ts +63 -33
  19. package/lib/Socket/messages-recv.js +174 -27
  20. package/lib/Socket/messages-send.d.ts +55 -29
  21. package/lib/Socket/messages-send.js +190 -26
  22. package/lib/Socket/newsletter.d.ts +140 -0
  23. package/lib/Socket/newsletter.js +252 -0
  24. package/lib/Socket/socket.d.ts +8 -10
  25. package/lib/Socket/socket.js +26 -13
  26. package/lib/Socket/usync.d.ts +10 -12
  27. package/lib/Socket/usync.js +10 -15
  28. package/lib/Store/index.d.ts +1 -2
  29. package/lib/Store/index.js +1 -3
  30. package/lib/Store/make-in-memory-store.d.ts +1 -1
  31. package/lib/Store/make-in-memory-store.js +14 -5
  32. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  33. package/lib/Types/Auth.d.ts +0 -2
  34. package/lib/Types/Chat.d.ts +7 -0
  35. package/lib/Types/Contact.d.ts +5 -0
  36. package/lib/Types/Events.d.ts +27 -0
  37. package/lib/Types/GroupMetadata.d.ts +7 -0
  38. package/lib/Types/Label.js +1 -1
  39. package/lib/Types/LabelAssociation.js +1 -1
  40. package/lib/Types/Message.d.ts +129 -16
  41. package/lib/Types/Message.js +0 -2
  42. package/lib/Types/Newsletter.d.ts +79 -0
  43. package/lib/Types/Newsletter.js +18 -0
  44. package/lib/Types/Socket.d.ts +8 -5
  45. package/lib/Types/index.d.ts +1 -0
  46. package/lib/Types/index.js +2 -1
  47. package/lib/Utils/auth-utils.d.ts +1 -1
  48. package/lib/Utils/auth-utils.js +6 -7
  49. package/lib/Utils/business.js +2 -2
  50. package/lib/Utils/chat-utils.d.ts +8 -10
  51. package/lib/Utils/chat-utils.js +11 -0
  52. package/lib/Utils/crypto.d.ts +14 -16
  53. package/lib/Utils/crypto.js +40 -26
  54. package/lib/Utils/decode-wa-message.d.ts +5 -3
  55. package/lib/Utils/decode-wa-message.js +171 -29
  56. package/lib/Utils/event-buffer.js +1 -3
  57. package/lib/Utils/generics.d.ts +35 -9
  58. package/lib/Utils/generics.js +93 -27
  59. package/lib/Utils/history.d.ts +2 -2
  60. package/lib/Utils/link-preview.d.ts +1 -1
  61. package/lib/Utils/link-preview.js +17 -7
  62. package/lib/Utils/make-mutex.d.ts +2 -2
  63. package/lib/Utils/make-mutex.js +0 -1
  64. package/lib/Utils/messages-media.d.ts +35 -16
  65. package/lib/Utils/messages-media.js +168 -43
  66. package/lib/Utils/messages.d.ts +6 -9
  67. package/lib/Utils/messages.js +297 -37
  68. package/lib/Utils/noise-handler.d.ts +5 -7
  69. package/lib/Utils/process-message.js +2 -3
  70. package/lib/Utils/use-multi-file-auth-state.js +44 -13
  71. package/lib/Utils/validate-connection.d.ts +2 -2
  72. package/lib/Utils/validate-connection.js +1 -3
  73. package/lib/WABinary/decode.d.ts +2 -4
  74. package/lib/WABinary/decode.js +20 -9
  75. package/lib/WABinary/encode.d.ts +1 -3
  76. package/lib/WABinary/encode.js +30 -12
  77. package/lib/WABinary/generic-utils.d.ts +1 -3
  78. package/lib/WABinary/generic-utils.js +2 -2
  79. package/lib/WABinary/jid-utils.d.ts +9 -4
  80. package/lib/WABinary/jid-utils.js +25 -4
  81. package/lib/WAM/BinaryInfo.d.ts +2 -12
  82. package/lib/WAM/encode.d.ts +1 -3
  83. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  84. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -2
  85. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  86. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -5
  87. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  88. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  89. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  90. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  91. package/lib/WAUSync/USyncQuery.d.ts +2 -0
  92. package/lib/WAUSync/USyncQuery.js +27 -13
  93. package/lib/WAUSync/USyncUser.d.ts +2 -0
  94. package/lib/WAUSync/USyncUser.js +4 -0
  95. package/lib/index.d.ts +2 -1
  96. package/lib/index.js +3 -1
  97. package/package.json +59 -57
  98. package/WAProto/GenerateStatics.sh +0 -4
  99. 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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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.extensionForMediaMessage = exports.downloadEncryptedContent = exports.downloadContentFromMessage = exports.getUrlFromDirectPath = exports.encryptedStream = exports.getHttpStream = exports.generateThumbnail = exports.getStream = exports.toBuffer = exports.toReadable = exports.getAudioWaveform = exports.getAudioDuration = exports.mediaMessageSHA256B64 = exports.generateProfilePicture = exports.encodeBase64EncodedStringForUpload = exports.extractImageThumb = exports.getMediaKeys = exports.hkdfInfoKey = void 0;
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 lib = await getImageProcessingLibrary();
159
- let img;
160
- if ('sharp' in lib && typeof ((_a = lib.sharp) === null || _a === void 0 ? void 0 : _a.default) === 'function') {
161
- img = lib.sharp.default(bufferOrFilePath)
162
- .resize(640, 640)
163
- .jpeg({
164
- quality: 50,
165
- })
166
- .toBuffer();
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 if ('jimp' in lib && typeof ((_b = lib.jimp) === null || _b === void 0 ? void 0 : _b.read) === 'function') {
169
- const { read, MIME_JPEG, RESIZE_BILINEAR } = lib.jimp;
170
- const jimp = await read(bufferOrFilePath);
171
- const min = Math.min(jimp.getWidth(), jimp.getHeight());
172
- const cropped = jimp.crop(0, 0, min, min);
173
- img = cropped
174
- .quality(50)
175
- .resize(640, 640, RESIZE_BILINEAR)
176
- .getBufferAsync(MIME_JPEG);
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
- throw new boom_1.Boom('No image processing library available');
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 img,
249
+ img: await cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG),
183
250
  };
184
251
  };
185
- exports.generateProfilePicture = generateProfilePicture;
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.generateMessageID)() + '.jpg');
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.generateMessageID)());
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
- for (const { hostname } of hosts) {
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}${Defaults_1.MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
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
- const body = await axios_1.default.post(url, stream, {
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
+ }
@@ -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['getUrlInfo'], logger: MessageGenerationOptions['logger']) => Promise<import("../Types").WAUrlInfo | undefined>;
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, 'userReceipt'>, receipt: MessageUserReceipt) => void;
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, 'reactions'>, reaction: proto.IReaction) => void;
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, 'pollUpdates'>, update: proto.IPollUpdate) => void;
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 "stream" | "buffer">(message: WAMessage, type: Type, options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Type extends "buffer" ? Buffer : Transform>;
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 {};