stfca 1.0.2 → 1.0.3
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/CHANGELOG.md +32 -0
- package/README.md +45 -2
- package/checkUpdate.js +109 -0
- package/index.js +460 -1
- package/package.json +22 -46
- package/src/{api/action/addExternalModule.js → addExternalModule.js} +25 -25
- package/src/addUserToGroup.js +115 -0
- package/src/changeAdminStatus.js +103 -0
- package/src/changeArchivedStatus.js +55 -0
- package/src/{api/action/changeAvatar.js → changeAvatar.js} +136 -137
- package/src/changeAvatarV2.js +86 -0
- package/src/changeAvt.js +85 -0
- package/src/{api/action/changeBio.js → changeBio.js} +76 -75
- package/src/{api/messaging/changeBlockedStatus.js → changeBlockedStatus.js} +49 -48
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +72 -0
- package/src/changeGroupImage.js +135 -0
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +59 -0
- package/src/changeThreadColor.js +65 -0
- package/src/changeThreadEmoji.js +55 -0
- package/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/{api/messaging/createNewGroup.js → createNewGroup.js} +88 -88
- package/src/createPoll.js +71 -0
- package/src/createPost.js +276 -0
- package/src/{api/messaging/deleteMessage.js → deleteMessage.js} +56 -56
- package/src/{api/messaging/deleteThread.js → deleteThread.js} +56 -56
- package/src/editMessage.js +68 -0
- package/src/editMessageOld.js +67 -0
- package/src/follow.js +74 -0
- package/src/forwardAttachment.js +60 -0
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/{api/action/getCurrentUserID.js → getCurrentUserID.js} +7 -7
- package/src/{api/messaging/getEmojiUrl.js → getEmojiUrl.js} +2 -2
- package/src/{api/messaging/getFriendsList.js → getFriendsList.js} +83 -82
- package/src/{api/messaging/getMessage.js → getMessage.js} +847 -829
- package/src/getRegion.js +7 -0
- package/src/{api/threads/getThreadHistory.js → getThreadHistory.js} +680 -664
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +232 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +119 -0
- package/src/{api/users/getUserID.js → getUserID.js} +61 -65
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/listenMqtt.js +833 -0
- package/src/logout.js +75 -0
- package/src/markAsDelivered.js +47 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +40 -0
- package/src/markAsSeen.js +48 -0
- package/src/muteThread.js +45 -0
- package/src/refreshFb_dtsg.js +89 -0
- package/src/removeUserFromGroup.js +79 -0
- package/src/{api/messaging/resolvePhotoUrl.js → resolvePhotoUrl.js} +45 -43
- package/src/{api/messaging/searchForThread.js → searchForThread.js} +53 -52
- package/src/searchStickers.js +53 -0
- package/src/sendMessage.js +379 -0
- package/src/{api/messaging/sendMessageMqtt.js → sendMessageMqtt.js} +322 -323
- package/src/sendTypingIndicator.js +101 -0
- package/src/sendTypingIndicatorV2.js +28 -0
- package/src/setMessageReaction.js +122 -0
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/{api/action/setPostReaction.js → setPostReaction.js} +112 -106
- package/src/setStoryReaction.js +64 -0
- package/src/setTitle.js +90 -0
- package/src/shareContact.js +110 -0
- package/src/shareLink.js +59 -0
- package/src/stopListenMqtt.js +23 -0
- package/src/{api/messaging/threadColors.js → threadColors.js} +131 -128
- package/src/{api/action/unfriend.js → unfriend.js} +52 -54
- package/src/unsendMessage.js +45 -0
- package/src/{api/messaging/uploadAttachment.js → uploadAttachment.js} +93 -95
- package/utils.js +2876 -0
- package/LICENSE-MIT +0 -4
- package/index.d.ts +0 -615
- package/module/config.js +0 -33
- package/module/login.js +0 -48
- package/module/loginHelper.js +0 -722
- package/module/options.js +0 -44
- package/src/api/action/handleFriendRequest.js +0 -57
- package/src/api/action/logout.js +0 -76
- package/src/api/action/refreshFb_dtsg.js +0 -71
- package/src/api/http/httpGet.js +0 -46
- package/src/api/http/httpPost.js +0 -52
- package/src/api/http/postFormData.js +0 -47
- package/src/api/messaging/addUserToGroup.js +0 -68
- package/src/api/messaging/changeAdminStatus.js +0 -122
- package/src/api/messaging/changeArchivedStatus.js +0 -55
- package/src/api/messaging/changeGroupImage.js +0 -90
- package/src/api/messaging/changeNickname.js +0 -70
- package/src/api/messaging/changeThreadColor.js +0 -79
- package/src/api/messaging/changeThreadEmoji.js +0 -106
- package/src/api/messaging/createPoll.js +0 -43
- package/src/api/messaging/editMessage.js +0 -68
- package/src/api/messaging/forwardAttachment.js +0 -51
- package/src/api/messaging/handleMessageRequest.js +0 -65
- package/src/api/messaging/markAsDelivered.js +0 -57
- package/src/api/messaging/markAsRead.js +0 -88
- package/src/api/messaging/markAsReadAll.js +0 -49
- package/src/api/messaging/markAsSeen.js +0 -61
- package/src/api/messaging/muteThread.js +0 -50
- package/src/api/messaging/removeUserFromGroup.js +0 -105
- package/src/api/messaging/sendMessage.js +0 -379
- package/src/api/messaging/sendTypingIndicator.js +0 -67
- package/src/api/messaging/setMessageReaction.js +0 -75
- package/src/api/messaging/setTitle.js +0 -119
- package/src/api/messaging/shareContact.js +0 -49
- package/src/api/messaging/unsendMessage.js +0 -81
- package/src/api/socket/core/connectMqtt.js +0 -179
- package/src/api/socket/core/getSeqID.js +0 -25
- package/src/api/socket/core/getTaskResponseData.js +0 -22
- package/src/api/socket/core/markDelivery.js +0 -12
- package/src/api/socket/core/parseDelta.js +0 -351
- package/src/api/socket/detail/buildStream.js +0 -208
- package/src/api/socket/detail/constants.js +0 -24
- package/src/api/socket/listenMqtt.js +0 -133
- package/src/api/threads/getThreadInfo.js +0 -358
- package/src/api/threads/getThreadList.js +0 -248
- package/src/api/threads/getThreadPictures.js +0 -78
- package/src/api/users/getUserInfo.js +0 -319
- package/src/api/users/getUserInfoV2.js +0 -133
- package/src/core/sendReqMqtt.js +0 -63
- package/src/database/models/index.js +0 -49
- package/src/database/models/thread.js +0 -31
- package/src/database/models/user.js +0 -32
- package/src/database/threadData.js +0 -98
- package/src/database/userData.js +0 -89
- package/src/utils/client.js +0 -214
- package/src/utils/constants.js +0 -23
- package/src/utils/format.js +0 -1111
- package/src/utils/headers.js +0 -41
- package/src/utils/request.js +0 -215
package/src/utils/headers.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function getHeaders(url, options, ctx, customHeader) {
|
|
4
|
-
const u = new URL(url);
|
|
5
|
-
const ua = options?.userAgent || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36";
|
|
6
|
-
const referer = options?.referer || "https://www.facebook.com/";
|
|
7
|
-
const origin = referer.replace(/\/+$/, "");
|
|
8
|
-
const contentType = options?.contentType || "application/x-www-form-urlencoded";
|
|
9
|
-
const acceptLang = options?.acceptLanguage || "en-US,en;q=0.9,vi;q=0.8";
|
|
10
|
-
const headers = {
|
|
11
|
-
Host: u.host,
|
|
12
|
-
Origin: origin,
|
|
13
|
-
Referer: referer,
|
|
14
|
-
"User-Agent": ua,
|
|
15
|
-
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,application/json;q=0.8,*/*;q=0.7",
|
|
16
|
-
"Accept-Language": acceptLang,
|
|
17
|
-
"Accept-Encoding": "gzip, deflate, br",
|
|
18
|
-
"Content-Type": contentType,
|
|
19
|
-
Connection: "keep-alive",
|
|
20
|
-
DNT: "1",
|
|
21
|
-
"Upgrade-Insecure-Requests": "1",
|
|
22
|
-
"sec-ch-ua": "\"Chromium\";v=\"139\", \"Not;A=Brand\";v=\"24\", \"Google Chrome\";v=\"139\"",
|
|
23
|
-
"sec-ch-ua-mobile": "?0",
|
|
24
|
-
"sec-ch-ua-platform": "\"Windows\"",
|
|
25
|
-
"sec-ch-ua-arch": "\"x86\"",
|
|
26
|
-
"sec-ch-ua-bitness": "\"64\"",
|
|
27
|
-
"sec-ch-ua-full-version-list": "\"Chromium\";v=\"139.0.0.0\", \"Not;A=Brand\";v=\"24.0.0.0\", \"Google Chrome\";v=\"139.0.0.0\"",
|
|
28
|
-
"sec-ch-ua-platform-version": "\"15.0.0\"",
|
|
29
|
-
"Sec-Fetch-Site": "same-origin",
|
|
30
|
-
"Sec-Fetch-Mode": "cors",
|
|
31
|
-
"Sec-Fetch-Dest": "empty",
|
|
32
|
-
"X-Requested-With": "XMLHttpRequest",
|
|
33
|
-
Pragma: "no-cache",
|
|
34
|
-
"Cache-Control": "no-cache"
|
|
35
|
-
};
|
|
36
|
-
if (ctx?.region) headers["X-MSGR-Region"] = ctx.region;
|
|
37
|
-
if (customHeader && typeof customHeader === "object") Object.assign(headers, customHeader);
|
|
38
|
-
return headers;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = { getHeaders };
|
package/src/utils/request.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
const axios = require("axios");
|
|
2
|
-
const { CookieJar } = require("tough-cookie");
|
|
3
|
-
const { wrapper } = require("axios-cookiejar-support");
|
|
4
|
-
const FormData = require("form-data");
|
|
5
|
-
const { HttpsProxyAgent } = require("https-proxy-agent");
|
|
6
|
-
const { Readable } = require("stream");
|
|
7
|
-
|
|
8
|
-
const headersMod = require("./headers");
|
|
9
|
-
const getHeaders = headersMod.getHeaders || headersMod;
|
|
10
|
-
const formatMod = require("./format");
|
|
11
|
-
const getType = formatMod.getType || formatMod;
|
|
12
|
-
const constMod = require("./constants");
|
|
13
|
-
const getFrom = constMod.getFrom || constMod;
|
|
14
|
-
|
|
15
|
-
const jar = new CookieJar();
|
|
16
|
-
const client = wrapper(axios.create({
|
|
17
|
-
jar,
|
|
18
|
-
withCredentials: true,
|
|
19
|
-
timeout: 60000,
|
|
20
|
-
validateStatus: s => s >= 200 && s < 600
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
const delay = ms => new Promise(r => setTimeout(r, ms));
|
|
24
|
-
|
|
25
|
-
async function requestWithRetry(fn, retries = 3) {
|
|
26
|
-
let err;
|
|
27
|
-
for (let i = 0; i < retries; i++) {
|
|
28
|
-
try { return await fn(); } catch (e) {
|
|
29
|
-
err = e;
|
|
30
|
-
if (i === retries - 1) return e.response ? e.response : Promise.reject(e);
|
|
31
|
-
await delay((1 << i) * 1000 + Math.floor(Math.random() * 200));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
throw err;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function cfg(base = {}) {
|
|
38
|
-
const { reqJar, headers, params, agent, timeout } = base;
|
|
39
|
-
return {
|
|
40
|
-
headers,
|
|
41
|
-
params,
|
|
42
|
-
jar: reqJar || jar,
|
|
43
|
-
withCredentials: true,
|
|
44
|
-
timeout: timeout || 60000,
|
|
45
|
-
httpAgent: agent || client.defaults.httpAgent,
|
|
46
|
-
httpsAgent: agent || client.defaults.httpsAgent,
|
|
47
|
-
proxy: false,
|
|
48
|
-
validateStatus: s => s >= 200 && s < 600
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function toStringVal(v) {
|
|
53
|
-
if (v === undefined || v === null) return "";
|
|
54
|
-
if (typeof v === "bigint") return v.toString();
|
|
55
|
-
if (typeof v === "boolean") return v ? "true" : "false";
|
|
56
|
-
return String(v);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function isStream(v) {
|
|
60
|
-
return v && typeof v === "object" && typeof v.pipe === "function" && typeof v.on === "function";
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function isBlobLike(v) {
|
|
64
|
-
return v && typeof v.arrayBuffer === "function" && (typeof v.type === "string" || typeof v.name === "string");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function isPairArrayList(arr) {
|
|
68
|
-
return Array.isArray(arr) && arr.length > 0 && arr.every(x => Array.isArray(x) && x.length === 2 && typeof x[0] === "string");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function cleanGet(url) {
|
|
72
|
-
return requestWithRetry(() => client.get(url, cfg()));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function get(url, reqJar, qs, options, ctx, customHeader) {
|
|
76
|
-
const headers = getHeaders(url, options, ctx, customHeader);
|
|
77
|
-
return requestWithRetry(() => client.get(url, cfg({ reqJar, headers, params: qs })));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function post(url, reqJar, form, options, ctx, customHeader) {
|
|
81
|
-
const headers = getHeaders(url, options, ctx, customHeader);
|
|
82
|
-
const ct = String(headers["Content-Type"] || headers["content-type"] || "application/x-www-form-urlencoded").toLowerCase();
|
|
83
|
-
let data;
|
|
84
|
-
if (ct.includes("json")) {
|
|
85
|
-
data = JSON.stringify(form || {});
|
|
86
|
-
headers["Content-Type"] = "application/json";
|
|
87
|
-
} else {
|
|
88
|
-
const p = new URLSearchParams();
|
|
89
|
-
if (form && typeof form === "object") {
|
|
90
|
-
for (const k of Object.keys(form)) {
|
|
91
|
-
let v = form[k];
|
|
92
|
-
if (isPairArrayList(v)) {
|
|
93
|
-
for (const [kk, vv] of v) p.append(`${k}[${kk}]`, toStringVal(vv));
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (Array.isArray(v)) {
|
|
97
|
-
for (const x of v) {
|
|
98
|
-
if (Array.isArray(x) && x.length === 2 && typeof x[1] !== "object") p.append(k, toStringVal(x[1]));
|
|
99
|
-
else p.append(k, toStringVal(x));
|
|
100
|
-
}
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (getType(v) === "Object") v = JSON.stringify(v);
|
|
104
|
-
p.append(k, toStringVal(v));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
data = p.toString();
|
|
108
|
-
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
109
|
-
}
|
|
110
|
-
return requestWithRetry(() => client.post(url, data, cfg({ reqJar, headers })));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async function postFormData(url, reqJar, form, qs, options, ctx) {
|
|
114
|
-
const fd = new FormData();
|
|
115
|
-
if (form && typeof form === "object") {
|
|
116
|
-
for (const k of Object.keys(form)) {
|
|
117
|
-
const v = form[k];
|
|
118
|
-
if (v === undefined || v === null) continue;
|
|
119
|
-
if (isPairArrayList(v)) {
|
|
120
|
-
for (const [kk, vv] of v) fd.append(`${k}[${kk}]`, typeof vv === "object" && !Buffer.isBuffer(vv) && !isStream(vv) ? JSON.stringify(vv) : vv);
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (Array.isArray(v)) {
|
|
124
|
-
for (const x of v) {
|
|
125
|
-
if (Array.isArray(x) && x.length === 2 && x[1] && typeof x[1] === "object" && !Buffer.isBuffer(x[1]) && !isStream(x[1])) {
|
|
126
|
-
fd.append(k, x[0], x[1]);
|
|
127
|
-
} else if (Array.isArray(x) && x.length === 2 && typeof x[1] !== "object") {
|
|
128
|
-
fd.append(k, toStringVal(x[1]));
|
|
129
|
-
} else if (x && typeof x === "object" && "value" in x && "options" in x) {
|
|
130
|
-
fd.append(k, x.value, x.options || {});
|
|
131
|
-
} else if (isStream(x) || Buffer.isBuffer(x) || typeof x === "string") {
|
|
132
|
-
fd.append(k, x);
|
|
133
|
-
} else if (isBlobLike(x)) {
|
|
134
|
-
const buf = Buffer.from(await x.arrayBuffer());
|
|
135
|
-
fd.append(k, buf, { filename: x.name || k, contentType: x.type || undefined });
|
|
136
|
-
} else {
|
|
137
|
-
fd.append(k, JSON.stringify(x));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if (v && typeof v === "object" && "value" in v && "options" in v) {
|
|
143
|
-
fd.append(k, v.value, v.options || {});
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (isStream(v) || Buffer.isBuffer(v) || typeof v === "string") {
|
|
147
|
-
fd.append(k, v);
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (isBlobLike(v)) {
|
|
151
|
-
const buf = Buffer.from(await v.arrayBuffer());
|
|
152
|
-
fd.append(k, buf, { filename: v.name || k, contentType: v.type || undefined });
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
if (typeof v === "number" || typeof v === "boolean") {
|
|
156
|
-
fd.append(k, toStringVal(v));
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
fd.append(k, JSON.stringify(v));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const headers = { ...getHeaders(url, options, ctx), ...fd.getHeaders() };
|
|
163
|
-
return requestWithRetry(() => client.post(url, fd, cfg({ reqJar, headers, params: qs })));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function makeDefaults(html, userID, ctx) {
|
|
167
|
-
let reqCounter = 1;
|
|
168
|
-
const revision = getFrom(html || "", 'revision":', ",") || getFrom(html || "", '"client_revision":', ",") || "";
|
|
169
|
-
function mergeWithDefaults(obj) {
|
|
170
|
-
const base = {
|
|
171
|
-
av: userID,
|
|
172
|
-
__user: userID,
|
|
173
|
-
__req: (reqCounter++).toString(36),
|
|
174
|
-
__rev: revision,
|
|
175
|
-
__a: 1
|
|
176
|
-
};
|
|
177
|
-
if (ctx?.fb_dtsg) base.fb_dtsg = ctx.fb_dtsg;
|
|
178
|
-
if (ctx?.jazoest) base.jazoest = ctx.jazoest;
|
|
179
|
-
if (!obj) return base;
|
|
180
|
-
for (const k of Object.keys(obj)) if (!(k in base)) base[k] = obj[k];
|
|
181
|
-
return base;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
get: (url, j, qs, ctxx, customHeader = {}) =>
|
|
185
|
-
get(url, j, mergeWithDefaults(qs), ctx?.globalOptions, ctxx || ctx, customHeader),
|
|
186
|
-
post: (url, j, form, ctxx, customHeader = {}) =>
|
|
187
|
-
post(url, j, mergeWithDefaults(form), ctx?.globalOptions, ctxx || ctx, customHeader),
|
|
188
|
-
postFormData: (url, j, form, qs, ctxx) =>
|
|
189
|
-
postFormData(url, j, mergeWithDefaults(form), mergeWithDefaults(qs), ctx?.globalOptions, ctxx || ctx)
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function setProxy(proxyUrl) {
|
|
194
|
-
if (!proxyUrl) {
|
|
195
|
-
client.defaults.httpAgent = undefined;
|
|
196
|
-
client.defaults.httpsAgent = undefined;
|
|
197
|
-
client.defaults.proxy = false;
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
const agent = new HttpsProxyAgent(proxyUrl);
|
|
201
|
-
client.defaults.httpAgent = agent;
|
|
202
|
-
client.defaults.httpsAgent = agent;
|
|
203
|
-
client.defaults.proxy = false;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
module.exports = {
|
|
207
|
-
cleanGet,
|
|
208
|
-
get,
|
|
209
|
-
post,
|
|
210
|
-
postFormData,
|
|
211
|
-
jar,
|
|
212
|
-
setProxy,
|
|
213
|
-
makeDefaults,
|
|
214
|
-
client
|
|
215
|
-
};
|