@open-wa/wa-automate 4.76.0 → 5.0.0-alpha.2
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/README.md +14 -165
- package/dist/cli-runtime-B7_3MM0c.cjs +798 -0
- package/dist/cli-runtime-B7_3MM0c.cjs.map +1 -0
- package/dist/cli-runtime-CmpYxFCk.d.cts +31 -0
- package/dist/cli-runtime-CmpYxFCk.d.cts.map +1 -0
- package/dist/cli.cjs +17 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +2 -0
- package/dist/index.cjs +224 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +81 -0
- package/dist/index.d.cts.map +1 -0
- package/package.json +34 -177
- package/CNAME +0 -1
- package/_tsconfig.docs.json +0 -140
- package/bin/config-schema.json +0 -1
- package/bin/oas-type-schemas.json +0 -1
- package/bin/server.js +0 -45
- package/build/build-config-json-for-bin.ts +0 -56
- package/build/generate-oas-types.ts +0 -31
- package/dist/api/Client.d.ts +0 -2255
- package/dist/api/Client.js +0 -4358
- package/dist/api/functions/exposed.enum.d.ts +0 -7
- package/dist/api/functions/exposed.enum.js +0 -11
- package/dist/api/model/aliases.d.ts +0 -110
- package/dist/api/model/aliases.js +0 -3
- package/dist/api/model/button.d.ts +0 -24
- package/dist/api/model/button.js +0 -2
- package/dist/api/model/call.d.ts +0 -51
- package/dist/api/model/call.js +0 -18
- package/dist/api/model/chat.d.ts +0 -221
- package/dist/api/model/chat.js +0 -52
- package/dist/api/model/config.d.ts +0 -836
- package/dist/api/model/config.js +0 -111
- package/dist/api/model/contact.d.ts +0 -143
- package/dist/api/model/contact.js +0 -2
- package/dist/api/model/errors.d.ts +0 -90
- package/dist/api/model/errors.js +0 -117
- package/dist/api/model/events.d.ts +0 -120
- package/dist/api/model/events.js +0 -127
- package/dist/api/model/group-metadata.d.ts +0 -124
- package/dist/api/model/group-metadata.js +0 -25
- package/dist/api/model/id.d.ts +0 -5
- package/dist/api/model/id.js +0 -2
- package/dist/api/model/index.d.ts +0 -110
- package/dist/api/model/index.js +0 -128
- package/dist/api/model/label.d.ts +0 -24
- package/dist/api/model/label.js +0 -2
- package/dist/api/model/media.d.ts +0 -93
- package/dist/api/model/media.js +0 -12
- package/dist/api/model/message.d.ts +0 -422
- package/dist/api/model/message.js +0 -40
- package/dist/api/model/product.d.ts +0 -141
- package/dist/api/model/product.js +0 -2
- package/dist/api/model/reactions.d.ts +0 -76
- package/dist/api/model/reactions.js +0 -2
- package/dist/api/model/sessionInfo.d.ts +0 -77
- package/dist/api/model/sessionInfo.js +0 -2
- package/dist/build/build-postman.d.ts +0 -1
- package/dist/build/build-postman.js +0 -262
- package/dist/cli/cli-options.d.ts +0 -9
- package/dist/cli/cli-options.js +0 -289
- package/dist/cli/collections.d.ts +0 -2
- package/dist/cli/collections.js +0 -251
- package/dist/cli/file-utils.d.ts +0 -1
- package/dist/cli/file-utils.js +0 -71
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +0 -231
- package/dist/cli/integrations/chatwoot.d.ts +0 -49
- package/dist/cli/integrations/chatwoot.js +0 -672
- package/dist/cli/integrations/cloudflare.d.ts +0 -6
- package/dist/cli/integrations/cloudflare.js +0 -76
- package/dist/cli/logo.d.ts +0 -1
- package/dist/cli/logo.js +0 -49
- package/dist/cli/server.d.ts +0 -24
- package/dist/cli/server.js +0 -540
- package/dist/cli/setup.d.ts +0 -30
- package/dist/cli/setup.js +0 -308
- package/dist/config/puppeteer.config.d.ts +0 -11
- package/dist/config/puppeteer.config.js +0 -65
- package/dist/controllers/auth.d.ts +0 -36
- package/dist/controllers/auth.js +0 -322
- package/dist/controllers/browser.d.ts +0 -17
- package/dist/controllers/browser.js +0 -603
- package/dist/controllers/events.d.ts +0 -82
- package/dist/controllers/events.js +0 -173
- package/dist/controllers/init_patch.d.ts +0 -13
- package/dist/controllers/init_patch.js +0 -42
- package/dist/controllers/initializer.d.ts +0 -22
- package/dist/controllers/initializer.js +0 -511
- package/dist/controllers/launch_checks.d.ts +0 -8
- package/dist/controllers/launch_checks.js +0 -130
- package/dist/controllers/patch_manager.d.ts +0 -37
- package/dist/controllers/patch_manager.js +0 -231
- package/dist/controllers/popup/index.d.ts +0 -3
- package/dist/controllers/popup/index.html +0 -168
- package/dist/controllers/popup/index.js +0 -148
- package/dist/controllers/script_preloader.d.ts +0 -17
- package/dist/controllers/script_preloader.js +0 -88
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -36
- package/dist/lib/README.md +0 -5
- package/dist/lib/base64.js +0 -1
- package/dist/lib/hash.js +0 -1
- package/dist/lib/jsSha.min.js +0 -1
- package/dist/lib/launch.js +0 -1
- package/dist/lib/qr.min.js +0 -1
- package/dist/lib/wapi.js +0 -2163
- package/dist/logging/custom_transport.d.ts +0 -9
- package/dist/logging/custom_transport.js +0 -35
- package/dist/logging/logging.d.ts +0 -50
- package/dist/logging/logging.js +0 -196
- package/dist/structures/Collector.d.ts +0 -202
- package/dist/structures/Collector.js +0 -391
- package/dist/structures/Dialog.d.ts +0 -55
- package/dist/structures/Dialog.js +0 -21
- package/dist/structures/MessageCollector.d.ts +0 -78
- package/dist/structures/MessageCollector.js +0 -145
- package/dist/structures/preProcessors.d.ts +0 -58
- package/dist/structures/preProcessors.js +0 -181
- package/dist/utils/pid_utils.d.ts +0 -1
- package/dist/utils/pid_utils.js +0 -26
- package/dist/utils/tools.d.ts +0 -152
- package/dist/utils/tools.js +0 -494
- package/tos.md +0 -77
package/dist/cli/setup.js
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.cli = exports.configFile = exports.envArgs = exports.helptext = exports.meowFlags = exports.cliOptionNames = exports.PrimitiveConverter = exports.optionKeysWithDefalts = exports.optionKeys = void 0;
|
|
39
|
-
const tools_1 = require("./../utils/tools");
|
|
40
|
-
const command_line_usage_1 = __importDefault(require("command-line-usage"));
|
|
41
|
-
const meow_1 = __importDefault(require("meow"));
|
|
42
|
-
const logo_1 = require("./logo");
|
|
43
|
-
const fs_extra_1 = require("fs-extra");
|
|
44
|
-
const changeCase = __importStar(require("change-case"));
|
|
45
|
-
const file_utils_1 = require("./file-utils");
|
|
46
|
-
const uuid_apikey_1 = __importDefault(require("uuid-apikey"));
|
|
47
|
-
const events_1 = require("../controllers/events");
|
|
48
|
-
const is_url_superb_1 = __importDefault(require("is-url-superb"));
|
|
49
|
-
const path = __importStar(require("path"));
|
|
50
|
-
const fs = __importStar(require("fs"));
|
|
51
|
-
const logging_1 = require("../logging/logging");
|
|
52
|
-
const cli_options_1 = require("./cli-options");
|
|
53
|
-
let checkUrl = url => typeof url === 'string' ? (0, is_url_superb_1.default)(url) : false;
|
|
54
|
-
const configWithCases = (0, fs_extra_1.readJsonSync)(path.join(__dirname, '../../bin/config-schema.json'));
|
|
55
|
-
exports.optionKeys = cli_options_1.optionList.map(({ name }) => (0, tools_1.camelize)(name));
|
|
56
|
-
exports.optionKeysWithDefalts = [...cli_options_1.optionList.filter(o => o.hasOwnProperty('default')).map(({ name }) => (0, tools_1.camelize)(name)), 'popup'];
|
|
57
|
-
exports.PrimitiveConverter = {
|
|
58
|
-
Number: 1,
|
|
59
|
-
Boolean: true,
|
|
60
|
-
String: "hello"
|
|
61
|
-
};
|
|
62
|
-
exports.cliOptionNames = cli_options_1.optionList.reduce((acc, c) => {
|
|
63
|
-
if (!c.type)
|
|
64
|
-
return acc;
|
|
65
|
-
acc[(0, tools_1.camelize)(c.name)] = typeof exports.PrimitiveConverter[c.type.name];
|
|
66
|
-
return acc;
|
|
67
|
-
}, {});
|
|
68
|
-
const meowFlags = () => {
|
|
69
|
-
const extraFlags = {};
|
|
70
|
-
configWithCases.map(({ type, key }) => {
|
|
71
|
-
if (key === "popup")
|
|
72
|
-
type = "number";
|
|
73
|
-
if (key === "viewport")
|
|
74
|
-
type = "string";
|
|
75
|
-
if (key === "stickerServerEndpoint")
|
|
76
|
-
type = "string";
|
|
77
|
-
extraFlags[key] = {
|
|
78
|
-
type
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
const res = {};
|
|
82
|
-
cli_options_1.optionList.map(option => {
|
|
83
|
-
var _a, _b;
|
|
84
|
-
res[(0, tools_1.camelize)(option.name)] = Object.assign(Object.assign({}, option), {
|
|
85
|
-
//@ts-ignore
|
|
86
|
-
type: (_b = (_a = option.type) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase() });
|
|
87
|
-
});
|
|
88
|
-
return Object.assign(Object.assign({}, res), extraFlags);
|
|
89
|
-
};
|
|
90
|
-
exports.meowFlags = meowFlags;
|
|
91
|
-
exports.helptext = (0, command_line_usage_1.default)([{
|
|
92
|
-
content: logo_1.HELP_HEADER,
|
|
93
|
-
raw: true,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
header: '',
|
|
97
|
-
optionList: cli_options_1.optionList
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
header: "Session config flags",
|
|
101
|
-
optionList: [
|
|
102
|
-
...configWithCases.map(c => {
|
|
103
|
-
let type;
|
|
104
|
-
if (c.type === 'boolean')
|
|
105
|
-
type = Boolean;
|
|
106
|
-
if (c.type === 'string')
|
|
107
|
-
type = String;
|
|
108
|
-
if (c.type === '"number"' || c.type === 'number')
|
|
109
|
-
type = Number;
|
|
110
|
-
return {
|
|
111
|
-
name: c.p,
|
|
112
|
-
type,
|
|
113
|
-
description: c.description
|
|
114
|
-
};
|
|
115
|
-
})
|
|
116
|
-
]
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
content: `Please check here for more information on some of the above mentioned parameters: {underline https://docs.openwa.dev/docs/reference/api/model/config/interfaces/ConfigObject}`
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
content: 'Project home: {underline https://github.com/open-wa/wa-automate-nodejs}'
|
|
123
|
-
}
|
|
124
|
-
]);
|
|
125
|
-
const envArgs = () => {
|
|
126
|
-
const env = {};
|
|
127
|
-
Object.entries(process.env).filter(([k,]) => k.includes('WA')).map(([k, v]) => env[changeCase.camelCase(k.replace('WA_', ''))] = (v == 'false' || v == 'FALSE') ? false : (v == 'true' || v == 'TRUE') ? true : Number(v) || v);
|
|
128
|
-
return env;
|
|
129
|
-
};
|
|
130
|
-
exports.envArgs = envArgs;
|
|
131
|
-
const configFile = (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
-
let confFile = null;
|
|
133
|
-
const conf = config || process.env.WA_CLI_CONFIG;
|
|
134
|
-
//check if it is a directory:
|
|
135
|
-
const isDir = fs.existsSync(conf) && fs.lstatSync(conf).isDirectory();
|
|
136
|
-
logging_1.log.info(`Config ${config} is directory: ${isDir}`);
|
|
137
|
-
const backup = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
-
if (!confFile)
|
|
139
|
-
confFile = yield (0, file_utils_1.tryOpenFileAsObject)(`cli.config.json`);
|
|
140
|
-
if (!confFile)
|
|
141
|
-
confFile = yield (0, file_utils_1.tryOpenFileAsObject)(`cli.config.js`);
|
|
142
|
-
});
|
|
143
|
-
const attempt = (firstAttempt, skipBackup) => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
-
try {
|
|
145
|
-
if (!confFile)
|
|
146
|
-
confFile = yield (0, file_utils_1.tryOpenFileAsObject)(firstAttempt || `cli.config.json`);
|
|
147
|
-
if (!skipBackup)
|
|
148
|
-
yield backup();
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
logging_1.log.error(error);
|
|
152
|
-
logging_1.log.error("Trying cli.config.js");
|
|
153
|
-
yield backup();
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
if (conf) {
|
|
157
|
-
if ((0, tools_1.isBase64)(conf)) {
|
|
158
|
-
confFile = JSON.parse(Buffer.from(conf, 'base64').toString('ascii'));
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
if (isDir) {
|
|
162
|
-
yield attempt(`${isDir && conf}/cli.config.json`, true);
|
|
163
|
-
yield attempt(`${isDir && conf}/cli.config.js`, true);
|
|
164
|
-
yield backup();
|
|
165
|
-
}
|
|
166
|
-
else
|
|
167
|
-
yield attempt(conf);
|
|
168
|
-
if (!confFile)
|
|
169
|
-
console.error(`Unable to read config file json: ${conf}`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
yield attempt();
|
|
174
|
-
}
|
|
175
|
-
logging_1.log.info(`Using config file: ${(confFile || {}).confPath || "???"}`);
|
|
176
|
-
return confFile || {};
|
|
177
|
-
});
|
|
178
|
-
exports.configFile = configFile;
|
|
179
|
-
const cli = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
-
var _a;
|
|
181
|
-
let loggingSetup = false;
|
|
182
|
-
const _cli = (0, meow_1.default)(exports.helptext, {
|
|
183
|
-
flags: Object.assign(Object.assign({}, (0, exports.meowFlags)()), { popup: {
|
|
184
|
-
type: 'boolean',
|
|
185
|
-
default: false
|
|
186
|
-
} }),
|
|
187
|
-
booleanDefault: undefined
|
|
188
|
-
});
|
|
189
|
-
process.env.CURRENT_SESSION_ID = ((_a = _cli.flags) === null || _a === void 0 ? void 0 : _a.sessionId) || process.env.WA_SESSION_ID || 'session';
|
|
190
|
-
const _setupLogging = (_config) => {
|
|
191
|
-
if (loggingSetup)
|
|
192
|
-
return;
|
|
193
|
-
//firstly set up logger
|
|
194
|
-
if ((_config === null || _config === void 0 ? void 0 : _config.logging) || (_config === null || _config === void 0 ? void 0 : _config.verbose)) {
|
|
195
|
-
if (!(_config === null || _config === void 0 ? void 0 : _config.logging) && (_config === null || _config === void 0 ? void 0 : _config.verbose))
|
|
196
|
-
_config.logging = [];
|
|
197
|
-
if ((_config === null || _config === void 0 ? void 0 : _config.logging) && !((_config === null || _config === void 0 ? void 0 : _config.logging) || []).find(transport => transport.type === "console"))
|
|
198
|
-
_config.logging.push({ type: 'console' });
|
|
199
|
-
if (Array.isArray(_config === null || _config === void 0 ? void 0 : _config.logging))
|
|
200
|
-
_config.logging = (0, logging_1.setupLogging)(_config === null || _config === void 0 ? void 0 : _config.logging, `easy-api-${(_config === null || _config === void 0 ? void 0 : _config.sessionId) || 'session'}`);
|
|
201
|
-
loggingSetup = true;
|
|
202
|
-
}
|
|
203
|
-
if (_config.verbose)
|
|
204
|
-
_config.disableSpins = true;
|
|
205
|
-
};
|
|
206
|
-
_setupLogging(_cli.flags);
|
|
207
|
-
/**
|
|
208
|
-
* Config order should follow airmanship rules. Least maneuverable to most maneuverable.
|
|
209
|
-
*
|
|
210
|
-
* 1. ENV VARS
|
|
211
|
-
* 2. Config file
|
|
212
|
-
* 3. CLI flags
|
|
213
|
-
*/
|
|
214
|
-
const resolvedConfigFromFile = ((yield (0, exports.configFile)(_cli.flags.config)) || {});
|
|
215
|
-
const nonCliConfigs = Object.assign(Object.assign({}, (0, exports.envArgs)()), resolvedConfigFromFile);
|
|
216
|
-
cli_options_1.optionList.filter(option => option.default);
|
|
217
|
-
const cliConfig = Object.assign(Object.assign(Object.assign({ sessionId: "session" }, nonCliConfigs), _cli.flags), exports.optionKeysWithDefalts.reduce((p, c) => nonCliConfigs.hasOwnProperty(c) ? Object.assign(Object.assign({}, p), { [c]: nonCliConfigs[c] }) : p, {}));
|
|
218
|
-
//firstly set up logger
|
|
219
|
-
_setupLogging(cliConfig);
|
|
220
|
-
process.env.CURRENT_SESSION_ID = cliConfig.sessionId;
|
|
221
|
-
const PORT = Number((typeof cliConfig.forcePort === "boolean" && cliConfig.forcePort ? process.env.PORT : cliConfig.forcePort) || cliConfig.port || process.env.PORT || 8080);
|
|
222
|
-
const spinner = new events_1.Spin(cliConfig.sessionId, 'STARTUP', cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.disableSpins);
|
|
223
|
-
const createConfig = Object.assign({}, cliConfig);
|
|
224
|
-
if (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.session) {
|
|
225
|
-
createConfig.sessionData = cliConfig.session;
|
|
226
|
-
}
|
|
227
|
-
if (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.allowSessionDataWh) {
|
|
228
|
-
cliConfig.allowSessionDataWebhook = cliConfig.allowSessionDataWh;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Build create() specific conig
|
|
232
|
-
*/
|
|
233
|
-
if (((cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.licenseKey) || (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.l))) {
|
|
234
|
-
createConfig.licenseKey = cliConfig.licenseKey || cliConfig.l;
|
|
235
|
-
}
|
|
236
|
-
if (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.popup) {
|
|
237
|
-
createConfig.popup = PORT;
|
|
238
|
-
}
|
|
239
|
-
if (!((cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.key) == null) && (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.key) == "") {
|
|
240
|
-
cliConfig.key = uuid_apikey_1.default.create().apiKey;
|
|
241
|
-
}
|
|
242
|
-
if (cliConfig.viewport && cliConfig.viewport.split && cliConfig.viewport.split('x').length && cliConfig.viewport.split('x').length == 2 && cliConfig.viewport.split('x').map(Number).map(n => !!n ? n : null).filter(n => n).length == 2) {
|
|
243
|
-
const [width, height] = cliConfig.viewport.split('x').map(Number).map(n => !!n ? n : null).filter(n => n);
|
|
244
|
-
createConfig.viewport = { width, height };
|
|
245
|
-
}
|
|
246
|
-
if (cliConfig.resizable) {
|
|
247
|
-
createConfig.defaultViewport = null; // <= set this to have viewport emulation off
|
|
248
|
-
}
|
|
249
|
-
if (cliConfig.sessionDataOnly) {
|
|
250
|
-
events_1.ev.on(`sessionData.**`, (sessionData, sessionId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
251
|
-
(0, fs_extra_1.writeFile)(`${sessionId}.data.json`, JSON.stringify(sessionData), (err) => {
|
|
252
|
-
if (err) {
|
|
253
|
-
spinner.fail(err.message);
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
else
|
|
257
|
-
spinner.succeed(`Session data saved: ${sessionId}.data.json\nClosing.`);
|
|
258
|
-
process.exit();
|
|
259
|
-
});
|
|
260
|
-
}));
|
|
261
|
-
}
|
|
262
|
-
if (cliConfig.skipUrlCheck)
|
|
263
|
-
checkUrl = () => true;
|
|
264
|
-
if (cliConfig.webhook || cliConfig.webhook == '') {
|
|
265
|
-
if (checkUrl(cliConfig.webhook) || Array.isArray(cliConfig.webhook)) {
|
|
266
|
-
spinner.succeed('webhooks set already');
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
if (cliConfig.webhook == '')
|
|
270
|
-
cliConfig.webhook = 'webhooks.json';
|
|
271
|
-
cliConfig.webhook = (0, file_utils_1.tryOpenFileAsObject)(cliConfig.webhook, true);
|
|
272
|
-
if (!checkUrl(cliConfig.webhook)) {
|
|
273
|
-
cliConfig.webhook = undefined;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (cliConfig.twilioWebhook || cliConfig.twilioWebhook == '') {
|
|
278
|
-
if (cliConfig.twilioWebhook == '' && cliConfig.webhook)
|
|
279
|
-
cliConfig.twilioWebhook = cliConfig.webhook;
|
|
280
|
-
if (!checkUrl(cliConfig.twilioWebhook)) {
|
|
281
|
-
cliConfig.twilioWebhook = undefined;
|
|
282
|
-
}
|
|
283
|
-
if (cliConfig.twilioWebhook && (!createConfig.cloudUploadOptions || createConfig.messagePreprocessor !== 'UPLOAD_CLOUD')) {
|
|
284
|
-
spinner.info('twilioWebhook set but messagePreprocessor not set to UPLOAD_CLOUD or cloudUploadOptions is missing');
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (cliConfig.apiHost) {
|
|
288
|
-
cliConfig.apiHost = cliConfig.apiHost.replace(/\/$/, '');
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Check the port in the config
|
|
292
|
-
*/
|
|
293
|
-
cliConfig.port = PORT;
|
|
294
|
-
if (cliConfig.debug) {
|
|
295
|
-
spinner.succeed(`DEBUG - PORT: ${PORT}`);
|
|
296
|
-
spinner.succeed(`DEBUG - flags: ${JSON.stringify(cliConfig)}`);
|
|
297
|
-
const WA_ENV = {};
|
|
298
|
-
Object.keys(process.env).map(k => {
|
|
299
|
-
if (k.startsWith('WA_'))
|
|
300
|
-
WA_ENV[k] = process.env[k];
|
|
301
|
-
});
|
|
302
|
-
spinner.succeed(`DEBUG - env vars: ${JSON.stringify(WA_ENV)}`);
|
|
303
|
-
}
|
|
304
|
-
return {
|
|
305
|
-
createConfig, cliConfig, PORT, spinner
|
|
306
|
-
};
|
|
307
|
-
});
|
|
308
|
-
exports.cli = cli;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare const puppeteerConfig: {
|
|
2
|
-
WAUrl: string;
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
chromiumArgs: string[];
|
|
6
|
-
};
|
|
7
|
-
export declare const createUserAgent: (waVersion: string) => string;
|
|
8
|
-
export declare const useragent: string;
|
|
9
|
-
export { puppeteerConfig };
|
|
10
|
-
export declare const width: number;
|
|
11
|
-
export declare const height: number;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.height = exports.width = exports.puppeteerConfig = exports.useragent = exports.createUserAgent = void 0;
|
|
4
|
-
const puppeteerConfig = {
|
|
5
|
-
WAUrl: 'https://web.whatsapp.com',
|
|
6
|
-
width: 1440,
|
|
7
|
-
height: 900,
|
|
8
|
-
chromiumArgs: [
|
|
9
|
-
// `--app=${WAUrl}`,
|
|
10
|
-
'--log-level=3',
|
|
11
|
-
//'--start-maximized',
|
|
12
|
-
'--no-default-browser-check',
|
|
13
|
-
'--disable-site-isolation-trials',
|
|
14
|
-
'--no-experiments',
|
|
15
|
-
'--ignore-gpu-blacklist',
|
|
16
|
-
'--ignore-certificate-errors',
|
|
17
|
-
'--ignore-certificate-errors-spki-list',
|
|
18
|
-
'--disable-gpu',
|
|
19
|
-
'--disable-extensions',
|
|
20
|
-
'--disable-default-apps',
|
|
21
|
-
'--enable-features=NetworkService',
|
|
22
|
-
'--disable-setuid-sandbox',
|
|
23
|
-
'--no-sandbox',
|
|
24
|
-
// Extras
|
|
25
|
-
'--disable-webgl',
|
|
26
|
-
'--disable-infobars',
|
|
27
|
-
'--window-position=0,0',
|
|
28
|
-
'--ignore-certifcate-errors',
|
|
29
|
-
'--ignore-certifcate-errors-spki-list',
|
|
30
|
-
'--disable-threaded-animation',
|
|
31
|
-
'--disable-threaded-scrolling',
|
|
32
|
-
'--disable-in-process-stack-traces',
|
|
33
|
-
'--disable-histogram-customizer',
|
|
34
|
-
'--disable-gl-extensions',
|
|
35
|
-
'--disable-composited-antialiasing',
|
|
36
|
-
'--disable-session-crashed-bubble',
|
|
37
|
-
'--disable-canvas-aa',
|
|
38
|
-
'--disable-3d-apis',
|
|
39
|
-
'--disable-accelerated-2d-canvas',
|
|
40
|
-
'--disable-accelerated-jpeg-decoding',
|
|
41
|
-
'--disable-accelerated-mjpeg-decode',
|
|
42
|
-
'--disable-app-list-dismiss-on-blur',
|
|
43
|
-
'--disable-accelerated-video-decode',
|
|
44
|
-
'--disable-dev-shm-usage',
|
|
45
|
-
'--js-flags=--expose-gc',
|
|
46
|
-
// '--incognito',
|
|
47
|
-
//suggested in #563
|
|
48
|
-
// '--single-process',
|
|
49
|
-
// '--no-zygote',
|
|
50
|
-
// '--renderer-process-limit=1',
|
|
51
|
-
// '--no-first-run'
|
|
52
|
-
'--disable-features=site-per-process',
|
|
53
|
-
'--disable-gl-drawing-for-tests',
|
|
54
|
-
//keep awake in all situations
|
|
55
|
-
'--disable-background-timer-throttling',
|
|
56
|
-
'--disable-backgrounding-occluded-windows',
|
|
57
|
-
'--disable-renderer-backgrounding'
|
|
58
|
-
]
|
|
59
|
-
};
|
|
60
|
-
exports.puppeteerConfig = puppeteerConfig;
|
|
61
|
-
const createUserAgent = (waVersion) => `WhatsApp/${waVersion} Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`;
|
|
62
|
-
exports.createUserAgent = createUserAgent;
|
|
63
|
-
exports.useragent = (0, exports.createUserAgent)('2.2147.16');
|
|
64
|
-
exports.width = puppeteerConfig.width;
|
|
65
|
-
exports.height = puppeteerConfig.height;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { Spin } from './events';
|
|
3
|
-
import { ConfigObject } from '../api/model';
|
|
4
|
-
import { Page } from 'puppeteer';
|
|
5
|
-
/**
|
|
6
|
-
* isAuthenticated
|
|
7
|
-
* Validates if client is authenticated
|
|
8
|
-
* @returns true if is authenticated, false otherwise
|
|
9
|
-
* @param waPage
|
|
10
|
-
*/
|
|
11
|
-
export declare const isAuthenticated: (waPage: Page) => Promise<unknown>;
|
|
12
|
-
export declare const needsToScan: (waPage: Page) => Observable<unknown>;
|
|
13
|
-
export declare const waitForRipeSession: (waPage: Page, waitForRipeSessionTimeout?: number) => Promise<boolean>;
|
|
14
|
-
export declare const sessionDataInvalid: (waPage: Page) => Promise<string>;
|
|
15
|
-
export declare const phoneIsOutOfReach: (waPage: Page) => Promise<boolean>;
|
|
16
|
-
export declare class QRManager {
|
|
17
|
-
qrEv: any;
|
|
18
|
-
qrNum: number;
|
|
19
|
-
hash: string;
|
|
20
|
-
config: ConfigObject;
|
|
21
|
-
firstEmitted: boolean;
|
|
22
|
-
_internalQrPngLoaded: boolean;
|
|
23
|
-
qrCheck: string;
|
|
24
|
-
constructor(config?: any);
|
|
25
|
-
setConfig(config: any): void;
|
|
26
|
-
qrEvF(config?: ConfigObject): any;
|
|
27
|
-
grabAndEmit(qrData: any, waPage: Page, config: ConfigObject, spinner: Spin): Promise<void>;
|
|
28
|
-
linkCode(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<boolean | void | string>;
|
|
29
|
-
smartQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<boolean | void | string>;
|
|
30
|
-
emitFirst(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Wait 10 seconds for the qr element to show.
|
|
33
|
-
* If it doesn't show up within 10 seconds then assume the session is authed already or blocked therefore ignore and return promise
|
|
34
|
-
*/
|
|
35
|
-
waitFirstQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<void>;
|
|
36
|
-
}
|