bb-fca 2.0.0
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-MIT +21 -0
- package/README.md +0 -0
- package/dist/core/client.js +50 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/models/buildAPI.js +103 -0
- package/dist/core/models/buildAPI.js.map +1 -0
- package/dist/core/models/loginHelper.js +209 -0
- package/dist/core/models/loginHelper.js.map +1 -0
- package/dist/core/models/setOptions.js +47 -0
- package/dist/core/models/setOptions.js.map +1 -0
- package/dist/deltas/apis/create.js +30 -0
- package/dist/deltas/apis/create.js.map +1 -0
- package/dist/deltas/apis/extra/addExternalModule.js +23 -0
- package/dist/deltas/apis/extra/addExternalModule.js.map +1 -0
- package/dist/deltas/apis/extra/getAccess.js +110 -0
- package/dist/deltas/apis/extra/getAccess.js.map +1 -0
- package/dist/deltas/apis/http/httpGet.js +57 -0
- package/dist/deltas/apis/http/httpGet.js.map +1 -0
- package/dist/deltas/apis/http/httpPost.js +57 -0
- package/dist/deltas/apis/http/httpPost.js.map +1 -0
- package/dist/deltas/apis/http/httpPostFormData.js +61 -0
- package/dist/deltas/apis/http/httpPostFormData.js.map +1 -0
- package/dist/deltas/apis/login/GetBotInfo.js +83 -0
- package/dist/deltas/apis/login/GetBotInfo.js.map +1 -0
- package/dist/deltas/apis/login/getBotInitialData.js +46 -0
- package/dist/deltas/apis/login/getBotInitialData.js.map +1 -0
- package/dist/deltas/apis/login/logout.js +54 -0
- package/dist/deltas/apis/login/logout.js.map +1 -0
- package/dist/deltas/apis/messaging/editMessage.js +64 -0
- package/dist/deltas/apis/messaging/editMessage.js.map +1 -0
- package/dist/deltas/apis/messaging/emoji.js +120 -0
- package/dist/deltas/apis/messaging/emoji.js.map +1 -0
- package/dist/deltas/apis/messaging/gcmember.js +164 -0
- package/dist/deltas/apis/messaging/gcmember.js.map +1 -0
- package/dist/deltas/apis/messaging/gcname.js +119 -0
- package/dist/deltas/apis/messaging/gcname.js.map +1 -0
- package/dist/deltas/apis/messaging/gcrule.js +144 -0
- package/dist/deltas/apis/messaging/gcrule.js.map +1 -0
- package/dist/deltas/apis/messaging/markAsDelivered.js +44 -0
- package/dist/deltas/apis/messaging/markAsDelivered.js.map +1 -0
- package/dist/deltas/apis/messaging/markAsRead.js +84 -0
- package/dist/deltas/apis/messaging/markAsRead.js.map +1 -0
- package/dist/deltas/apis/messaging/markAsReadAll.js +34 -0
- package/dist/deltas/apis/messaging/markAsReadAll.js.map +1 -0
- package/dist/deltas/apis/messaging/markAsSeen.js +64 -0
- package/dist/deltas/apis/messaging/markAsSeen.js.map +1 -0
- package/dist/deltas/apis/messaging/nickname.js +129 -0
- package/dist/deltas/apis/messaging/nickname.js.map +1 -0
- package/dist/deltas/apis/messaging/notes.js +156 -0
- package/dist/deltas/apis/messaging/notes.js.map +1 -0
- package/dist/deltas/apis/messaging/resolvePhotoUrl.js +55 -0
- package/dist/deltas/apis/messaging/resolvePhotoUrl.js.map +1 -0
- package/dist/deltas/apis/messaging/sendMessage.js +239 -0
- package/dist/deltas/apis/messaging/sendMessage.js.map +1 -0
- package/dist/deltas/apis/messaging/sendTypingIndicator.js +41 -0
- package/dist/deltas/apis/messaging/sendTypingIndicator.js.map +1 -0
- package/dist/deltas/apis/messaging/setMessageReaction.js +30 -0
- package/dist/deltas/apis/messaging/setMessageReaction.js.map +1 -0
- package/dist/deltas/apis/messaging/shareContact.js +59 -0
- package/dist/deltas/apis/messaging/shareContact.js.map +1 -0
- package/dist/deltas/apis/messaging/stickers.js +246 -0
- package/dist/deltas/apis/messaging/stickers.js.map +1 -0
- package/dist/deltas/apis/messaging/theme.js +227 -0
- package/dist/deltas/apis/messaging/theme.js.map +1 -0
- package/dist/deltas/apis/messaging/unsendMessage.js +19 -0
- package/dist/deltas/apis/messaging/unsendMessage.js.map +1 -0
- package/dist/deltas/apis/mqtt/deltas/value.js +193 -0
- package/dist/deltas/apis/mqtt/deltas/value.js.map +1 -0
- package/dist/deltas/apis/mqtt/listenMqtt.js +306 -0
- package/dist/deltas/apis/mqtt/listenMqtt.js.map +1 -0
- package/dist/deltas/apis/mqtt/listenSpeed.js +166 -0
- package/dist/deltas/apis/mqtt/listenSpeed.js.map +1 -0
- package/dist/deltas/apis/mqtt/pinMessage.js +166 -0
- package/dist/deltas/apis/mqtt/pinMessage.js.map +1 -0
- package/dist/deltas/apis/mqtt/realtime.js +160 -0
- package/dist/deltas/apis/mqtt/realtime.js.map +1 -0
- package/dist/deltas/apis/mqtt/sendMessageMqtt.js +184 -0
- package/dist/deltas/apis/mqtt/sendMessageMqtt.js.map +1 -0
- package/dist/deltas/apis/mqtt/setMessageReactionMqtt.js +57 -0
- package/dist/deltas/apis/mqtt/setMessageReactionMqtt.js.map +1 -0
- package/dist/deltas/apis/posting/comment.js +195 -0
- package/dist/deltas/apis/posting/comment.js.map +1 -0
- package/dist/deltas/apis/posting/follow.js +82 -0
- package/dist/deltas/apis/posting/follow.js.map +1 -0
- package/dist/deltas/apis/posting/friend.js +253 -0
- package/dist/deltas/apis/posting/friend.js.map +1 -0
- package/dist/deltas/apis/posting/post.js +551 -0
- package/dist/deltas/apis/posting/post.js.map +1 -0
- package/dist/deltas/apis/posting/share.js +59 -0
- package/dist/deltas/apis/posting/share.js.map +1 -0
- package/dist/deltas/apis/posting/story.js +176 -0
- package/dist/deltas/apis/posting/story.js.map +1 -0
- package/dist/deltas/apis/threads/getThreadHistory.js +233 -0
- package/dist/deltas/apis/threads/getThreadHistory.js.map +1 -0
- package/dist/deltas/apis/threads/getThreadInfo.js +197 -0
- package/dist/deltas/apis/threads/getThreadInfo.js.map +1 -0
- package/dist/deltas/apis/threads/getThreadList.js +201 -0
- package/dist/deltas/apis/threads/getThreadList.js.map +1 -0
- package/dist/deltas/apis/users/getUserInfo.js +254 -0
- package/dist/deltas/apis/users/getUserInfo.js.map +1 -0
- package/dist/index.d.ts +696 -0
- package/dist/types/core/client.d.ts +2 -0
- package/dist/types/core/models/buildAPI.d.ts +13 -0
- package/dist/types/core/models/loginHelper.d.ts +15 -0
- package/dist/types/core/models/setOptions.d.ts +2 -0
- package/dist/types/deltas/apis/create.d.ts +23 -0
- package/dist/types/deltas/apis/extra/addExternalModule.d.ts +1 -0
- package/dist/types/deltas/apis/extra/getAccess.d.ts +1 -0
- package/dist/types/deltas/apis/http/httpGet.d.ts +1 -0
- package/dist/types/deltas/apis/http/httpPost.d.ts +1 -0
- package/dist/types/deltas/apis/http/httpPostFormData.d.ts +1 -0
- package/dist/types/deltas/apis/login/GetBotInfo.d.ts +32 -0
- package/dist/types/deltas/apis/login/getBotInitialData.d.ts +1 -0
- package/dist/types/deltas/apis/login/logout.d.ts +7 -0
- package/dist/types/deltas/apis/messaging/editMessage.d.ts +7 -0
- package/dist/types/deltas/apis/messaging/emoji.d.ts +1 -0
- package/dist/types/deltas/apis/messaging/gcmember.d.ts +1 -0
- package/dist/types/deltas/apis/messaging/gcname.d.ts +1 -0
- package/dist/types/deltas/apis/messaging/gcrule.d.ts +1 -0
- package/dist/types/deltas/apis/messaging/markAsDelivered.d.ts +7 -0
- package/dist/types/deltas/apis/messaging/markAsRead.d.ts +6 -0
- package/dist/types/deltas/apis/messaging/markAsReadAll.d.ts +7 -0
- package/dist/types/deltas/apis/messaging/markAsSeen.d.ts +6 -0
- package/dist/types/deltas/apis/messaging/nickname.d.ts +1 -0
- package/dist/types/deltas/apis/messaging/notes.d.ts +14 -0
- package/dist/types/deltas/apis/messaging/resolvePhotoUrl.d.ts +9 -0
- package/dist/types/deltas/apis/messaging/sendMessage.d.ts +1 -0
- package/dist/types/deltas/apis/messaging/sendTypingIndicator.d.ts +6 -0
- package/dist/types/deltas/apis/messaging/setMessageReaction.d.ts +1 -0
- package/dist/types/deltas/apis/messaging/shareContact.d.ts +8 -0
- package/dist/types/deltas/apis/messaging/stickers.d.ts +48 -0
- package/dist/types/deltas/apis/messaging/theme.d.ts +1 -0
- package/dist/types/deltas/apis/messaging/unsendMessage.d.ts +1 -0
- package/dist/types/deltas/apis/mqtt/deltas/value.d.ts +2 -0
- package/dist/types/deltas/apis/mqtt/listenMqtt.d.ts +20 -0
- package/dist/types/deltas/apis/mqtt/listenSpeed.d.ts +21 -0
- package/dist/types/deltas/apis/mqtt/pinMessage.d.ts +1 -0
- package/dist/types/deltas/apis/mqtt/realtime.d.ts +1 -0
- package/dist/types/deltas/apis/mqtt/sendMessageMqtt.d.ts +1 -0
- package/dist/types/deltas/apis/mqtt/setMessageReactionMqtt.d.ts +1 -0
- package/dist/types/deltas/apis/posting/comment.d.ts +9 -0
- package/dist/types/deltas/apis/posting/follow.d.ts +14 -0
- package/dist/types/deltas/apis/posting/friend.d.ts +61 -0
- package/dist/types/deltas/apis/posting/post.d.ts +20 -0
- package/dist/types/deltas/apis/posting/share.d.ts +1 -0
- package/dist/types/deltas/apis/posting/story.d.ts +39 -0
- package/dist/types/deltas/apis/threads/getThreadHistory.d.ts +7 -0
- package/dist/types/deltas/apis/threads/getThreadInfo.d.ts +7 -0
- package/dist/types/deltas/apis/threads/getThreadList.d.ts +7 -0
- package/dist/types/deltas/apis/users/getUserInfo.d.ts +1 -0
- package/dist/types/utils/axios.d.ts +7 -0
- package/dist/types/utils/clients.d.ts +4 -0
- package/dist/types/utils/constants.d.ts +24 -0
- package/dist/types/utils/formatters/data/formatAttachment.d.ts +2 -0
- package/dist/types/utils/formatters/data/formatDelta.d.ts +4 -0
- package/dist/types/utils/formatters/index.d.ts +17 -0
- package/dist/types/utils/formatters/value/formatCookie.d.ts +8 -0
- package/dist/types/utils/formatters/value/formatDate.d.ts +6 -0
- package/dist/types/utils/formatters/value/formatID.d.ts +7 -0
- package/dist/types/utils/headers.d.ts +2 -0
- package/dist/types/utils/index.d.ts +75 -0
- package/dist/types/utils/user-agents.d.ts +9 -0
- package/dist/utils/axios.js +148 -0
- package/dist/utils/axios.js.map +1 -0
- package/dist/utils/clients.js +120 -0
- package/dist/utils/clients.js.map +1 -0
- package/dist/utils/constants.js +249 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/formatters/data/formatAttachment.js +61 -0
- package/dist/utils/formatters/data/formatAttachment.js.map +1 -0
- package/dist/utils/formatters/data/formatDelta.js +67 -0
- package/dist/utils/formatters/data/formatDelta.js.map +1 -0
- package/dist/utils/formatters/index.js +132 -0
- package/dist/utils/formatters/index.js.map +1 -0
- package/dist/utils/formatters/value/formatCookie.js +13 -0
- package/dist/utils/formatters/value/formatCookie.js.map +1 -0
- package/dist/utils/formatters/value/formatDate.js +33 -0
- package/dist/utils/formatters/value/formatDate.js.map +1 -0
- package/dist/utils/formatters/value/formatID.js +17 -0
- package/dist/utils/formatters/value/formatID.js.map +1 -0
- package/dist/utils/headers.js +61 -0
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/index.js +105 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/user-agents.js +41 -0
- package/dist/utils/user-agents.js.map +1 -0
- package/examples/post.example.js +149 -0
- package/module/index.js +5 -0
- package/package.json +56 -0
- package/src/core/client.ts +66 -0
- package/src/core/models/buildAPI.ts +131 -0
- package/src/core/models/loginHelper.ts +226 -0
- package/src/core/models/setOptions.ts +48 -0
- package/src/deltas/apis/create.ts +28 -0
- package/src/deltas/apis/extra/addExternalModule.ts +23 -0
- package/src/deltas/apis/extra/getAccess.ts +141 -0
- package/src/deltas/apis/http/httpGet.ts +61 -0
- package/src/deltas/apis/http/httpPost.ts +61 -0
- package/src/deltas/apis/http/httpPostFormData.ts +67 -0
- package/src/deltas/apis/login/GetBotInfo.ts +88 -0
- package/src/deltas/apis/login/getBotInitialData.ts +42 -0
- package/src/deltas/apis/login/logout.ts +62 -0
- package/src/deltas/apis/messaging/editMessage.ts +69 -0
- package/src/deltas/apis/messaging/emoji.ts +135 -0
- package/src/deltas/apis/messaging/gcmember.ts +175 -0
- package/src/deltas/apis/messaging/gcname.ts +136 -0
- package/src/deltas/apis/messaging/gcrule.ts +152 -0
- package/src/deltas/apis/messaging/markAsDelivered.ts +47 -0
- package/src/deltas/apis/messaging/markAsRead.ts +94 -0
- package/src/deltas/apis/messaging/markAsReadAll.ts +38 -0
- package/src/deltas/apis/messaging/markAsSeen.ts +69 -0
- package/src/deltas/apis/messaging/nickname.ts +153 -0
- package/src/deltas/apis/messaging/notes.ts +165 -0
- package/src/deltas/apis/messaging/resolvePhotoUrl.ts +56 -0
- package/src/deltas/apis/messaging/sendMessage.ts +286 -0
- package/src/deltas/apis/messaging/sendTypingIndicator.ts +48 -0
- package/src/deltas/apis/messaging/setMessageReaction.ts +25 -0
- package/src/deltas/apis/messaging/shareContact.ts +63 -0
- package/src/deltas/apis/messaging/stickers.ts +255 -0
- package/src/deltas/apis/messaging/theme.ts +280 -0
- package/src/deltas/apis/messaging/unsendMessage.ts +15 -0
- package/src/deltas/apis/mqtt/deltas/value.ts +224 -0
- package/src/deltas/apis/mqtt/listenMqtt.ts +332 -0
- package/src/deltas/apis/mqtt/listenSpeed.ts +179 -0
- package/src/deltas/apis/mqtt/pinMessage.ts +135 -0
- package/src/deltas/apis/mqtt/realtime.ts +169 -0
- package/src/deltas/apis/mqtt/sendMessageMqtt.ts +206 -0
- package/src/deltas/apis/mqtt/setMessageReactionMqtt.ts +61 -0
- package/src/deltas/apis/posting/comment.ts +205 -0
- package/src/deltas/apis/posting/follow.ts +79 -0
- package/src/deltas/apis/posting/friend.ts +241 -0
- package/src/deltas/apis/posting/post.ts +599 -0
- package/src/deltas/apis/posting/share.ts +60 -0
- package/src/deltas/apis/posting/story.ts +207 -0
- package/src/deltas/apis/threads/getThreadHistory.ts +237 -0
- package/src/deltas/apis/threads/getThreadInfo.ts +210 -0
- package/src/deltas/apis/threads/getThreadList.ts +224 -0
- package/src/deltas/apis/users/getUserInfo.ts +244 -0
- package/src/types/index.d.ts +696 -0
- package/src/utils/axios.ts +178 -0
- package/src/utils/clients.ts +125 -0
- package/src/utils/constants.ts +281 -0
- package/src/utils/formatters/data/formatAttachment.ts +58 -0
- package/src/utils/formatters/data/formatDelta.ts +45 -0
- package/src/utils/formatters/index.ts +82 -0
- package/src/utils/formatters/value/formatCookie.ts +13 -0
- package/src/utils/formatters/value/formatDate.ts +34 -0
- package/src/utils/formatters/value/formatID.ts +14 -0
- package/src/utils/formatters.old.ts +1049 -0
- package/src/utils/headers.ts +65 -0
- package/src/utils/index.ts +65 -0
- package/src/utils/user-agents.ts +49 -0
- package/tsconfig.json +37 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @namespace api.create
|
|
3
|
+
* @description A collection of functions for creating and managing content on Facebook.
|
|
4
|
+
* @license Ex-it
|
|
5
|
+
*/
|
|
6
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
7
|
+
const postModule = require('./posting/post').default(defaultFuncs, api, ctx);
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new post on Facebook.
|
|
12
|
+
* @param {string|object} options - The post content (string) or options object.
|
|
13
|
+
* @param {string} options.message - The text content of the post.
|
|
14
|
+
* @param {string} [options.privacy="SELF"] - Privacy setting: "EVERYONE", "FRIENDS", or "SELF".
|
|
15
|
+
* @param {Function} [callback] - Optional callback function.
|
|
16
|
+
* @returns {Promise<object>} The server's response containing post details.
|
|
17
|
+
*/
|
|
18
|
+
addPost: postModule.create,
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Deletes a post from Facebook.
|
|
22
|
+
* @param {string} postID - The ID of the post to delete.
|
|
23
|
+
* @param {Function} [callback] - Optional callback function.
|
|
24
|
+
* @returns {Promise<object>} The server's response.
|
|
25
|
+
*/
|
|
26
|
+
deletePost: postModule.delete,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import utils = require("../../../utils");
|
|
2
|
+
|
|
3
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
4
|
+
return function addExternalModule(moduleObj) {
|
|
5
|
+
if (utils.getType(moduleObj) == "Object") {
|
|
6
|
+
for (const apiName in moduleObj) {
|
|
7
|
+
if (utils.getType(moduleObj[apiName]) == "Function") {
|
|
8
|
+
api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
|
9
|
+
} else {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(
|
|
12
|
+
moduleObj[apiName],
|
|
13
|
+
)}!`,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`moduleObj must be an object, not ${utils.getType(moduleObj)}!`,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import utils = require('../../../utils');
|
|
2
|
+
|
|
3
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
4
|
+
return function getAccess(authCode = '', callback) {
|
|
5
|
+
var cb;
|
|
6
|
+
var url = 'https://business.facebook.com/';
|
|
7
|
+
var Referer =
|
|
8
|
+
url +
|
|
9
|
+
'security/twofactor/reauth/?twofac_next=' +
|
|
10
|
+
encodeURIComponent(url + 'content_management') +
|
|
11
|
+
'&type=avoid_bypass&app_id=0&save_device=0';
|
|
12
|
+
var rt = new Promise<any>(function(resolve, reject) {
|
|
13
|
+
cb = (error, token) => (token ? resolve(token) : reject(error));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
if (typeof authCode == 'function') {
|
|
17
|
+
callback = authCode;
|
|
18
|
+
authCode = '';
|
|
19
|
+
}
|
|
20
|
+
if (typeof callback == 'function') cb = callback;
|
|
21
|
+
if (!!ctx.access_token) cb(null, ctx.access_token);
|
|
22
|
+
else
|
|
23
|
+
utils
|
|
24
|
+
.get(
|
|
25
|
+
url + 'content_management',
|
|
26
|
+
ctx.jar,
|
|
27
|
+
null,
|
|
28
|
+
ctx.globalOptions,
|
|
29
|
+
null,
|
|
30
|
+
{
|
|
31
|
+
noRef: true,
|
|
32
|
+
Origin: url,
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
.then(function(res) {
|
|
36
|
+
var html = res.body;
|
|
37
|
+
var lsd = utils.getFrom(html, '["LSD",[],{"token":"', '"}');
|
|
38
|
+
return lsd;
|
|
39
|
+
})
|
|
40
|
+
.then(function(lsd) {
|
|
41
|
+
function submitCode(code) {
|
|
42
|
+
var pCb;
|
|
43
|
+
var rtPromise = new Promise<any>(function(resolve) {
|
|
44
|
+
pCb = (error, token) => resolve(cb(error, token));
|
|
45
|
+
});
|
|
46
|
+
if (typeof code != 'string')
|
|
47
|
+
pCb({
|
|
48
|
+
error: 'submitCode',
|
|
49
|
+
lerror: 'code must be string',
|
|
50
|
+
continue: submitCode,
|
|
51
|
+
});
|
|
52
|
+
else
|
|
53
|
+
defaultFuncs
|
|
54
|
+
.post(
|
|
55
|
+
url + 'security/twofactor/reauth/enter/',
|
|
56
|
+
ctx.jar,
|
|
57
|
+
{
|
|
58
|
+
approvals_code: code,
|
|
59
|
+
save_device: true,
|
|
60
|
+
lsd,
|
|
61
|
+
},
|
|
62
|
+
ctx.globalOptions,
|
|
63
|
+
null,
|
|
64
|
+
{
|
|
65
|
+
Referer,
|
|
66
|
+
Origin: url,
|
|
67
|
+
},
|
|
68
|
+
)
|
|
69
|
+
.then(function(res) {
|
|
70
|
+
var { payload } = JSON.parse(
|
|
71
|
+
res.body.split(';').pop() || '{}',
|
|
72
|
+
);
|
|
73
|
+
if (payload && !payload.codeConfirmed)
|
|
74
|
+
throw {
|
|
75
|
+
error: 'submitCode',
|
|
76
|
+
lerror: payload.message,
|
|
77
|
+
continue: submitCode,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return;
|
|
81
|
+
})
|
|
82
|
+
.then(function() {
|
|
83
|
+
return utils
|
|
84
|
+
.get(
|
|
85
|
+
url + 'content_management',
|
|
86
|
+
ctx.jar,
|
|
87
|
+
null,
|
|
88
|
+
ctx.globalOptions,
|
|
89
|
+
null,
|
|
90
|
+
{ noRef: true },
|
|
91
|
+
)
|
|
92
|
+
.then(function(res) {
|
|
93
|
+
var html = res.body;
|
|
94
|
+
var token = /"accessToken":"(\S+)","clientID":/g.exec(
|
|
95
|
+
html,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
return [html, token];
|
|
99
|
+
});
|
|
100
|
+
})
|
|
101
|
+
.then(function(res) {
|
|
102
|
+
if (!res[1])
|
|
103
|
+
throw {
|
|
104
|
+
error: 'token-undefined',
|
|
105
|
+
htmlData: res[0],
|
|
106
|
+
};
|
|
107
|
+
ctx.access_token = res[1][1];
|
|
108
|
+
return pCb(null, res[1][1]);
|
|
109
|
+
})
|
|
110
|
+
.catch(function(err) {
|
|
111
|
+
utils.error('getAccess', err.error || err);
|
|
112
|
+
return pCb(err);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return rtPromise;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (authCode.length == 6 && !isNaN(authCode as any))
|
|
119
|
+
submitCode(authCode.toString());
|
|
120
|
+
else if (typeof callback == 'function')
|
|
121
|
+
throw {
|
|
122
|
+
error: 'submitCode',
|
|
123
|
+
continue: submitCode,
|
|
124
|
+
};
|
|
125
|
+
else
|
|
126
|
+
throw {
|
|
127
|
+
error:
|
|
128
|
+
'authentication code must be string or number or callback must be a function to continue',
|
|
129
|
+
};
|
|
130
|
+
})
|
|
131
|
+
.catch(function(err) {
|
|
132
|
+
utils.error(
|
|
133
|
+
'getAccess',
|
|
134
|
+
typeof callback == 'function' ? err.error || err : err,
|
|
135
|
+
);
|
|
136
|
+
return cb(err);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return rt;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import utils = require("../../../utils");
|
|
2
|
+
|
|
3
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
4
|
+
return function httpGet(url, form, customHeader, callback, notAPI) {
|
|
5
|
+
let resolveFunc: Function = function () {};
|
|
6
|
+
let rejectFunc: Function = function () {};
|
|
7
|
+
|
|
8
|
+
const returnPromise = new Promise<any>(function (resolve, reject) {
|
|
9
|
+
resolveFunc = resolve;
|
|
10
|
+
rejectFunc = reject;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
utils.getType(form) == "Function" ||
|
|
15
|
+
utils.getType(form) == "AsyncFunction"
|
|
16
|
+
) {
|
|
17
|
+
callback = form;
|
|
18
|
+
form = {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
utils.getType(customHeader) == "Function" ||
|
|
23
|
+
utils.getType(customHeader) == "AsyncFunction"
|
|
24
|
+
) {
|
|
25
|
+
callback = customHeader;
|
|
26
|
+
customHeader = {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
customHeader = customHeader || {};
|
|
30
|
+
|
|
31
|
+
callback =
|
|
32
|
+
callback ||
|
|
33
|
+
function (err, data) {
|
|
34
|
+
if (err) return rejectFunc(err);
|
|
35
|
+
resolveFunc(data);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (notAPI) {
|
|
39
|
+
utils
|
|
40
|
+
.get(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
|
41
|
+
.then(function (resData) {
|
|
42
|
+
callback(null, resData.body.toString());
|
|
43
|
+
})
|
|
44
|
+
.catch(function (err) {
|
|
45
|
+
utils.error("httpGet", err);
|
|
46
|
+
return callback(err);
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
defaultFuncs
|
|
50
|
+
.get(url, ctx.jar, form, null, customHeader)
|
|
51
|
+
.then(function (resData) {
|
|
52
|
+
callback(null, resData.body.toString());
|
|
53
|
+
})
|
|
54
|
+
.catch(function (err) {
|
|
55
|
+
utils.error("httpGet", err);
|
|
56
|
+
return callback(err);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return returnPromise;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import utils = require("../../../utils");
|
|
2
|
+
|
|
3
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
4
|
+
return function httpPost(url, form, customHeader, callback, notAPI) {
|
|
5
|
+
let resolveFunc: Function = function () {};
|
|
6
|
+
let rejectFunc: Function = function () {};
|
|
7
|
+
|
|
8
|
+
const returnPromise = new Promise<any>(function (resolve, reject) {
|
|
9
|
+
resolveFunc = resolve;
|
|
10
|
+
rejectFunc = reject;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
utils.getType(form) == "Function" ||
|
|
15
|
+
utils.getType(form) == "AsyncFunction"
|
|
16
|
+
) {
|
|
17
|
+
callback = form;
|
|
18
|
+
form = {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
utils.getType(customHeader) == "Function" ||
|
|
23
|
+
utils.getType(customHeader) == "AsyncFunction"
|
|
24
|
+
) {
|
|
25
|
+
callback = customHeader;
|
|
26
|
+
customHeader = {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
customHeader = customHeader || {};
|
|
30
|
+
|
|
31
|
+
callback =
|
|
32
|
+
callback ||
|
|
33
|
+
function (err, data) {
|
|
34
|
+
if (err) return rejectFunc(err);
|
|
35
|
+
resolveFunc(data);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (notAPI) {
|
|
39
|
+
utils
|
|
40
|
+
.post(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
|
41
|
+
.then(function (resData) {
|
|
42
|
+
callback(null, resData.body.toString());
|
|
43
|
+
})
|
|
44
|
+
.catch(function (err) {
|
|
45
|
+
utils.error("httpPost", err);
|
|
46
|
+
return callback(err);
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
defaultFuncs
|
|
50
|
+
.post(url, ctx.jar, form, {}, customHeader)
|
|
51
|
+
.then(function (resData) {
|
|
52
|
+
callback(null, resData.body.toString());
|
|
53
|
+
})
|
|
54
|
+
.catch(function (err) {
|
|
55
|
+
utils.error("httpPost", err);
|
|
56
|
+
return callback(err);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return returnPromise;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import utils = require("../../../utils");
|
|
2
|
+
|
|
3
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
4
|
+
return function httpPostFormData(url, form, customHeader, callback, notAPI) {
|
|
5
|
+
let resolveFunc: Function = function () {};
|
|
6
|
+
let rejectFunc: Function = function () {};
|
|
7
|
+
|
|
8
|
+
const returnPromise = new Promise<any>(function (resolve, reject) {
|
|
9
|
+
resolveFunc = resolve;
|
|
10
|
+
rejectFunc = reject;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
utils.getType(form) == "Function" ||
|
|
15
|
+
utils.getType(form) == "AsyncFunction"
|
|
16
|
+
) {
|
|
17
|
+
callback = form;
|
|
18
|
+
form = {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
utils.getType(customHeader) == "Function" ||
|
|
23
|
+
utils.getType(customHeader) == "AsyncFunction"
|
|
24
|
+
) {
|
|
25
|
+
callback = customHeader;
|
|
26
|
+
customHeader = {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
customHeader = customHeader || {};
|
|
30
|
+
|
|
31
|
+
if (utils.getType(callback) == "Boolean") {
|
|
32
|
+
notAPI = callback;
|
|
33
|
+
callback = null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
callback =
|
|
37
|
+
callback ||
|
|
38
|
+
function (err, data) {
|
|
39
|
+
if (err) return rejectFunc(err);
|
|
40
|
+
resolveFunc(data);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
if (notAPI) {
|
|
44
|
+
utils
|
|
45
|
+
.postFormData(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
|
46
|
+
.then(function (resData) {
|
|
47
|
+
callback(null, resData.body.toString());
|
|
48
|
+
})
|
|
49
|
+
.catch(function (err) {
|
|
50
|
+
utils.error("httpPostFormData", err);
|
|
51
|
+
return callback(err);
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
defaultFuncs
|
|
55
|
+
.postFormData(url, ctx.jar, form, null, customHeader)
|
|
56
|
+
.then(function (resData) {
|
|
57
|
+
callback(null, resData.body.toString());
|
|
58
|
+
})
|
|
59
|
+
.catch(function (err) {
|
|
60
|
+
utils.error("httpPostFormData", err);
|
|
61
|
+
return callback(err);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return returnPromise;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// @ChoruOfficial
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
import 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
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
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,42 @@
|
|
|
1
|
+
import utils = require("../../../utils");
|
|
2
|
+
// @NethWs3Dev
|
|
3
|
+
|
|
4
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
5
|
+
return async (callback) => {
|
|
6
|
+
let resolveFunc: Function = () => {};
|
|
7
|
+
let rejectFunc: Function = () => {};
|
|
8
|
+
const returnPromise = new Promise<any>((resolve, reject) => {
|
|
9
|
+
resolveFunc = resolve;
|
|
10
|
+
rejectFunc = reject;
|
|
11
|
+
});
|
|
12
|
+
if (!callback) {
|
|
13
|
+
callback = (err, data) => {
|
|
14
|
+
if (err) {
|
|
15
|
+
return rejectFunc(err);
|
|
16
|
+
}
|
|
17
|
+
resolveFunc(data);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
utils.log("Fetching account info...");
|
|
21
|
+
api.httpGet(`https://www.facebook.com/profile.php?id=${ctx.userID}`, null, {
|
|
22
|
+
customUserAgent: utils.windowsUserAgent
|
|
23
|
+
}, (err, data) => {
|
|
24
|
+
|
|
25
|
+
if (err) throw err;
|
|
26
|
+
const profileMatch = data.match(/"CurrentUserInitialData",\[\],\{(.*?)\},(.*?)\]/);
|
|
27
|
+
if (profileMatch && profileMatch[1]){
|
|
28
|
+
const accountJson = JSON.parse(`{${profileMatch[1]}}`);
|
|
29
|
+
accountJson.name = accountJson.NAME;
|
|
30
|
+
accountJson.uid = accountJson.USER_ID;
|
|
31
|
+
delete accountJson.NAME;
|
|
32
|
+
delete accountJson.USER_ID;
|
|
33
|
+
return callback(null, {
|
|
34
|
+
...accountJson
|
|
35
|
+
});
|
|
36
|
+
} 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." });
|
|
37
|
+
}, true);
|
|
38
|
+
return returnPromise;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// @ChoruOfficial
|
|
2
|
+
import utils = require("../../../utils");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {Object} defaultFuncs
|
|
6
|
+
* @param {Object} api
|
|
7
|
+
* @param {Object} ctx
|
|
8
|
+
* @returns {function(): Promise<void>}
|
|
9
|
+
*/
|
|
10
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
11
|
+
/**
|
|
12
|
+
* Logs the current user out of Facebook.
|
|
13
|
+
* @returns {Promise<void>} A promise that resolves when logout is successful or rejects on error.
|
|
14
|
+
*/
|
|
15
|
+
return async function logout() {
|
|
16
|
+
const form = {
|
|
17
|
+
pmid: "0",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const resData = await defaultFuncs
|
|
22
|
+
.post(
|
|
23
|
+
"https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",
|
|
24
|
+
ctx.jar,
|
|
25
|
+
form,
|
|
26
|
+
)
|
|
27
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
|
28
|
+
|
|
29
|
+
const elem = resData.jsmods.instances[0][2][0].find(v => v.value === "logout");
|
|
30
|
+
if (!elem) {
|
|
31
|
+
throw { error: "Could not find logout form element." };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const html = resData.jsmods.markup.find(v => v[0] === elem.markup.__m)[1].__html;
|
|
35
|
+
|
|
36
|
+
const logoutForm = {
|
|
37
|
+
fb_dtsg: utils.getFrom(html, '"fb_dtsg" value="', '"'),
|
|
38
|
+
ref: utils.getFrom(html, '"ref" value="', '"'),
|
|
39
|
+
h: utils.getFrom(html, '"h" value="', '"'),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const logoutRes = await defaultFuncs
|
|
43
|
+
.post("https://www.facebook.com/logout.php", ctx.jar, logoutForm)
|
|
44
|
+
.then(utils.saveCookies(ctx.jar));
|
|
45
|
+
|
|
46
|
+
if (!logoutRes.headers || !logoutRes.headers.location) {
|
|
47
|
+
throw { error: "An error occurred when logging out." };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await defaultFuncs
|
|
51
|
+
.get(logoutRes.headers.location, ctx.jar)
|
|
52
|
+
.then(utils.saveCookies(ctx.jar));
|
|
53
|
+
|
|
54
|
+
ctx.loggedIn = false;
|
|
55
|
+
utils.log("logout", "Logged out successfully.");
|
|
56
|
+
|
|
57
|
+
} catch (err) {
|
|
58
|
+
utils.error("logout", err);
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author RFS-ADRENO
|
|
3
|
+
* @rewrittenBy Isai Ivanov
|
|
4
|
+
*/
|
|
5
|
+
//fixed march 30
|
|
6
|
+
import utils = require('../../../utils');
|
|
7
|
+
|
|
8
|
+
function canBeCalled(func) {
|
|
9
|
+
try {
|
|
10
|
+
Reflect.apply(func, null, []);
|
|
11
|
+
return true;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A function for editing bot's messages.
|
|
19
|
+
* @param {string} text - The text with which the bot will edit its messages.
|
|
20
|
+
* @param {string} messageID - The message ID of the message the bot will edit.
|
|
21
|
+
* @param {Object} callback - Callback for the function.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export default function(defaultFuncs: any, api: any, ctx: any) {
|
|
25
|
+
return function editMessage(text, messageID, callback) {
|
|
26
|
+
if (!ctx.mqttClient) {
|
|
27
|
+
throw new Error('Not connected to MQTT');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ctx.wsReqNumber += 1;
|
|
31
|
+
ctx.wsTaskNumber += 1;
|
|
32
|
+
|
|
33
|
+
const queryPayload = {
|
|
34
|
+
message_id: messageID,
|
|
35
|
+
text,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const query = {
|
|
39
|
+
failure_count: null,
|
|
40
|
+
label: '742',
|
|
41
|
+
payload: JSON.stringify(queryPayload),
|
|
42
|
+
queue_name: 'edit_message',
|
|
43
|
+
task_id: ctx.wsTaskNumber,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const context: any = {
|
|
47
|
+
app_id: '2220391788200892',
|
|
48
|
+
payload: {
|
|
49
|
+
data_trace_id: null,
|
|
50
|
+
epoch_id: parseInt(utils.generateOfflineThreadingID()),
|
|
51
|
+
tasks: [query],
|
|
52
|
+
version_id: '6903494529735864',
|
|
53
|
+
},
|
|
54
|
+
request_id: ctx.wsReqNumber,
|
|
55
|
+
type: 3,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
context.payload = JSON.stringify(context.payload);
|
|
59
|
+
|
|
60
|
+
// if (canBeCalled(callback)) {
|
|
61
|
+
// ctx.reqCallbacks[ctx.wsReqNumber] = callback;
|
|
62
|
+
// }
|
|
63
|
+
|
|
64
|
+
ctx.mqttClient.publish('/ls_req', JSON.stringify(context), {
|
|
65
|
+
qos: 1,
|
|
66
|
+
retain: false,
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
}
|