rapido-fca 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/readme.md +39 -237
- package/src/addExternalModule.js +23 -19
- package/src/addUserToGroup.js +97 -99
- package/src/changeAdminStatus.js +62 -86
- package/src/changeArchivedStatus.js +49 -49
- package/src/changeAvatar.js +108 -118
- package/src/changeBio.js +64 -63
- package/src/changeBlockedStatus.js +38 -40
- package/src/changeGroupImage.js +126 -129
- package/src/changeNickname.js +49 -49
- package/src/changeThreadColor.js +53 -53
- package/src/changeThreadEmoji.js +45 -45
- package/src/createNewGroup.js +72 -74
- package/src/createPoll.js +59 -59
- package/src/deleteMessage.js +50 -50
- package/src/deleteThread.js +50 -50
- package/src/editMessage.js +49 -51
- package/src/forwardAttachment.js +54 -54
- package/src/getCurrentUserID.js +3 -3
- package/src/getEmojiUrl.js +17 -17
- package/src/getFriendsList.js +67 -67
- package/src/getMessage.js +767 -806
- package/src/getThreadHistory.js +642 -656
- package/src/getThreadInfo.js +1 -1
- package/src/getThreadList.js +227 -199
- package/src/getThreadPictures.js +71 -51
- package/src/getUserID.js +58 -53
- package/src/getUserInfo.js +60 -52
- package/src/handleFriendRequest.js +65 -41
- package/src/handleMessageRequest.js +60 -42
- package/src/httpGet.js +57 -49
- package/src/httpPost.js +57 -48
- package/src/httpPostFormData.js +63 -0
- package/src/listenMqtt.js +895 -827
- package/src/logout.js +61 -61
- package/src/markAsDelivered.js +53 -42
- package/src/markAsRead.js +69 -59
- package/src/markAsReadAll.js +42 -32
- package/src/markAsSeen.js +54 -43
- package/src/muteThread.js +47 -40
- package/src/refreshFb_dtsg.js +69 -77
- package/src/removeUserFromGroup.js +67 -67
- package/src/resolvePhotoUrl.js +34 -34
- package/src/searchForThread.js +43 -43
- package/src/sendMessage.js +228 -80
- package/src/sendTypingIndicator.js +88 -86
- package/src/setMessageReaction.js +109 -110
- package/src/setPostReaction.js +87 -90
- package/src/setTitle.js +72 -76
- package/src/threadColors.js +121 -121
- package/src/unfriend.js +43 -43
- package/src/unsendMessage.js +38 -34
- package/src/uploadAttachment.js +81 -79
- package/src/changeAvatarV2.js +0 -86
- package/src/changeAvt.js +0 -85
- package/src/changeBlockedStatusMqtt.js +0 -80
- package/src/changeCover.js +0 -72
- package/src/changeName.js +0 -79
- package/src/changeUsername.js +0 -59
- package/src/createCommentPost.js +0 -230
- package/src/createPost.js +0 -276
- package/src/editMessageOld.js +0 -67
- package/src/follow.js +0 -74
- package/src/getAccess.js +0 -112
- package/src/getAvatarUser.js +0 -78
- package/src/getRegion.js +0 -7
- package/src/getThreadHistoryDeprecated.js +0 -71
- package/src/getThreadInfoDeprecated.js +0 -56
- package/src/getThreadListDeprecated.js +0 -46
- package/src/getUID.js +0 -119
- package/src/searchStickers.js +0 -53
- package/src/sendMessageMqtt.js +0 -322
- package/src/sendTypingIndicatorV2.js +0 -28
- package/src/setMessageReactionMqtt.js +0 -62
- package/src/setStoryReaction.js +0 -64
- package/src/shareContact.js +0 -110
- package/src/shareLink.js +0 -59
- package/src/stopListenMqtt.js +0 -23
package/src/uploadAttachment.js
CHANGED
|
@@ -1,93 +1,95 @@
|
|
|
1
1
|
const utils = require("../utils");
|
|
2
|
+
const log = require("npmlog");
|
|
2
3
|
|
|
3
4
|
module.exports = function (defaultFuncs, api, ctx) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function upload(attachments, callback) {
|
|
6
|
+
callback = callback || function () { };
|
|
7
|
+
const uploads = [];
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
// create an array of promises
|
|
10
|
+
for (let i = 0; i < attachments.length; i++) {
|
|
11
|
+
if (!utils.isReadableStream(attachments[i])) {
|
|
12
|
+
throw {
|
|
13
|
+
error:
|
|
14
|
+
"Attachment should be a readable stream and not " +
|
|
15
|
+
utils.getType(attachments[i]) +
|
|
16
|
+
"."
|
|
17
|
+
};
|
|
18
|
+
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const form = {
|
|
21
|
+
upload_1024: attachments[i],
|
|
22
|
+
voice_clip: "true"
|
|
23
|
+
};
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
uploads.push(
|
|
26
|
+
defaultFuncs
|
|
27
|
+
.postFormData(
|
|
28
|
+
"https://upload.facebook.com/ajax/mercury/upload.php",
|
|
29
|
+
ctx.jar,
|
|
30
|
+
form,
|
|
31
|
+
{}
|
|
32
|
+
)
|
|
33
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
34
|
+
.then(function (resData) {
|
|
35
|
+
if (resData.error) {
|
|
36
|
+
throw resData;
|
|
37
|
+
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
// We have to return the data unformatted unless we want to change it
|
|
40
|
+
// back in sendMessage.
|
|
41
|
+
return resData.payload.metadata[0];
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
// resolve all promises
|
|
47
|
+
Promise
|
|
48
|
+
.all(uploads)
|
|
49
|
+
.then(function (resData) {
|
|
50
|
+
callback(null, resData);
|
|
51
|
+
})
|
|
52
|
+
.catch(function (err) {
|
|
53
|
+
log.error("uploadAttachment", err);
|
|
54
|
+
return callback(err);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
throw { error: "Please pass an attachment or an array of attachments." };
|
|
58
|
+
return function uploadAttachment(attachments, callback) {
|
|
59
|
+
if (
|
|
60
|
+
!attachments &&
|
|
61
|
+
!utils.isReadableStream(attachments) &&
|
|
62
|
+
!utils.getType(attachments) === "Array" &&
|
|
63
|
+
(utils.getType(attachments) === "Array" && !attachments.length)
|
|
64
|
+
)
|
|
65
|
+
throw { error: "Please pass an attachment or an array of attachments." };
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
let resolveFunc = function () { };
|
|
68
|
+
let rejectFunc = function () { };
|
|
69
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
70
|
+
resolveFunc = resolve;
|
|
71
|
+
rejectFunc = reject;
|
|
72
|
+
});
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
if (!callback) {
|
|
75
|
+
callback = function (err, info) {
|
|
76
|
+
if (err) {
|
|
77
|
+
return rejectFunc(err);
|
|
78
|
+
}
|
|
79
|
+
resolveFunc(info);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
if (utils.getType(attachments) !== "Array")
|
|
84
|
+
attachments = [attachments];
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
upload(attachments, (err, info) => {
|
|
87
|
+
if (err) {
|
|
88
|
+
return callback(err);
|
|
89
|
+
}
|
|
90
|
+
callback(null, info);
|
|
91
|
+
});
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
93
|
+
return returnPromise;
|
|
94
|
+
};
|
|
95
|
+
};
|
package/src/changeAvatarV2.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var utils = require("../utils");
|
|
5
|
-
// @NethWs3Dev
|
|
6
|
-
/**
|
|
7
|
-
* It posts an image to a Facebook profile
|
|
8
|
-
* @param Api - The API object
|
|
9
|
-
* @param BotID - The ID of the bot you want to post the image to.
|
|
10
|
-
* @param form - The form data that you want to send.
|
|
11
|
-
* @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
|
|
12
|
-
* {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
|
|
13
|
-
*/
|
|
14
|
-
async function postImage(Api, BotID, form) {
|
|
15
|
-
var Data = await Api.httpPostFormData(`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`, form);
|
|
16
|
-
return JSON.parse(Data.split("for (;;);")[1]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
|
20
|
-
/* Changing the profile picture of the bot. */
|
|
21
|
-
return function changeAvt(link, caption, callback) {
|
|
22
|
-
var resolveFunc = function() {};
|
|
23
|
-
var rejectFunc = function() {};
|
|
24
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
|
25
|
-
resolveFunc = resolve;
|
|
26
|
-
rejectFunc = reject;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
if (!callback) {
|
|
30
|
-
callback = function(err, data) {
|
|
31
|
-
if (err) return rejectFunc(err);
|
|
32
|
-
resolveFunc(data);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
var Fetch = require('axios')
|
|
37
|
-
Fetch.get(link, { responseType: "stream" }).then(data => {
|
|
38
|
-
postImage(api, ctx.userID, { file: data.data }).then(data => {
|
|
39
|
-
if (data.error) throw new Error({ error: data.error, des: data.error.errorDescription });
|
|
40
|
-
var form = {
|
|
41
|
-
av: ctx.userID,
|
|
42
|
-
fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
|
|
43
|
-
fb_api_caller_class: "RelayModern",
|
|
44
|
-
doc_id: "5066134240065849",
|
|
45
|
-
variables: JSON.stringify({
|
|
46
|
-
input: {
|
|
47
|
-
caption: (caption || ""),
|
|
48
|
-
existing_photo_id: data.payload.fbid,
|
|
49
|
-
expiration_time: null,
|
|
50
|
-
profile_id: ctx.userID,
|
|
51
|
-
profile_pic_method: "EXISTING",
|
|
52
|
-
profile_pic_source: "TIMELINE",
|
|
53
|
-
scaled_crop_rect: {
|
|
54
|
-
height: 1,
|
|
55
|
-
width: 1,
|
|
56
|
-
x: 0,
|
|
57
|
-
y: 0
|
|
58
|
-
},
|
|
59
|
-
skip_cropping: true,
|
|
60
|
-
actor_id: ctx.userID,
|
|
61
|
-
client_mutation_id: Math.round(Math.random() * 19).toString()
|
|
62
|
-
},
|
|
63
|
-
isPage: false,
|
|
64
|
-
isProfile: true,
|
|
65
|
-
scale: 3,
|
|
66
|
-
})
|
|
67
|
-
};
|
|
68
|
-
defaultFuncs
|
|
69
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
70
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
71
|
-
.then(function(resData) {
|
|
72
|
-
if (resData.error) throw resData;
|
|
73
|
-
else return callback(null,true)
|
|
74
|
-
})
|
|
75
|
-
.catch(function(err) {
|
|
76
|
-
return callback(err);
|
|
77
|
-
});
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
catch (e) {
|
|
82
|
-
throw e;
|
|
83
|
-
}
|
|
84
|
-
return returnPromise;
|
|
85
|
-
};
|
|
86
|
-
};
|
package/src/changeAvt.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var utils = require("../utils");
|
|
4
|
-
var log = require("npmlog");
|
|
5
|
-
/**
|
|
6
|
-
* It posts an image to a Facebook profile
|
|
7
|
-
* @param Api - The API object
|
|
8
|
-
* @param BotID - The ID of the bot you want to post the image to.
|
|
9
|
-
* @param form - The form data that you want to send.
|
|
10
|
-
* @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
|
|
11
|
-
* {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
|
|
12
|
-
*/
|
|
13
|
-
async function postImage(Api,BotID,form) {
|
|
14
|
-
var Data = await Api.httpPostFormData(`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`, form);
|
|
15
|
-
return JSON.parse(Data.split("for (;;);")[1]);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
|
19
|
-
/* Changing the profile picture of the bot. */
|
|
20
|
-
return function changeAvt(link, caption, callback) {
|
|
21
|
-
var resolveFunc = function() {};
|
|
22
|
-
var rejectFunc = function() {};
|
|
23
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
|
24
|
-
resolveFunc = resolve;
|
|
25
|
-
rejectFunc = reject;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
if (!callback) {
|
|
29
|
-
callback = function(err, data) {
|
|
30
|
-
if (err) return rejectFunc(err);
|
|
31
|
-
resolveFunc(data);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
var Fetch = require('axios')
|
|
36
|
-
Fetch.get(link, { responseType: "stream" }).then(data => {
|
|
37
|
-
postImage(api, ctx.userID, { file: data.data }).then(data => {
|
|
38
|
-
if (data.error) throw new Error({ error: data.error, des: data.error.errorDescription });
|
|
39
|
-
var form = {
|
|
40
|
-
av: ctx.userID,
|
|
41
|
-
fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
|
|
42
|
-
fb_api_caller_class: "RelayModern",
|
|
43
|
-
doc_id: "5066134240065849",
|
|
44
|
-
variables: JSON.stringify({
|
|
45
|
-
input: {
|
|
46
|
-
caption: (caption || ""),
|
|
47
|
-
existing_photo_id: data.payload.fbid,
|
|
48
|
-
expiration_time: null,
|
|
49
|
-
profile_id: ctx.userID,
|
|
50
|
-
profile_pic_method: "EXISTING",
|
|
51
|
-
profile_pic_source: "TIMELINE",
|
|
52
|
-
scaled_crop_rect: {
|
|
53
|
-
height: 1,
|
|
54
|
-
width: 1,
|
|
55
|
-
x: 0,
|
|
56
|
-
y: 0
|
|
57
|
-
},
|
|
58
|
-
skip_cropping: true,
|
|
59
|
-
actor_id: ctx.userID,
|
|
60
|
-
client_mutation_id: Math.round(Math.random() * 19).toString()
|
|
61
|
-
},
|
|
62
|
-
isPage: false,
|
|
63
|
-
isProfile: true,
|
|
64
|
-
scale: 3,
|
|
65
|
-
})
|
|
66
|
-
};
|
|
67
|
-
defaultFuncs
|
|
68
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
69
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
70
|
-
.then(function(resData) {
|
|
71
|
-
if (resData.error) throw resData;
|
|
72
|
-
else return callback(null,true)
|
|
73
|
-
})
|
|
74
|
-
.catch(function(err) {
|
|
75
|
-
return callback(err);
|
|
76
|
-
});
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
throw e;
|
|
82
|
-
}
|
|
83
|
-
return returnPromise;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
const { generateOfflineThreadingID, getCurrentTimestamp, getGUID } = require('../utils.js');
|
|
5
|
-
|
|
6
|
-
function isCallable(func) {
|
|
7
|
-
try {
|
|
8
|
-
Reflect.apply(func, null, []);
|
|
9
|
-
return true;
|
|
10
|
-
} catch (error) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
16
|
-
return function changeBlockedStatusMqtt(userID, status, type, callback) {
|
|
17
|
-
if (!ctx.mqttClient) {
|
|
18
|
-
throw new Error('Not connected to MQTT');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
ctx.wsReqNumber += 1;
|
|
22
|
-
ctx.wsTaskNumber += 1;
|
|
23
|
-
|
|
24
|
-
const label = '334';
|
|
25
|
-
let userBlockAction = 0;
|
|
26
|
-
|
|
27
|
-
switch (type) {
|
|
28
|
-
case 'messenger':
|
|
29
|
-
if (status) {
|
|
30
|
-
userBlockAction = 1; // Block
|
|
31
|
-
} else {
|
|
32
|
-
userBlockAction = 0; // Unblock
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
case 'facebook':
|
|
36
|
-
if (status) {
|
|
37
|
-
userBlockAction = 3; // Block
|
|
38
|
-
} else {
|
|
39
|
-
userBlockAction = 2; // Unblock
|
|
40
|
-
}
|
|
41
|
-
break;
|
|
42
|
-
default:
|
|
43
|
-
throw new Error('Invalid type');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const taskPayload = {
|
|
47
|
-
blockee_id: userID,
|
|
48
|
-
request_id: getGUID(),
|
|
49
|
-
user_block_action: userBlockAction,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const payload = JSON.stringify(taskPayload);
|
|
53
|
-
const version = '25393437286970779';
|
|
54
|
-
|
|
55
|
-
const task = {
|
|
56
|
-
failure_count: null,
|
|
57
|
-
label: label,
|
|
58
|
-
payload: payload,
|
|
59
|
-
queue_name: 'native_sync_block',
|
|
60
|
-
task_id: ctx.wsTaskNumber,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const content = {
|
|
64
|
-
app_id: '2220391788200892',
|
|
65
|
-
payload: JSON.stringify({
|
|
66
|
-
tasks: [task],
|
|
67
|
-
epoch_id: parseInt(generateOfflineThreadingID()),
|
|
68
|
-
version_id: version,
|
|
69
|
-
}),
|
|
70
|
-
request_id: ctx.wsReqNumber,
|
|
71
|
-
type: 3,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
if (isCallable(callback)) {
|
|
75
|
-
ctx.reqCallbacks[ctx.wsReqNumber] = callback;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
ctx.mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
|
|
79
|
-
};
|
|
80
|
-
};
|
package/src/changeCover.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('../utils');
|
|
4
|
-
|
|
5
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
-
return function changeCover(image, callback) {
|
|
7
|
-
var cb;
|
|
8
|
-
var rt = new Promise(function (resolve, reject) {
|
|
9
|
-
cb = (error, url) => error ? reject(error) : resolve(url);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
if (typeof image == 'function') {
|
|
13
|
-
callback = image;
|
|
14
|
-
image = null;
|
|
15
|
-
}
|
|
16
|
-
if (typeof callback == 'function') cb = callback;
|
|
17
|
-
if (!utils.isReadableStream(image)) {
|
|
18
|
-
var error = 'image should be a readable stream, not ' + utils.getType(image);
|
|
19
|
-
console.error('changeCover', error);
|
|
20
|
-
cb(error);
|
|
21
|
-
}
|
|
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
|
-
var 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
|
-
console.error('changeCover', err);
|
|
66
|
-
return cb(err);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return rt;
|
|
71
|
-
}
|
|
72
|
-
}
|
package/src/changeName.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var utils = require('./../utils.js');
|
|
4
|
-
var log = require('npmlog');
|
|
5
|
-
|
|
6
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
-
return function changeName(input, format, callback) {
|
|
8
|
-
var cb;
|
|
9
|
-
var 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
|
-
var error = 'name must be an object, not ' + utils.getType(input);
|
|
24
|
-
log('changeName', error);
|
|
25
|
-
return cb(error);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var { first_name, middle_name, last_name } = input;
|
|
29
|
-
if (!first_name || !last_name) {
|
|
30
|
-
console.error('changeName', 'name is not be accepted');
|
|
31
|
-
return cb('name is not be accepted');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
middle_name = middle_name || '';
|
|
35
|
-
|
|
36
|
-
var 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
|
-
var 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
|
-
console.error('changeName', err);
|
|
74
|
-
return cb(err);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return rt;
|
|
78
|
-
}
|
|
79
|
-
}
|
package/src/changeUsername.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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 changeUsername(username, callback) {
|
|
8
|
-
var cb;
|
|
9
|
-
var rt = new Promise(function (resolve, reject) {
|
|
10
|
-
cb = (error, info) => info ? resolve(info) : reject(error);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
if (typeof username == 'function') {
|
|
14
|
-
var error = 'username must be a string, and not ' + utils.getType(username);
|
|
15
|
-
console.error('changeUsername', error);
|
|
16
|
-
return username(error);
|
|
17
|
-
}
|
|
18
|
-
if (typeof callback == 'function') cb = callback;
|
|
19
|
-
if (typeof username != 'string') {
|
|
20
|
-
var error = 'username must be a string, and not ' + utils.getType(username);
|
|
21
|
-
console.error('changeUsername', error);
|
|
22
|
-
return cb(error);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var 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
|
-
console.error('changeUsername', err);
|
|
54
|
-
return cb(err);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return rt;
|
|
58
|
-
}
|
|
59
|
-
}
|