@wppconnect-team/wppconnect 1.32.0 → 1.32.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## <small>1.32.2 (2024-06-18)</small>
2
+
3
+ - chore: Remove unused deps ([a600ce0](https://github.com/wppconnect-team/wppconnect/commit/a600ce0))
4
+
5
+ ## <small>1.32.1 (2024-06-17)</small>
6
+
7
+ - fix: Fixed emitting events ([95e934d](https://github.com/wppconnect-team/wppconnect/commit/95e934d))
8
+
1
9
  ## 1.32.0 (2024-06-12)
2
10
 
3
11
  - fix: Improovment whatsappVersion to 2.3000.10139x ([d246c58](https://github.com/wppconnect-team/wppconnect/commit/d246c58))
package/README.md CHANGED
@@ -62,6 +62,13 @@ Building WPPConnect is really simple, to build the entire project just run
62
62
  > npm run build
63
63
  ```
64
64
 
65
+ # Update checking
66
+
67
+ Whatsapp is in constant change. In order to tackle this issue, we suggest always keeping your Wppconnect package up-to-date.
68
+
69
+ The method/function names won't change, only their core algorithm. This way you won't have to makes changes in your code at every update.
70
+ They will remain the same forever but might experience deprecation.
71
+
65
72
  ## Maintainers
66
73
 
67
74
  Maintainers are needed, I cannot keep with all the updates by myself. If you are
@@ -1,6 +1,6 @@
1
1
  import { Page } from 'puppeteer';
2
2
  import { CreateConfig } from '../../config/create-config';
3
- import { Ack, Chat, LiveLocation, Message, ParticipantEvent, PresenceEvent, Wid } from '../model';
3
+ import { Ack, Chat, LiveLocation, Message, ParticipantEvent, PresenceEvent, Wid, IncomingCall } from '../model';
4
4
  import { SocketState, SocketStream } from '../model/enum';
5
5
  import { InterfaceMode } from '../model/enum/interface-mode';
6
6
  import { InterfaceState } from '../model/enum/interface-state';
@@ -132,17 +132,15 @@ export declare class ListenerLayer extends ProfileLayer {
132
132
  dispose: () => void;
133
133
  };
134
134
  /**
135
- * @event Escuta por ligações recebidas, seja de áudio ou vídeo.
136
- *
137
- * Para recusar a ligação, basta chamar o `rejectCall` {@link rejectCall}
138
- *
139
- * @returns Objeto descartável para parar de ouvir
135
+ * @event Listen for incoming calls, whether audio or video (pending a reaction).
136
+ * To reject the call, simply call `rejectCall` {@link rejectCall}
137
+ * @returns Disposable object to stop listening
140
138
  */
141
- onIncomingCall(callback: (call: any) => any): {
139
+ onIncomingCall(callback: (call: IncomingCall) => any): {
142
140
  dispose: () => void;
143
141
  };
144
142
  /**
145
- * Listens to presence changed, by default, it will triggered for active chats only or contacts subscribed (see {@link subscribePresence})
143
+ * Listens to presence changed, by default, it will be triggered for active chats only or contacts subscribed (see {@link subscribePresence})
146
144
  * @event Listens to presence changed
147
145
  * @param callback Callback of on presence changed
148
146
  * @returns Disposable object to stop the listening
@@ -515,11 +515,9 @@ var ListenerLayer = /** @class */ (function (_super) {
515
515
  return this.registerEvent('onAddedToGroup', callback);
516
516
  };
517
517
  /**
518
- * @event Escuta por ligações recebidas, seja de áudio ou vídeo.
519
- *
520
- * Para recusar a ligação, basta chamar o `rejectCall` {@link rejectCall}
521
- *
522
- * @returns Objeto descartável para parar de ouvir
518
+ * @event Listen for incoming calls, whether audio or video (pending a reaction).
519
+ * To reject the call, simply call `rejectCall` {@link rejectCall}
520
+ * @returns Disposable object to stop listening
523
521
  */
524
522
  ListenerLayer.prototype.onIncomingCall = function (callback) {
525
523
  return this.registerEvent('onIncomingCall', callback);
@@ -262,28 +262,10 @@ var RetrieverLayer = /** @class */ (function (_super) {
262
262
  */
263
263
  RetrieverLayer.prototype.checkNumberStatus = function (contactId) {
264
264
  return __awaiter(this, void 0, void 0, function () {
265
- var result;
266
265
  return __generator(this, function (_a) {
267
266
  switch (_a.label) {
268
- case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (contactId) { return WPP.contact.queryExists(contactId); }, contactId)];
269
- case 1:
270
- result = _a.sent();
271
- if (!result) {
272
- return [2 /*return*/, {
273
- id: contactId,
274
- isBusiness: false,
275
- canReceiveMessage: false,
276
- numberExists: false,
277
- status: 404,
278
- }];
279
- }
280
- return [2 /*return*/, {
281
- id: result.wid,
282
- isBusiness: result.biz,
283
- canReceiveMessage: true,
284
- numberExists: true,
285
- status: 200,
286
- }];
267
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (contactId) { return WAPI.checkNumberStatus(contactId); }, contactId)];
268
+ case 1: return [2 /*return*/, _a.sent()];
287
269
  }
288
270
  });
289
271
  });
@@ -1,4 +1,4 @@
1
- import type { FileMessageOptions, ListMessageOptions, LocationMessageOptions, SendMessageReturn, TextMessageOptions, PoolMessageOptions, ForwardMessagesOptions } from '@wppconnect/wa-js/dist/chat';
1
+ import type { FileMessageOptions, ListMessageOptions, LocationMessageOptions, SendMessageReturn, TextMessageOptions, PoolMessageOptions, ForwardMessagesOptions, AllMessageOptions } from '@wppconnect/wa-js/dist/chat';
2
2
  import { Page } from 'puppeteer';
3
3
  import { CreateConfig } from '../../config/create-config';
4
4
  import { Message } from '../model';
@@ -306,18 +306,45 @@ export declare class SenderLayer extends ListenerLayer {
306
306
  forwardMessage(toChatId: string, msgId: string | string[], options?: ForwardMessagesOptions): Promise<boolean>;
307
307
  /**
308
308
  * Generates sticker from the provided animated gif image and sends it (Send image as animated sticker)
309
+ *
310
+ * @example
311
+ * ```javascript
312
+ * client.sendImageAsStickerGif('000000000000@c.us', 'base64....');
313
+ * ```
314
+ *
315
+ * @example
316
+ * Send Sticker with reply
317
+ * ```javascript
318
+ * client.sendImageAsStickerGif('000000000000@c.us', 'base64....', {
319
+ * quotedMsg: 'msgId',
320
+ * });
321
+ * ```
309
322
  * @category Chat
310
323
  * @param pathOrBase64 image path imageBase64 A valid gif image is required. You can also send via http/https (http://www.website.com/img.gif)
311
324
  * @param to chatId '000000000000@c.us'
312
325
  */
313
- sendImageAsStickerGif(to: string, pathOrBase64: string): Promise<SendMessageReturn>;
326
+ sendImageAsStickerGif(to: string, pathOrBase64: string, options?: AllMessageOptions): Promise<SendMessageReturn>;
314
327
  /**
315
328
  * Generates sticker from given image and sends it (Send Image As Sticker)
329
+ *
330
+ * @example
331
+ * ```javascript
332
+ * client.sendImageAsSticker('000000000000@c.us', 'base64....');
333
+ * ```
334
+ *
335
+ * @example
336
+ * Send Sticker with reply
337
+ * ```javascript
338
+ * client.sendImageAsSticker('000000000000@c.us', 'base64....', {
339
+ * quotedMsg: 'msgId',
340
+ * });
341
+ * ```
342
+ *
316
343
  * @category Chat
317
344
  * @param pathOrBase64 image path imageBase64 A valid png, jpg and webp image is required. You can also send via http/https (http://www.website.com/img.gif)
318
345
  * @param to chatId '000000000000@c.us'
319
346
  */
320
- sendImageAsSticker(to: string, pathOrBase64: string): Promise<SendMessageReturn>;
347
+ sendImageAsSticker(to: string, pathOrBase64: string, options?: AllMessageOptions): Promise<SendMessageReturn>;
321
348
  /**
322
349
  * Sends location to given chat id
323
350
  * @category Chat
@@ -887,11 +887,24 @@ var SenderLayer = /** @class */ (function (_super) {
887
887
  };
888
888
  /**
889
889
  * Generates sticker from the provided animated gif image and sends it (Send image as animated sticker)
890
+ *
891
+ * @example
892
+ * ```javascript
893
+ * client.sendImageAsStickerGif('000000000000@c.us', 'base64....');
894
+ * ```
895
+ *
896
+ * @example
897
+ * Send Sticker with reply
898
+ * ```javascript
899
+ * client.sendImageAsStickerGif('000000000000@c.us', 'base64....', {
900
+ * quotedMsg: 'msgId',
901
+ * });
902
+ * ```
890
903
  * @category Chat
891
904
  * @param pathOrBase64 image path imageBase64 A valid gif image is required. You can also send via http/https (http://www.website.com/img.gif)
892
905
  * @param to chatId '000000000000@c.us'
893
906
  */
894
- SenderLayer.prototype.sendImageAsStickerGif = function (to, pathOrBase64) {
907
+ SenderLayer.prototype.sendImageAsStickerGif = function (to, pathOrBase64, options) {
895
908
  return __awaiter(this, void 0, void 0, function () {
896
909
  var base64, fileContent, error, mimeInfo, error, buff, obj, error, webpBase64;
897
910
  return __generator(this, function (_a) {
@@ -946,11 +959,9 @@ var SenderLayer = /** @class */ (function (_super) {
946
959
  }
947
960
  webpBase64 = obj.webpBase64;
948
961
  return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
949
- var to = _a.to, webpBase64 = _a.webpBase64;
950
- return WPP.chat.sendFileMessage(to, webpBase64, {
951
- type: 'sticker',
952
- });
953
- }, { to: to, webpBase64: webpBase64 })];
962
+ var to = _a.to, webpBase64 = _a.webpBase64, options = _a.options;
963
+ return WPP.chat.sendFileMessage(to, webpBase64, __assign({ type: 'sticker' }, options));
964
+ }, { to: to, webpBase64: webpBase64, options: options })];
954
965
  case 7: return [2 /*return*/, _a.sent()];
955
966
  }
956
967
  });
@@ -958,11 +969,25 @@ var SenderLayer = /** @class */ (function (_super) {
958
969
  };
959
970
  /**
960
971
  * Generates sticker from given image and sends it (Send Image As Sticker)
972
+ *
973
+ * @example
974
+ * ```javascript
975
+ * client.sendImageAsSticker('000000000000@c.us', 'base64....');
976
+ * ```
977
+ *
978
+ * @example
979
+ * Send Sticker with reply
980
+ * ```javascript
981
+ * client.sendImageAsSticker('000000000000@c.us', 'base64....', {
982
+ * quotedMsg: 'msgId',
983
+ * });
984
+ * ```
985
+ *
961
986
  * @category Chat
962
987
  * @param pathOrBase64 image path imageBase64 A valid png, jpg and webp image is required. You can also send via http/https (http://www.website.com/img.gif)
963
988
  * @param to chatId '000000000000@c.us'
964
989
  */
965
- SenderLayer.prototype.sendImageAsSticker = function (to, pathOrBase64) {
990
+ SenderLayer.prototype.sendImageAsSticker = function (to, pathOrBase64, options) {
966
991
  return __awaiter(this, void 0, void 0, function () {
967
992
  var base64, fileContent, error, mimeInfo, error, buff, obj, error, webpBase64;
968
993
  return __generator(this, function (_a) {
@@ -1020,11 +1045,9 @@ var SenderLayer = /** @class */ (function (_super) {
1020
1045
  }
1021
1046
  webpBase64 = obj.webpBase64;
1022
1047
  return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1023
- var to = _a.to, webpBase64 = _a.webpBase64;
1024
- return WPP.chat.sendFileMessage(to, webpBase64, {
1025
- type: 'sticker',
1026
- });
1027
- }, { to: to, webpBase64: webpBase64 })];
1048
+ var to = _a.to, webpBase64 = _a.webpBase64, options = _a.options;
1049
+ return WPP.chat.sendFileMessage(to, webpBase64, __assign({ type: 'sticker' }, options));
1050
+ }, { to: to, webpBase64: webpBase64, options: options })];
1028
1051
  case 7: return [2 /*return*/, _a.sent()];
1029
1052
  }
1030
1053
  });
@@ -18,12 +18,12 @@ export interface Contact {
18
18
  labels: any[];
19
19
  msgs: any;
20
20
  /**
21
- * Name of concat in your agenda
21
+ * Name of the contact in your agenda
22
22
  */
23
23
  name?: string;
24
24
  plaintextDisabled: boolean;
25
25
  /**
26
- * @deprecated Depreciado em favor da função {@link getProfilePicFromServer}
26
+ * @deprecated Deprecated in favor of the function `getProfilePicFromServer` {@link getProfilePicFromServer}
27
27
  */
28
28
  profilePicThumbObj: ProfilePicThumbObj;
29
29
  /**
@@ -0,0 +1,17 @@
1
+ export interface IncomingCall {
2
+ /** alphanumeric ID of the call, can e.g. usable for hanging up */
3
+ id: string;
4
+ /** ID of the caller, can be used to message them directly */
5
+ peerJid: string;
6
+ /** Epoch timestamp (seconds) */
7
+ offerTime: number;
8
+ isVideo: boolean;
9
+ isGroup: boolean;
10
+ groupJid: string | null;
11
+ canHandleLocally: boolean;
12
+ outgoing: boolean;
13
+ isSilenced: boolean;
14
+ offerReceivedWhileOffline: boolean;
15
+ webClientShouldHandle: boolean;
16
+ participants: any[];
17
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /*
3
+ * This file is part of WPPConnect.
4
+ *
5
+ * WPPConnect is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Lesser General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * WPPConnect is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public License
16
+ * along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,6 +11,7 @@ export { LiveLocation } from './live-location';
11
11
  export { ContactStatus } from './contact-status';
12
12
  export { GroupCreation } from './group-creation';
13
13
  export { WhatsappProfile } from './whatsapp-profile';
14
+ export { IncomingCall } from './incoming-call';
14
15
  export * from './result';
15
16
  export * from './get-messages-param';
16
17
  export * from './initializer';
@@ -321,7 +321,20 @@ function injectApi(page, onLoadingScreenCallBack) {
321
321
  })];
322
322
  case 4:
323
323
  _a.sent();
324
- onLoadingScreen(page, onLoadingScreenCallBack);
324
+ return [4 /*yield*/, onLoadingScreen(page, onLoadingScreenCallBack)];
325
+ case 5:
326
+ _a.sent();
327
+ // Make sure WAPI is initialized
328
+ return [4 /*yield*/, page
329
+ .waitForFunction(function () {
330
+ return (typeof window.WAPI !== 'undefined' &&
331
+ typeof window.Store !== 'undefined' &&
332
+ window.WPP.isReady);
333
+ })
334
+ .catch(function () { return false; })];
335
+ case 6:
336
+ // Make sure WAPI is initialized
337
+ _a.sent();
325
338
  return [2 /*return*/];
326
339
  }
327
340
  });
@@ -70,7 +70,7 @@ function welcomeScreen() {
70
70
  return;
71
71
  }
72
72
  welcomeShown = true;
73
- logger_1.defaultLogger.info("\n _ ______ ____ ______ __ \n | | / / __ \\/ __ \\/ ____/___ ____ ____ ___ _____/ /_\n | | /| / / /_/ / /_/ / / / __ \\/ __ \\/ __ \\/ _ \\/ ___/ __/\n | |/ |/ / ____/ ____/ /___/ /_/ / / / / / / / __/ /__/ /_ \n |__/|__/_/ /_/ \\____/\\____/_/ /_/_/ /_/\\___/\\___/\\__/");
73
+ logger_1.defaultLogger.info("\n _ ______ ____ ______ __ \n | | / / __ \\/ __ \\/ ____/___ ____ ____ ___ _____/ /_\n | | /| / / /_/ / /_/ / / / __ \\/ __ \\/ __ \\/ _ \\/ ___/ __/\n | |/ |/ / ____/ ____/ /___/ /_/ / / / / / / / __/ /__/ /_ \n |__/|__/_/ /_/ \\____/\\____/_/ /_/_/ /_/\\___/\\___/\\__/");
74
74
  }
75
75
  exports.welcomeScreen = welcomeScreen;
76
76
  function checkUpdates() {
@@ -91,7 +91,7 @@ function checkUpdates() {
91
91
  }
92
92
  exports.checkUpdates = checkUpdates;
93
93
  /**
94
- * Checs for a new versoin of wppconnect and logs
94
+ * Checks for a new version of WPPConnect and logs the result
95
95
  */
96
96
  function checkWPPConnectVersion() {
97
97
  return __awaiter(this, void 0, void 0, function () {
@@ -110,7 +110,7 @@ function checkWPPConnectVersion() {
110
110
  }
111
111
  })
112
112
  .catch(function () {
113
- logger_1.defaultLogger.warn('Failed to check updates');
113
+ logger_1.defaultLogger.warn('Failed to check for updates');
114
114
  })];
115
115
  case 1:
116
116
  _a.sent();
@@ -130,5 +130,5 @@ function logUpdateAvailable(current, latest) {
130
130
  "Update your package by running:\n\n" +
131
131
  "".concat(chalk_1.default.bold('\>'), " ").concat(chalk_1.default.blueBright('npm update @wppconnect-team/wppconnect'));
132
132
  logger_1.defaultLogger.info((0, boxen_1.default)(newVersionLog, { padding: 1 }));
133
- logger_1.defaultLogger.info("For more info visit: ".concat(chalk_1.default.underline('https://github.com/wppconnect-team/wppconnect/blob/master/Update.md'), "\n"));
133
+ logger_1.defaultLogger.info("For more info visit: ".concat(chalk_1.default.underline('https://github.com/wppconnect-team/wppconnect/blob/master/README.md#update-checking'), "\n"));
134
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.32.0",
3
+ "version": "1.32.2",
4
4
  "description": "WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination... 😀🤔💭",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -64,9 +64,7 @@
64
64
  "@types/atob": "^2.1.4",
65
65
  "@types/mime-types": "^2.1.4",
66
66
  "@types/mocha": "^10.0.6",
67
- "@types/node": "^18.19.34",
68
- "@types/rimraf": "^4.0.5",
69
- "@types/sharp": "^0.32.0",
67
+ "@types/node": "^18.19.36",
70
68
  "@types/shelljs": "^0.8.15",
71
69
  "@types/tmp": "^0.2.6",
72
70
  "@types/ws": "^8.5.10",
@@ -94,8 +92,8 @@
94
92
  "webpack-cli": "^5.1.4"
95
93
  },
96
94
  "dependencies": {
97
- "@wppconnect/wa-js": "^3.3.1",
98
- "@wppconnect/wa-version": "^1.5.0",
95
+ "@wppconnect/wa-js": "^3.3.2",
96
+ "@wppconnect/wa-version": "^1.5.15",
99
97
  "atob": "^2.1.2",
100
98
  "axios": "^1.7.2",
101
99
  "boxen": "^5.1.2",
@@ -109,7 +107,7 @@
109
107
  "logform": "^2.6.0",
110
108
  "lookpath": "^1.2.2",
111
109
  "mime-types": "^2.1.35",
112
- "puppeteer": "^22.11.0",
110
+ "puppeteer": "^22.11.2",
113
111
  "puppeteer-extra": "^3.3.6",
114
112
  "puppeteer-extra-plugin-stealth": "^2.11.2",
115
113
  "puppeteer-extra-plugin-user-data-dir": "^2.4.1",
@@ -122,7 +120,7 @@
122
120
  "tmp": "^0.2.3",
123
121
  "tree-kill": "^1.2.2",
124
122
  "winston": "^3.13.0",
125
- "ws": "^8.17.0"
123
+ "ws": "^8.17.1"
126
124
  },
127
125
  "optionalDependencies": {
128
126
  "@img/sharp-win32-x64": "^0.33.4",