@open-wa/wa-automate 4.28.7 → 4.28.8
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/controllers/auth.js
CHANGED
@@ -115,6 +115,8 @@ function smartQr(waPage, config, spinner) {
|
|
115
115
|
return true;
|
116
116
|
let hash = 'START';
|
117
117
|
const grabAndEmit = (qrData) => __awaiter(this, void 0, void 0, function* () {
|
118
|
+
if (!qrNum && browser_1.BROWSER_START_TS)
|
119
|
+
spinner.info(`First QR: ${Date.now() - browser_1.BROWSER_START_TS} ms`);
|
118
120
|
if (qrData) {
|
119
121
|
if (!config.qrLogSkip)
|
120
122
|
qrcode.generate(qrData, { small: true });
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Browser, Page } from 'puppeteer';
|
2
2
|
import { Spin } from './events';
|
3
3
|
import { ConfigObject } from '../api/model';
|
4
|
+
export declare let BROWSER_START_TS: number;
|
4
5
|
export declare function initPage(sessionId?: string, config?: ConfigObject, customUserAgent?: string, spinner?: Spin, _page?: Page, skipAuth?: boolean): Promise<Page>;
|
5
6
|
export declare const deleteSessionData: (config: ConfigObject) => boolean;
|
6
7
|
export declare const getSessionDataFilePath: (sessionId: string, config: ConfigObject) => string | boolean;
|
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
32
32
|
};
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
34
|
-
exports.kill = exports.injectApi = exports.addScript = exports.getSessionDataFilePath = exports.deleteSessionData = exports.initPage = void 0;
|
34
|
+
exports.kill = exports.injectApi = exports.addScript = exports.getSessionDataFilePath = exports.deleteSessionData = exports.initPage = exports.BROWSER_START_TS = void 0;
|
35
35
|
const path = __importStar(require("path"));
|
36
36
|
const fs = __importStar(require("fs"));
|
37
37
|
const death_1 = __importDefault(require("death"));
|
@@ -45,6 +45,7 @@ const tree_kill_1 = __importDefault(require("tree-kill"));
|
|
45
45
|
const logging_1 = require("../logging/logging");
|
46
46
|
const tools_1 = require("../utils/tools");
|
47
47
|
let browser;
|
48
|
+
exports.BROWSER_START_TS = 0;
|
48
49
|
function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth) {
|
49
50
|
var _a, _b, _c, _d, _e;
|
50
51
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -58,7 +59,7 @@ function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth)
|
|
58
59
|
let waPage = _page;
|
59
60
|
if (!waPage) {
|
60
61
|
spinner === null || spinner === void 0 ? void 0 : spinner.info('Launching Browser');
|
61
|
-
browser = yield initBrowser(sessionId, config);
|
62
|
+
browser = yield initBrowser(sessionId, config, spinner);
|
62
63
|
waPage = yield getWAPage(browser);
|
63
64
|
}
|
64
65
|
spinner === null || spinner === void 0 ? void 0 : spinner.info('Setting Up Page');
|
@@ -281,7 +282,7 @@ function injectApi(page) {
|
|
281
282
|
});
|
282
283
|
}
|
283
284
|
exports.injectApi = injectApi;
|
284
|
-
function initBrowser(sessionId, config = {}) {
|
285
|
+
function initBrowser(sessionId, config = {}, spinner) {
|
285
286
|
var _a, _b, _c;
|
286
287
|
return __awaiter(this, void 0, void 0, function* () {
|
287
288
|
if (config === null || config === void 0 ? void 0 : config.raspi) {
|
@@ -327,13 +328,17 @@ function initBrowser(sessionId, config = {}) {
|
|
327
328
|
if (config === null || config === void 0 ? void 0 : config.multiDevice) {
|
328
329
|
args = args.filter(x => x != '--incognito');
|
329
330
|
config["userDataDir"] = config["userDataDir"] || `${(config === null || config === void 0 ? void 0 : config.inDocker) ? '/sessions' : (config === null || config === void 0 ? void 0 : config.sessionDataPath) || '.'}/_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
|
331
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info('MD Enabled, turning off incognito mode.');
|
332
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info(`Data dir: ${config["userDataDir"]}`);
|
330
333
|
}
|
331
334
|
if (config === null || config === void 0 ? void 0 : config.corsFix)
|
332
335
|
args.push('--disable-web-security');
|
333
336
|
if (config["userDataDir"] && !fs.existsSync(config["userDataDir"])) {
|
337
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info(`Data dir doesnt exist, creating...: ${config["userDataDir"]}`);
|
334
338
|
fs.mkdirSync(config["userDataDir"], { recursive: true });
|
335
339
|
}
|
336
340
|
const browser = (config === null || config === void 0 ? void 0 : config.browserWSEndpoint) ? yield puppeteer.connect(Object.assign({}, config)) : yield puppeteer.launch(Object.assign(Object.assign({ headless: true, args }, config), { devtools: false }));
|
341
|
+
exports.BROWSER_START_TS = Date.now();
|
337
342
|
//devtools
|
338
343
|
if (config === null || config === void 0 ? void 0 : config.devtools) {
|
339
344
|
const _dt = yield Promise.resolve().then(() => __importStar(require('puppeteer-extra-plugin-devtools')));
|
@@ -352,11 +357,10 @@ function initBrowser(sessionId, config = {}) {
|
|
352
357
|
// const tunnel = await devtools.createTunnel(browser);
|
353
358
|
const tunnel = config.devtools == 'local' ? devtools.getLocalDevToolsUrl(browser) : (yield devtools.createTunnel(browser)).url;
|
354
359
|
const l = `\ndevtools URL: ${typeof config.devtools == 'object' ? Object.assign(Object.assign({}, config.devtools), { tunnel }) : tunnel}`;
|
355
|
-
|
356
|
-
logging_1.log.info(l);
|
360
|
+
spinner.info(l);
|
357
361
|
}
|
358
362
|
catch (error) {
|
359
|
-
|
363
|
+
spinner.fail(error);
|
360
364
|
logging_1.log.error("initBrowser -> error", error);
|
361
365
|
}
|
362
366
|
}
|
@@ -171,7 +171,7 @@ function create(config = {}) {
|
|
171
171
|
config.multiDevice = true;
|
172
172
|
}
|
173
173
|
if ((config === null || config === void 0 ? void 0 : config.multiDevice) && (config === null || config === void 0 ? void 0 : config.chromiumArgs))
|
174
|
-
spinner.info(`Using custom chromium args with multi device will cause issues! Please remove
|
174
|
+
spinner.info(`Using custom chromium args with multi device will cause issues! Please remove them: ${config === null || config === void 0 ? void 0 : config.chromiumArgs}`);
|
175
175
|
if ((config === null || config === void 0 ? void 0 : config.multiDevice) && !(config === null || config === void 0 ? void 0 : config.useChrome))
|
176
176
|
spinner.info(`It is recommended to set useChrome: true or use the --use-chrome flag if you are experiencing issues with Multi device support`);
|
177
177
|
waPage = yield (0, browser_1.initPage)(sessionId, config, customUserAgent, spinner);
|
package/package.json
CHANGED