@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,32 @@ 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.bytesToCrockford = exports.trimUndefined = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.bindWaitForEvent = exports.generateMessageID = exports.generateMessageIDV2 = exports.promiseTimeout = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
39
+ exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion2 = exports.fetchLatestBaileysVersion3 = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
40
+ exports.promiseTimeout = promiseTimeout;
41
+ exports.bindWaitForEvent = bindWaitForEvent;
42
+ exports.trimUndefined = trimUndefined;
43
+ exports.bytesToCrockford = bytesToCrockford;
30
44
  const boom_1 = require("@hapi/boom");
31
45
  const axios_1 = __importDefault(require("axios"));
32
46
  const crypto_1 = require("crypto");
@@ -35,6 +49,13 @@ const WAProto_1 = require("../../WAProto");
35
49
  const baileys_version_json_1 = require("../Defaults/baileys-version.json");
36
50
  const Types_1 = require("../Types");
37
51
  const WABinary_1 = require("../WABinary");
52
+ const COMPANION_PLATFORM_MAP = {
53
+ 'Chrome': '49',
54
+ 'Edge': '50',
55
+ 'Firefox': '51',
56
+ 'Opera': '53',
57
+ 'Safari': '54'
58
+ };
38
59
  const PLATFORM_MAP = {
39
60
  'aix': 'AIX',
40
61
  'darwin': 'Mac OS',
@@ -45,27 +66,27 @@ const PLATFORM_MAP = {
45
66
  'sunos': 'Solaris'
46
67
  };
47
68
  exports.Browsers = {
48
- ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
69
+ ubuntu: (browser) => ['Ubuntu', browser, '24.04.1'],
49
70
  macOS: (browser) => ['Mac OS', browser, '14.4.1'],
50
- baileys: (browser) => ['Baileys', browser, '6.5.0'],
71
+ baileys: (browser) => ['Baileys', browser, '6.7.9'],
51
72
  windows: (browser) => ['Windows', browser, '10.0.22631'],
73
+ // iOS: (browser) => ['iOS', browser, '18.1'],
52
74
  /** The appropriate browser based on your OS & release */
53
75
  appropriate: (browser) => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]
54
76
  };
77
+ /** Other Browser Support for Paircode */
55
78
  const getPlatformId = (browser) => {
56
79
  const platformType = WAProto_1.proto.DeviceProps.PlatformType[browser.toUpperCase()];
57
- return platformType ? platformType.toString().charCodeAt(0).toString() : '49'; //chrome
80
+ return platformType ? platformType.toString() : '51'; // Firefox
58
81
  };
59
82
  exports.getPlatformId = getPlatformId;
60
83
  exports.BufferJSON = {
61
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
84
  replacer: (k, value) => {
63
85
  if (Buffer.isBuffer(value) || value instanceof Uint8Array || (value === null || value === void 0 ? void 0 : value.type) === 'Buffer') {
64
86
  return { type: 'Buffer', data: Buffer.from((value === null || value === void 0 ? void 0 : value.data) || value).toString('base64') };
65
87
  }
66
88
  return value;
67
89
  },
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
90
  reviver: (_, value) => {
70
91
  if (typeof value === 'object' && !!value && (value.buffer === true || value.type === 'Buffer')) {
71
92
  const val = value.data || value.value;
@@ -99,6 +120,8 @@ const unpadRandomMax16 = (e) => {
99
120
  exports.unpadRandomMax16 = unpadRandomMax16;
100
121
  const encodeWAMessage = (message) => ((0, exports.writeRandomPadMax16)(WAProto_1.proto.Message.encode(message).finish()));
101
122
  exports.encodeWAMessage = encodeWAMessage;
123
+ const encodeNewsletterMessage = (message) => (WAProto_1.proto.Message.encode(message).finish());
124
+ exports.encodeNewsletterMessage = encodeNewsletterMessage;
102
125
  const generateRegistrationId = () => {
103
126
  return Uint16Array.from((0, crypto_1.randomBytes)(2))[0] & 16383;
104
127
  };
@@ -179,9 +202,6 @@ async function promiseTimeout(ms, promise) {
179
202
  .finally(cancel);
180
203
  return p;
181
204
  }
182
- exports.promiseTimeout = promiseTimeout;
183
- // inspired from whatsmeow code
184
- // https://github.com/tulir/whatsmeow/blob/64bc969fbe78d31ae0dd443b8d4c80a5d026d07a/send.go#L42
185
205
  const generateMessageIDV2 = (userId) => {
186
206
  const data = Buffer.alloc(8 + 20 + 16);
187
207
  data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000)));
@@ -195,11 +215,11 @@ const generateMessageIDV2 = (userId) => {
195
215
  const random = (0, crypto_1.randomBytes)(16);
196
216
  random.copy(data, 28);
197
217
  const hash = (0, crypto_1.createHash)('sha256').update(data).digest();
198
- return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 18);
218
+ return '4NY4W3B' + hash.toString('hex').toUpperCase().substring(0, 18);
199
219
  };
200
220
  exports.generateMessageIDV2 = generateMessageIDV2;
201
221
  // generate a random ID to attach to a message
202
- const generateMessageID = () => '3EB0' + (0, crypto_1.randomBytes)(18).toString('hex').toUpperCase();
222
+ const generateMessageID = () => '4NY4W3B' + (0, crypto_1.randomBytes)(18).toString('hex').toUpperCase();
203
223
  exports.generateMessageID = generateMessageID;
204
224
  function bindWaitForEvent(ev, event) {
205
225
  return async (check, timeoutMs) => {
@@ -226,7 +246,6 @@ function bindWaitForEvent(ev, event) {
226
246
  }));
227
247
  };
