@dongdev/fca-unofficial 0.0.4 → 0.0.5
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/.travis.yml +6 -6
- package/CHANGELOG.md +1 -1
- package/DOCS.md +1738 -1738
- package/LICENSE-MIT +21 -21
- package/README.md +219 -219
- package/index.js +267 -571
- package/lib/login.js +0 -0
- package/package.json +3 -3
- package/src/addExternalModule.js +19 -15
- package/src/addUserToGroup.js +113 -77
- package/src/changeAdminStatus.js +79 -47
- package/src/changeArchivedStatus.js +55 -41
- package/src/changeAvatar.js +126 -0
- package/src/changeBio.js +66 -54
- package/src/changeBlockedStatus.js +40 -29
- package/src/changeGroupImage.js +127 -101
- package/src/changeNickname.js +50 -36
- package/src/changeThreadColor.js +65 -61
- package/src/changeThreadEmoji.js +55 -41
- package/src/createNewGroup.js +86 -70
- package/src/createPoll.js +71 -59
- package/src/deleteMessage.js +56 -44
- package/src/deleteThread.js +56 -42
- package/src/forwardAttachment.js +60 -47
- package/src/getCurrentUserID.js +7 -7
- package/src/getEmojiUrl.js +29 -27
- package/src/getFriendsList.js +83 -73
- package/src/getMessage.js +796 -0
- package/src/getThreadHistory.js +666 -537
- package/src/getThreadInfo.js +232 -171
- package/src/getThreadList.js +241 -213
- package/src/getThreadPictures.js +79 -59
- package/src/getUserID.js +66 -61
- package/src/getUserInfo.js +74 -66
- package/src/handleFriendRequest.js +61 -46
- package/src/handleMessageRequest.js +65 -47
- package/src/httpGet.js +52 -44
- package/src/httpPost.js +52 -43
- package/src/httpPostFormData.js +63 -0
- package/src/listenMqtt.js +877 -709
- package/src/logout.js +62 -55
- package/src/markAsDelivered.js +58 -47
- package/src/markAsRead.js +80 -70
- package/src/markAsReadAll.js +49 -39
- package/src/markAsSeen.js +59 -48
- package/src/muteThread.js +52 -45
- package/src/postFormData.js +46 -0
- package/src/refreshFb_dtsg.js +81 -0
- package/src/removeUserFromGroup.js +79 -45
- package/src/resolvePhotoUrl.js +45 -36
- package/src/searchForThread.js +53 -42
- package/src/sendMessage.js +328 -328
- package/src/sendMessageMqtt.js +316 -0
- package/src/sendTypingIndicator.js +103 -70
- package/src/setMessageReaction.js +106 -98
- package/src/setPostReaction.js +102 -95
- package/src/setTitle.js +86 -70
- package/src/threadColors.js +131 -41
- package/src/unfriend.js +52 -42
- package/src/unsendMessage.js +49 -39
- package/src/uploadAttachment.js +95 -0
- package/utils.js +1470 -1196
- package/.gitattributes +0 -2
- package/src/Screenshot.js +0 -83
- package/src/changeAvt.js +0 -85
- package/src/getThreadHistoryDeprecated.js +0 -71
- package/src/getThreadInfoDeprecated.js +0 -56
- package/src/getThreadListDeprecated.js +0 -46
- package/src/shareContact.js +0 -46
- package/test/data/shareAttach.js +0 -146
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +0 -7
- package/test/example-config.json +0 -18
- package/test/test-page.js +0 -140
- package/test/test.js +0 -385
package/src/forwardAttachment.js
CHANGED
@@ -1,47 +1,60 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
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
|
-
|
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 forwardAttachment(attachmentID, userOrUsers, 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
|
+
attachment_id: attachmentID
|
25
|
+
};
|
26
|
+
|
27
|
+
if (utils.getType(userOrUsers) !== "Array") {
|
28
|
+
userOrUsers = [userOrUsers];
|
29
|
+
}
|
30
|
+
|
31
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
32
|
+
|
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
|
+
}
|
38
|
+
|
39
|
+
defaultFuncs
|
40
|
+
.post(
|
41
|
+
"https://www.facebook.com/mercury/attachments/forward/",
|
42
|
+
ctx.jar,
|
43
|
+
form
|
44
|
+
)
|
45
|
+
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
46
|
+
.then(function (resData) {
|
47
|
+
if (resData.error) {
|
48
|
+
throw resData;
|
49
|
+
}
|
50
|
+
|
51
|
+
return callback();
|
52
|
+
})
|
53
|
+
.catch(function (err) {
|
54
|
+
log.error("forwardAttachment", err);
|
55
|
+
return callback(err);
|
56
|
+
});
|
57
|
+
|
58
|
+
return returnPromise;
|
59
|
+
};
|
60
|
+
};
|
package/src/getCurrentUserID.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
};
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
4
|
+
return function getCurrentUserID() {
|
5
|
+
return ctx.i_userID || ctx.userID;
|
6
|
+
};
|
7
|
+
};
|
package/src/getEmojiUrl.js
CHANGED
@@ -1,27 +1,29 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
const util = require("util");
|
4
|
-
|
5
|
-
module.exports = function () {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const util = require("util");
|
4
|
+
|
5
|
+
module.exports = function () {
|
6
|
+
return function getEmojiUrl(c, size, pixelRatio) {
|
7
|
+
/*
|
8
|
+
Resolves Facebook Messenger emoji image asset URL for an emoji character.
|
9
|
+
Supported sizes are 32, 64, and 128.
|
10
|
+
Supported pixel ratios are '1.0' and '1.5' (possibly more; haven't tested)
|
11
|
+
*/
|
12
|
+
const baseUrl = "https://static.xx.fbcdn.net/images/emoji.php/v8/z%s/%s";
|
13
|
+
pixelRatio = pixelRatio || "1.0";
|
14
|
+
|
15
|
+
const ending = util.format(
|
16
|
+
"%s/%s/%s.png",
|
17
|
+
pixelRatio,
|
18
|
+
size,
|
19
|
+
c.codePointAt(0).toString(16)
|
20
|
+
);
|
21
|
+
let base = 317426846;
|
22
|
+
for (let i = 0; i < ending.length; i++) {
|
23
|
+
base = (base << 5) - base + ending.charCodeAt(i);
|
24
|
+
}
|
25
|
+
|
26
|
+
const hashed = (base & 255).toString(16);
|
27
|
+
return util.format(baseUrl, hashed, ending);
|
28
|
+
};
|
29
|
+
};
|
package/src/getFriendsList.js
CHANGED
@@ -1,73 +1,83 @@
|
|
1
|
-
"use strict";
|
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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
}
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
|
+
|
6
|
+
// [almost] copy pasted from one of FB's minified file (GenderConst)
|
7
|
+
const GENDERS = {
|
8
|
+
0: "unknown",
|
9
|
+
1: "female_singular",
|
10
|
+
2: "male_singular",
|
11
|
+
3: "female_singular_guess",
|
12
|
+
4: "male_singular_guess",
|
13
|
+
5: "mixed",
|
14
|
+
6: "neuter_singular",
|
15
|
+
7: "unknown_singular",
|
16
|
+
8: "female_plural",
|
17
|
+
9: "male_plural",
|
18
|
+
10: "neuter_plural",
|
19
|
+
11: "unknown_plural"
|
20
|
+
};
|
21
|
+
|
22
|
+
function formatData(obj) {
|
23
|
+
return Object.keys(obj).map(function (key) {
|
24
|
+
const user = obj[key];
|
25
|
+
return {
|
26
|
+
alternateName: user.alternateName,
|
27
|
+
firstName: user.firstName,
|
28
|
+
gender: GENDERS[user.gender],
|
29
|
+
userID: utils.formatID(user.id.toString()),
|
30
|
+
isFriend: user.is_friend != null && user.is_friend ? true : false,
|
31
|
+
fullName: user.name,
|
32
|
+
profilePicture: user.thumbSrc,
|
33
|
+
type: user.type,
|
34
|
+
profileUrl: user.uri,
|
35
|
+
vanity: user.vanity,
|
36
|
+
isBirthday: !!user.is_birthday
|
37
|
+
};
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
42
|
+
return function getFriendsList(callback) {
|
43
|
+
let resolveFunc = function () { };
|
44
|
+
let rejectFunc = function () { };
|
45
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
46
|
+
resolveFunc = resolve;
|
47
|
+
rejectFunc = reject;
|
48
|
+
});
|
49
|
+
|
50
|
+
if (!callback) {
|
51
|
+
callback = function (err, friendList) {
|
52
|
+
if (err) {
|
53
|
+
return rejectFunc(err);
|
54
|
+
}
|
55
|
+
resolveFunc(friendList);
|
56
|
+
};
|
57
|
+
}
|
58
|
+
|
59
|
+
defaultFuncs
|
60
|
+
.postFormData(
|
61
|
+
"https://www.facebook.com/chat/user_info_all",
|
62
|
+
ctx.jar,
|
63
|
+
{},
|
64
|
+
{ viewer: ctx.i_userID || ctx.userID }
|
65
|
+
)
|
66
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
67
|
+
.then(function (resData) {
|
68
|
+
if (!resData) {
|
69
|
+
throw { error: "getFriendsList returned empty object." };
|
70
|
+
}
|
71
|
+
if (resData.error) {
|
72
|
+
throw resData;
|
73
|
+
}
|
74
|
+
callback(null, formatData(resData.payload));
|
75
|
+
})
|
76
|
+
.catch(function (err) {
|
77
|
+
log.error("getFriendsList", err);
|
78
|
+
return callback(err);
|
79
|
+
});
|
80
|
+
|
81
|
+
return returnPromise;
|
82
|
+
};
|
83
|
+
};
|