@open-wa/wa-automate 4.23.14 → 4.23.15

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/README.md CHANGED
@@ -36,24 +36,17 @@
36
36
  Use this command to install the library for the first time and to keep the library up to date.
37
37
 
38
38
  ```bash
39
- > npm i --save @open-wa/wa-automate@latest --multi-device
39
+ > npm i --save @open-wa/wa-automate@latest
40
40
  ```
41
41
 
42
42
  ## Usage
43
43
 
44
- ```javascript
45
- // import { create, Client } from '@open-wa/wa-automate';
46
- const wa = require('@open-wa/wa-automate');
44
+ ## CLI
47
45
 
48
- wa.create().then(client => start(client));
46
+ Want to convert your WA account to an API instantly? You can now with the CLI. For more details see [Easy API](https://docs.openwa.dev/pages/Getting%20Started/quick-run.html)
49
47
 
50
- function start(client) {
51
- client.onMessage(async message => {
52
- if (message.body === 'Hi') {
53
- await client.sendText(message.from, '👋 Hello!');
54
- }
55
- });
56
- }
48
+ ```bash
49
+ > npx @open-wa/wa-automate --help
57
50
  ```
58
51
 
59
52
  ## Custom Setup
@@ -90,13 +83,6 @@ function start(client) {
90
83
 
91
84
  ###### @open-wa/wa-automate will remember the session so there is no need to authenticate every time
92
85
 
93
- ## CLI
94
-
95
- Want to convert your WA account to an API instantly? You can now with the CLI. For more details see [Easy API](https://docs.openwa.dev/pages/Getting%20Started/quick-run.html)
96
-
97
- ```bash
98
- > npx @open-wa/wa-automate --help
99
- ```
100
86
 
101
87
  ## Multi Device Support
102
88
 
@@ -305,14 +305,15 @@ function initBrowser(sessionId, config = {}) {
305
305
  let args = [...puppeteer_config_1.puppeteerConfig.chromiumArgs, ...((config === null || config === void 0 ? void 0 : config.chromiumArgs) || [])];
306
306
  if (config === null || config === void 0 ? void 0 : config.multiDevice) {
307
307
  args = args.filter(x => x != '--incognito');
308
- config["userDataDir"] = `./_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`;
308
+ 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'}`;
309
309
  }
310
310
  if (config === null || config === void 0 ? void 0 : config.corsFix)
311
311
  args.push('--disable-web-security');
312
312
  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 }));
313
313
  //devtools
314
314
  if (config === null || config === void 0 ? void 0 : config.devtools) {
315
- const devtools = (yield Promise.resolve().then(() => __importStar(require('puppeteer-extra-plugin-devtools'))))();
315
+ const _dt = yield Promise.resolve().then(() => __importStar(require('puppeteer-extra-plugin-devtools')));
316
+ const devtools = _dt.default();
316
317
  if (config.devtools !== 'local' && !((_b = config === null || config === void 0 ? void 0 : config.devtools) === null || _b === void 0 ? void 0 : _b.user) && !((_c = config === null || config === void 0 ? void 0 : config.devtools) === null || _c === void 0 ? void 0 : _c.pass)) {
317
318
  config.devtools = {};
318
319
  config.devtools.user = 'dev';
@@ -322,6 +323,7 @@ function initBrowser(sessionId, config = {}) {
322
323
  if (config.devtools.user && config.devtools.pass) {
323
324
  devtools.setAuthCredentials(config.devtools.user, config.devtools.pass);
324
325
  }
326
+ puppeteer.use(devtools);
325
327
  try {
326
328
  // const tunnel = await devtools.createTunnel(browser);
327
329
  const tunnel = config.devtools == 'local' ? devtools.getLocalDevToolsUrl(browser) : (yield devtools.createTunnel(browser)).url;
@@ -157,7 +157,8 @@ function create(config = {}) {
157
157
  /**
158
158
  * Check if the IGNORE folder exists, therefore, assume that the session is MD.
159
159
  */
160
- if (fs.existsSync(`./_IGNORE_${(config === null || config === void 0 ? void 0 : config.sessionId) || 'session'}`) && !(config === null || config === void 0 ? void 0 : config.multiDevice)) {
160
+ const mdDir = 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'}`;
161
+ if (fs.existsSync(mdDir) && !(config === null || config === void 0 ? void 0 : config.multiDevice)) {
161
162
  spinner.info(`Multi-Device directory detected. multiDevice set to true.`);
162
163
  config.multiDevice = true;
163
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.23.14",
3
+ "version": "4.23.15",
4
4
  "licenseCheckUrl": "https://openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",
@@ -140,7 +140,7 @@
140
140
  "puppeteer": "10.4.0",
141
141
  "puppeteer-extra": "^3.1.9",
142
142
  "puppeteer-extra-plugin-block-resources": "^2.2.7",
143
- "puppeteer-extra-plugin-devtools": "^2.2.8",
143
+ "puppeteer-extra-plugin-devtools": "^2.3.3",
144
144
  "puppeteer-extra-plugin-stealth": "^2.4.9",
145
145
  "puppeteer-page-proxy": "^1.2.8",
146
146
  "qrcode-terminal": "^0.12.0",