@open-wa/wa-automate 4.43.4 → 4.44.1
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/cli-options.js +25 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/server.d.ts +2 -1
- package/dist/cli/server.js +33 -1
- package/package.json +5 -3
package/dist/cli/cli-options.js
CHANGED
@@ -240,6 +240,31 @@ exports.optionList = [{
|
|
240
240
|
typeLabel: '{yellow {underline "--max-memory-restart 300M"}}',
|
241
241
|
description: "Offload the EASY API to local instance of pm2. You can add pm2 specific arguments also if you want."
|
242
242
|
},
|
243
|
+
{
|
244
|
+
name: 'privkey',
|
245
|
+
type: String,
|
246
|
+
typeLabel: '{yellow {underline "./privatekey.pem"}}',
|
247
|
+
description: "The private key to use for the TLS connection. --cert is also required"
|
248
|
+
},
|
249
|
+
{
|
250
|
+
name: 'cert',
|
251
|
+
type: String,
|
252
|
+
typeLabel: '{yellow {underline "./certificate.pem"}}',
|
253
|
+
description: "The certificate to use for the TLS connection. --privkey is also required"
|
254
|
+
},
|
255
|
+
{
|
256
|
+
name: 'helmet',
|
257
|
+
type: Boolean,
|
258
|
+
description: "Enable helmet middleware for security.",
|
259
|
+
},
|
260
|
+
{
|
261
|
+
name: 'allow-ips',
|
262
|
+
type: String,
|
263
|
+
//@ts-ignore
|
264
|
+
isMultiple: true,
|
265
|
+
typeLabel: '{blueBright {underline 192.168.0.1,192.168.0.2}}',
|
266
|
+
description: "Allow only these IPs to connect to the EASY API. By default, all IPs are allowed."
|
267
|
+
},
|
243
268
|
{
|
244
269
|
name: 'help',
|
245
270
|
description: 'Print this usage guide.'
|
package/dist/cli/index.js
CHANGED
package/dist/cli/server.d.ts
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
import http from 'http';
|
3
3
|
import { Client } from '..';
|
4
4
|
export declare const app: import("express-serve-static-core").Express;
|
5
|
-
export declare
|
5
|
+
export declare let server: http.Server;
|
6
6
|
export declare type cliFlags = {
|
7
7
|
[k: string]: number | string | boolean;
|
8
8
|
};
|
9
|
+
export declare const setupHttpServer: (cliConfig: cliFlags) => void;
|
9
10
|
export declare const setUpExpressApp: () => void;
|
10
11
|
export declare const enableCORSRequests: () => void;
|
11
12
|
export declare const setupAuthenticationLayer: (cliConfig: cliFlags) => void;
|
package/dist/cli/server.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.setupSocketServer = exports.setupBotPressHandler = exports.setupChatwoot = exports.setupTwilioCompatibleWebhook = exports.setupMediaMiddleware = exports.listListeners = exports.getCommands = exports.setupRefocusDisengageMiddleware = exports.setupSwaggerStatsMiddleware = exports.setupApiDocs = exports.setupAuthenticationLayer = exports.enableCORSRequests = exports.setUpExpressApp = exports.server = exports.app = void 0;
|
34
|
+
exports.setupSocketServer = exports.setupBotPressHandler = exports.setupChatwoot = exports.setupTwilioCompatibleWebhook = exports.setupMediaMiddleware = exports.listListeners = exports.getCommands = exports.setupRefocusDisengageMiddleware = exports.setupSwaggerStatsMiddleware = exports.setupApiDocs = exports.setupAuthenticationLayer = exports.enableCORSRequests = exports.setUpExpressApp = exports.setupHttpServer = exports.server = exports.app = void 0;
|
35
35
|
//@ts-ignore
|
36
36
|
const express_1 = __importDefault(require("express"));
|
37
37
|
const http_1 = __importDefault(require("http"));
|
@@ -42,8 +42,11 @@ const axios_1 = __importDefault(require("axios"));
|
|
42
42
|
const parse_function_1 = __importDefault(require("parse-function"));
|
43
43
|
const __1 = require("..");
|
44
44
|
const qs_1 = __importDefault(require("qs"));
|
45
|
+
const fs = __importStar(require("fs"));
|
45
46
|
const xmlbuilder2_1 = require("xmlbuilder2");
|
46
47
|
const chatwoot_1 = require("./integrations/chatwoot");
|
48
|
+
const express_ipfilter_1 = require("express-ipfilter");
|
49
|
+
const helmet_1 = __importDefault(require("helmet"));
|
47
50
|
exports.app = (0, express_1.default)();
|
48
51
|
exports.server = http_1.default.createServer(exports.app);
|
49
52
|
const trimChatId = (chatId) => chatId.replace("@c.us", "").replace("@g.us", "");
|
@@ -51,6 +54,35 @@ const socketListenerCallbacks = {};
|
|
51
54
|
// const existingListeners = () => Object.keys(Object.keys(socketListenerCallbacks).flatMap(id=>Object.keys(socketListenerCallbacks[id])).reduce((acc,curr)=>{acc[curr]=true;return acc},{}))
|
52
55
|
const existingListeners = [];
|
53
56
|
const getCallbacks = (listener) => Object.keys(socketListenerCallbacks).flatMap(k => socketListenerCallbacks[k]).map(o => o[listener]).filter(x => x);
|
57
|
+
const setupHttpServer = (cliConfig) => {
|
58
|
+
//check if there is an allow IP list:
|
59
|
+
if (cliConfig.allowIps) {
|
60
|
+
let allowIps = cliConfig.allowIps;
|
61
|
+
if (!Array.isArray(cliConfig.allowIps))
|
62
|
+
allowIps = [cliConfig.allowIps];
|
63
|
+
if (Array.isArray(allowIps) && allowIps.length > 0 && allowIps[0]) {
|
64
|
+
console.log("Allowed IPs", allowIps);
|
65
|
+
exports.app.use((0, express_ipfilter_1.IpFilter)(allowIps, { mode: 'allow' }));
|
66
|
+
}
|
67
|
+
}
|
68
|
+
if (cliConfig.helmet) {
|
69
|
+
//@ts-ignore
|
70
|
+
exports.app.use((0, helmet_1.default)());
|
71
|
+
}
|
72
|
+
const privkey = `${process.env.PRIV || cliConfig.privkey || ""}`;
|
73
|
+
const cert = `${process.env.CERT || cliConfig.cert || ""}`;
|
74
|
+
if (privkey && cert) {
|
75
|
+
const privContents = fs.readFileSync(privkey);
|
76
|
+
const certContents = fs.readFileSync(cert);
|
77
|
+
if (privContents && certContents) {
|
78
|
+
const options = { key: privContents, cert: certContents };
|
79
|
+
exports.server = http_1.default.createServer(options, exports.app);
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
exports.server = http_1.default.createServer(exports.app);
|
84
|
+
};
|
85
|
+
exports.setupHttpServer = setupHttpServer;
|
54
86
|
const setUpExpressApp = () => {
|
55
87
|
exports.app.use((0, express_robots_txt_1.default)({ UserAgent: '*', Disallow: '/' }));
|
56
88
|
//@ts-ignore
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@open-wa/wa-automate",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.44.1",
|
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",
|
@@ -75,7 +75,7 @@
|
|
75
75
|
"@types/localtunnel": "^2.0.1",
|
76
76
|
"@types/marked": "^4.0.2",
|
77
77
|
"@types/mime-types": "^2.1.0",
|
78
|
-
"@types/node": "^
|
78
|
+
"@types/node": "^18.7.6",
|
79
79
|
"@types/puppeteer": "^5.4.0",
|
80
80
|
"@types/shelljs": "^0.8.5",
|
81
81
|
"@types/winston-syslog": "^2.4.0",
|
@@ -123,12 +123,14 @@
|
|
123
123
|
"death": "^1.1.0",
|
124
124
|
"eventemitter2": "^6.4.4",
|
125
125
|
"express": "^4.17.1",
|
126
|
+
"express-ipfilter": "^1.3.1",
|
126
127
|
"express-robots-txt": "^1.0.0",
|
127
128
|
"find-up": "^5.0.0",
|
128
129
|
"form-data": "^4.0.0",
|
129
130
|
"fs-extra": "^10.0.0",
|
130
131
|
"get-port": "^5.1.1",
|
131
132
|
"hasha": "^5.2.0",
|
133
|
+
"helmet": "^5.1.1",
|
132
134
|
"image-type": "^4.1.0",
|
133
135
|
"is-url-superb": "^5.0.0",
|
134
136
|
"json5": "^2.2.0",
|
@@ -143,7 +145,7 @@
|
|
143
145
|
"parse-function": "^5.6.10",
|
144
146
|
"parse-url": "^5.0.2",
|
145
147
|
"patch-package": "^6.2.2",
|
146
|
-
"pico-s3": "^
|
148
|
+
"pico-s3": "^2.0.0",
|
147
149
|
"pidtree": "^0.6.0",
|
148
150
|
"pidusage": "^3.0.0",
|
149
151
|
"postman-2-swagger": "^0.5.0",
|