@wppconnect-team/wppconnect 1.14.5 → 1.16.1

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,20 @@
1
+ ## 1.16.1 (2022-08-09)
2
+
3
+
4
+
5
+ # 1.16.0 (2022-08-05)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **deps:** update dependency @wppconnect/wa-js to ^2.10.0 ([dc8133a](https://github.com/wppconnect-team/wppconnect/commit/dc8133a2896c011830c874c94c780acd9368a25a))
11
+
12
+
13
+
14
+ # 1.15.0 (2022-07-20)
15
+
16
+
17
+
1
18
  ## 1.14.5 (2022-07-11)
2
19
 
3
20
 
@@ -152,4 +152,18 @@ export declare class GroupLayer extends RetrieverLayer {
152
152
  * @returns empty object
153
153
  */
154
154
  setGroupProperty(groupId: string, property: GroupProperty, value: boolean): Promise<boolean>;
155
+ /**
156
+ * Set group subject (if allowed)
157
+ * @category Group
158
+ * @param groupId Group ID ('000000-000000@g.us')
159
+ * @param base64 Image in base64 ( data:image/jpeg;base64,..... )
160
+ * @returns empty object
161
+ */
162
+ setGroupIcon(groupId: string, pathOrBase64: string): Promise<{
163
+ eurl: string;
164
+ status: number;
165
+ tag: string;
166
+ token: string;
167
+ _duplicate: boolean;
168
+ }>;
155
169
  }
@@ -386,6 +386,67 @@ var GroupLayer = /** @class */ (function (_super) {
386
386
  });
387
387
  });
388
388
  };
389
+ /**
390
+ * Set group subject (if allowed)
391
+ * @category Group
392
+ * @param groupId Group ID ('000000-000000@g.us')
393
+ * @param base64 Image in base64 ( data:image/jpeg;base64,..... )
394
+ * @returns empty object
395
+ */
396
+ GroupLayer.prototype.setGroupIcon = function (groupId, pathOrBase64) {
397
+ return __awaiter(this, void 0, void 0, function () {
398
+ var base64, fileContent, error, mimeInfo, error;
399
+ return __generator(this, function (_a) {
400
+ switch (_a.label) {
401
+ case 0:
402
+ base64 = '';
403
+ if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
404
+ base64 = pathOrBase64;
405
+ return [3 /*break*/, 5];
406
+ case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64, [
407
+ 'image/gif',
408
+ 'image/png',
409
+ 'image/jpg',
410
+ 'image/jpeg',
411
+ 'image/webp',
412
+ ])];
413
+ case 2:
414
+ fileContent = _a.sent();
415
+ if (!!fileContent) return [3 /*break*/, 4];
416
+ return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
417
+ case 3:
418
+ fileContent = _a.sent();
419
+ _a.label = 4;
420
+ case 4:
421
+ if (fileContent) {
422
+ base64 = fileContent;
423
+ }
424
+ _a.label = 5;
425
+ case 5:
426
+ if (!base64) {
427
+ error = new Error('Empty or invalid file or base64');
428
+ Object.assign(error, {
429
+ code: 'empty_file',
430
+ });
431
+ throw error;
432
+ }
433
+ mimeInfo = (0, helpers_1.base64MimeType)(base64);
434
+ if (!mimeInfo || !mimeInfo.includes('image')) {
435
+ error = new Error('Not an image, allowed formats png, jpeg and webp');
436
+ Object.assign(error, {
437
+ code: 'invalid_image',
438
+ });
439
+ throw error;
440
+ }
441
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
442
+ var groupId = _a.groupId, base64 = _a.base64;
443
+ return WPP.group.setIcon(groupId, base64);
444
+ }, { groupId: groupId, base64: base64 })];
445
+ case 6: return [2 /*return*/, _a.sent()];
446
+ }
447
+ });
448
+ });
449
+ };
389
450
  return GroupLayer;
390
451
  }(retriever_layer_1.RetrieverLayer));
391
452
  exports.GroupLayer = GroupLayer;
@@ -4,7 +4,7 @@ import { SocketState } from '../model/enum';
4
4
  import { ScrapQrcode } from '../model/qrcode';
5
5
  import { LogLevel } from '../../utils/logger';
6
6
  import { Logger } from 'winston';
7
- import { CatchQRCallback, HostDevice, StatusFindCallback } from '../model';
7
+ import { CatchQRCallback, HostDevice, LoadingScreenCallback, StatusFindCallback } from '../model';
8
8
  import { TokenStore } from '../../token-store';
