@open-wa/wa-automate 4.44.0 → 4.44.3
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.
@@ -51,7 +51,7 @@ const chatwootMiddleware = (cliConfig, client) => {
|
|
51
51
|
const sendAttachment = (attachment, c) => __awaiter(void 0, void 0, void 0, function* () { return client.sendImage(to, attachment.data_url, attachment.data_url.substring(attachment.data_url.lastIndexOf('/') + 1), c || '', null, true); });
|
52
52
|
//send the text as the caption with the first message only
|
53
53
|
promises.push(sendAttachment(firstAttachment, content));
|
54
|
-
restAttachments.map(sendAttachment).map(promises.push);
|
54
|
+
(restAttachments || []).map(sendAttachment).map(promises.push);
|
55
55
|
}
|
56
56
|
else {
|
57
57
|
//no attachments
|
package/dist/cli/server.d.ts
CHANGED
package/dist/cli/server.js
CHANGED
@@ -34,7 +34,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
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
|
-
const
|
37
|
+
const node_https_1 = __importDefault(require("node:https"));
|
38
|
+
const node_http_1 = __importDefault(require("node:http"));
|
38
39
|
const collections_1 = require("./collections");
|
39
40
|
const express_robots_txt_1 = __importDefault(require("express-robots-txt"));
|
40
41
|
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
@@ -48,7 +49,7 @@ const chatwoot_1 = require("./integrations/chatwoot");
|
|
48
49
|
const express_ipfilter_1 = require("express-ipfilter");
|
49
50
|
const helmet_1 = __importDefault(require("helmet"));
|
50
51
|
exports.app = (0, express_1.default)();
|
51
|
-
exports.server =
|
52
|
+
exports.server = node_http_1.default.createServer(exports.app);
|
52
53
|
const trimChatId = (chatId) => chatId.replace("@c.us", "").replace("@g.us", "");
|
53
54
|
const socketListenerCallbacks = {};
|
54
55
|
// const existingListeners = () => Object.keys(Object.keys(socketListenerCallbacks).flatMap(id=>Object.keys(socketListenerCallbacks[id])).reduce((acc,curr)=>{acc[curr]=true;return acc},{}))
|
@@ -60,7 +61,25 @@ const setupHttpServer = (cliConfig) => {
|
|
60
61
|
let allowIps = cliConfig.allowIps;
|
61
62
|
if (!Array.isArray(cliConfig.allowIps))
|
62
63
|
allowIps = [cliConfig.allowIps];
|
63
|
-
|
64
|
+
if (Array.isArray(allowIps) && allowIps.length > 0 && allowIps[0]) {
|
65
|
+
console.log("Allowed IPs", allowIps);
|
66
|
+
let allowIpsOptions = {
|
67
|
+
mode: 'allow',
|
68
|
+
forbidden: 'You are not authorized to access this page.',
|
69
|
+
log: false
|
70
|
+
};
|
71
|
+
if (cliConfig.verbose)
|
72
|
+
allowIpsOptions = Object.assign(Object.assign({}, allowIpsOptions), { logLevel: 'deny', log: true });
|
73
|
+
exports.app.use((0, express_ipfilter_1.IpFilter)(allowIps, allowIpsOptions));
|
74
|
+
exports.app.use((err, req, res, next) => {
|
75
|
+
if (err instanceof express_ipfilter_1.IpDeniedError) {
|
76
|
+
res.status(401);
|
77
|
+
res.send("Access Denied");
|
78
|
+
return;
|
79
|
+
}
|
80
|
+
next();
|
81
|
+
});
|
82
|
+
}
|
64
83
|
}
|
65
84
|
if (cliConfig.helmet) {
|
66
85
|
//@ts-ignore
|
@@ -69,15 +88,22 @@ const setupHttpServer = (cliConfig) => {
|
|
69
88
|
const privkey = `${process.env.PRIV || cliConfig.privkey || ""}`;
|
70
89
|
const cert = `${process.env.CERT || cliConfig.cert || ""}`;
|
71
90
|
if (privkey && cert) {
|
91
|
+
console.log("HTTPS Mode:", privkey, cert);
|
72
92
|
const privContents = fs.readFileSync(privkey);
|
73
93
|
const certContents = fs.readFileSync(cert);
|
94
|
+
exports.app.use((req, res, next) => {
|
95
|
+
if (!req.secure && req.get('x-forwarded-proto') !== 'https' && process.env.NODE_ENV !== "development") {
|
96
|
+
return res.redirect('https://' + req.get('host') + req.url);
|
97
|
+
}
|
98
|
+
next();
|
99
|
+
});
|
74
100
|
if (privContents && certContents) {
|
75
101
|
const options = { key: privContents, cert: certContents };
|
76
|
-
exports.server =
|
102
|
+
exports.server = node_https_1.default.createServer(options, exports.app);
|
77
103
|
return;
|
78
104
|
}
|
79
105
|
}
|
80
|
-
exports.server =
|
106
|
+
exports.server = node_http_1.default.createServer(exports.app);
|
81
107
|
};
|
82
108
|
exports.setupHttpServer = setupHttpServer;
|
83
109
|
const setUpExpressApp = () => {
|
package/package.json
CHANGED