@open-wa/wa-automate 4.31.8 → 4.31.9
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.js
CHANGED
@@ -346,7 +346,8 @@ class Client {
|
|
346
346
|
const START_TIME = Date.now();
|
347
347
|
spinner.info("Opening session in new tab");
|
348
348
|
const newTab = yield this._page.browser().newPage();
|
349
|
-
|
349
|
+
const qrManager = new auth_1.QRManager(this._createConfig);
|
350
|
+
yield (0, browser_1.initPage)(this.getSessionId(), this._createConfig, qrManager, this._createConfig.customUserAgent, spinner, newTab, true);
|
350
351
|
// await newTab.goto(puppeteerConfig.WAUrl);
|
351
352
|
//Two promises. One that closes the previous page, one that sets up the new page
|
352
353
|
const closePageOnConflict = () => __awaiter(this, void 0, void 0, function* () {
|
package/dist/controllers/auth.js
CHANGED
@@ -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.
|
34
|
+
exports.QRManager = exports.phoneIsOutOfReach = exports.sessionDataInvalid = exports.waitForRipeSession = exports.needsToScan = exports.isAuthenticated = void 0;
|
35
35
|
const qrcode = __importStar(require("qrcode-terminal"));
|
36
36
|
const rxjs_1 = require("rxjs");
|
37
37
|
const events_1 = require("./events");
|
@@ -269,4 +269,3 @@ class QRManager {
|
|
269
269
|
}
|
270
270
|
}
|
271
271
|
exports.QRManager = QRManager;
|
272
|
-
exports.qrManager = new QRManager();
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { Browser, Page } from 'puppeteer';
|
2
2
|
import { Spin } from './events';
|
3
3
|
import { ConfigObject } from '../api/model';
|
4
|
+
import { QRManager } from './auth';
|
4
5
|
export declare let BROWSER_START_TS: number;
|
5
|
-
export declare function initPage(sessionId?: string, config?: ConfigObject, customUserAgent?: string, spinner?: Spin, _page?: Page, skipAuth?: boolean): Promise<Page>;
|
6
|
+
export declare function initPage(sessionId?: string, config?: ConfigObject, qrManager?: QRManager, customUserAgent?: string, spinner?: Spin, _page?: Page, skipAuth?: boolean): Promise<Page>;
|
6
7
|
export declare const deleteSessionData: (config: ConfigObject) => boolean;
|
7
8
|
export declare const getSessionDataFilePath: (sessionId: string, config: ConfigObject) => string | boolean;
|
8
9
|
export declare const addScript: (page: Page, js: string) => Promise<unknown>;
|
@@ -44,12 +44,11 @@ const puppeteer = require('puppeteer-extra');
|
|
44
44
|
const promise_1 = __importDefault(require("terminate/promise"));
|
45
45
|
const logging_1 = require("../logging/logging");
|
46
46
|
const tools_1 = require("../utils/tools");
|
47
|
-
const auth_1 = require("./auth");
|
48
47
|
const script_preloader_1 = require("./script_preloader");
|
49
48
|
const patch_manager_1 = require("./patch_manager");
|
50
49
|
let browser, wapiInjected = false, dumbCache = undefined, wapiAttempts = 1;
|
51
50
|
exports.BROWSER_START_TS = 0;
|
52
|
-
function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth) {
|
51
|
+
function initPage(sessionId, config, qrManager, customUserAgent, spinner, _page, skipAuth) {
|
53
52
|
var _a, _b, _c, _d, _e;
|
54
53
|
return __awaiter(this, void 0, void 0, function* () {
|
55
54
|
const setupPromises = [];
|
@@ -79,7 +78,7 @@ function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth)
|
|
79
78
|
logging_1.log.info(`FRAME NAV, ${frame.url()}, ${webpPackKey}`);
|
80
79
|
if (webpPackKey) {
|
81
80
|
frameNavPromises.push(injectApi(waPage, spinner, true));
|
82
|
-
frameNavPromises.push(
|
81
|
+
frameNavPromises.push(qrManager.waitFirstQr(waPage, config, spinner));
|
83
82
|
}
|
84
83
|
if (frame.url().includes('post_logout=1')) {
|
85
84
|
console.log("Session most likely logged out");
|
@@ -145,7 +145,7 @@ function create(config = {}) {
|
|
145
145
|
if (!sessionId)
|
146
146
|
sessionId = 'session';
|
147
147
|
const spinner = new events_1.Spin(sessionId, 'STARTUP', config === null || config === void 0 ? void 0 : config.disableSpins);
|
148
|
-
auth_1.
|
148
|
+
const qrManager = new auth_1.QRManager(config);
|
149
149
|
try {
|
150
150
|
if (typeof config === 'string')
|
151
151
|
console.error("AS OF VERSION 3+ YOU CAN NO LONGER SET THE SESSION ID AS THE FIRST PARAMETER OF CREATE. CREATE CAN ONLY TAKE A CONFIG OBJECT. IF YOU STILL HAVE CONFIGS AS A SECOND PARAMETER, THEY WILL HAVE NO EFFECT! PLEASE SEE DOCS.");
|
@@ -164,7 +164,7 @@ function create(config = {}) {
|
|
164
164
|
spinner.info(`Using custom chromium args with multi device will cause issues! Please remove them: ${config === null || config === void 0 ? void 0 : config.chromiumArgs}`);
|
165
165
|
if ((config === null || config === void 0 ? void 0 : config.multiDevice) && !(config === null || config === void 0 ? void 0 : config.useChrome))
|
166
166
|
spinner.info(`It is recommended to set useChrome: true or use the --use-chrome flag if you are experiencing issues with Multi device support`);
|
167
|
-
waPage = yield (0, browser_1.initPage)(sessionId, config, customUserAgent, spinner);
|
167
|
+
waPage = yield (0, browser_1.initPage)(sessionId, config, qrManager, customUserAgent, spinner);
|
168
168
|
spinner.succeed('Page loaded');
|
169
169
|
const browserLaunchedTs = (0, tools_1.now)();
|
170
170
|
const throwOnError = config && config.throwErrorOnTosBlock == true;
|
@@ -268,7 +268,7 @@ function create(config = {}) {
|
|
268
268
|
else {
|
269
269
|
spinner.info('Authenticate to continue');
|
270
270
|
const race = [];
|
271
|
-
race.push(
|
271
|
+
race.push(qrManager.smartQr(waPage, config, spinner));
|
272
272
|
if ((config === null || config === void 0 ? void 0 : config.qrTimeout) !== 0) {
|
273
273
|
let to = ((config === null || config === void 0 ? void 0 : config.qrTimeout) || 60) * 1000;
|
274
274
|
if (config === null || config === void 0 ? void 0 : config.multiDevice)
|
package/package.json
CHANGED