@lazyneoaz/metachat 1.1.1 → 1.1.2
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/index.js +4 -0
- package/package.json +1 -1
- package/src/apis/listenMqtt.js +3 -10
- package/src/apis/sendMessage.js +0 -3
- package/src/apis/sendMessageMqtt.js +0 -3
- package/src/types/index.d.ts +2 -0
- package/src/utils/headers.js +3 -11
package/index.js
CHANGED
|
@@ -54,3 +54,7 @@ module.exports.createRequestHelper = createRequestHelper;
|
|
|
54
54
|
module.exports.normalizeCookieHeaderString = normalizeCookieHeaderString;
|
|
55
55
|
module.exports.setJarFromPairs = setJarFromPairs;
|
|
56
56
|
module.exports.createAuthCore = createAuthCore;
|
|
57
|
+
|
|
58
|
+
module.exports.getVersion = function getVersion() {
|
|
59
|
+
return require('./package.json').version;
|
|
60
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazyneoaz/metachat",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"types": "src/types/index.d.ts",
|
|
6
6
|
"description": "Advanced Facebook Chat API client for building Messenger bots — real-time messaging, thread management, MQTT, and session stability.",
|
package/src/apis/listenMqtt.js
CHANGED
|
@@ -140,14 +140,10 @@ async function listenMqtt(defaultFuncs, api, ctx, globalCallback, scheduleReconn
|
|
|
140
140
|
|
|
141
141
|
utils.log("Connecting to MQTT...", host);
|
|
142
142
|
|
|
143
|
-
const cachedSecChUa = ctx.globalOptions.cachedSecChUa || '"Google Chrome";v="136", "Not;A=Brand";v="99", "Chromium";v="136"';
|
|
144
|
-
const cachedSecChUaPlatform = ctx.globalOptions.cachedSecChUaPlatform || '"Windows"';
|
|
145
143
|
const cachedLocale = ctx.globalOptions.cachedLocale || 'en-US,en;q=0.9';
|
|
146
144
|
|
|
147
|
-
// Generate a unique client ID per session like a real browser would
|
|
148
|
-
const mqttClientId = 'mqttwsclient_' + Math.random().toString(36).slice(2, 10) + Date.now().toString(36);
|
|
149
145
|
const options = {
|
|
150
|
-
clientId:
|
|
146
|
+
clientId: 'mqttwsclient',
|
|
151
147
|
protocolId: 'MQIsdp',
|
|
152
148
|
protocolVersion: 3,
|
|
153
149
|
username: JSON.stringify(username),
|
|
@@ -166,18 +162,15 @@ async function listenMqtt(defaultFuncs, api, ctx, globalCallback, scheduleReconn
|
|
|
166
162
|
'Sec-WebSocket-Version': '13',
|
|
167
163
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
168
164
|
'Accept-Language': cachedLocale,
|
|
169
|
-
'Sec-Ch-Ua': cachedSecChUa,
|
|
170
|
-
'Sec-Ch-Ua-Mobile': '?0',
|
|
171
|
-
'Sec-Ch-Ua-Platform': cachedSecChUaPlatform,
|
|
172
165
|
'Sec-WebSocket-Extensions': 'permessage-deflate; client_max_window_bits'
|
|
173
166
|
},
|
|
174
167
|
origin: 'https://www.facebook.com',
|
|
175
168
|
protocolVersion: 13,
|
|
176
169
|
binaryType: 'arraybuffer'
|
|
177
170
|
},
|
|
178
|
-
keepalive:
|
|
171
|
+
keepalive: 30,
|
|
179
172
|
reschedulePings: true,
|
|
180
|
-
connectTimeout:
|
|
173
|
+
connectTimeout: 12000,
|
|
181
174
|
reconnectPeriod: 0
|
|
182
175
|
};
|
|
183
176
|
|
package/src/apis/sendMessage.js
CHANGED
|
@@ -62,9 +62,6 @@ module.exports = (defaultFuncs, api, ctx) => {
|
|
|
62
62
|
const batch = attachments.slice(i, i + CONCURRENT_UPLOADS);
|
|
63
63
|
const results = await Promise.all(batch.map(a => uploadSingleAttachment(a, threadIDHint)));
|
|
64
64
|
uploads.push(...results);
|
|
65
|
-
if (i + CONCURRENT_UPLOADS < attachments.length) {
|
|
66
|
-
await globalAntiSuspension.addSmartDelay();
|
|
67
|
-
}
|
|
68
65
|
}
|
|
69
66
|
return uploads;
|
|
70
67
|
}
|
|
@@ -22,9 +22,6 @@ module.exports = (defaultFuncs, api, ctx) => {
|
|
|
22
22
|
if (!utils.isReadableStream(attachments[i])) {
|
|
23
23
|
throw new Error("Attachment should be a readable stream and not " + utils.getType(attachments[i]) + ".");
|
|
24
24
|
}
|
|
25
|
-
if (i > 0) {
|
|
26
|
-
await globalAntiSuspension.addSmartDelay();
|
|
27
|
-
}
|
|
28
25
|
const form = {
|
|
29
26
|
upload_1024: attachments[i],
|
|
30
27
|
...detectAttachmentType(attachments[i]),
|
package/src/types/index.d.ts
CHANGED
package/src/utils/headers.js
CHANGED
|
@@ -113,7 +113,6 @@ function getHeaders(url, options, ctx, customHeader, requestType = 'navigate') {
|
|
|
113
113
|
const isXhr = requestType === 'xhr';
|
|
114
114
|
|
|
115
115
|
const locales = options?.cachedLocale || (androidData?.locale ? androidData.locale.replace('_', '-') : getRandomLocale());
|
|
116
|
-
const timezone = options?.cachedTimezone || getRandomTimezone();
|
|
117
116
|
|
|
118
117
|
if (isAndroid) {
|
|
119
118
|
const headers = {
|
|
@@ -161,29 +160,26 @@ function getHeaders(url, options, ctx, customHeader, requestType = 'navigate') {
|
|
|
161
160
|
const isLinux = secChUaPlatform === '"Linux"';
|
|
162
161
|
|
|
163
162
|
const headers = {
|
|
164
|
-
'Accept':
|
|
163
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,application/json;q=0.8,*/*;q=0.7',
|
|
165
164
|
'Accept-Language': locales,
|
|
166
165
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
167
166
|
'Cache-Control': 'no-cache',
|
|
168
167
|
'Connection': 'keep-alive',
|
|
169
168
|
'DNT': '1',
|
|
170
|
-
'Dpr': '1',
|
|
171
169
|
'Host': host,
|
|
172
170
|
'Pragma': 'no-cache',
|
|
173
171
|
'Referer': referer,
|
|
174
|
-
'Sec-Ch-Prefers-Color-Scheme': 'light',
|
|
175
172
|
'Sec-Ch-Ua': secChUa,
|
|
176
173
|
'Sec-Ch-Ua-Full-Version-List': secChUaFullVersionList,
|
|
177
174
|
'Sec-Ch-Ua-Mobile': '?0',
|
|
178
|
-
'Sec-Ch-Ua-Model': '""',
|
|
179
175
|
'Sec-Ch-Ua-Platform': secChUaPlatform,
|
|
180
176
|
'Sec-Ch-Ua-Platform-Version': secChUaPlatformVersion,
|
|
181
177
|
'Sec-Fetch-Dest': isXhr ? 'empty' : 'document',
|
|
182
178
|
'Sec-Fetch-Mode': isXhr ? 'cors' : 'navigate',
|
|
183
179
|
'Sec-Fetch-Site': isXhr ? 'same-origin' : 'none',
|
|
184
180
|
'User-Agent': userAgent,
|
|
185
|
-
'
|
|
186
|
-
'X-
|
|
181
|
+
'Upgrade-Insecure-Requests': '1',
|
|
182
|
+
'X-Requested-With': 'XMLHttpRequest'
|
|
187
183
|
};
|
|
188
184
|
|
|
189
185
|
if (isWindows || isMac || isLinux) {
|
|
@@ -193,10 +189,6 @@ function getHeaders(url, options, ctx, customHeader, requestType = 'navigate') {
|
|
|
193
189
|
|
|
194
190
|
if (isXhr) {
|
|
195
191
|
headers['Origin'] = `https://${host}`;
|
|
196
|
-
headers['X-Requested-With'] = 'XMLHttpRequest';
|
|
197
|
-
} else {
|
|
198
|
-
headers['Sec-Fetch-User'] = '?1';
|
|
199
|
-
headers['Upgrade-Insecure-Requests'] = '1';
|
|
200
192
|
}
|
|
201
193
|
|
|
202
194
|
if (ctx) {
|