@open-wa/wa-automate 4.50.2 → 4.51.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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, _b, _c;
3885
- const chatId = (((_b = (_a = c) === null || _a === void 0 ? void 0 : _a.chat) === null || _b === void 0 ? void 0 : _b.id) || ((_c = c) === null || _c === void 0 ? void 0 : _c.id) || c);
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
- declare type Brand<K, T> = K & {
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 declare type ChatServer = 'c.us';
7
+ export type ChatServer = 'c.us';
8
8
  /**
9
9
  * The suffix used to identify a group chat id
10
10
  */
11
- export declare type GroupChatServer = 'g.us';
11
+ export type GroupChatServer = 'g.us';
12
12
  /**
13
13
  * A type alias for all available "servers"
14
14
  */
15
- export declare type WaServers = ChatServer | GroupChatServer;
15
+ export type WaServers = ChatServer | GroupChatServer;
16
16
  /**
17
17
  * Type alias representing all available country codes
18
18
  */
19
- export declare 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;
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 declare type AccountNumber = `${number}`;
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 declare type GroupChatId = `${AccountNumber}-${number}@${GroupChatServer}` | `${number}@${GroupChatServer}`;
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 declare type ContactId = Brand<`${AccountNumber}@${ChatServer}`, "ContactId">;
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 declare type ChatId = ContactId | GroupChatId;
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 declare type MessageId = Brand<`${boolean}_${ChatId}_${string}`, "MessageId">;
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 declare type Content = Brand<string, "Content">;
66
- export declare type NonSerializedId = {
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 declare type DataURL = Brand<`data:${string};base64,${Base64}`, "DataURL">;
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 declare type Base64 = Brand<string, "Base64">;
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 declare type FilePath = Brand<string, "FilePath">;
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 declare type GetURL = Brand<string, "GetURL">;
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 declare type AdvancedFile = DataURL | FilePath | GetURL;
105
+ export type AdvancedFile = DataURL | FilePath | GetURL;
106
106
  export {};
@@ -105,7 +105,7 @@ export interface GroupChat extends BaseChat {
105
105
  */
106
106
  isGroup: true;
107
107
  }
108
- export declare type Chat = SingleChat | GroupChat;
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 declare type EphemeralDuration = 86400 | 604800 | 7776000;
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
- declare type SessionId = string;
40
- declare type LicenseKey = string;
41
- declare type HostAccountNumber = `${number}`;
42
- declare type HostAccountNumberOrSessionID = HostAccountNumber | SessionId;
43
- declare type LicenseKeyConfigObject = {
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
- declare type LicenseKeyConfigFunctionReturn = LicenseKeyConfigObject | LicenseKey;
47
- declare type LicenseKeyConfigFunction = (sessionId?: SessionId, number?: HostAccountNumber) => LicenseKeyConfigFunctionReturn | Promise<LicenseKeyConfigFunctionReturn>;
48
- declare type LicenseKeyConfig = LicenseKeyConfigFunction | LicenseKeyConfigObject | LicenseKey;
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 declare type AdvancedConfig = ConfigObject & {
802
+ export type AdvancedConfig = ConfigObject & {
803
803
  licenseKey: LicenseKeyConfig;
804
804
  };
805
805
  export {};
@@ -100,7 +100,7 @@ export declare enum STATE {
100
100
  */
101
101
  DISCONNECTED = "DISCONNECTED"
102
102
  }
103
- export declare type EasyApiResponse = {
103
+ export type EasyApiResponse = {
104
104
  success: boolean;
105
105
  response: any;
106
106
  };
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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 declare type StickerMetadata = {
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 declare type Mp4StickerConversionProcessOptions = {
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 declare type Reaction = {
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 declare type ReactionRecord = {
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 declare type ReactionEvent = {
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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 declare type expressMiddleware = (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
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>;
@@ -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 declare type cliFlags = {
6
+ export type cliFlags = {
7
7
  [k: string]: number | string | boolean;
8
8
  };
9
9
  export declare const setupHttpServer: (cliConfig: cliFlags) => void;
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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, _e; acc[key.replace("/", "")] = ((_e = (_d = (_c = (_b = (_a = value) === null || _a === void 0 ? void 0 : _a.post) === null || _b === void 0 ? void 0 : _b.requestBody) === null || _c === void 0 ? void 0 : _c.content["application/json"]) === null || _d === void 0 ? void 0 : _d.example) === null || _e === void 0 ? void 0 : _e.args) || {}; return acc; }, {});
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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 declare type ConfigLogTransport = {
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
  */
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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 declare type CollectorFilter<T extends any[]> = (...args: T) => boolean | Promise<boolean>;
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 declare type CheckFunction = (lastReceivedMessage: Message, currentProps: CurrentDialogProps) => boolean;
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 declare type MessagePreProcessor = (message: Message, client?: Client) => Promise<Message>;
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 declare type MPConfigType = PREPROCESSORS | MessagePreProcessor | (PREPROCESSORS | MessagePreProcessor)[];
50
+ export type MPConfigType = PREPROCESSORS | MessagePreProcessor | (PREPROCESSORS | MessagePreProcessor)[];
@@ -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
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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,18 @@ 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
+ const IGNORE_FILE_EXTS = [
67
+ 'mpga'
68
+ ];
69
+ let _ft = null;
70
+ const ft = () => __awaiter(void 0, void 0, void 0, function* () {
71
+ if (!_ft) {
72
+ const x = yield (0, import_1.import_)('file-type');
73
+ _ft = x;
74
+ }
75
+ return _ft;
76
+ });
61
77
  //@ts-ignore
62
78
  process.send = process.send || function () { };
63
79
  const timeout = ms => new Promise(resolve => setTimeout(resolve, ms, 'timeout'));
@@ -141,18 +157,35 @@ const isDataURL = (s) => !!s.match(/^data:((?:\w+\/(?:(?!;).)+)?)((?:;[\w\W]*?[^
141
157
  exports.isDataURL = isDataURL;
142
158
  /**
143
159
  * @internal
144
- * A convinience method to download the [[DataURL]] of a file
160
+ * A convinience method to download the buffer of a downloaded file
145
161
  * @param url The url
146
162
  * @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
147
163
  */
148
- const getDUrl = (url, optionsOverride = {}) => __awaiter(void 0, void 0, void 0, function* () {
164
+ const getBufferFromUrl = (url, optionsOverride = {}) => __awaiter(void 0, void 0, void 0, function* () {
149
165
  // eslint-disable-next-line no-useless-catch
150
166
  try {
151
167
  const res = yield (0, axios_1.default)(Object.assign(Object.assign({ method: 'get', url, headers: {
152
168
  DNT: 1,
153
169
  'Upgrade-Insecure-Requests': 1,
154
170
  } }, optionsOverride), { responseType: 'arraybuffer' }));
155
- const dUrl = `data:${res.headers['content-type']};base64,${Buffer.from(res.data, 'binary').toString('base64')}`;
171
+ return [Buffer.from(res.data, 'binary'), res.headers];
172
+ }
173
+ catch (error) {
174
+ throw error;
175
+ }
176
+ });
177
+ exports.getBufferFromUrl = getBufferFromUrl;
178
+ /**
179
+ * @internal
180
+ * A convinience method to download the [[DataURL]] of a file
181
+ * @param url The url
182
+ * @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
183
+ */
184
+ const getDUrl = (url, optionsOverride = {}) => __awaiter(void 0, void 0, void 0, function* () {
185
+ // eslint-disable-next-line no-useless-catch
186
+ try {
187
+ const [buff, headers] = yield (0, exports.getBufferFromUrl)(url, optionsOverride);
188
+ const dUrl = `data:${headers['content-type']};base64,${buff.toString('base64')}`;
156
189
  return dUrl;
157
190
  }
158
191
  catch (error) {
@@ -272,6 +305,10 @@ exports.generateGHIssueLink = generateGHIssueLink;
272
305
  */
273
306
  const ensureDUrl = (file, requestConfig = {}, filename) => __awaiter(void 0, void 0, void 0, function* () {
274
307
  if (Buffer.isBuffer(file)) {
308
+ if (!filename) {
309
+ const { ext } = yield (yield ft()).fileTypeFromBuffer(file);
310
+ filename = `file.${ext}`;
311
+ }
275
312
  return `data:${mime_1.default.lookup(filename)};base64,${file.toString('base64').split(',')[1]}`;
276
313
  }
277
314
  else if (!(0, exports.isDataURL)(file) && !(0, exports.isBase64)(file)) {
@@ -286,6 +323,10 @@ const ensureDUrl = (file, requestConfig = {}, filename) => __awaiter(void 0, voi
286
323
  else
287
324
  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
325
  }
326
+ if (!filename) {
327
+ const { ext } = yield (yield ft()).fileTypeFromBuffer(Buffer.from(file.split(',')[1], 'base64'));
328
+ filename = `file.${ext}`;
329
+ }
289
330
  if (file.includes("data:") && file.includes("undefined") || file.includes("application/octet-stream") && filename && mime_1.default.lookup(filename)) {
290
331
  file = `data:${mime_1.default.lookup(filename)};base64,${file.split(',')[1]}`;
291
332
  }
@@ -369,13 +410,17 @@ const assertFile = (file, outfileName, desiredOutputType, requestConfig) => __aw
369
410
  /**
370
411
  * Create a temp file in tempdir, return the tempfile.
371
412
  */
372
- const tempFilePath = path.join((0, os_2.tmpdir)(), `${crypto_1.default.randomBytes(6).readUIntLE(0, 6).toString(36)}.${outfileName}`);
373
- logging_1.log.info(`Saved temporary file to ${tempFilePath}`);
413
+ let tfn = `${crypto_1.default.randomBytes(6).readUIntLE(0, 6).toString(36)}.${outfileName}`;
374
414
  if (inputType != exports.FileInputTypes.BUFFER) {
375
415
  file = yield (0, exports.ensureDUrl)(file, requestConfig, outfileName);
416
+ const ext = mime_1.default.extension(file.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0]);
417
+ if (ext && !IGNORE_FILE_EXTS.includes(ext) && !tfn.endsWith(ext))
418
+ tfn = `${tfn}.${ext}`;
376
419
  file = Buffer.from(file.split(',')[1], 'base64');
377
420
  }
421
+ const tempFilePath = path.join((0, os_2.tmpdir)(), tfn);
378
422
  yield fs.writeFileSync(tempFilePath, file);
423
+ logging_1.log.info(`Saved temporary file to ${tempFilePath}`);
379
424
  return tempFilePath;
380
425
  break;
381
426
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.50.2",
3
+ "version": "4.51.1",
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.0.0",
100
+ "ts-node": "^10.9.1",
101
101
  "tsc-watch": "^4.0.0",
102
102
  "typeconv": "^1.7.0",
103
- "typedoc": "^0.21.6",
104
- "typedoc-plugin-pages": "^1.0.1",
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",