@open-wa/wa-automate 4.54.0 → 4.54.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/Client.d.ts +2 -1
- package/dist/api/Client.js +36 -2
- package/dist/cli/index.js +1 -1
- package/dist/controllers/browser.js +6 -0
- package/package.json +1 -1
package/dist/api/Client.d.ts
CHANGED
@@ -40,6 +40,7 @@ export declare class Client {
|
|
40
40
|
private _currentlyBeingKilled;
|
41
41
|
private _refreshing;
|
42
42
|
private _loaded;
|
43
|
+
private _hostAccountNumber;
|
43
44
|
private _prio;
|
44
45
|
private _pageListeners;
|
45
46
|
private _registeredPageListeners;
|
@@ -1914,7 +1915,7 @@ export declare class Client {
|
|
1914
1915
|
*
|
1915
1916
|
* For example, if you have a session with id `host` if you set useSessionIdInPath to true, then all requests will need to be prefixed with the path `host`. E.g `localhost:8082/sendText` becomes `localhost:8082/host/sendText`
|
1916
1917
|
*/
|
1917
|
-
middleware: (useSessionIdInPath?: boolean) => (req: Request, res: Response, next: NextFunction) => Promise<any>;
|
1918
|
+
middleware: (useSessionIdInPath?: boolean, PORT?: number) => (req: Request, res: Response, next: NextFunction) => Promise<any>;
|
1918
1919
|
/**
|
1919
1920
|
* Retreives an array of webhook objects
|
1920
1921
|
*/
|
package/dist/api/Client.js
CHANGED
@@ -190,10 +190,42 @@ class Client {
|
|
190
190
|
*
|
191
191
|
* For example, if you have a session with id `host` if you set useSessionIdInPath to true, then all requests will need to be prefixed with the path `host`. E.g `localhost:8082/sendText` becomes `localhost:8082/host/sendText`
|
192
192
|
*/
|
193
|
-
this.middleware = (useSessionIdInPath = false) => (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
193
|
+
this.middleware = (useSessionIdInPath = false, PORT) => (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
194
194
|
if (useSessionIdInPath && !req.path.includes(this._createConfig.sessionId) && this._createConfig.sessionId !== 'session')
|
195
195
|
return next();
|
196
196
|
const methodFromPath = this._createConfig.sessionId && this._createConfig.sessionId !== 'session' && req.path.includes(this._createConfig.sessionId) ? req.path.replace(`/${this._createConfig.sessionId}/`, '') : req.path.replace('/', '');
|
197
|
+
if (req.get('owa-check-property') && req.get('owa-check-value')) {
|
198
|
+
const checkProp = req.get('owa-check-property');
|
199
|
+
const checkValue = req.get('owa-check-value');
|
200
|
+
const sessionId = this._createConfig.sessionId;
|
201
|
+
const hostAccountNumber = yield this.getHostNumber();
|
202
|
+
let checkPassed = false;
|
203
|
+
switch (checkProp) {
|
204
|
+
case 'session':
|
205
|
+
checkPassed = sessionId === checkValue;
|
206
|
+
break;
|
207
|
+
case 'number':
|
208
|
+
checkPassed = hostAccountNumber.includes(checkValue);
|
209
|
+
break;
|
210
|
+
}
|
211
|
+
if (!checkPassed) {
|
212
|
+
if (PORT)
|
213
|
+
(0, tools_1.processSendData)({ port: PORT });
|
214
|
+
return res.status(412).send({
|
215
|
+
success: false,
|
216
|
+
error: {
|
217
|
+
name: 'CHECK_FAILED',
|
218
|
+
message: `Check FAILED - Are you sure you meant to send the request to this session?`,
|
219
|
+
data: {
|
220
|
+
incomingCheckProperty: checkProp,
|
221
|
+
incomingCheckValue: checkValue,
|
222
|
+
sessionId,
|
223
|
+
hostAccountNumber: `${hostAccountNumber.substr(-4)}`
|
224
|
+
}
|
225
|
+
}
|
226
|
+
});
|
227
|
+
}
|
228
|
+
}
|
197
229
|
if (req.method === 'POST') {
|
198
230
|
const rb = (req === null || req === void 0 ? void 0 : req.body) || {};
|
199
231
|
let { args } = rb;
|
@@ -2229,7 +2261,9 @@ class Client {
|
|
2229
2261
|
*/
|
2230
2262
|
getHostNumber() {
|
2231
2263
|
return __awaiter(this, void 0, void 0, function* () {
|
2232
|
-
|
2264
|
+
if (!this._hostAccountNumber)
|
2265
|
+
this._hostAccountNumber = (yield this.pup(() => WAPI.getHostNumber()));
|
2266
|
+
return this._hostAccountNumber;
|
2233
2267
|
});
|
2234
2268
|
}
|
2235
2269
|
/**
|
package/dist/cli/index.js
CHANGED
@@ -173,7 +173,7 @@ function start() {
|
|
173
173
|
if (createConfig.messagePreprocessor === "AUTO_DECRYPT_SAVE") {
|
174
174
|
(0, server_1.setupMediaMiddleware)();
|
175
175
|
}
|
176
|
-
server_1.app.use(client.middleware((cliConfig && cliConfig.useSessionIdInPath)));
|
176
|
+
server_1.app.use(client.middleware((cliConfig && cliConfig.useSessionIdInPath), PORT));
|
177
177
|
if (cliConfig.socket) {
|
178
178
|
spinner.info("Setting up socket");
|
179
179
|
yield (0, server_1.setupSocketServer)(cliConfig, client);
|
@@ -41,6 +41,7 @@ const fs = __importStar(require("fs/promises"));
|
|
41
41
|
const death_1 = __importDefault(require("death"));
|
42
42
|
// import puppeteer from 'puppeteer-extra';
|
43
43
|
const puppeteer_config_1 = require("../config/puppeteer.config");
|
44
|
+
const puppeteer_1 = require("puppeteer");
|
44
45
|
const events_1 = require("./events");
|
45
46
|
const pico_s3_1 = require("pico-s3");
|
46
47
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
@@ -457,6 +458,11 @@ function initBrowser(sessionId, config = {}, spinner) {
|
|
457
458
|
browserDownloadSpinner.succeed('Something went wrong while downloading the browser');
|
458
459
|
}
|
459
460
|
}
|
461
|
+
/**
|
462
|
+
* Explicit fallback due to pptr 19
|
463
|
+
*/
|
464
|
+
if (!config.executablePath)
|
465
|
+
config.executablePath = (0, puppeteer_1.executablePath)();
|
460
466
|
if (((_a = config === null || config === void 0 ? void 0 : config.proxyServerCredentials) === null || _a === void 0 ? void 0 : _a.address) && (config === null || config === void 0 ? void 0 : config.useNativeProxy))
|
461
467
|
puppeteer_config_1.puppeteerConfig.chromiumArgs.push(`--proxy-server=${config.proxyServerCredentials.address}`);
|
462
468
|
if (config === null || config === void 0 ? void 0 : config.browserWsEndpoint)
|
package/package.json
CHANGED