@wppconnect-team/wppconnect 1.41.3 → 2.0.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 +12 -0
- package/dist/api/helpers/base64-mimetype.js +2 -2
- package/dist/api/helpers/decrypt.js +65 -72
- package/dist/api/helpers/download-file.js +31 -81
- package/dist/api/helpers/evaluate-and-return.js +98 -93
- package/dist/api/helpers/exposed.enum.d.ts +2 -1
- package/dist/api/helpers/exposed.enum.js +1 -0
- package/dist/api/helpers/file-to-base64.js +30 -81
- package/dist/api/helpers/filename-from-mimetype.js +4 -4
- package/dist/api/helpers/scrape-img-qr.js +37 -86
- package/dist/api/helpers/scrape-login.js +12 -57
- package/dist/api/helpers/select-sticker.js +35 -100
- package/dist/api/layers/business.layer.js +29 -134
- package/dist/api/layers/catalog.layer.js +59 -210
- package/dist/api/layers/community.layer.js +29 -120
- package/dist/api/layers/controls.layer.js +62 -262
- package/dist/api/layers/group.layer.js +126 -391
- package/dist/api/layers/host.layer.js +348 -702
- package/dist/api/layers/labels.layer.js +35 -131
- package/dist/api/layers/listener.layer.d.ts +9 -1
- package/dist/api/layers/listener.layer.js +392 -491
- package/dist/api/layers/newsletter.layer.js +20 -89
- package/dist/api/layers/profile.layer.js +73 -184
- package/dist/api/layers/retriever.layer.js +163 -468
- package/dist/api/layers/sender.layer.js +554 -1094
- package/dist/api/layers/status.layer.js +80 -179
- package/dist/api/layers/ui.layer.js +32 -129
- package/dist/api/model/enum/definitions.js +1 -1
- package/dist/api/whatsapp.js +200 -426
- package/dist/config/WAuserAgente.js +1 -1
- package/dist/config/create-config.js +1 -1
- package/dist/config/puppeteer.config.js +1 -1
- package/dist/controllers/auth.js +42 -110
- package/dist/controllers/browser.js +251 -411
- package/dist/controllers/initializer.js +171 -265
- package/dist/controllers/websocket.js +29 -28
- package/dist/controllers/welcome.js +38 -88
- package/dist/lib/wapi/wapi.js +1 -1
- package/dist/token-store/fileTokenStore.js +83 -173
- package/dist/token-store/isValidSessionToken.js +2 -2
- package/dist/token-store/isValidTokenStore.js +2 -2
- package/dist/token-store/memoryTokenStore.js +11 -14
- package/dist/utils/ffmpeg.js +75 -131
- package/dist/utils/logger.js +5 -5
- package/dist/utils/semver.js +6 -6
- package/dist/utils/sleep.js +1 -1
- package/package.json +8 -8
|
@@ -15,155 +15,65 @@
|
|
|
15
15
|
* You should have received a copy of the GNU Lesser General Public License
|
|
16
16
|
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
17
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
44
|
-
return g.next = verb(0), g["throw"] = verb(1), g["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 (g && (g = 0, op[0] && (_ = 0)), _) 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
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
19
|
exports.GroupLayer = void 0;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return _this;
|
|
20
|
+
const helpers_1 = require("../helpers");
|
|
21
|
+
const retriever_layer_1 = require("./retriever.layer");
|
|
22
|
+
class GroupLayer extends retriever_layer_1.RetrieverLayer {
|
|
23
|
+
page;
|
|
24
|
+
constructor(page, session, options) {
|
|
25
|
+
super(page, session, options);
|
|
26
|
+
this.page = page;
|
|
79
27
|
}
|
|
80
28
|
/**
|
|
81
29
|
* Removes the host device from the group
|
|
82
30
|
* @category Group
|
|
83
31
|
* @param groupId group id
|
|
84
32
|
*/
|
|
85
|
-
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (groupId) { return WPP.group.leave(groupId); }, groupId)];
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
33
|
+
async leaveGroup(groupId) {
|
|
34
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (groupId) => WPP.group.leave(groupId), groupId);
|
|
35
|
+
}
|
|
92
36
|
/**
|
|
93
37
|
* Retrieves group members as [Id] objects
|
|
94
38
|
* @category Group
|
|
95
39
|
* @param groupId group id
|
|
96
40
|
*/
|
|
97
|
-
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (groupId) {
|
|
101
|
-
return Promise.resolve(WPP.group.getParticipants(groupId)).then(function (participants) { return participants.map(function (p) { return p.id; }); });
|
|
102
|
-
}, groupId)];
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
};
|
|
41
|
+
async getGroupMembersIds(groupId) {
|
|
42
|
+
return (0, helpers_1.evaluateAndReturn)(this.page, (groupId) => Promise.resolve(WPP.group.getParticipants(groupId)).then((participants) => participants.map((p) => p.id)), groupId);
|
|
43
|
+
}
|
|
106
44
|
/**
|
|
107
45
|
* Returns current group members as [Contact] objects
|
|
108
46
|
* For previous members, see `groupMetadata.pastParticipants`.
|
|
109
47
|
* @category Group
|
|
110
48
|
* @param groupId
|
|
111
49
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return __generator(this, function (_a) {
|
|
117
|
-
switch (_a.label) {
|
|
118
|
-
case 0: return [4 /*yield*/, this.getGroupMembersIds(groupId)];
|
|
119
|
-
case 1:
|
|
120
|
-
membersIds = _a.sent();
|
|
121
|
-
actions = membersIds.map(function (memberId) {
|
|
122
|
-
return _this.getContact(memberId._serialized);
|
|
123
|
-
});
|
|
124
|
-
return [2 /*return*/, Promise.all(actions)];
|
|
125
|
-
}
|
|
126
|
-
});
|
|
50
|
+
async getGroupMembers(groupId) {
|
|
51
|
+
const membersIds = await this.getGroupMembersIds(groupId);
|
|
52
|
+
const actions = membersIds.map((memberId) => {
|
|
53
|
+
return this.getContact(memberId._serialized);
|
|
127
54
|
});
|
|
128
|
-
|
|
55
|
+
return Promise.all(actions);
|
|
56
|
+
}
|
|
129
57
|
/**
|
|
130
58
|
* Generates group-invite link
|
|
131
59
|
* @category Group
|
|
132
60
|
* @param chatId
|
|
133
61
|
* @returns Invitation link
|
|
134
62
|
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
switch (_a.label) {
|
|
140
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (chatId) { return WPP.group.getInviteCode(chatId); }, chatId)];
|
|
141
|
-
case 1:
|
|
142
|
-
code = _a.sent();
|
|
143
|
-
return [2 /*return*/, "https://chat.whatsapp.com/".concat(code)];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
};
|
|
63
|
+
async getGroupInviteLink(chatId) {
|
|
64
|
+
const code = await (0, helpers_1.evaluateAndReturn)(this.page, (chatId) => WPP.group.getInviteCode(chatId), chatId);
|
|
65
|
+
return `https://chat.whatsapp.com/${code}`;
|
|
66
|
+
}
|
|
148
67
|
/**
|
|
149
68
|
* Revokes group-invite link and generates a new one.
|
|
150
69
|
* @category Group
|
|
151
70
|
* @param chatId
|
|
152
71
|
* @returns Invitation link
|
|
153
72
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
switch (_a.label) {
|
|
159
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (chatId) { return WPP.group.revokeInviteCode(chatId); }, chatId)];
|
|
160
|
-
case 1:
|
|
161
|
-
code = _a.sent();
|
|
162
|
-
return [2 /*return*/, "https://chat.whatsapp.com/".concat(code)];
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
};
|
|
73
|
+
async revokeGroupInviteLink(chatId) {
|
|
74
|
+
const code = await (0, helpers_1.evaluateAndReturn)(this.page, (chatId) => WPP.group.revokeInviteCode(chatId), chatId);
|
|
75
|
+
return `https://chat.whatsapp.com/${code}`;
|
|
76
|
+
}
|
|
167
77
|
/**
|
|
168
78
|
* Displays group info from an invitation link (or invitation ID)
|
|
169
79
|
* @category Group
|
|
@@ -172,138 +82,69 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
172
82
|
* @example getGroupInfoFromInviteLink('https://chat.whatsapp.com/invite/CMJYfPFqRyE2GxrnkldYED')
|
|
173
83
|
* @example getGroupInfoFromInviteLink('CMJYfPFqRyE2GxrnkldYED')
|
|
174
84
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
inviteCode = inviteCode.replace('https://', '');
|
|
183
|
-
inviteCode = inviteCode.replace('http://', '');
|
|
184
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (inviteCode) { return WPP.group.getGroupInfoFromInviteCode(inviteCode); }, inviteCode)];
|
|
185
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
};
|
|
85
|
+
async getGroupInfoFromInviteLink(inviteCode) {
|
|
86
|
+
inviteCode = inviteCode.replace('chat.whatsapp.com/', '');
|
|
87
|
+
inviteCode = inviteCode.replace('invite/', '');
|
|
88
|
+
inviteCode = inviteCode.replace('https://', '');
|
|
89
|
+
inviteCode = inviteCode.replace('http://', '');
|
|
90
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, (inviteCode) => WPP.group.getGroupInfoFromInviteCode(inviteCode), inviteCode);
|
|
91
|
+
}
|
|
190
92
|
/**
|
|
191
93
|
* Creates a new chat group
|
|
192
94
|
* @category Group
|
|
193
95
|
* @param groupName Group name
|
|
194
96
|
* @param contacts Contacts that should be added.
|
|
195
97
|
*/
|
|
196
|
-
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
switch (_a.label) {
|
|
200
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
201
|
-
var groupName = _a.groupName, contacts = _a.contacts;
|
|
202
|
-
return WPP.group.create(groupName, contacts, null);
|
|
203
|
-
}, { groupName: groupName, contacts: contacts })];
|
|
204
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
};
|
|
98
|
+
async createGroup(groupName, contacts) {
|
|
99
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupName, contacts }) => WPP.group.create(groupName, contacts, null), { groupName, contacts });
|
|
100
|
+
}
|
|
209
101
|
/**
|
|
210
102
|
* Removes participant from group
|
|
211
103
|
* @category Group
|
|
212
104
|
* @param groupId Chat id ('0000000000-00000000@g.us')
|
|
213
105
|
* @param participantId Participant id'000000000000@c.us'
|
|
214
106
|
*/
|
|
215
|
-
|
|
216
|
-
return
|
|
217
|
-
|
|
218
|
-
switch (_a.label) {
|
|
219
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
220
|
-
var groupId = _a.groupId, participantId = _a.participantId;
|
|
221
|
-
return WPP.group.removeParticipants(groupId, participantId);
|
|
222
|
-
}, { groupId: groupId, participantId: participantId })];
|
|
223
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
};
|
|
107
|
+
async removeParticipant(groupId, participantId) {
|
|
108
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, participantId }) => WPP.group.removeParticipants(groupId, participantId), { groupId, participantId });
|
|
109
|
+
}
|
|
228
110
|
/**
|
|
229
111
|
* Adds participant to Group
|
|
230
112
|
* @category Group
|
|
231
113
|
* @param groupId Chat id ('0000000000-00000000@g.us')
|
|
232
114
|
* @param participantId Participant id'000000000000@c.us'
|
|
233
115
|
*/
|
|
234
|
-
|
|
235
|
-
return
|
|
236
|
-
|
|
237
|
-
switch (_a.label) {
|
|
238
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
239
|
-
var groupId = _a.groupId, participantId = _a.participantId;
|
|
240
|
-
return WPP.group.addParticipants(groupId, participantId);
|
|
241
|
-
}, { groupId: groupId, participantId: participantId })];
|
|
242
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
};
|
|
116
|
+
async addParticipant(groupId, participantId) {
|
|
117
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, participantId }) => WPP.group.addParticipants(groupId, participantId), { groupId, participantId });
|
|
118
|
+
}
|
|
247
119
|
/**
|
|
248
120
|
* Promotes participant as Admin in given group
|
|
249
121
|
* @category Group
|
|
250
122
|
* @param groupId Chat id ('0000000000-00000000@g.us')
|
|
251
123
|
* @param participantId Participant id'000000000000@c.us'
|
|
252
124
|
*/
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
258
|
-
var groupId = _a.groupId, participantId = _a.participantId;
|
|
259
|
-
return WPP.group.promoteParticipants(groupId, participantId);
|
|
260
|
-
}, { groupId: groupId, participantId: participantId })];
|
|
261
|
-
case 1:
|
|
262
|
-
_a.sent();
|
|
263
|
-
return [2 /*return*/, true];
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
};
|
|
125
|
+
async promoteParticipant(groupId, participantId) {
|
|
126
|
+
await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, participantId }) => WPP.group.promoteParticipants(groupId, participantId), { groupId, participantId });
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
268
129
|
/**
|
|
269
130
|
* Demotes admin privileges of participant
|
|
270
131
|
* @category Group
|
|
271
132
|
* @param groupId Chat id ('0000000000-00000000@g.us')
|
|
272
133
|
* @param participantId Participant id'000000000000@c.us'
|
|
273
134
|
*/
|
|
274
|
-
|
|
275
|
-
return
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
279
|
-
var groupId = _a.groupId, participantId = _a.participantId;
|
|
280
|
-
return WPP.group.demoteParticipants(groupId, participantId);
|
|
281
|
-
}, { groupId: groupId, participantId: participantId })];
|
|
282
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
};
|
|
135
|
+
async demoteParticipant(groupId, participantId) {
|
|
136
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, participantId }) => WPP.group.demoteParticipants(groupId, participantId), { groupId, participantId });
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
287
139
|
/**
|
|
288
140
|
* Retrieves group admins
|
|
289
141
|
* @category Group
|
|
290
142
|
* @param chatId Group/Chat id ('0000000000-00000000@g.us')
|
|
291
143
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
switch (_a.label) {
|
|
297
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (chatId) {
|
|
298
|
-
return Promise.resolve(WPP.group.getParticipants(chatId)).then(function (participants) { return participants.map(function (p) { return p.toJSON(); }); });
|
|
299
|
-
}, chatId)];
|
|
300
|
-
case 1:
|
|
301
|
-
participants = _a.sent();
|
|
302
|
-
return [2 /*return*/, participants.filter(function (p) { return p.isAdmin; }).map(function (p) { return p.id; })];
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
};
|
|
144
|
+
async getGroupAdmins(chatId) {
|
|
145
|
+
const participants = await (0, helpers_1.evaluateAndReturn)(this.page, (chatId) => Promise.resolve(WPP.group.getParticipants(chatId)).then((participants) => participants.map((p) => p.toJSON())), chatId);
|
|
146
|
+
return participants.filter((p) => p.isAdmin).map((p) => p.id);
|
|
147
|
+
}
|
|
307
148
|
/**
|
|
308
149
|
* Join a group with an invite code or link
|
|
309
150
|
* @category Group
|
|
@@ -311,21 +152,13 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
311
152
|
* @example joinGroup('https://chat.whatsapp.com/invite/CMJYfPFqRyE2GxrnkldYED')
|
|
312
153
|
* @example joinGroup('CMJYfPFqRyE2GxrnkldYED')
|
|
313
154
|
*/
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
inviteCode = inviteCode.replace('https://', '');
|
|
322
|
-
inviteCode = inviteCode.replace('http://', '');
|
|
323
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (inviteCode) { return WPP.group.join(inviteCode); }, inviteCode)];
|
|
324
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
};
|
|
155
|
+
async joinGroup(inviteCode) {
|
|
156
|
+
inviteCode = inviteCode.replace('chat.whatsapp.com/', '');
|
|
157
|
+
inviteCode = inviteCode.replace('invite/', '');
|
|
158
|
+
inviteCode = inviteCode.replace('https://', '');
|
|
159
|
+
inviteCode = inviteCode.replace('http://', '');
|
|
160
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, (inviteCode) => WPP.group.join(inviteCode), inviteCode);
|
|
161
|
+
}
|
|
329
162
|
/**
|
|
330
163
|
* Set group description (if allowed)
|
|
331
164
|
* @category Group
|
|
@@ -333,19 +166,9 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
333
166
|
* @param description New group description
|
|
334
167
|
* @returns empty object
|
|
335
168
|
*/
|
|
336
|
-
|
|
337
|
-
return
|
|
338
|
-
|
|
339
|
-
switch (_a.label) {
|
|
340
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
341
|
-
var groupId = _a.groupId, description = _a.description;
|
|
342
|
-
return WPP.group.setDescription(groupId, description);
|
|
343
|
-
}, { groupId: groupId, description: description })];
|
|
344
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
};
|
|
169
|
+
async setGroupDescription(groupId, description) {
|
|
170
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, description }) => WPP.group.setDescription(groupId, description), { groupId, description });
|
|
171
|
+
}
|
|
349
172
|
/**
|
|
350
173
|
* Set group subject (if allowed)
|
|
351
174
|
* @category Group
|
|
@@ -353,19 +176,9 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
353
176
|
* @param title New group subject
|
|
354
177
|
* @returns empty object
|
|
355
178
|
*/
|
|
356
|
-
|
|
357
|
-
return
|
|
358
|
-
|
|
359
|
-
switch (_a.label) {
|
|
360
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
361
|
-
var groupId = _a.groupId, title = _a.title;
|
|
362
|
-
return WPP.group.setSubject(groupId, title);
|
|
363
|
-
}, { groupId: groupId, title: title })];
|
|
364
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
};
|
|
179
|
+
async setGroupSubject(groupId, title) {
|
|
180
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, title }) => WPP.group.setSubject(groupId, title), { groupId, title });
|
|
181
|
+
}
|
|
369
182
|
/**
|
|
370
183
|
* Enable or disable group properties, see {@link GroupProperty for details}
|
|
371
184
|
* @category Group
|
|
@@ -374,19 +187,9 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
374
187
|
* @param value true or false
|
|
375
188
|
* @returns empty object
|
|
376
189
|
*/
|
|
377
|
-
|
|
378
|
-
return
|
|
379
|
-
|
|
380
|
-
switch (_a.label) {
|
|
381
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
382
|
-
var groupId = _a.groupId, property = _a.property, value = _a.value;
|
|
383
|
-
return WPP.group.setProperty(groupId, property, value);
|
|
384
|
-
}, { groupId: groupId, property: property, value: value })];
|
|
385
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
};
|
|
190
|
+
async setGroupProperty(groupId, property, value) {
|
|
191
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, property, value }) => WPP.group.setProperty(groupId, property, value), { groupId, property, value });
|
|
192
|
+
}
|
|
390
193
|
/**
|
|
391
194
|
* Set group icon
|
|
392
195
|
* @category Group
|
|
@@ -394,100 +197,63 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
394
197
|
* @param base64 Image in base64 ( data:image/jpeg;base64,..... )
|
|
395
198
|
* @returns empty object
|
|
396
199
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
case 4:
|
|
422
|
-
if (fileContent) {
|
|
423
|
-
base64 = fileContent;
|
|
424
|
-
}
|
|
425
|
-
_a.label = 5;
|
|
426
|
-
case 5:
|
|
427
|
-
if (!base64) {
|
|
428
|
-
error = new Error('Empty or invalid file or base64');
|
|
429
|
-
Object.assign(error, {
|
|
430
|
-
code: 'empty_file',
|
|
431
|
-
});
|
|
432
|
-
throw error;
|
|
433
|
-
}
|
|
434
|
-
mimeInfo = (0, helpers_1.base64MimeType)(base64);
|
|
435
|
-
if (!mimeInfo || !mimeInfo.includes('image')) {
|
|
436
|
-
error = new Error('Not an image, allowed formats png, jpeg and webp');
|
|
437
|
-
Object.assign(error, {
|
|
438
|
-
code: 'invalid_image',
|
|
439
|
-
});
|
|
440
|
-
throw error;
|
|
441
|
-
}
|
|
442
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
443
|
-
var groupId = _a.groupId, base64 = _a.base64;
|
|
444
|
-
return WPP.group.setIcon(groupId, base64);
|
|
445
|
-
}, { groupId: groupId, base64: base64 })];
|
|
446
|
-
case 6: return [2 /*return*/, _a.sent()];
|
|
447
|
-
}
|
|
200
|
+
async setGroupIcon(groupId, pathOrBase64) {
|
|
201
|
+
let base64 = '';
|
|
202
|
+
if (pathOrBase64.startsWith('data:')) {
|
|
203
|
+
base64 = pathOrBase64;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
let fileContent = await (0, helpers_1.downloadFileToBase64)(pathOrBase64, [
|
|
207
|
+
'image/gif',
|
|
208
|
+
'image/png',
|
|
209
|
+
'image/jpg',
|
|
210
|
+
'image/jpeg',
|
|
211
|
+
'image/webp',
|
|
212
|
+
]);
|
|
213
|
+
if (!fileContent) {
|
|
214
|
+
fileContent = await (0, helpers_1.fileToBase64)(pathOrBase64);
|
|
215
|
+
}
|
|
216
|
+
if (fileContent) {
|
|
217
|
+
base64 = fileContent;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (!base64) {
|
|
221
|
+
const error = new Error('Empty or invalid file or base64');
|
|
222
|
+
Object.assign(error, {
|
|
223
|
+
code: 'empty_file',
|
|
448
224
|
});
|
|
449
|
-
|
|
450
|
-
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
const mimeInfo = (0, helpers_1.base64MimeType)(base64);
|
|
228
|
+
if (!mimeInfo || !mimeInfo.includes('image')) {
|
|
229
|
+
const error = new Error('Not an image, allowed formats png, jpeg and webp');
|
|
230
|
+
Object.assign(error, {
|
|
231
|
+
code: 'invalid_image',
|
|
232
|
+
});
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, base64 }) => WPP.group.setIcon(groupId, base64), { groupId, base64 });
|
|
236
|
+
}
|
|
451
237
|
/**
|
|
452
238
|
* Set group subject (if allowed)
|
|
453
239
|
* @category Group
|
|
454
240
|
* @param groupId Group ID ('0000000000@g.us')
|
|
455
241
|
* @returns empty object
|
|
456
242
|
*/
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
throw new Error('Empty or invalid group id');
|
|
464
|
-
}
|
|
465
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
466
|
-
var groupId = _a.groupId;
|
|
467
|
-
return WPP.group.removeIcon(groupId);
|
|
468
|
-
}, { groupId: groupId })];
|
|
469
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
});
|
|
473
|
-
};
|
|
243
|
+
async removeGroupIcon(groupId) {
|
|
244
|
+
if (!groupId) {
|
|
245
|
+
throw new Error('Empty or invalid group id');
|
|
246
|
+
}
|
|
247
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId }) => WPP.group.removeIcon(groupId), { groupId });
|
|
248
|
+
}
|
|
474
249
|
/**
|
|
475
250
|
* Get the max number of participants for a group
|
|
476
251
|
* @category Group
|
|
477
252
|
* @returns number
|
|
478
253
|
*/
|
|
479
|
-
|
|
480
|
-
return
|
|
481
|
-
|
|
482
|
-
switch (_a.label) {
|
|
483
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
|
|
484
|
-
return WPP.group.getGroupSizeLimit();
|
|
485
|
-
})];
|
|
486
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
});
|
|
490
|
-
};
|
|
254
|
+
async getGroupSizeLimit() {
|
|
255
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, () => WPP.group.getGroupSizeLimit());
|
|
256
|
+
}
|
|
491
257
|
/**
|
|
492
258
|
* Approve a membership request to group
|
|
493
259
|
* @category Group
|
|
@@ -495,19 +261,9 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
495
261
|
* @param wid <number>@c.us
|
|
496
262
|
* @returns Promise
|
|
497
263
|
*/
|
|
498
|
-
|
|
499
|
-
return
|
|
500
|
-
|
|
501
|
-
switch (_a.label) {
|
|
502
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
503
|
-
var groupId = _a.groupId, membershipIds = _a.membershipIds;
|
|
504
|
-
return WPP.group.approve(groupId, membershipIds);
|
|
505
|
-
}, { groupId: groupId, membershipIds: membershipIds })];
|
|
506
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
});
|
|
510
|
-
};
|
|
264
|
+
async approveGroupMembershipRequest(groupId, membershipIds) {
|
|
265
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, membershipIds }) => WPP.group.approve(groupId, membershipIds), { groupId, membershipIds });
|
|
266
|
+
}
|
|
511
267
|
/**
|
|
512
268
|
* Reject a membership request to group
|
|
513
269
|
* @category Group
|
|
@@ -515,38 +271,17 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
515
271
|
* @param wid <number>@c.us
|
|
516
272
|
* @returns Promise
|
|
517
273
|
*/
|
|
518
|
-
|
|
519
|
-
return
|
|
520
|
-
|
|
521
|
-
switch (_a.label) {
|
|
522
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
523
|
-
var groupId = _a.groupId, membershipIds = _a.membershipIds;
|
|
524
|
-
return WPP.group.reject(groupId, membershipIds);
|
|
525
|
-
}, { groupId: groupId, membershipIds: membershipIds })];
|
|
526
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
};
|
|
274
|
+
async rejectGroupMembershipRequest(groupId, membershipIds) {
|
|
275
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId, membershipIds }) => WPP.group.reject(groupId, membershipIds), { groupId, membershipIds });
|
|
276
|
+
}
|
|
531
277
|
/**
|
|
532
278
|
* Retrieve a list of a membership approval requests
|
|
533
279
|
* @category Group
|
|
534
280
|
* @param groupId Group ID ('000000-000000@g.us')
|
|
535
281
|
* @returns Promise
|
|
536
282
|
*/
|
|
537
|
-
|
|
538
|
-
return
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
542
|
-
var groupId = _a.groupId;
|
|
543
|
-
return WPP.group.getMembershipRequests(groupId);
|
|
544
|
-
}, { groupId: groupId })];
|
|
545
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
});
|
|
549
|
-
};
|
|
550
|
-
return GroupLayer;
|
|
551
|
-
}(retriever_layer_1.RetrieverLayer));
|
|
283
|
+
async getGroupMembershipRequests(groupId) {
|
|
284
|
+
return await (0, helpers_1.evaluateAndReturn)(this.page, ({ groupId }) => WPP.group.getMembershipRequests(groupId), { groupId });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
552
287
|
exports.GroupLayer = GroupLayer;
|