fca-smart-shankar 10.9.1 → 13.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/.replit +12 -3
- package/.upm/store.json +1 -1
- package/CHANGELOG.md +2 -0
- package/LICENSE-MIT +21 -0
- package/README.md +175 -30
- package/generated-icon.png +0 -0
- package/index.js +511 -414
- package/package.json +370 -85
- package/replit.nix +5 -0
- package/shankar-fca.json +4 -0
- package/src/addExternalModule.js +14 -5
- package/src/addUserToGroup.js +56 -20
- package/src/changeAdminStatus.js +44 -20
- package/src/changeArchivedStatus.js +25 -11
- package/src/changeAvatar.js +136 -0
- package/src/{changeAvt.js → changeAvatarV2.js} +3 -2
- package/src/changeBio.js +26 -15
- package/src/changeBlockedStatus.js +21 -8
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +73 -0
- package/src/changeGroupImage.js +53 -24
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +27 -13
- package/src/changeThreadColor.js +22 -19
- package/src/changeThreadEmoji.js +24 -11
- package/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/createNewGroup.js +38 -20
- package/src/createPoll.js +27 -16
- package/src/createPost.js +277 -0
- package/src/data/getThreadInfo.json +1 -0
- package/src/deleteMessage.js +24 -13
- package/src/deleteThread.js +25 -12
- package/src/editMessage.js +71 -53
- package/src/editMessageOld.js +67 -0
- package/src/follow.js +74 -0
- package/src/forwardAttachment.js +27 -15
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/getCurrentUserID.js +1 -1
- package/src/getEmojiUrl.js +10 -8
- package/src/getFriendsList.js +25 -15
- package/src/getMessage.js +813 -81
- package/src/getRegion.js +7 -0
- package/src/getThreadHistory.js +241 -98
- package/src/getThreadHistoryDeprecated.js +93 -0
- package/src/getThreadInfo.js +90 -287
- package/src/getThreadInfoDeprecated.js +80 -0
- package/src/getThreadList.js +214 -157
- package/src/getThreadListDeprecated.js +75 -0
- package/src/getThreadPictures.js +39 -19
- package/src/getUID.js +113 -50
- package/src/getUserID.js +18 -14
- package/src/getUserInfo.js +65 -71
- package/src/handleFriendRequest.js +24 -13
- package/src/handleMessageRequest.js +36 -20
- package/src/httpGet.js +34 -18
- package/src/httpPost.js +35 -18
- package/src/httpPostFormData.js +53 -24
- package/src/listenMqtt.js +680 -944
- package/src/listenNotification.js +85 -0
- package/src/logout.js +22 -15
- package/src/markAsDelivered.js +25 -15
- package/src/markAsRead.js +45 -27
- package/src/markAsReadAll.js +21 -14
- package/src/markAsSeen.js +28 -18
- package/src/muteThread.js +17 -12
- package/src/pinMessage.js +59 -0
- package/src/refreshFb_dtsg.js +89 -0
- package/src/removeUserFromGroup.js +47 -17
- package/src/resolvePhotoUrl.js +21 -13
- package/src/searchForThread.js +23 -13
- package/src/searchStickers.js +53 -0
- package/src/sendMessage.js +178 -117
- package/src/sendMessageMqtt.js +322 -0
- package/src/sendTypingIndicator.js +46 -16
- package/src/sendTypingIndicatorV2.js +28 -0
- package/src/setMessageReaction.js +33 -20
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/setPostReaction.js +105 -95
- package/src/setProfileGuard.js +45 -0
- package/src/setStoryReaction.js +64 -0
- package/src/setTitle.js +34 -18
- package/src/shareContact.js +92 -37
- package/src/shareLink.js +5 -4
- package/src/stopListenMqtt.js +26 -0
- package/src/threadColors.js +110 -18
- package/src/unfriend.js +18 -9
- package/src/unsendMessage.js +31 -34
- package/src/uploadAttachment.js +94 -0
- package/test/data/shareAttach.js +1 -1
- package/test/test.js +1 -1
- package/utils.js +1393 -2918
- package/.cache/replit/env/latest +0 -56
- package/.cache/replit/env/latest.json +0 -1
- package/.cache/replit/modules/nodejs-14.res +0 -1
- package/.cache/replit/modules/replit.res +0 -1
- package/.cache/replit/modules/web.res +0 -1
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/typescript/5.5/package.json +0 -1
- package/.config/configstore/update-notifier-npm.json +0 -4
- package/.gitattributes +0 -2
- package/Extra/Balancer.js +0 -49
- package/Extra/Bypass/956/index.js +0 -234
- package/Extra/Bypass/test/aaaa.json +0 -170
- package/Extra/Bypass/test/index.js +0 -188
- package/Extra/Database/index.js +0 -469
- package/Extra/ExtraAddons.js +0 -82
- package/Extra/ExtraFindUID.js +0 -62
- package/Extra/ExtraGetThread.js +0 -365
- package/Extra/ExtraScreenShot.js +0 -430
- package/Extra/ExtraUptimeRobot.js +0 -38
- package/Extra/Html/Classic/script.js +0 -119
- package/Extra/Html/Classic/style.css +0 -8
- package/Extra/Security/AES_256_GCM/index.js +0 -0
- package/Extra/Security/Base/Step_1.js +0 -6
- package/Extra/Security/Base/Step_2.js +0 -22
- package/Extra/Security/Base/Step_3.js +0 -22
- package/Extra/Security/Base/index.js +0 -191
- package/Extra/Security/Index.js +0 -5
- package/Extra/Security/Step_1.js +0 -6
- package/Extra/Security/Step_2.js +0 -22
- package/Extra/Security/Step_3.js +0 -22
- package/Extra/Src/Change_Environment.js +0 -24
- package/Extra/Src/Check_Update.js +0 -67
- package/Extra/Src/History.js +0 -115
- package/Extra/Src/Instant_Update.js +0 -65
- package/Extra/Src/Last-Run.js +0 -65
- package/Extra/Src/Premium.js +0 -81
- package/Extra/Src/Release_Memory.js +0 -160
- package/Extra/Src/Websocket.js +0 -213
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/test.js +0 -28
- package/Extra/Src/uuid.js +0 -137
- package/Func/AcceptAgreement.js +0 -31
- package/Func/ClearCache.js +0 -64
- package/Func/ReportV1.js +0 -54
- package/LICENSE +0 -678
- package/Language/index.json +0 -228
- package/Main.js +0 -1444
- package/SECURITY.md +0 -18
- package/broadcast.js +0 -44
- package/logger.js +0 -66
- package/src/Dev_Horizon_Data.js +0 -125
- package/src/Dev_getThreadInfoOLD.js +0 -422
- package/src/Dev_shareTest2.js +0 -68
- package/src/Dev_shareTest3.js +0 -71
- package/src/Premium.js +0 -25
- package/src/Screenshot.js +0 -83
- package/src/getAccessToken.js +0 -28
- package/src/getThreadInfoOLD.js +0 -422
- package/src/getThreadMain.js +0 -220
- package/src/getUserInfoMain.js +0 -65
- package/src/getUserInfoV2.js +0 -32
- package/src/getUserInfoV3.js +0 -63
- package/src/getUserInfoV4.js +0 -55
- package/src/getUserInfoV5.js +0 -61
- package/src/listenMqttV1.js +0 -846
- package/src/sendMqttMessage.js +0 -71
- package/src/unsendMqttMessage.js +0 -66
- package/test/Database_Test.js +0 -4
- package/test/Db2.js +0 -530
- package/test/Shankar_Database/A_README.md +0 -1
- package/test/Shankar_Database/Database.db +0 -0
- package/test/env/.env +0 -0
- package/test/example-db.db +0 -0
- package/test/memoryleak.js +0 -18
- package/test/testname.js +0 -1342
- package/test/testv2.js +0 -3
package/src/deleteMessage.js
CHANGED
@@ -1,37 +1,48 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
5
|
|
6
6
|
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function deleteMessage(messageOrMessages, callback) {
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
let resolveFunc = function () {};
|
9
|
+
let rejectFunc = function () {};
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
if (!callback) {
|
15
15
|
callback = function (err) {
|
16
|
-
if (err)
|
17
|
-
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
18
19
|
resolveFunc();
|
19
20
|
};
|
20
21
|
}
|
21
22
|
|
22
|
-
|
23
|
-
client: "mercury"
|
23
|
+
const form = {
|
24
|
+
client: "mercury",
|
24
25
|
};
|
25
26
|
|
26
|
-
if (utils.getType(messageOrMessages) !== "Array")
|
27
|
+
if (utils.getType(messageOrMessages) !== "Array") {
|
28
|
+
messageOrMessages = [messageOrMessages];
|
29
|
+
}
|
27
30
|
|
28
|
-
for (
|
31
|
+
for (let i = 0; i < messageOrMessages.length; i++) {
|
32
|
+
form["message_ids[" + i + "]"] = messageOrMessages[i];
|
33
|
+
}
|
29
34
|
|
30
35
|
defaultFuncs
|
31
|
-
.post(
|
36
|
+
.post(
|
37
|
+
"https://www.facebook.com/ajax/mercury/delete_messages.php",
|
38
|
+
ctx.jar,
|
39
|
+
form,
|
40
|
+
)
|
32
41
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
33
42
|
.then(function (resData) {
|
34
|
-
if (resData.error)
|
43
|
+
if (resData.error) {
|
44
|
+
throw resData;
|
45
|
+
}
|
35
46
|
|
36
47
|
return callback();
|
37
48
|
})
|
package/src/deleteThread.js
CHANGED
@@ -1,35 +1,48 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
5
|
|
6
6
|
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function deleteThread(threadOrThreads, callback) {
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
let resolveFunc = function () {};
|
9
|
+
let rejectFunc = function () {};
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
if (!callback) {
|
15
15
|
callback = function (err) {
|
16
|
-
if (err)
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
17
19
|
resolveFunc();
|
18
20
|
};
|
19
21
|
}
|
20
22
|
|
21
|
-
|
22
|
-
client: "mercury"
|
23
|
+
const form = {
|
24
|
+
client: "mercury",
|
23
25
|
};
|
24
26
|
|
25
|
-
if (utils.getType(threadOrThreads) !== "Array")
|
26
|
-
|
27
|
+
if (utils.getType(threadOrThreads) !== "Array") {
|
28
|
+
threadOrThreads = [threadOrThreads];
|
29
|
+
}
|
30
|
+
|
31
|
+
for (let i = 0; i < threadOrThreads.length; i++) {
|
32
|
+
form["ids[" + i + "]"] = threadOrThreads[i];
|
33
|
+
}
|
27
34
|
|
28
35
|
defaultFuncs
|
29
|
-
.post(
|
36
|
+
.post(
|
37
|
+
"https://www.facebook.com/ajax/mercury/delete_thread.php",
|
38
|
+
ctx.jar,
|
39
|
+
form,
|
40
|
+
)
|
30
41
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
31
42
|
.then(function (resData) {
|
32
|
-
if (resData.error)
|
43
|
+
if (resData.error) {
|
44
|
+
throw resData;
|
45
|
+
}
|
33
46
|
|
34
47
|
return callback();
|
35
48
|
})
|
package/src/editMessage.js
CHANGED
@@ -1,53 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
1
|
+
"use_strict";
|
2
|
+
/**
|
3
|
+
* @author RFS-ADRENO
|
4
|
+
* @rewrittenBy Isai Ivanov
|
5
|
+
*/
|
6
|
+
const generateOfflineThreadingId = 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
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
25
|
+
return function editMessage(text, messageID, callback) {
|
26
|
+
if (!ctx.mqttClient) {
|
27
|
+
throw new Error('Not connected to MQTT');
|
28
|
+
}
|
29
|
+
|
30
|
+
// modified and fix by kenneth panio the edit now works on secondary profile accounts
|
31
|
+
|
32
|
+
ctx.wsReqNumber ??= 0;
|
33
|
+
ctx.wsTaskNumber ??= 0;
|
34
|
+
|
35
|
+
ctx.wsReqNumber += 1;
|
36
|
+
ctx.wsTaskNumber += 1;
|
37
|
+
|
38
|
+
const queryPayload = {
|
39
|
+
message_id: messageID,
|
40
|
+
text: text,
|
41
|
+
};
|
42
|
+
|
43
|
+
const query = {
|
44
|
+
failure_count: null,
|
45
|
+
label: '742',
|
46
|
+
payload: JSON.stringify(queryPayload),
|
47
|
+
queue_name: 'edit_message',
|
48
|
+
task_id: ctx.wsTaskNumber,
|
49
|
+
};
|
50
|
+
|
51
|
+
const context = {
|
52
|
+
app_id: '2220391788200892',
|
53
|
+
payload: {
|
54
|
+
data_trace_id: null,
|
55
|
+
epoch_id: parseInt(generateOfflineThreadingId),
|
56
|
+
tasks: [query],
|
57
|
+
version_id: '6903494529735864',
|
58
|
+
},
|
59
|
+
request_id: ctx.wsReqNumber,
|
60
|
+
type: 3,
|
61
|
+
};
|
62
|
+
|
63
|
+
context.payload = JSON.stringify(context.payload);
|
64
|
+
|
65
|
+
if (canBeCalled(callback)) {
|
66
|
+
ctx.reqCallbacks[ctx.wsReqNumber] = callback;
|
67
|
+
}
|
68
|
+
|
69
|
+
ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false });
|
70
|
+
}
|
71
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use_strict";
|
2
|
+
|
3
|
+
const { generateOfflineThreadingID } = require('../utils');
|
4
|
+
|
5
|
+
function isCallable(func) {
|
6
|
+
try {
|
7
|
+
Reflect.apply(func, null, []);
|
8
|
+
return true;
|
9
|
+
} catch (error) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
15
|
+
|
16
|
+
return function editMessage(text, messageID, callback) {
|
17
|
+
|
18
|
+
|
19
|
+
if (!ctx.mqttClient) {
|
20
|
+
throw new Error('Not connected to MQTT');
|
21
|
+
}
|
22
|
+
|
23
|
+
ctx.wsReqNumber ??= 0;
|
24
|
+
ctx.wsTaskNumber ??= 0;
|
25
|
+
|
26
|
+
ctx.wsReqNumber += 1;
|
27
|
+
ctx.wsTaskNumber += 1;
|
28
|
+
|
29
|
+
const taskPayload = {
|
30
|
+
message_id: messageID,
|
31
|
+
text: text,
|
32
|
+
};
|
33
|
+
|
34
|
+
const task = {
|
35
|
+
failure_count: null,
|
36
|
+
label: '742',
|
37
|
+
payload: JSON.stringify(taskPayload),
|
38
|
+
queue_name: 'edit_message',
|
39
|
+
task_id: ctx.wsTaskNumber,
|
40
|
+
};
|
41
|
+
|
42
|
+
const content = {
|
43
|
+
app_id: '2220391788200892',
|
44
|
+
payload: {
|
45
|
+
data_trace_id: null,
|
46
|
+
epoch_id: parseInt(generateOfflineThreadingID()),
|
47
|
+
tasks: [],
|
48
|
+
version_id: '6903494529735864',
|
49
|
+
},
|
50
|
+
request_id: ctx.wsReqNumber,
|
51
|
+
type: 3,
|
52
|
+
};
|
53
|
+
|
54
|
+
content.payload.tasks.push(task);
|
55
|
+
content.payload = JSON.stringify(content.payload);
|
56
|
+
|
57
|
+
if (isCallable(callback)) {
|
58
|
+
ctx.reqCallbacks[ctx.wsReqNumber] = callback;
|
59
|
+
}
|
60
|
+
|
61
|
+
ctx.mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
|
62
|
+
require(__dirname.replace("/fca-unofficial/src", "/handlers")).modifymsg({
|
63
|
+
body: text,
|
64
|
+
msgId: messageID
|
65
|
+
});
|
66
|
+
};
|
67
|
+
}
|
package/src/follow.js
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Author @YanMaglinte
|
5
|
+
* https://github.com/YANDEVA
|
6
|
+
*
|
7
|
+
* Example:
|
8
|
+
* api.follow("100090794779367", true); // Set true to follow, false if otherwise.
|
9
|
+
*/
|
10
|
+
|
11
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
12
|
+
return function follow(senderID, boolean, callback) {
|
13
|
+
if (!ctx.mqttClient) {
|
14
|
+
throw new Error("Not connected to MQTT");
|
15
|
+
}
|
16
|
+
|
17
|
+
let form;
|
18
|
+
|
19
|
+
if (boolean) {
|
20
|
+
form = {
|
21
|
+
av: ctx.userID || ctx.i_userID,
|
22
|
+
fb_api_req_friendly_name: "CometUserFollowMutation",
|
23
|
+
fb_api_caller_class: "RelayModern",
|
24
|
+
doc_id: "25472099855769847",
|
25
|
+
variables: JSON.stringify({
|
26
|
+
input: {
|
27
|
+
attribution_id_v2:
|
28
|
+
"ProfileCometTimelineListViewRoot.react,comet.profile.timeline.list,via_cold_start,1717249218695,723451,250100865708545,,",
|
29
|
+
is_tracking_encrypted: true,
|
30
|
+
subscribe_location: "PROFILE",
|
31
|
+
subscribee_id: senderID,
|
32
|
+
tracking: null,
|
33
|
+
actor_id: ctx.userID || ctx.i_userID,
|
34
|
+
client_mutation_id: "1",
|
35
|
+
},
|
36
|
+
scale: 1,
|
37
|
+
}),
|
38
|
+
};
|
39
|
+
} else {
|
40
|
+
form = {
|
41
|
+
av: ctx.userID || ctx.i_userID,
|
42
|
+
fb_api_req_friendly_name: "CometUserUnfollowMutation",
|
43
|
+
fb_api_caller_class: "RelayModern",
|
44
|
+
doc_id: "25472099855769847",
|
45
|
+
variables: JSON.stringify({
|
46
|
+
action_render_location: "WWW_COMET_FRIEND_MENU",
|
47
|
+
input: {
|
48
|
+
attribution_id_v2:
|
49
|
+
"ProfileCometTimelineListViewRoot.react,comet.profile.timeline.list,tap_search_bar,1717294006136,602597,250100865708545,,",
|
50
|
+
is_tracking_encrypted: true,
|
51
|
+
subscribe_location: "PROFILE",
|
52
|
+
tracking: null,
|
53
|
+
unsubscribee_id: senderID,
|
54
|
+
actor_id: ctx.userID || ctx.i_userID,
|
55
|
+
client_mutation_id: "10",
|
56
|
+
},
|
57
|
+
scale: 1,
|
58
|
+
}),
|
59
|
+
};
|
60
|
+
}
|
61
|
+
|
62
|
+
api.httpPost("https://www.facebook.com/api/graphql/", form, (err, data) => {
|
63
|
+
if (err) {
|
64
|
+
if (typeof callback === "function") {
|
65
|
+
callback(err);
|
66
|
+
}
|
67
|
+
} else {
|
68
|
+
if (typeof callback === "function") {
|
69
|
+
callback(null, data);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
});
|
73
|
+
};
|
74
|
+
};
|
package/src/forwardAttachment.js
CHANGED
@@ -1,40 +1,52 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
5
|
|
6
6
|
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function forwardAttachment(attachmentID, userOrUsers, callback) {
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
let resolveFunc = function () {};
|
9
|
+
let rejectFunc = function () {};
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
if (!callback) {
|
15
15
|
callback = function (err) {
|
16
|
-
if (err)
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
17
19
|
resolveFunc();
|
18
20
|
};
|
19
21
|
}
|
20
22
|
|
21
|
-
|
22
|
-
attachment_id: attachmentID
|
23
|
+
const form = {
|
24
|
+
attachment_id: attachmentID,
|
23
25
|
};
|
24
26
|
|
25
|
-
if (utils.getType(userOrUsers) !== "Array")
|
27
|
+
if (utils.getType(userOrUsers) !== "Array") {
|
28
|
+
userOrUsers = [userOrUsers];
|
29
|
+
}
|
26
30
|
|
27
|
-
|
31
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
for (let i = 0; i < userOrUsers.length; i++) {
|
34
|
+
//That's good, the key of the array is really timestmap in seconds + index
|
35
|
+
//Probably time when the attachment will be sent?
|
36
|
+
form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
|
37
|
+
}
|
32
38
|
|
33
39
|
defaultFuncs
|
34
|
-
.post(
|
40
|
+
.post(
|
41
|
+
"https://www.facebook.com/mercury/attachments/forward/",
|
42
|
+
ctx.jar,
|
43
|
+
form,
|
44
|
+
)
|
35
45
|
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
36
46
|
.then(function (resData) {
|
37
|
-
if (resData.error)
|
47
|
+
if (resData.error) {
|
48
|
+
throw resData;
|
49
|
+
}
|
38
50
|
|
39
51
|
return callback();
|
40
52
|
})
|
package/src/getAccess.js
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('../utils');
|
4
|
+
var log = require('npmlog');
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function getAccess(authCode = '', callback) {
|
8
|
+
var cb;
|
9
|
+
var url = 'https://business.facebook.com/';
|
10
|
+
var Referer = url + 'security/twofactor/reauth/?twofac_next=' + encodeURIComponent(url + 'content_management') + '&type=avoid_bypass&app_id=0&save_device=0';
|
11
|
+
var rt = new Promise(function (resolve, reject) {
|
12
|
+
cb = (error, token) => token ? resolve(token) : reject(error);
|
13
|
+
});
|
14
|
+
|
15
|
+
if (typeof authCode == 'function') {
|
16
|
+
callback = authCode;
|
17
|
+
authCode = '';
|
18
|
+
}
|
19
|
+
if (typeof callback == 'function') cb = callback;
|
20
|
+
if (!!ctx.access_token)
|
21
|
+
cb(null, ctx.access_token);
|
22
|
+
else
|
23
|
+
utils
|
24
|
+
.get(url + 'content_management', ctx.jar, null, ctx.globalOptions, null, {
|
25
|
+
noRef: true,
|
26
|
+
Origin: url
|
27
|
+
})
|
28
|
+
.then(function (res) {
|
29
|
+
var html = res.body;
|
30
|
+
var lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
31
|
+
return lsd;
|
32
|
+
})
|
33
|
+
.then(function (lsd) {
|
34
|
+
function submitCode(code) {
|
35
|
+
var pCb;
|
36
|
+
var rtPromise = new Promise(function (resolve) {
|
37
|
+
pCb = (error, token) => resolve(cb(error, token));
|
38
|
+
});
|
39
|
+
if (typeof code != 'string')
|
40
|
+
pCb({
|
41
|
+
error: 'submitCode',
|
42
|
+
lerror: 'code must be string',
|
43
|
+
continue: submitCode
|
44
|
+
});
|
45
|
+
else
|
46
|
+
defaultFuncs
|
47
|
+
.post(url + 'security/twofactor/reauth/enter/', ctx.jar, {
|
48
|
+
approvals_code: code,
|
49
|
+
save_device: true,
|
50
|
+
lsd
|
51
|
+
}, ctx.globalOptions, null, {
|
52
|
+
Referer,
|
53
|
+
Origin: url
|
54
|
+
})
|
55
|
+
.then(function (res) {
|
56
|
+
var { payload } = JSON.parse(res.body.split(';').pop() || '{}');
|
57
|
+
if (payload && !payload.codeConfirmed)
|
58
|
+
throw {
|
59
|
+
error: 'submitCode',
|
60
|
+
lerror: payload.message,
|
61
|
+
continue: submitCode
|
62
|
+
}
|
63
|
+
|
64
|
+
return;
|
65
|
+
})
|
66
|
+
.then(function () {
|
67
|
+
return utils
|
68
|
+
.get(url + 'content_management', ctx.jar, null, ctx.globalOptions, null, { noRef: true })
|
69
|
+
.then(function (res) {
|
70
|
+
var html = res.body;
|
71
|
+
var token = /"accessToken":"(\S+)","clientID":/g.exec(html);
|
72
|
+
|
73
|
+
return [html, token];
|
74
|
+
});
|
75
|
+
})
|
76
|
+
.then(function (res) {
|
77
|
+
if (!res[1])
|
78
|
+
throw {
|
79
|
+
error: 'token-undefined',
|
80
|
+
htmlData: res[0]
|
81
|
+
}
|
82
|
+
ctx.access_token = res[1][1];
|
83
|
+
return pCb(null, res[1][1]);
|
84
|
+
})
|
85
|
+
.catch(function (err) {
|
86
|
+
log.error('getAccess', err.error || err);
|
87
|
+
return pCb(err);
|
88
|
+
});
|
89
|
+
|
90
|
+
return rtPromise;
|
91
|
+
}
|
92
|
+
|
93
|
+
if (authCode.length == 6 && !isNaN(authCode))
|
94
|
+
submitCode(authCode.toString());
|
95
|
+
else if (typeof callback == 'function')
|
96
|
+
throw {
|
97
|
+
error: 'submitCode',
|
98
|
+
continue: submitCode
|
99
|
+
}
|
100
|
+
else
|
101
|
+
throw {
|
102
|
+
error: 'authentication code must be string or number or callback must be a function to continue'
|
103
|
+
}
|
104
|
+
})
|
105
|
+
.catch(function (err) {
|
106
|
+
log.error('getAccess', typeof callback == 'function' ? (err.error || err) : err);
|
107
|
+
return cb(err);
|
108
|
+
});
|
109
|
+
|
110
|
+
return rt;
|
111
|
+
}
|
112
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require('../utils');
|
4
|
+
var log = require('npmlog');
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
function handleAvatar(userIDs, height, width) {
|
8
|
+
var cb;
|
9
|
+
var uploads = [];
|
10
|
+
var rtPromise = new Promise(function (resolve, reject) {
|
11
|
+
cb = (error, data) => data ? resolve(data) : reject(error);
|
12
|
+
});
|
13
|
+
|
14
|
+
// Getting User Data From GraphAPI In The Loop
|
15
|
+
userIDs.map(function (v) {
|
16
|
+
var mainPromise = defaultFuncs
|
17
|
+
.get(`https://graph.facebook.com/${v}/picture?height=${height}&width=${width}&redirect=false&access_token=` + ctx.access_token, ctx.jar)
|
18
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
19
|
+
.then(function (res) {
|
20
|
+
return {
|
21
|
+
userID: v,
|
22
|
+
url: res.data.url
|
23
|
+
}
|
24
|
+
})
|
25
|
+
.catch(function (err) {
|
26
|
+
return cb(err);
|
27
|
+
});
|
28
|
+
uploads.push(mainPromise);
|
29
|
+
});
|
30
|
+
|
31
|
+
// resolve all promises
|
32
|
+
Promise
|
33
|
+
.all(uploads)
|
34
|
+
.then(function (res) {
|
35
|
+
return cb(null, res.reduce(function (Obj, { userID, url }) {
|
36
|
+
Obj[userID] = url;
|
37
|
+
return Obj;
|
38
|
+
}, {}));
|
39
|
+
})
|
40
|
+
.catch(function (err) {
|
41
|
+
return cb(err);
|
42
|
+
});
|
43
|
+
|
44
|
+
return rtPromise;
|
45
|
+
}
|
46
|
+
|
47
|
+
return function getAvatarUser(userIDs, size = [1500, 1500], callback) {
|
48
|
+
var cb;
|
49
|
+
var rtPromise = new Promise(function (resolve, reject) {
|
50
|
+
cb = (err, res) => res ? resolve(res) : reject(err);
|
51
|
+
});
|
52
|
+
|
53
|
+
(typeof size == 'string' || typeof size == 'number') ? size = [size, size] : Array.isArray(size) && size.length == 1 ? size = [size[0], size[0]] : null;
|
54
|
+
|
55
|
+
if (typeof size == 'function') {
|
56
|
+
callback = size;
|
57
|
+
size = [1500, 1500];
|
58
|
+
}
|
59
|
+
if (typeof callback == 'function') cb = callback;
|
60
|
+
if (!Array.isArray(userIDs)) userIDs = [userIDs];
|
61
|
+
var [height, width] = size;
|
62
|
+
if (!ctx.access_token) {
|
63
|
+
log.error('getAvatarUser', 'Cant get access_token');
|
64
|
+
return cb('Cant get access_token');
|
65
|
+
};
|
66
|
+
|
67
|
+
handleAvatar(userIDs, height, width)
|
68
|
+
.then(function (res) {
|
69
|
+
return cb(null, res);
|
70
|
+
})
|
71
|
+
.catch(function (err) {
|
72
|
+
log.error('getAvatarUser', err);
|
73
|
+
return cb(err);
|
74
|
+
});
|
75
|
+
|
76
|
+
return rtPromise;
|
77
|
+
}
|
78
|
+
}
|