@open-wa/wa-automate 4.31.7 → 4.31.10

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.
@@ -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
- yield (0, browser_1.initPage)(this.getSessionId(), this._createConfig, this._createConfig.customUserAgent, spinner, newTab, true);
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* () {
@@ -135,6 +135,10 @@ export interface Message {
135
135
  mediaData: unknown;
136
136
  shareDuration: number;
137
137
  isAnimated: boolean;
138
+ /**
139
+ * Is the message a "view once" message
140
+ */
141
+ isViewOnce: boolean;
138
142
  /**
139
143
  * The URL of the file after being uploaded to the cloud using a cloud upload message preprocessor.
140
144
  */
@@ -33,4 +33,3 @@ export declare class QRManager {
33
33
  */
34
34
  waitFirstQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<void>;
35
35
  }
36
- export declare const qrManager: QRManager;
@@ -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.qrManager = exports.QRManager = exports.phoneIsOutOfReach = exports.sessionDataInvalid = exports.waitForRipeSession = exports.needsToScan = exports.isAuthenticated = void 0;
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");
@@ -121,13 +121,14 @@ class QRManager {
121
121
  this._internalQrPngLoaded = false;
122
122
  this.qrCheck = `document.querySelector("canvas[aria-label='Scan me!']")?document.querySelector("canvas[aria-label='Scan me!']").parentElement.getAttribute("data-ref"):false`;
123
123
  this.config = config;
124
+ this.setConfig(this.config);
124
125
  }
125
126
  setConfig(config) {
126
127
  this.config = config;
127
128
  this.qrEvF(this.config);
128
129
  }
129
130
  qrEvF(config = this.config) {
130
- return new events_1.EvEmitter(config.sessionId || 'session', 'qr');
131
+ // return new EvEmitter(config.sessionId || 'session', 'qr');
131
132
  if (!this.qrEv)
132
133
  this.qrEv = new events_1.EvEmitter(config.sessionId || 'session', 'qr');
133
134
  return this.qrEv;
@@ -269,4 +270,3 @@ class QRManager {
269
270
  }
270
271
  }
271
272
  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(auth_1.qrManager.waitFirstQr(waPage, config, spinner));
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.qrManager.setConfig(config);
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(auth_1.qrManager.smartQr(waPage, config, spinner));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.31.7",
3
+ "version": "4.31.10",
4
4
  "licenseCheckUrl": "https://funcs.openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://funcs.openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",