@open-wa/wa-automate 4.23.13 → 4.23.17
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 +5 -19
- package/dist/api/Client.js +2 -1
- package/dist/api/model/chat.d.ts +57 -0
- package/dist/api/model/index.d.ts +4 -0
- package/dist/api/model/index.js +0 -1
- package/dist/api/model/media.d.ts +8 -0
- package/dist/cli/collections.d.ts +1 -0
- package/dist/cli/collections.js +50 -5
- package/dist/controllers/browser.d.ts +1 -1
- package/dist/controllers/browser.js +54 -38
- package/dist/controllers/initializer.js +2 -1
- package/package.json +4 -2
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
|
39
|
+
> npm i --save @open-wa/wa-automate@latest
|
40
40
|
```
|
41
41
|
|
42
42
|
## Usage
|
43
43
|
|
44
|
-
|
45
|
-
// import { create, Client } from '@open-wa/wa-automate';
|
46
|
-
const wa = require('@open-wa/wa-automate');
|
44
|
+
## CLI
|
47
45
|
|
48
|
-
|
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
|
-
|
51
|
-
|
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
|
|
package/dist/api/Client.js
CHANGED
@@ -355,7 +355,8 @@ class Client {
|
|
355
355
|
const START_TIME = Date.now();
|
356
356
|
spinner.info("Opening session in new tab");
|
357
357
|
const newTab = yield this._page.browser().newPage();
|
358
|
-
yield
|
358
|
+
yield browser_1.initPage(this.getSessionId(), this._createConfig, this._createConfig.customUserAgent, spinner, newTab, true);
|
359
|
+
// await newTab.goto(puppeteerConfig.WAUrl);
|
359
360
|
//Two promises. One that closes the previous page, one that sets up the new page
|
360
361
|
const closePageOnConflict = () => __awaiter(this, void 0, void 0, function* () {
|
361
362
|
const useHere = yield this._page.evaluate(() => WAPI.getUseHereString());
|
package/dist/api/model/chat.d.ts
CHANGED
@@ -5,26 +5,83 @@ export interface Chat {
|
|
5
5
|
archive: boolean;
|
6
6
|
changeNumberNewJid: any;
|
7
7
|
changeNumberOldJid: any;
|
8
|
+
/**
|
9
|
+
* The contact related to this chat
|
10
|
+
*/
|
8
11
|
contact: Contact;
|
12
|
+
/**
|
13
|
+
* Group metadata for this chat
|
14
|
+
*/
|
9
15
|
groupMetadata: GroupMetadata;
|
16
|
+
/**
|
17
|
+
* The id of the chat
|
18
|
+
*/
|
10
19
|
id: ChatId;
|
20
|
+
/**
|
21
|
+
* If the chat is a group chat is restricted
|
22
|
+
*/
|
11
23
|
isAnnounceGrpRestrict: any;
|
24
|
+
/**
|
25
|
+
* The title of the chat
|
26
|
+
*/
|
12
27
|
formattedTitle?: string;
|
28
|
+
/**
|
29
|
+
* Whether your host account is able to send messages to this chat
|
30
|
+
*/
|
13
31
|
canSend?: boolean;
|
32
|
+
/**
|
33
|
+
* Whether the chat is a group chat
|
34
|
+
*/
|
14
35
|
isGroup: boolean;
|
36
|
+
/**
|
37
|
+
* Whether the chat is a group chat and the group is restricted
|
38
|
+
*/
|
15
39
|
isReadOnly: boolean;
|
16
40
|
kind: string;
|
41
|
+
/**
|
42
|
+
* The labels attached to this chat.
|
43
|
+
*/
|
17
44
|
labels: any;
|
45
|
+
/**
|
46
|
+
* The ID of the last message received in this chat
|
47
|
+
*/
|
18
48
|
lastReceivedKey: any;
|
19
49
|
modifyTag: number;
|
50
|
+
/**
|
51
|
+
* The messages in the chat
|
52
|
+
*/
|
20
53
|
msgs: any;
|
54
|
+
/**
|
55
|
+
* The expiration timestamp of the chat mute
|
56
|
+
*/
|
21
57
|
muteExpiration: number;
|
58
|
+
/**
|
59
|
+
* The name of the chat
|
60
|
+
*/
|
22
61
|
name: string;
|
62
|
+
/**
|
63
|
+
* Whether the chat is marked as spam
|
64
|
+
*/
|
23
65
|
notSpam: boolean;
|
66
|
+
/**
|
67
|
+
* Messages that are pending to be sent
|
68
|
+
*/
|
24
69
|
pendingMsgs: boolean;
|
70
|
+
/**
|
71
|
+
* Whether the chat is pinned
|
72
|
+
*/
|
25
73
|
pin: number;
|
74
|
+
/**
|
75
|
+
* The presence state of the chat participant
|
76
|
+
*/
|
26
77
|
presence: any;
|
78
|
+
/**
|
79
|
+
* The timestamp of the last interaction in the chat
|
80
|
+
*/
|
27
81
|
t: number;
|
82
|
+
/**
|
83
|
+
* The number of undread messages in this chat
|
84
|
+
*/
|
28
85
|
unreadCount: number;
|
29
86
|
ack?: any;
|
30
87
|
/**
|
@@ -97,6 +97,10 @@ export declare enum STATE {
|
|
97
97
|
*/
|
98
98
|
DISCONNECTED = "DISCONNECTED"
|
99
99
|
}
|
100
|
+
export declare type EasyApiResponse = {
|
101
|
+
success: boolean;
|
102
|
+
response: any;
|
103
|
+
};
|
100
104
|
export * from './config';
|
101
105
|
export * from './media';
|
102
106
|
export * from './aliases';
|
package/dist/api/model/index.js
CHANGED
@@ -115,7 +115,6 @@ var STATE;
|
|
115
115
|
*/
|
116
116
|
STATE["DISCONNECTED"] = "DISCONNECTED";
|
117
117
|
})(STATE = exports.STATE || (exports.STATE = {}));
|
118
|
-
;
|
119
118
|
__exportStar(require("./config"), exports);
|
120
119
|
__exportStar(require("./media"), exports);
|
121
120
|
__exportStar(require("./aliases"), exports);
|
@@ -44,6 +44,14 @@ export declare type StickerMetadata = {
|
|
44
44
|
* @default `attention`
|
45
45
|
*/
|
46
46
|
cropPosition?: 'top' | 'right top' | 'right' | 'right bottom' | 'bottom' | 'left bottom' | 'left' | 'left top' | 'north' | 'northeast' | 'east' | 'southeast' | 'south' | 'southwest' | 'west' | 'northwest' | 'center' | 'centre' | 'entropy' | 'attention';
|
47
|
+
/**
|
48
|
+
* The corner radius of the sticker when `stickerMetadata.circle` is set to true.
|
49
|
+
* @default `100`
|
50
|
+
* @minimum `1`
|
51
|
+
* @maximum `100`
|
52
|
+
* @multipleOf `1`
|
53
|
+
*/
|
54
|
+
cornerRadius?: number;
|
47
55
|
};
|
48
56
|
export declare type Mp4StickerConversionProcessOptions = {
|
49
57
|
/**
|
package/dist/cli/collections.js
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -12,14 +31,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
32
|
};
|
14
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.generateCollections = exports.collections = void 0;
|
34
|
+
exports.getTypeSchemas = exports.generateCollections = exports.collections = void 0;
|
16
35
|
const __1 = require("..");
|
17
36
|
const postman_2_swagger_1 = __importDefault(require("postman-2-swagger"));
|
18
37
|
const fs_extra_1 = require("fs-extra");
|
38
|
+
const typeconv_1 = require("typeconv");
|
39
|
+
const fs = __importStar(require("fs"));
|
40
|
+
const glob_promise_1 = __importDefault(require("glob-promise"));
|
19
41
|
exports.collections = {};
|
20
42
|
const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void 0, function* () {
|
21
43
|
let swCol = null;
|
22
44
|
let pmCol = null;
|
45
|
+
const _types = yield exports.getTypeSchemas();
|
23
46
|
spinner.info('Generating Swagger Spec');
|
24
47
|
pmCol = yield __1.generatePostmanJson(config);
|
25
48
|
spinner.succeed(`Postman collection generated: open-wa-${config.sessionId}.postman_collection.json`);
|
@@ -40,6 +63,9 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
|
|
40
63
|
"description": "Documentation",
|
41
64
|
"url": swCol.paths[p].post.documentationUrl
|
42
65
|
};
|
66
|
+
swCol.paths[p].post.responses['200'].schema = {
|
67
|
+
"$ref": "#/components/schemas/EasyApiResponse"
|
68
|
+
};
|
43
69
|
swCol.paths[p].post.requestBody = {
|
44
70
|
"description": path.summary,
|
45
71
|
"content": {
|
@@ -55,20 +81,20 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
|
|
55
81
|
});
|
56
82
|
delete swCol.swagger;
|
57
83
|
swCol.openapi = "3.0.3";
|
84
|
+
swCol.components = {};
|
85
|
+
swCol.components.schemas = _types;
|
58
86
|
swCol.externalDocs = {
|
59
87
|
"description": "Find more info here",
|
60
88
|
"url": "https://openwa.dev/"
|
61
89
|
};
|
62
90
|
if (config.key) {
|
63
|
-
swCol.components = {
|
64
|
-
"securitySchemes": {
|
91
|
+
swCol.components = Object.assign(Object.assign({}, swCol.components), { "securitySchemes": {
|
65
92
|
"api_key": {
|
66
93
|
"type": "apiKey",
|
67
94
|
"name": "api_key",
|
68
95
|
"in": "header"
|
69
96
|
}
|
70
|
-
}
|
71
|
-
};
|
97
|
+
} });
|
72
98
|
swCol.security = [
|
73
99
|
{
|
74
100
|
"api_key": []
|
@@ -86,3 +112,22 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
|
|
86
112
|
return;
|
87
113
|
});
|
88
114
|
exports.generateCollections = generateCollections;
|
115
|
+
const getTypeSchemas = () => __awaiter(void 0, void 0, void 0, function* () {
|
116
|
+
const reader = typeconv_1.getTypeScriptReader();
|
117
|
+
const writer = typeconv_1.getOpenApiWriter({ format: 'json', title: 'My API', version: 'v3.0.3' });
|
118
|
+
const { convert } = typeconv_1.makeConverter(reader, writer, {
|
119
|
+
simplify: true
|
120
|
+
});
|
121
|
+
const s = (yield Promise.all([...(yield glob_promise_1.default('../**/*.d.ts')), ...(yield glob_promise_1.default('../**/message.js')), ...(yield glob_promise_1.default('../**/chat.js'))])).filter(f => !f.includes('node_modules'));
|
122
|
+
const res = {};
|
123
|
+
yield Promise.all(s.map((x) => __awaiter(void 0, void 0, void 0, function* () {
|
124
|
+
var _a, _b;
|
125
|
+
const { data } = yield convert({ data: fs.readFileSync(x, 'utf8') });
|
126
|
+
const schemas = (_b = (_a = JSON.parse(data)) === null || _a === void 0 ? void 0 : _a.components) === null || _b === void 0 ? void 0 : _b.schemas;
|
127
|
+
Object.keys(schemas).forEach(k => {
|
128
|
+
res[k] = schemas[k];
|
129
|
+
});
|
130
|
+
})));
|
131
|
+
return res;
|
132
|
+
});
|
133
|
+
exports.getTypeSchemas = getTypeSchemas;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Page } from 'puppeteer';
|
2
2
|
import { Spin } from './events';
|
3
3
|
import { ConfigObject } from '../api/model';
|
4
|
-
export declare function initPage(sessionId?: string, config?: ConfigObject, customUserAgent?: string, spinner?: Spin): Promise<Page>;
|
4
|
+
export declare function initPage(sessionId?: string, config?: ConfigObject, customUserAgent?: string, spinner?: Spin, _page?: Page, skipAuth?: boolean): Promise<Page>;
|
5
5
|
export declare const deleteSessionData: (config: ConfigObject) => boolean;
|
6
6
|
export declare const getSessionDataFilePath: (sessionId: string, config: ConfigObject) => string | boolean;
|
7
7
|
export declare const addScript: (page: Page, js: string) => Promise<unknown>;
|
@@ -42,7 +42,7 @@ const pico_s3_1 = require("pico-s3");
|
|
42
42
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
43
43
|
const puppeteer = require('puppeteer-extra');
|
44
44
|
let browser;
|
45
|
-
function initPage(sessionId, config, customUserAgent, spinner) {
|
45
|
+
function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth) {
|
46
46
|
var _a, _b, _c, _d, _e;
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
48
48
|
const setupPromises = [];
|
@@ -52,10 +52,13 @@ function initPage(sessionId, config, customUserAgent, spinner) {
|
|
52
52
|
const { default: stealth } = yield Promise.resolve().then(() => __importStar(require('puppeteer-extra-plugin-stealth')));
|
53
53
|
puppeteer.use(stealth());
|
54
54
|
}
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
let waPage = _page;
|
56
|
+
if (!waPage) {
|
57
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info('Launching Browser');
|
58
|
+
browser = yield initBrowser(sessionId, config);
|
59
|
+
waPage = yield getWAPage(browser);
|
60
|
+
}
|
61
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info('Setting Up Page');
|
59
62
|
if (config === null || config === void 0 ? void 0 : config.proxyServerCredentials) {
|
60
63
|
yield waPage.authenticate(config.proxyServerCredentials);
|
61
64
|
}
|
@@ -115,40 +118,51 @@ function initPage(sessionId, config, customUserAgent, spinner) {
|
|
115
118
|
request.continue();
|
116
119
|
}));
|
117
120
|
}
|
118
|
-
|
119
|
-
|
120
|
-
if (!sessionjson && sessionjson !== "" && config.sessionDataBucketAuth) {
|
121
|
-
try {
|
122
|
-
spinner === null || spinner === void 0 ? void 0 : spinner.info('Unable to find session data file locally, attempting to find session data in cloud storage..');
|
123
|
-
sessionjson = JSON.parse(Buffer.from(yield pico_s3_1.getTextFile(Object.assign(Object.assign({ directory: '_sessionData' }, JSON.parse(Buffer.from(config.sessionDataBucketAuth, 'base64').toString('ascii'))), { filename: `${config.sessionId || 'session'}.data.json` })), 'base64').toString('ascii'));
|
124
|
-
spinner === null || spinner === void 0 ? void 0 : spinner.succeed('Successfully downloaded session data file from cloud storage!');
|
125
|
-
}
|
126
|
-
catch (error) {
|
127
|
-
spinner === null || spinner === void 0 ? void 0 : spinner.fail(`${error instanceof pico_s3_1.FileNotFoundError ? 'The session data file was not found in the cloud storage bucket' : 'Something went wrong while fetching session data from cloud storage bucket'}. Continuing...`);
|
128
|
-
}
|
129
|
-
}
|
130
|
-
if (sessionjson) {
|
131
|
-
spinner === null || spinner === void 0 ? void 0 : spinner.info(config.multiDevice ? "multi-device enabled. Session data skipped..." : 'Existing session data detected. Injecting...');
|
132
|
-
if (!(config === null || config === void 0 ? void 0 : config.multiDevice))
|
133
|
-
yield waPage.evaluateOnNewDocument(session => {
|
134
|
-
localStorage.clear();
|
135
|
-
Object.keys(session).forEach(key => localStorage.setItem(key, session[key]));
|
136
|
-
}, sessionjson);
|
137
|
-
spinner === null || spinner === void 0 ? void 0 : spinner.succeed('Existing session data injected');
|
121
|
+
if (skipAuth) {
|
122
|
+
spinner.info("Skipping Authentication");
|
138
123
|
}
|
139
124
|
else {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
}
|
125
|
+
/**
|
126
|
+
* AUTH
|
127
|
+
*/
|
128
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info('Loading session data');
|
129
|
+
let sessionjson = getSessionDataFromFile(sessionId, config, spinner);
|
130
|
+
if (!sessionjson && sessionjson !== "" && config.sessionDataBucketAuth) {
|
131
|
+
try {
|
132
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info('Unable to find session data file locally, attempting to find session data in cloud storage..');
|
133
|
+
sessionjson = JSON.parse(Buffer.from(yield pico_s3_1.getTextFile(Object.assign(Object.assign({ directory: '_sessionData' }, JSON.parse(Buffer.from(config.sessionDataBucketAuth, 'base64').toString('ascii'))), { filename: `${config.sessionId || 'session'}.data.json` })), 'base64').toString('ascii'));
|
134
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.succeed('Successfully downloaded session data file from cloud storage!');
|
135
|
+
}
|
136
|
+
catch (error) {
|
137
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.fail(`${error instanceof pico_s3_1.FileNotFoundError ? 'The session data file was not found in the cloud storage bucket' : 'Something went wrong while fetching session data from cloud storage bucket'}. Continuing...`);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
if (sessionjson) {
|
141
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info(config.multiDevice ? "multi-device enabled. Session data skipped..." : 'Existing session data detected. Injecting...');
|
142
|
+
if (!(config === null || config === void 0 ? void 0 : config.multiDevice))
|
143
|
+
yield waPage.evaluateOnNewDocument(session => {
|
144
|
+
localStorage.clear();
|
145
|
+
Object.keys(session).forEach(key => localStorage.setItem(key, session[key]));
|
146
|
+
}, sessionjson);
|
147
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.succeed('Existing session data injected');
|
148
|
+
}
|
149
|
+
else {
|
150
|
+
if (config === null || config === void 0 ? void 0 : config.multiDevice) {
|
151
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info("No session data detected. Opting in for MD.");
|
152
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info("Make sure to keep the session alive for at least 5 minutes after scanning the QR code before trying to restart a session!!");
|
153
|
+
yield waPage.evaluateOnNewDocument(session => {
|
154
|
+
localStorage.clear();
|
155
|
+
Object.keys(session).forEach(key => localStorage.setItem(key, session[key]));
|
156
|
+
}, {
|
157
|
+
"md-opted-in": "true",
|
158
|
+
"MdUpgradeWamFlag": "true",
|
159
|
+
"remember-me": "true"
|
160
|
+
});
|
161
|
+
}
|
151
162
|
}
|
163
|
+
/**
|
164
|
+
* END AUTH
|
165
|
+
*/
|
152
166
|
}
|
153
167
|
if ((config === null || config === void 0 ? void 0 : config.proxyServerCredentials) && !(config === null || config === void 0 ? void 0 : config.useNativeProxy)) {
|
154
168
|
yield proxy(waPage, proxyAddr);
|
@@ -305,14 +319,15 @@ function initBrowser(sessionId, config = {}) {
|
|
305
319
|
let args = [...puppeteer_config_1.puppeteerConfig.chromiumArgs, ...((config === null || config === void 0 ? void 0 : config.chromiumArgs) || [])];
|
306
320
|
if (config === null || config === void 0 ? void 0 : config.multiDevice) {
|
307
321
|
args = args.filter(x => x != '--incognito');
|
308
|
-
config["userDataDir"] =
|
322
|
+
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
323
|
}
|
310
324
|
if (config === null || config === void 0 ? void 0 : config.corsFix)
|
311
325
|
args.push('--disable-web-security');
|
312
326
|
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
327
|
//devtools
|
314
328
|
if (config === null || config === void 0 ? void 0 : config.devtools) {
|
315
|
-
const
|
329
|
+
const _dt = yield Promise.resolve().then(() => __importStar(require('puppeteer-extra-plugin-devtools')));
|
330
|
+
const devtools = _dt.default();
|
316
331
|
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
332
|
config.devtools = {};
|
318
333
|
config.devtools.user = 'dev';
|
@@ -322,6 +337,7 @@ function initBrowser(sessionId, config = {}) {
|
|
322
337
|
if (config.devtools.user && config.devtools.pass) {
|
323
338
|
devtools.setAuthCredentials(config.devtools.user, config.devtools.pass);
|
324
339
|
}
|
340
|
+
puppeteer.use(devtools);
|
325
341
|
try {
|
326
342
|
// const tunnel = await devtools.createTunnel(browser);
|
327
343
|
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
|
-
|
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.
|
3
|
+
"version": "4.23.17",
|
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",
|
@@ -120,6 +120,7 @@
|
|
120
120
|
"find-up": "^5.0.0",
|
121
121
|
"fs-extra": "^10.0.0",
|
122
122
|
"get-port": "^5.1.1",
|
123
|
+
"glob-promise": "^4.2.2",
|
123
124
|
"hasha": "^5.2.0",
|
124
125
|
"image-type": "^4.1.0",
|
125
126
|
"is-url-superb": "^5.0.0",
|
@@ -139,7 +140,7 @@
|
|
139
140
|
"puppeteer": "10.4.0",
|
140
141
|
"puppeteer-extra": "^3.1.9",
|
141
142
|
"puppeteer-extra-plugin-block-resources": "^2.2.7",
|
142
|
-
"puppeteer-extra-plugin-devtools": "^2.
|
143
|
+
"puppeteer-extra-plugin-devtools": "^2.3.3",
|
143
144
|
"puppeteer-extra-plugin-stealth": "^2.4.9",
|
144
145
|
"puppeteer-page-proxy": "^1.2.8",
|
145
146
|
"qrcode-terminal": "^0.12.0",
|
@@ -157,6 +158,7 @@
|
|
157
158
|
"ts-json-schema-generator": "^0.95.0",
|
158
159
|
"ts-morph": "^12.0.0",
|
159
160
|
"type-fest": "^1.1.1",
|
161
|
+
"typeconv": "^1.7.0",
|
160
162
|
"update-notifier": "^5.0.0",
|
161
163
|
"uuid": "^8.3.2",
|
162
164
|
"uuid-apikey": "^1.4.6",
|