9
9
  export declare class HostLayer {
10
10
  page: Page;
@@ -15,6 +15,7 @@ export declare class HostLayer {
15
15
  protected autoCloseInterval: any;
16
16
  protected autoCloseCalled: boolean;
17
17
  protected statusFind?: StatusFindCallback;
18
+ onLoadingScreen?: LoadingScreenCallback;
18
19
  constructor(page: Page, session?: string, options?: CreateConfig);
19
20
  protected log(level: LogLevel, message: string, meta?: object): void;
20
21
  protected initialize(): Promise<void>;
@@ -77,6 +77,7 @@ var HostLayer = /** @class */ (function () {
77
77
  this.autoCloseInterval = null;
78
78
  this.autoCloseCalled = false;
79
79
  this.statusFind = null;
80
+ this.onLoadingScreen = null;
80
81
  this.session = session;
81
82
  this.options = __assign(__assign({}, create_config_1.defaultOptions), options);
82
83
  this.logger = this.options.logger || logger_1.defaultLogger;
@@ -173,7 +174,7 @@ var HostLayer = /** @class */ (function () {
173
174
  }, options)];
174
175
  case 1:
175
176
  _a.sent();
176
- return [4 /*yield*/, (0, browser_1.injectApi)(this.page)
177
+ return [4 /*yield*/, (0, browser_1.injectApi)(this.page, this.onLoadingScreen)
177
178
  .then(function () {
178
179
  _this.log('verbose', 'wapi.js injected');
179
180
  _this.getWAVersion()
@@ -0,0 +1,63 @@
1
+ import { Page } from 'puppeteer';
2
+ import { CreateConfig } from '../../config/create-config';
3
+ import { HostLayer } from './host.layer';
4
+ export declare class LabelsLayer extends HostLayer {
5
+ page: Page;
6
+ constructor(page: Page, session?: string, options?: CreateConfig);
7
+ /**
8
+ * Create New Label
9
+ *
10
+ * @example
11
+ * ```javascript
12
+ * client.addNewLabel(`Name of label`);
13
+ * //or
14
+ * client.addNewLabel(`Name of label`, { labelColor: '#dfaef0' });
15
+ * //or
16
+ * client.addNewLabel(`Name of label`, { labelColor: 4292849392 });
17
+ * ```
18
+ * @param name Name of label
19
+ * @param options options of label
20
+ */
21
+ addNewLabel(name: string, options?: string): Promise<void>;
22
+ /**
23
+ * Add or delete label of chatId
24
+ *
25
+ * @example
26
+ * ```javascript
27
+ * client.addOrRemoveLabels(['[number]@c.us','[number]@c.us'],
28
+ * [{labelId:'76', type:'add'},{labelId:'75', type:'remove'}]);
29
+ * //or
30
+ * ```
31
+ * @param name Name of label
32
+ * @param options options to remove or add
33
+ */
34
+ addOrRemoveLabels(chatIds: string, options: string): Promise<void>;
35
+ /**
36
+ * Get all Labels
37
+ *
38
+ * @example
39
+ * ```javascript
40
+ * client.getAllLabels();
41
+ * ```
42
+ */
43
+ getAllLabels(): Promise<import("@wppconnect/wa-js/dist/labels").Label[]>;
44
+ /**
45
+ * Delete all Labels
46
+ *
47
+ * @example
48
+ * ```javascript
49
+ * client.deleteAllLabels();
50
+ * ```
51
+ */
52
+ deleteAllLabels(): Promise<void>;
53
+ /**
54
+ * Add or delete label of chatId
55
+ *
56
+ * @example
57
+ * ```javascript
58
+ * client.deleteLabel();
59
+ * ```
60
+ * @param id Id or string to labels to delete
61
+ */
62
+ deleteLabel(id: string | string[]): Promise<void>;
63
+ }
@@ -0,0 +1,191 @@
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
+ var __extends = (this && this.__extends) || (function () {
19
+ var extendStatics = function (d, b) {
20
+ extendStatics = Object.setPrototypeOf ||
21
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
23
+ return extendStatics(d, b);
24
+ };
25
+ return function (d, b) {
26
+ if (typeof b !== "function" && b !== null)
27
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
28
+ extendStatics(d, b);
29
+ function __() { this.constructor = d; }
30
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31
+ };
32
+ })();
33
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
34
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
35
+ return new (P || (P = Promise))(function (resolve, reject) {
36
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
37
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
38
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
40
+ });
41
+ };
42
+ var __generator = (this && this.__generator) || function (thisArg, body) {
43
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
44
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
45
+ function verb(n) { return function (v) { return step([n, v]); }; }
46
+ function step(op) {
47
+ if (f) throw new TypeError("Generator is already executing.");
48
+ while (_) try {
49
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
50
+ if (y = 0, t) op = [op[0] & 2, t.value];
51
+ switch (op[0]) {
52
+ case 0: case 1: t = op; break;
53
+ case 4: _.label++; return { value: op[1], done: false };
54
+ case 5: _.label++; y = op[1]; op = [0]; continue;
55
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
56
+ default:
57
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
58
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
59
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
60
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
61
+ if (t[2]) _.ops.pop();
62
+ _.trys.pop(); continue;
63
+ }
64
+ op = body.call(thisArg, _);
65
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
66
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
67
+ }
68
+ };
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ exports.LabelsLayer = void 0;
71
+ var host_layer_1 = require("./host.layer");
72
+ var helpers_1 = require("../helpers");
73
+ var LabelsLayer = /** @class */ (function (_super) {
74
+ __extends(LabelsLayer, _super);
75
+ function LabelsLayer(page, session, options) {
76
+ var _this = _super.call(this, page, session, options) || this;
77
+ _this.page = page;
78
+ return _this;
79
+ }
80
+ /**
81
+ * Create New Label
82
+ *
83
+ * @example
84
+ * ```javascript
85
+ * client.addNewLabel(`Name of label`);
86
+ * //or
87
+ * client.addNewLabel(`Name of label`, { labelColor: '#dfaef0' });
88
+ * //or
89
+ * client.addNewLabel(`Name of label`, { labelColor: 4292849392 });
90
+ * ```
91
+ * @param name Name of label
92
+ * @param options options of label
93
+ */
94
+ LabelsLayer.prototype.addNewLabel = function (name, options) {
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
99
+ var name = _a.name, options = _a.options;
100
+ WPP.labels.addNewLabel(name, options);
101
+ }, { name: name, options: options })];
102
+ case 1: return [2 /*return*/, _a.sent()];
103
+ }
104
+ });
105
+ });
106
+ };
107
+ /**
108
+ * Add or delete label of chatId
109
+ *
110
+ * @example
111
+ * ```javascript
112
+ * client.addOrRemoveLabels(['[number]@c.us','[number]@c.us'],
113
+ * [{labelId:'76', type:'add'},{labelId:'75', type:'remove'}]);
114
+ * //or
115
+ * ```
116
+ * @param name Name of label
117
+ * @param options options to remove or add
118
+ */
119
+ LabelsLayer.prototype.addOrRemoveLabels = function (chatIds, options) {
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
124
+ var chatIds = _a.chatIds, options = _a.options;
125
+ WPP.labels.addOrRemoveLabels(chatIds, options);
126
+ }, { chatIds: chatIds, options: options })];
127
+ case 1: return [2 /*return*/, _a.sent()];
128
+ }
129
+ });
130
+ });
131
+ };
132
+ /**
133
+ * Get all Labels
134
+ *
135
+ * @example
136
+ * ```javascript
137
+ * client.getAllLabels();
138
+ * ```
139
+ */
140
+ LabelsLayer.prototype.getAllLabels = function () {
141
+ return __awaiter(this, void 0, void 0, function () {
142
+ return __generator(this, function (_a) {
143
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function () { return WPP.labels.getAllLabels(); })];
144
+ });
145
+ });
146
+ };
147
+ /**
148
+ * Delete all Labels
149
+ *
150
+ * @example
151
+ * ```javascript
152
+ * client.deleteAllLabels();
153
+ * ```
154
+ */
155
+ LabelsLayer.prototype.deleteAllLabels = function () {
156
+ return __awaiter(this, void 0, void 0, function () {
157
+ return __generator(this, function (_a) {
158
+ switch (_a.label) {
159
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
160
+ WPP.labels.deleteAllLabels();
161
+ })];
162
+ case 1: return [2 /*return*/, _a.sent()];
163
+ }
164
+ });
165
+ });
166
+ };
167
+ /**
168
+ * Add or delete label of chatId
169
+ *
170
+ * @example
171
+ * ```javascript
172
+ * client.deleteLabel();
173
+ * ```
174
+ * @param id Id or string to labels to delete
175
+ */
176
+ LabelsLayer.prototype.deleteLabel = function (id) {
177
+ return __awaiter(this, void 0, void 0, function () {
178
+ return __generator(this, function (_a) {
179
+ switch (_a.label) {
180
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
181
+ var id = _a.id;
182
+ WPP.labels.deleteLabel(id);
183
+ }, { id: id })];
184
+ case 1: return [2 /*return*/, _a.sent()];
185
+ }
186
+ });
187
+ });
188
+ };
189
+ return LabelsLayer;
190
+ }(host_layer_1.HostLayer));
191
+ exports.LabelsLayer = LabelsLayer;
@@ -109,7 +109,7 @@ export declare class ListenerLayer extends ProfileLayer {
109
109
  * @param to callback
110
110
  * @returns Stream of ParticipantEvent
111
111
  */
112
- onParticipantsChanged(callback: (participantChangedEvent: ParticipantEvent) => void): {
112
+ onParticipantsChanged(callback: (evData: ParticipantEvent) => void): {
113
113
  dispose: () => void;
114
114
  };
115
115
  /**
@@ -118,7 +118,7 @@ export declare class ListenerLayer extends ProfileLayer {
118
118
  * @param to callback
119
119
  * @returns Stream of ParticipantEvent
120
120
  */
121
- onParticipantsChanged(groupId: string, callback: (participantChangedEvent: ParticipantEvent) => void): {
121
+ onParticipantsChanged(groupId: string, callback: (evData: ParticipantEvent) => void): {
122
122
  dispose: () => void;
123
123
  };
124
124
  /**
@@ -197,4 +197,19 @@ export declare class ListenerLayer extends ProfileLayer {
197
197
  }) => any): {
198
198
  dispose: () => void;
199
199
  };
200
+ /**
201
+ * @event Listens to reaction messages
202
+ * @returns Disposable object to stop the listening
203
+ */
204
+ onReactionMessage(callback: (data: {
205
+ id: string;
206
+ msgId: string;
207
+ reactionText: string;
208
+ read: boolean;
209
+ orphan: number;
210
+ orphanReason: any;
211
+ timestamp: number;
212
+ }) => any): {
213
+ dispose: () => void;
214
+ };
200
215
  }
@@ -80,7 +80,6 @@ exports.ListenerLayer = void 0;
80
80
  var events_1 = require("events");
81
81
  var helpers_1 = require("../helpers");
82
82
  var exposed_enum_1 = require("../helpers/exposed.enum");
83
- var enum_1 = require("../model/enum");
84
83
  var profile_layer_1 = require("./profile.layer");
85
84
  var ListenerLayer = /** @class */ (function (_super) {
86
85
  __extends(ListenerLayer, _super);
@@ -123,6 +122,7 @@ var ListenerLayer = /** @class */ (function (_super) {
123
122
  'onAddedToGroup',
124
123
  'onIncomingCall',
125
124
  'onRevokedMessage',
125
+ 'onReactionMessage',
126
126
  ], false);
127
127
  _loop_1 = function (func) {
128
128
  var has;
@@ -297,6 +297,37 @@ var ListenerLayer = /** @class */ (function (_super) {
297
297
  catch (error) {
298
298
  console.error(error);
299
299
  }
300
+ try {
301
+ if (!window['onReactionMessage'].exposed) {
302
+ WPP.on('chat.new_reaction', function (data) {
303
+ var eventData = {
304
+ id: data.id,
305
+ msgId: data.msgId,
306
+ reactionText: data.reactionText,
307
+ read: data.read,
308
+ orphan: data.orphan,
309
+ orphanReason: data.orphanReason,
310
+ timestamp: data.timestamp,
311
+ };
312
+ window['onReactionMessage'](eventData);
313
+ });
314
+ window['onReactionMessage'].exposed = true;
315
+ }
316
+ }
317
+ catch (error) {
318
+ console.error(error);
319
+ }
320
+ try {
321
+ if (!window['onParticipantsChanged'].exposed) {
322
+ WPP.on('group.participant_changed', function (participantChangedEvent) {
323
+ window['onParticipantsChanged'](participantChangedEvent);
324
+ });
325
+ window['onParticipantsChanged'].exposed = true;
326
+ }
327
+ }
328
+ catch (error) {
329
+ console.error(error);
330
+ }
300
331
  })
301
332
  .catch(function () { })];
302
333
  case 6:
@@ -398,21 +429,17 @@ var ListenerLayer = /** @class */ (function (_super) {
398
429
  callback = groupId;
399
430
  groupId = null;
400
431
  }
401
- var subtypeEvents = ['invite', 'add', 'remove', 'leave'];
402
- return this.registerEvent(exposed_enum_1.ExposedFn.onNotificationMessage, function (message) {
403
- // Only group events
404
- if (message.type !== enum_1.MessageType.GP2 ||
405
- !subtypeEvents.includes(message.subtype)) {
406
- return;
407
- }
408
- if (groupId && groupId !== message.id) {
432
+ return this.registerEvent(exposed_enum_1.ExposedFn.onParticipantsChanged, function (evData) {
433
+ if (groupId && groupId !== evData.groupId) {
409
434
  return;
410
435
  }
411
436
  callback({
412
- by: message.from,
413
- groupId: message.chatId,
414
- action: message.subtype,
415
- who: message.recipients,
437
+ by: evData.author,
438
+ byPushName: evData.authorPushName,
439
+ groupId: evData.groupId,
440
+ action: evData.action,
441
+ operation: evData.operation,
442
+ who: evData.participants,
416
443
  });
417
444
  });
418
445
  };
@@ -507,6 +534,13 @@ var ListenerLayer = /** @class */ (function (_super) {
507
534
  ListenerLayer.prototype.onRevokedMessage = function (callback) {
508
535
  return this.registerEvent('onRevokedMessage', callback);
509
536
  };
537
+ /**
538
+ * @event Listens to reaction messages
539
+ * @returns Disposable object to stop the listening
540
+ */
541
+ ListenerLayer.prototype.onReactionMessage = function (callback) {
542
+ return this.registerEvent('onReactionMessage', callback);
543
+ };
510
544
  return ListenerLayer;
511
545
  }(profile_layer_1.ProfileLayer));
512
546
  exports.ListenerLayer = ListenerLayer;
@@ -1,7 +1,7 @@
1
1
  import { Page } from 'puppeteer';
2
- import { HostLayer } from './host.layer';
3
2
  import { CreateConfig } from '../../config/create-config';
4
- export declare class ProfileLayer extends HostLayer {
3
+ import { StatusLayer } from './status.layer';
4
+ export declare class ProfileLayer extends StatusLayer {
5
5
  page: Page;
6
6
  constructor(page: Page, session?: string, options?: CreateConfig);
7
7
  /**
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
68
68
  };
69
69
  Object.defineProperty(exports, "__esModule", { value: true });
70
70
  exports.ProfileLayer = void 0;
71
- var host_layer_1 = require("./host.layer");
72
71
  var helpers_1 = require("../helpers");
72
+ var status_layer_1 = require("./status.layer");
73
73
  var ProfileLayer = /** @class */ (function (_super) {
74
74
  __extends(ProfileLayer, _super);
75
75
  function ProfileLayer(page, session, options) {
@@ -212,5 +212,5 @@ var ProfileLayer = /** @class */ (function (_super) {
212
212
  });
213
213
  };
214
214
  return ProfileLayer;
215
- }(host_layer_1.HostLayer));
215
+ }(status_layer_1.StatusLayer));
216
216
  exports.ProfileLayer = ProfileLayer;
@@ -428,4 +428,21 @@ export declare class SenderLayer extends ListenerLayer {
428
428
  * @deprecated Deprecated in favor of Use startTyping or startRecording functions
429
429
  */
430
430
  setChatState(chatId: string, chatState: ChatState): Promise<void>;
431
+ /**
432
+ * Send reaction to message
433
+ * @example
434
+ * ```javascript
435
+ * // For send Reaction, just to send emoji
436
+ * await client.sendReactionToMessage('[number]@c.us', '🤯');
437
+ *
438
+ * // to remove reacition
439
+ * await client.startRecording('[number]@c.us', false);
440
+ * ```
441
+ * @category Chat
442
+ * @param to Chat Id
443
+ * @param duration Duration um miliseconds
444
+ */
445
+ sendReactionToMessage(msgId: string, reaction: string | false): Promise<{
446
+ sendMsgResult: string;
447
+ }>;
431
448
  }
@@ -1264,6 +1264,33 @@ var SenderLayer = /** @class */ (function (_super) {
1264
1264
  });
1265
1265
  });
1266
1266
  };
1267
+ /**
1268
+ * Send reaction to message
1269
+ * @example
1270
+ * ```javascript
1271
+ * // For send Reaction, just to send emoji
1272
+ * await client.sendReactionToMessage('[number]@c.us', '🤯');
1273
+ *
1274
+ * // to remove reacition
1275
+ * await client.startRecording('[number]@c.us', false);
1276
+ * ```
1277
+ * @category Chat
1278
+ * @param to Chat Id
1279
+ * @param duration Duration um miliseconds
1280
+ */
1281
+ SenderLayer.prototype.sendReactionToMessage = function (msgId, reaction) {
1282
+ return __awaiter(this, void 0, void 0, function () {
1283
+ return __generator(this, function (_a) {
1284
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1285
+ var msgId = _a.msgId, reaction = _a.reaction;
1286
+ return WPP.chat.sendReactionToMessage(msgId, reaction);
1287
+ }, {
1288
+ msgId: msgId,
1289
+ reaction: reaction,
1290
+ })];
1291
+ });
1292
+ });
1293
+ };
1267
1294
  return SenderLayer;
1268
1295
  }(listener_layer_1.ListenerLayer));
