nexus-fca 1.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/CHANGELOG.md +1 -0
- package/DOCS.md +2047 -0
- package/Fca_Database/database.sqlite +0 -0
- package/LICENSE-MIT +21 -0
- package/README.md +240 -0
- package/docs/README.md +9 -0
- package/docs/addExternalModule.md +15 -0
- package/docs/addUserToGroup.md +20 -0
- package/docs/changeAdminStatus.md +21 -0
- package/docs/changeArchivedStatus.md +19 -0
- package/docs/changeAvatar.md +21 -0
- package/docs/changeAvatarV2.md +18 -0
- package/docs/changeBio.md +15 -0
- package/docs/changeBlockedStatus.md +16 -0
- package/docs/changeBlockedStatusMqtt.md +16 -0
- package/docs/changeCover.md +15 -0
- package/docs/changeGroupImage.md +16 -0
- package/docs/changeName.md +18 -0
- package/docs/changeNickname.md +17 -0
- package/docs/changeThreadColor.md +16 -0
- package/docs/changeThreadEmoji.md +16 -0
- package/docs/changeUsername.md +15 -0
- package/docs/createCommentPost.md +16 -0
- package/docs/createNewGroup.md +16 -0
- package/docs/createPoll.md +17 -0
- package/docs/createPost.md +15 -0
- package/docs/deleteMessage.md +15 -0
- package/docs/deleteThread.md +15 -0
- package/docs/editMessage.md +16 -0
- package/docs/follow.md +15 -0
- package/docs/forwardAttachment.md +16 -0
- package/docs/getAccess.md +17 -0
- package/docs/getAvatarUser.md +15 -0
- package/docs/getBotInitialData.md +14 -0
- package/docs/getCtx.md +14 -0
- package/docs/getCurrentUserID.md +12 -0
- package/docs/getEmojiUrl.md +17 -0
- package/docs/getFriendsList.md +14 -0
- package/docs/getMessage.md +15 -0
- package/docs/getOptions.md +14 -0
- package/docs/getRegion.md +14 -0
- package/docs/getThreadHistory.md +17 -0
- package/docs/getThreadHistoryDeprecated.md +17 -0
- package/docs/getThreadInfo.md +15 -0
- package/docs/getThreadInfoDeprecated.md +17 -0
- package/docs/getThreadList.md +17 -0
- package/docs/getThreadListDeprecated.md +17 -0
- package/docs/getThreadPictures.md +17 -0
- package/docs/getUID.md +15 -0
- package/docs/getUserID.md +15 -0
- package/docs/getUserInfo.md +15 -0
- package/docs/handleFriendRequest.md +16 -0
- package/docs/handleMessageRequest.md +16 -0
- package/docs/httpGet.md +15 -0
- package/docs/httpPost.md +16 -0
- package/docs/httpPostFormData.md +16 -0
- package/docs/listenMqtt.md +17 -0
- package/docs/listenNotification.md +14 -0
- package/docs/logout.md +14 -0
- package/docs/markAsDelivered.md +16 -0
- package/docs/markAsRead.md +16 -0
- package/docs/markAsReadAll.md +14 -0
- package/docs/markAsSeen.md +15 -0
- package/docs/muteThread.md +16 -0
- package/docs/pinMessage.md +17 -0
- package/docs/postFormData.md +16 -0
- package/docs/refreshFb_dtsg.md +14 -0
- package/docs/removeUserFromGroup.md +16 -0
- package/docs/resolvePhotoUrl.md +15 -0
- package/docs/searchForThread.md +15 -0
- package/docs/searchStickers.md +15 -0
- package/docs/sendComment.md +16 -0
- package/docs/sendMessage.md +16 -0
- package/docs/sendMessageMqtt.md +16 -0
- package/docs/sendTypingIndicator.md +15 -0
- package/docs/setMessageReaction.md +17 -0
- package/docs/setMessageReactionMqtt.md +16 -0
- package/docs/setPostReaction.md +16 -0
- package/docs/setProfileGuard.md +15 -0
- package/docs/setStoryReaction.md +16 -0
- package/docs/setTitle.md +16 -0
- package/docs/shareContact.md +16 -0
- package/docs/shareLink.md +16 -0
- package/docs/stopListenMqtt.md +8 -0
- package/docs/threadColors.md +11 -0
- package/docs/unfriend.md +15 -0
- package/docs/unsendMessage.md +15 -0
- package/docs/uploadAttachment.md +15 -0
- package/fca-config.json +7 -0
- package/index.d.ts +618 -0
- package/index.js +361 -0
- package/lib/database/models/index.js +47 -0
- package/lib/database/models/thread.js +31 -0
- package/lib/database/threadData.js +93 -0
- package/lib/logger.js +24 -0
- package/lib/login.js +0 -0
- package/package.json +90 -0
- package/src/addExternalModule.js +19 -0
- package/src/addUserToGroup.js +113 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +55 -0
- package/src/changeAvatar.js +126 -0
- package/src/changeAvatarV2.js +77 -0
- package/src/changeBio.js +77 -0
- package/src/changeBlockedStatus.js +47 -0
- package/src/changeBlockedStatusMqtt.js +71 -0
- package/src/changeCover.js +72 -0
- package/src/changeGroupImage.js +132 -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 +58 -0
- package/src/createCommentPost.js +225 -0
- package/src/createNewGroup.js +86 -0
- package/src/createPoll.js +71 -0
- package/src/createPost.js +276 -0
- package/src/deleteMessage.js +56 -0
- package/src/deleteThread.js +56 -0
- package/src/editMessage.js +57 -0
- package/src/follow.js +54 -0
- package/src/forwardAttachment.js +60 -0
- package/src/getAccess.js +67 -0
- package/src/getAvatarUser.js +56 -0
- package/src/getBotInitialData.js +37 -0
- package/src/getCtx.js +6 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +29 -0
- package/src/getFriendsList.js +83 -0
- package/src/getMessage.js +796 -0
- package/src/getOptions.js +6 -0
- package/src/getRegion.js +8 -0
- package/src/getThreadHistory.js +666 -0
- package/src/getThreadHistoryDeprecated.js +55 -0
- package/src/getThreadInfo.js +535 -0
- package/src/getThreadInfoDeprecated.js +49 -0
- package/src/getThreadList.js +192 -0
- package/src/getThreadListDeprecated.js +54 -0
- package/src/getThreadPictures.js +79 -0
- package/src/getUID.js +67 -0
- package/src/getUserID.js +66 -0
- package/src/getUserInfo.js +80 -0
- package/src/handleFriendRequest.js +61 -0
- package/src/handleMessageRequest.js +65 -0
- package/src/httpGet.js +57 -0
- package/src/httpPost.js +57 -0
- package/src/httpPostFormData.js +63 -0
- package/src/listenMqtt.js +1039 -0
- package/src/listenNotification.js +65 -0
- package/src/logout.js +75 -0
- package/src/markAsDelivered.js +58 -0
- package/src/markAsRead.js +80 -0
- package/src/markAsReadAll.js +50 -0
- package/src/markAsSeen.js +59 -0
- package/src/muteThread.js +52 -0
- package/src/pinMessage.js +59 -0
- package/src/postFormData.js +46 -0
- package/src/refreshFb_dtsg.js +66 -0
- package/src/removeUserFromGroup.js +79 -0
- package/src/resolvePhotoUrl.js +45 -0
- package/src/searchForThread.js +53 -0
- package/src/searchStickers.js +51 -0
- package/src/sendComment.js +63 -0
- package/src/sendMessage.js +328 -0
- package/src/sendMessageMqtt.js +316 -0
- package/src/sendTypingIndicator.js +103 -0
- package/src/setMessageReaction.js +119 -0
- package/src/setMessageReactionMqtt.js +61 -0
- package/src/setPostReaction.js +109 -0
- package/src/setProfileGuard.js +45 -0
- package/src/setStoryReaction.js +62 -0
- package/src/setTitle.js +86 -0
- package/src/shareContact.js +49 -0
- package/src/shareLink.js +59 -0
- package/src/stopListenMqtt.js +21 -0
- package/src/threadColors.js +131 -0
- package/src/unfriend.js +52 -0
- package/src/unsendMessage.js +49 -0
- package/src/uploadAttachment.js +95 -0
- package/utils.js +1432 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Nexus-FCA: Advanced and Safe Facebook Chat API
|
|
2
|
+
// changeCover.js - Change Facebook cover photo
|
|
3
|
+
|
|
4
|
+
const utils = require('../utils');
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function changeCover(image, callback) {
|
|
8
|
+
let cb;
|
|
9
|
+
const rt = new Promise(function (resolve, reject) {
|
|
10
|
+
cb = (error, url) => error ? reject(error) : resolve(url);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (typeof image == 'function') {
|
|
14
|
+
callback = image;
|
|
15
|
+
image = null;
|
|
16
|
+
}
|
|
17
|
+
if (typeof callback == 'function') cb = callback;
|
|
18
|
+
if (!utils.isReadableStream(image)) {
|
|
19
|
+
const error = 'image should be a readable stream, not ' + utils.getType(image);
|
|
20
|
+
utils.error('changeCover', error);
|
|
21
|
+
cb(error);
|
|
22
|
+
} else {
|
|
23
|
+
defaultFuncs
|
|
24
|
+
.postFormData('https://www.facebook.com/profile/picture/upload/', ctx.jar, {
|
|
25
|
+
profile_id: ctx.userID,
|
|
26
|
+
photo_source: 57,
|
|
27
|
+
av: ctx.userID,
|
|
28
|
+
file: image
|
|
29
|
+
})
|
|
30
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
31
|
+
.then(function (res) {
|
|
32
|
+
if (res.error || res.errors || !res.payload)
|
|
33
|
+
throw res;
|
|
34
|
+
|
|
35
|
+
const vari = {
|
|
36
|
+
input: {
|
|
37
|
+
attribution_id_v2: `ProfileCometCollectionRoot.react,comet.profile.collection.photos_by,unexpected,${Date.now()},770083,,;ProfileCometCollectionRoot.react,comet.profile.collection.photos_albums,unexpected,${Date.now()},470774,,;ProfileCometCollectionRoot.react,comet.profile.collection.photos,unexpected,${Date.now()},94740,,;ProfileCometCollectionRoot.react,comet.profile.collection.saved_reels_on_profile,unexpected,${Date.now()},89669,,;ProfileCometCollectionRoot.react,comet.profile.collection.reels_tab,unexpected,${Date.now()},152201,,`,
|
|
38
|
+
cover_photo_id: res.payload.fbid,
|
|
39
|
+
focus: {
|
|
40
|
+
x: 0.5,
|
|
41
|
+
y: 1
|
|
42
|
+
},
|
|
43
|
+
target_user_id: ctx.userID,
|
|
44
|
+
actor_id: ctx.userID,
|
|
45
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
|
46
|
+
},
|
|
47
|
+
scale: 1,
|
|
48
|
+
contextualProfileContext: null
|
|
49
|
+
};
|
|
50
|
+
return defaultFuncs
|
|
51
|
+
.post('https://www.facebook.com/api/graphql', ctx.jar, {
|
|
52
|
+
doc_id: 8247793861913071,
|
|
53
|
+
server_timestamps: true,
|
|
54
|
+
fb_api_req_friendly_name: 'ProfileCometCoverPhotoUpdateMutation',
|
|
55
|
+
variables: JSON.stringify(vari)
|
|
56
|
+
})
|
|
57
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
|
58
|
+
})
|
|
59
|
+
.then(function (res) {
|
|
60
|
+
if (res.errors)
|
|
61
|
+
throw res;
|
|
62
|
+
return cb(null, res.data.user_update_cover_photo.user.cover_photo.photo.url);
|
|
63
|
+
})
|
|
64
|
+
.catch(function (err) {
|
|
65
|
+
utils.error('changeCover', err);
|
|
66
|
+
return cb(err);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return rt;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
const log = require("npmlog");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
function handleUpload(image, callback) {
|
|
8
|
+
const uploads = [];
|
|
9
|
+
|
|
10
|
+
const form = {
|
|
11
|
+
images_only: "true",
|
|
12
|
+
"attachment[]": image
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
uploads.push(
|
|
16
|
+
defaultFuncs
|
|
17
|
+
.postFormData(
|
|
18
|
+
"https://upload.facebook.com/ajax/mercury/upload.php",
|
|
19
|
+
ctx.jar,
|
|
20
|
+
form,
|
|
21
|
+
{}
|
|
22
|
+
)
|
|
23
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
24
|
+
.then(function (resData) {
|
|
25
|
+
if (resData.error) {
|
|
26
|
+
throw resData;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return resData.payload.metadata[0];
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// resolve all promises
|
|
34
|
+
Promise
|
|
35
|
+
.all(uploads)
|
|
36
|
+
.then(function (resData) {
|
|
37
|
+
callback(null, resData);
|
|
38
|
+
})
|
|
39
|
+
.catch(function (err) {
|
|
40
|
+
log.error("handleUpload", err);
|
|
41
|
+
return callback(err);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return function changeGroupImage(image, threadID, callback) {
|
|
46
|
+
if (
|
|
47
|
+
!callback &&
|
|
48
|
+
(utils.getType(threadID) === "Function" ||
|
|
49
|
+
utils.getType(threadID) === "AsyncFunction")
|
|
50
|
+
) {
|
|
51
|
+
throw { error: "please pass a threadID as a second argument." };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!utils.isReadableStream(image)) {
|
|
55
|
+
throw { error: "please pass a readable stream as a first argument." };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let resolveFunc = function () { };
|
|
59
|
+
let rejectFunc = function () { };
|
|
60
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
61
|
+
resolveFunc = resolve;
|
|
62
|
+
rejectFunc = reject;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (!callback) {
|
|
66
|
+
callback = function (err) {
|
|
67
|
+
if (err) {
|
|
68
|
+
return rejectFunc(err);
|
|
69
|
+
}
|
|
70
|
+
resolveFunc();
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const messageAndOTID = utils.generateOfflineThreadingID();
|
|
75
|
+
const form = {
|
|
76
|
+
client: "mercury",
|
|
77
|
+
action_type: "ma-type:log-message",
|
|
78
|
+
author: "fbid:" + (ctx.i_userID || ctx.userID),
|
|
79
|
+
author_email: "",
|
|
80
|
+
ephemeral_ttl_mode: "0",
|
|
81
|
+
is_filtered_content: false,
|
|
82
|
+
is_filtered_content_account: false,
|
|
83
|
+
is_filtered_content_bh: false,
|
|
84
|
+
is_filtered_content_invalid_app: false,
|
|
85
|
+
is_filtered_content_quasar: false,
|
|
86
|
+
is_forward: false,
|
|
87
|
+
is_spoof_warning: false,
|
|
88
|
+
is_unread: false,
|
|
89
|
+
log_message_type: "log:thread-image",
|
|
90
|
+
manual_retry_cnt: "0",
|
|
91
|
+
message_id: messageAndOTID,
|
|
92
|
+
offline_threading_id: messageAndOTID,
|
|
93
|
+
source: "source:chat:web",
|
|
94
|
+
"source_tags[0]": "source:chat",
|
|
95
|
+
status: "0",
|
|
96
|
+
thread_fbid: threadID,
|
|
97
|
+
thread_id: "",
|
|
98
|
+
timestamp: Date.now(),
|
|
99
|
+
timestamp_absolute: "Today",
|
|
100
|
+
timestamp_relative: utils.generateTimestampRelative(),
|
|
101
|
+
timestamp_time_passed: "0"
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
handleUpload(image, function (err, payload) {
|
|
105
|
+
if (err) {
|
|
106
|
+
return callback(err);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
form["thread_image_id"] = payload[0]["image_id"];
|
|
110
|
+
form["thread_id"] = threadID;
|
|
111
|
+
|
|
112
|
+
defaultFuncs
|
|
113
|
+
.post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
|
|
114
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
115
|
+
.then(function (resData) {
|
|
116
|
+
// check for errors here
|
|
117
|
+
|
|
118
|
+
if (resData.error) {
|
|
119
|
+
throw resData;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return callback();
|
|
123
|
+
})
|
|
124
|
+
.catch(function (err) {
|
|
125
|
+
log.error("changeGroupImage", err);
|
|
126
|
+
return callback(err);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
return returnPromise;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Nexus-FCA: Advanced and Safe Facebook Chat API
|
|
2
|
+
// changeName.js - Change Facebook profile name
|
|
3
|
+
|
|
4
|
+
const utils = require('../utils');
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function changeName(input, format, callback) {
|
|
8
|
+
let cb;
|
|
9
|
+
const rt = new Promise(function (resolve, reject) {
|
|
10
|
+
cb = error => error ? reject(error) : resolve();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (typeof input == 'function') {
|
|
14
|
+
callback = input;
|
|
15
|
+
input = null;
|
|
16
|
+
}
|
|
17
|
+
if (typeof format == 'function') {
|
|
18
|
+
callback = format;
|
|
19
|
+
format = 'complete';
|
|
20
|
+
}
|
|
21
|
+
if (typeof callback == 'function') cb = callback;
|
|
22
|
+
if (utils.getType(input) != 'Object') {
|
|
23
|
+
const error = 'name must be an object, not ' + utils.getType(input);
|
|
24
|
+
utils.error('changeName', error);
|
|
25
|
+
return cb(error);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let { first_name, middle_name, last_name } = input;
|
|
29
|
+
if (!first_name || !last_name) {
|
|
30
|
+
utils.error('changeName', 'name is not be accepted');
|
|
31
|
+
return cb('name is not be accepted');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
middle_name = middle_name || '';
|
|
35
|
+
|
|
36
|
+
const full_name =
|
|
37
|
+
format == 'complete' ? last_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + first_name :
|
|
38
|
+
format == 'standard' ? last_name + ' ' + first_name :
|
|
39
|
+
format == 'reversed' ? first_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + last_name :
|
|
40
|
+
last_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + first_name;
|
|
41
|
+
|
|
42
|
+
const form = {
|
|
43
|
+
fb_api_caller_class: 'RelayModern',
|
|
44
|
+
fb_api_req_friendly_name: 'useFXIMUpdateNameMutation',
|
|
45
|
+
variables: JSON.stringify({
|
|
46
|
+
client_mutation_id: utils.getGUID(),
|
|
47
|
+
family_device_id: "device_id_fetch_datr",
|
|
48
|
+
identity_ids: [ctx.userID],
|
|
49
|
+
full_name,
|
|
50
|
+
first_name,
|
|
51
|
+
middle_name,
|
|
52
|
+
last_name,
|
|
53
|
+
interface: 'FB_WEB'
|
|
54
|
+
}),
|
|
55
|
+
server_timestamps: true,
|
|
56
|
+
doc_id: '5763510853763960'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
defaultFuncs
|
|
60
|
+
.post('https://accountscenter.facebook.com/api/graphql/', ctx.jar, form, null, null, {
|
|
61
|
+
Origin: 'https://accountscenter.facebook.com',
|
|
62
|
+
Referer: `https://accountscenter.facebook.com/profiles/${ctx.userID}/name`
|
|
63
|
+
})
|
|
64
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
65
|
+
.then(function (res) {
|
|
66
|
+
if (res.errors)
|
|
67
|
+
throw res;
|
|
68
|
+
else if (res.data.fxim_update_identity_name.error)
|
|
69
|
+
throw res.data.fxim_update_identity_name.error;
|
|
70
|
+
return cb();
|
|
71
|
+
})
|
|
72
|
+
.catch(function (err) {
|
|
73
|
+
utils.error('changeName', err);
|
|
74
|
+
return cb(err);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return rt;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
const log = require("npmlog");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function changeNickname(nickname, threadID, participantID, callback) {
|
|
8
|
+
let resolveFunc = function () { };
|
|
9
|
+
let rejectFunc = function () { };
|
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
if (!callback) {
|
|
15
|
+
callback = function (err) {
|
|
16
|
+
if (err) {
|
|
17
|
+
return rejectFunc(err);
|
|
18
|
+
}
|
|
19
|
+
resolveFunc();
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const form = {
|
|
24
|
+
nickname: nickname,
|
|
25
|
+
participant_id: participantID,
|
|
26
|
+
thread_or_other_fbid: threadID
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
defaultFuncs
|
|
30
|
+
.post(
|
|
31
|
+
"https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
|
|
32
|
+
ctx.jar,
|
|
33
|
+
form
|
|
34
|
+
)
|
|
35
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
36
|
+
.then(function (resData) {
|
|
37
|
+
if (resData.error === 1545014) {
|
|
38
|
+
throw { error: "Trying to change nickname of user isn't in thread" };
|
|
39
|
+
}
|
|
40
|
+
if (resData.error === 1357031) {
|
|
41
|
+
throw {
|
|
42
|
+
error:
|
|
43
|
+
"Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname."
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (resData.error) {
|
|
47
|
+
throw resData;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return callback();
|
|
51
|
+
})
|
|
52
|
+
.catch(function (err) {
|
|
53
|
+
log.error("changeNickname", err);
|
|
54
|
+
return callback(err);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return returnPromise;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
const log = require("npmlog");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function changeThreadColor(color, threadID, callback) {
|
|
8
|
+
let resolveFunc = function () { };
|
|
9
|
+
let rejectFunc = function () { };
|
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!callback) {
|
|
16
|
+
callback = function (err) {
|
|
17
|
+
if (err) {
|
|
18
|
+
return rejectFunc(err);
|
|
19
|
+
}
|
|
20
|
+
resolveFunc(err);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!isNaN(color)) {
|
|
25
|
+
color = color.toString();
|
|
26
|
+
}
|
|
27
|
+
const validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
|
|
28
|
+
|
|
29
|
+
const form = {
|
|
30
|
+
dpr: 1,
|
|
31
|
+
queries: JSON.stringify({
|
|
32
|
+
o0: {
|
|
33
|
+
//This doc_id is valid as of January 31, 2020
|
|
34
|
+
doc_id: "1727493033983591",
|
|
35
|
+
query_params: {
|
|
36
|
+
data: {
|
|
37
|
+
actor_id: ctx.i_userID || ctx.userID,
|
|
38
|
+
client_mutation_id: "0",
|
|
39
|
+
source: "SETTINGS",
|
|
40
|
+
theme_id: validatedColor,
|
|
41
|
+
thread_id: threadID
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
defaultFuncs
|
|
49
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
|
50
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
51
|
+
.then(function (resData) {
|
|
52
|
+
if (resData[resData.length - 1].error_results > 0) {
|
|
53
|
+
throw new utils.CustomError(resData[0].o0.errors);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return callback();
|
|
57
|
+
})
|
|
58
|
+
.catch(function (err) {
|
|
59
|
+
log.error("changeThreadColor", err);
|
|
60
|
+
return callback(err);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return returnPromise;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
const log = require("npmlog");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function changeThreadEmoji(emoji, threadID, callback) {
|
|
8
|
+
let resolveFunc = function () { };
|
|
9
|
+
let rejectFunc = function () { };
|
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!callback) {
|
|
16
|
+
callback = function (err) {
|
|
17
|
+
if (err) {
|
|
18
|
+
return rejectFunc(err);
|
|
19
|
+
}
|
|
20
|
+
resolveFunc();
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const form = {
|
|
24
|
+
emoji_choice: emoji,
|
|
25
|
+
thread_or_other_fbid: threadID
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
defaultFuncs
|
|
29
|
+
.post(
|
|
30
|
+
"https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",
|
|
31
|
+
ctx.jar,
|
|
32
|
+
form
|
|
33
|
+
)
|
|
34
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
35
|
+
.then(function (resData) {
|
|
36
|
+
if (resData.error === 1357031) {
|
|
37
|
+
throw {
|
|
38
|
+
error:
|
|
39
|
+
"Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji."
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (resData.error) {
|
|
43
|
+
throw resData;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return callback();
|
|
47
|
+
})
|
|
48
|
+
.catch(function (err) {
|
|
49
|
+
log.error("changeThreadEmoji", err);
|
|
50
|
+
return callback(err);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return returnPromise;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Nexus-FCA: Advanced and Safe Facebook Chat API
|
|
2
|
+
// changeUsername.js - Change your Facebook username
|
|
3
|
+
|
|
4
|
+
const utils = require('../utils');
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function changeUsername(username, callback) {
|
|
8
|
+
let cb;
|
|
9
|
+
let rt = new Promise(function (resolve, reject) {
|
|
10
|
+
cb = (error, info) => info ? resolve(info) : reject(error);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (typeof username == 'function') {
|
|
14
|
+
let error = 'username must be a string, and not ' + utils.getType(username);
|
|
15
|
+
utils.error('changeUsername', error);
|
|
16
|
+
return username(error);
|
|
17
|
+
}
|
|
18
|
+
if (typeof callback == 'function') cb = callback;
|
|
19
|
+
if (typeof username != 'string') {
|
|
20
|
+
let error = 'username must be a string, and not ' + utils.getType(username);
|
|
21
|
+
utils.error('changeUsername', error);
|
|
22
|
+
return cb(error);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let form = {
|
|
26
|
+
fb_api_caller_class: 'RelayModern',
|
|
27
|
+
fb_api_req_friendly_name: 'useFXIMUpdateUsernameMutation',
|
|
28
|
+
variables: JSON.stringify({
|
|
29
|
+
client_mutation_id: utils.getGUID(),
|
|
30
|
+
family_device_id: "device_id_fetch_datr",
|
|
31
|
+
identity_ids: [ctx.userID],
|
|
32
|
+
username,
|
|
33
|
+
interface: "FB_WEB"
|
|
34
|
+
}),
|
|
35
|
+
server_timestamps: true,
|
|
36
|
+
doc_id: 5737739449613305
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
defaultFuncs
|
|
40
|
+
.post('https://accountscenter.facebook.com/api/graphql/', ctx.jar, form, null, null, {
|
|
41
|
+
Origin: 'https://accountscenter.facebook.com',
|
|
42
|
+
Referer: `https://accountscenter.facebook.com/profiles/${ctx.userID}/username/?entrypoint=fb_account_center`
|
|
43
|
+
})
|
|
44
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
45
|
+
.then(function (res) {
|
|
46
|
+
if (res.errors)
|
|
47
|
+
throw res;
|
|
48
|
+
else if (res.data.fxim_update_identity_username.error)
|
|
49
|
+
throw res.data.fxim_update_identity_username.error;
|
|
50
|
+
return cb();
|
|
51
|
+
})
|
|
52
|
+
.catch(function (err) {
|
|
53
|
+
utils.error('changeUsername', err);
|
|
54
|
+
return cb(err);
|
|
55
|
+
});
|
|
56
|
+
return rt;
|
|
57
|
+
}
|
|
58
|
+
}
|