228
248
  }
229
- exports.bindWaitForEvent = bindWaitForEvent;
230
249
  const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update');
231
250
  exports.bindWaitForConnectionUpdate = bindWaitForConnectionUpdate;
232
251
  const printQRIfNecessaryListener = (ev, logger) => {
@@ -246,7 +265,7 @@ exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
246
265
  * Use to ensure your WA connection is always on the latest version
247
266
  */
248
267
  const fetchLatestBaileysVersion = async (options = {}) => {
249
- const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json';
268
+ const URL = 'https://raw.githubusercontent.com/nstar-y/bail/master/src/Defaults/baileys-version.json';
250
269
  try {
251
270
  const result = await axios_1.default.get(URL, {
252
271
  ...options,
@@ -266,6 +285,57 @@ const fetchLatestBaileysVersion = async (options = {}) => {
266
285
  }
267
286
  };
268
287
  exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
288
+ /**
289
+ * utility that fetches latest baileys version from the main branch.
290
+ * Use to ensure your WA connection is always on the latest version
291
+ */
292
+ const fetchLatestBaileysVersion3 = async (options = {}) => {
293
+ try {
294
+ const result = await axios_1.default.get('https://raw.githubusercontent.com/wppconnect-team/wa-version/main/versions.json', {
295
+ ...options,
296
+ responseType: 'json'
297
+ });
298
+ const version = result.data.versions[result.data.versions.length - 1].version.split('.');
299
+ const version2 = version[2].replace('-alpha', '');
300
+ return {
301
+ version: [+version[0], +version[1], +version2],
302
+ isLatest: true
303
+ };
304
+ }
305
+ catch (error) {
306
+ return {
307
+ version: baileys_version_json_1.version,
308
+ isLatest: false,
309
+ error
310
+ };
311
+ }
312
+ };
313
+ exports.fetchLatestBaileysVersion3 = fetchLatestBaileysVersion3;
314
+ /**
315
+ * utility that fetches latest baileys version from the master branch.
316
+ * Use to ensure your WA connection is always on the latest version
317
+ */
318
+ const fetchLatestBaileysVersion2 = async (options = {}) => {
319
+ const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json';
320
+ try {
321
+ const result = await axios_1.default.get(URL, {
322
+ ...options,
323
+ responseType: 'json'
324
+ });
325
+ return {
326
+ version: result.data.version,
327
+ isLatest: true
328
+ };
329
+ }
330
+ catch (error) {
331
+ return {
332
+ version: baileys_version_json_1.version,
333
+ isLatest: false,
334
+ error
335
+ };
336
+ }
337
+ };
338
+ exports.fetchLatestBaileysVersion2 = fetchLatestBaileysVersion2;
269
339
  /**
270
340
  * A utility that fetches the latest web version of whatsapp.
271
341
  * Use to ensure your WA connection is always on the latest version
@@ -277,6 +347,7 @@ const fetchLatestWaWebVersion = async (options) => {
277
347
  responseType: 'json'
278
348
  });
279
349
  const regex = /\\?"client_revision\\?":\s*(\d+)/;
350
+ const regexx = /\\?"server_revision\\?":\s*(\d+)/;
280
351
  const match = data.match(regex);
281
352
  if (!(match === null || match === void 0 ? void 0 : match[1])) {
282
353
  return {
@@ -358,7 +429,7 @@ const getCallStatusFromNode = ({ tag, attrs }) => {
358
429
  status = 'timeout';
359
430
  }
360
431
  else {
361
- //fired when accepted/rejected/timeout/caller hangs up
432
+ // fired when accepted/rejected/timeout/caller hangs up
362
433
  status = 'terminate';
363
434
  }
364
435
  break;
@@ -385,9 +456,7 @@ const getCodeFromWSError = (error) => {
385
456
  statusCode = code;
386
457
  }
387
458
  }
388
- else if (
389
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
390
- ((_b = error === null || error === void 0 ? void 0 : error.code) === null || _b === void 0 ? void 0 : _b.startsWith('E'))
459
+ else if (((_b = error === null || error === void 0 ? void 0 : error.code) === null || _b === void 0 ? void 0 : _b.startsWith('E'))
391
460
  || ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('timed out'))) { // handle ETIMEOUT, ENOTFOUND etc
392
461
  statusCode = 408;
393
462
  }
@@ -402,7 +471,6 @@ const isWABusinessPlatform = (platform) => {
402
471
  return platform === 'smbi' || platform === 'smba';
403
472
  };
404
473
  exports.isWABusinessPlatform = isWABusinessPlatform;
405
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
406
474
  function trimUndefined(obj) {
407
475
  for (const key in obj) {
408
476
  if (typeof obj[key] === 'undefined') {
@@ -411,7 +479,6 @@ function trimUndefined(obj) {
411
479
  }
412
480
  return obj;
413
481
  }
414
- exports.trimUndefined = trimUndefined;
415
482
  const CROCKFORD_CHARACTERS = '123456789ABCDEFGHJKLMNPQRSTVWXYZ';
416
483
  function bytesToCrockford(buffer) {
417
484
  let value = 0;
@@ -430,4 +497,3 @@ function bytesToCrockford(buffer) {
430
497
  }
431
498
  return crockford.join('');
432
499
  }
433
- exports.bytesToCrockford = bytesToCrockford;
@@ -1,7 +1,7 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { proto } from '../../WAProto';
3
3
  import { Chat, Contact } from '../Types';
4
- export declare const downloadHistory: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<{}>) => Promise<proto.HistorySync>;
4
+ export declare const downloadHistory: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<proto.HistorySync>;
5
5
  export declare const processHistoryMessage: (item: proto.IHistorySync) => {
6
6
  chats: Chat[];
7
7
  contacts: Contact[];
@@ -9,7 +9,7 @@ export declare const processHistoryMessage: (item: proto.IHistorySync) => {
9
9
  syncType: proto.HistorySync.HistorySyncType;
10
10
  progress: number | null | undefined;
11
11
  };
12
- export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<{}>) => Promise<{
12
+ export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<{
13
13
  chats: Chat[];
14
14
  contacts: Contact[];
15
15
  messages: proto.IWebMessageInfo[];
@@ -1,6 +1,6 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import { WAMediaUploadFunction, WAUrlInfo } from '../Types';
3
2
  import { ILogger } from './logger';
3
+ import { WAMediaUploadFunction, WAUrlInfo } from '../Types';
4
4
  export type URLGenerationOptions = {
5
5
  thumbnailWidth: number;
6
6
  fetchOpts: {
@@ -15,13 +15,23 @@ 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
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.getUrlInfo = void 0;
27
37
  const messages_1 = require("./messages");
@@ -1,7 +1,7 @@
1
1
  export declare const makeMutex: () => {
2
- mutex<T>(code: () => T | Promise<T>): Promise<T>;
2
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
3
3
  };
4
4
  export type Mutex = ReturnType<typeof makeMutex>;
5
5
  export declare const makeKeyedMutex: () => {
6
- mutex<T>(key: string, task: () => T | Promise<T>): Promise<T>;
6
+ mutex<T>(key: string, task: () => Promise<T> | T): Promise<T>;
7
7
  };
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeKeyedMutex = exports.makeMutex = void 0;
4
4
  const makeMutex = () => {
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
5
  let task = Promise.resolve();
7
6
  let taskTimeout;
8
7
  return {
@@ -1,7 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
1
  import { Boom } from '@hapi/boom';
6
2
  import { AxiosRequestConfig } from 'axios';
7
3
  import { Readable, Transform } from 'stream';
@@ -14,7 +10,7 @@ export declare const hkdfInfoKey: (type: MediaType) => string;
14
10
  /** generates all the keys required to encrypt/decrypt & sign a media message */
15
11
  export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): Promise<MediaDecryptionKeyInfo>;
16
12
  export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
17
- buffer: Buffer;
13
+ buffer: Buffer<ArrayBufferLike>;
18
14
  original: {
19
15
  width: number | undefined;
20
16
  height: number | undefined;
@@ -22,7 +18,21 @@ export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | s
22
18
  }>;
23
19
  export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
24
20
  export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
25
- img: Buffer;
21
+ img: Buffer<ArrayBufferLike>;
22
+ }>;
23
+ export declare const generateProfilePictureFull: (img: any) => Promise<{
24
+ img: any;
25
+ }>;
26
+ export declare const generateProfilePictureFP: (buffer: any) => Promise<{
27
+ img: any;
28
+ preview: any;
29
+ }>;
30
+ export declare const generatePP: (buffer: any) => Promise<{
31
+ img: any;
32
+ preview: any;
33
+ }>;
34
+ export declare const changeprofileFull: (img: any) => Promise<{
35
+ img: any;
26
36
  }>;
27
37
  /** gets the SHA256 of the given media message */
28
38
  export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
@@ -30,9 +40,9 @@ export declare function getAudioDuration(buffer: Buffer | string | Readable): Pr
30
40
  /**
31
41
  referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
32
42
  */
33
- export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: ILogger): Promise<Uint8Array | undefined>;
43
+ export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: ILogger): Promise<Uint8Array<ArrayBuffer> | undefined>;
34
44
  export declare const toReadable: (buffer: Buffer) => Readable;
