@open-wa/wa-automate 4.50.2 → 4.51.0
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/api/Client.js +8 -4
- package/dist/api/model/aliases.d.ts +17 -17
- package/dist/api/model/chat.d.ts +2 -2
- package/dist/api/model/config.d.ts +9 -9
- package/dist/api/model/index.d.ts +1 -1
- package/dist/api/model/index.js +5 -1
- package/dist/api/model/media.d.ts +2 -2
- package/dist/api/model/reactions.d.ts +3 -3
- package/dist/build/build-postman.js +5 -1
- package/dist/cli/collections.js +5 -1
- package/dist/cli/file-utils.js +5 -1
- package/dist/cli/integrations/chatwoot.d.ts +1 -1
- package/dist/cli/server.d.ts +1 -1
- package/dist/cli/server.js +6 -2
- package/dist/cli/setup.js +5 -1
- package/dist/controllers/auth.js +5 -1
- package/dist/controllers/browser.js +5 -1
- package/dist/controllers/initializer.js +5 -1
- package/dist/controllers/launch_checks.js +5 -1
- package/dist/controllers/patch_manager.js +7 -2
- package/dist/controllers/popup/index.js +5 -1
- package/dist/controllers/script_preloader.js +5 -1
- package/dist/index.js +5 -1
- package/dist/logging/logging.d.ts +1 -1
- package/dist/logging/logging.js +5 -1
- package/dist/structures/Collector.d.ts +2 -1
- package/dist/structures/Dialog.d.ts +1 -1
- package/dist/structures/preProcessors.d.ts +2 -2
- package/dist/utils/tools.d.ts +10 -1
- package/dist/utils/tools.js +49 -7
- package/package.json +7 -5
package/dist/api/Client.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -233,7 +237,7 @@ class Client {
|
|
233
237
|
}
|
234
238
|
catch (error) {
|
235
239
|
console.error("middleware -> error", error);
|
236
|
-
if (methodRequiresArgs && args
|
240
|
+
if (methodRequiresArgs && Array.isArray(args))
|
237
241
|
error.message = `${(req === null || req === void 0 ? void 0 : req.params) ? "Please set arguments in request json body, not in params." : "Args expected, none found."} ${error.message}`;
|
238
242
|
return res.send({
|
239
243
|
success: false,
|
@@ -3881,8 +3885,8 @@ class Client {
|
|
3881
3885
|
* @param options The options for the collector. For example, how long the collector shall run for, how many messages it should collect, how long between messages before timing out, etc.
|
3882
3886
|
*/
|
3883
3887
|
createMessageCollector(c, filter, options) {
|
3884
|
-
var _a
|
3885
|
-
const chatId = (((
|
3888
|
+
var _a;
|
3889
|
+
const chatId = (((_a = c === null || c === void 0 ? void 0 : c.chat) === null || _a === void 0 ? void 0 : _a.id) || (c === null || c === void 0 ? void 0 : c.id) || c);
|
3886
3890
|
return new MessageCollector_1.MessageCollector(this.getSessionId(), this.getInstanceId(), chatId, filter, options, events_1.ev);
|
3887
3891
|
}
|
3888
3892
|
/**
|
@@ -1,26 +1,26 @@
|
|
1
|
-
|
1
|
+
type Brand<K, T> = K & {
|
2
2
|
__brand?: T;
|
3
3
|
};
|
4
4
|
/**
|
5
5
|
* The suffix used to identify a non-group chat id
|
6
6
|
*/
|
7
|
-
export
|
7
|
+
export type ChatServer = 'c.us';
|
8
8
|
/**
|
9
9
|
* The suffix used to identify a group chat id
|
10
10
|
*/
|
11
|
-
export
|
11
|
+
export type GroupChatServer = 'g.us';
|
12
12
|
/**
|
13
13
|
* A type alias for all available "servers"
|
14
14
|
*/
|
15
|
-
export
|
15
|
+
export type WaServers = ChatServer | GroupChatServer;
|
16
16
|
/**
|
17
17
|
* Type alias representing all available country codes
|
18
18
|
*/
|
19
|
-
export
|
19
|
+
export type CountryCode = 1 | 7 | 20 | 27 | 30 | 31 | 32 | 33 | 34 | 36 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 81 | 82 | 84 | 86 | 90 | 91 | 92 | 93 | 94 | 95 | 98 | 211 | 212 | 213 | 216 | 218 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 290 | 291 | 297 | 298 | 299 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 380 | 381 | 382 | 383 | 385 | 386 | 387 | 389 | 420 | 421 | 423 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 670 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 850 | 852 | 853 | 855 | 856 | 880 | 886 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 992 | 993 | 994 | 995 | 996 | 998;
|
20
20
|
/**
|
21
21
|
* The account number. It is made up of a country code and then the local number without the preceeding 0. For example, if a UK (+44) wa account is linked to the number 07123456789 then the account number will be 447123456789.
|
22
22
|
*/
|
23
|
-
export
|
23
|
+
export type AccountNumber = `${number}`;
|
24
24
|
/**
|
25
25
|
* A group chat ends with `@g.us` and usually has two parts, the timestamp of when it was created, and the user id of the number that created the group. For example `[creator number]-[timestamp]@g.us`
|
26
26
|
*
|
@@ -28,7 +28,7 @@ export declare type AccountNumber = `${number}`;
|
|
28
28
|
*
|
29
29
|
* `"447123456789-1445627445@g.us"`
|
30
30
|
*/
|
31
|
-
export
|
31
|
+
export type GroupChatId = `${AccountNumber}-${number}@${GroupChatServer}` | `${number}@${GroupChatServer}`;
|
32
32
|
/**
|
33
33
|
* A contact id ends with `@c.us` and only contains the number of the contact. For example, if the country code of a contact is `44` and their number is `7123456789` then the contact id would be `447123456789@c.us`
|
34
34
|
*
|
@@ -36,7 +36,7 @@ export declare type GroupChatId = `${AccountNumber}-${number}@${GroupChatServer}
|
|
36
36
|
*
|
37
37
|
* `"447123456789@c.us"`
|
38
38
|
*/
|
39
|
-
export
|
39
|
+
export type ContactId = Brand<`${AccountNumber}@${ChatServer}`, "ContactId">;
|
40
40
|
/**
|
41
41
|
* A chat id ends with `@c.us` or `@g.us` for group chats.
|
42
42
|
*
|
@@ -46,7 +46,7 @@ export declare type ContactId = Brand<`${AccountNumber}@${ChatServer}`, "Contact
|
|
46
46
|
* A group chat: `"447123456789@g.us"`
|
47
47
|
*
|
48
48
|
*/
|
49
|
-
export
|
49
|
+
export type ChatId = ContactId | GroupChatId;
|
50
50
|
/**
|
51
51
|
* The id of a message. The format is `[boolean]_[ChatId]_[random character string]`
|
52
52
|
*
|
@@ -54,7 +54,7 @@ export declare type ChatId = ContactId | GroupChatId;
|
|
54
54
|
*
|
55
55
|
* `"false_447123456789@c.us_9C4D0965EA5C09D591334AB6BDB07FEB"`
|
56
56
|
*/
|
57
|
-
export
|
57
|
+
export type MessageId = Brand<`${boolean}_${ChatId}_${string}`, "MessageId">;
|
58
58
|
/**
|
59
59
|
* This is a generic type alias for the content of a message
|
60
60
|
*
|
@@ -62,8 +62,8 @@ export declare type MessageId = Brand<`${boolean}_${ChatId}_${string}`, "Message
|
|
62
62
|
*
|
63
63
|
* `"hello!"`
|
64
64
|
*/
|
65
|
-
export
|
66
|
-
export
|
65
|
+
export type Content = Brand<string, "Content">;
|
66
|
+
export type NonSerializedId = {
|
67
67
|
server: WaServers;
|
68
68
|
user: AccountNumber;
|
69
69
|
_serialized: ContactId;
|
@@ -80,7 +80,7 @@ export declare type NonSerializedId = {
|
|
80
80
|
*
|
81
81
|
* Learn more here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
|
82
82
|
*/
|
83
|
-
export
|
83
|
+
export type DataURL = Brand<`data:${string};base64,${Base64}`, "DataURL">;
|
84
84
|
/**
|
85
85
|
* Base64 is basically a file encoded as a string.
|
86
86
|
*
|
@@ -88,19 +88,19 @@ export declare type DataURL = Brand<`data:${string};base64,${Base64}`, "DataURL"
|
|
88
88
|
*
|
89
89
|
* Learn more here: https://developer.mozilla.org/en-US/docs/Glossary/Base64
|
90
90
|
*/
|
91
|
-
export
|
91
|
+
export type Base64 = Brand<string, "Base64">;
|
92
92
|
/**
|
93
93
|
* The relative or absolute path of a file
|
94
94
|
*
|
95
95
|
* Learn more here: https://www.w3schools.com/html/html_filepaths.asp
|
96
96
|
*/
|
97
|
-
export
|
97
|
+
export type FilePath = Brand<string, "FilePath">;
|
98
98
|
/**
|
99
99
|
* A URL of a file used with a GET request
|
100
100
|
*/
|
101
|
-
export
|
101
|
+
export type GetURL = Brand<string, "GetURL">;
|
102
102
|
/**
|
103
103
|
* Some file based actions in open-wa are powerful enough to take a dataurl, url or filepath
|
104
104
|
*/
|
105
|
-
export
|
105
|
+
export type AdvancedFile = DataURL | FilePath | GetURL;
|
106
106
|
export {};
|
package/dist/api/model/chat.d.ts
CHANGED
@@ -105,7 +105,7 @@ export interface GroupChat extends BaseChat {
|
|
105
105
|
*/
|
106
106
|
isGroup: true;
|
107
107
|
}
|
108
|
-
export
|
108
|
+
export type Chat = SingleChat | GroupChat;
|
109
109
|
export interface LiveLocationChangedEvent {
|
110
110
|
id: string;
|
111
111
|
lat: number;
|
@@ -210,4 +210,4 @@ export interface GroupChatCreationResponse {
|
|
210
210
|
/**
|
211
211
|
* Ephemeral duration can be 1 day, 7 days or 90 days. The default is 1 day.
|
212
212
|
*/
|
213
|
-
export
|
213
|
+
export type EphemeralDuration = 86400 | 604800 | 7776000;
|
@@ -36,16 +36,16 @@ export declare enum DIRECTORY_STRATEGY {
|
|
36
36
|
*/
|
37
37
|
DATE_CHAT = "DATE_CHAT"
|
38
38
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
type SessionId = string;
|
40
|
+
type LicenseKey = string;
|
41
|
+
type HostAccountNumber = `${number}`;
|
42
|
+
type HostAccountNumberOrSessionID = HostAccountNumber | SessionId;
|
43
|
+
type LicenseKeyConfigObject = {
|
44
44
|
[key: HostAccountNumberOrSessionID]: LicenseKey;
|
45
45
|
};
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
type LicenseKeyConfigFunctionReturn = LicenseKeyConfigObject | LicenseKey;
|
47
|
+
type LicenseKeyConfigFunction = (sessionId?: SessionId, number?: HostAccountNumber) => LicenseKeyConfigFunctionReturn | Promise<LicenseKeyConfigFunctionReturn>;
|
48
|
+
type LicenseKeyConfig = LicenseKeyConfigFunction | LicenseKeyConfigObject | LicenseKey;
|
49
49
|
/**
|
50
50
|
* The available languages for the host security notification
|
51
51
|
*/
|
@@ -799,7 +799,7 @@ export interface ConfigObject {
|
|
799
799
|
/**@internal */
|
800
800
|
[x: string]: any;
|
801
801
|
}
|
802
|
-
export
|
802
|
+
export type AdvancedConfig = ConfigObject & {
|
803
803
|
licenseKey: LicenseKeyConfig;
|
804
804
|
};
|
805
805
|
export {};
|
package/dist/api/model/index.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export
|
1
|
+
export type StickerMetadata = {
|
2
2
|
/**
|
3
3
|
* The author of the sticker
|
4
4
|
* @default ``
|
@@ -53,7 +53,7 @@ export declare type StickerMetadata = {
|
|
53
53
|
*/
|
54
54
|
cornerRadius?: number;
|
55
55
|
};
|
56
|
-
export
|
56
|
+
export type Mp4StickerConversionProcessOptions = {
|
57
57
|
/**
|
58
58
|
* Desired Frames per second of the sticker output
|
59
59
|
* @default `10`
|
@@ -3,7 +3,7 @@ import { Message, MessageAck } from "./message";
|
|
3
3
|
/**
|
4
4
|
* A reaction is identified the specific emoji.
|
5
5
|
*/
|
6
|
-
export
|
6
|
+
export type Reaction = {
|
7
7
|
/**
|
8
8
|
* The aggregate emoji used for the reaction.
|
9
9
|
*/
|
@@ -24,7 +24,7 @@ export declare type Reaction = {
|
|
24
24
|
/**
|
25
25
|
* The specific reaction by a user
|
26
26
|
*/
|
27
|
-
export
|
27
|
+
export type ReactionRecord = {
|
28
28
|
/**
|
29
29
|
* The acknowledgement of the reaction
|
30
30
|
*/
|
@@ -56,7 +56,7 @@ export declare type ReactionRecord = {
|
|
56
56
|
/**
|
57
57
|
* Emitted by onReaction
|
58
58
|
*/
|
59
|
-
export
|
59
|
+
export type ReactionEvent = {
|
60
60
|
/**
|
61
61
|
* The message being reacted to
|
62
62
|
*/
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
package/dist/cli/collections.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
package/dist/cli/file-utils.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -2,6 +2,6 @@ import { Client } from '../..';
|
|
2
2
|
import { cliFlags } from '../server';
|
3
3
|
import { Request, Response } from "express";
|
4
4
|
export declare const chatwoot_webhook_check_event_name = "cli.integrations.chatwoot.check";
|
5
|
-
export
|
5
|
+
export type expressMiddleware = (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
6
6
|
export declare const chatwootMiddleware: (cliConfig: cliFlags, client: Client) => expressMiddleware;
|
7
7
|
export declare const setupChatwootOutgoingMessageHandler: (cliConfig: cliFlags, client: Client) => Promise<void>;
|
package/dist/cli/server.d.ts
CHANGED
@@ -3,7 +3,7 @@ import http from 'http';
|
|
3
3
|
import { Client } from '..';
|
4
4
|
export declare const app: import("express-serve-static-core").Express;
|
5
5
|
export declare let server: http.Server;
|
6
|
-
export
|
6
|
+
export type cliFlags = {
|
7
7
|
[k: string]: number | string | boolean;
|
8
8
|
};
|
9
9
|
export declare const setupHttpServer: (cliConfig: cliFlags) => void;
|
package/dist/cli/server.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -239,7 +243,7 @@ const setupMetaMiddleware = () => {
|
|
239
243
|
}
|
240
244
|
}));
|
241
245
|
};
|
242
|
-
const getCommands = () => Object.entries(collections_1.collections['swagger'].paths).reduce((acc, [key, value]) => { var _a, _b, _c, _d
|
246
|
+
const getCommands = () => Object.entries(collections_1.collections['swagger'].paths).reduce((acc, [key, value]) => { var _a, _b, _c, _d; acc[key.replace("/", "")] = ((_d = (_c = (_b = (_a = value === null || value === void 0 ? void 0 : value.post) === null || _a === void 0 ? void 0 : _a.requestBody) === null || _b === void 0 ? void 0 : _b.content["application/json"]) === null || _c === void 0 ? void 0 : _c.example) === null || _d === void 0 ? void 0 : _d.args) || {}; return acc; }, {});
|
243
247
|
exports.getCommands = getCommands;
|
244
248
|
const listListeners = () => {
|
245
249
|
return Object.keys(__1.SimpleListener).map(eventKey => __1.SimpleListener[eventKey]);
|
package/dist/cli/setup.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
package/dist/controllers/auth.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -153,8 +157,9 @@ function getLicense(config, me, debugInfo, spinner) {
|
|
153
157
|
//run the funciton to get the key
|
154
158
|
config.licenseKey = yield config.licenseKey(config.sessionId, me._serialized);
|
155
159
|
}
|
156
|
-
if (typeof config.licenseKey === "object") {
|
160
|
+
if (config.licenseKey && typeof config.licenseKey === "object") {
|
157
161
|
//attempt to get the key from the object
|
162
|
+
//@ts-ignore
|
158
163
|
config.licenseKey = config.licenseKey[me._serialized] || config.licenseKey[config.sessionId];
|
159
164
|
}
|
160
165
|
//asume by now the key is a string
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
package/dist/index.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -29,7 +29,7 @@ export declare const addRotateFileLogTransport: (options?: any) => void;
|
|
29
29
|
* @private
|
30
30
|
*/
|
31
31
|
export declare const addSysLogTransport: (options?: any) => void;
|
32
|
-
export
|
32
|
+
export type ConfigLogTransport = {
|
33
33
|
/**
|
34
34
|
* The type of winston transport. At the moment only `file`, `console`, `ev` and `syslog` are supported.
|
35
35
|
*/
|
package/dist/logging/logging.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -1,4 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
2
3
|
/**
|
3
4
|
* This code is a copy of the Discord Collector: https://github.com/discordjs/discord.js/blob/stable/src/structures/interfaces/Collector.js
|
4
5
|
*
|
@@ -16,7 +17,7 @@ export declare class Collection<K, V> extends BaseCollection<K, V> {
|
|
16
17
|
* @param {Collection} collection The items collected by this collector
|
17
18
|
* @returns {boolean|Promise<boolean>}
|
18
19
|
*/
|
19
|
-
export
|
20
|
+
export type CollectorFilter<T extends any[]> = (...args: T) => boolean | Promise<boolean>;
|
20
21
|
/**
|
21
22
|
* Options to be applied to the collector.
|
22
23
|
*/
|
@@ -20,7 +20,7 @@ export interface DialogTemplate {
|
|
20
20
|
[key: string]: DialogProperty;
|
21
21
|
};
|
22
22
|
}
|
23
|
-
export
|
23
|
+
export type CheckFunction = (lastReceivedMessage: Message, currentProps: CurrentDialogProps) => boolean;
|
24
24
|
export interface DialogProperty {
|
25
25
|
"order": number;
|
26
26
|
"key": string;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Client } from "../api/Client";
|
2
2
|
import { Message } from "../api/model/message";
|
3
|
-
export
|
3
|
+
export type MessagePreProcessor = (message: Message, client?: Client) => Promise<Message>;
|
4
4
|
/**
|
5
5
|
* An object that contains all available [[PREPROCESSORS]].
|
6
6
|
*
|
@@ -47,4 +47,4 @@ export declare enum PREPROCESSORS {
|
|
47
47
|
/**
|
48
48
|
* The actual type for [config.messagePreprocessor](/docs/api/interfaces/api_model_config.ConfigObject#messagepreprocessor)
|
49
49
|
*/
|
50
|
-
export
|
50
|
+
export type MPConfigType = PREPROCESSORS | MessagePreProcessor | (PREPROCESSORS | MessagePreProcessor)[];
|
package/dist/utils/tools.d.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
/// <reference types="node" />
|
2
4
|
import { AdvancedFile, ConfigObject, DataURL } from '../api/model';
|
3
|
-
import { AxiosRequestConfig } from 'axios';
|
5
|
+
import { AxiosRequestConfig, AxiosResponseHeaders } from 'axios';
|
4
6
|
import { SessionInfo } from '../api/model/sessionInfo';
|
5
7
|
import { Readable } from "stream";
|
6
8
|
export declare const timeout: (ms: any) => Promise<unknown>;
|
@@ -31,6 +33,13 @@ export declare const isBase64: (str: string) => boolean;
|
|
31
33
|
* @returns
|
32
34
|
*/
|
33
35
|
export declare const isDataURL: (s: string) => boolean;
|
36
|
+
/**
|
37
|
+
* @internal
|
38
|
+
* A convinience method to download the buffer of a downloaded file
|
39
|
+
* @param url The url
|
40
|
+
* @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
|
41
|
+
*/
|
42
|
+
export declare const getBufferFromUrl: (url: string, optionsOverride?: AxiosRequestConfig) => Promise<[Buffer, AxiosResponseHeaders]>;
|
34
43
|
/**
|
35
44
|
* @internal
|
36
45
|
* A convinience method to download the [[DataURL]] of a file
|
package/dist/utils/tools.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
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);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -42,7 +46,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
43
47
|
};
|
44
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
45
|
-
exports.fixPath = exports.pathExists = exports.assertFile = exports.rmFileAsync = exports.FileOutputTypes = exports.FileInputTypes = exports.ensureDUrl = exports.generateGHIssueLink = exports.processSendData = exports.timePromise = exports.now = exports.perf = exports.processSend = exports.base64MimeType = exports.getDUrl = exports.isDataURL = exports.isBase64 = exports.camelize = exports.without = exports.getConfigFromProcessEnv = exports.smartUserAgent = exports.timeout = void 0;
|
49
|
+
exports.fixPath = exports.pathExists = exports.assertFile = exports.rmFileAsync = exports.FileOutputTypes = exports.FileInputTypes = exports.ensureDUrl = exports.generateGHIssueLink = exports.processSendData = exports.timePromise = exports.now = exports.perf = exports.processSend = exports.base64MimeType = exports.getDUrl = exports.getBufferFromUrl = exports.isDataURL = exports.isBase64 = exports.camelize = exports.without = exports.getConfigFromProcessEnv = exports.smartUserAgent = exports.timeout = void 0;
|
46
50
|
const crypto_1 = __importDefault(require("crypto"));
|
47
51
|
const fs = __importStar(require("fs"));
|
48
52
|
const fsp = __importStar(require("fs/promises"));
|
@@ -58,6 +62,15 @@ const mime_1 = __importDefault(require("mime"));
|
|
58
62
|
const os_2 = require("os");
|
59
63
|
const stream_1 = require("stream");
|
60
64
|
const logging_1 = require("../logging/logging");
|
65
|
+
const import_1 = require("@brillout/import");
|
66
|
+
let _ft = null;
|
67
|
+
const ft = () => __awaiter(void 0, void 0, void 0, function* () {
|
68
|
+
if (!_ft) {
|
69
|
+
const x = yield (0, import_1.import_)('file-type');
|
70
|
+
_ft = x;
|
71
|
+
}
|
72
|
+
return _ft;
|
73
|
+
});
|
61
74
|
//@ts-ignore
|
62
75
|
process.send = process.send || function () { };
|
63
76
|
const timeout = ms => new Promise(resolve => setTimeout(resolve, ms, 'timeout'));
|
@@ -141,18 +154,35 @@ const isDataURL = (s) => !!s.match(/^data:((?:\w+\/(?:(?!;).)+)?)((?:;[\w\W]*?[^
|
|
141
154
|
exports.isDataURL = isDataURL;
|
142
155
|
/**
|
143
156
|
* @internal
|
144
|
-
* A convinience method to download the
|
157
|
+
* A convinience method to download the buffer of a downloaded file
|
145
158
|
* @param url The url
|
146
159
|
* @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
|
147
160
|
*/
|
148
|
-
const
|
161
|
+
const getBufferFromUrl = (url, optionsOverride = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
149
162
|
// eslint-disable-next-line no-useless-catch
|
150
163
|
try {
|
151
164
|
const res = yield (0, axios_1.default)(Object.assign(Object.assign({ method: 'get', url, headers: {
|
152
165
|
DNT: 1,
|
153
166
|
'Upgrade-Insecure-Requests': 1,
|
154
167
|
} }, optionsOverride), { responseType: 'arraybuffer' }));
|
155
|
-
|
168
|
+
return [Buffer.from(res.data, 'binary'), res.headers];
|
169
|
+
}
|
170
|
+
catch (error) {
|
171
|
+
throw error;
|
172
|
+
}
|
173
|
+
});
|
174
|
+
exports.getBufferFromUrl = getBufferFromUrl;
|
175
|
+
/**
|
176
|
+
* @internal
|
177
|
+
* A convinience method to download the [[DataURL]] of a file
|
178
|
+
* @param url The url
|
179
|
+
* @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
|
180
|
+
*/
|
181
|
+
const getDUrl = (url, optionsOverride = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
182
|
+
// eslint-disable-next-line no-useless-catch
|
183
|
+
try {
|
184
|
+
const [buff, headers] = yield (0, exports.getBufferFromUrl)(url, optionsOverride);
|
185
|
+
const dUrl = `data:${headers['content-type']};base64,${buff.toString('base64')}`;
|
156
186
|
return dUrl;
|
157
187
|
}
|
158
188
|
catch (error) {
|
@@ -272,6 +302,10 @@ exports.generateGHIssueLink = generateGHIssueLink;
|
|
272
302
|
*/
|
273
303
|
const ensureDUrl = (file, requestConfig = {}, filename) => __awaiter(void 0, void 0, void 0, function* () {
|
274
304
|
if (Buffer.isBuffer(file)) {
|
305
|
+
if (!filename) {
|
306
|
+
const { ext } = yield (yield ft()).fileTypeFromBuffer(file);
|
307
|
+
filename = `file.${ext}`;
|
308
|
+
}
|
275
309
|
return `data:${mime_1.default.lookup(filename)};base64,${file.toString('base64').split(',')[1]}`;
|
276
310
|
}
|
277
311
|
else if (!(0, exports.isDataURL)(file) && !(0, exports.isBase64)(file)) {
|
@@ -286,6 +320,10 @@ const ensureDUrl = (file, requestConfig = {}, filename) => __awaiter(void 0, voi
|
|
286
320
|
else
|
287
321
|
throw new model_1.CustomError(model_1.ERROR_NAME.FILE_NOT_FOUND, 'Cannot find file. Make sure the file reference is relative, a valid URL or a valid DataURL');
|
288
322
|
}
|
323
|
+
if (!filename) {
|
324
|
+
const { ext } = yield (yield ft()).fileTypeFromBuffer(Buffer.from(file.split(',')[1], 'base64'));
|
325
|
+
filename = `file.${ext}`;
|
326
|
+
}
|
289
327
|
if (file.includes("data:") && file.includes("undefined") || file.includes("application/octet-stream") && filename && mime_1.default.lookup(filename)) {
|
290
328
|
file = `data:${mime_1.default.lookup(filename)};base64,${file.split(',')[1]}`;
|
291
329
|
}
|
@@ -369,13 +407,17 @@ const assertFile = (file, outfileName, desiredOutputType, requestConfig) => __aw
|
|
369
407
|
/**
|
370
408
|
* Create a temp file in tempdir, return the tempfile.
|
371
409
|
*/
|
372
|
-
|
373
|
-
logging_1.log.info(`Saved temporary file to ${tempFilePath}`);
|
410
|
+
let tfn = `${crypto_1.default.randomBytes(6).readUIntLE(0, 6).toString(36)}.${outfileName}`;
|
374
411
|
if (inputType != exports.FileInputTypes.BUFFER) {
|
375
412
|
file = yield (0, exports.ensureDUrl)(file, requestConfig, outfileName);
|
413
|
+
const ext = mime_1.default.extension(file.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0]);
|
414
|
+
if (ext && !tfn.endsWith(ext))
|
415
|
+
tfn = `${tfn}.${ext}`;
|
376
416
|
file = Buffer.from(file.split(',')[1], 'base64');
|
377
417
|
}
|
418
|
+
const tempFilePath = path.join((0, os_2.tmpdir)(), tfn);
|
378
419
|
yield fs.writeFileSync(tempFilePath, file);
|
420
|
+
logging_1.log.info(`Saved temporary file to ${tempFilePath}`);
|
379
421
|
return tempFilePath;
|
380
422
|
break;
|
381
423
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@open-wa/wa-automate",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.51.0",
|
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",
|
@@ -97,14 +97,14 @@
|
|
97
97
|
"shelljs": "^0.8.3",
|
98
98
|
"tiny-glob": "^0.2.9",
|
99
99
|
"ts-json-schema-generator": "^v1.1.0-next.5",
|
100
|
-
"ts-node": "^10.
|
100
|
+
"ts-node": "^10.9.1",
|
101
101
|
"tsc-watch": "^4.0.0",
|
102
102
|
"typeconv": "^1.7.0",
|
103
|
-
"typedoc": "^0.21
|
104
|
-
"
|
105
|
-
"typescript": "^4.4.4"
|
103
|
+
"typedoc": "^0.23.21",
|
104
|
+
"typescript": "^4.9.3"
|
106
105
|
},
|
107
106
|
"dependencies": {
|
107
|
+
"@brillout/import": "^0.2.1",
|
108
108
|
"@discordjs/collection": "^0.5.0",
|
109
109
|
"@open-wa/wa-automate-socket-client": "*",
|
110
110
|
"@open-wa/wa-decrypt": "^4.3.1",
|
@@ -127,6 +127,7 @@
|
|
127
127
|
"express": "^4.17.1",
|
128
128
|
"express-ipfilter": "^1.3.1",
|
129
129
|
"express-robots-txt": "^1.0.0",
|
130
|
+
"file-type": "^18.0.0",
|
130
131
|
"find-up": "^5.0.0",
|
131
132
|
"form-data": "^4.0.0",
|
132
133
|
"fs-extra": "^10.0.0",
|
@@ -170,6 +171,7 @@
|
|
170
171
|
"terminal-link": "^2.1.1",
|
171
172
|
"terminate": "^2.5.0",
|
172
173
|
"traverse": "^0.6.6",
|
174
|
+
"ts-loader": "^9.4.1",
|
173
175
|
"ts-morph": "^12.0.0",
|
174
176
|
"type-fest": "^1.1.1",
|
175
177
|
"update-notifier": "^5.0.0",
|