alipclutch-baileys 8.3.0 → 8.4.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.
Files changed (120) hide show
  1. package/LICENSE +3 -1
  2. package/README.md +10 -9
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +4775 -0
  5. package/WAProto/index.d.ts +55057 -0
  6. package/WAProto/index.js +56887 -17535
  7. package/WAProto/index.ts.ts +53473 -0
  8. package/lib/Defaults/baileys-version.json +2 -2
  9. package/lib/Defaults/index.d.ts +16 -7
  10. package/lib/Defaults/index.js +90 -119
  11. package/lib/Socket/Client/index.d.ts +2 -3
  12. package/lib/Socket/Client/index.js +2 -3
  13. package/lib/Socket/Client/types.d.ts +0 -1
  14. package/lib/Socket/Client/types.js +0 -1
  15. package/lib/Socket/Client/websocket.d.ts +0 -1
  16. package/lib/Socket/Client/websocket.js +0 -1
  17. package/lib/Socket/business.d.ts +59 -58
  18. package/lib/Socket/chats.d.ts +45 -230
  19. package/lib/Socket/chats.js +139 -238
  20. package/lib/Socket/groups.d.ts +41 -32
  21. package/lib/Socket/groups.js +38 -23
  22. package/lib/Socket/index.d.ts +63 -64
  23. package/lib/Socket/index.js +2 -3
  24. package/lib/Socket/messages-recv.js +9 -65
  25. package/lib/Socket/messages-send.d.ts +49 -47
  26. package/lib/Socket/messages-send.js +584 -395
  27. package/lib/Socket/newsletter.d.ts +39 -37
  28. package/lib/Socket/newsletter.js +88 -123
  29. package/lib/Socket/setup.js +433 -0
  30. package/lib/Socket/{dugong.d.ts → setup.ts} +17 -52
  31. package/lib/Socket/socket.d.ts +10 -10
  32. package/lib/Socket/socket.js +62 -38
  33. package/lib/Socket/usync.d.ts +3 -4
  34. package/lib/Socket/usync.js +0 -1
  35. package/lib/Store/index.d.ts +1 -2
  36. package/lib/Store/index.js +1 -3
  37. package/lib/Store/make-in-memory-store.d.ts +24 -24
  38. package/lib/Store/make-in-memory-store.js +26 -14
  39. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  40. package/lib/Store/make-ordered-dictionary.js +2 -2
  41. package/lib/Types/Auth.d.ts +0 -7
  42. package/lib/Types/Call.d.ts +1 -1
  43. package/lib/Types/Chat.d.ts +14 -7
  44. package/lib/Types/Contact.d.ts +5 -1
  45. package/lib/Types/Events.d.ts +44 -2
  46. package/lib/Types/GroupMetadata.d.ts +11 -2
  47. package/lib/Types/Label.js +1 -1
  48. package/lib/Types/LabelAssociation.js +1 -1
  49. package/lib/Types/Message.d.ts +148 -21
  50. package/lib/Types/Message.js +0 -2
  51. package/lib/Types/Newsletter.d.ts +73 -97
  52. package/lib/Types/Newsletter.js +18 -38
  53. package/lib/Types/Socket.d.ts +17 -9
  54. package/lib/Types/index.d.ts +8 -1
  55. package/lib/Types/index.js +2 -2
  56. package/lib/Utils/auth-utils.d.ts +3 -3
  57. package/lib/Utils/auth-utils.js +6 -13
  58. package/lib/Utils/business.js +2 -2
  59. package/lib/Utils/chat-utils.d.ts +15 -16
  60. package/lib/Utils/chat-utils.js +36 -35
  61. package/lib/Utils/crypto.d.ts +15 -16
  62. package/lib/Utils/crypto.js +71 -29
  63. package/lib/Utils/decode-wa-message.d.ts +22 -6
  64. package/lib/Utils/decode-wa-message.js +65 -56
  65. package/lib/Utils/event-buffer.d.ts +2 -2
  66. package/lib/Utils/event-buffer.js +11 -7
  67. package/lib/Utils/generics.d.ts +17 -20
  68. package/lib/Utils/generics.js +95 -75
  69. package/lib/Utils/history.d.ts +4 -0
  70. package/lib/Utils/history.js +4 -6
  71. package/lib/Utils/link-preview.d.ts +2 -2
  72. package/lib/Utils/link-preview.js +34 -1
  73. package/lib/Utils/logger.d.ts +10 -3
  74. package/lib/Utils/lt-hash.d.ts +2 -2
  75. package/lib/Utils/lt-hash.js +6 -6
  76. package/lib/Utils/make-mutex.d.ts +2 -2
  77. package/lib/Utils/messages-media.d.ts +28 -24
  78. package/lib/Utils/messages-media.js +272 -111
  79. package/lib/Utils/messages.d.ts +13 -10
  80. package/lib/Utils/messages.js +323 -50
  81. package/lib/Utils/noise-handler.d.ts +10 -12
  82. package/lib/Utils/noise-handler.js +18 -23
  83. package/lib/Utils/process-message.d.ts +5 -4
  84. package/lib/Utils/process-message.js +108 -25
  85. package/lib/Utils/signal.d.ts +2 -1
  86. package/lib/Utils/signal.js +26 -26
  87. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -1
  88. package/lib/Utils/use-multi-file-auth-state.js +51 -6
  89. package/lib/Utils/validate-connection.d.ts +3 -4
  90. package/lib/Utils/validate-connection.js +90 -66
  91. package/lib/WABinary/constants.d.ts +24 -27
  92. package/lib/WABinary/constants.js +1276 -13
  93. package/lib/WABinary/decode.d.ts +3 -4
  94. package/lib/WABinary/decode.js +26 -13
  95. package/lib/WABinary/encode.d.ts +1 -2
  96. package/lib/WABinary/encode.js +137 -152
  97. package/lib/WABinary/generic-utils.d.ts +1 -4
  98. package/lib/WABinary/generic-utils.js +37 -125
  99. package/lib/WABinary/jid-utils.d.ts +11 -5
  100. package/lib/WABinary/jid-utils.js +28 -5
  101. package/lib/WABinary/jid-utils.js.bak +83 -0
  102. package/lib/WAM/BinaryInfo.d.ts +2 -11
  103. package/lib/WAM/encode.d.ts +1 -2
  104. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  105. package/lib/index.d.ts +0 -1
  106. package/lib/index.js +27 -15
  107. package/package.json +18 -31
  108. package/engine-requirements.js +0 -10
  109. package/lib/Defaults/phonenumber-mcc.json +0 -223
  110. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  111. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  112. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  113. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  114. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  115. package/lib/Socket/Client/web-socket-client.js +0 -62
  116. package/lib/Socket/dugong.js +0 -483
  117. package/lib/Socket/registration.d.ts +0 -267
  118. package/lib/Socket/registration.js +0 -166
  119. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  120. package/lib/Store/make-cache-manager-store.js +0 -83
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2, 3000, 1026924051]
3
- }
2
+ "version": [2, 3000, 1027934701]
3
+ }
@@ -1,18 +1,24 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { proto } from '../../WAProto';
4
- import type { MediaType, SocketConfig } from '../Types';
2
+ import type { MediaType, SocketConfig, WAVersion } from '../Types';
3
+
5
4
  export declare const UNAUTHORIZED_CODES: number[];
