@wppconnect-team/wppconnect 1.24.0 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 1.25.0 (2023-05-30)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **deps:** update dependency @wppconnect/wa-version to ^1.2.42 ([#1700](https://github.com/wppconnect-team/wppconnect/issues/1700)) ([1c07a4b](https://github.com/wppconnect-team/wppconnect/commit/1c07a4b410037dbb748749e9faefde0fc4f04903))
6
+
1
7
  # 1.24.0 (2023-04-29)
2
8
 
3
9
  ## 1.23.2 (2023-04-03)
@@ -94,4 +94,26 @@ export declare class ControlsLayer extends UILayer {
94
94
  * @returns boolean
95
95
  */
96
96
  setTemporaryMessages(chatOrGroupId: string, value: boolean): Promise<boolean>;
97
+ /**
98
+ * Change limits of whatsapp web
99
+ * * @example
100
+ * ```javascript
101
+ * //Change the maximum size (bytes) for uploading media (max 70MB)
102
+ * WPP.conn.setLimit('maxMediaSize',16777216);
103
+ *
104
+ * //Change the maximum size (bytes) for uploading files (max 1GB)
105
+ * WPP.conn.setLimit('maxFileSize',104857600);
106
+ *
107
+ * //Change the maximum number of contacts that can be selected when sharing (Default 5)
108
+ * WPP.conn.setLimit('maxShare',100);
109
+ *
110
+ * //Change the maximum time (seconds) of a video status
111
+ * WPP.conn.setLimit('statusVideoMaxDuration',120);
112
+ *
113
+ * //Remove pinned conversation limit (only whatsapp web) (Default 3)
114
+ * WPP.conn.setLimit('unlimitedPin',true);
115
+ * ```
116
+ * @category Chat
117
+ */
118
+ setLimit(key: 'maxMediaSize' | 'maxFileSize' | 'maxShare' | 'statusVideoMaxDuration' | 'unlimitedPin', value: boolean | number): Promise<number>;
97
119
  }
@@ -303,6 +303,40 @@ var ControlsLayer = /** @class */ (function (_super) {
303
303
  });
304
304
  });
305
305
  };
306
+ /**
307
+ * Change limits of whatsapp web
308
+ * * @example
309
+ * ```javascript
310
+ * //Change the maximum size (bytes) for uploading media (max 70MB)
311
+ * WPP.conn.setLimit('maxMediaSize',16777216);
312
+ *
313
+ * //Change the maximum size (bytes) for uploading files (max 1GB)
314
+ * WPP.conn.setLimit('maxFileSize',104857600);
315
+ *
316
+ * //Change the maximum number of contacts that can be selected when sharing (Default 5)
317
+ * WPP.conn.setLimit('maxShare',100);
318
+ *
319
+ * //Change the maximum time (seconds) of a video status
320
+ * WPP.conn.setLimit('statusVideoMaxDuration',120);
321
+ *
322
+ * //Remove pinned conversation limit (only whatsapp web) (Default 3)
323
+ * WPP.conn.setLimit('unlimitedPin',true);
324
+ * ```
325
+ * @category Chat
326
+ */
327
+ ControlsLayer.prototype.setLimit = function (key, value) {
328
+ return __awaiter(this, void 0, void 0, function () {
329
+ return __generator(this, function (_a) {
330
+ switch (_a.label) {
331
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
332
+ var key = _a.key, value = _a.value;
333
+ return WPP.conn.setLimit(key, value);
334
+ }, { key: key, value: value })];
335
+ case 1: return [2 /*return*/, _a.sent()];
336
+ }
337
+ });
338
+ });
339
+ };
306
340
  return ControlsLayer;
307
341
  }(ui_layer_1.UILayer));
308
342
  exports.ControlsLayer = ControlsLayer;
@@ -1,6 +1,6 @@
1
1
  import { Page } from 'puppeteer';
2
2
  import { CreateConfig } from '../../config/create-config';
3
- import { Id } from '../model';
3
+ import { Id, Wid } from '../model';
4
4
  import { GroupProperty } from '../model/enum';
5
5
  import { RetrieverLayer } from './retriever.layer';
