@open-wa/wa-automate 4.28.2 → 4.28.3
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/dist/api/Client.d.ts
CHANGED
@@ -397,7 +397,7 @@ export declare class Client {
|
|
397
397
|
* Shuts down the page and browser
|
398
398
|
* @returns true
|
399
399
|
*/
|
400
|
-
kill(): Promise<boolean>;
|
400
|
+
kill(reason?: string): Promise<boolean>;
|
401
401
|
/**
|
402
402
|
* This is a convinient method to click the `Use Here` button in the WA web session.
|
403
403
|
*
|
package/dist/api/Client.js
CHANGED
@@ -267,7 +267,7 @@ class Client {
|
|
267
267
|
if ((_b = this._createConfig) === null || _b === void 0 ? void 0 : _b.killClientOnLogout) {
|
268
268
|
console.log("Session logged out. Killing client");
|
269
269
|
logging_1.log.warn("Session logged out. Killing client");
|
270
|
-
this.kill();
|
270
|
+
this.kill("LOGGED_OUT");
|
271
271
|
}
|
272
272
|
});
|
273
273
|
}
|
@@ -290,7 +290,7 @@ class Client {
|
|
290
290
|
if (!this._refreshing) {
|
291
291
|
console.log("Browser page has closed. Killing client");
|
292
292
|
logging_1.log.warn("Browser page has closed. Killing client");
|
293
|
-
this.kill();
|
293
|
+
this.kill("PAGE_CLOSED");
|
294
294
|
if ((_a = this._createConfig) === null || _a === void 0 ? void 0 : _a.killProcessOnBrowserClose)
|
295
295
|
process.exit();
|
296
296
|
}
|
@@ -1038,7 +1038,7 @@ class Client {
|
|
1038
1038
|
* Shuts down the page and browser
|
1039
1039
|
* @returns true
|
1040
1040
|
*/
|
1041
|
-
kill() {
|
1041
|
+
kill(reason = "MANUALLY_KILLED") {
|
1042
1042
|
var _a, _b, _c, _d, _e, _f, _g;
|
1043
1043
|
return __awaiter(this, void 0, void 0, function* () {
|
1044
1044
|
if (this._currentlyBeingKilled)
|
@@ -1046,6 +1046,9 @@ class Client {
|
|
1046
1046
|
this._currentlyBeingKilled = true;
|
1047
1047
|
console.log('Killing client. Shutting Down');
|
1048
1048
|
logging_1.log.info('Killing client. Shutting Down');
|
1049
|
+
(0, tools_1.processSendData)({
|
1050
|
+
reason
|
1051
|
+
});
|
1049
1052
|
const browser = yield ((_a = this === null || this === void 0 ? void 0 : this._page) === null || _a === void 0 ? void 0 : _a.browser());
|
1050
1053
|
const pid = (browser === null || browser === void 0 ? void 0 : browser.process()) ? (_b = browser === null || browser === void 0 ? void 0 : browser.process()) === null || _b === void 0 ? void 0 : _b.pid : null;
|
1051
1054
|
try {
|
package/dist/controllers/auth.js
CHANGED
@@ -131,8 +131,9 @@ function smartQr(waPage, config, spinner) {
|
|
131
131
|
qrNum++;
|
132
132
|
(0, tools_1.processSend)('ready');
|
133
133
|
if (config.qrMax && qrNum >= config.qrMax) {
|
134
|
-
spinner.info('QR Code limit reached, exiting');
|
135
|
-
yield (
|
134
|
+
spinner.info('QR Code limit reached, exiting...');
|
135
|
+
yield timeout(3000);
|
136
|
+
yield (0, browser_1.kill)(waPage, null, true, null, "QR_LIMIT_REACHED");
|
136
137
|
}
|
137
138
|
if (config.ezqr || config.inDocker) {
|
138
139
|
const host = 'https://qr.openwa.cloud/';
|
@@ -9,4 +9,4 @@ export declare function injectApi(page: Page): Promise<Page>;
|
|
9
9
|
/**
|
10
10
|
* @internal
|
11
11
|
*/
|
12
|
-
export declare const kill: (p: Page, b?: Browser, exit?: boolean, pid?: number) => Promise<void>;
|
12
|
+
export declare const kill: (p: Page, b?: Browser, exit?: boolean, pid?: number, reason?: string) => Promise<void>;
|
@@ -43,6 +43,7 @@ const pico_s3_1 = require("pico-s3");
|
|
43
43
|
const puppeteer = require('puppeteer-extra');
|
44
44
|
const tree_kill_1 = __importDefault(require("tree-kill"));
|
45
45
|
const logging_1 = require("../logging/logging");
|
46
|
+
const tools_1 = require("../utils/tools");
|
46
47
|
let browser;
|
47
48
|
function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth) {
|
48
49
|
var _a, _b, _c, _d, _e;
|
@@ -377,7 +378,11 @@ function getWAPage(browser) {
|
|
377
378
|
/**
|
378
379
|
* @internal
|
379
380
|
*/
|
380
|
-
const kill = (p, b, exit, pid) => __awaiter(void 0, void 0, void 0, function* () {
|
381
|
+
const kill = (p, b, exit, pid, reason = "LAUNCH_KILL") => __awaiter(void 0, void 0, void 0, function* () {
|
382
|
+
(0, tools_1.processSendData)({
|
383
|
+
type: "close",
|
384
|
+
reason
|
385
|
+
});
|
381
386
|
const killBrowser = (browser) => __awaiter(void 0, void 0, void 0, function* () {
|
382
387
|
if (!browser)
|
383
388
|
return;
|
package/dist/utils/tools.d.ts
CHANGED
@@ -25,3 +25,4 @@ export declare const getDUrl: (url: string, optionsOverride?: AxiosRequestConfig
|
|
25
25
|
*/
|
26
26
|
export declare const base64MimeType: (dUrl: DataURL) => string;
|
27
27
|
export declare const processSend: (message: string) => void;
|
28
|
+
export declare const processSendData: (data?: any) => boolean;
|
package/dist/utils/tools.js
CHANGED
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.processSend = exports.base64MimeType = exports.getDUrl = exports.isDataURL = exports.isBase64 = exports.camelize = exports.without = exports.getConfigFromProcessEnv = exports.smartUserAgent = void 0;
|
26
|
+
exports.processSendData = exports.processSend = exports.base64MimeType = exports.getDUrl = exports.isDataURL = exports.isBase64 = exports.camelize = exports.without = exports.getConfigFromProcessEnv = exports.smartUserAgent = void 0;
|
27
27
|
const axios_1 = __importDefault(require("axios"));
|
28
28
|
/**
|
29
29
|
* Use this to generate a more likely valid user agent. It makes sure it has the WA part and replaces any windows or linux os info with mac.
|
@@ -133,3 +133,10 @@ const processSend = (message) => {
|
|
133
133
|
return;
|
134
134
|
};
|
135
135
|
exports.processSend = processSend;
|
136
|
+
const processSendData = (data = {}) => {
|
137
|
+
return process.send({
|
138
|
+
type: 'process:msg',
|
139
|
+
data
|
140
|
+
});
|
141
|
+
};
|
142
|
+
exports.processSendData = processSendData;
|
package/package.json
CHANGED