@d0v3riz/baileys 6.7.7 → 6.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -10
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +1 -231
- package/lib/Defaults/index.js +1 -17
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
- package/lib/Socket/business.d.ts +3 -1
- package/lib/Socket/chats.d.ts +4 -1
- package/lib/Socket/chats.js +39 -11
- package/lib/Socket/groups.d.ts +3 -1
- package/lib/Socket/index.d.ts +12 -12
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +4 -2
- package/lib/Socket/messages-recv.js +126 -117
- package/lib/Socket/messages-send.d.ts +3 -1
- package/lib/Socket/messages-send.js +23 -8
- package/lib/Socket/socket.d.ts +3 -1
- package/lib/Socket/socket.js +9 -14
- package/lib/Store/make-cache-manager-store.d.ts +2 -1
- package/lib/Store/make-in-memory-store.js +8 -10
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +1 -6
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +10 -7
- package/lib/Types/Contact.d.ts +1 -1
- package/lib/Types/Events.d.ts +4 -0
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Message.d.ts +5 -2
- package/lib/Types/Socket.d.ts +3 -3
- package/lib/Utils/auth-utils.js +1 -7
- package/lib/Utils/chat-utils.d.ts +5 -4
- package/lib/Utils/chat-utils.js +41 -20
- package/lib/Utils/crypto.d.ts +1 -0
- package/lib/Utils/decode-wa-message.js +1 -0
- package/lib/Utils/event-buffer.js +14 -8
- package/lib/Utils/generics.d.ts +10 -5
- package/lib/Utils/generics.js +35 -7
- package/lib/Utils/history.d.ts +2 -2
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/link-preview.js +24 -1
- package/lib/Utils/make-mutex.js +1 -0
- package/lib/Utils/messages-media.d.ts +2 -1
- package/lib/Utils/messages-media.js +8 -15
- package/lib/Utils/messages.d.ts +1 -0
- package/lib/Utils/messages.js +7 -11
- package/lib/Utils/noise-handler.d.ts +2 -2
- package/lib/Utils/noise-handler.js +5 -10
- package/lib/Utils/process-message.js +3 -1
- package/lib/Utils/signal.js +2 -0
- package/lib/Utils/use-multi-file-auth-state.js +1 -0
- package/lib/Utils/validate-connection.d.ts +0 -1
- package/lib/Utils/validate-connection.js +10 -44
- package/lib/WABinary/constants.js +5 -5
- package/lib/WABinary/decode.d.ts +1 -0
- package/lib/WABinary/encode.d.ts +1 -0
- package/lib/WABinary/encode.js +7 -5
- package/lib/WABinary/generic-utils.d.ts +1 -0
- package/lib/WABinary/jid-utils.d.ts +2 -2
- package/lib/WABinary/jid-utils.js +1 -1
- package/lib/WAM/BinaryInfo.d.ts +3 -2
- package/lib/WAM/constants.d.ts +3 -2
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +2 -2
- package/package.json +5 -6
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.d.ts +0 -241
- package/lib/Socket/registration.js +0 -166
- /package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +0 -0
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
package/README.md
CHANGED
|
@@ -89,16 +89,6 @@ connectToWhatsApp()
|
|
|
89
89
|
|
|
90
90
|
If the connection is successful, you will see a QR code printed on your terminal screen, scan it with WhatsApp on your phone and you'll be logged in!
|
|
91
91
|
|
|
92
|
-
**Note:** install `qrcode-terminal` using `yarn add qrcode-terminal` to auto-print the QR to the terminal.
|
|
93
|
-
|
|
94
|
-
**Note:** the code to support the legacy version of WA Web (pre multi-device) has been removed in v5. Only the standard multi-device connection is now supported. This is done as WA seems to have completely dropped support for the legacy version.
|
|
95
|
-
|
|
96
|
-
## Connecting native mobile api
|
|
97
|
-
|
|
98
|
-
Baileys also supports the native mobile API, which allows users to authenticate as a standalone WhatsApp client using their phone number.
|
|
99
|
-
|
|
100
|
-
Run the [example](Example/example.ts) file with ``--mobile`` cli flag to use the native mobile API.
|
|
101
|
-
|
|
102
92
|
## Configuring the Connection
|
|
103
93
|
|
|
104
94
|
You can configure the connection by passing a `SocketConfig` object.
|
package/lib/Defaults/index.d.ts
CHANGED
|
@@ -1,247 +1,17 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { proto } from '../../WAProto';
|
|
3
4
|
import type { MediaType, SocketConfig } from '../Types';
|
|
4
5
|
export declare const UNAUTHORIZED_CODES: number[];
|
|
5
|
-
export declare const PHONENUMBER_MCC: {
|
|
6
|
-
"93": number;
|
|
7
|
-
"355": number;
|
|
8
|
-
"213": number;
|
|
9
|
-
"1-684": number;
|
|
10
|
-
"376": number;
|
|
11
|
-
"244": number;
|
|
12
|
-
"1-264": number;
|
|
13
|
-
"1-268": number;
|
|
14
|
-
"54": number;
|
|
15
|
-
"374": number;
|
|
16
|
-
"297": number;
|
|
17
|
-
"61": number;
|
|
18
|
-
"43": number;
|
|
19
|
-
"994": number;
|
|
20
|
-
"1-242": number;
|
|
21
|
-
"973": number;
|
|
22
|
-
"880": number;
|
|
23
|
-
"1-246": number;
|
|
24
|
-
"375": number;
|
|
25
|
-
"32": number;
|
|
26
|
-
"501": number;
|
|
27
|
-
"229": number;
|
|
28
|
-
"1-441": number;
|
|
29
|
-
"975": number;
|
|
30
|
-
"591": number;
|
|
31
|
-
"387": number;
|
|
32
|
-
"267": number;
|
|
33
|
-
"55": number;
|
|
34
|
-
"1-284": number;
|
|
35
|
-
"673": number;
|
|
36
|
-
"359": number;
|
|
37
|
-
"226": number;
|
|
38
|
-
"257": number;
|
|
39
|
-
"855": number;
|
|
40
|
-
"237": number;
|
|
41
|
-
"238": number;
|
|
42
|
-
"1-345": number;
|
|
43
|
-
"236": number;
|
|
44
|
-
"235": number;
|
|
45
|
-
"56": number;
|
|
46
|
-
"86": number;
|
|
47
|
-
"57": number;
|
|
48
|
-
"269": number;
|
|
49
|
-
"682": number;
|
|
50
|
-
"506": number;
|
|
51
|
-
"385": number;
|
|
52
|
-
"53": number;
|
|
53
|
-
"357": number;
|
|
54
|
-
"420": number;
|
|
55
|
-
"243": number;
|
|
56
|
-
"45": number;
|
|
57
|
-
"253": number;
|
|
58
|
-
"1-767": number;
|
|
59
|
-
"1-809": number;
|
|
60
|
-
"1-849": number;
|
|
61
|
-
"1-829": number;
|
|
62
|
-
"593": number;
|
|
63
|
-
"20": number;
|
|
64
|
-
"503": number;
|
|
65
|
-
"240": number;
|
|
66
|
-
"291": number;
|
|
67
|
-
"372": number;
|
|
68
|
-
"251": number;
|
|
69
|
-
"500": number;
|
|
70
|
-
"298": number;
|
|
71
|
-
"679": number;
|
|
72
|
-
"358": number;
|
|
73
|
-
"33": number;
|
|
74
|
-
"689": number;
|
|
75
|
-
"241": number;
|
|
76
|
-
"220": number;
|
|
77
|
-
"995": number;
|
|
78
|
-
"49": number;
|
|
79
|
-
"233": number;
|
|
80
|
-
"350": number;
|
|
81
|
-
"30": number;
|
|
82
|
-
"299": number;
|
|
83
|
-
"1-473": number;
|
|
84
|
-
"1-671": number;
|
|
85
|
-
"502": number;
|
|
86
|
-
"224": number;
|
|
87
|
-
"592": number;
|
|
88
|
-
"509": number;
|
|
89
|
-
"504": number;
|
|
90
|
-
"852": number;
|
|
91
|
-
"36": number;
|
|
92
|
-
"354": number;
|
|
93
|
-
"91": number;
|
|
94
|
-
"62": number;
|
|
95
|
-
"98": number;
|
|
96
|
-
"964": number;
|
|
97
|
-
"353": number;
|
|
98
|
-
"972": number;
|
|
99
|
-
"39": number;
|
|
100
|
-
"225": number;
|
|
101
|
-
"1-876": number;
|
|
102
|
-
"81": number;
|
|
103
|
-
"962": number;
|
|
104
|
-
"254": number;
|
|
105
|
-
"686": number;
|
|
106
|
-
"383": number;
|
|
107
|
-
"965": number;
|
|
108
|
-
"371": number;
|
|
109
|
-
"961": number;
|
|
110
|
-
"266": number;
|
|
111
|
-
"231": number;
|
|
112
|
-
"218": number;
|
|
113
|
-
"423": number;
|
|
114
|
-
"370": number;
|
|
115
|
-
"352": number;
|
|
116
|
-
"389": number;
|
|
117
|
-
"261": number;
|
|
118
|
-
"265": number;
|
|
119
|
-
"60": number;
|
|
120
|
-
"960": number;
|
|
121
|
-
"223": number;
|
|
122
|
-
"356": number;
|
|
123
|
-
"692": number;
|
|
124
|
-
"222": number;
|
|
125
|
-
"230": number;
|
|
126
|
-
"52": number;
|
|
127
|
-
"691": number;
|
|
128
|
-
"373": number;
|
|
129
|
-
"377": number;
|
|
130
|
-
"976": number;
|
|
131
|
-
"382": number;
|
|
132
|
-
"1-664": number;
|
|
133
|
-
"212": number;
|
|
134
|
-
"258": number;
|
|
135
|
-
"95": number;
|
|
136
|
-
"264": number;
|
|
137
|
-
"674": number;
|
|
138
|
-
"977": number;
|
|
139
|
-
"31": number;
|
|
140
|
-
"687": number;
|
|
141
|
-
"64": number;
|
|
142
|
-
"505": number;
|
|
143
|
-
"227": number;
|
|
144
|
-
"234": number;
|
|
145
|
-
"683": number;
|
|
146
|
-
"1-670": number;
|
|
147
|
-
"47": number;
|
|
148
|
-
"968": number;
|
|
149
|
-
"92": number;
|
|
150
|
-
"680": number;
|
|
151
|
-
"970": number;
|
|
152
|
-
"507": number;
|
|
153
|
-
"675": number;
|
|
154
|
-
"595": number;
|
|
155
|
-
"51": number;
|
|
156
|
-
"63": number;
|
|
157
|
-
"48": number;
|
|
158
|
-
"351": number;
|
|
159
|
-
"1-787, 1-939": number;
|
|
160
|
-
"974": number;
|
|
161
|
-
"242": number;
|
|
162
|
-
"40": number;
|
|
163
|
-
"7": number;
|
|
164
|
-
"250": number;
|
|
165
|
-
"290": number;
|
|
166
|
-
"1-869": number;
|
|
167
|
-
"1-758": number;
|
|
168
|
-
"508": number;
|
|
169
|
-
"1-784": number;
|
|
170
|
-
"685": number;
|
|
171
|
-
"378": number;
|
|
172
|
-
"239": number;
|
|
173
|
-
"966": number;
|
|
174
|
-
"221": number;
|
|
175
|
-
"381": number;
|
|
176
|
-
"248": number;
|
|
177
|
-
"232": number;
|
|
178
|
-
"65": number;
|
|
179
|
-
"386": number;
|
|
180
|
-
"677": number;
|
|
181
|
-
"27": number;
|
|
182
|
-
"211": number;
|
|
183
|
-
"34": number;
|
|
184
|
-
"94": number;
|
|
185
|
-
"249": number;
|
|
186
|
-
"597": number;
|
|
187
|
-
"268": number;
|
|
188
|
-
"46": number;
|
|
189
|
-
"41": number;
|
|
190
|
-
"963": number;
|
|
191
|
-
"886": number;
|
|
192
|
-
"992": number;
|
|
193
|
-
"255": number;
|
|
194
|
-
"66": number;
|
|
195
|
-
"228": number;
|
|
196
|
-
"690": number;
|
|
197
|
-
"676": number;
|
|
198
|
-
"1-868": number;
|
|
199
|
-
"216": number;
|
|
200
|
-
"90": number;
|
|
201
|
-
"993": number;
|
|
202
|
-
"1-649": number;
|
|
203
|
-
"688": number;
|
|
204
|
-
"1-340": number;
|
|
205
|
-
"256": number;
|
|
206
|
-
"380": number;
|
|
207
|
-
"971": number;
|
|
208
|
-
"44": number;
|
|
209
|
-
"1": number;
|
|
210
|
-
"598": number;
|
|
211
|
-
"998": number;
|
|
212
|
-
"678": number;
|
|
213
|
-
"379": number;
|
|
214
|
-
"58": number;
|
|
215
|
-
"681": number;
|
|
216
|
-
"967": number;
|
|
217
|
-
"260": number;
|
|
218
|
-
"263": number;
|
|
219
|
-
"670": number;
|
|
220
|
-
"245": number;
|
|
221
|
-
"856": number;
|
|
222
|
-
"599": number;
|
|
223
|
-
"850": number;
|
|
224
|
-
"262": number;
|
|
225
|
-
"82": number;
|
|
226
|
-
"84": number;
|
|
227
|
-
};
|
|
228
6
|
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
229
|
-
export declare const MOBILE_ENDPOINT = "g.whatsapp.net";
|
|
230
|
-
export declare const MOBILE_PORT = 443;
|
|
231
7
|
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
232
8
|
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
233
9
|
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
234
10
|
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
235
|
-
export declare const MOBILE_TOKEN: Buffer;
|
|
236
|
-
export declare const MOBILE_REGISTRATION_ENDPOINT = "https://v.whatsapp.net/v2";
|
|
237
|
-
export declare const MOBILE_USERAGENT: string;
|
|
238
|
-
export declare const REGISTRATION_PUBLIC_KEY: Buffer;
|
|
239
11
|
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
240
12
|
export declare const DICT_VERSION = 2;
|
|
241
13
|
export declare const KEY_BUNDLE_TYPE: Buffer;
|
|
242
14
|
export declare const NOISE_WA_HEADER: Buffer;
|
|
243
|
-
export declare const PROTOCOL_VERSION: number[];
|
|
244
|
-
export declare const MOBILE_NOISE_HEADER: Buffer;
|
|
245
15
|
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
246
16
|
export declare const URL_REGEX: RegExp;
|
|
247
17
|
export declare const WA_CERT_DETAILS: {
|
package/lib/Defaults/index.js
CHANGED
|
@@ -3,38 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_CACHE_TTLS = 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.
|
|
7
|
-
const crypto_1 = require("crypto");
|
|
6
|
+
exports.DEFAULT_CACHE_TTLS = 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.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = void 0;
|
|
8
7
|
const WAProto_1 = require("../../WAProto");
|
|
9
8
|
const libsignal_1 = require("../Signal/libsignal");
|
|
10
9
|
const Utils_1 = require("../Utils");
|
|
11
10
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
12
11
|
const baileys_version_json_1 = require("./baileys-version.json");
|
|
13
|
-
const phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
|
|
14
12
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
15
|
-
exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default;
|
|
16
13
|
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
17
|
-
exports.MOBILE_ENDPOINT = 'g.whatsapp.net';
|
|
18
|
-
exports.MOBILE_PORT = 443;
|
|
19
14
|
exports.DEF_CALLBACK_PREFIX = 'CB:';
|
|
20
15
|
exports.DEF_TAG_PREFIX = 'TAG:';
|
|
21
16
|
exports.PHONE_CONNECTION_CB = 'CB:Pong';
|
|
22
17
|
exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
23
|
-
const WA_VERSION = '2.24.6.77';
|
|
24
|
-
const WA_VERSION_HASH = (0, crypto_1.createHash)('md5').update(WA_VERSION).digest('hex');
|
|
25
|
-
exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
|
|
26
|
-
exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
|
|
27
|
-
exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/15.3.1 Device/Apple-iPhone_7`;
|
|
28
|
-
exports.REGISTRATION_PUBLIC_KEY = Buffer.from([
|
|
29
|
-
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,
|
|
30
|
-
34, 251, 111, 18, 37, 18, 48, 45,
|
|
31
|
-
]);
|
|
32
18
|
exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
33
19
|
exports.DICT_VERSION = 2;
|
|
34
20
|
exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
35
21
|
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]); // last is "DICT_VERSION"
|
|
36
|
-
exports.PROTOCOL_VERSION = [5, 2];
|
|
37
|
-
exports.MOBILE_NOISE_HEADER = Buffer.concat([Buffer.from('WA'), Buffer.from(exports.PROTOCOL_VERSION)]);
|
|
38
22
|
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
39
23
|
exports.URL_REGEX = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/;
|
|
40
24
|
exports.WA_CERT_DETAILS = {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
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("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./web-socket-client"), exports);
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./websocket"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WebSocket from '@d0v3riz/ws';
|
|
2
|
-
import { AbstractSocketClient } from './
|
|
2
|
+
import { AbstractSocketClient } from './types';
|
|
3
3
|
export declare class WebSocketClient extends AbstractSocketClient {
|
|
4
4
|
protected socket: WebSocket | null;
|
|
5
5
|
get isOpen(): boolean;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.WebSocketClient = void 0;
|
|
7
7
|
const ws_1 = __importDefault(require("@d0v3riz/ws"));
|
|
8
8
|
const Defaults_1 = require("../../Defaults");
|
|
9
|
-
const
|
|
10
|
-
class WebSocketClient extends
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
class WebSocketClient extends types_1.AbstractSocketClient {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.socket = null;
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="long" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
|
|
4
5
|
import { BinaryNode } from '../WABinary';
|
|
5
6
|
export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
@@ -107,6 +108,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
107
108
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
108
109
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
109
110
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
111
|
+
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
110
112
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
111
113
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
112
114
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -116,7 +118,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
116
118
|
fromMe?: boolean | undefined;
|
|
117
119
|
}[], star: boolean) => Promise<void>;
|
|
118
120
|
type: "md";
|
|
119
|
-
ws:
|
|
121
|
+
ws: import("./Client").WebSocketClient;
|
|
120
122
|
ev: import("../Types").BaileysEventEmitter & {
|
|
121
123
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
122
124
|
buffer(): void;
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { Boom } from '@hapi/boom';
|
|
3
4
|
import { proto } from '../../WAProto';
|
|
4
5
|
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
|
6
|
+
import { LabelActionBody } from '../Types/Label';
|
|
5
7
|
import { BinaryNode } from '../WABinary';
|
|
6
8
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
7
9
|
processingMutex: {
|
|
@@ -41,6 +43,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
41
43
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
42
44
|
chatModify: (mod: ChatModification, jid: string) => Promise<void>;
|
|
43
45
|
cleanDirtyBits: (type: 'account_sync' | 'groups', fromTimestamp?: number | string) => Promise<void>;
|
|
46
|
+
addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
|
|
44
47
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
45
48
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
46
49
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -50,7 +53,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
50
53
|
fromMe?: boolean;
|
|
51
54
|
}[], star: boolean) => Promise<void>;
|
|
52
55
|
type: "md";
|
|
53
|
-
ws:
|
|
56
|
+
ws: import("./Client").WebSocketClient;
|
|
54
57
|
ev: import("../Types").BaileysEventEmitter & {
|
|
55
58
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
56
59
|
buffer(): void;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -183,11 +183,19 @@ const makeChatsSocket = (config) => {
|
|
|
183
183
|
};
|
|
184
184
|
/** update the profile picture for yourself or a group */
|
|
185
185
|
const updateProfilePicture = async (jid, content) => {
|
|
186
|
+
let targetJid;
|
|
187
|
+
if (!jid) {
|
|
188
|
+
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
189
|
+
}
|
|
190
|
+
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
191
|
+
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
192
|
+
}
|
|
186
193
|
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
187
194
|
await query({
|
|
188
195
|
tag: 'iq',
|
|
189
196
|
attrs: {
|
|
190
|
-
|
|
197
|
+
target: targetJid,
|
|
198
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
191
199
|
type: 'set',
|
|
192
200
|
xmlns: 'w:profile:picture'
|
|
193
201
|
},
|
|
@@ -202,10 +210,18 @@ const makeChatsSocket = (config) => {
|
|
|
202
210
|
};
|
|
203
211
|
/** remove the profile picture for yourself or a group */
|
|
204
212
|
const removeProfilePicture = async (jid) => {
|
|
213
|
+
let targetJid;
|
|
214
|
+
if (!jid) {
|
|
215
|
+
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
216
|
+
}
|
|
217
|
+
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
218
|
+
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
219
|
+
}
|
|
205
220
|
await query({
|
|
206
221
|
tag: 'iq',
|
|
207
222
|
attrs: {
|
|
208
|
-
|
|
223
|
+
target: targetJid,
|
|
224
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
209
225
|
type: 'set',
|
|
210
226
|
xmlns: 'w:profile:picture'
|
|
211
227
|
}
|
|
@@ -611,7 +627,7 @@ const makeChatsSocket = (config) => {
|
|
|
611
627
|
};
|
|
612
628
|
/** sending non-abt props may fix QR scan fail if server expects */
|
|
613
629
|
const fetchProps = async () => {
|
|
614
|
-
var _a, _b;
|
|
630
|
+
var _a, _b, _c;
|
|
615
631
|
const resultNode = await query({
|
|
616
632
|
tag: 'iq',
|
|
617
633
|
attrs: {
|
|
@@ -629,8 +645,10 @@ const makeChatsSocket = (config) => {
|
|
|
629
645
|
const propsNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, 'props');
|
|
630
646
|
let props = {};
|
|
631
647
|
if (propsNode) {
|
|
632
|
-
|
|
633
|
-
|
|
648
|
+
if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) { // on some clients, the hash is returning as undefined
|
|
649
|
+
authState.creds.lastPropHash = (_c = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _c === void 0 ? void 0 : _c.hash;
|
|
650
|
+
ev.emit('creds.update', authState.creds);
|
|
651
|
+
}
|
|
634
652
|
props = (0, WABinary_1.reduceBinaryNodeToDictionary)(propsNode, 'prop');
|
|
635
653
|
}
|
|
636
654
|
logger.debug('fetched props');
|
|
@@ -656,6 +674,16 @@ const makeChatsSocket = (config) => {
|
|
|
656
674
|
}
|
|
657
675
|
}, jid);
|
|
658
676
|
};
|
|
677
|
+
/**
|
|
678
|
+
* Adds label
|
|
679
|
+
*/
|
|
680
|
+
const addLabel = (jid, labels) => {
|
|
681
|
+
return chatModify({
|
|
682
|
+
addLabel: {
|
|
683
|
+
...labels
|
|
684
|
+
}
|
|
685
|
+
}, jid);
|
|
686
|
+
};
|
|
659
687
|
/**
|
|
660
688
|
* Adds label for the chats
|
|
661
689
|
*/
|
|
@@ -803,14 +831,13 @@ const makeChatsSocket = (config) => {
|
|
|
803
831
|
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
804
832
|
.catch(error => onUnexpectedError(error, 'presence update requests'));
|
|
805
833
|
}
|
|
806
|
-
if (receivedPendingNotifications
|
|
807
|
-
// if we don't have the app state key
|
|
834
|
+
if (receivedPendingNotifications && // if we don't have the app state key
|
|
808
835
|
// we keep buffering events until we finally have
|
|
809
836
|
// the key and can sync the messages
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
837
|
+
// todo scrutinize
|
|
838
|
+
!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
|
|
839
|
+
ev.buffer();
|
|
840
|
+
needToFlushWithAppStateSync = true;
|
|
814
841
|
}
|
|
815
842
|
});
|
|
816
843
|
return {
|
|
@@ -842,6 +869,7 @@ const makeChatsSocket = (config) => {
|
|
|
842
869
|
resyncAppState,
|
|
843
870
|
chatModify,
|
|
844
871
|
cleanDirtyBits,
|
|
872
|
+
addLabel,
|
|
845
873
|
addChatLabel,
|
|
846
874
|
removeChatLabel,
|
|
847
875
|
addMessageLabel,
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { proto } from '../../WAProto';
|
|
3
4
|
import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
|
|
4
5
|
import { BinaryNode } from '../WABinary';
|
|
@@ -81,6 +82,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
81
82
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
82
83
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
83
84
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
85
|
+
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
84
86
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
85
87
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
86
88
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -90,7 +92,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
90
92
|
fromMe?: boolean | undefined;
|
|
91
93
|
}[], star: boolean) => Promise<void>;
|
|
92
94
|
type: "md";
|
|
93
|
-
ws:
|
|
95
|
+
ws: import("./Client").WebSocketClient;
|
|
94
96
|
ev: import("../Types").BaileysEventEmitter & {
|
|
95
97
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
96
98
|
buffer(): void;
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/// <reference types="long" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import { UserFacingSocketConfig } from '../Types';
|
|
4
5
|
declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
5
|
-
register: (code: string) => Promise<import("./registration").ExistsResponse>;
|
|
6
|
-
requestRegistrationCode: (registrationOptions?: import("./registration").RegistrationOptions | undefined) => Promise<import("./registration").ExistsResponse>;
|
|
7
6
|
logger: import("pino").Logger<import("pino").LoggerOptions>;
|
|
8
7
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
9
8
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
@@ -18,12 +17,12 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
18
17
|
deleted: number;
|
|
19
18
|
}>;
|
|
20
19
|
productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
|
|
21
|
-
sendMessageAck: ({ tag, attrs, content }: import("
|
|
22
|
-
sendRetryRequest: (node: import("
|
|
20
|
+
sendMessageAck: ({ tag, attrs, content }: import("..").BinaryNode) => Promise<void>;
|
|
21
|
+
sendRetryRequest: (node: import("..").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
23
22
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
24
23
|
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAProto.IMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
|
|
25
24
|
requestPlaceholderResend: (messageKey: import("../Types").WAProto.IMessageKey) => Promise<string | undefined>;
|
|
26
|
-
getPrivacyTokens: (jids: string[]) => Promise<import("
|
|
25
|
+
getPrivacyTokens: (jids: string[]) => Promise<import("..").BinaryNode>;
|
|
27
26
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
28
27
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
29
28
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
@@ -38,10 +37,10 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
38
37
|
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
|
|
39
38
|
[key: string]: string;
|
|
40
39
|
} | undefined) => Promise<{
|
|
41
|
-
nodes: import("
|
|
40
|
+
nodes: import("..").BinaryNode[];
|
|
42
41
|
shouldIncludeDeviceIdentity: boolean;
|
|
43
42
|
}>;
|
|
44
|
-
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("
|
|
43
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("..").JidWithDevice[]>;
|
|
45
44
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
46
45
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
47
46
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
@@ -58,7 +57,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
58
57
|
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
|
59
58
|
status: string;
|
|
60
59
|
jid: string;
|
|
61
|
-
content: import("
|
|
60
|
+
content: import("..").BinaryNode;
|
|
62
61
|
}[]>;
|
|
63
62
|
groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
64
63
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
@@ -108,6 +107,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
108
107
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
109
108
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
110
109
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
110
|
+
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
111
111
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
112
112
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
113
113
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -117,7 +117,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
117
117
|
fromMe?: boolean | undefined;
|
|
118
118
|
}[], star: boolean) => Promise<void>;
|
|
119
119
|
type: "md";
|
|
120
|
-
ws:
|
|
120
|
+
ws: import("./Client").WebSocketClient;
|
|
121
121
|
ev: import("../Types").BaileysEventEmitter & {
|
|
122
122
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
123
123
|
buffer(): void;
|
|
@@ -132,11 +132,11 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
132
132
|
signalRepository: import("../Types").SignalRepository;
|
|
133
133
|
user: import("../Types").Contact | undefined;
|
|
134
134
|
generateMessageTag: () => string;
|
|
135
|
-
query: (node: import("
|
|
135
|
+
query: (node: import("..").BinaryNode, timeoutMs?: number | undefined) => Promise<import("..").BinaryNode>;
|
|
136
136
|
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
|
|
137
137
|
waitForSocketOpen: () => Promise<void>;
|
|
138
138
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
139
|
-
sendNode: (frame: import("
|
|
139
|
+
sendNode: (frame: import("..").BinaryNode) => Promise<void>;
|
|
140
140
|
logout: (msg?: string | undefined) => Promise<void>;
|
|
141
141
|
end: (error: Error | undefined) => void;
|
|
142
142
|
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
|
@@ -144,6 +144,6 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
144
144
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
145
145
|
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
146
146
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
|
147
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("
|
|
147
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("..").BinaryNode>;
|
|
148
148
|
};
|
|
149
149
|
export default makeWASocket;
|
package/lib/Socket/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Defaults_1 = require("../Defaults");
|
|
4
|
-
const
|
|
4
|
+
const business_1 = require("./business");
|
|
5
5
|
// export the last socket layer
|
|
6
|
-
const makeWASocket = (config) => ((0,
|
|
6
|
+
const makeWASocket = (config) => ((0, business_1.makeBusinessSocket)({
|
|
7
7
|
...Defaults_1.DEFAULT_CONNECTION_CONFIG,
|
|
8
8
|
...config
|
|
9
9
|
}));
|