fca-neokex-fix 1.0.1
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 +220 -0
- package/LICENSE +26 -0
- package/README.md +346 -0
- package/THEME_FEATURES.md +137 -0
- package/examples/README.md +131 -0
- package/examples/apply-ai-theme.js +127 -0
- package/examples/check-current-theme.js +74 -0
- package/examples/simple-bot.js +114 -0
- package/examples/test-bot.js +752 -0
- package/examples/test-logging.js +85 -0
- package/examples/theme-usage-example.js +53 -0
- package/index.js +2 -0
- package/package.json +105 -0
- package/src/apis/addExternalModule.js +24 -0
- package/src/apis/addUserToGroup.js +108 -0
- package/src/apis/changeAdminStatus.js +148 -0
- package/src/apis/changeArchivedStatus.js +61 -0
- package/src/apis/changeAvatar.js +103 -0
- package/src/apis/changeBio.js +69 -0
- package/src/apis/changeBlockedStatus.js +54 -0
- package/src/apis/changeGroupImage.js +136 -0
- package/src/apis/changeThreadColor.js +116 -0
- package/src/apis/comment.js +207 -0
- package/src/apis/createAITheme.js +129 -0
- package/src/apis/createNewGroup.js +79 -0
- package/src/apis/createPoll.js +73 -0
- package/src/apis/deleteMessage.js +44 -0
- package/src/apis/deleteThread.js +52 -0
- package/src/apis/editMessage.js +70 -0
- package/src/apis/emoji.js +124 -0
- package/src/apis/fetchThemeData.js +65 -0
- package/src/apis/follow.js +81 -0
- package/src/apis/forwardMessage.js +52 -0
- package/src/apis/friend.js +243 -0
- package/src/apis/gcmember.js +122 -0
- package/src/apis/gcname.js +123 -0
- package/src/apis/gcrule.js +119 -0
- package/src/apis/getAccess.js +111 -0
- package/src/apis/getBotInfo.js +88 -0
- package/src/apis/getBotInitialData.js +43 -0
- package/src/apis/getFriendsList.js +79 -0
- package/src/apis/getMessage.js +423 -0
- package/src/apis/getTheme.js +104 -0
- package/src/apis/getThemeInfo.js +96 -0
- package/src/apis/getThreadHistory.js +239 -0
- package/src/apis/getThreadInfo.js +257 -0
- package/src/apis/getThreadList.js +222 -0
- package/src/apis/getThreadPictures.js +58 -0
- package/src/apis/getUserID.js +83 -0
- package/src/apis/getUserInfo.js +495 -0
- package/src/apis/getUserInfoV2.js +146 -0
- package/src/apis/handleMessageRequest.js +50 -0
- package/src/apis/httpGet.js +63 -0
- package/src/apis/httpPost.js +89 -0
- package/src/apis/httpPostFormData.js +69 -0
- package/src/apis/listenMqtt.js +796 -0
- package/src/apis/listenSpeed.js +170 -0
- package/src/apis/logout.js +63 -0
- package/src/apis/markAsDelivered.js +47 -0
- package/src/apis/markAsRead.js +95 -0
- package/src/apis/markAsReadAll.js +41 -0
- package/src/apis/markAsSeen.js +70 -0
- package/src/apis/mqttDeltaValue.js +330 -0
- package/src/apis/muteThread.js +45 -0
- package/src/apis/nickname.js +132 -0
- package/src/apis/notes.js +163 -0
- package/src/apis/pinMessage.js +141 -0
- package/src/apis/produceMetaTheme.js +180 -0
- package/src/apis/realtime.js +161 -0
- package/src/apis/removeUserFromGroup.js +117 -0
- package/src/apis/resolvePhotoUrl.js +58 -0
- package/src/apis/searchForThread.js +154 -0
- package/src/apis/sendMessage.js +281 -0
- package/src/apis/sendMessageMqtt.js +188 -0
- package/src/apis/sendTypingIndicator.js +41 -0
- package/src/apis/setMessageReaction.js +27 -0
- package/src/apis/setMessageReactionMqtt.js +61 -0
- package/src/apis/setThreadTheme.js +260 -0
- package/src/apis/setThreadThemeMqtt.js +94 -0
- package/src/apis/share.js +107 -0
- package/src/apis/shareContact.js +66 -0
- package/src/apis/stickers.js +257 -0
- package/src/apis/story.js +181 -0
- package/src/apis/theme.js +233 -0
- package/src/apis/unfriend.js +47 -0
- package/src/apis/unsendMessage.js +17 -0
- package/src/database/appStateBackup.js +189 -0
- package/src/database/models/index.js +56 -0
- package/src/database/models/thread.js +31 -0
- package/src/database/models/user.js +32 -0
- package/src/database/threadData.js +101 -0
- package/src/database/userData.js +90 -0
- package/src/engine/client.js +91 -0
- package/src/engine/models/buildAPI.js +109 -0
- package/src/engine/models/loginHelper.js +326 -0
- package/src/engine/models/setOptions.js +53 -0
- package/src/utils/auth-helpers.js +149 -0
- package/src/utils/autoReLogin.js +169 -0
- package/src/utils/axios.js +290 -0
- package/src/utils/clients.js +270 -0
- package/src/utils/constants.js +396 -0
- package/src/utils/formatters/data/formatAttachment.js +370 -0
- package/src/utils/formatters/data/formatDelta.js +153 -0
- package/src/utils/formatters/index.js +159 -0
- package/src/utils/formatters/value/formatCookie.js +91 -0
- package/src/utils/formatters/value/formatDate.js +36 -0
- package/src/utils/formatters/value/formatID.js +16 -0
- package/src/utils/formatters.js +1067 -0
- package/src/utils/headers.js +199 -0
- package/src/utils/index.js +151 -0
- package/src/utils/monitoring.js +358 -0
- package/src/utils/rateLimiter.js +380 -0
- package/src/utils/tokenRefresh.js +311 -0
- package/src/utils/user-agents.js +238 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
+
return function getAccess(authCode = '', callback) {
|
|
7
|
+
var cb;
|
|
8
|
+
var url = 'https://business.facebook.com/';
|
|
9
|
+
var Referer = url + 'security/twofactor/reauth/?twofac_next=' + encodeURIComponent(url + 'content_management') + '&type=avoid_bypass&app_id=0&save_device=0';
|
|
10
|
+
var rt = new Promise(function (resolve, reject) {
|
|
11
|
+
cb = (error, token) => token ? resolve(token) : reject(error);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (typeof authCode == 'function') {
|
|
15
|
+
callback = authCode;
|
|
16
|
+
authCode = '';
|
|
17
|
+
}
|
|
18
|
+
if (typeof callback == 'function') cb = callback;
|
|
19
|
+
if (!!ctx.access_token)
|
|
20
|
+
cb(null, ctx.access_token);
|
|
21
|
+
else
|
|
22
|
+
utils
|
|
23
|
+
.get(url + 'content_management', ctx.jar, null, ctx.globalOptions, null, {
|
|
24
|
+
noRef: true,
|
|
25
|
+
Origin: url
|
|
26
|
+
})
|
|
27
|
+
.then(function (res) {
|
|
28
|
+
var html = res.body;
|
|
29
|
+
var lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
|
30
|
+
return lsd;
|
|
31
|
+
})
|
|
32
|
+
.then(function (lsd) {
|
|
33
|
+
function submitCode(code) {
|
|
34
|
+
var pCb;
|
|
35
|
+
var rtPromise = new Promise(function (resolve) {
|
|
36
|
+
pCb = (error, token) => resolve(cb(error, token));
|
|
37
|
+
});
|
|
38
|
+
if (typeof code != 'string')
|
|
39
|
+
pCb({
|
|
40
|
+
error: 'submitCode',
|
|
41
|
+
lerror: 'code must be string',
|
|
42
|
+
continue: submitCode
|
|
43
|
+
});
|
|
44
|
+
else
|
|
45
|
+
defaultFuncs
|
|
46
|
+
.post(url + 'security/twofactor/reauth/enter/', ctx.jar, {
|
|
47
|
+
approvals_code: code,
|
|
48
|
+
save_device: true,
|
|
49
|
+
lsd
|
|
50
|
+
}, ctx.globalOptions, null, {
|
|
51
|
+
Referer,
|
|
52
|
+
Origin: url
|
|
53
|
+
})
|
|
54
|
+
.then(function (res) {
|
|
55
|
+
var { payload } = JSON.parse(res.body.split(';').pop() || '{}');
|
|
56
|
+
if (payload && !payload.codeConfirmed)
|
|
57
|
+
throw {
|
|
58
|
+
error: 'submitCode',
|
|
59
|
+
lerror: payload.message,
|
|
60
|
+
continue: submitCode
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return;
|
|
64
|
+
})
|
|
65
|
+
.then(function () {
|
|
66
|
+
return utils
|
|
67
|
+
.get(url + 'content_management', ctx.jar, null, ctx.globalOptions, null, { noRef: true })
|
|
68
|
+
.then(function (res) {
|
|
69
|
+
var html = res.body;
|
|
70
|
+
var token = /"accessToken":"(\S+)","clientID":/g.exec(html);
|
|
71
|
+
|
|
72
|
+
return [html, token];
|
|
73
|
+
});
|
|
74
|
+
})
|
|
75
|
+
.then(function (res) {
|
|
76
|
+
if (!res[1])
|
|
77
|
+
throw {
|
|
78
|
+
error: 'token-undefined',
|
|
79
|
+
htmlData: res[0]
|
|
80
|
+
}
|
|
81
|
+
ctx.access_token = res[1][1];
|
|
82
|
+
return pCb(null, res[1][1]);
|
|
83
|
+
})
|
|
84
|
+
.catch(function (err) {
|
|
85
|
+
utils.error('getAccess', err.error || err);
|
|
86
|
+
return pCb(err);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return rtPromise;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (authCode.length == 6 && !isNaN(authCode))
|
|
93
|
+
submitCode(authCode.toString());
|
|
94
|
+
else if (typeof callback == 'function')
|
|
95
|
+
throw {
|
|
96
|
+
error: 'submitCode',
|
|
97
|
+
continue: submitCode
|
|
98
|
+
}
|
|
99
|
+
else
|
|
100
|
+
throw {
|
|
101
|
+
error: 'authentication code must be string or number or callback must be a function to continue'
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.catch(function (err) {
|
|
105
|
+
utils.error('getAccess', typeof callback == 'function' ? (err.error || err) : err);
|
|
106
|
+
return cb(err);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return rt;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const utils = require('../utils');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {Object} defaultFuncs
|
|
8
|
+
* @param {Object} api
|
|
9
|
+
* @param {Object} ctx
|
|
10
|
+
* @returns {function(netData: Array<Object>): Object | null}
|
|
11
|
+
*/
|
|
12
|
+
module.exports = (defaultFuncs, api, ctx) => {
|
|
13
|
+
/**
|
|
14
|
+
* @param {Array<Object>} netData - The array of all extracted JSON objects from the HTML.
|
|
15
|
+
* @returns {Object|null} An object containing the bot's essential info, security tokens, and context accessor functions.
|
|
16
|
+
*/
|
|
17
|
+
return function getBotInfo(netData) {
|
|
18
|
+
if (!netData || !Array.isArray(netData)) {
|
|
19
|
+
utils.error("getBotInfo", "netData is not a valid array.");
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} key The configuration key to find (e.g., "MqttWebDeviceID").
|
|
25
|
+
* @returns {Object|null} The configuration object or null if not found.
|
|
26
|
+
*/
|
|
27
|
+
const findConfig = (key) => {
|
|
28
|
+
for (const scriptData of netData) {
|
|
29
|
+
if (scriptData.require) {
|
|
30
|
+
for (const req of scriptData.require) {
|
|
31
|
+
if (Array.isArray(req) && req[0] === key && req[2]) {
|
|
32
|
+
return req[2];
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(req) && req[3] && req[3][0]?.__bbox?.define) {
|
|
35
|
+
for (const def of req[3][0].__bbox.define) {
|
|
36
|
+
if (Array.isArray(def) && def[0].endsWith(key) && def[2]) {
|
|
37
|
+
return def[2];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const currentUserData = findConfig("CurrentUserInitialData");
|
|
48
|
+
const dtsgInitialData = findConfig("DTSGInitialData");
|
|
49
|
+
const dtsgInitData = findConfig("DTSGInitData");
|
|
50
|
+
const lsdData = findConfig("LSD");
|
|
51
|
+
|
|
52
|
+
if (!currentUserData || !dtsgInitialData) {
|
|
53
|
+
utils.error("getBotInfo", "Could not find critical data (CurrentUserInitialData or DTSGInitialData).");
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const botInfo = {
|
|
58
|
+
name: currentUserData.NAME,
|
|
59
|
+
firstName: currentUserData.SHORT_NAME,
|
|
60
|
+
uid: currentUserData.USER_ID,
|
|
61
|
+
appID: currentUserData.APP_ID,
|
|
62
|
+
dtsgToken: dtsgInitialData.token,
|
|
63
|
+
lsdToken: lsdData ? lsdData.token : undefined,
|
|
64
|
+
dtsgInit: dtsgInitData ? {
|
|
65
|
+
token: dtsgInitData.token,
|
|
66
|
+
async_get_token: dtsgInitData.async_get_token
|
|
67
|
+
} : undefined,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {string} key The key of the value to retrieve.
|
|
71
|
+
* @returns {any} The value from the context.
|
|
72
|
+
*/
|
|
73
|
+
getCtx: (key) => ctx[key],
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {string} key The key of the option to retrieve.
|
|
77
|
+
* @returns {any} The value of the option.
|
|
78
|
+
*/
|
|
79
|
+
getOptions: (key) => ctx.globalOptions[key],
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @returns {string | undefined} The current region.
|
|
83
|
+
*/
|
|
84
|
+
getRegion: () => ctx?.region
|
|
85
|
+
};
|
|
86
|
+
return botInfo;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
|
|
5
|
+
module.exports = (defaultFuncs, api, ctx) => {
|
|
6
|
+
return async (callback) => {
|
|
7
|
+
let resolveFunc = () => {};
|
|
8
|
+
let rejectFunc = () => {};
|
|
9
|
+
const returnPromise = new Promise((resolve, reject) => {
|
|
10
|
+
resolveFunc = resolve;
|
|
11
|
+
rejectFunc = reject;
|
|
12
|
+
});
|
|
13
|
+
if (!callback) {
|
|
14
|
+
callback = (err, data) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
return rejectFunc(err);
|
|
17
|
+
}
|
|
18
|
+
resolveFunc(data);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
utils.log("Fetching account info...");
|
|
22
|
+
api.httpGet(`https://www.facebook.com/profile.php?id=${ctx.userID}`, null, {
|
|
23
|
+
customUserAgent: utils.windowsUserAgent
|
|
24
|
+
}, (err, data) => {
|
|
25
|
+
|
|
26
|
+
if (err) throw err;
|
|
27
|
+
const profileMatch = data.match(/"CurrentUserInitialData",\[\],\{(.*?)\},(.*?)\]/);
|
|
28
|
+
if (profileMatch && profileMatch[1]){
|
|
29
|
+
const accountJson = JSON.parse(`{${profileMatch[1]}}`);
|
|
30
|
+
accountJson.name = accountJson.NAME;
|
|
31
|
+
accountJson.uid = accountJson.USER_ID;
|
|
32
|
+
delete accountJson.NAME;
|
|
33
|
+
delete accountJson.USER_ID;
|
|
34
|
+
return callback(null, {
|
|
35
|
+
...accountJson
|
|
36
|
+
});
|
|
37
|
+
} else return callback(null, { error: "Something went wrong. Maybe its possible that it has a limitation due to spam requests. You can try again later." });
|
|
38
|
+
}, true);
|
|
39
|
+
return returnPromise;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
const GENDERS = {
|
|
6
|
+
0: "unknown",
|
|
7
|
+
1: "female_singular",
|
|
8
|
+
2: "male_singular",
|
|
9
|
+
3: "female_singular_guess",
|
|
10
|
+
4: "male_singular_guess",
|
|
11
|
+
5: "mixed",
|
|
12
|
+
6: "neuter_singular",
|
|
13
|
+
7: "unknown_singular",
|
|
14
|
+
8: "female_plural",
|
|
15
|
+
9: "male_plural",
|
|
16
|
+
10: "neuter_plural",
|
|
17
|
+
11: "unknown_plural"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function formatData(obj) {
|
|
21
|
+
return Object.keys(obj).map(key => {
|
|
22
|
+
const user = obj[key];
|
|
23
|
+
return {
|
|
24
|
+
alternateName: user.alternateName,
|
|
25
|
+
firstName: user.firstName,
|
|
26
|
+
gender: GENDERS[user.gender],
|
|
27
|
+
userID: utils.formatID(user.id.toString()),
|
|
28
|
+
isFriend: user.is_friend != null && user.is_friend ? true : false,
|
|
29
|
+
fullName: user.name,
|
|
30
|
+
profilePicture: user.thumbSrc,
|
|
31
|
+
type: user.type,
|
|
32
|
+
profileUrl: user.uri,
|
|
33
|
+
vanity: user.vanity,
|
|
34
|
+
isBirthday: !!user.is_birthday
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = (defaultFuncs, api, ctx) => {
|
|
40
|
+
return async function getFriendsList(callback) {
|
|
41
|
+
let resolveFunc = () => {};
|
|
42
|
+
let rejectFunc = () => {};
|
|
43
|
+
const returnPromise = new Promise((resolve, reject) => {
|
|
44
|
+
resolveFunc = resolve;
|
|
45
|
+
rejectFunc = reject;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (!callback) {
|
|
49
|
+
callback = (err, result) => {
|
|
50
|
+
if (err) return rejectFunc(err);
|
|
51
|
+
resolveFunc(result);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
const res = await defaultFuncs.postFormData(
|
|
57
|
+
"https://www.facebook.com/chat/user_info_all",
|
|
58
|
+
ctx.jar,
|
|
59
|
+
{},
|
|
60
|
+
{ viewer: ctx.userID }
|
|
61
|
+
).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
|
62
|
+
|
|
63
|
+
if (!res) {
|
|
64
|
+
throw { error: "getFriendsList returned empty object." };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (res.error) {
|
|
68
|
+
throw res;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
callback(null, formatData(res.payload));
|
|
72
|
+
} catch (err) {
|
|
73
|
+
utils.error("getFriendsList", err);
|
|
74
|
+
callback(err);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return returnPromise;
|
|
78
|
+
};
|
|
79
|
+
};
|