@open-wa/wa-automate 4.24.2 → 4.26.1
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/bin/config-schema.json +1 -1
- package/dist/api/Client.d.ts +8 -1
- package/dist/api/Client.js +40 -16
- package/dist/api/model/config.d.ts +5 -0
- package/dist/cli/index.js +8 -5
- package/dist/cli/integrations/chatwoot.d.ts +6 -0
- package/dist/cli/integrations/chatwoot.js +234 -0
- package/dist/cli/server.d.ts +1 -0
- package/dist/cli/server.js +7 -1
- package/dist/cli/setup.js +10 -0
- package/dist/config/puppeteer.config.js +5 -1
- package/dist/controllers/auth.js +12 -8
- package/dist/controllers/initializer.d.ts +1 -36
- package/dist/controllers/initializer.js +21 -165
- package/dist/controllers/patch_manager.d.ts +37 -0
- package/dist/controllers/patch_manager.js +219 -0
- package/dist/structures/Dialog.d.ts +55 -0
- package/dist/structures/Dialog.js +21 -0
- package/dist/utils/tools.d.ts +1 -0
- package/dist/utils/tools.js +27 -10
- package/package.json +1 -1
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ValidationType = void 0;
|
4
|
+
var ValidationType;
|
5
|
+
(function (ValidationType) {
|
6
|
+
ValidationType["REGEX"] = "regex";
|
7
|
+
ValidationType["LENGTH"] = "length";
|
8
|
+
ValidationType["CHECK"] = "check";
|
9
|
+
})(ValidationType = exports.ValidationType || (exports.ValidationType = {}));
|
10
|
+
// async function processDialog(dialog: DialogTemplate, chatId: ChatId, client: Client){
|
11
|
+
// if(dialog.privateOnly && chatId.includes('g')) return;
|
12
|
+
// const requiredProperties = Object.keys(dialog.properties);
|
13
|
+
// const requiredPropertiesInOrder = requiredProperties.map(prop=>dialog.properties[prop]).sort((a, b) => a.order - b.order);
|
14
|
+
// /**
|
15
|
+
// * Send start dialog message
|
16
|
+
// */
|
17
|
+
// await client.sendText(chatId, dialog.startMessage);
|
18
|
+
// requiredPropertiesInOrder.map((diaProp: DialogProperty) => {
|
19
|
+
// diaProp.type
|
20
|
+
// })
|
21
|
+
// }
|
package/dist/utils/tools.d.ts
CHANGED
@@ -24,3 +24,4 @@ export declare const getDUrl: (url: string, optionsOverride?: AxiosRequestConfig
|
|
24
24
|
* Use this to extract the mime type from a [[DataURL]]
|
25
25
|
*/
|
26
26
|
export declare const base64MimeType: (dUrl: DataURL) => string;
|
27
|
+
export declare const processSend: (message: string) => void;
|
package/dist/utils/tools.js
CHANGED
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.base64MimeType = exports.getDUrl = exports.isDataURL = exports.isBase64 = exports.camelize = exports.without = exports.getConfigFromProcessEnv = exports.smartUserAgent = void 0;
|
26
|
+
exports.processSend = exports.base64MimeType = exports.getDUrl = exports.isDataURL = exports.isBase64 = exports.camelize = exports.without = exports.getConfigFromProcessEnv = exports.smartUserAgent = void 0;
|
27
27
|
const axios_1 = __importDefault(require("axios"));
|
28
28
|
/**
|
29
29
|
* Use this to generate a more likely valid user agent. It makes sure it has the WA part and replaces any windows or linux os info with mac.
|
@@ -31,10 +31,16 @@ const axios_1 = __importDefault(require("axios"));
|
|
31
31
|
* @param v The WA version from the debug info. This is optional. default is 2.2117.5
|
32
32
|
*/
|
33
33
|
const smartUserAgent = (useragent, v = '2.2117.5') => {
|
34
|
-
useragent = useragent.replace(useragent
|
34
|
+
useragent = useragent.replace(useragent
|
35
|
+
.match(/\(([^()]*)\)/g)
|
36
|
+
.find((x) => x.toLowerCase().includes('linux') ||
|
37
|
+
x.toLowerCase().includes('windows')), '(Macintosh; Intel Mac OS X 10_15_2)');
|
35
38
|
if (!useragent.includes('WhatsApp'))
|
36
39
|
return `WhatsApp/${v} ${useragent}`;
|
37
|
-
return useragent.replace(useragent
|
40
|
+
return useragent.replace(useragent
|
41
|
+
.match(/WhatsApp\/([.\d])*/g)[0]
|
42
|
+
.match(/[.\d]*/g)
|
43
|
+
.find((x) => x), v);
|
38
44
|
};
|
39
45
|
exports.smartUserAgent = smartUserAgent;
|
40
46
|
const getConfigFromProcessEnv = (json) => {
|
@@ -59,9 +65,11 @@ const without = (obj, key) => {
|
|
59
65
|
exports.without = without;
|
60
66
|
const camelize = (str) => {
|
61
67
|
const arr = str.split('-');
|
62
|
-
const capital = arr.map((item, index) => index
|
68
|
+
const capital = arr.map((item, index) => index
|
69
|
+
? item.charAt(0).toUpperCase() + item.slice(1).toLowerCase()
|
70
|
+
: item.toLowerCase());
|
63
71
|
// ^-- change here.
|
64
|
-
const capitalString = capital.join(
|
72
|
+
const capitalString = capital.join('');
|
65
73
|
return capitalString;
|
66
74
|
};
|
67
75
|
exports.camelize = camelize;
|
@@ -71,9 +79,9 @@ const isBase64 = (str) => {
|
|
71
79
|
return false;
|
72
80
|
}
|
73
81
|
const firstPaddingChar = str.indexOf('=');
|
74
|
-
return firstPaddingChar === -1 ||
|
82
|
+
return (firstPaddingChar === -1 ||
|
75
83
|
firstPaddingChar === len - 1 ||
|
76
|
-
(firstPaddingChar === len - 2 && str[len - 1] === '=');
|
84
|
+
(firstPaddingChar === len - 2 && str[len - 1] === '='));
|
77
85
|
};
|
78
86
|
exports.isBase64 = isBase64;
|
79
87
|
const isDataURL = (s) => !!s.match(/^data:((?:\w+\/(?:(?!;).)+)?)((?:;[\w\W]*?[^;])*),(.+)$/g);
|
@@ -88,9 +96,9 @@ exports.isDataURL = isDataURL;
|
|
88
96
|
const getDUrl = (url, optionsOverride = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
89
97
|
// eslint-disable-next-line no-useless-catch
|
90
98
|
try {
|
91
|
-
const res = yield axios_1.default(Object.assign(Object.assign({ method:
|
92
|
-
|
93
|
-
'Upgrade-Insecure-Requests': 1
|
99
|
+
const res = yield axios_1.default(Object.assign(Object.assign({ method: 'get', url, headers: {
|
100
|
+
DNT: 1,
|
101
|
+
'Upgrade-Insecure-Requests': 1,
|
94
102
|
} }, optionsOverride), { responseType: 'arraybuffer' }));
|
95
103
|
const dUrl = `data:${res.headers['content-type']};base64,${Buffer.from(res.data, 'binary').toString('base64')}`;
|
96
104
|
return dUrl;
|
@@ -116,3 +124,12 @@ const base64MimeType = (dUrl) => {
|
|
116
124
|
return result;
|
117
125
|
};
|
118
126
|
exports.base64MimeType = base64MimeType;
|
127
|
+
const processSend = (message) => {
|
128
|
+
if (process.send) {
|
129
|
+
process.send(message);
|
130
|
+
process.send(message);
|
131
|
+
process.send(message);
|
132
|
+
}
|
133
|
+
return;
|
134
|
+
};
|
135
|
+
exports.processSend = processSend;
|
package/package.json
CHANGED