@wppconnect-team/wppconnect 1.21.0 → 1.22.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 +6 -0
- package/dist/api/layers/host.layer.d.ts +1 -1
- package/dist/api/layers/host.layer.js +9 -5
- package/dist/config/create-config.d.ts +5 -0
- package/dist/config/create-config.js +2 -1
- package/dist/controllers/browser.d.ts +1 -1
- package/dist/controllers/browser.js +11 -3
- package/dist/utils/logger.js +1 -1
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# 1.22.0 (2023-02-19)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- Added deviceSyncTimeout option (close [#1551](https://github.com/wppconnect-team/wppconnect/issues/1551)) ([d4458e5](https://github.com/wppconnect-team/wppconnect/commit/d4458e5c3727b4d96e1595a6f5fa2d798a2bd69a))
|
|
6
|
+
|
|
1
7
|
# 1.21.0 (2023-02-03)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
|
@@ -24,7 +24,7 @@ export declare class HostLayer {
|
|
|
24
24
|
protected afterPageLoad(): Promise<void>;
|
|
25
25
|
protected afterPageScriptInjected(): Promise<void>;
|
|
26
26
|
protected tryAutoClose(): void;
|
|
27
|
-
protected startAutoClose(): void;
|
|
27
|
+
protected startAutoClose(time?: number | null): void;
|
|
28
28
|
protected cancelAutoClose(): void;
|
|
29
29
|
getQrCode(): Promise<ScrapQrcode>;
|
|
30
30
|
waitForQrCodeScan(catchQR?: CatchQRCallback): Promise<void>;
|
|
@@ -217,7 +217,7 @@ var HostLayer = /** @class */ (function () {
|
|
|
217
217
|
if (this.autoCloseInterval) {
|
|
218
218
|
this.cancelAutoClose();
|
|
219
219
|
}
|
|
220
|
-
if (this.options.autoClose > 0 &&
|
|
220
|
+
if ((this.options.autoClose > 0 || this.options.deviceSyncTimeout > 0) &&
|
|
221
221
|
!this.autoCloseInterval &&
|
|
222
222
|
!this.page.isClosed()) {
|
|
223
223
|
this.log('info', 'Closing the page');
|
|
@@ -229,10 +229,14 @@ var HostLayer = /** @class */ (function () {
|
|
|
229
229
|
catch (error) { }
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
|
-
HostLayer.prototype.startAutoClose = function () {
|
|
232
|
+
HostLayer.prototype.startAutoClose = function (time) {
|
|
233
233
|
var _this = this;
|
|
234
|
-
if (
|
|
235
|
-
|
|
234
|
+
if (time === void 0) { time = null; }
|
|
235
|
+
if (time === null || time === undefined) {
|
|
236
|
+
time = this.options.autoClose;
|
|
237
|
+
}
|
|
238
|
+
if (time > 0 && !this.autoCloseInterval) {
|
|
239
|
+
var seconds = Math.round(time / 1000);
|
|
236
240
|
this.log('info', "Auto close configured to ".concat(seconds, "s"));
|
|
237
241
|
var remain_1 = seconds;
|
|
238
242
|
this.autoCloseInterval = setInterval(function () {
|
|
@@ -422,7 +426,7 @@ var HostLayer = /** @class */ (function () {
|
|
|
422
426
|
case 8:
|
|
423
427
|
// Wait for interface update
|
|
424
428
|
_a.sent();
|
|
425
|
-
this.startAutoClose();
|
|
429
|
+
this.startAutoClose(this.options.deviceSyncTimeout);
|
|
426
430
|
this.log('http', 'Checking phone is connected...');
|
|
427
431
|
return [4 /*yield*/, this.waitForInChat()];
|
|
428
432
|
case 9:
|
|
@@ -62,6 +62,11 @@ export interface CreateConfig {
|
|
|
62
62
|
* @default 60000
|
|
63
63
|
*/
|
|
64
64
|
autoClose?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Automatically closes the wppconnect only when is syncing the device (default 180000 miliseconds, 3 minutes, if you want to turn it off, assign 0 or false)
|
|
67
|
+
* @default 180000 (3 minutes)
|
|
68
|
+
*/
|
|
69
|
+
deviceSyncTimeout?: number;
|
|
65
70
|
/**
|
|
66
71
|
* Wait for in chat to return a instance of {@link Whatsapp}
|
|
67
72
|
* @default false
|
|
@@ -15,11 +15,12 @@ exports.defaultOptions = {
|
|
|
15
15
|
disableWelcome: false,
|
|
16
16
|
updatesLog: true,
|
|
17
17
|
autoClose: 60000,
|
|
18
|
+
deviceSyncTimeout: 180000,
|
|
18
19
|
createPathFileToken: true,
|
|
19
20
|
waitForLogin: true,
|
|
20
21
|
logger: logger_1.defaultLogger,
|
|
21
22
|
tokenStore: 'file',
|
|
22
|
-
whatsappVersion: '2.
|
|
23
|
+
whatsappVersion: '2.2307.x',
|
|
23
24
|
deviceName: false,
|
|
24
25
|
linkPreviewApiServers: null,
|
|
25
26
|
disableGoogleAnalytics: true,
|
|
@@ -10,7 +10,7 @@ export declare function unregisterServiceWorker(page: Page): Promise<void>;
|
|
|
10
10
|
* @param page Página a ser injetada
|
|
11
11
|
* @param version Versão ou expressão semver
|
|
12
12
|
*/
|
|
13
|
-
export declare function setWhatsappVersion(page: Page, version: string): Promise<void>;
|
|
13
|
+
export declare function setWhatsappVersion(page: Page, version: string, log?: (level: LogLevel, message: string, meta?: object) => any): Promise<void>;
|
|
14
14
|
export declare function initWhatsapp(page: Page, token?: SessionToken, clear?: boolean, version?: string, log?: (level: LogLevel, message: string, meta?: object) => any): Promise<Page>;
|
|
15
15
|
export declare function onLoadingScreen(page: Page, onLoadingScreenCallBack?: LoadingScreenCallback): Promise<void>;
|
|
16
16
|
export declare function injectApi(page: Page, onLoadingScreenCallBack?: LoadingScreenCallback): Promise<void>;
|
|
@@ -148,13 +148,21 @@ exports.unregisterServiceWorker = unregisterServiceWorker;
|
|
|
148
148
|
* @param page Página a ser injetada
|
|
149
149
|
* @param version Versão ou expressão semver
|
|
150
150
|
*/
|
|
151
|
-
function setWhatsappVersion(page, version) {
|
|
151
|
+
function setWhatsappVersion(page, version, log) {
|
|
152
152
|
return __awaiter(this, void 0, void 0, function () {
|
|
153
153
|
var body;
|
|
154
154
|
return __generator(this, function (_a) {
|
|
155
155
|
switch (_a.label) {
|
|
156
156
|
case 0:
|
|
157
|
-
body =
|
|
157
|
+
body = null;
|
|
158
|
+
try {
|
|
159
|
+
body = waVersion.getPageContent(version);
|
|
160
|
+
}
|
|
161
|
+
catch (error) { }
|
|
162
|
+
if (!body) {
|
|
163
|
+
log === null || log === void 0 ? void 0 : log('error', "Version not available for ".concat(version, ", using latest as fallback"));
|
|
164
|
+
return [2 /*return*/];
|
|
165
|
+
}
|
|
158
166
|
return [4 /*yield*/, page.setRequestInterception(true)];
|
|
159
167
|
case 1:
|
|
160
168
|
_a.sent();
|
|
@@ -200,7 +208,7 @@ function initWhatsapp(page, token, clear, version, log) {
|
|
|
200
208
|
_a.sent();
|
|
201
209
|
if (!version) return [3 /*break*/, 5];
|
|
202
210
|
log === null || log === void 0 ? void 0 : log('verbose', "Setting WhatsApp WEB version to ".concat(version));
|
|
203
|
-
return [4 /*yield*/, setWhatsappVersion(page, version)];
|
|
211
|
+
return [4 /*yield*/, setWhatsappVersion(page, version, log)];
|
|
204
212
|
case 4:
|
|
205
213
|
_a.sent();
|
|
206
214
|
_a.label = 5;
|
package/dist/utils/logger.js
CHANGED
|
@@ -35,7 +35,7 @@ exports.formatLabelSession = (0, winston_1.format)(function (info, opts) {
|
|
|
35
35
|
return info;
|
|
36
36
|
});
|
|
37
37
|
exports.defaultLogger = (0, winston_1.createLogger)({
|
|
38
|
-
level: '
|
|
38
|
+
level: 'silly',
|
|
39
39
|
levels: winston_1.config.npm.levels,
|
|
40
40
|
format: winston_1.format.combine((0, exports.formatLabelSession)(), winston_1.format.colorize(), winston_1.format.padLevels(), winston_1.format.simple()),
|
|
41
41
|
// defaultMeta: { service: 'venon-bot' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wppconnect-team/wppconnect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.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",
|
|
@@ -58,47 +58,47 @@
|
|
|
58
58
|
"@babel/eslint-parser": "^7.19.1",
|
|
59
59
|
"@babel/eslint-plugin": "^7.19.1",
|
|
60
60
|
"@babel/preset-env": "^7.20.2",
|
|
61
|
-
"@commitlint/cli": "^17.4.
|
|
62
|
-
"@commitlint/config-conventional": "^17.4.
|
|
61
|
+
"@commitlint/cli": "^17.4.3",
|
|
62
|
+
"@commitlint/config-conventional": "^17.4.3",
|
|
63
63
|
"@commitlint/cz-commitlint": "^17.4.2",
|
|
64
64
|
"@knodes/typedoc-plugin-pages": "^0.23.1",
|
|
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.
|
|
68
|
+
"@types/node": "^18.13.0",
|
|
69
69
|
"@types/rimraf": "^3.0.2",
|
|
70
70
|
"@types/sharp": "^0.31.1",
|
|
71
71
|
"@types/shelljs": "^0.8.11",
|
|
72
72
|
"@types/tmp": "^0.2.3",
|
|
73
73
|
"@types/ws": "^8.5.4",
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
75
|
-
"@typescript-eslint/parser": "^5.
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
|
75
|
+
"@typescript-eslint/parser": "^5.52.0",
|
|
76
76
|
"babel-loader": "^9.1.2",
|
|
77
77
|
"commitizen": "^4.3.0",
|
|
78
78
|
"concurrently": "^7.6.0",
|
|
79
79
|
"conventional-changelog-cli": "^2.2.2",
|
|
80
|
-
"eslint": "^8.
|
|
80
|
+
"eslint": "^8.34.0",
|
|
81
81
|
"eslint-config-prettier": "^8.6.0",
|
|
82
82
|
"eslint-plugin-header": "^3.1.1",
|
|
83
83
|
"eslint-plugin-prettier": "^4.2.1",
|
|
84
84
|
"husky": "^8.0.3",
|
|
85
85
|
"mocha": "^10.2.0",
|
|
86
|
-
"prettier": "^2.8.
|
|
86
|
+
"prettier": "^2.8.4",
|
|
87
87
|
"pretty-quick": "^3.1.3",
|
|
88
88
|
"regenerator-runtime": "^0.13.11",
|
|
89
89
|
"release-it": "^15.6.0",
|
|
90
90
|
"shx": "^0.3.4",
|
|
91
91
|
"ts-node": "^10.9.1",
|
|
92
|
-
"typedoc": "^0.23.
|
|
92
|
+
"typedoc": "^0.23.25",
|
|
93
93
|
"typescript": "^4.9.5",
|
|
94
94
|
"webpack": "^5.75.0",
|
|
95
95
|
"webpack-cli": "^5.0.1"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@wppconnect/wa-js": "^2.19.
|
|
99
|
-
"@wppconnect/wa-version": "^1.1.
|
|
98
|
+
"@wppconnect/wa-js": "^2.19.1",
|
|
99
|
+
"@wppconnect/wa-version": "^1.1.257",
|
|
100
100
|
"atob": "^2.1.2",
|
|
101
|
-
"axios": "^1.3.
|
|
101
|
+
"axios": "^1.3.3",
|
|
102
102
|
"boxen": "^5.1.2",
|
|
103
103
|
"catch-exit": "^1.2.2",
|
|
104
104
|
"chalk": "~4.1.2",
|
|
@@ -107,10 +107,10 @@
|
|
|
107
107
|
"file-type": "~16.5.4",
|
|
108
108
|
"futoin-hkdf": "^1.5.1",
|
|
109
109
|
"latest-version": "^5.1.0",
|
|
110
|
-
"logform": "^2.
|
|
110
|
+
"logform": "^2.5.1",
|
|
111
111
|
"lookpath": "^1.2.2",
|
|
112
112
|
"mime-types": "^2.1.35",
|
|
113
|
-
"puppeteer": "^19.
|
|
113
|
+
"puppeteer": "^19.7.1",
|
|
114
114
|
"puppeteer-extra": "^3.3.4",
|
|
115
115
|
"puppeteer-extra-plugin-stealth": "^2.11.1",
|
|
116
116
|
"puppeteer-extra-plugin-user-data-dir": "^2.4.0",
|