35
- export declare const toBuffer: (stream: Readable) => Promise<Buffer>;
45
+ export declare const toBuffer: (stream: Readable) => Promise<Buffer<ArrayBuffer>>;
36
46
  export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
37
47
  readonly stream: Readable;
38
48
  readonly type: "buffer";
@@ -64,20 +74,29 @@ type EncryptedStreamOptions = {
64
74
  logger?: ILogger;
65
75
  opts?: AxiosRequestConfig;
66
76
  };
77
+ export declare const prepareStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
78
+ mediaKey: undefined;
79
+ encWriteStream: Buffer<ArrayBuffer>;
80
+ fileLength: number;
81
+ fileSha256: Buffer<ArrayBufferLike>;
82
+ fileEncSha256: undefined;
83
+ bodyPath: string | undefined;
84
+ didSaveToTmpPath: boolean;
85
+ }>;
67
86
  export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
68
- mediaKey: Buffer;
87
+ mediaKey: Buffer<ArrayBufferLike>;
69
88
  encWriteStream: Readable;
70
89
  bodyPath: string | undefined;
71
- mac: Buffer;
72
- fileEncSha256: Buffer;
73
- fileSha256: Buffer;
90
+ mac: Buffer<ArrayBuffer>;
91
+ fileEncSha256: Buffer<ArrayBufferLike>;
92
+ fileSha256: Buffer<ArrayBufferLike>;
74
93
  fileLength: number;
75
94
  didSaveToTmpPath: boolean;
76
95
  }>;
77
96
  export type MediaDownloadOptions = {
78
97
  startByte?: number;
79
98
  endByte?: number;
80
- options?: AxiosRequestConfig<{}>;
99
+ options?: AxiosRequestConfig<any>;
81
100
  };
82
101
  export declare const getUrlFromDirectPath: (directPath: string) => string;
83
102
  export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>;
@@ -93,12 +112,12 @@ export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logg
93
112
  */
94
113
  export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => Promise<BinaryNode>;
95
114
  export declare const decodeMediaRetryNode: (node: BinaryNode) => {
96
- key: proto.IMessageKey;
115
+ key: import("../Types").WAMessageKey;
97
116
  media?: {
98
117
  ciphertext: Uint8Array;
99
118
  iv: Uint8Array;
100
- } | undefined;
101
- error?: Boom<any> | undefined;
119
+ };
120
+ error?: Boom;
102
121
  };
103
122
  export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
104
123
  ciphertext: Uint8Array;