1269
1296
  exports.SenderLayer = SenderLayer;
@@ -0,0 +1,37 @@
1
+ import { Page } from 'puppeteer';
2
+ import { CreateConfig } from '../../config/create-config';
3
+ import { LabelsLayer } from './labels.layer';
4
+ export declare class StatusLayer extends LabelsLayer {
5
+ page: Page;
6
+ constructor(page: Page, session?: string, options?: CreateConfig);
7
+ /**
8
+ * Send a image message to status stories
9
+ *
10
+ * @example
11
+ * ```javascript
12
+ * client.sendImageStatus('data:image/jpeg;base64,<a long base64 file...>');
13
+ * ```
14
+ * @param pathOrBase64 Path or base 64 image
15
+ */
16
+ sendImageStatus(pathOrBase64: string): Promise<void>;
17
+ /**
18
+ * Send a video message to status stories
19
+ *
20
+ * @example
21
+ * ```javascript
22
+ * client.sendVideoStatus('data:video/mp4;base64,<a long base64 file...>');
23
+ * ```
24
+ * @param pathOrBase64 Path or base 64 image
25
+ */
26
+ sendVideoStatus(pathOrBase64: string): Promise<void>;
27
+ /**
28
+ * Send a text to status stories
29
+ *
30
+ * @example
31
+ * ```javascript
32
+ * client.sendTextStatus(`Bootstrap primary color: #0275d8`, { backgroundColor: '#0275d8', font: 2});
33
+ * ```
34
+ * @param pathOrBase64 Path or base 64 image
35
+ */
36
+ sendTextStatus(text: string, options: string): Promise<void>;
37
+ }
@@ -0,0 +1,216 @@
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
+ var __extends = (this && this.__extends) || (function () {
19
+ var extendStatics = function (d, b) {
20
+ extendStatics = Object.setPrototypeOf ||
21
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
23
+ return extendStatics(d, b);
24
+ };
25
+ return function (d, b) {
26
+ if (typeof b !== "function" && b !== null)
27
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
28
+ extendStatics(d, b);
29
+ function __() { this.constructor = d; }
30
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31
+ };
32
+ })();
33
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
34
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
35
+ return new (P || (P = Promise))(function (resolve, reject) {
36
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
37
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
38
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
40
+ });
41
+ };
42
+ var __generator = (this && this.__generator) || function (thisArg, body) {
43
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
44
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
45
+ function verb(n) { return function (v) { return step([n, v]); }; }
46
+ function step(op) {
47
+ if (f) throw new TypeError("Generator is already executing.");
48
+ while (_) try {
49
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
50
+ if (y = 0, t) op = [op[0] & 2, t.value];
51
+ switch (op[0]) {
52
+ case 0: case 1: t = op; break;
53
+ case 4: _.label++; return { value: op[1], done: false };
54
+ case 5: _.label++; y = op[1]; op = [0]; continue;
55
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
56
+ default:
57
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
58
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
59
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
60
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
61
+ if (t[2]) _.ops.pop();
62
+ _.trys.pop(); continue;
63
+ }
64
+ op = body.call(thisArg, _);
65
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
66
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
67
+ }
68
+ };
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ exports.StatusLayer = void 0;
71
+ var labels_layer_1 = require("./labels.layer");
72
+ var helpers_1 = require("../helpers");
73
+ var StatusLayer = /** @class */ (function (_super) {
74
+ __extends(StatusLayer, _super);
75
+ function StatusLayer(page, session, options) {
76
+ var _this = _super.call(this, page, session, options) || this;
77
+ _this.page = page;
78
+ return _this;
79
+ }
80
+ /**
81
+ * Send a image message to status stories
82
+ *
83
+ * @example
84
+ * ```javascript
85
+ * client.sendImageStatus('data:image/jpeg;base64,<a long base64 file...>');
86
+ * ```
87
+ * @param pathOrBase64 Path or base 64 image
88
+ */
89
+ StatusLayer.prototype.sendImageStatus = function (pathOrBase64) {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ var base64, fileContent, error, mimeInfo, error;
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0:
95
+ base64 = '';
96
+ if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
97
+ base64 = pathOrBase64;
98
+ return [3 /*break*/, 5];
99
+ case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64, [
100
+ 'image/gif',
101
+ 'image/png',
102
+ 'image/jpg',
103
+ 'image/jpeg',
104
+ 'image/webp',
105
+ ])];
106
+ case 2:
107
+ fileContent = _a.sent();
108
+ if (!!fileContent) return [3 /*break*/, 4];
109
+ return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
110
+ case 3:
111
+ fileContent = _a.sent();
112
+ _a.label = 4;
113
+ case 4:
114
+ if (fileContent) {
115
+ base64 = fileContent;
116
+ }
117
+ _a.label = 5;
118
+ case 5:
119
+ if (!base64) {
120
+ error = new Error('Empty or invalid file or base64');
121
+ Object.assign(error, {
122
+ code: 'empty_file',
123
+ });
124
+ throw error;
125
+ }
126
+ mimeInfo = (0, helpers_1.base64MimeType)(base64);
127
+ if (!mimeInfo || !mimeInfo.includes('image')) {
128
+ error = new Error('Not an image, allowed formats png, jpeg and webp');
129
+ Object.assign(error, {
130
+ code: 'invalid_image',
131
+ });
132
+ throw error;
133
+ }
134
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
135
+ var base64 = _a.base64;
136
+ WPP.status.sendImageStatus(base64);
137
+ }, { base64: base64 })];
138
+ case 6: return [2 /*return*/, _a.sent()];
139
+ }
140
+ });
141
+ });
142
+ };
143
+ /**
144
+ * Send a video message to status stories
145
+ *
146
+ * @example
147
+ * ```javascript
148
+ * client.sendVideoStatus('data:video/mp4;base64,<a long base64 file...>');
149
+ * ```
150
+ * @param pathOrBase64 Path or base 64 image
151
+ */
152
+ StatusLayer.prototype.sendVideoStatus = function (pathOrBase64) {
153
+ return __awaiter(this, void 0, void 0, function () {
154
+ var base64, fileContent, error;
155
+ return __generator(this, function (_a) {
156
+ switch (_a.label) {
157
+ case 0:
158
+ base64 = '';
159
+ if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
160
+ base64 = pathOrBase64;
161
+ return [3 /*break*/, 5];
162
+ case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64)];
163
+ case 2:
164
+ fileContent = _a.sent();
165
+ if (!!fileContent) return [3 /*break*/, 4];
166
+ return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
167
+ case 3:
168
+ fileContent = _a.sent();
169
+ _a.label = 4;
170
+ case 4:
171
+ if (fileContent) {
172
+ base64 = fileContent;
173
+ }
174
+ _a.label = 5;
175
+ case 5:
176
+ if (!base64) {
177
+ error = new Error('Empty or invalid file or base64');
178
+ Object.assign(error, {
179
+ code: 'empty_file',
180
+ });
181
+ throw error;
182
+ }
183
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
184
+ var base64 = _a.base64;
185
+ WPP.status.sendVideoStatus(base64);
186
+ }, { base64: base64 })];
187
+ case 6: return [2 /*return*/, _a.sent()];
188
+ }
189
+ });
190
+ });
191
+ };
192
+ /**
193
+ * Send a text to status stories
194
+ *
195
+ * @example
196
+ * ```javascript
197
+ * client.sendTextStatus(`Bootstrap primary color: #0275d8`, { backgroundColor: '#0275d8', font: 2});
198
+ * ```
199
+ * @param pathOrBase64 Path or base 64 image
200
+ */
201
+ StatusLayer.prototype.sendTextStatus = function (text, options) {
202
+ return __awaiter(this, void 0, void 0, function () {
203
+ return __generator(this, function (_a) {
204
+ switch (_a.label) {
205
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
206
+ var text = _a.text, options = _a.options;
207
+ WPP.status.sendTextStatus(text, options);
208
+ }, { text: text, options: options })];
209
+ case 1: return [2 /*return*/, _a.sent()];
210
+ }
211
+ });
212
+ });
213
+ };
214
+ return StatusLayer;
215
+ }(labels_layer_1.LabelsLayer));
216
+ exports.StatusLayer = StatusLayer;
@@ -1,6 +1,5 @@
1
1
  export { AckType } from './ack-type';
