@wppconnect-team/wppconnect 1.29.0 → 1.30.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 +8 -0
- package/dist/api/helpers/download-file.js +3 -3
- package/dist/api/layers/business.layer.js +24 -28
- package/dist/api/layers/controls.layer.js +28 -30
- package/dist/api/layers/group.layer.d.ts +1 -1
- package/dist/api/layers/group.layer.js +1 -3
- package/dist/api/layers/host.layer.d.ts +3 -1
- package/dist/api/layers/host.layer.js +59 -11
- package/dist/api/layers/retriever.layer.js +42 -46
- package/dist/api/layers/sender.layer.js +166 -184
- package/dist/api/layers/status.layer.d.ts +18 -2
- package/dist/api/layers/status.layer.js +15 -4
- package/dist/api/model/initializer.d.ts +8 -0
- package/dist/api/whatsapp.js +3 -3
- package/dist/config/create-config.d.ts +5 -1
- package/dist/config/puppeteer.config.js +2 -0
- package/dist/controllers/browser.js +3 -3
- package/dist/controllers/initializer.d.ts +2 -2
- package/dist/controllers/initializer.js +4 -2
- package/dist/lib/wapi/wapi.js +1 -1
- package/package.json +20 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## <small>1.30.1 (2024-03-11)</small>
|
|
2
|
+
|
|
3
|
+
- fix: Fixed login by qr code ([5ebd5f5](https://github.com/wppconnect-team/wppconnect/commit/5ebd5f5))
|
|
4
|
+
|
|
5
|
+
## 1.30.0 (2024-03-10)
|
|
6
|
+
|
|
7
|
+
- fix(deps): update dependency @wppconnect/wa-js to v3 (#2103) ([3f5a658](https://github.com/wppconnect-team/wppconnect/commit/3f5a658)), closes [#2103](https://github.com/wppconnect-team/wppconnect/issues/2103)
|
|
8
|
+
|
|
1
9
|
## 1.29.0 (2024-01-25)
|
|
2
10
|
|
|
3
11
|
- [FIX] version whatsapp web ([716cd97](https://github.com/wppconnect-team/wppconnect/commit/716cd97))
|
|
@@ -57,10 +57,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
57
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
58
|
exports.downloadFileToBase64 = void 0;
|
|
59
59
|
var axios_1 = __importDefault(require("axios"));
|
|
60
|
-
function downloadFileToBase64(
|
|
61
|
-
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
function downloadFileToBase64(_path_1) {
|
|
61
|
+
return __awaiter(this, arguments, void 0, function (_path, _mines) {
|
|
63
62
|
var reHttp, response, mimeType_1, isValidMime, content, error_1;
|
|
63
|
+
if (_mines === void 0) { _mines = []; }
|
|
64
64
|
return __generator(this, function (_a) {
|
|
65
65
|
switch (_a.label) {
|
|
66
66
|
case 0:
|
|
@@ -99,21 +99,19 @@ var BusinessLayer = /** @class */ (function (_super) {
|
|
|
99
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
100
|
var _this = this;
|
|
101
101
|
return __generator(this, function (_a) {
|
|
102
|
-
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
});
|
|
102
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
103
|
+
var _c, _d, _e, _f;
|
|
104
|
+
var id = _b.id;
|
|
105
|
+
return __generator(this, function (_g) {
|
|
106
|
+
switch (_g.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
_d = (_c = JSON).parse;
|
|
109
|
+
_f = (_e = JSON).stringify;
|
|
110
|
+
return [4 /*yield*/, WPP.contact.getBusinessProfile(id)];
|
|
111
|
+
case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
|
|
112
|
+
}
|
|
115
113
|
});
|
|
116
|
-
}, { id: id })];
|
|
114
|
+
}); }, { id: id })];
|
|
117
115
|
});
|
|
118
116
|
});
|
|
119
117
|
};
|
|
@@ -292,21 +290,19 @@ var BusinessLayer = /** @class */ (function (_super) {
|
|
|
292
290
|
var _this = this;
|
|
293
291
|
return __generator(this, function (_a) {
|
|
294
292
|
switch (_a.label) {
|
|
295
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
});
|
|
293
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
294
|
+
var _c, _d, _e, _f;
|
|
295
|
+
var options = _b.options;
|
|
296
|
+
return __generator(this, function (_g) {
|
|
297
|
+
switch (_g.label) {
|
|
298
|
+
case 0:
|
|
299
|
+
_d = (_c = JSON).parse;
|
|
300
|
+
_f = (_e = JSON).stringify;
|
|
301
|
+
return [4 /*yield*/, WPP.profile.editBusinessProfile(options)];
|
|
302
|
+
case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
|
|
303
|
+
}
|
|
308
304
|
});
|
|
309
|
-
}, { options: options })];
|
|
305
|
+
}); }, { options: options })];
|
|
310
306
|
case 1: return [2 /*return*/, _a.sent()];
|
|
311
307
|
}
|
|
312
308
|
});
|
|
@@ -157,9 +157,9 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
157
157
|
* @param option {boolean} true or false
|
|
158
158
|
* @returns boolean
|
|
159
159
|
*/
|
|
160
|
-
ControlsLayer.prototype.archiveChat = function (
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
ControlsLayer.prototype.archiveChat = function (chatId_1) {
|
|
161
|
+
return __awaiter(this, arguments, void 0, function (chatId, option) {
|
|
162
|
+
if (option === void 0) { option = true; }
|
|
163
163
|
return __generator(this, function (_a) {
|
|
164
164
|
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
165
165
|
var chatId = _a.chatId, option = _a.option;
|
|
@@ -205,10 +205,10 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
205
205
|
* @param keepStarred Keep starred messages
|
|
206
206
|
* @returns boolean
|
|
207
207
|
*/
|
|
208
|
-
ControlsLayer.prototype.clearChat = function (
|
|
209
|
-
|
|
210
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
ControlsLayer.prototype.clearChat = function (chatId_1) {
|
|
209
|
+
return __awaiter(this, arguments, void 0, function (chatId, keepStarred) {
|
|
211
210
|
var result;
|
|
211
|
+
if (keepStarred === void 0) { keepStarred = true; }
|
|
212
212
|
return __generator(this, function (_a) {
|
|
213
213
|
switch (_a.label) {
|
|
214
214
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
@@ -229,10 +229,10 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
229
229
|
* @param messageId The specific message id of the message to be deleted
|
|
230
230
|
* @param onlyLocal If it should only delete locally (message remains on the other recipienct's phone). Defaults to false.
|
|
231
231
|
*/
|
|
232
|
-
ControlsLayer.prototype.deleteMessage = function (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
ControlsLayer.prototype.deleteMessage = function (chatId_1, messageId_1) {
|
|
233
|
+
return __awaiter(this, arguments, void 0, function (chatId, messageId, onlyLocal, deleteMediaInDevice) {
|
|
234
|
+
if (onlyLocal === void 0) { onlyLocal = false; }
|
|
235
|
+
if (deleteMediaInDevice === void 0) { deleteMediaInDevice = true; }
|
|
236
236
|
return __generator(this, function (_a) {
|
|
237
237
|
switch (_a.label) {
|
|
238
238
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
@@ -259,11 +259,11 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
259
259
|
* client.editMessage('true_<number>@c.us_messageId', 'new Text For Simple Message');
|
|
260
260
|
* ```
|
|
261
261
|
*/
|
|
262
|
-
ControlsLayer.prototype.editMessage = function (
|
|
263
|
-
|
|
264
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
+
ControlsLayer.prototype.editMessage = function (msgId_1, newText_1) {
|
|
263
|
+
return __awaiter(this, arguments, void 0, function (msgId, newText, options) {
|
|
265
264
|
var editResult, result;
|
|
266
265
|
var _this = this;
|
|
266
|
+
if (options === void 0) { options = {}; }
|
|
267
267
|
return __generator(this, function (_a) {
|
|
268
268
|
switch (_a.label) {
|
|
269
269
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
@@ -272,21 +272,19 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
272
272
|
}, { msgId: msgId, newText: newText, options: options })];
|
|
273
273
|
case 1:
|
|
274
274
|
editResult = _a.sent();
|
|
275
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
});
|
|
275
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
276
|
+
var _c, _d, _e, _f;
|
|
277
|
+
var messageId = _b.messageId;
|
|
278
|
+
return __generator(this, function (_g) {
|
|
279
|
+
switch (_g.label) {
|
|
280
|
+
case 0:
|
|
281
|
+
_d = (_c = JSON).parse;
|
|
282
|
+
_f = (_e = JSON).stringify;
|
|
283
|
+
return [4 /*yield*/, WAPI.getMessageById(messageId)];
|
|
284
|
+
case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
|
|
285
|
+
}
|
|
288
286
|
});
|
|
289
|
-
}, { messageId: editResult.id })];
|
|
287
|
+
}); }, { messageId: editResult.id })];
|
|
290
288
|
case 2:
|
|
291
289
|
result = (_a.sent());
|
|
292
290
|
if (result.body !== newText)
|
|
@@ -302,9 +300,9 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
302
300
|
* @param messagesId The specific message id of the message to be starred
|
|
303
301
|
* @param star Add or remove star of the message. Defaults to true.
|
|
304
302
|
*/
|
|
305
|
-
ControlsLayer.prototype.starMessage = function (
|
|
306
|
-
|
|
307
|
-
|
|
303
|
+
ControlsLayer.prototype.starMessage = function (messagesId_1) {
|
|
304
|
+
return __awaiter(this, arguments, void 0, function (messagesId, star) {
|
|
305
|
+
if (star === void 0) { star = true; }
|
|
308
306
|
return __generator(this, function (_a) {
|
|
309
307
|
switch (_a.label) {
|
|
310
308
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
@@ -93,7 +93,7 @@ export declare class GroupLayer extends RetrieverLayer {
|
|
|
93
93
|
* @param groupId Chat id ('0000000000-00000000@g.us')
|
|
94
94
|
* @param participantId Participant id'000000000000@c.us'
|
|
95
95
|
*/
|
|
96
|
-
removeParticipant(groupId: string, participantId: string | string[]): Promise<
|
|
96
|
+
removeParticipant(groupId: string, participantId: string | string[]): Promise<void>;
|
|
97
97
|
/**
|
|
98
98
|
* Adds participant to Group
|
|
99
99
|
* @category Group
|
|
@@ -217,9 +217,7 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
217
217
|
var groupId = _a.groupId, participantId = _a.participantId;
|
|
218
218
|
return WPP.group.removeParticipants(groupId, participantId);
|
|
219
219
|
}, { groupId: groupId, participantId: participantId })];
|
|
220
|
-
case 1:
|
|
221
|
-
_a.sent();
|
|
222
|
-
return [2 /*return*/, true];
|
|
220
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
223
221
|
}
|
|
224
222
|
});
|
|
225
223
|
});
|
|
@@ -3,7 +3,7 @@ import { Page } from 'puppeteer';
|
|
|
3
3
|
import { Logger } from 'winston';
|
|
4
4
|
import { CreateConfig } from '../../config/create-config';
|
|
5
5
|
import { LogLevel } from '../../utils/logger';
|
|
6
|
-
import { CatchQRCallback, HostDevice, LoadingScreenCallback, StatusFindCallback } from '../model';
|
|
6
|
+
import { CatchQRCallback, HostDevice, LinkByCodeCallback, LoadingScreenCallback, StatusFindCallback } from '../model';
|
|
7
7
|
import { SocketState } from '../model/enum';
|
|
8
8
|
import { ScrapQrcode } from '../model/qrcode';
|
|
9
9
|
export declare class HostLayer {
|
|
@@ -24,6 +24,7 @@ export declare class HostLayer {
|
|
|
24
24
|
catchQR?: CatchQRCallback;
|
|
25
25
|
statusFind?: StatusFindCallback;
|
|
26
26
|
onLoadingScreen?: LoadingScreenCallback;
|
|
27
|
+
catchLinkCode?: LinkByCodeCallback;
|
|
27
28
|
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
28
29
|
protected log(level: LogLevel, message: string, meta?: object): void;
|
|
29
30
|
protected initialize(): Promise<void>;
|
|
@@ -32,6 +33,7 @@ export declare class HostLayer {
|
|
|
32
33
|
start(): Promise<void>;
|
|
33
34
|
protected checkStart(): Promise<void>;
|
|
34
35
|
protected checkQrCode(): Promise<void>;
|
|
36
|
+
protected loginByCode(phone: string): Promise<void>;
|
|
35
37
|
protected checkInChat(): Promise<void>;
|
|
36
38
|
protected tryAutoClose(): void;
|
|
37
39
|
protected startAutoClose(time?: number | null): void;
|
|
@@ -86,6 +86,7 @@ var HostLayer = /** @class */ (function () {
|
|
|
86
86
|
this.catchQR = null;
|
|
87
87
|
this.statusFind = null;
|
|
88
88
|
this.onLoadingScreen = null;
|
|
89
|
+
this.catchLinkCode = null;
|
|
89
90
|
this.session = session;
|
|
90
91
|
this.options = __assign(__assign({}, create_config_1.defaultOptions), options);
|
|
91
92
|
this.logger = this.options.logger || logger_1.defaultLogger;
|
|
@@ -171,8 +172,8 @@ var HostLayer = /** @class */ (function () {
|
|
|
171
172
|
(0, helpers_1.evaluateAndReturn)(this.page, function () {
|
|
172
173
|
WPP.on('conn.main_ready', window.checkInChat);
|
|
173
174
|
}).catch(function () { return null; });
|
|
174
|
-
this.checkQrCode();
|
|
175
175
|
this.checkInChat();
|
|
176
|
+
this.checkQrCode();
|
|
176
177
|
return [2 /*return*/];
|
|
177
178
|
});
|
|
178
179
|
});
|
|
@@ -193,8 +194,14 @@ var HostLayer = /** @class */ (function () {
|
|
|
193
194
|
return [4 /*yield*/, this.page.exposeFunction('checkQrCode', function () { return _this.checkQrCode(); })];
|
|
194
195
|
case 2:
|
|
195
196
|
_a.sent();
|
|
197
|
+
/*await this.page.exposeFunction('loginByCode', (phone: string) =>
|
|
198
|
+
this.loginByCode(phone)
|
|
199
|
+
);*/
|
|
196
200
|
return [4 /*yield*/, this.page.exposeFunction('checkInChat', function () { return _this.checkInChat(); })];
|
|
197
201
|
case 3:
|
|
202
|
+
/*await this.page.exposeFunction('loginByCode', (phone: string) =>
|
|
203
|
+
this.loginByCode(phone)
|
|
204
|
+
);*/
|
|
198
205
|
_a.sent();
|
|
199
206
|
this.checkStartInterval = setInterval(function () { return _this.checkStart(); }, 5000);
|
|
200
207
|
this.page.on('close', function () {
|
|
@@ -216,9 +223,9 @@ var HostLayer = /** @class */ (function () {
|
|
|
216
223
|
});
|
|
217
224
|
};
|
|
218
225
|
HostLayer.prototype.checkQrCode = function () {
|
|
219
|
-
var _a;
|
|
220
226
|
return __awaiter(this, void 0, void 0, function () {
|
|
221
227
|
var needScan, result, qr;
|
|
228
|
+
var _a;
|
|
222
229
|
return __generator(this, function (_b) {
|
|
223
230
|
switch (_b.label) {
|
|
224
231
|
case 0: return [4 /*yield*/, (0, auth_1.needsToScan)(this.page).catch(function () { return null; })];
|
|
@@ -235,6 +242,9 @@ var HostLayer = /** @class */ (function () {
|
|
|
235
242
|
if (!(result === null || result === void 0 ? void 0 : result.urlCode) || this.urlCode === result.urlCode) {
|
|
236
243
|
return [2 /*return*/];
|
|
237
244
|
}
|
|
245
|
+
if (typeof this.options.phoneNumber === 'string') {
|
|
246
|
+
return [2 /*return*/, this.loginByCode(this.options.phoneNumber)];
|
|
247
|
+
}
|
|
238
248
|
this.urlCode = result.urlCode;
|
|
239
249
|
this.attempt++;
|
|
240
250
|
qr = '';
|
|
@@ -256,10 +266,44 @@ var HostLayer = /** @class */ (function () {
|
|
|
256
266
|
});
|
|
257
267
|
});
|
|
258
268
|
};
|
|
269
|
+
HostLayer.prototype.loginByCode = function (phone) {
|
|
270
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
271
|
+
var code;
|
|
272
|
+
var _this = this;
|
|
273
|
+
var _a;
|
|
274
|
+
return __generator(this, function (_b) {
|
|
275
|
+
switch (_b.label) {
|
|
276
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
277
|
+
var _c, _d, _e, _f;
|
|
278
|
+
var phone = _b.phone;
|
|
279
|
+
return __generator(this, function (_g) {
|
|
280
|
+
switch (_g.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
_d = (_c = JSON).parse;
|
|
283
|
+
_f = (_e = JSON).stringify;
|
|
284
|
+
return [4 /*yield*/, WPP.conn.genLinkDeviceCodeForPhoneNumber(phone)];
|
|
285
|
+
case 1: return [2 /*return*/, _d.apply(_c, [_f.apply(_e, [_g.sent()])])];
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}); }, { phone: phone })];
|
|
289
|
+
case 1:
|
|
290
|
+
code = _b.sent();
|
|
291
|
+
if (this.options.logQR) {
|
|
292
|
+
this.log('info', "Waiting for Login By Code (Code: ".concat(code, ")\n"));
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
this.log('verbose', "Waiting for Login By Code");
|
|
296
|
+
}
|
|
297
|
+
(_a = this.catchLinkCode) === null || _a === void 0 ? void 0 : _a.call(this, code);
|
|
298
|
+
return [2 /*return*/];
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
};
|
|
259
303
|
HostLayer.prototype.checkInChat = function () {
|
|
260
|
-
var _a;
|
|
261
304
|
return __awaiter(this, void 0, void 0, function () {
|
|
262
305
|
var inChat;
|
|
306
|
+
var _a;
|
|
263
307
|
return __generator(this, function (_b) {
|
|
264
308
|
switch (_b.label) {
|
|
265
309
|
case 0: return [4 /*yield*/, (0, auth_1.isInsideChat)(this.page).catch(function () { return null; })];
|
|
@@ -409,9 +453,9 @@ var HostLayer = /** @class */ (function () {
|
|
|
409
453
|
});
|
|
410
454
|
};
|
|
411
455
|
HostLayer.prototype.waitForLogin = function () {
|
|
412
|
-
var _a, _b, _c, _d, _e, _f;
|
|
413
456
|
return __awaiter(this, void 0, void 0, function () {
|
|
414
457
|
var authenticated, inChat;
|
|
458
|
+
var _a, _b, _c, _d, _e, _f;
|
|
415
459
|
return __generator(this, function (_g) {
|
|
416
460
|
switch (_g.label) {
|
|
417
461
|
case 0:
|
|
@@ -425,12 +469,16 @@ var HostLayer = /** @class */ (function () {
|
|
|
425
469
|
authenticated = _g.sent();
|
|
426
470
|
this.startAutoClose();
|
|
427
471
|
if (!(authenticated === false)) return [3 /*break*/, 6];
|
|
428
|
-
this.log('http',
|
|
472
|
+
this.log('http', typeof this.options.phoneNumber === 'string'
|
|
473
|
+
? 'Waiting for Login by Code...'
|
|
474
|
+
: 'Waiting for QRCode Scan...');
|
|
429
475
|
(_a = this.statusFind) === null || _a === void 0 ? void 0 : _a.call(this, 'notLogged', this.session);
|
|
430
476
|
return [4 /*yield*/, this.waitForQrCodeScan()];
|
|
431
477
|
case 3:
|
|
432
478
|
_g.sent();
|
|
433
|
-
this.log('http',
|
|
479
|
+
this.log('http', typeof this.options.phoneNumber === 'string'
|
|
480
|
+
? 'Checking Login by Code status...'
|
|
481
|
+
: 'Checking QRCode status...');
|
|
434
482
|
// Wait for interface update
|
|
435
483
|
return [4 /*yield*/, (0, sleep_1.sleep)(200)];
|
|
436
484
|
case 4:
|
|
@@ -444,11 +492,11 @@ var HostLayer = /** @class */ (function () {
|
|
|
444
492
|
(_b = this.statusFind) === null || _b === void 0 ? void 0 : _b.call(this, 'qrReadError', this.session);
|
|
445
493
|
}
|
|
446
494
|
else if (authenticated) {
|
|
447
|
-
this.log('http', '
|
|
495
|
+
this.log('http', 'Login with success');
|
|
448
496
|
(_c = this.statusFind) === null || _c === void 0 ? void 0 : _c.call(this, 'qrReadSuccess', this.session);
|
|
449
497
|
}
|
|
450
498
|
else {
|
|
451
|
-
this.log('warn', '
|
|
499
|
+
this.log('warn', 'Login Fail');
|
|
452
500
|
(_d = this.statusFind) === null || _d === void 0 ? void 0 : _d.call(this, 'qrReadFail', this.session);
|
|
453
501
|
this.tryAutoClose();
|
|
454
502
|
throw 'Failed to read the QRCode';
|
|
@@ -645,9 +693,9 @@ var HostLayer = /** @class */ (function () {
|
|
|
645
693
|
* @category Host
|
|
646
694
|
* @param interval interval number in miliseconds
|
|
647
695
|
*/
|
|
648
|
-
HostLayer.prototype.startPhoneWatchdog = function (
|
|
649
|
-
|
|
650
|
-
|
|
696
|
+
HostLayer.prototype.startPhoneWatchdog = function () {
|
|
697
|
+
return __awaiter(this, arguments, void 0, function (interval) {
|
|
698
|
+
if (interval === void 0) { interval = 15000; }
|
|
651
699
|
return __generator(this, function (_a) {
|
|
652
700
|
switch (_a.label) {
|
|
653
701
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (interval) { return WAPI.startPhoneWatchdog(interval); }, interval)];
|
|
@@ -185,9 +185,9 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
185
185
|
* @returns array of [Chat]
|
|
186
186
|
* @deprecated Deprecated in favor of listChats.
|
|
187
187
|
*/
|
|
188
|
-
RetrieverLayer.prototype.getAllChats = function (
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
RetrieverLayer.prototype.getAllChats = function () {
|
|
189
|
+
return __awaiter(this, arguments, void 0, function (withNewMessageOnly) {
|
|
190
|
+
if (withNewMessageOnly === void 0) { withNewMessageOnly = false; }
|
|
191
191
|
return __generator(this, function (_a) {
|
|
192
192
|
this.logger.warn('Deprecated: This function [getAllChats] is deprecated in favor of the listChats function. Please update your code accordingly.');
|
|
193
193
|
if (withNewMessageOnly) {
|
|
@@ -236,21 +236,19 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
236
236
|
var _this = this;
|
|
237
237
|
return __generator(this, function (_a) {
|
|
238
238
|
switch (_a.label) {
|
|
239
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
});
|
|
239
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
240
|
+
var chats, serialized;
|
|
241
|
+
var options = _b.options;
|
|
242
|
+
return __generator(this, function (_c) {
|
|
243
|
+
switch (_c.label) {
|
|
244
|
+
case 0: return [4 /*yield*/, WPP.chat.list(options)];
|
|
245
|
+
case 1:
|
|
246
|
+
chats = _c.sent();
|
|
247
|
+
serialized = chats.map(function (c) { return WAPI._serializeChatObj(c); });
|
|
248
|
+
return [2 /*return*/, serialized];
|
|
249
|
+
}
|
|
252
250
|
});
|
|
253
|
-
}, { options: options })];
|
|
251
|
+
}); }, { options: options })];
|
|
254
252
|
case 1: return [2 /*return*/, _a.sent()];
|
|
255
253
|
}
|
|
256
254
|
});
|
|
@@ -280,9 +278,9 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
280
278
|
* @returns array of [Chat]
|
|
281
279
|
* @deprecated Deprecated in favor of listChats.
|
|
282
280
|
*/
|
|
283
|
-
RetrieverLayer.prototype.getAllChatsWithMessages = function (
|
|
284
|
-
|
|
285
|
-
|
|
281
|
+
RetrieverLayer.prototype.getAllChatsWithMessages = function () {
|
|
282
|
+
return __awaiter(this, arguments, void 0, function (withNewMessageOnly) {
|
|
283
|
+
if (withNewMessageOnly === void 0) { withNewMessageOnly = false; }
|
|
286
284
|
return __generator(this, function (_a) {
|
|
287
285
|
this.logger.warn('Deprecated: This function [getAllChatsWithMessages] is deprecated in favor of the listChats function. Please update your code accordingly.');
|
|
288
286
|
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (withNewMessageOnly) {
|
|
@@ -299,34 +297,32 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
299
297
|
* @returns array of groups
|
|
300
298
|
* @deprecated Deprecated in favor of listChats.
|
|
301
299
|
*/
|
|
302
|
-
RetrieverLayer.prototype.getAllGroups = function (
|
|
303
|
-
|
|
304
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
300
|
+
RetrieverLayer.prototype.getAllGroups = function () {
|
|
301
|
+
return __awaiter(this, arguments, void 0, function (withNewMessagesOnly) {
|
|
305
302
|
var _this = this;
|
|
303
|
+
if (withNewMessagesOnly === void 0) { withNewMessagesOnly = false; }
|
|
306
304
|
return __generator(this, function (_a) {
|
|
307
305
|
switch (_a.label) {
|
|
308
306
|
case 0:
|
|
309
307
|
this.logger.warn('Deprecated: This function [getAllGroups] is deprecated in favor of the listChats function. Please update your code accordingly.');
|
|
310
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
311
|
-
var
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
});
|
|
308
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
309
|
+
var chats, groups;
|
|
310
|
+
var withNewMessagesOnly = _b.withNewMessagesOnly;
|
|
311
|
+
return __generator(this, function (_c) {
|
|
312
|
+
switch (_c.label) {
|
|
313
|
+
case 0: return [4 /*yield*/, WPP.chat.list({
|
|
314
|
+
onlyGroups: true,
|
|
315
|
+
onlyWithUnreadMessage: withNewMessagesOnly,
|
|
316
|
+
})];
|
|
317
|
+
case 1:
|
|
318
|
+
chats = _c.sent();
|
|
319
|
+
return [4 /*yield*/, Promise.all(chats.map(function (c) { return WPP.group.ensureGroup(c.id); }))];
|
|
320
|
+
case 2:
|
|
321
|
+
groups = _c.sent();
|
|
322
|
+
return [2 /*return*/, groups.map(function (g) { return WAPI._serializeChatObj(g); })];
|
|
323
|
+
}
|
|
328
324
|
});
|
|
329
|
-
}, { withNewMessagesOnly: withNewMessagesOnly })];
|
|
325
|
+
}); }, { withNewMessagesOnly: withNewMessagesOnly })];
|
|
330
326
|
case 1: return [2 /*return*/, _a.sent()];
|
|
331
327
|
}
|
|
332
328
|
});
|
|
@@ -567,10 +563,10 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
567
563
|
* @param includeNotifications
|
|
568
564
|
* @returns any
|
|
569
565
|
*/
|
|
570
|
-
RetrieverLayer.prototype.loadAndGetAllMessagesInChat = function (
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
566
|
+
RetrieverLayer.prototype.loadAndGetAllMessagesInChat = function (chatId_1) {
|
|
567
|
+
return __awaiter(this, arguments, void 0, function (chatId, includeMe, includeNotifications) {
|
|
568
|
+
if (includeMe === void 0) { includeMe = false; }
|
|
569
|
+
if (includeNotifications === void 0) { includeNotifications = false; }
|
|
574
570
|
return __generator(this, function (_a) {
|
|
575
571
|
switch (_a.label) {
|
|
576
572
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|