@wppconnect-team/wppconnect 1.14.4 → 1.14.5

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,7 @@
1
+ ## 1.14.5 (2022-07-11)
2
+
3
+
4
+
1
5
  ## 1.14.4 (2022-06-20)
2
6
 
3
7
 
@@ -163,6 +163,10 @@ var HostLayer = /** @class */ (function () {
163
163
  this.log('verbose', 'Injecting wapi.js');
164
164
  options = {
165
165
  deviceName: this.options.deviceName,
166
+ disableGoogleAnalytics: this.options.disableGoogleAnalytics,
167
+ googleAnalyticsId: this.options.googleAnalyticsId,
168
+ linkPreviewApiServers: this.options.linkPreviewApiServers,
169
+ poweredBy: this.options.poweredBy,
166
170
  };
167
171
  return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (options) {
168
172
  window.WPPConfig = options;
@@ -169,10 +169,14 @@ var ListenerLayer = /** @class */ (function (_super) {
169
169
  .evaluate(function () {
170
170
  try {
171
171
  if (!window['onMessage'].exposed) {
172
- window.WAPI.waitNewMessages(false, function (data) {
173
- data.forEach(function (message) {
174
- window['onMessage'](message);
175
- });
172
+ WPP.on('chat.new_message', function (msg) {
173
+ if (msg.isSentByMe || msg.isStatusV3) {
174
+ return;
175
+ }
176
+ var serialized = WAPI.processMessageObj(msg, false, false);
177
+ if (serialized) {
178
+ window['onMessage'](serialized);
179
+ }
176
180
  });
177
181
  window['onMessage'].exposed = true;
178
182
  }
@@ -191,7 +195,12 @@ var ListenerLayer = /** @class */ (function (_super) {
191
195
  }
192
196
  try {
193
197
  if (!window['onAnyMessage'].exposed) {
194
- window.WAPI.allNewMessagesListener(window['onAnyMessage']);
198
+ WPP.on('chat.new_message', function (msg) {
199
+ var serialized = WAPI.processMessageObj(msg, true, false);
200
+ if (serialized) {
201
+ window['onAnyMessage'](serialized);
202
+ }
203
+ });
195
204
  window['onAnyMessage'].exposed = true;
196
205
  }
197
206
  }
@@ -254,7 +263,7 @@ var ListenerLayer = /** @class */ (function (_super) {
254
263
  }
255
264
  try {
256
265
  if (!window['onPresenceChanged'].exposed) {
257
- window.WAPI.onPresenceChanged(window['onPresenceChanged']);
266
+ WPP.on('chat.presence_change', window['onPresenceChanged']);
258
267
  window['onPresenceChanged'].exposed = true;
259
268
  }
260
269
  }
@@ -235,21 +235,30 @@ var RetrieverLayer = /** @class */ (function (_super) {
235
235
  RetrieverLayer.prototype.getAllGroups = function (withNewMessagesOnly) {
236
236
  if (withNewMessagesOnly === void 0) { withNewMessagesOnly = false; }
237
237
  return __awaiter(this, void 0, void 0, function () {
238
- var chats, chats;
238
+ var _this = this;
239
239
  return __generator(this, function (_a) {
240
240
  switch (_a.label) {
241
- case 0:
242
- if (!withNewMessagesOnly) return [3 /*break*/, 2];
243
- return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () { return WAPI.getAllChatsWithNewMsg(); })];
244
- case 1:
245
- chats = _a.sent();
246
- return [2 /*return*/, chats.filter(function (chat) { return chat.isGroup; })];
247
- case 2: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
248
- return WAPI.getAllChats();
249
- })];
250
- case 3:
251
- chats = _a.sent();
252
- return [2 /*return*/, chats.filter(function (chat) { return chat.isGroup; })];
241
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
242
+ var withNewMessagesOnly = _a.withNewMessagesOnly;
243
+ return __awaiter(_this, void 0, void 0, function () {
244
+ var chats, groups;
245
+ return __generator(this, function (_b) {
246
+ switch (_b.label) {
247
+ case 0: return [4 /*yield*/, WPP.chat.list({
248
+ onlyGroups: true,
249
+ onlyWithUnreadMessage: withNewMessagesOnly,
250
+ })];
251
+ case 1:
252
+ chats = _b.sent();
253
+ return [4 /*yield*/, Promise.all(chats.map(function (c) { return WPP.group.ensureGroup(c.id); }))];
254
+ case 2:
255
+ groups = _b.sent();
256
+ return [2 /*return*/, groups.map(function (g) { return WAPI._serializeChatObj(g); })];
257
+ }
258
+ });
259
+ });
260
+ }, { withNewMessagesOnly: withNewMessagesOnly })];
261
+ case 1: return [2 /*return*/, _a.sent()];
253
262
  }
254
263
  });
255
264
  });
@@ -16,6 +16,12 @@ export interface Chat {
16
16
  pin: number;
17
17
  msgs: null;
18
18
  kind: string;
19
+ isAnnounceGrpRestrict: boolean;
20
+ ephemeralDuration: number;
21
+ hasChatBeenOpened: boolean;
22
+ unreadMentionCount: number;
23
+ hasUnreadMention: boolean;
24
+ archiveAtMentionViewedInDrawer: boolean;
19
25
  isBroadcast: boolean;
20
26
  isGroup: boolean;
21
27
  isReadOnly: boolean;
@@ -3,6 +3,21 @@ export interface GroupMetadata {
3
3
  id: Wid;
4
4
  creation: number;
5
5
  owner: Wid;
6
+ desc: string;
7
+ descId: string;
8
+ descTime: number;
9
+ descOwner: Wid;
10
+ restrict: boolean;
11
+ announce: boolean;
12
+ noFrequentlyForwarded: boolean;
13
+ ephemeralDuration: number;
14
+ size: number;
15
+ support: boolean;
16
+ suspended: boolean;
17
+ terminated: boolean;
18
+ isParentGroup: boolean;
19
+ defaultSubgroup: boolean;
20
+ displayCadminPromotion: boolean;
6
21
  participants: any[];
7
22
  pendingParticipants: any[];
8
23
  }
@@ -110,5 +110,26 @@ export interface CreateConfig {
110
110
  * @default 'WPPConnect'
111
111
  */
112
112
  deviceName?: string | false;
113
+ /**
114
+ * Set custom Link Preview API servers
115
+ * @default null
116
+ */
117
+ linkPreviewApiServers?: string[] | null;
118
+ /**
119
+ * Disable custom Google Analytics
120
+ * @default true
121
+ */
122
+ disableGoogleAnalytics?: boolean;
123
+ /**
124
+ * Custom Google Analytics Tracker Id, like 'G-XXXXXXXXXX'
125
+ * collect analytics data to your GA account
126
+ * @default null
127
+ */
128
+ googleAnalyticsId?: string | null;
129
+ /**
130
+ * Custom variable for Google Analytics
131
+ * @default 'WPPConnect'
132
+ */
133
+ poweredBy?: string;
113
134
  }
114
135
  export declare const defaultOptions: CreateConfig;
@@ -21,4 +21,8 @@ exports.defaultOptions = {
21
21
  tokenStore: 'file',
22
22
  whatsappVersion: '2.2220.x',
23
23
  deviceName: false,
24
+ linkPreviewApiServers: null,
25
+ disableGoogleAnalytics: true,
26
+ googleAnalyticsId: null,
27
+ poweredBy: 'WPPConnect',
24
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.14.4",
3
+ "version": "1.14.5",
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",
@@ -58,24 +58,24 @@
58
58
  },
59
59
  "homepage": "https://github.com/wppconnect-team/wppconnect#readme",
60
60
  "devDependencies": {
61
- "@babel/core": "^7.18.5",
61
+ "@babel/core": "^7.18.6",
62
62
  "@babel/eslint-parser": "^7.18.2",
63
63
  "@babel/eslint-plugin": "^7.17.7",
64
- "@babel/preset-env": "^7.18.2",
65
- "@commitlint/cli": "^17.0.2",
66
- "@commitlint/config-conventional": "^17.0.2",
67
- "@commitlint/cz-commitlint": "^17.0.0",
64
+ "@babel/preset-env": "^7.18.6",
65
+ "@commitlint/cli": "^17.0.3",
66
+ "@commitlint/config-conventional": "^17.0.3",
67
+ "@commitlint/cz-commitlint": "^17.0.3",
68
68
  "@types/atob": "^2.1.2",
69
69
  "@types/mime-types": "^2.1.1",
70
70
  "@types/mocha": "^9.1.1",
71
- "@types/node": "^16.11.41",
71
+ "@types/node": "^16.11.43",
72
72
  "@types/rimraf": "^3.0.2",
73
73
  "@types/sharp": "^0.30.4",
74
74
  "@types/shelljs": "^0.8.11",
75
75
  "@types/tmp": "^0.2.3",
76
76
  "@types/ws": "^8.5.3",
77
- "@typescript-eslint/eslint-plugin": "^5.27.1",
78
- "@typescript-eslint/parser": "^5.27.1",
77
+ "@typescript-eslint/eslint-plugin": "^5.29.0",
78
+ "@typescript-eslint/parser": "^5.29.0",
79
79
  "babel-loader": "^8.2.5",
80
80
  "commitizen": "^4.2.4",
81
81
  "concurrently": "^7.2.2",
@@ -88,12 +88,12 @@
88
88
  "husky": "^8.0.1",
89
89
  "license-check-and-add": "^4.0.5",
90
90
  "mocha": "^10.0.0",
91
- "prettier": "^2.6.2",
91
+ "prettier": "^2.7.1",
92
92
  "pretty-quick": "^3.1.3",
93
93
  "regenerator-runtime": "^0.13.9",
94
- "release-it": "^15.0.0",
94
+ "release-it": "^15.1.1",
95
95
  "shx": "^0.3.4",
96
- "ts-node": "^10.8.1",
96
+ "ts-node": "^10.8.2",
97
97
  "typedoc": "^0.21.10",
98
98
  "typedoc-plugin-pages": "^1.1.0",
99
99
  "typescript": "^4.7.4",
@@ -101,8 +101,8 @@
101
101
  "webpack-cli": "^4.10.0"
102
102
  },
103
103
  "dependencies": {
104
- "@wppconnect/wa-js": "^2.7.3",
105
- "@wppconnect/wa-version": "^1.1.97",
104
+ "@wppconnect/wa-js": "^2.8.1",
105
+ "@wppconnect/wa-version": "^1.1.104",
106
106
  "atob": "^2.1.2",
107
107
  "axios": "^0.27.2",
108
108
  "boxen": "^5.1.2",
@@ -113,22 +113,22 @@
113
113
  "file-type": "~16.5.3",
114
114
  "futoin-hkdf": "^1.5.1",
115
115
  "latest-version": "^5.1.0",
116
- "logform": "^2.4.0",
116
+ "logform": "^2.4.2",
117
117
  "lookpath": "^1.2.2",
118
118
  "mime-types": "^2.1.35",
119
119
  "puppeteer": "*",
120
- "puppeteer-extra": "^3.2.3",
121
- "puppeteer-extra-plugin-stealth": "^2.9.0",
120
+ "puppeteer-extra": "^3.3.4",
121
+ "puppeteer-extra-plugin-stealth": "^2.10.1",
122
122
  "puppeteer-extra-plugin-user-data-dir": "^2.3.1",
123
123
  "puppeteer-extra-plugin-user-preferences": "^2.3.1",
124
124
  "qrcode-terminal": "^0.12.0",
125
125
  "reflect-metadata": "^0.1.13",
126
126
  "rimraf": "^3.0.2",
127
127
  "sanitize-filename": "^1.6.3",
128
- "sharp": "^0.30.6",
128
+ "sharp": "^0.30.7",
129
129
  "tmp": "^0.2.1",
130
130
  "tree-kill": "^1.2.2",
131
- "winston": "^3.7.2",
131
+ "winston": "^3.8.1",
132
132
  "ws": "^8.8.0"
133
133
  },
134
134
  "optionalDependencies": {