diff --git a/package-lock.json b/package-lock.json index 0a43239c6d..44a427365a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "dependencies": { "@brillout/import": "^0.2.1", "@discordjs/collection": "0.8.0", - "@open-wa/wa-automate-socket-client": "*", + "@open-wa/wa-automate-socket-client": "^3.3.0", "@open-wa/wa-decrypt": "^4.3.1", "atob": "^2.1.2", "aws4": "^1.11.0", @@ -22,6 +22,7 @@ "change-case": "^4.1.2", "chokidar": "^3.5.3", "chrome-launcher": "^0.15.0", + "cloudflared": "^0.5.1", "command-exists": "^1.2.9", "command-line-usage": "^6.1.1", "cors": "^2.8.5", @@ -44,7 +45,6 @@ "is-url-superb": "^5.0.0", "json5": "^2.2.0", "klona": "^2.0.5", - "localtunnel": "^2.0.2", "lodash.uniq": "^4.5.0", "meow": "^9.0.0", "mime": "^3.0.0", @@ -101,7 +101,6 @@ "@types/express": "^4.17.11", "@types/fs-extra": "^9.0.11", "@types/line-reader": "0.0.34", - "@types/localtunnel": "^2.0.1", "@types/marked": "^4.0.2", "@types/mime": "^3.0.1", "@types/node": "^18.7.6", @@ -2638,15 +2637,16 @@ } }, "node_modules/@open-wa/wa-automate-socket-client": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@open-wa/wa-automate-socket-client/-/wa-automate-socket-client-2.2.1.tgz", - "integrity": "sha512-yU8vYQSDRtYLgcUuPdyhEFx52Iya1qZruIhdAzXupkNEG8kDIkH0OEaplmQk5KR23itr0LY6rDEGv44Hg69Cug==", + "version": "3.3.0", + "resolved": "https://registry.openwa.cloud/@open-wa/wa-automate-socket-client/-/wa-automate-socket-client-3.3.0.tgz", + "integrity": "sha512-+y/ZYsEr8XSr2lWQC5891OEasphyCD7DEp3R+uTjneZrjUuBCXlcZq6mJYeHckC5CuRorJETKC30KHQQmhbjgw==", "dependencies": { + "@discordjs/collection": "^0.8.0", "@open-wa/wa-automate-types-only": "*", "debug": "^4.3.4", - "eventemitter2": "^6.4.5", - "socket.io-client": "^4.4.1", - "uuid": "^8.3.2" + "eventemitter2": "^6.4.9", + "socket.io-client": "^4.6.1", + "uuid": "^9.0.0" } }, "node_modules/@open-wa/wa-automate-socket-client/node_modules/debug": { @@ -3048,15 +3048,6 @@ "@types/node": "*" } }, - "node_modules/@types/localtunnel": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/localtunnel/-/localtunnel-2.0.1.tgz", - "integrity": "sha512-0h/ggh+tp9uKHc2eEOLdMgWW0cNwsQfn6iEE1Y44FszNB4BQyL5N6xvd5BnChZksB0YgVqa5MKxJt0dFoOKRxw==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/marked": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.2.tgz", @@ -6597,6 +6588,15 @@ "mimic-response": "^1.0.0" } }, + "node_modules/cloudflared": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/cloudflared/-/cloudflared-0.5.1.tgz", + "integrity": "sha512-DQ33z5dBrE32xrHRyA35CtE8WcDgOzefR0/x/gVVa2jSKc54vRTIDwNQXCbXcet3sv2DOVtLWUbdcjxbCYK+OQ==", + "hasInstallScript": true, + "bin": { + "cloudflared": "lib/cloudflared.js" + } + }, "node_modules/coa": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/coa/-/coa-2.0.2.tgz", @@ -8744,14 +8744,14 @@ } }, "node_modules/engine.io-client": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.3.tgz", - "integrity": "sha512-aXPtgF1JS3RuuKcpSrBtimSjYvrbhKW9froICH4s0F3XQWLxsKNxqzG39nnvQZQnva4CMvUK63T7shevxRyYHw==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", + "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", - "engine.io-parser": "~5.0.3", - "ws": "~8.2.3", + "engine.io-parser": "~5.2.1", + "ws": "~8.11.0", "xmlhttprequest-ssl": "~2.0.0" } }, @@ -8771,11 +8771,39 @@ } } }, + "node_modules/engine.io-client/node_modules/engine.io-parser": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.2.tgz", + "integrity": "sha512-RcyUFKA93/CXH20l4SoVvzZfrSDMOTUS3bWVpTt2FuFP+XYrL8i8oonHP7WInRyVHXh0n/ORtoeiE1os+8qkSw==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/engine.io-client/node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/engine.io-client/node_modules/ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/engine.io-parser": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.3.tgz", @@ -9400,9 +9428,9 @@ } }, "node_modules/eventemitter2": { - "version": "6.4.7", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.7.tgz", - "integrity": "sha512-tYUSVOGeQPKt/eC1ABfhHy5Xd96N3oIijJvN3O9+TsC28T5V9yX9oEfEK5faP0EFSNVOG97qtAS68GBrQB2hDg==" + "version": "6.4.9", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.9.tgz", + "integrity": "sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==" }, "node_modules/eventemitter3": { "version": "4.0.7", @@ -21087,14 +21115,14 @@ "integrity": "sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg==" }, "node_modules/socket.io-client": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.5.4.tgz", - "integrity": "sha512-ZpKteoA06RzkD32IbqILZ+Cnst4xewU7ZYK12aS1mzHftFFjpoMz69IuhP/nL25pJfao/amoPI527KnuhFm01g==", + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.4.tgz", + "integrity": "sha512-wh+OkeF0rAVCrABWQBaEjLfb7DVPotMbu0cgWgyR0v6eA4EoVnAwcIeIbcdTE3GT/H3kbdLl7OoH2+asoDRIIg==", "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.2", - "engine.io-client": "~6.2.3", - "socket.io-parser": "~4.2.1" + "engine.io-client": "~6.5.2", + "socket.io-parser": "~4.2.4" }, "engines": { "node": ">=10.0.0" @@ -21122,9 +21150,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/socket.io-parser": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.1.tgz", - "integrity": "sha512-V4GrkLy+HeF1F/en3SpUaM+7XxYXpuMUWLGde1kSSh5nQMN4hLrbPIkD+otwh6q9R6NOQBN4AMaOZ2zVjui82g==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", + "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1" @@ -26262,14 +26290,15 @@ "integrity": "sha512-T8TbSnGsxo6TDBJx/Sgv/BlVJL3tshxZP7Aq5R1mSnM5OcHY2dQaxLMu2+E8u3gN0MLOzdjurqN4ZRVuzQycOQ==" }, "@open-wa/wa-automate-socket-client": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@open-wa/wa-automate-socket-client/-/wa-automate-socket-client-2.2.1.tgz", - "integrity": "sha512-yU8vYQSDRtYLgcUuPdyhEFx52Iya1qZruIhdAzXupkNEG8kDIkH0OEaplmQk5KR23itr0LY6rDEGv44Hg69Cug==", + "version": "3.3.0", + "resolved": "https://registry.openwa.cloud/@open-wa/wa-automate-socket-client/-/wa-automate-socket-client-3.3.0.tgz", + "integrity": "sha512-+y/ZYsEr8XSr2lWQC5891OEasphyCD7DEp3R+uTjneZrjUuBCXlcZq6mJYeHckC5CuRorJETKC30KHQQmhbjgw==", "requires": { + "@discordjs/collection": "^0.8.0", "@open-wa/wa-automate-types-only": "*", "debug": "^4.3.4", - "eventemitter2": "^6.4.5", - "socket.io-client": "^4.4.1", + "eventemitter2": "^6.4.9", + "socket.io-client": "^4.6.1", "uuid": "^9.0.0" }, "dependencies": { @@ -26623,15 +26652,6 @@ "@types/node": "*" } }, - "@types/localtunnel": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/localtunnel/-/localtunnel-2.0.1.tgz", - "integrity": "sha512-0h/ggh+tp9uKHc2eEOLdMgWW0cNwsQfn6iEE1Y44FszNB4BQyL5N6xvd5BnChZksB0YgVqa5MKxJt0dFoOKRxw==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/marked": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.2.tgz", @@ -29285,6 +29305,11 @@ "mimic-response": "^1.0.0" } }, + "cloudflared": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/cloudflared/-/cloudflared-0.5.1.tgz", + "integrity": "sha512-DQ33z5dBrE32xrHRyA35CtE8WcDgOzefR0/x/gVVa2jSKc54vRTIDwNQXCbXcet3sv2DOVtLWUbdcjxbCYK+OQ==" + }, "coa": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/coa/-/coa-2.0.2.tgz", @@ -31022,14 +31047,14 @@ } }, "engine.io-client": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.3.tgz", - "integrity": "sha512-aXPtgF1JS3RuuKcpSrBtimSjYvrbhKW9froICH4s0F3XQWLxsKNxqzG39nnvQZQnva4CMvUK63T7shevxRyYHw==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", + "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", "requires": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", - "engine.io-parser": "~5.0.3", - "ws": "~8.2.3", + "engine.io-parser": "~5.2.1", + "ws": "~8.11.0", "xmlhttprequest-ssl": "~2.0.0" }, "dependencies": { @@ -31041,10 +31066,21 @@ "ms": "2.1.2" } }, + "engine.io-parser": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.2.tgz", + "integrity": "sha512-RcyUFKA93/CXH20l4SoVvzZfrSDMOTUS3bWVpTt2FuFP+XYrL8i8oonHP7WInRyVHXh0n/ORtoeiE1os+8qkSw==" + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "requires": {} } } }, @@ -31510,9 +31546,9 @@ } }, "eventemitter2": { - "version": "6.4.7", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.7.tgz", - "integrity": "sha512-tYUSVOGeQPKt/eC1ABfhHy5Xd96N3oIijJvN3O9+TsC28T5V9yX9oEfEK5faP0EFSNVOG97qtAS68GBrQB2hDg==" + "version": "6.4.9", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.9.tgz", + "integrity": "sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==" }, "eventemitter3": { "version": "4.0.7", @@ -40423,14 +40459,14 @@ "integrity": "sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg==" }, "socket.io-client": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.5.4.tgz", - "integrity": "sha512-ZpKteoA06RzkD32IbqILZ+Cnst4xewU7ZYK12aS1mzHftFFjpoMz69IuhP/nL25pJfao/amoPI527KnuhFm01g==", + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.4.tgz", + "integrity": "sha512-wh+OkeF0rAVCrABWQBaEjLfb7DVPotMbu0cgWgyR0v6eA4EoVnAwcIeIbcdTE3GT/H3kbdLl7OoH2+asoDRIIg==", "requires": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.2", - "engine.io-client": "~6.2.3", - "socket.io-parser": "~4.2.1" + "engine.io-client": "~6.5.2", + "socket.io-parser": "~4.2.4" }, "dependencies": { "debug": { @@ -40449,9 +40485,9 @@ } }, "socket.io-parser": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.1.tgz", - "integrity": "sha512-V4GrkLy+HeF1F/en3SpUaM+7XxYXpuMUWLGde1kSSh5nQMN4hLrbPIkD+otwh6q9R6NOQBN4AMaOZ2zVjui82g==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", + "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", "requires": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1" diff --git a/package.json b/package.json index ee7f27b868..620a051072 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,6 @@ "@types/express": "^4.17.11", "@types/fs-extra": "^9.0.11", "@types/line-reader": "0.0.34", - "@types/localtunnel": "^2.0.1", "@types/marked": "^4.0.2", "@types/mime": "^3.0.1", "@types/node": "^18.7.6", @@ -106,7 +105,7 @@ "dependencies": { "@brillout/import": "^0.2.1", "@discordjs/collection": "0.8.0", - "@open-wa/wa-automate-socket-client": "*", + "@open-wa/wa-automate-socket-client": "^3.3.0", "@open-wa/wa-decrypt": "^4.3.1", "atob": "^2.1.2", "aws4": "^1.11.0", @@ -116,6 +115,7 @@ "change-case": "^4.1.2", "chokidar": "^3.5.3", "chrome-launcher": "^0.15.0", + "cloudflared": "^0.5.1", "command-exists": "^1.2.9", "command-line-usage": "^6.1.1", "cors": "^2.8.5", @@ -138,7 +138,6 @@ "is-url-superb": "^5.0.0", "json5": "^2.2.0", "klona": "^2.0.5", - "localtunnel": "^2.0.2", "lodash.uniq": "^4.5.0", "meow": "^9.0.0", "mime": "^3.0.0", diff --git a/src/cli/cli-options.ts b/src/cli/cli-options.ts index dd864285d1..ca681732dc 100644 --- a/src/cli/cli-options.ts +++ b/src/cli/cli-options.ts @@ -244,7 +244,19 @@ Merge Promise<{ + url: string; + connections: Promise[]; + child: any; + stop: () => Promise; +}> = async (cliConfig, PORT: number) => { + const {cfTunnelHostDomain, sessionId, cfTunnelNamespace} = cliConfig; + const sessionName = sessionId.replace(/[^A-Z0-9]/ig, "_").toLowerCase(); + const tunnelName = `_owa_${sessionName}` + const FQDN = `${sessionName}${cfTunnelNamespace ? `.${cfTunnelNamespace}` : `_owa`}.${cfTunnelHostDomain}` + const hostname = `https://${FQDN}` + const target = `http://localhost:${PORT}` + const logData = (data) => log.info(`CLOUDFLARE TUNNEL: ${typeof data === "object" ? JSON.stringify(data,null,2) : data}`); + // simlpe helper function to convert child proc to a promise and log the output + const cfp = (child) => { + return new Promise((resolve, reject) => { + child.stdout?.on('data', logData); + child.stderr?.on('data', logData); + child.on('error', reject); + child.on('exit', (code) => { + if (code === 0) { + resolve(true); + } else { + reject(`Exit code: ${code}`); + } + }); + }); + } + log.info(`Checking if tunnel ${tunnelName} exists...`) + const tunnelExists = await new Promise((resolve) => { + const check = (data) => { + logData(data.toString()) + return resolve(!data.toString().includes("error")) + } + const {child} = tunnel({ "info": tunnelName }) + child.stdout.once('data', check) + child.stderr.once('data', check) + }); + if (!tunnelExists) { + log.info("Tunnel does not exist, creating...") + await cfp(tunnel({ "create": tunnelName }).child); + } + log.info(`Routing traffic to the tunnel via URL ${FQDN}...`) + await cfp(tunnel({ "route": "dns", "--overwrite-dns": null, [tunnelName]: FQDN }).child) + const { connections, child, stop } = tunnel({ + "--url": target, + "--hostname": hostname, + "run": tunnelName + }) + child.stdout.on('data', logData) + + // wait for the all 4 connections to be established + const conns = await Promise.all(connections); + // show the connections + log.info("Connections Ready!", conns); + + return { + url: hostname, + connections, + child, + stop: async () => { + stop(); + await cfp(tunnel({ "delete": tunnelName }).child) + } + } +} \ No newline at end of file diff --git a/src/cli/server.ts b/src/cli/server.ts index 360f1b1606..05f07a7d6a 100644 --- a/src/cli/server.ts +++ b/src/cli/server.ts @@ -14,13 +14,17 @@ import { convert } from 'xmlbuilder2'; import { chatwootMiddleware, chatwoot_webhook_check_event_name } from './integrations/chatwoot'; import {IpFilter, IpDeniedError} from'express-ipfilter' import helmet from "helmet"; -import localtunnel from 'localtunnel'; +import { tunnel } from "cloudflared"; + import { spawn } from 'child_process'; +import { createCustomDomainTunnel } from './integrations/cloudflare'; export const app = express(); export let server = http.createServer(app); -let tunnel : localtunnel.Tunnel; +// will be used to clean up cloudflared tunnel +let stop; + const trimChatId = (chatId : ChatId) => chatId.replace("@c.us","").replace("@g.us","") export type cliFlags = { @@ -238,7 +242,7 @@ export const setupMetaProcessMiddleware = (client : Client, cliConfig) => { closing = true; await client.kill("API_KILL"); log.info("Waiting for maximum ") - if(tunnel && tunnel.close && typeof tunnel.close === 'function') tunnel.close() + if(stop && typeof stop === 'function') stop() await Promise.race([ new Promise((resolve)=>server.close(() => { console.log('Server closed'); @@ -287,19 +291,18 @@ export const listListeners : () => string[] = () => { return Object.keys(SimpleListener).map(eventKey => SimpleListener[eventKey]) } - export const setupMediaMiddleware : () => void = () => { app.use("/media", express.static('media')) } -export const setupTunnel : (cliConfig, tunnelCode: string, PORT: number) => Promise = async (cliConfig, tunnelCode: string,PORT: number) => { - tunnel = await localtunnel({ - port: PORT, - host: process.env.WA_TUNNEL_SERVER || "https://public.openwa.cloud", - subdomain: tunnelCode - }); - cliConfig.apiHost = cliConfig.tunnel = tunnel.url; - return tunnel.url; +export const setupTunnel : (cliConfig, PORT: number) => Promise = async (cliConfig, PORT: number) => { + const cfT = cliConfig.cfTunnelHostDomain ? await createCustomDomainTunnel(cliConfig,PORT) : tunnel({ "--url": `localhost:${PORT}` }); + stop = cfT.stop; + const url = await cfT.url; + const conns = await Promise.all(cfT.connections); + log.info(`Connections Ready! ${conns}`) + cliConfig.apiHost = cliConfig.tunnel = url; + return url; } export const setupTwilioCompatibleWebhook : (cliConfig : cliFlags, client: Client) => void = (cliConfig : cliFlags, client: Client) => { diff --git a/src/controllers/initializer.ts b/src/controllers/initializer.ts index a59fa546d0..d79fc20214 100755 --- a/src/controllers/initializer.ts +++ b/src/controllers/initializer.ts @@ -296,6 +296,7 @@ export async function create(config: AdvancedConfig | ConfigObject = {}): Promis spinner.succeed(); } if(config.logInternalEvents) await waPage.evaluate("debugEvents=true") + await waPage.evaluate("window.critlis=true") const tI = await timePromise(()=> injectInternalEventHandler(waPage)) log.info(`Injected internal event handler: ${tI} ms`) if(attemptingReauth) {