diff --git a/package-lock.json b/package-lock.json index cb20456af2..9645221f03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,6 +36,7 @@ "image-type": "^4.1.0", "is-url-superb": "^5.0.0", "json5": "^2.2.0", + "localtunnel": "^2.0.2", "lodash.uniq": "^4.5.0", "meow": "^9.0.0", "node-persist": "^3.1.0", @@ -88,6 +89,7 @@ "@types/express": "^4.17.11", "@types/fs-extra": "^9.0.11", "@types/line-reader": "0.0.34", + "@types/localtunnel": "^2.0.1", "@types/marked": "^3.0.0", "@types/mime-types": "^2.1.0", "@types/node": "^16.0.0", @@ -866,6 +868,15 @@ "@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": "3.0.1", "resolved": "https://registry.npmjs.org/@types/marked/-/marked-3.0.1.tgz", @@ -6220,14 +6231,14 @@ } }, "node_modules/localtunnel": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/localtunnel/-/localtunnel-2.0.1.tgz", - "integrity": "sha512-LiaI5wZdz0xFkIQpXbNI62ZnNn8IMsVhwxHmhA+h4vj8R9JG/07bQHWwQlyy7b95/5fVOCHJfIHv+a5XnkvaJA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/localtunnel/-/localtunnel-2.0.2.tgz", + "integrity": "sha512-n418Cn5ynvJd7m/N1d9WVJISLJF/ellZnfsLnx8WBWGzxv/ntNcFkJ1o6se5quUhCplfLGBNL5tYHiq5WF3Nug==", "dependencies": { - "axios": "0.21.1", - "debug": "4.3.1", + "axios": "0.21.4", + "debug": "4.3.2", "openurl": "1.1.1", - "yargs": "16.2.0" + "yargs": "17.1.1" }, "bin": { "lt": "bin/lt.js" @@ -6236,18 +6247,10 @@ "node": ">=8.3.0" } }, - "node_modules/localtunnel/node_modules/axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", - "dependencies": { - "follow-redirects": "^1.10.0" - } - }, "node_modules/localtunnel/node_modules/debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", "dependencies": { "ms": "2.1.2" }, @@ -6265,6 +6268,23 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/localtunnel/node_modules/yargs": { + "version": "17.1.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.1.1.tgz", + "integrity": "sha512-c2k48R0PwKIqKhPMWjeiF6y2xY/gPMUlro0sgxqXpbOIohWiLNXWslsootttv7E1e73QPAMQSg5FeySbVcpsPQ==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -12140,6 +12160,7 @@ "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, "dependencies": { "cliui": "^7.0.2", "escalade": "^3.1.1", @@ -12827,6 +12848,15 @@ "@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": "3.0.1", "resolved": "https://registry.npmjs.org/@types/marked/-/marked-3.0.1.tgz", @@ -16873,28 +16903,20 @@ } }, "localtunnel": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/localtunnel/-/localtunnel-2.0.1.tgz", - "integrity": "sha512-LiaI5wZdz0xFkIQpXbNI62ZnNn8IMsVhwxHmhA+h4vj8R9JG/07bQHWwQlyy7b95/5fVOCHJfIHv+a5XnkvaJA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/localtunnel/-/localtunnel-2.0.2.tgz", + "integrity": "sha512-n418Cn5ynvJd7m/N1d9WVJISLJF/ellZnfsLnx8WBWGzxv/ntNcFkJ1o6se5quUhCplfLGBNL5tYHiq5WF3Nug==", "requires": { - "axios": "0.21.1", - "debug": "4.3.1", + "axios": "0.21.4", + "debug": "4.3.2", "openurl": "1.1.1", - "yargs": "16.2.0" + "yargs": "17.1.1" }, "dependencies": { - "axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", - "requires": { - "follow-redirects": "^1.10.0" - } - }, "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", "requires": { "ms": "2.1.2" } @@ -16903,6 +16925,20 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "yargs": { + "version": "17.1.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.1.1.tgz", + "integrity": "sha512-c2k48R0PwKIqKhPMWjeiF6y2xY/gPMUlro0sgxqXpbOIohWiLNXWslsootttv7E1e73QPAMQSg5FeySbVcpsPQ==", + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } } } }, @@ -21328,6 +21364,7 @@ "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, "requires": { "cliui": "^7.0.2", "escalade": "^3.1.1", diff --git a/package.json b/package.json index b0861cdfd7..925acf29b2 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "4.23.18", "licenseCheckUrl": "https://openwa.dev/license-check", "brokenMethodReportUrl": "https://openwa.dev/report-bm", - "patches": "https://cdn.openwa.dev/patches.json", + "patches": "http://127.0.0.1:5503/functions/patches.json", "stickerUrl": "https://sticker-api.openwa.dev", "description": " 💬 🤖 The most reliable NodeJS whatsapp library for chatbots with advanced features.", "main": "dist/index.js", @@ -69,6 +69,7 @@ "@types/express": "^4.17.11", "@types/fs-extra": "^9.0.11", "@types/line-reader": "0.0.34", + "@types/localtunnel": "^2.0.1", "@types/marked": "^3.0.0", "@types/mime-types": "^2.1.0", "@types/node": "^16.0.0", @@ -124,6 +125,7 @@ "image-type": "^4.1.0", "is-url-superb": "^5.0.0", "json5": "^2.2.0", + "localtunnel": "^2.0.2", "lodash.uniq": "^4.5.0", "meow": "^9.0.0", "node-persist": "^3.1.0", diff --git a/src/cli/index.ts b/src/cli/index.ts index 9b9637c17d..6a1823d726 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -6,6 +6,7 @@ import { default as axios } from 'axios' import { cli } from './setup'; import { collections, generateCollections } from './collections'; import { setUpExpressApp, setupAuthenticationLayer, setupRefocusDisengageMiddleware, setupApiDocs, setupSwaggerStatsMiddleware, setupMediaMiddleware, app, setupSocketServer, server, setupBotPressHandler, setupTwilioCompatibleWebhook, enableCORSRequests } from './server'; +import localtunnel from 'localtunnel'; let checkUrl = (s : any) => (typeof s === "string") && isUrl(s); @@ -166,6 +167,11 @@ async function start() { spinner.succeed(`\n• Listening on port ${PORT}!`); await ready({...cliConfig, ...createConfig, ...client.getSessionInfo(), hostAccountNumber: await client.getHostNumber()}); }); + if(cliConfig.tunnel) { + spinner.info(`\n• Setting up external tunnel`); + const tunnel = await localtunnel({ port: PORT }); + spinner.succeed(`\n\t${terminalLink('External address', tunnel.url)}`) + } const apiDocsUrl = cliConfig.apiHost ? `${cliConfig.apiHost}/api-docs/ ` : `${cliConfig.host.includes('http') ? '' : 'http://'}${cliConfig.host}:${PORT}/api-docs/ `; const link = terminalLink('API Explorer', apiDocsUrl); if (cliConfig && cliConfig.generateApiDocs) spinner.succeed(`\n\t${link}`) diff --git a/src/cli/setup.ts b/src/cli/setup.ts index 19f9e1aabc..f87eef46fc 100644 --- a/src/cli/setup.ts +++ b/src/cli/setup.ts @@ -229,6 +229,11 @@ const optionList: type: Boolean, description: "Don't validate webhook URLs. Enables use of non-FQDNs." }, + { + name: 'tunnel', + type: Boolean, + description: "Expose a tunnel to your EASY API session - this is for testing and it is unsecured." + }, { name: 'help', description: 'Print this usage guide.'