2
2
  export { ChatState } from './chat-state';
3
- export { GroupChangeEvent } from './group-change-event';
4
3
  export { GroupNotificationType } from './group-notification-type';
5
4
  export { SocketState, SocketStream } from './socket-state';
6
5
  export { MessageType, MediaType } from './message-type';
@@ -30,13 +30,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
30
30
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.MediaType = exports.MessageType = exports.SocketStream = exports.SocketState = exports.GroupNotificationType = exports.GroupChangeEvent = exports.ChatState = exports.AckType = void 0;
33
+ exports.MediaType = exports.MessageType = exports.SocketStream = exports.SocketState = exports.GroupNotificationType = exports.ChatState = exports.AckType = void 0;
34
34
  var ack_type_1 = require("./ack-type");
35
35
  Object.defineProperty(exports, "AckType", { enumerable: true, get: function () { return ack_type_1.AckType; } });
36
36
  var chat_state_1 = require("./chat-state");
37
37
  Object.defineProperty(exports, "ChatState", { enumerable: true, get: function () { return chat_state_1.ChatState; } });
38
- var group_change_event_1 = require("./group-change-event");
39
- Object.defineProperty(exports, "GroupChangeEvent", { enumerable: true, get: function () { return group_change_event_1.GroupChangeEvent; } });
40
38
  var group_notification_type_1 = require("./group-notification-type");