6
6
  export declare class GroupLayer extends RetrieverLayer {
@@ -163,7 +163,7 @@ export declare class GroupLayer extends RetrieverLayer {
163
163
  */
164
164
  setGroupProperty(groupId: string, property: GroupProperty, value: boolean): Promise<boolean>;
165
165
  /**
166
- * Set group subject (if allowed)
166
+ * Set group icon
167
167
  * @category Group
168
168
  * @param groupId Group ID ('000000-000000@g.us')
169
169
  * @param base64 Image in base64 ( data:image/jpeg;base64,..... )
@@ -189,4 +189,39 @@ export declare class GroupLayer extends RetrieverLayer {
189
189
  * @returns number
190
190
  */
191
191
  getGroupSizeLimit(): Promise<number>;
192
+ /**
193
+ * Approve a membership request to group
194
+ * @category Group
195
+ * @param groupId Group ID ('000000-000000@g.us')
196
+ * @param wid <number>@c.us
197
+ * @returns Promise
198
+ */
199
+ approveGroupMembershipRequest(groupId: string, membershipIds: string | string[]): Promise<{
200
+ error: any;
201
+ wid: Wid;
202
+ }[]>;
203
+ /**
204
+ * Reject a membership request to group
205
+ * @category Group
206
+ * @param groupId Group ID ('000000-000000@g.us')
207
+ * @param wid <number>@c.us
208
+ * @returns Promise
209
+ */
210
+ rejectGroupMembershipRequest(groupId: string, membershipIds: string | string[]): Promise<{
211
+ error: any;
212
+ wid: Wid;
213
+ }[]>;
214
+ /**
215
+ * Retrieve a list of a membership approval requests
216
+ * @category Group
217
+ * @param groupId Group ID ('000000-000000@g.us')
218
+ * @returns Promise
219
+ */
220
+ getGroupMembershipRequests(groupId: string): Promise<{
221
+ addedBy: Wid;
222
+ id: Wid;
223
+ parentGroupId?: Wid;
224
+ requestMethod: 'InviteLink' | 'LinkedGroupJoin' | 'NonAdminAdd';
225
+ t: number;
226
+ }[]>;
192
227
  }
@@ -385,7 +385,7 @@ var GroupLayer = /** @class */ (function (_super) {
385
385
  });
386
386
  };
387
387
  /**
388
- * Set group subject (if allowed)
388
+ * Set group icon
389
389
  * @category Group
390
390
  * @param groupId Group ID ('000000-000000@g.us')
391
391
  * @param base64 Image in base64 ( data:image/jpeg;base64,..... )
@@ -485,6 +485,65 @@ var GroupLayer = /** @class */ (function (_super) {
485
485
  });
486
486
  });
487
487
  };
488
+ /**
489
+ * Approve a membership request to group
490
+ * @category Group
491
+ * @param groupId Group ID ('000000-000000@g.us')
492
+ * @param wid <number>@c.us
493
+ * @returns Promise
494
+ */
495
+ GroupLayer.prototype.approveGroupMembershipRequest = function (groupId, membershipIds) {
496
+ return __awaiter(this, void 0, void 0, function () {
497
+ return __generator(this, function (_a) {
498
+ switch (_a.label) {
499
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
500
+ var groupId = _a.groupId, membershipIds = _a.membershipIds;
501
+ return WPP.group.approve(groupId, membershipIds);
502
+ }, { groupId: groupId, membershipIds: membershipIds })];
503
+ case 1: return [2 /*return*/, _a.sent()];
504
+ }
505
+ });
506
+ });
507
+ };
508
+ /**
509
+ * Reject a membership request to group
510
+ * @category Group
511
+ * @param groupId Group ID ('000000-000000@g.us')
512
+ * @param wid <number>@c.us
513
+ * @returns Promise
514
+ */
515
+ GroupLayer.prototype.rejectGroupMembershipRequest = function (groupId, membershipIds) {
516
+ return __awaiter(this, void 0, void 0, function () {
517
+ return __generator(this, function (_a) {
518
+ switch (_a.label) {
519
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
520
+ var groupId = _a.groupId, membershipIds = _a.membershipIds;
521
+ return WPP.group.reject(groupId, membershipIds);
522
+ }, { groupId: groupId, membershipIds: membershipIds })];
523
+ case 1: return [2 /*return*/, _a.sent()];
524
+ }
525
+ });
526
+ });
527
+ };
528
+ /**
529
+ * Retrieve a list of a membership approval requests
530
+ * @category Group
531
+ * @param groupId Group ID ('000000-000000@g.us')
532
+ * @returns Promise
533
+ */
534
+ GroupLayer.prototype.getGroupMembershipRequests = function (groupId) {
535
+ return __awaiter(this, void 0, void 0, function () {
536
+ return __generator(this, function (_a) {
537
+ switch (_a.label) {
538
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
539
+ var groupId = _a.groupId;
540
+ return WPP.group.getMembershipRequests(groupId);
541
+ }, { groupId: groupId })];
542
+ case 1: return [2 /*return*/, _a.sent()];
543
+ }
544
+ });
545
+ });
546
+ };
488
547
  return GroupLayer;
