@open-wa/wa-automate 4.47.4 → 4.47.5

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
@@ -44,7 +44,7 @@ function start() {
44
44
  spinner.start("Launching EASY API");
45
45
  (0, server_1.setUpExpressApp)();
46
46
  if (cliConfig.cors)
47
- yield (0, server_1.enableCORSRequests)();
47
+ yield (0, server_1.enableCORSRequests)(cliConfig);
48
48
  try {
49
49
  const { status, data } = yield axios_1.default.post(`http://localhost:${PORT}/getConnectionState`);
50
50
  if (status === 200 && data.response === "CONNECTED") {
@@ -8,7 +8,7 @@ export declare type cliFlags = {
8
8
  };
9
9
  export declare const setupHttpServer: (cliConfig: cliFlags) => void;
10
10
  export declare const setUpExpressApp: () => void;
11
- export declare const enableCORSRequests: () => void;
11
+ export declare const enableCORSRequests: (cliConfig: cliFlags) => void;
12
12
  export declare const setupAuthenticationLayer: (cliConfig: cliFlags) => void;
13
13
  export declare const setupApiDocs: (cliConfig: cliFlags) => void;
14
14
  export declare const setupSwaggerStatsMiddleware: (cliConfig: cliFlags) => Promise<void>;
@@ -114,9 +114,9 @@ const setUpExpressApp = () => {
114
114
  setupMetaMiddleware();
115
115
  };
116
116
  exports.setUpExpressApp = setUpExpressApp;
117
- const enableCORSRequests = () => __awaiter(void 0, void 0, void 0, function* () {
117
+ const enableCORSRequests = (cliConfig) => __awaiter(void 0, void 0, void 0, function* () {
118
118
  const { default: cors } = yield Promise.resolve().then(() => __importStar(require('cors')));
119
- exports.app.use(cors());
119
+ exports.app.use(cors(typeof cliConfig.cors === 'object' && cliConfig.cors));
120
120
  });
121
121
  exports.enableCORSRequests = enableCORSRequests;
122
122
  const setupAuthenticationLayer = (cliConfig) => {
@@ -383,7 +383,13 @@ const setupBotPressHandler = (cliConfig, client) => {
383
383
  exports.setupBotPressHandler = setupBotPressHandler;
384
384
  const setupSocketServer = (cliConfig, client) => __awaiter(void 0, void 0, void 0, function* () {
385
385
  const { Server } = yield Promise.resolve().then(() => __importStar(require("socket.io")));
386
- const io = new Server(exports.server);
386
+ const socketServerOptions = cliConfig.cors ? {
387
+ cors: typeof cliConfig.cors === 'object' ? cliConfig.cors : {
388
+ origin: "*",
389
+ methods: ["GET", "POST"],
390
+ },
391
+ } : null;
392
+ const io = socketServerOptions ? new Server(exports.server, socketServerOptions) : new Server(exports.server);
387
393
  if (cliConfig.key) {
388
394
  io.use((socket, next) => {
389
395
  if (socket.handshake.auth["apiKey"] == cliConfig.key)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.47.4",
3
+ "version": "4.47.5",
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",