41
39
  Object.defineProperty(exports, "GroupNotificationType", { enumerable: true, get: function () { return group_notification_type_1.GroupNotificationType; } });
42
40
  var socket_state_1 = require("./socket-state");
@@ -9,6 +9,10 @@ export declare type CatchQRCallback = (qrCode: string, asciiQR: string, attempt:
9
9
  * A callback will be received, informing the customer's status
10
10
  */
11
11
  export declare type StatusFindCallback = (status: StatusFind | keyof typeof StatusFind, session: string) => void;
12
+ /**
13
+ * A callback will be received, informing data as percentage and loading screen message
14
+ */
15
+ export declare type LoadingScreenCallback = (percent: number, message: string) => void;
12
16
  export interface CreateOptions extends CreateConfig {
13
17
  /**
14
18
  * You must pass a string type parameter, this parameter will be the name of the client's session. If the parameter is not passed, the section name will be "session".
@@ -22,6 +26,10 @@ export interface CreateOptions extends CreateConfig {
22
26
  * A callback will be received, informing the customer's status
23
27
  */
24
28
  statusFind?: StatusFindCallback;
29
+ /**
30
+ * A callback will be received, informing data as percentage and loading screen message
31
+ */
32
+ onLoadingScreen?: LoadingScreenCallback;
25
33
  /**
26
34
  * Pass the session token information you can receive this token with the await client.getSessionTokenBrowser () function
27
35
  * @deprecated in favor of `sessionToken`
@@ -1,7 +1,8 @@
1
- import { GroupChangeEvent } from './enum';
2
1
  export interface ParticipantEvent {
3
- by: string;
2
+ by?: string;
3
+ byPushName?: string;
4
4
  groupId: string;
5
- action: GroupChangeEvent;
5
+ action: 'add' | 'remove' | 'demote' | 'promote' | 'leaver' | 'join';
6
+ operation: 'add' | 'remove' | 'demote' | 'promote';
6
7
  who: string[];
7
8
  }
@@ -2,6 +2,7 @@ import { Browser, BrowserContext, Page } from 'puppeteer';
2
2
  import { CreateConfig } from '../config/create-config';
3
3
  import { Logger } from 'winston';
4
4
  import { SessionToken } from '../token-store';
5
+ import { LoadingScreenCallback } from '../api/model';
5
6
  export declare function unregisterServiceWorker(page: Page): Promise<void>;
6
7
  /**
7
8
  * Força o carregamento de uma versão específica do WhatsApp WEB
@@ -10,7 +11,8 @@ export declare function unregisterServiceWorker(page: Page): Promise<void>;
10
11
  */
11
12
  export declare function setWhatsappVersion(page: Page, version: string): Promise<void>;
12
13
  export declare function initWhatsapp(page: Page, token?: SessionToken, clear?: boolean, version?: string): Promise<Page>;
13
- export declare function injectApi(page: Page): Promise<boolean | import("puppeteer").JSHandle<unknown>>;
14
+ export declare function onLoadingScreen(page: Page, onLoadingScreenCallBack?: LoadingScreenCallback): Promise<void>;
15
+ export declare function injectApi(page: Page, onLoadingScreenCallBack?: LoadingScreenCallback): Promise<boolean | import("puppeteer").JSHandle<unknown>>;
14
16
  /**
15
17
  * Initializes browser, will try to use chrome as default
16
18
  * @param session
@@ -98,7 +98,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
98
98
  return (mod && mod.__esModule) ? mod : { "default": mod };
99
99
  };
100
100
  Object.defineProperty(exports, "__esModule", { value: true });
101
- exports.getOrCreatePage = exports.initBrowser = exports.injectApi = exports.initWhatsapp = exports.setWhatsappVersion = exports.unregisterServiceWorker = void 0;
101
+ exports.getOrCreatePage = exports.initBrowser = exports.injectApi = exports.onLoadingScreen = exports.initWhatsapp = exports.setWhatsappVersion = exports.unregisterServiceWorker = void 0;
102
102
  var ChromeLauncher = __importStar(require("chrome-launcher"));
103
103
  var os = __importStar(require("os"));
104
104
  var path = __importStar(require("path"));
@@ -211,7 +211,61 @@ function initWhatsapp(page, token, clear, version) {
211
211
  });
212
212
  }
213
213
  exports.initWhatsapp = initWhatsapp;
214
- function injectApi(page) {
214
+ var lastPercent = null;
215
+ var lastPercentMessage = null;
216
+ function onLoadingScreen(page, onLoadingScreenCallBack) {
217
+ return __awaiter(this, void 0, void 0, function () {
218
+ var _this = this;
219
+ return __generator(this, function (_a) {
220
+ switch (_a.label) {
221
+ case 0: return [4 /*yield*/, page.evaluate("function getElementByXpath(path) {\n return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;\n }")];
222
+ case 1:
223
+ _a.sent();
224
+ return [4 /*yield*/, page.exposeFunction('loadingScreen', function (percent, message) { return __awaiter(_this, void 0, void 0, function () {
225
+ return __generator(this, function (_a) {
226
+ if (lastPercent !== percent || lastPercentMessage !== message) {
227
+ onLoadingScreenCallBack && onLoadingScreenCallBack(percent, message);
228
+ lastPercent = percent;
229
+ lastPercentMessage = message;
230
+ }
231
+ return [2 /*return*/];
232
+ });
233
+ }); })];
234
+ case 2:
235
+ _a.sent();
236
+ return [4 /*yield*/, page.evaluate(function (selectors) {
237
+ var observer = new MutationObserver(function () {
238
+ var window2 = window;
239
+ var progressBar = window2.getElementByXpath(selectors.PROGRESS);
240
+ var progressMessage = window2.getElementByXpath(selectors.PROGRESS_MESSAGE);
241
+ if (progressBar) {
242
+ if (this.lastPercent !== progressBar.value ||
243
+ this.lastPercentMessage !== progressMessage.innerText) {
244
+ window2.loadingScreen(progressBar.value, progressMessage.innerText);
245
+ this.lastPercent = progressBar.value;
246
+ this.lastPercentMessage = progressMessage.innerText;
247
+ }
248
+ }
249
+ });
250
+ observer.observe(document, {
251
+ attributes: true,
252
+ childList: true,
253
+ characterData: true,
254
+ subtree: true,
255
+ });
256
+ }, {
257
+ PROGRESS: "//*[@id='app']/div/div/div[2]/progress",
258
+ PROGRESS_MESSAGE: "//*[@id='app']/div/div/div[3]",
259
+ })];
260
+ case 3:
261
+ _a.sent();
262
+ return [2 /*return*/];
263
+ }
264
+ });
265
+ });
266
+ }
267
+ exports.onLoadingScreen = onLoadingScreen;
268
+ function injectApi(page, onLoadingScreenCallBack) {
215
269
  return __awaiter(this, void 0, void 0, function () {
216
270
  var injected;
217
271
  return __generator(this, function (_a) {
@@ -254,6 +308,9 @@ function injectApi(page) {
254
308
  path: require.resolve(path.join(__dirname, '../../dist/lib/wapi', 'wapi.js')),
255
309
  })];
256
310
  case 5:
311
+ _a.sent();
312
+ return [4 /*yield*/, onLoadingScreen(page, onLoadingScreenCallBack)];
313
+ case 6:
257
314
  _a.sent();
258
315
  return [4 /*yield*/, page
259
316
  .waitForFunction(function () {
@@ -261,7 +318,7 @@ function injectApi(page) {
261
318
  typeof window.Store !== 'undefined');
262
319
  })
263
320
  .catch(function () { return false; })];
264
- case 6:
321
+ case 7:
265
322
  // Make sure WAPI is initialized
266
323
  return [2 /*return*/, _a.sent()];
267
324
  }
@@ -1,6 +1,6 @@
1
1
  import { Whatsapp } from '../api/whatsapp';
2
2
  import { CreateConfig } from '../config/create-config';
3
- import { CatchQRCallback, CreateOptions, StatusFindCallback } from '../api/model/initializer';
3
+ import { CatchQRCallback, CreateOptions, LoadingScreenCallback, StatusFindCallback } from '../api/model/initializer';
4
4
  import { SessionToken } from '../token-store';
5
5
  /**
6
6
  * Start the bot
@@ -13,4 +13,4 @@ export declare function create(createOption: CreateOptions): Promise<Whatsapp>;
13
13
  * @returns Whatsapp page, with this parameter you will be able to access the bot functions
14
14
  * @deprecated Deprecated in favor of create with {@link CreateOptions} (e.g., wppconnect.create({session: 'test'})).
15
15
  */
16
- export declare function create(sessionName: string, catchQR?: CatchQRCallback, statusFind?: StatusFindCallback, options?: CreateConfig, browserSessionToken?: SessionToken): Promise<Whatsapp>;
16
+ export declare function create(sessionName: string, catchQR?: CatchQRCallback, statusFind?: StatusFindCallback, onLoadingScreen?: LoadingScreenCallback, options?: CreateConfig, browserSessionToken?: SessionToken): Promise<Whatsapp>;
@@ -114,7 +114,7 @@ process.on('unhandledRejection', function (reason, promise) {
114
114
  }
115
115
  logger_1.defaultLogger.error(message);
116
116
  });
117
- function create(sessionOrOption, catchQR, statusFind, options, browserSessionToken) {
117
+ function create(sessionOrOption, catchQR, statusFind, onLoadingScreen, options, browserSessionToken) {
118
118
  var _a;
119
119
  return __awaiter(this, void 0, void 0, function () {
120
120
  var session, usingDeprecatedCreate, mergedOptions, logger, browser, page, client_1, isLogged, waitLoginPromise_1;
@@ -139,6 +139,7 @@ function create(sessionOrOption, catchQR, statusFind, options, browserSessionTok
139
139
  session = sessionOrOption.session;
140
140
  catchQR = sessionOrOption.catchQR || catchQR;
141
141
  statusFind = sessionOrOption.statusFind || statusFind;
142
+ onLoadingScreen = sessionOrOption.onLoadingScreen || onLoadingScreen;
142
143
  if (!options.sessionToken) {
143
144
  options.sessionToken =
144
145
  sessionOrOption.browserSessionToken || browserSessionToken;
@@ -263,6 +264,7 @@ function create(sessionOrOption, catchQR, statusFind, options, browserSessionTok
263
264
  case 7:
264
265
  if (!page) return [3 /*break*/, 10];
265
266
  client_1 = new whatsapp_1.Whatsapp(page, session, mergedOptions);
267
+ client_1.onLoadingScreen = onLoadingScreen;
266
268
  if (!mergedOptions.waitForLogin) return [3 /*break*/, 9];
267
269
  return [4 /*yield*/, client_1.waitForLogin(catchQR, statusFind)];
268
270
  case 8:
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.14.5",
3
+ "version": "1.16.1",
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",
7
7
  "scripts": {
8
- "build:docs": "typedoc && git add docs/*",
9
8
  "build:client": "tsc",
10
9
  "build:wapi": "cd src/lib/wapi/ && webpack",
11
10
  "build": "npm run build:wapi && npm run build:client",
@@ -14,12 +13,9 @@
14
13
  "changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s",
15
14
  "clean": "shx rm -rf session dist",
16
15
  "commit": "cz",
17
- "docs:build": "npm run docs:clean && npm run docs:fix && typedoc && npm run docs:copy-images",
16
+ "docs:build": "npm run docs:clean && typedoc && npm run docs:copy-images",
18
17
  "docs:clean": "shx rm -rf api-docs",
19
18
  "docs:copy-images": "shx cp -R ./img ./api-docs",
20
- "docs:fix": "ts-node ./docs/layouts/fix-docs.ts",
21
- "license:add": "license-check-and-add add",
22
- "license:check": "license-check-and-add check",
23
19
  "lint:js": "npx eslint -c .eslintrc.js --ext .js src",
24
20
  "lint:ts": "npx eslint -c .eslintrc.js --ext .ts src",
25
21
  "lint": "npm run lint:ts && npm run lint:js",
@@ -58,51 +54,49 @@
58
54
  },
59
55
  "homepage": "https://github.com/wppconnect-team/wppconnect#readme",
60
56
  "devDependencies": {
61
- "@babel/core": "^7.18.6",
62
- "@babel/eslint-parser": "^7.18.2",
63
- "@babel/eslint-plugin": "^7.17.7",
64
- "@babel/preset-env": "^7.18.6",
57
+ "@babel/core": "^7.18.10",
58
+ "@babel/eslint-parser": "^7.18.9",
59
+ "@babel/eslint-plugin": "^7.18.10",
60
+ "@babel/preset-env": "^7.18.10",
65
61
  "@commitlint/cli": "^17.0.3",
66
62
  "@commitlint/config-conventional": "^17.0.3",
67
63
  "@commitlint/cz-commitlint": "^17.0.3",
64
+ "@knodes/typedoc-plugin-pages": "^0.23.1",
68
65
  "@types/atob": "^2.1.2",
69
66
  "@types/mime-types": "^2.1.1",
70
67
  "@types/mocha": "^9.1.1",
71
- "@types/node": "^16.11.43",
68
+ "@types/node": "^16.11.47",
72
69
  "@types/rimraf": "^3.0.2",
73
70
  "@types/sharp": "^0.30.4",
74
71
  "@types/shelljs": "^0.8.11",
75
72
  "@types/tmp": "^0.2.3",
76
73
  "@types/ws": "^8.5.3",
77
- "@typescript-eslint/eslint-plugin": "^5.29.0",
78
- "@typescript-eslint/parser": "^5.29.0",
74
+ "@typescript-eslint/eslint-plugin": "^5.32.0",
75
+ "@typescript-eslint/parser": "^5.32.0",
79
76
  "babel-loader": "^8.2.5",
80
- "commitizen": "^4.2.4",
81
- "concurrently": "^7.2.2",
77
+ "commitizen": "^4.2.5",
78
+ "concurrently": "^7.3.0",
82
79
  "conventional-changelog-cli": "^2.2.2",
83
- "copy-webpack-plugin": "^11.0.0",
84
- "eslint": "^8.18.0",
80
+ "eslint": "^8.21.0",
85
81
  "eslint-config-prettier": "^8.5.0",
86
- "eslint-plugin-prettier": "^4.0.0",
87
- "gulp": "^4.0.2",
82
+ "eslint-plugin-header": "^3.1.1",
83
+ "eslint-plugin-prettier": "^4.2.1",
88
84
  "husky": "^8.0.1",
89
- "license-check-and-add": "^4.0.5",
90
85
  "mocha": "^10.0.0",
91
86
  "prettier": "^2.7.1",
92
87
  "pretty-quick": "^3.1.3",
93
88
  "regenerator-runtime": "^0.13.9",
94
- "release-it": "^15.1.1",
89
+ "release-it": "^15.2.0",
95
90
  "shx": "^0.3.4",
96
- "ts-node": "^10.8.2",
97
- "typedoc": "^0.21.10",
98
- "typedoc-plugin-pages": "^1.1.0",
91
+ "ts-node": "^10.9.1",
92
+ "typedoc": "^0.23.10",
99
93
  "typescript": "^4.7.4",
100
- "webpack": "^5.73.0",
94
+ "webpack": "^5.74.0",
101
95
  "webpack-cli": "^4.10.0"
102
96
  },
103
97
  "dependencies": {
104
- "@wppconnect/wa-js": "^2.8.1",
105
- "@wppconnect/wa-version": "^1.1.104",
98
+ "@wppconnect/wa-js": "^2.10.1",
99
+ "@wppconnect/wa-version": "^1.1.123",
106
100
  "atob": "^2.1.2",
107
101
  "axios": "^0.27.2",
108
102
  "boxen": "^5.1.2",
@@ -110,7 +104,7 @@
110
104
  "chalk": "~4.1.2",
111
105
  "chrome-launcher": "^0.15.1",
112
106
  "execa": "^5.1.1",
113
- "file-type": "~16.5.3",
107
+ "file-type": "~16.5.4",
114
108
  "futoin-hkdf": "^1.5.1",
115
109
  "latest-version": "^5.1.0",
116
110
  "logform": "^2.4.2",
@@ -118,9 +112,9 @@
118
112
  "mime-types": "^2.1.35",
119
113
  "puppeteer": "*",
120
114
  "puppeteer-extra": "^3.3.4",
121
- "puppeteer-extra-plugin-stealth": "^2.10.1",
122
- "puppeteer-extra-plugin-user-data-dir": "^2.3.1",
123
- "puppeteer-extra-plugin-user-preferences": "^2.3.1",
115
+ "puppeteer-extra-plugin-stealth": "^2.11.0",
116
+ "puppeteer-extra-plugin-user-data-dir": "^2.4.0",
117
+ "puppeteer-extra-plugin-user-preferences": "^2.4.0",
124
118
  "qrcode-terminal": "^0.12.0",
125
119
  "reflect-metadata": "^0.1.13",
126
120
  "rimraf": "^3.0.2",
@@ -129,7 +123,7 @@
129
123
  "tmp": "^0.2.1",
130
124
  "tree-kill": "^1.2.2",
131
125
  "winston": "^3.8.1",
132
- "ws": "^8.8.0"
126
+ "ws": "^8.8.1"
133
127
  },
134
128
  "optionalDependencies": {
135
129
  "fsevents": "^2.3.2"
package/LICENSE.header DELETED
@@ -1,14 +0,0 @@
1
- This file is part of WPPConnect.
2
-
3
- WPPConnect is free software: you can redistribute it and/or modify
4
- it under the terms of the GNU Lesser General Public License as published by
5
- the Free Software Foundation, either version 3 of the License, or
6
- (at your option) any later version.
7
-
8
- WPPConnect is distributed in the hope that it will be useful,
9
- but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- GNU Lesser General Public License for more details.
12
-
13
- You should have received a copy of the GNU Lesser General Public License
14
- along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
@@ -1,6 +0,0 @@
1
- export declare enum GroupChangeEvent {
2
- Add = "add",
3
- Inivite = "invite",
4
- Leave = "leave",
5
- Remove = "remove"
6
- }
@@ -1,26 +0,0 @@
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 });
19
- exports.GroupChangeEvent = void 0;
20
- var GroupChangeEvent;
21
- (function (GroupChangeEvent) {
22
- GroupChangeEvent["Add"] = "add";
23
- GroupChangeEvent["Inivite"] = "invite";
24
- GroupChangeEvent["Leave"] = "leave";
25
- GroupChangeEvent["Remove"] = "remove";
26
- })(GroupChangeEvent = exports.GroupChangeEvent || (exports.GroupChangeEvent = {}));
@@ -1,19 +0,0 @@
1
- {
2
- "ignore": ["**/.*", "**/*.md", ".github", ".husky", "api-docs", "tokens"],
3
- "license": "LICENSE.header",
4
- "licenseFormats": {
5
- "js|ts": {
6
- "prepend": "/*",
7
- "append": " */",
8
- "eachLine": {
9
- "prepend": " * "
10
- }
11
- },
12
- "dotfile": {
13
- "eachLine": {
14
- "prepend": "# "
15
- }
16
- }
17
- },
18
- "trailingWhitespace": "TRIM"
19
- }