489
548
  }(retriever_layer_1.RetrieverLayer));
490
549
  exports.GroupLayer = GroupLayer;
@@ -71,6 +71,11 @@ export declare class HostLayer {
71
71
  * @category Host
72
72
  */
73
73
  isConnected(): Promise<boolean>;
74
+ /**
75
+ * Check is online
76
+ * @category Host
77
+ */
78
+ isOnline(): Promise<boolean>;
74
79
  /**
75
80
  * Retrieves if the phone is online. Please note that this may not be real time.
76
81
  * @category Host
@@ -118,4 +123,10 @@ export declare class HostLayer {
118
123
  * @category Host
119
124
  */
120
125
  isMainInit(): Promise<boolean>;
126
+ /**
127
+ * Join or leave of WhatsApp Web beta program.
128
+ * Will return the value seted
129
+ * @category Host
130
+ */
131
+ joinWebBeta(value: boolean): Promise<boolean>;
121
132
  }
@@ -597,6 +597,20 @@ var HostLayer = /** @class */ (function () {
597
597
  });
598
598
  });
599
599
  };
600
+ /**
601
+ * Check is online
602
+ * @category Host
603
+ */
604
+ HostLayer.prototype.isOnline = function () {
605
+ return __awaiter(this, void 0, void 0, function () {
606
+ return __generator(this, function (_a) {
607
+ switch (_a.label) {
608
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () { return WPP.conn.isOnline(); })];
609
+ case 1: return [2 /*return*/, _a.sent()];
610
+ }
611
+ });
612
+ });
613
+ };
600
614
  /**
601
615
  * Retrieves if the phone is online. Please note that this may not be real time.
602
616
  * @category Host
@@ -726,6 +740,21 @@ var HostLayer = /** @class */ (function () {
726
740
  });
727
741
  });
728
742
  };
743
+ /**
744
+ * Join or leave of WhatsApp Web beta program.
745
+ * Will return the value seted
746
+ * @category Host
747
+ */
748
+ HostLayer.prototype.joinWebBeta = function (value) {
749
+ return __awaiter(this, void 0, void 0, function () {
750
+ return __generator(this, function (_a) {
751
+ switch (_a.label) {
752
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (value) { return WPP.conn.joinWebBeta(value); }, value)];
753
+ case 1: return [2 /*return*/, _a.sent()];
754
+ }
755
+ });
756
+ });
757
+ };
729
758
  return HostLayer;
730
759
  }());
731
760
  exports.HostLayer = HostLayer;
@@ -5,6 +5,7 @@ import { SocketState, SocketStream } from '../model/enum';
5
5
  import { InterfaceMode } from '../model/enum/interface-mode';
6
6
  import { InterfaceState } from '../model/enum/interface-state';
7
7
  import { ProfileLayer } from './profile.layer';
8
+ import { Label } from '../model/label';
8
9
  declare global {
9
10
  interface Window {
10
11
  onMessage: any;
@@ -225,4 +226,16 @@ export declare class ListenerLayer extends ProfileLayer {
225
226
  }) => any): {
226
227
  dispose: () => void;
227
228
  };
229
+ /**
230
+ * @event Listens to update label
231
+ * @returns Disposable object to stop the listening
232
+ */
233
+ onUpdateLabel(callback: (data: {
234
+ chat: Chat;
235
+ ids: string[];
236
+ labels: Label[];
237
+ type: 'add' | 'remove';
238
+ }) => any): {
239
+ dispose: () => void;
240
+ };
228
241
  }
@@ -125,6 +125,7 @@ var ListenerLayer = /** @class */ (function (_super) {
125
125
  'onRevokedMessage',
126
126
  'onReactionMessage',
127
127
  'onPollResponse',
128
+ 'onUpdateLabel',
128
129
  ], false);
