@open-wa/wa-automate 4.27.0 → 4.27.4
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/cli/index.js
CHANGED
@@ -113,12 +113,6 @@ function start() {
|
|
113
113
|
process.exit();
|
114
114
|
}
|
115
115
|
}));
|
116
|
-
if (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.chatwootUrl) {
|
117
|
-
spinner.info('Setting Up Chatwoot handler');
|
118
|
-
spinner.info('Make sure to set up the Chatwoot inbox webhook to the following path on this process: /chatwoot');
|
119
|
-
yield server_1.setupChatwoot(cliConfig, client);
|
120
|
-
spinner.succeed('Chatwoot handler set up successfully');
|
121
|
-
}
|
122
116
|
if (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.botPressUrl) {
|
123
117
|
spinner.info('Setting Up Botpress handler');
|
124
118
|
server_1.setupBotPressHandler(cliConfig, client);
|
@@ -150,6 +144,12 @@ function start() {
|
|
150
144
|
console.log(`Please use the following api key for requests as a header:\napi_key: ${cliConfig.key}`);
|
151
145
|
server_1.setupAuthenticationLayer(cliConfig);
|
152
146
|
}
|
147
|
+
if (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.chatwootUrl) {
|
148
|
+
spinner.info('Setting Up Chatwoot handler');
|
149
|
+
spinner.info(`Make sure to set up the Chatwoot inbox webhook to the following path on this process: /chatwoot${cliConfig.key ? `?api_key=YOUR-API-KEY` : ''}`);
|
150
|
+
yield server_1.setupChatwoot(cliConfig, client);
|
151
|
+
spinner.succeed('Chatwoot handler set up successfully');
|
152
|
+
}
|
153
153
|
server_1.setupRefocusDisengageMiddleware(cliConfig);
|
154
154
|
if (cliConfig && cliConfig.generateApiDocs && collections_1.collections["swagger"]) {
|
155
155
|
spinner.info('Setting Up API Explorer');
|
package/dist/cli/server.js
CHANGED
@@ -71,7 +71,10 @@ const setupAuthenticationLayer = (cliConfig) => {
|
|
71
71
|
return next();
|
72
72
|
}
|
73
73
|
const apiKey = req.get('key') || req.get('api_key');
|
74
|
-
if (
|
74
|
+
if (req.path.includes('chatwoot') && req.query['api_key'] && req.query['api_key'] == cliConfig.key) {
|
75
|
+
next();
|
76
|
+
}
|
77
|
+
else if (!apiKey || apiKey !== cliConfig.key) {
|
75
78
|
res.status(401).json({ error: 'unauthorised' });
|
76
79
|
}
|
77
80
|
else {
|
package/dist/cli/setup.d.ts
CHANGED
@@ -3,6 +3,7 @@ import { Merge, JsonObject } from 'type-fest';
|
|
3
3
|
import { ConfigObject } from '../api/model/config';
|
4
4
|
import { Spin } from '../controllers/events';
|
5
5
|
export declare const optionKeys: string[];
|
6
|
+
export declare const optionKeysWithDefalts: string[];
|
6
7
|
export declare const PrimitiveConverter: {
|
7
8
|
Number: number;
|
8
9
|
Boolean: boolean;
|
package/dist/cli/setup.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.cli = exports.configFile = exports.envArgs = exports.helptext = exports.meowFlags = exports.cliOptionNames = exports.PrimitiveConverter = exports.optionKeys = void 0;
|
34
|
+
exports.cli = exports.configFile = exports.envArgs = exports.helptext = exports.meowFlags = exports.cliOptionNames = exports.PrimitiveConverter = exports.optionKeysWithDefalts = exports.optionKeys = void 0;
|
35
35
|
const tools_1 = require("./../utils/tools");
|
36
36
|
const command_line_usage_1 = __importDefault(require("command-line-usage"));
|
37
37
|
const meow_1 = __importDefault(require("meow"));
|
@@ -272,6 +272,7 @@ const optionList = [{
|
|
272
272
|
}
|
273
273
|
];
|
274
274
|
exports.optionKeys = optionList.map(({ name }) => tools_1.camelize(name));
|
275
|
+
exports.optionKeysWithDefalts = optionList.filter(o => o.hasOwnProperty('default')).map(({ name }) => tools_1.camelize(name));
|
275
276
|
exports.PrimitiveConverter = {
|
276
277
|
Number: 1,
|
277
278
|
Boolean: true,
|
@@ -380,7 +381,9 @@ const cli = () => {
|
|
380
381
|
* 2. Config file
|
381
382
|
* 3. CLI flags
|
382
383
|
*/
|
383
|
-
const
|
384
|
+
const nonCliConfigs = Object.assign(Object.assign({}, exports.envArgs()), (exports.configFile(_cli.flags.config) || {}));
|
385
|
+
optionList.filter(option => option.default);
|
386
|
+
const cliConfig = Object.assign(Object.assign(Object.assign({ sessionId: "session" }, nonCliConfigs), _cli.flags), exports.optionKeysWithDefalts.reduce((p, c) => nonCliConfigs.hasOwnProperty(c) ? Object.assign(Object.assign({}, p), { [c]: nonCliConfigs[c] }) : p, {}));
|
384
387
|
const PORT = Number(cliConfig.port || process.env.PORT || 8080);
|
385
388
|
const spinner = new events_1.Spin(cliConfig.sessionId, 'STARTUP', cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.disableSpins);
|
386
389
|
const createConfig = Object.assign({}, cliConfig);
|
@@ -9,4 +9,4 @@ export declare function injectApi(page: Page): Promise<Page>;
|
|
9
9
|
/**
|
10
10
|
* @internal
|
11
11
|
*/
|
12
|
-
export declare const kill: (p: Page, b?: Browser, exit?: boolean) => Promise<void>;
|
12
|
+
export declare const kill: (p: Page, b?: Browser, exit?: boolean, pid?: number) => Promise<void>;
|
@@ -290,6 +290,8 @@ function initBrowser(sessionId, config = {}) {
|
|
290
290
|
if (!_savedPath) {
|
291
291
|
const chromeLauncher = yield Promise.resolve().then(() => __importStar(require('chrome-launcher')));
|
292
292
|
config.executablePath = chromeLauncher.Launcher.getInstallations()[0];
|
293
|
+
if (!config.executablePath)
|
294
|
+
delete config.executablePath;
|
293
295
|
yield storage.setItem('executablePath', config.executablePath);
|
294
296
|
}
|
295
297
|
else
|
@@ -324,6 +326,9 @@ function initBrowser(sessionId, config = {}) {
|
|
324
326
|
}
|
325
327
|
if (config === null || config === void 0 ? void 0 : config.corsFix)
|
326
328
|
args.push('--disable-web-security');
|
329
|
+
if (config["userDataDir"] && !fs.existsSync(config["userDataDir"])) {
|
330
|
+
fs.mkdirSync(config["userDataDir"], { recursive: true });
|
331
|
+
}
|
327
332
|
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 }));
|
328
333
|
//devtools
|
329
334
|
if (config === null || config === void 0 ? void 0 : config.devtools) {
|
@@ -366,27 +371,27 @@ death_1.default(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
366
371
|
/**
|
367
372
|
* @internal
|
368
373
|
*/
|
369
|
-
const kill = (p, b, exit) => __awaiter(void 0, void 0, void 0, function* () {
|
374
|
+
const kill = (p, b, exit, pid) => __awaiter(void 0, void 0, void 0, function* () {
|
370
375
|
const killBrowser = (browser) => __awaiter(void 0, void 0, void 0, function* () {
|
371
376
|
if (!browser)
|
372
377
|
return;
|
373
|
-
|
378
|
+
pid = (browser === null || browser === void 0 ? void 0 : browser.process()) ? browser === null || browser === void 0 ? void 0 : browser.process().pid : null;
|
374
379
|
if (!pid)
|
375
380
|
return;
|
376
381
|
if (!(p === null || p === void 0 ? void 0 : p.isClosed()))
|
377
382
|
yield (p === null || p === void 0 ? void 0 : p.close());
|
378
383
|
if (browser)
|
379
384
|
yield (browser === null || browser === void 0 ? void 0 : browser.close().catch(() => { }));
|
380
|
-
if (pid)
|
381
|
-
tree_kill_1.default(pid, 'SIGKILL');
|
382
385
|
});
|
383
386
|
if (p) {
|
384
|
-
const browser = p === null || p === void 0 ? void 0 : p.browser();
|
387
|
+
const browser = (p === null || p === void 0 ? void 0 : p.browser) && typeof (p === null || p === void 0 ? void 0 : p.browser) === 'function' && (p === null || p === void 0 ? void 0 : p.browser());
|
385
388
|
yield killBrowser(browser);
|
386
389
|
}
|
387
390
|
else if (b) {
|
388
391
|
yield killBrowser(b);
|
389
392
|
}
|
393
|
+
if (pid)
|
394
|
+
tree_kill_1.default(pid, 'SIGKILL');
|
390
395
|
if (exit)
|
391
396
|
process.exit();
|
392
397
|
return;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@open-wa/wa-automate",
|
3
|
-
"version": "4.27.
|
3
|
+
"version": "4.27.4",
|
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",
|
@@ -28,7 +28,7 @@
|
|
28
28
|
"docwatch": "onchange 'src/**/*.ts' 'docs-source/**/*.md' -- typedoc",
|
29
29
|
"build:config-for-bin": "cd build && ts-node build-config-json-for-bin.ts && cd ..",
|
30
30
|
"postinstall": "patch-package",
|
31
|
-
"install": "cross-env npm_config_yes=true npx ignore-check@latest -p '**.data.json' -p '**.node-persist**' --comment 'managed by open-wa'"
|
31
|
+
"install": "cross-env npm_config_yes=true npx ignore-check@latest -p '**.data.json' -p '**.node-persist**' -p '**_IGNORE_**' --comment 'managed by open-wa'"
|
32
32
|
},
|
33
33
|
"husky": {
|
34
34
|
"hooks": {
|
@@ -138,11 +138,11 @@
|
|
138
138
|
"pico-s3": "^1.0.1",
|
139
139
|
"pino": "^6.11.1",
|
140
140
|
"postman-2-swagger": "^0.5.0",
|
141
|
-
"puppeteer": "
|
142
|
-
"puppeteer-extra": "^3.
|
143
|
-
"puppeteer-extra-plugin-block-resources": "^2.
|
141
|
+
"puppeteer": "^13.0.0",
|
142
|
+
"puppeteer-extra": "^3.2.3",
|
143
|
+
"puppeteer-extra-plugin-block-resources": "^2.3.0",
|
144
144
|
"puppeteer-extra-plugin-devtools": "^2.3.3",
|
145
|
-
"puppeteer-extra-plugin-stealth": "^2.
|
145
|
+
"puppeteer-extra-plugin-stealth": "^2.9.0",
|
146
146
|
"puppeteer-page-proxy": "^1.2.8",
|
147
147
|
"qrcode-terminal": "^0.12.0",
|
148
148
|
"qs": "^6.10.1",
|