@badzz88/baileys 8.5.2 → 8.5.4
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 +1 -1
- package/WAProto/WAProto.proto +1256 -75
- package/WAProto/index.d.ts +36042 -19649
- package/WAProto/index.js +181990 -135645
- package/engine-requirements.js +7 -15
- package/lib/Defaults/index.js +22 -17
- package/lib/Signal/Group/group_cipher.js +5 -5
- package/lib/Signal/Group/keyhelper.js +4 -4
- package/lib/Signal/Group/sender-chain-key.js +2 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-record.js +1 -1
- package/lib/Signal/Group/sender-message-key.js +5 -5
- package/lib/Signal/libsignal.js +39 -59
- package/lib/Signal/lid-mapping.js +28 -10
- package/lib/Socket/aigroups.js +5 -5
- package/lib/Socket/business.js +3 -11
- package/lib/Socket/chats.js +668 -319
- package/lib/Socket/communities.js +85 -89
- package/lib/Socket/graphql.js +435 -228
- package/lib/Socket/groups.js +132 -211
- package/lib/Socket/index.js +9 -7
- package/lib/Socket/interactive-handler.js +117 -60
- package/lib/Socket/interop.js +56 -175
- package/lib/Socket/managed-account.js +79 -48
- package/lib/Socket/messages-recv.js +898 -340
- package/lib/Socket/messages-send.js +462 -160
- package/lib/Socket/mex.js +40 -53
- package/lib/Socket/newsletter.js +291 -291
- package/lib/Socket/privacy.js +77 -265
- package/lib/Socket/registration.js +164 -157
- package/lib/Socket/socket.js +181 -199
- package/lib/Socket/username.js +144 -227
- package/lib/Store/make-cache-manager-store.js +2 -2
- package/lib/Store/make-in-memory-store.js +25 -141
- package/lib/Types/Auth.js +3 -3
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Newsletter.js +96 -65
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +52 -57
- package/lib/Utils/browser-utils.js +1 -1
- package/lib/Utils/business.js +2 -6
- package/lib/Utils/chat-utils.js +102 -38
- package/lib/Utils/crypto.js +54 -84
- package/lib/Utils/decode-wa-message.js +316 -83
- package/lib/Utils/event-buffer.js +37 -61
- package/lib/Utils/generics.js +157 -103
- package/lib/Utils/group-history.js +3 -12
- package/lib/Utils/history.js +15 -15
- package/lib/Utils/index.js +1 -5
- package/lib/Utils/link-preview.js +3 -8
- package/lib/Utils/lt-hash.js +2 -35
- package/lib/Utils/make-mutex.js +1 -1
- package/lib/Utils/message-inspect.js +393 -0
- package/lib/Utils/message-retry-manager.js +27 -92
- package/lib/Utils/messages-media.js +159 -130
- package/lib/Utils/messages.js +144 -566
- package/lib/Utils/meta-ai-msmsg.js +62 -202
- package/lib/Utils/noise-handler.js +19 -21
- package/lib/Utils/offline-node-processor.js +3 -8
- package/lib/Utils/pre-key-manager.js +13 -23
- package/lib/Utils/process-message.js +197 -106
- package/lib/Utils/reporting-utils.js +2 -2
- package/lib/Utils/signal.js +28 -63
- package/lib/Utils/stanza-ack.js +39 -12
- package/lib/Utils/sync-action-utils.js +4 -7
- package/lib/Utils/tc-token-utils.js +20 -25
- package/lib/Utils/use-multi-file-auth-state.js +30 -14
- package/lib/Utils/validate-connection.js +59 -19
- package/lib/WABinary/decode.js +50 -16
- package/lib/WABinary/encode.js +54 -224
- package/lib/WABinary/generic-utils.js +7 -97
- package/lib/WABinary/jid-utils.js +27 -14
- package/lib/WAM/encode.js +7 -7
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +58 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -4
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +20 -7
- package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +865 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -2
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -1
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/USyncBackoff.js +26 -0
- package/lib/WAUSync/USyncQuery.js +77 -6
- package/lib/WAUSync/USyncUser.js +16 -8
- package/lib/WAUSync/index.js +1 -0
- package/lib/antiban.js +608 -854
- package/lib/index.js +3 -3
- package/package.json +16 -19
- package/lib/Socket/luxu.js +0 -387
- package/lib/Socket/text-router.js +0 -83
- package/lib/Store/keyed-db.js +0 -108
- package/lib/Types/Mex.js +0 -112
- package/lib/Utils/command-loader.d.ts +0 -31
- package/lib/Utils/command-loader.js +0 -100
- package/lib/Utils/companion-reg-client-utils.js +0 -42
- package/lib/Utils/curve25519-js.js +0 -275
- package/lib/Utils/native-bridge.js +0 -82
- package/lib/Utils/session-pool.d.ts +0 -16
- package/lib/Utils/session-pool.js +0 -94
- package/lib/Utils/sticker.d.ts +0 -17
- package/lib/Utils/sticker.js +0 -145
- package/lib/Utils/view-once-cache.d.ts +0 -9
- package/lib/Utils/view-once-cache.js +0 -79
package/lib/Socket/username.js
CHANGED
|
@@ -2,242 +2,159 @@
|
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
3
|
exports.makeUsernameSocket = void 0
|
|
4
4
|
|
|
5
|
-
const { executeWMexQuery } = require('./mex
|
|
6
|
-
const { USyncQuery, USyncUser } = require('../WAUSync
|
|
7
|
-
const { makeNewsletterSocket } = require('
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* w:mex query IDs for username operations.
|
|
11
|
-
*
|
|
12
|
-
* Source: whatsapp-android-mex_client_persist_ids.json (WA 2.26.26.4 APK assets)
|
|
13
|
-
* Cross-checked: live Frida capture on real device (wa-logger-2.26.26.4.js, 2026-06-30)
|
|
14
|
-
*/
|
|
5
|
+
const { executeWMexQuery } = require('./mex')
|
|
6
|
+
const { USyncQuery, USyncUser } = require('../WAUSync')
|
|
7
|
+
const { makeNewsletterSocket } = require('../WAUSync/Protocols/USyncNewsletterProtocol')
|
|
8
|
+
|
|
9
|
+
|
|
15
10
|
const USERNAME_QUERY_IDS = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
CHECK: '26124072630599518',
|
|
12
|
+
CHECK_MULTI: '27134626522840286',
|
|
13
|
+
SET: '27108705368767936',
|
|
14
|
+
GET: '32618050064506055',
|
|
15
|
+
GET_RECOMMENDATIONS: '26077456248616957',
|
|
16
|
+
PIN_SET: '25529696019976770'
|
|
22
17
|
}
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
* Source enum values from EnumC141106Vn (UsernameCheck result)
|
|
26
|
-
* and EnumC141056Vi (rejection reasons) confirmed via C164057Wg.java
|
|
27
|
-
*/
|
|
19
|
+
|
|
28
20
|
const USERNAME_CHECK_RESULT = {
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
SUCCESS: 'SUCCESS',
|
|
22
|
+
INVALID: 'INVALID'
|
|
31
23
|
}
|
|
32
24
|
|
|
33
25
|
const USERNAME_SOURCE = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
FB: 'FB',
|
|
27
|
+
IG: 'IG',
|
|
28
|
+
USER_INPUT: 'USER_INPUT',
|
|
29
|
+
SUGGESTION: 'SUGGESTION'
|
|
38
30
|
}
|
|
39
31
|
|
|
40
32
|
const makeUsernameSocket = config => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* { tag: 'contact', attrs: { username, pin? } }
|
|
167
|
-
*
|
|
168
|
-
* @param {string} username - The username to look up (without @)
|
|
169
|
-
* @param {string} [pin] - Optional PIN if the username is PIN-protected
|
|
170
|
-
* @returns {{ jid, lid?, contact: boolean }|null}
|
|
171
|
-
*/
|
|
172
|
-
const findUserByUsername = async (username, pin) => {
|
|
173
|
-
const usyncQuery = new USyncQuery().withContactProtocol()
|
|
174
|
-
const user = new USyncUser().withUsername(username)
|
|
175
|
-
if (pin) user.withUsernameKey(pin)
|
|
176
|
-
usyncQuery.withUser(user)
|
|
177
|
-
const result = await executeUSyncQuery(usyncQuery)
|
|
178
|
-
if (!result?.list?.length) return null
|
|
179
|
-
const entry = result.list[0]
|
|
180
|
-
return {
|
|
181
|
-
jid: entry.id,
|
|
182
|
-
contact: entry.contact?? false
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Fetch the username of one or more contacts by their JID.
|
|
188
|
-
* Uses USync with the username protocol.
|
|
189
|
-
*
|
|
190
|
-
* @param {...string} jids - One or more JIDs
|
|
191
|
-
* @returns {Array<{ id, username: string|null }>}
|
|
192
|
-
*/
|
|
193
|
-
const fetchContactUsernames = async (...jids) => {
|
|
194
|
-
const usyncQuery = new USyncQuery().withUsernameProtocol()
|
|
195
|
-
for (const jid of jids) {
|
|
196
|
-
usyncQuery.withUser(new USyncUser().withId(jid))
|
|
197
|
-
}
|
|
198
|
-
const result = await executeUSyncQuery(usyncQuery)
|
|
199
|
-
return result?.list?? []
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Check multiple usernames for availability at once.
|
|
204
|
-
* @param {string[]} usernames - Array of usernames (without @)
|
|
205
|
-
*/
|
|
206
|
-
const checkUsernameMulti = async usernames => {
|
|
207
|
-
const data = await mexQuery(
|
|
208
|
-
{ usernames },
|
|
209
|
-
USERNAME_QUERY_IDS.CHECK_MULTI,
|
|
210
|
-
'xwa2_username_check_multi'
|
|
211
|
-
)
|
|
212
|
-
return data
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Fetch username recommendations for the current user.
|
|
217
|
-
* @param {string} [source] - Source hint: 'FB' | 'IG' | 'USER_INPUT'
|
|
218
|
-
*/
|
|
219
|
-
const getUsernameRecommendations = async (source = null) => {
|
|
220
|
-
const variables = {}
|
|
221
|
-
if (source) variables.source = source
|
|
222
|
-
return mexQuery(variables, USERNAME_QUERY_IDS.GET_RECOMMENDATIONS, 'xwa2_username_get_recommendations')
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return {
|
|
226
|
-
...sock,
|
|
227
|
-
checkUsername,
|
|
228
|
-
checkUsernameMulti,
|
|
229
|
-
setUsername,
|
|
230
|
-
deleteUsername,
|
|
231
|
-
getMyUsername,
|
|
232
|
-
getUsernameRecommendations,
|
|
233
|
-
setUsernamePin,
|
|
234
|
-
findUserByUsername,
|
|
235
|
-
fetchContactUsernames,
|
|
236
|
-
checkAndSetUsername,
|
|
237
|
-
USERNAME_QUERY_IDS,
|
|
238
|
-
USERNAME_CHECK_RESULT,
|
|
239
|
-
USERNAME_SOURCE
|
|
240
|
-
}
|
|
33
|
+
const sock = makeNewsletterSocket(config)
|
|
34
|
+
const { query, generateMessageTag, executeUSyncQuery } = sock
|
|
35
|
+
|
|
36
|
+
const mexQuery = (variables, queryId, dataPath) =>
|
|
37
|
+
executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const checkUsername = async (username, includeSuggestions = true, sessionId) => {
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const session_id = sessionId || require('crypto').randomUUID()
|
|
44
|
+
const data = await mexQuery(
|
|
45
|
+
{
|
|
46
|
+
username,
|
|
47
|
+
include_suggestions: includeSuggestions,
|
|
48
|
+
session_id,
|
|
49
|
+
source: USERNAME_SOURCE.USER_INPUT
|
|
50
|
+
},
|
|
51
|
+
USERNAME_QUERY_IDS.CHECK,
|
|
52
|
+
'xwa2_username_check'
|
|
53
|
+
)
|
|
54
|
+
if (data?.result === USERNAME_CHECK_RESULT.SUCCESS) {
|
|
55
|
+
return { available: true, username, session_id }
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
available: false,
|
|
59
|
+
username,
|
|
60
|
+
session_id,
|
|
61
|
+
suggestions: data?.suggestions ?? [],
|
|
62
|
+
rejectionReasons: data?.rejection_reasons ?? [],
|
|
63
|
+
suggestionsEligible: data?.suggestions_eligible ?? true
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const setUsername = async (username, options = {}) => {
|
|
69
|
+
const { source = USERNAME_SOURCE.USER_INPUT, sessionId, pin } = options
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
const session_id = sessionId || require('crypto').randomUUID()
|
|
73
|
+
const variables = {
|
|
74
|
+
username,
|
|
75
|
+
reserved: true,
|
|
76
|
+
source,
|
|
77
|
+
session_id,
|
|
78
|
+
...(pin ? { pin } : {})
|
|
79
|
+
}
|
|
80
|
+
return mexQuery(variables, USERNAME_QUERY_IDS.SET, 'xwa2_username_set')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
const deleteUsername = async () => {
|
|
85
|
+
return mexQuery({ username: null }, USERNAME_QUERY_IDS.SET, 'xwa2_username_delete')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
const getMyUsername = async () => {
|
|
90
|
+
const data = await mexQuery({}, USERNAME_QUERY_IDS.GET, 'xwa2_username_get')
|
|
91
|
+
return data?.username ?? null
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
const setUsernamePin = async pin => {
|
|
96
|
+
|
|
97
|
+
const variables = pin != null ? { pin } : {}
|
|
98
|
+
return mexQuery(variables, USERNAME_QUERY_IDS.PIN_SET, 'xwa2_username_pin_set')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
const findUserByUsername = async (username, pin) => {
|
|
103
|
+
const usyncQuery = new USyncQuery().withContactProtocol()
|
|
104
|
+
const user = new USyncUser().withUsername(username)
|
|
105
|
+
if (pin) user.withUsernameKey(pin)
|
|
106
|
+
usyncQuery.withUser(user)
|
|
107
|
+
const result = await executeUSyncQuery(usyncQuery)
|
|
108
|
+
if (!result?.list?.length) return null
|
|
109
|
+
const entry = result.list[0]
|
|
110
|
+
return {
|
|
111
|
+
jid: entry.id,
|
|
112
|
+
contact: entry.contact ?? false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
const fetchContactUsernames = async (...jids) => {
|
|
118
|
+
const usyncQuery = new USyncQuery().withUsernameProtocol()
|
|
119
|
+
for (const jid of jids) {
|
|
120
|
+
usyncQuery.withUser(new USyncUser().withId(jid))
|
|
121
|
+
}
|
|
122
|
+
const result = await executeUSyncQuery(usyncQuery)
|
|
123
|
+
return result?.list ?? []
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
const checkUsernameMulti = async usernames => {
|
|
128
|
+
const data = await mexQuery(
|
|
129
|
+
{ usernames },
|
|
130
|
+
USERNAME_QUERY_IDS.CHECK_MULTI,
|
|
131
|
+
'xwa2_username_check_multi'
|
|
132
|
+
)
|
|
133
|
+
return data
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
const getUsernameRecommendations = async (source = null) => {
|
|
138
|
+
const variables = {}
|
|
139
|
+
if (source) variables.source = source
|
|
140
|
+
return mexQuery(variables, USERNAME_QUERY_IDS.GET_RECOMMENDATIONS, 'xwa2_username_get_recommendations')
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
...sock,
|
|
145
|
+
checkUsername,
|
|
146
|
+
checkUsernameMulti,
|
|
147
|
+
setUsername,
|
|
148
|
+
deleteUsername,
|
|
149
|
+
getMyUsername,
|
|
150
|
+
getUsernameRecommendations,
|
|
151
|
+
setUsernamePin,
|
|
152
|
+
findUserByUsername,
|
|
153
|
+
fetchContactUsernames,
|
|
154
|
+
USERNAME_QUERY_IDS,
|
|
155
|
+
USERNAME_CHECK_RESULT,
|
|
156
|
+
USERNAME_SOURCE
|
|
157
|
+
}
|
|
241
158
|
}
|
|
242
159
|
|
|
243
|
-
exports.makeUsernameSocket = makeUsernameSocket
|
|
160
|
+
exports.makeUsernameSocket = makeUsernameSocket
|
|
@@ -19,7 +19,7 @@ const makeCacheManagerAuthState = async (store, sessionKey) => {
|
|
|
19
19
|
const writeData = async (file, data) => {
|
|
20
20
|
let ttl = undefined
|
|
21
21
|
if (file === 'creds') {
|
|
22
|
-
ttl = 63115200
|
|
22
|
+
ttl = 63115200
|
|
23
23
|
}
|
|
24
24
|
await databaseConn.set(defaultKey(file), JSON.stringify(data, Utils_1.BufferJSON.replacer), ttl)
|
|
25
25
|
}
|
|
@@ -71,7 +71,7 @@ const makeCacheManagerAuthState = async (store, sessionKey) => {
|
|
|
71
71
|
return data
|
|
72
72
|
},
|
|
73
73
|
set: async data => {
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
const tasks = []
|
|
76
76
|
for (const category in data) {
|
|
77
77
|
for (const id in data[category]) {
|