129
130
  _loop_1 = function (func) {
130
131
  var has;
@@ -343,6 +344,23 @@ var ListenerLayer = /** @class */ (function (_super) {
343
344
  catch (error) {
344
345
  console.error(error);
345
346
  }
347
+ try {
348
+ if (!window['onUpdateLabel'].exposed) {
349
+ WPP.on('chat.update_label', function (data) {
350
+ var eventData = {
351
+ chat: data.chat,
352
+ ids: data.ids,
353
+ labels: data.labels,
354
+ type: data.type,
355
+ };
356
+ window['onUpdateLabel'](eventData);
357
+ });
358
+ window['onUpdateLabel'].exposed = true;
359
+ }
360
+ }
361
+ catch (error) {
362
+ console.error(error);
363
+ }
346
364
  try {
347
365
  if (!window['onParticipantsChanged'].exposed) {
348
366
  WPP.on('group.participant_changed', function (participantChangedEvent) {
@@ -575,6 +593,13 @@ var ListenerLayer = /** @class */ (function (_super) {
575
593
  ListenerLayer.prototype.onPollResponse = function (callback) {
576
594
  return this.registerEvent('onPollResponse', callback);
577
595
  };
596
+ /**
597
+ * @event Listens to update label
598
+ * @returns Disposable object to stop the listening
599
+ */
600
+ ListenerLayer.prototype.onUpdateLabel = function (callback) {
601
+ return this.registerEvent('onUpdateLabel', callback);
602
+ };
578
603
  return ListenerLayer;
579
604
  }(profile_layer_1.ProfileLayer));
580
605
  exports.ListenerLayer = ListenerLayer;
@@ -132,8 +132,9 @@ export declare class SenderLayer extends ListenerLayer {
132
132
  * @param filename
133
133
  * @param caption
134
134
  * @param quotedMessageId Quoted message id
135
+ * @param messageId Set the id for this message
135
136
  */
136
- sendPttFromBase64(to: string, base64: string, filename: string, caption?: string, quotedMessageId?: string): Promise<{
137
+ sendPttFromBase64(to: string, base64: string, filename: string, caption?: string, quotedMessageId?: string, messageId?: string): Promise<{
137
138
  ack: number;
138
139
  id: string;
139
140
  sendMsgResult: import("@wppconnect/wa-js/dist/whatsapp/enums").SendMsgResult;
@@ -146,8 +147,9 @@ export declare class SenderLayer extends ListenerLayer {
146
147
  * @param filename
147
148
  * @param caption
148
149
  * @param quotedMessageId Quoted message id
150
+ * @param messageId Set the id for this message
149
151
  */
150
- sendPtt(to: string, filePath: string, filename?: string, caption?: string, quotedMessageId?: string): Promise<unknown>;
152
+ sendPtt(to: string, filePath: string, filename?: string, caption?: string, quotedMessageId?: string, messageId?: string): Promise<unknown>;
151
153
  /**
152
154
  * Sends file
153
155
  * base64 parameter should have mime type already defined
@@ -488,8 +488,9 @@ var SenderLayer = /** @class */ (function (_super) {
488
488
  * @param filename
489
489
  * @param caption
490
490
  * @param quotedMessageId Quoted message id
491
+ * @param messageId Set the id for this message
491
492
  */
492
- SenderLayer.prototype.sendPttFromBase64 = function (to, base64, filename, caption, quotedMessageId) {
493
+ SenderLayer.prototype.sendPttFromBase64 = function (to, base64, filename, caption, quotedMessageId, messageId) {
493
494
  return __awaiter(this, void 0, void 0, function () {
494
495
  var result;
495
496
  var _this = this;
@@ -509,6 +510,7 @@ var SenderLayer = /** @class */ (function (_super) {
509
510
  caption: caption,
510
511
  quotedMsg: quotedMessageId,
511
512
  waitForAck: true,
513
+ messageId: messageId,
512
514
  })];
513
515
  case 1:
514
516
  result = _c.sent();
@@ -538,8 +540,9 @@ var SenderLayer = /** @class */ (function (_super) {
538
540
  * @param filename
539
541
  * @param caption
540
542
  * @param quotedMessageId Quoted message id
543
+ * @param messageId Set the id for this message
541
544
  */
542
- SenderLayer.prototype.sendPtt = function (to, filePath, filename, caption, quotedMessageId) {
545
+ SenderLayer.prototype.sendPtt = function (to, filePath, filename, caption, quotedMessageId, messageId) {
543
546
  return __awaiter(this, void 0, void 0, function () {
544
547
  var _this = this;
545
548
  return __generator(this, function (_a) {
@@ -567,7 +570,7 @@ var SenderLayer = /** @class */ (function (_super) {
567
570
  if (!filename) {
568
571
  filename = path.basename(filePath);
569
572
  }
570
- return [2 /*return*/, this.sendPttFromBase64(to, base64, filename, caption, quotedMessageId)
573
+ return [2 /*return*/, this.sendPttFromBase64(to, base64, filename, caption, quotedMessageId, messageId)
571
574
  .then(resolve)
572
575
  .catch(reject)];
573
576
  }
@@ -0,0 +1,7 @@
1
+ export interface Label {
2
+ id: string;
3
+ name: string;
4
+ color: number | null;
5
+ count: number;
6
+ hexColor: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -378,7 +378,7 @@ function initBrowser(session, options, logger) {
378
378
  case 2:
379
379
  browser = _a.sent();
380
380
  return [3 /*break*/, 5];
381
- case 3: return [4 /*yield*/, puppeteer_extra_1.default.launch(__assign({ headless: options.headless, devtools: options.devtools, args: options.browserArgs
381
+ case 3: return [4 /*yield*/, puppeteer_extra_1.default.launch(__assign({ headless: options.headless ? 'new' : false, devtools: options.devtools, args: options.browserArgs
382
382
  ? options.browserArgs
383
383
  : __spreadArray([], puppeteer_config_1.puppeteerConfig.chromiumArgs, true) }, options.puppeteerOptions))];
384
384
  case 4:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
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",
@@ -54,30 +54,30 @@
54
54
  },
55
55
  "homepage": "https://github.com/wppconnect-team/wppconnect#readme",
56
56
  "devDependencies": {
57
- "@babel/core": "^7.21.5",
58
- "@babel/eslint-parser": "^7.21.3",
57
+ "@babel/core": "^7.22.1",
58
+ "@babel/eslint-parser": "^7.21.8",
59
59
  "@babel/eslint-plugin": "^7.19.1",
60
- "@babel/preset-env": "^7.21.5",
61
- "@commitlint/cli": "^17.6.1",
62
- "@commitlint/config-conventional": "^17.6.1",
60
+ "@babel/preset-env": "^7.22.4",
61
+ "@commitlint/cli": "^17.6.3",
62
+ "@commitlint/config-conventional": "^17.6.3",
63
63
  "@commitlint/cz-commitlint": "^17.5.0",
64
64
  "@knodes/typedoc-plugin-pages": "^0.23.4",
65
65
  "@types/atob": "^2.1.2",
66
66
  "@types/mime-types": "^2.1.1",
67
67
  "@types/mocha": "^10.0.1",
68
- "@types/node": "^18.16.3",
68
+ "@types/node": "^18.16.16",
69
69
  "@types/rimraf": "^3.0.2",
70
70
  "@types/sharp": "^0.31.1",
71
71
  "@types/shelljs": "^0.8.12",
72
72
  "@types/tmp": "^0.2.3",
73
73
  "@types/ws": "^8.5.4",
74
- "@typescript-eslint/eslint-plugin": "^5.59.1",
75
- "@typescript-eslint/parser": "^5.59.1",
74
+ "@typescript-eslint/eslint-plugin": "^5.59.8",
75
+ "@typescript-eslint/parser": "^5.59.8",
76
76
  "babel-loader": "^9.1.2",
77
77
  "commitizen": "^4.3.0",
78
78
  "concurrently": "^8.0.1",
79
79
  "conventional-changelog-cli": "^2.2.2",
80
- "eslint": "^8.39.0",
80
+ "eslint": "^8.41.0",
81
81
  "eslint-config-prettier": "^8.8.0",
82
82
  "eslint-plugin-header": "^3.1.1",
83
83
  "eslint-plugin-prettier": "^4.2.1",
@@ -86,17 +86,17 @@
86
86
  "prettier": "^2.8.8",
87
87
  "pretty-quick": "^3.1.3",
88
88
  "regenerator-runtime": "^0.13.11",
89
- "release-it": "^15.10.1",
89
+ "release-it": "^15.10.3",
90
90
  "shx": "^0.3.4",
91
91
  "ts-node": "^10.9.1",
92
92
  "typedoc": "^0.23.28",
93
93
  "typescript": "^5.0.4",
94
- "webpack": "^5.81.0",
95
- "webpack-cli": "^5.0.2"
94
+ "webpack": "^5.84.1",
95
+ "webpack-cli": "^5.1.1"
96
96
  },
97
97
  "dependencies": {
98
- "@wppconnect/wa-js": "^2.23.5",
99
- "@wppconnect/wa-version": "^1.2.27",
98
+ "@wppconnect/wa-js": "^2.24.2",
99
+ "@wppconnect/wa-version": "^1.2.42",
100
100
  "atob": "^2.1.2",
101
101
  "axios": "^1.4.0",
102
102
  "boxen": "^5.1.2",
@@ -122,7 +122,7 @@
122
122
  "sharp": "^0.32.1",
123
123
  "tmp": "^0.2.1",
124
124
  "tree-kill": "^1.2.2",
125
- "winston": "^3.8.2",
125
+ "winston": "^3.9.0",
126
126
  "ws": "^8.13.0"
127
127
  },
128
128
  "optionalDependencies": {