@alannxd/baileys 6.1.4 → 6.1.7
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/LICENSE +4 -1
- package/README.md +205 -281
- package/lib/Defaults/index.js +1 -1
- package/lib/Socket/chats.js +5 -0
- package/lib/Socket/graphql.js +716 -0
- package/lib/Socket/index.js +9 -1
- package/lib/Socket/interop.js +463 -0
- package/lib/Socket/message-builder.js +475 -0
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-send.js +106 -30
- package/lib/Socket/mex.js +51 -39
- package/lib/Socket/newsletter.js +729 -242
- package/lib/Socket/privacy.js +318 -0
- package/lib/Socket/socket.js +163 -16
- package/lib/Socket/username.js +225 -136
- package/lib/Store/make-in-memory-store.js +47 -1
- package/lib/Types/Mex.js +76 -2
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/messages-media.js +82 -0
- package/lib/Utils/messages.js +143 -2
- package/lib/Utils/sticker.js +133 -0
- package/lib/Utils/use-sqlite-auth-state.js +162 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -50
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +55 -52
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +28 -25
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +58 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -36
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -23
- package/lib/WAUSync/Protocols/index.js +12 -6
- package/lib/WAUSync/USyncQuery.js +149 -96
- package/lib/WAUSync/USyncUser.js +54 -29
- package/lib/WAUSync/index.js +3 -4
- package/lib/index.js +2 -3
- package/package.json +20 -21
- package/WAProto/fix-import.js +0 -29
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/community.js +0 -392
- package/lib/Socket/dugong.js +0 -637
- package/lib/Socket/registration.js +0 -167
- package/lib/Socket/usync.js +0 -69
- package/lib/Types/Newsletter.js +0 -38
- package/lib/Utils/baileys-event-stream.js +0 -63
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
package/lib/Socket/username.js
CHANGED
|
@@ -1,147 +1,236 @@
|
|
|
1
1
|
import { executeWMexQuery } from './mex.js'
|
|
2
2
|
import { USyncQuery, USyncUser } from '../WAUSync/index.js'
|
|
3
3
|
import { makeNewsletterSocket } from './newsletter.js'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import crypto from 'crypto'
|
|
5
|
+
/**
|
|
6
|
+
* w:mex query IDs for username operations.
|
|
7
|
+
*
|
|
8
|
+
* Source: whatsapp-android-mex_client_persist_ids.json (WA 2.26.26.4 APK assets)
|
|
9
|
+
* Cross-checked: live Frida capture on real device (wa-logger-2.26.26.4.js, 2026-06-30)
|
|
10
|
+
*/
|
|
11
|
+
const USERNAME_QUERY_IDS = {
|
|
12
|
+
CHECK: '26124072630599518', // UsernameCheck
|
|
13
|
+
CHECK_MULTI: '27134626522840286', // UsernameCheckMulti
|
|
14
|
+
SET: '27108705368767936', // UsernameSet
|
|
15
|
+
GET: '32618050064506055', // UsernameGet
|
|
16
|
+
GET_RECOMMENDATIONS: '26077456248616957', // UsernameGetRecommendationsQuery
|
|
17
|
+
PIN_SET: '25529696019976770' // UsernamePinSet
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Source enum values from EnumC141106Vn (UsernameCheck result)
|
|
22
|
+
* and EnumC141056Vi (rejection reasons) confirmed via C164057Wg.java
|
|
23
|
+
*/
|
|
24
|
+
const USERNAME_CHECK_RESULT = {
|
|
25
|
+
SUCCESS: 'SUCCESS',
|
|
26
|
+
INVALID: 'INVALID'
|
|
17
27
|
}
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
const USERNAME_SOURCE = {
|
|
30
|
+
FB: 'FB',
|
|
31
|
+
IG: 'IG',
|
|
32
|
+
USER_INPUT: 'USER_INPUT',
|
|
33
|
+
SUGGESTION: 'SUGGESTION'
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
export const makeUsernameSocket = config => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
37
|
+
const sock = makeNewsletterSocket(config)
|
|
38
|
+
const { query, generateMessageTag, executeUSyncQuery } = sock
|
|
39
|
+
|
|
40
|
+
const mexQuery = (variables, queryId, dataPath) =>
|
|
41
|
+
executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag)
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check whether a username is available.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} username - The @username to check (without @)
|
|
47
|
+
* @param {boolean} includeSuggestions - Request alternative suggestions when taken
|
|
48
|
+
* @returns {object}
|
|
49
|
+
* On success: { available: true, username }
|
|
50
|
+
* On taken: { available: false, username, suggestions: string[], rejectionReasons: string[], suggestionsEligible: boolean }
|
|
51
|
+
* On rate-limit: throws Boom with statusCode 429
|
|
52
|
+
*
|
|
53
|
+
* Confirmed fields from C164057Wg.java:
|
|
54
|
+
* data.xwa2_username_check.result → 'SUCCESS' | 'INVALID'
|
|
55
|
+
* data.xwa2_username_check.suggestions
|
|
56
|
+
* data.xwa2_username_check.rejection_reasons
|
|
57
|
+
* data.xwa2_username_check.suggestions_eligible
|
|
58
|
+
*/
|
|
59
|
+
const checkUsername = async (username, includeSuggestions = true, sessionId) => {
|
|
60
|
+
// session_id ties this check to the subsequent set step — caller can pass one in
|
|
61
|
+
// so both use the same UUID (confirmed from live WA 2.26.26.4 capture).
|
|
62
|
+
const session_id = sessionId || crypto.randomUUID()
|
|
63
|
+
const data = await mexQuery(
|
|
64
|
+
{
|
|
65
|
+
username,
|
|
66
|
+
include_suggestions: includeSuggestions,
|
|
67
|
+
session_id,
|
|
68
|
+
source: USERNAME_SOURCE.USER_INPUT
|
|
69
|
+
},
|
|
70
|
+
USERNAME_QUERY_IDS.CHECK,
|
|
71
|
+
'xwa2_username_check'
|
|
72
|
+
)
|
|
73
|
+
if (data?.includes(USERNAME_CHECK_RESULT.SUCCESS) || data?.result === USERNAME_CHECK_RESULT.SUCCESS) {
|
|
74
|
+
return { available: true, username, session_id }
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
available: false,
|
|
78
|
+
username,
|
|
79
|
+
session_id,
|
|
80
|
+
suggestions: data?.suggestions?? [],
|
|
81
|
+
rejectionReasons: data?.rejection_reasons?? [],
|
|
82
|
+
suggestionsEligible: data?.suggestions_eligible?? true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Set your own username.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} username - The username to set (without @)
|
|
90
|
+
* @param {object} options
|
|
91
|
+
* @param {string} [options.source] - 'USER_INPUT' | 'FB' | 'IG' | 'SUGGESTION'
|
|
92
|
+
* @param {string} [options.sessionId] - Optional session tracking ID
|
|
93
|
+
* @param {string} [options.pin] - Optional PIN for protected usernames
|
|
94
|
+
*
|
|
95
|
+
* Confirmed variables from C1568872p.java A00():
|
|
96
|
+
* username, reserved (bool), session_id, source, pin
|
|
97
|
+
*/
|
|
98
|
+
const setUsername = async (username, options = {}) => {
|
|
99
|
+
const { source = USERNAME_SOURCE.USER_INPUT, sessionId, pin } = options
|
|
100
|
+
// session_id links the check and set steps — generate one if caller doesn't supply it.
|
|
101
|
+
// reserved:true confirmed from live WA 2.26.26.4 capture (was wrongly false before).
|
|
102
|
+
const session_id = sessionId || crypto.randomUUID()
|
|
103
|
+
const variables = {
|
|
104
|
+
username,
|
|
105
|
+
reserved: true,
|
|
106
|
+
source,
|
|
107
|
+
session_id,
|
|
108
|
+
...(pin? { pin } : {})
|
|
109
|
+
}
|
|
110
|
+
return mexQuery(variables, USERNAME_QUERY_IDS.SET, 'xwa2_username_set')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const checkAndSetUsername = async (username) => {
|
|
114
|
+
const r = await checkUsername(username);
|
|
115
|
+
if (r.available) {
|
|
116
|
+
return await setUsername(username)
|
|
117
|
+
}
|
|
118
|
+
return r
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Delete (unset) your own username.
|
|
123
|
+
*
|
|
124
|
+
* Confirmed from C1568872p.java:
|
|
125
|
+
* str4 = str == null? "delete" : "set"
|
|
126
|
+
* → sending username=null triggers the delete path on the server.
|
|
127
|
+
*/
|
|
128
|
+
const deleteUsername = async () => {
|
|
129
|
+
return mexQuery({ username: null }, USERNAME_QUERY_IDS.SET, 'xwa2_username_delete')
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get your own current username.
|
|
134
|
+
*
|
|
135
|
+
* Confirmed from C1568872p.java A02():
|
|
136
|
+
* AbstractC41851rT.A0L(AbstractC130045pa.A0T(), C1363664w.class, "UsernameGet", false)
|
|
137
|
+
*/
|
|
138
|
+
const getMyUsername = async () => {
|
|
139
|
+
const data = await mexQuery({}, USERNAME_QUERY_IDS.GET, 'xwa2_username_get')
|
|
140
|
+
return data?.username?? null
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Set or delete the PIN that protects your username.
|
|
145
|
+
*
|
|
146
|
+
* @param {string|null} pin - New PIN, or null to delete the PIN
|
|
147
|
+
*
|
|
148
|
+
* Confirmed from MexUsernamePinProtocolApi.java:
|
|
149
|
+
* operation "UsernamePinSet", variable "pin"
|
|
150
|
+
* pin=null triggers the "delete" path on the server.
|
|
151
|
+
*/
|
|
152
|
+
const setUsernamePin = async pin => {
|
|
153
|
+
// pin=null → delete PIN (server interprets empty/null variables as delete)
|
|
154
|
+
const variables = pin!= null? { pin } : {}
|
|
155
|
+
return mexQuery(variables, USERNAME_QUERY_IDS.PIN_SET, 'xwa2_username_pin_set')
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Look up a contact by their @username via USync.
|
|
160
|
+
*
|
|
161
|
+
* Confirmed via USyncContactProtocol.getUserElement():
|
|
162
|
+
* { tag: 'contact', attrs: { username, pin? } }
|
|
163
|
+
*
|
|
164
|
+
* @param {string} username - The username to look up (without @)
|
|
165
|
+
* @param {string} [pin] - Optional PIN if the username is PIN-protected
|
|
166
|
+
* @returns {{ jid, lid?, contact: boolean }|null}
|
|
167
|
+
*/
|
|
168
|
+
const findUserByUsername = async (username, pin) => {
|
|
169
|
+
const usyncQuery = new USyncQuery().withContactProtocol()
|
|
170
|
+
const user = new USyncUser().withUsername(username)
|
|
171
|
+
if (pin) user.withUsernameKey(pin)
|
|
172
|
+
usyncQuery.withUser(user)
|
|
173
|
+
const result = await executeUSyncQuery(usyncQuery)
|
|
174
|
+
if (!result?.list?.length) return null
|
|
175
|
+
const entry = result.list[0]
|
|
176
|
+
return {
|
|
177
|
+
jid: entry.id,
|
|
178
|
+
contact: entry.contact?? false
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Fetch the username of one or more contacts by their JID.
|
|
184
|
+
* Uses USync with the username protocol.
|
|
185
|
+
*
|
|
186
|
+
* @param {...string} jids - One or more JIDs
|
|
187
|
+
* @returns {Array<{ id, username: string|null }>}
|
|
188
|
+
*/
|
|
189
|
+
const fetchContactUsernames = async (...jids) => {
|
|
190
|
+
const usyncQuery = new USyncQuery().withUsernameProtocol()
|
|
191
|
+
for (const jid of jids) {
|
|
192
|
+
usyncQuery.withUser(new USyncUser().withId(jid))
|
|
193
|
+
}
|
|
194
|
+
const result = await executeUSyncQuery(usyncQuery)
|
|
195
|
+
return result?.list?? []
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Check multiple usernames for availability at once.
|
|
200
|
+
* @param {string[]} usernames - Array of usernames (without @)
|
|
201
|
+
*/
|
|
202
|
+
const checkUsernameMulti = async usernames => {
|
|
203
|
+
const data = await mexQuery(
|
|
204
|
+
{ usernames },
|
|
205
|
+
USERNAME_QUERY_IDS.CHECK_MULTI,
|
|
206
|
+
'xwa2_username_check_multi'
|
|
207
|
+
)
|
|
208
|
+
return data
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Fetch username recommendations for the current user.
|
|
213
|
+
* @param {string} [source] - Source hint: 'FB' | 'IG' | 'USER_INPUT'
|
|
214
|
+
*/
|
|
215
|
+
const getUsernameRecommendations = async (source = null) => {
|
|
216
|
+
const variables = {}
|
|
217
|
+
if (source) variables.source = source
|
|
218
|
+
return mexQuery(variables, USERNAME_QUERY_IDS.GET_RECOMMENDATIONS, 'xwa2_username_get_recommendations')
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
...sock,
|
|
223
|
+
checkUsername,
|
|
224
|
+
checkUsernameMulti,
|
|
225
|
+
setUsername,
|
|
226
|
+
deleteUsername,
|
|
227
|
+
getMyUsername,
|
|
228
|
+
getUsernameRecommendations,
|
|
229
|
+
setUsernamePin,
|
|
230
|
+
findUserByUsername,
|
|
231
|
+
fetchContactUsernames,
|
|
232
|
+
USERNAME_QUERY_IDS,
|
|
233
|
+
USERNAME_CHECK_RESULT,
|
|
234
|
+
USERNAME_SOURCE
|
|
235
|
+
}
|
|
147
236
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from "fs";
|
|
1
2
|
import * as WAProto_1 from "../../WAProto/index.js";
|
|
2
3
|
import * as Defaults_1 from "../Defaults/index.js";
|
|
3
4
|
import { LabelAssociationType } from "../Types/LabelAssociation.js";
|
|
@@ -181,6 +182,48 @@ export default function makeInMemoryStore(config) {
|
|
|
181
182
|
const loadMessage = async (jid, id) => {
|
|
182
183
|
return messages[jid]?.get(id)
|
|
183
184
|
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Persist the whole store to a JSON file on disk (synchronous, atomic write).
|
|
188
|
+
* Writes to a temp file first then renames, so a crash mid-write can't
|
|
189
|
+
* corrupt the existing store file.
|
|
190
|
+
*/
|
|
191
|
+
const writeToFile = (path) => {
|
|
192
|
+
try {
|
|
193
|
+
const tmpPath = `${path}.tmp`;
|
|
194
|
+
fs.writeFileSync(tmpPath, JSON.stringify(toJSON()));
|
|
195
|
+
fs.renameSync(tmpPath, path);
|
|
196
|
+
} catch (err) {
|
|
197
|
+
logger.error({ err }, "failed to write store to file");
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Load store state from a JSON file on disk, if it exists.
|
|
203
|
+
* Safe to call even if the file was never created yet.
|
|
204
|
+
*/
|
|
205
|
+
const readFromFile = (path) => {
|
|
206
|
+
if (!fs.existsSync(path)) return;
|
|
207
|
+
try {
|
|
208
|
+
const jsonStr = fs.readFileSync(path, { encoding: "utf-8" });
|
|
209
|
+
const json = JSON.parse(jsonStr);
|
|
210
|
+
fromJSON(json);
|
|
211
|
+
} catch (err) {
|
|
212
|
+
logger.error({ err }, "failed to read store from file");
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Convenience helper: load once from `path` (if present), then keep
|
|
218
|
+
* saving to the same file every `intervalMs` (default 10s).
|
|
219
|
+
* Returns a function to stop the auto-save interval.
|
|
220
|
+
*/
|
|
221
|
+
const writeToFileInterval = (path, intervalMs = 10_000) => {
|
|
222
|
+
readFromFile(path);
|
|
223
|
+
const interval = setInterval(() => writeToFile(path), intervalMs);
|
|
224
|
+
return () => clearInterval(interval);
|
|
225
|
+
};
|
|
226
|
+
|
|
184
227
|
return {
|
|
185
228
|
chats,
|
|
186
229
|
contacts,
|
|
@@ -193,6 +236,9 @@ export default function makeInMemoryStore(config) {
|
|
|
193
236
|
bind,
|
|
194
237
|
toJSON,
|
|
195
238
|
fromJSON,
|
|
196
|
-
loadMessage
|
|
239
|
+
loadMessage,
|
|
240
|
+
writeToFile,
|
|
241
|
+
readFromFile,
|
|
242
|
+
writeToFileInterval
|
|
197
243
|
};
|
|
198
244
|
}
|
package/lib/Types/Mex.js
CHANGED
|
@@ -16,12 +16,48 @@ export var XWAPaths;
|
|
|
16
16
|
XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
|
|
17
17
|
XWAPaths["xwa2_fetch_account_reachout_timelock"] = "xwa2_fetch_account_reachout_timelock";
|
|
18
18
|
XWAPaths["xwa2_message_capping_info"] = "xwa2_message_capping_info";
|
|
19
|
+
XWAPaths["xwa2_newsletter_subscribed"] = "xwa2_newsletter_subscribed";
|
|
20
|
+
XWAPaths["xwa2_newsletter_update"] = "xwa2_newsletter_update";
|
|
21
|
+
XWAPaths["xwa2_newsletter_admin"] = "xwa2_newsletter_admin";
|
|
22
|
+
XWAPaths["xwa2_newsletter_admin_invite_create"] = "xwa2_newsletter_admin_invite_create";
|
|
23
|
+
XWAPaths["xwa2_newsletter_admin_invite_revoke"] = "xwa2_newsletter_admin_invite_revoke";
|
|
24
|
+
XWAPaths["xwa2_newsletter_admin_invite_accept"] = "xwa2_newsletter_admin_invite_accept";
|
|
25
|
+
XWAPaths["xwa2_newsletter_admin_profile_update"] = "xwa2_newsletter_admin_profile_update";
|
|
26
|
+
XWAPaths["xwa2_newsletter_admin_insights"] = "xwa2_newsletter_admin_insights";
|
|
27
|
+
XWAPaths["xwa2_newsletter_following"] = "xwa2_newsletter_following";
|
|
28
|
+
XWAPaths["xwa2_newsletter_create_verified"] = "xwa2_newsletter_create_verified";
|
|
29
|
+
XWAPaths["xwa2_newsletter_enforcements"] = "xwa2_newsletter_enforcements";
|
|
30
|
+
XWAPaths["xwa2_newsletter_user_reports"] = "xwa2_newsletter_user_reports";
|
|
31
|
+
XWAPaths["xwa2_newsletter_create_report_appeal"] = "xwa2_newsletter_create_report_appeal";
|
|
32
|
+
XWAPaths["xwa2_newsletter_link_preview_check"] = "xwa2_newsletter_link_preview_check";
|
|
33
|
+
XWAPaths["xwa2_newsletter_update_verification"] = "xwa2_newsletter_update_verification";
|
|
34
|
+
XWAPaths["xwa2_newsletter_label_paid_partnership"] = "xwa2_newsletter_label_paid_partnership";
|
|
35
|
+
XWAPaths["xwa2_newsletter_log_exposures"] = "xwa2_newsletter_log_exposures";
|
|
36
|
+
XWAPaths["xwa2_newsletter_update_user_setting"] = "xwa2_newsletter_update_user_setting";
|
|
37
|
+
XWAPaths["xwa2_newsletter_ranking_features"] = "xwa2_newsletter_ranking_features";
|
|
38
|
+
XWAPaths["xwa2_newsletter_block_user"] = "xwa2_newsletter_block_user";
|
|
39
|
+
XWAPaths["xwa2_newsletters_directory_list"] = "xwa2_newsletters_directory_list";
|
|
40
|
+
XWAPaths["xwa2_newsletters_directory_search"] = "xwa2_newsletters_directory_search";
|
|
41
|
+
XWAPaths["xwa2_newsletters_directory_category_preview"] = "xwa2_newsletters_directory_category_preview";
|
|
42
|
+
XWAPaths["xwa2_newsletters_search"] = "xwa2_newsletters_search";
|
|
43
|
+
XWAPaths["xwa2_newsletters_recommended"] = "xwa2_newsletters_recommended";
|
|
44
|
+
XWAPaths["xwa2_newsletters_similar"] = "xwa2_newsletters_similar";
|
|
45
|
+
XWAPaths["xwa2_newsletters_poll_voter_list"] = "xwa2_newsletters_poll_voter_list";
|
|
46
|
+
XWAPaths["xwa2_newsletters_reaction_sender_list"] = "xwa2_newsletters_reaction_sender_list";
|
|
47
|
+
XWAPaths["xwa2_wamo_afs_age_collection"] = "xwa2_wamo_afs_age_collection";
|
|
48
|
+
XWAPaths["xwa2_wamo_asset_collection"] = "xwa2_wamo_asset_collection";
|
|
49
|
+
XWAPaths["xwa2_wamo_fetch_adhoc_notice_by_id"] = "xwa2_wamo_fetch_adhoc_notice_by_id";
|
|
50
|
+
XWAPaths["xwa2_wamo_fetch_identity_token"] = "xwa2_wamo_fetch_identity_token";
|
|
51
|
+
XWAPaths["xwa2_wamo_sub_get_compliance_info"] = "xwa2_wamo_sub_get_compliance_info";
|
|
52
|
+
XWAPaths["xwa2_wamo_user_id_version"] = "xwa2_wamo_user_id_version";
|
|
53
|
+
XWAPaths["xwa2_wamo_set_user_id_version"] = "xwa2_wamo_set_user_id_version";
|
|
19
54
|
})(XWAPaths || (XWAPaths = {}));
|
|
55
|
+
|
|
20
56
|
export var QueryIds;
|
|
21
57
|
(function (QueryIds) {
|
|
22
58
|
QueryIds["CREATE"] = "8823471724422422";
|
|
23
|
-
QueryIds["
|
|
24
|
-
QueryIds["
|
|
59
|
+
QueryIds["METADATA"] = "26099060629688646";
|
|
60
|
+
QueryIds["UPDATE_METADATA"] = "25976052865358570";
|
|
25
61
|
QueryIds["SUBSCRIBERS"] = "9783111038412085";
|
|
26
62
|
QueryIds["FOLLOW"] = "24404358912487870";
|
|
27
63
|
QueryIds["UNFOLLOW"] = "9767147403369991";
|
|
@@ -33,5 +69,43 @@ export var QueryIds;
|
|
|
33
69
|
QueryIds["DELETE"] = "30062808666639665";
|
|
34
70
|
QueryIds["REACHOUT_TIMELOCK"] = "23983697327930364";
|
|
35
71
|
QueryIds["MESSAGE_CAPPING_INFO"] = "24503548349331633";
|
|
72
|
+
QueryIds["FETCH_SUBSCRIBE"] = "6388546374527196";
|
|
73
|
+
QueryIds["LEAVE"] = "9784043202933196";
|
|
74
|
+
QueryIds["ADMIN_INVITE"] = "7148599488585196";
|
|
75
|
+
QueryIds["ADMIN_INVITE_REVOKE"] = "6345824195482235";
|
|
76
|
+
QueryIds["ADMIN_INVITE_ACCEPT"] = "6345824195482236";
|
|
77
|
+
QueryIds["ADMIN_METADATA"] = "6895563180530100";
|
|
78
|
+
QueryIds["ADMIN_PROFILE_UPDATE"] = "6895563180530101";
|
|
79
|
+
QueryIds["INSIGHTS"] = "6243647912368353";
|
|
80
|
+
QueryIds["FOLLOWING_LIST"] = "6388546374527197";
|
|
81
|
+
QueryIds["CREATE_VERIFIED"] = "8823471724422423";
|
|
82
|
+
QueryIds["ENFORCEMENTS"] = "7130823597031707";
|
|
83
|
+
QueryIds["USER_REPORTS"] = "9783111038412086";
|
|
84
|
+
QueryIds["CREATE_REPORT_APPEAL"] = "6551828931592904";
|
|
85
|
+
QueryIds["LINK_PREVIEW_CHECK"] = "24404358912487871";
|
|
86
|
+
QueryIds["UPDATE_VERIFICATION"] = "25976052865358571";
|
|
87
|
+
QueryIds["LABEL_PAID_PARTNERSHIP"] = "7341777602580934";
|
|
88
|
+
QueryIds["LOG_EXPOSURES"] = "9864994326891138";
|
|
89
|
+
QueryIds["UPDATE_USER_SETTING"] = "29766401636284407";
|
|
90
|
+
QueryIds["RANKING_FEATURES"] = "7130823597031708";
|
|
91
|
+
QueryIds["BLOCK_USER"] = "6345824195482237";
|
|
92
|
+
QueryIds["DIRECTORY_LIST"] = "6388546374527198";
|
|
93
|
+
QueryIds["DIRECTORY_SEARCH"] = "6388546374527199";
|
|
94
|
+
QueryIds["DIRECTORY_CATEGORY_PREVIEW"] = "6388546374527200";
|
|
95
|
+
QueryIds["SEARCH"] = "26099060629688647";
|
|
96
|
+
QueryIds["RECOMMENDED"] = "26099060629688648";
|
|
97
|
+
QueryIds["SIMILAR"] = "26099060629688649";
|
|
98
|
+
QueryIds["POLL_VOTER_LIST"] = "9783111038412087";
|
|
99
|
+
QueryIds["REACTION_SENDERS_LIST"] = "9783111038412088";
|
|
100
|
+
QueryIds["WAMO_ENABLE_SUB"] = "7148599488585197";
|
|
101
|
+
QueryIds["WAMO_DISABLE_SUB"] = "7148599488585198";
|
|
102
|
+
QueryIds["WAMO_CHANGE_SUB"] = "7148599488585199";
|
|
103
|
+
QueryIds["WAMO_AFS_AGE_COLLECTION"] = "6895563180530102";
|
|
104
|
+
QueryIds["WAMO_ASSET_COLLECTION"] = "6895563180530103";
|
|
105
|
+
QueryIds["WAMO_FETCH_ADHOC_NOTICE"] = "6895563180530104";
|
|
106
|
+
QueryIds["WAMO_FETCH_IDENTITY_TOKEN"] = "6895563180530105";
|
|
107
|
+
QueryIds["WAMO_SUB_COMPLIANCE_INFO"] = "6895563180530106";
|
|
108
|
+
QueryIds["WAMO_USER_ID_VERSION"] = "6895563180530107";
|
|
109
|
+
QueryIds["WAMO_SET_USER_ID_VERSION"] = "6895563180530108";
|
|
36
110
|
})(QueryIds || (QueryIds = {}));
|
|
37
111
|
//# sourceMappingURL=Mex.js.map
|
package/lib/Utils/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export * from './chat-utils.js';
|
|
|
11
11
|
export * from './lt-hash.js';
|
|
12
12
|
export * from './auth-utils.js';
|
|
13
13
|
export * from './use-multi-file-auth-state.js';
|
|
14
|
+
export * from './use-sqlite-auth-state.js';
|
|
14
15
|
export * from './link-preview.js';
|
|
15
16
|
export * from './event-buffer.js';
|
|
16
17
|
export * from './process-message.js';
|
|
@@ -778,6 +778,88 @@ export const decryptMediaRetryData = ({ ciphertext, iv }, mediaKey, msgId) => {
|
|
|
778
778
|
const plaintext = aesDecryptGCM(ciphertext, retryKey, iv, Buffer.from(msgId));
|
|
779
779
|
return proto.MediaRetryNotification.decode(plaintext);
|
|
780
780
|
};
|
|
781
|
+
const CRC_TABLE = (() => {
|
|
782
|
+
const table = new Uint32Array(256);
|
|
783
|
+
for (let n = 0; n < 256; n++) {
|
|
784
|
+
let c = n;
|
|
785
|
+
for (let k = 0; k < 8; k++) {
|
|
786
|
+
c = c & 1 ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1);
|
|
787
|
+
}
|
|
788
|
+
table[n] = c >>> 0;
|
|
789
|
+
}
|
|
790
|
+
return table;
|
|
791
|
+
})();
|
|
792
|
+
export const crc32 = (buf) => {
|
|
793
|
+
let crc = 0xffffffff;
|
|
794
|
+
for (let i = 0; i < buf.length; i++) {
|
|
795
|
+
crc = CRC_TABLE[(crc ^ buf[i]) & 0xff] ^ (crc >>> 8);
|
|
796
|
+
}
|
|
797
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
798
|
+
};
|
|
799
|
+
export const buildZipArchive = (files) => {
|
|
800
|
+
const localChunks = [];
|
|
801
|
+
const centralChunks = [];
|
|
802
|
+
let offset = 0;
|
|
803
|
+
for (const { name, data } of files) {
|
|
804
|
+
const nameBuf = Buffer.from(name, 'utf8');
|
|
805
|
+
const crc = crc32(data);
|
|
806
|
+
const dosTime = 0;
|
|
807
|
+
const dosDate = 0x21;
|
|
808
|
+
const localHeader = Buffer.alloc(30);
|
|
809
|
+
localHeader.writeUInt32LE(0x04034b50, 0);
|
|
810
|
+
localHeader.writeUInt16LE(20, 4);
|
|
811
|
+
localHeader.writeUInt16LE(0, 6);
|
|
812
|
+
localHeader.writeUInt16LE(0, 8);
|
|
813
|
+
localHeader.writeUInt16LE(dosTime, 10);
|
|
814
|
+
localHeader.writeUInt16LE(dosDate, 12);
|
|
815
|
+
localHeader.writeUInt32LE(crc, 14);
|
|
816
|
+
localHeader.writeUInt32LE(data.length, 18);
|
|
817
|
+
localHeader.writeUInt32LE(data.length, 22);
|
|
818
|
+
localHeader.writeUInt16LE(nameBuf.length, 26);
|
|
819
|
+
localHeader.writeUInt16LE(0, 28);
|
|
820
|
+
localChunks.push(localHeader, nameBuf, data);
|
|
821
|
+
const centralHeader = Buffer.alloc(46);
|
|
822
|
+
centralHeader.writeUInt32LE(0x02014b50, 0);
|
|
823
|
+
centralHeader.writeUInt16LE(20, 4);
|
|
824
|
+
centralHeader.writeUInt16LE(20, 6);
|
|
825
|
+
centralHeader.writeUInt16LE(0, 8);
|
|
826
|
+
centralHeader.writeUInt16LE(0, 10);
|
|
827
|
+
centralHeader.writeUInt16LE(dosTime, 12);
|
|
828
|
+
centralHeader.writeUInt16LE(dosDate, 14);
|
|
829
|
+
centralHeader.writeUInt32LE(crc, 16);
|
|
830
|
+
centralHeader.writeUInt32LE(data.length, 20);
|
|
831
|
+
centralHeader.writeUInt32LE(data.length, 24);
|
|
832
|
+
centralHeader.writeUInt16LE(nameBuf.length, 28);
|
|
833
|
+
centralHeader.writeUInt16LE(0, 30);
|
|
834
|
+
centralHeader.writeUInt16LE(0, 32);
|
|
835
|
+
centralHeader.writeUInt16LE(0, 34);
|
|
836
|
+
centralHeader.writeUInt16LE(0, 36);
|
|
837
|
+
centralHeader.writeUInt32LE(0, 38);
|
|
838
|
+
centralHeader.writeUInt32LE(offset, 42);
|
|
839
|
+
centralChunks.push(centralHeader, nameBuf);
|
|
840
|
+
offset += localHeader.length + nameBuf.length + data.length;
|
|
841
|
+
}
|
|
842
|
+
const centralDirStart = offset;
|
|
843
|
+
const centralDirBuf = Buffer.concat(centralChunks);
|
|
844
|
+
const eocd = Buffer.alloc(22);
|
|
845
|
+
eocd.writeUInt32LE(0x06054b50, 0);
|
|
846
|
+
eocd.writeUInt16LE(0, 4);
|
|
847
|
+
eocd.writeUInt16LE(0, 6);
|
|
848
|
+
eocd.writeUInt16LE(files.length, 8);
|
|
849
|
+
eocd.writeUInt16LE(files.length, 10);
|
|
850
|
+
eocd.writeUInt32LE(centralDirBuf.length, 12);
|
|
851
|
+
eocd.writeUInt32LE(centralDirStart, 16);
|
|
852
|
+
eocd.writeUInt16LE(0, 20);
|
|
853
|
+
return Buffer.concat([...localChunks, centralDirBuf, eocd]);
|
|
854
|
+
};
|
|
855
|
+
export const resolveStickerBuffer = async (item, opts) => {
|
|
856
|
+
if (Buffer.isBuffer(item)) {
|
|
857
|
+
return item;
|
|
858
|
+
}
|
|
859
|
+
const media = typeof item === 'string' ? { url: item } : item;
|
|
860
|
+
const { stream } = await getStream(media, opts);
|
|
861
|
+
return toBuffer(stream);
|
|
862
|
+
};
|
|
781
863
|
export const getStatusCodeForMediaRetry = (code) => MEDIA_RETRY_STATUS_MAP[code];
|
|
782
864
|
const MEDIA_RETRY_STATUS_MAP = {
|
|
783
865
|
[proto.MediaRetryNotification.ResultType.SUCCESS]: 200,
|