6
5
  export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
6
+ export declare const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
7
+ export declare const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
7
8
  export declare const DEF_CALLBACK_PREFIX = "CB:";
8
9
  export declare const DEF_TAG_PREFIX = "TAG:";
9
10
  export declare const PHONE_CONNECTION_CB = "CB:Pong";
11
+
12
+ export declare const WA_ADV_ACCOUNT_SIG_PREFIX: Buffer;
13
+ export declare const WA_ADV_DEVICE_SIG_PREFIX: Buffer;
14
+ export declare const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: Buffer;
15
+ export declare const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: Buffer;
16
+
10
17
  export declare const WA_DEFAULT_EPHEMERAL: number;
11
18
  export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
12
- export declare const DICT_VERSION = 2;
19
+ export declare const DICT_VERSION = 3;
13
20
  export declare const KEY_BUNDLE_TYPE: Buffer;
14
21
  export declare const NOISE_WA_HEADER: Buffer;
15
- /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
16
22
  export declare const URL_REGEX: RegExp;
17
23
  export declare const WA_CERT_DETAILS: {
18
24
  SERIAL: number;
@@ -41,10 +47,13 @@ export declare const MEDIA_HKDF_KEY_MAPPING: {
41
47
  'product-catalog-image': string;
42
48
  'payment-bg-image': string;
43
49
  ptv: string;
50
+ 'biz-cover-photo': string;
44
51
  };
45
- export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
52
+ export declare const MEDIA_KEYS: MediaType[];
46
53
  export declare const MIN_PREKEY_COUNT = 5;
47
- export declare const INITIAL_PREKEY_COUNT = 30;
54
+ export declare const INITIAL_PREKEY_COUNT = 812;
55
+ export declare const UPLOAD_TIMEOUT = 30000;
56
+ export declare const MIN_UPLOAD_INTERVAL = 5000;
48
57
  export declare const DEFAULT_CACHE_TTLS: {
49
58
  SIGNAL_STORE: number;
50
59
  MSG_RETRY: number;
@@ -1,146 +1,117 @@
1
- var __importDefault = this && this.__importDefault || function (a) {
2
- return a && a.__esModule ? a : { "default": a }
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
3
4
  };
4
-
5
- Object.defineProperty(exports, "__esModule", { value: !0 });
6
-
7
- exports.DEFAULT_CACHE_TTLS =
8
- exports.INITIAL_PREKEY_COUNT =
9
- exports.MIN_PREKEY_COUNT =
10
- exports.MEDIA_KEYS =
11
- exports.MEDIA_HKDF_KEY_MAPPING =
12
- exports.MEDIA_PATH_MAP =
13
- exports.DEFAULT_CONNECTION_CONFIG =
14
- exports.PROCESSABLE_HISTORY_TYPES =
15
- exports.WA_CERT_DETAILS =
16
- exports.URL_REGEX =
17
- exports.NOISE_WA_HEADER =
18
- exports.KEY_BUNDLE_TYPE =
19
- exports.DICT_VERSION =
20
- exports.NOISE_MODE =
21
- exports.WA_DEFAULT_EPHEMERAL =
22
- exports.PHONE_CONNECTION_CB =
23
- exports.DEF_TAG_PREFIX =
24
- exports.DEF_CALLBACK_PREFIX =
25
- exports.DEFAULT_ORIGIN =
26
- exports.UNAUTHORIZED_CODES =
27
- void 0;
28
-
29
- const crypto_1 = require("crypto");
30
- const WAProto_1 = require("../../WAProto"),
31
- libsignal_1 = require("../Signal/libsignal"),
32
- Utils_1 = require("../Utils"),
33
- logger_1 = __importDefault(require("../Utils/logger")),
34
- baileys_version_json_1 = require("./baileys-version.json");
35
- phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
36
-
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEFAULT_CACHE_TTLS = exports.MIN_UPLOAD_INTERVAL = exports.UPLOAD_TIMEOUT = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.CALL_AUDIO_PREFIX = exports.CALL_VIDEO_PREFIX = exports.DEFAULT_ORIGIN = exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.UNAUTHORIZED_CODES = void 0;
7
+ const WAProto_1 = require("../../WAProto");
8
+ const libsignal_1 = require("../Signal/libsignal");
9
+ const Utils_1 = require("../Utils");
10
+ const logger_1 = __importDefault(require("../Utils/logger"));
11
+ const version = [2, 3000, 1027934701];
37
12
  exports.UNAUTHORIZED_CODES = [401, 403, 419];
38
- exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default;
39
- exports.DEFAULT_ORIGIN = "https://web.whatsapp.com";
40
- exports.MOBILE_ENDPOINT = 'g.whatsapp.net';
41
- exports.MOBILE_PORT = 443;
42
- exports.DEF_CALLBACK_PREFIX = "CB:";
43
- exports.DEF_TAG_PREFIX = "TAG:";
44
- exports.PHONE_CONNECTION_CB = "CB:Pong";
45
- exports.WA_DEFAULT_EPHEMERAL = 604800;
46
- const WA_VERSION = '2.25.23.24';
47
- const WA_VERSION_HASH = (0, crypto_1.createHash)('md5').update(WA_VERSION).digest('hex');
48
- exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
49
- exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
50
- exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/17.5.1 Device/Apple-iPhone_13`;
51
- exports.REGISTRATION_PUBLIC_KEY = Buffer.from([
52
- 5, 142, 140, 15, 116, 195, 235, 197, 215, 166, 134, 92, 108, 60, 132, 56, 86, 176, 97, 33, 204, 232, 234, 119, 77,
53
- 34, 251, 111, 18, 37, 18, 48, 45,
54
- ]);
55
- exports.NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\x00\x00\x00\x00";
56
- exports.DICT_VERSION = 2;
13
+ exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
14
+ exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
15
+ exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
16
+ exports.DEF_CALLBACK_PREFIX = 'CB:';
17
+ exports.DEF_TAG_PREFIX = 'TAG:';
18
+ exports.PHONE_CONNECTION_CB = 'CB:Pong';
19
+ exports.WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
20
+ exports.WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
21
+ exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
22
+ exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
23
+ exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
24
+ exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
25
+ exports.DICT_VERSION = 3;
57
26
  exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
58
27
  exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
59
- exports.PROTOCOL_VERSION = [5, 2];
60
- exports.MOBILE_NOISE_HEADER = Buffer.concat([Buffer.from('WA'), Buffer.from(exports.PROTOCOL_VERSION)]);
61
-
62
28
  exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
63
- exports.WA_CERT_DETAILS = { SERIAL: 0 };
64
-
29
+ exports.WA_CERT_DETAILS = {
30
+ SERIAL: 0,
31
+ };
65
32
  exports.PROCESSABLE_HISTORY_TYPES = [
66
33
  WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
67
34
  WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
68
35
  WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
69
36
  WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL,
70
- WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND
37
+ WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
71
38
  ];
72
-
73
39
  exports.DEFAULT_CONNECTION_CONFIG = {
74
- version: baileys_version_json_1.version,
75
- browser: Utils_1.Browsers.ubuntu("Chrome"),
76
- waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
77
- connectTimeoutMs: 2E4,
78
- keepAliveIntervalMs: 3E4,
79
- logger: logger_1.default.child({ class: "baileys" }),
80
- printQRInTerminal: !1,
81
- emitOwnEvents: !0,
82
- defaultQueryTimeoutMs: 6E4,
40
+ version: version,
41
+ browser: Utils_1.Browsers.ubuntu('Chrome'),
42
+ waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
43
+ connectTimeoutMs: 20000,
44
+ keepAliveIntervalMs: 30000,
45
+ logger: logger_1.default.child({ class: 'baileys' }),
46
+ printQRInTerminal: false,
47
+ emitOwnEvents: true,
48
+ defaultQueryTimeoutMs: 60000,
83
49
  customUploadHosts: [],
84
50
  retryRequestDelayMs: 250,
85
51
  maxMsgRetryCount: 5,
86
- fireInitQueries: !0,
87
- auth: void 0,
88
- markOnlineOnConnect: !0,
89
- syncFullHistory: !1,
90
- patchMessageBeforeSending: a => a,
91
- shouldSyncHistoryMessage: () => !0,
92
- shouldIgnoreJid: () => !1,
52
+ fireInitQueries: true,
53
+ auth: undefined,
54
+ markOnlineOnConnect: true,
55
+ syncFullHistory: true,
56
+ patchMessageBeforeSending: msg => msg,
57
+ shouldSyncHistoryMessage: () => true,
58
+ shouldIgnoreJid: () => false,
93
59
  linkPreviewImageThumbnailWidth: 192,
94
- transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3E3 },
95
- generateHighQualityLinkPreview: !1,
60
+ transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
61
+ generateHighQualityLinkPreview: false,
62
+ enableAutoSessionRecreation: true,
63
+ enableRecentMessageCache: true,
96
64
  options: {},
97
- appStateMacVerification: { patch: !1, snapshot: !1 },
98
- countryCode: "US",
99
- getMessage: async () => { },
100
- cachedGroupMetadata: async () => { },
65
+ appStateMacVerification: {
66
+ patch: false,
67
+ snapshot: false,
68
+ },
69
+ countryCode: 'US',
70
+ getMessage: async () => undefined,
71
+ cachedGroupMetadata: async () => undefined,
101
72
  makeSignalRepository: libsignal_1.makeLibSignalRepository
102
73
  };
103
-
104
74
  exports.MEDIA_PATH_MAP = {
105
- image: "/mms/image",
106
- video: "/mms/video",
107
- document: "/mms/document",
108
- audio: "/mms/audio",
109
- sticker: "/mms/image",
110
- "thumbnail-link": "/mms/image",
111
- "product-catalog-image": "/product/image",
112
- "md-app-state": "",
113
- "md-msg-hist": "/mms/md-app-state"
75
+ image: '/mms/image',
76
+ video: '/mms/video',
77
+ document: '/mms/document',
78
+ audio: '/mms/audio',
79
+ sticker: '/mms/image',
80
+ 'thumbnail-link': '/mms/image',
81
+ 'product-catalog-image': '/product/image',
82
+ 'md-app-state': '',
83
+ 'md-msg-hist': '/mms/md-app-state',
84
+ 'biz-cover-photo': '/pps/biz-cover-photo'
114
85
  };
115
-
116
86
  exports.MEDIA_HKDF_KEY_MAPPING = {
117
- audio: "Audio",
118
- document: "Document",
119
- gif: "Video",
120
- image: "Image",
121
- ppic: "",
122
- product: "Image",
123
- ptt: "Audio",
124
- sticker: "Image",
125
- video: "Video",
126
- "thumbnail-document": "Document Thumbnail",
127
- "thumbnail-image": "Image Thumbnail",
128
- "thumbnail-video": "Video Thumbnail",
129
- "thumbnail-link": "Link Thumbnail",
130
- "md-msg-hist": "History",
131
- "md-app-state": "App State",
132
- "product-catalog-image": "",
133
- "payment-bg-image": "Payment Background",
134
- ptv: "Video"
87
+ 'audio': 'Audio',
88
+ 'document': 'Document',
89
+ 'gif': 'Video',
90
+ 'image': 'Image',
91
+ 'ppic': '',
92
+ 'product': 'Image',
93
+ 'ptt': 'Audio',
94
+ 'sticker': 'Image',
95
+ 'video': 'Video',
96
+ 'thumbnail-document': 'Document Thumbnail',
97
+ 'thumbnail-image': 'Image Thumbnail',
98
+ 'thumbnail-video': 'Video Thumbnail',
99
+ 'thumbnail-link': 'Link Thumbnail',
100
+ 'md-msg-hist': 'History',
101
+ 'md-app-state': 'App State',
102
+ 'product-catalog-image': '',
103
+ 'payment-bg-image': 'Payment Background',
104
+ 'ptv': 'Video',
105
+ 'biz-cover-photo': 'Image'
135
106
  };
136
-
137
107
  exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
138
108
  exports.MIN_PREKEY_COUNT = 5;
139
- exports.INITIAL_PREKEY_COUNT = 30;
140
-
109
+ exports.INITIAL_PREKEY_COUNT = 812;
110
+ exports.UPLOAD_TIMEOUT = 30000;
111
+ exports.MIN_UPLOAD_INTERVAL = 5000;
141
112
  exports.DEFAULT_CACHE_TTLS = {
142
- SIGNAL_STORE: 300,
143
- MSG_RETRY: 3600,
144
- CALL_OFFER: 300,
145
- USER_DEVICES: 300
113
+ SIGNAL_STORE: 5 * 60,
114
+ MSG_RETRY: 60 * 60,
115
+ CALL_OFFER: 5 * 60,
116
+ USER_DEVICES: 5 * 60,
146
117
  };
@@ -1,3 +1,2 @@
1
- export * from './abstract-socket-client';
2
- export * from './mobile-socket-client';
3
- export * from './web-socket-client';
1
+ export * from './types';
2
+ export * from './websocket';
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./abstract-socket-client"), exports);
18
- __exportStar(require("./mobile-socket-client"), exports);
19
- __exportStar(require("./web-socket-client"), exports);
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./websocket"), exports);
@@ -1,4 +1,3 @@
1
- // baileys by denzy
2
1
  import { EventEmitter } from 'events';
3
2
  import { URL } from 'url';
4
3
  import { SocketConfig } from '../../Types';
@@ -1,4 +1,3 @@
1
- // baileys by denzy
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.AbstractSocketClient = void 0;
@@ -1,4 +1,3 @@
1
- // baileys by denzy
2
1
  import WebSocket from 'ws';
3
2
  import { AbstractSocketClient } from './types';
4
3
  export declare class WebSocketClient extends AbstractSocketClient {
@@ -1,4 +1,3 @@
1
- // baileys by denzy
2
1
  "use strict";
3
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,8 +1,7 @@
1
- /// <reference types="node" />
2
1
  import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
3
2
  import { BinaryNode } from '../WABinary';
4
3
  export declare const makeBusinessSocket: (config: SocketConfig) => {
5
- logger: import("pino").Logger<import("pino").LoggerOptions>;
4
+ logger: import("../Utils/logger").ILogger;
6
5
  getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
7
6
  getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
8
7
  products: import("../Types").Product[];
@@ -16,41 +15,40 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
16
15
  deleted: number;
17
16
  }>;
18
17
  productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
19
- sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
18
+ sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number) => Promise<void>;
20
19
  sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
20
+ rejectCall: (callId: string, callFrom: string) => Promise<void>;
21
21
  offerCall: (toJid: string, isVideo?: boolean) => Promise<{
22
- id: string;
23
- to: string;
22
+ callId: string;
23
+ toJid: string;
24
+ isVideo: boolean;
24
25
  }>;
25
- rejectCall: (callId: string, callFrom: string) => Promise<void>;
26
- getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
26
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
27
+ requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
28
+ getPrivacyTokens: (jids: string[]) => Promise<any>;
27
29
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
28
- relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
30
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
29
31
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
30
- sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
31
- getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
32
- [key: string]: string;
33
- };
34
- readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
32
+ sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
33
+ readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
35
34
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
36
- getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
37
- createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
38
- [key: string]: string;
39
- } | undefined) => Promise<{
40
- nodes: BinaryNode[];
41
- shouldIncludeDeviceIdentity: boolean;
42
- }>;
43
35
  waUploadToServer: import("../Types").WAMediaUploadFunction;
44
36
  fetchPrivacySettings: (force?: boolean) => Promise<{
45
37
  [_: string]: string;
46
38
  }>;
39
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
40
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
41
+ nodes: BinaryNode[];
42
+ shouldIncludeDeviceIdentity: boolean;
43
+ }>;
44
+ sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
47
45
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
48
- sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
46
+ sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
49
47
  subscribeNewsletterUpdates: (jid: string) => Promise<{
50
48
  duration: string;
51
49
  }>;
52
50
  newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
53
- newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
51
+ newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
54
52
  newsletterUpdateName: (jid: string, name: string) => Promise<void>;
55
53
  newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
56
54
  newsletterRemovePicture: (jid: string) => Promise<void>;
@@ -58,16 +56,16 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
58
56
  newsletterFollow: (jid: string) => Promise<void>;
59
57
  newsletterUnmute: (jid: string) => Promise<void>;
60
58
  newsletterMute: (jid: string) => Promise<void>;
61
- newsletterAction: (jid: string, type: "mute" | "follow" | "unfollow" | "unmute") => Promise<void>;
62
- newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
63
- newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
59
+ newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
60
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
64
61
  newsletterAdminCount: (jid: string) => Promise<number>;
65
62
  newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
66
63
  newsletterDemote: (jid: string, user: string) => Promise<void>;
67
64
  newsletterDelete: (jid: string) => Promise<void>;
68
- newsletterReactMessage: (jid: string, serverId: string, code?: string | undefined) => Promise<void>;
69
- newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
70
- newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
65
+ newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
66
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
67
+ newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
68
+ groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
71
69
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
72
70
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
73
71
  groupLeave: (id: string) => Promise<void>;
@@ -75,7 +73,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
75
73
  groupRequestParticipantsList: (jid: string) => Promise<{
76
74
  [key: string]: string;
77
75
  }[]>;
78
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
76
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
79
77
  status: string;
80
78
  jid: string;
81
79
  }[]>;
@@ -84,68 +82,71 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
84
82
  jid: string;
85
83
  content: BinaryNode;
86
84
  }[]>;
87
- groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
85
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
88
86
  groupInviteCode: (jid: string) => Promise<string | undefined>;
89
87
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
90
88
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
91
- groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
89
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
90
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
92
91
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
93
92
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
94
- groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
95
- groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
93
+ groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
94
+ groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
96
95
  groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
97
96
  groupFetchAllParticipating: () => Promise<{
98
97
  [_: string]: import("../Types").GroupMetadata;
99
98
  }>;
99
+ getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
100
100
  processingMutex: {
101
- mutex<T>(code: () => T | Promise<T>): Promise<T>;
101
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
102
102
  };
103
- upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
103
+ upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
104
104
  appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
105
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
106
- presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
107
- profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
105
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
106
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
107
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
108
108
  onWhatsApp: (...jids: string[]) => Promise<{
109
109
  jid: string;
110
110
  exists: unknown;
111
111
  lid: unknown;
112
112
  }[] | undefined>;
113
113
  fetchBlocklist: () => Promise<string[]>;
114
- fetchStatus: (jid: string) => Promise<{
115
- status: string | undefined;
116
- setAt: Date;
117
- } | undefined>;
114
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
115
+ fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
118
116
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
119
117
  removeProfilePicture: (jid: string) => Promise<void>;
120
118
  updateProfileStatus: (status: string) => Promise<void>;
121
119
  updateProfileName: (name: string) => Promise<void>;
122
120
  updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
121
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
122
+ updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
123
123
  updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
124
124
  updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
125
125
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
126
126
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
127
127
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
128
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
128
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
129
129
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
130
- getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
131
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
130
+ getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
131
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
132
132
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
133
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
133
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
134
134
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
135
135
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
136
136
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
137
137
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
138
138
  star: (jid: string, messages: {
139
139
  id: string;
140
- fromMe?: boolean | undefined;
140
+ fromMe?: boolean;
141
141
  }[], star: boolean) => Promise<void>;
142
+ executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
142
143
  type: "md";
143
- ws: any;
144
+ ws: import("./Client").WebSocketClient;
144
145
  ev: import("../Types").BaileysEventEmitter & {
145
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
146
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
146
147
  buffer(): void;
147
- createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
148
- flush(force?: boolean | undefined): boolean;
148
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
149
+ flush(force?: boolean): boolean;
149
150
  isBuffering(): boolean;
150
151
  };
151
152
  authState: {
@@ -155,17 +156,17 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
155
156
  signalRepository: import("../Types").SignalRepository;
156
157
  user: import("../Types").Contact | undefined;
157
158
  generateMessageTag: () => string;
158
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
159
- waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
159
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
160
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
160
161
  waitForSocketOpen: () => Promise<void>;
161
162
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
162
163
  sendNode: (frame: BinaryNode) => Promise<void>;
163
- logout: (msg?: string | undefined) => Promise<void>;
164
+ logout: (msg?: string) => Promise<void>;
164
165
  end: (error: Error | undefined) => void;
165
- onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
166
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
166
167
  uploadPreKeys: (count?: number) => Promise<void>;
167
168
  uploadPreKeysToServerIfRequired: () => Promise<void>;
168
- requestPairingCode: (phoneNumber: string) => Promise<string>;
169
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
170
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
169
+ requestPairingCode: (phoneNumber: any, pairKey?: string) => Promise<string>;
170
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
171
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
171
172
  };