@dongdev/fca-unofficial 2.0.7 → 2.0.10
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/DOCS.md +1699 -1434
- package/README.md +250 -168
- package/package.json +54 -28
- package/src/api/action/addExternalModule.js +5 -5
- package/src/api/action/changeAvatar.js +11 -10
- package/src/api/action/changeBio.js +7 -8
- package/src/api/action/getCurrentUserID.js +1 -1
- package/src/api/action/handleFriendRequest.js +5 -5
- package/src/api/action/logout.js +9 -8
- package/src/api/action/refreshFb_dtsg.js +17 -12
- package/src/api/action/setPostReaction.js +10 -11
- package/src/api/action/unfriend.js +3 -4
- package/src/api/http/httpGet.js +7 -8
- package/src/api/http/httpPost.js +7 -8
- package/src/api/http/postFormData.js +6 -5
- package/src/api/messaging/addUserToGroup.js +0 -1
- package/src/api/messaging/changeAdminStatus.js +108 -89
- package/src/api/messaging/changeArchivedStatus.js +6 -6
- package/src/api/messaging/changeBlockedStatus.js +3 -4
- package/src/api/messaging/changeGroupImage.js +72 -117
- package/src/api/messaging/changeNickname.js +59 -48
- package/src/api/messaging/changeThreadColor.js +61 -47
- package/src/api/messaging/changeThreadEmoji.js +106 -0
- package/src/api/messaging/createNewGroup.js +5 -5
- package/src/api/messaging/createPoll.js +36 -63
- package/src/api/messaging/deleteMessage.js +4 -4
- package/src/api/messaging/deleteThread.js +4 -4
- package/src/api/messaging/forwardAttachment.js +38 -47
- package/src/api/messaging/getFriendsList.js +5 -6
- package/src/api/messaging/getMessage.js +4 -9
- package/src/api/messaging/handleMessageRequest.js +5 -5
- package/src/api/messaging/markAsDelivered.js +5 -5
- package/src/api/messaging/markAsRead.js +7 -7
- package/src/api/messaging/markAsReadAll.js +3 -4
- package/src/api/messaging/markAsSeen.js +7 -7
- package/src/api/messaging/muteThread.js +3 -4
- package/src/api/messaging/removeUserFromGroup.js +82 -56
- package/src/api/messaging/resolvePhotoUrl.js +2 -3
- package/src/api/messaging/searchForThread.js +2 -3
- package/src/api/messaging/sendMessage.js +171 -101
- package/src/api/messaging/sendMessageMqtt.js +14 -12
- package/src/api/messaging/sendTypingIndicator.js +11 -11
- package/src/api/messaging/setMessageReaction.js +68 -82
- package/src/api/messaging/setTitle.js +77 -48
- package/src/api/messaging/shareContact.js +2 -4
- package/src/api/messaging/threadColors.js +0 -3
- package/src/api/messaging/unsendMessage.js +74 -37
- package/src/api/messaging/uploadAttachment.js +11 -9
- package/src/api/socket/core/connectMqtt.js +180 -0
- package/src/api/socket/core/getSeqID.js +25 -0
- package/src/api/socket/core/getTaskResponseData.js +22 -0
- package/src/api/socket/core/markDelivery.js +12 -0
- package/src/api/socket/core/parseDelta.js +351 -0
- package/src/api/socket/detail/buildStream.js +176 -68
- package/src/api/socket/detail/constants.js +24 -0
- package/src/api/socket/listenMqtt.js +80 -1005
- package/src/api/{messaging → threads}/getThreadHistory.js +5 -22
- package/src/api/threads/getThreadInfo.js +35 -248
- package/src/api/threads/getThreadList.js +20 -20
- package/src/api/threads/getThreadPictures.js +3 -4
- package/src/api/users/getUserID.js +5 -6
- package/src/api/users/getUserInfo.js +305 -73
- package/src/api/users/getUserInfoV2.js +134 -0
- package/src/database/models/user.js +32 -0
- package/src/database/userData.js +89 -0
- package/src/utils/constants.js +12 -2
- package/src/utils/format.js +1051 -0
- package/src/utils/request.js +75 -7
- package/CHANGELOG.md +0 -52
- package/LICENSE-MIT +0 -21
- package/func/checkUpdate.js +0 -58
- package/func/logger.js +0 -112
- package/func/login.js +0 -0
- package/index.d.ts +0 -618
- package/module/config.js +0 -34
- package/module/login.js +0 -47
- package/module/loginHelper.js +0 -635
- package/module/options.js +0 -49
- package/src/api/threads/changeThreadEmoji.js +0 -55
- package/src/utils/index.js +0 -1497
@@ -1,13 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { parseAndCheckLogin, saveCookies } = require("../../utils/client");
|
5
|
+
const { getType } = require("../../utils/format");
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return async function markAsRead(threadID, read, callback) {
|
8
8
|
if (
|
9
|
-
|
10
|
-
|
9
|
+
getType(read) === "Function" ||
|
10
|
+
getType(read) === "AsyncFunction"
|
11
11
|
) {
|
12
12
|
callback = read;
|
13
13
|
read = true;
|
@@ -39,8 +39,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
39
39
|
ctx.jar,
|
40
40
|
form
|
41
41
|
)
|
42
|
-
.then(
|
43
|
-
.then(
|
42
|
+
.then(saveCookies(ctx.jar))
|
43
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs));
|
44
44
|
} catch (e) {
|
45
45
|
callback(e);
|
46
46
|
return e;
|
@@ -49,7 +49,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
49
49
|
if (resData.error) {
|
50
50
|
const err = resData.error;
|
51
51
|
log.error("markAsRead", err);
|
52
|
-
if (
|
52
|
+
if (getType(err) == "Object" && err.error === "Not logged in.") {
|
53
53
|
ctx.loggedIn = false;
|
54
54
|
}
|
55
55
|
callback(err);
|
@@ -1,8 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { parseAndCheckLogin, saveCookies } = require("../../utils/client");
|
6
5
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
6
|
return function markAsReadAll(callback) {
|
8
7
|
let resolveFunc = function() {};
|
@@ -31,8 +30,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
31
30
|
ctx.jar,
|
32
31
|
form
|
33
32
|
)
|
34
|
-
.then(
|
35
|
-
.then(
|
33
|
+
.then(saveCookies(ctx.jar))
|
34
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
36
35
|
.then(function(resData) {
|
37
36
|
if (resData.error) {
|
38
37
|
throw resData;
|
@@ -1,13 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { parseAndCheckLogin, saveCookies } = require("../../utils/client");
|
5
|
+
const { getType } = require("../../utils/format");
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function markAsRead(seen_timestamp, callback) {
|
8
8
|
if (
|
9
|
-
|
10
|
-
|
9
|
+
getType(seen_timestamp) == "Function" ||
|
10
|
+
getType(seen_timestamp) == "AsyncFunction"
|
11
11
|
) {
|
12
12
|
callback = seen_timestamp;
|
13
13
|
seen_timestamp = Date.now();
|
@@ -39,8 +39,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
39
39
|
ctx.jar,
|
40
40
|
form
|
41
41
|
)
|
42
|
-
.then(
|
43
|
-
.then(
|
42
|
+
.then(saveCookies(ctx.jar))
|
43
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
44
44
|
.then(function(resData) {
|
45
45
|
if (resData.error) {
|
46
46
|
throw resData;
|
@@ -50,7 +50,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
50
50
|
})
|
51
51
|
.catch(function(err) {
|
52
52
|
log.error("markAsSeen", err);
|
53
|
-
if (
|
53
|
+
if (getType(err) == "Object" && err.error === "Not logged in.") {
|
54
54
|
ctx.loggedIn = false;
|
55
55
|
}
|
56
56
|
return callback(err);
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
|
-
const utils = require("../../utils");
|
3
2
|
const log = require("npmlog");
|
4
|
-
|
3
|
+
const { parseAndCheckLogin, saveCookies } = require("../../utils/client");
|
5
4
|
module.exports = function(defaultFuncs, api, ctx) {
|
6
5
|
// muteSecond: -1=permanent mute, 0=unmute, 60=one minute, 3600=one hour, etc.
|
7
6
|
return function muteThread(threadID, muteSeconds, callback) {
|
@@ -32,8 +31,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
32
31
|
ctx.jar,
|
33
32
|
form
|
34
33
|
)
|
35
|
-
.then(
|
36
|
-
.then(
|
34
|
+
.then(saveCookies(ctx.jar))
|
35
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
37
36
|
.then(function(resData) {
|
38
37
|
if (resData.error) {
|
39
38
|
throw resData;
|
@@ -1,79 +1,105 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const
|
3
|
+
const { parseAndCheckLogin, getType } = require("../../utils/format");
|
4
4
|
const log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
|
8
|
-
if (
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
) {
|
13
|
-
|
14
|
-
}
|
15
|
-
if (
|
16
|
-
utils.getType(threadID) !== "Number" &&
|
17
|
-
utils.getType(threadID) !== "String"
|
18
|
-
) {
|
19
|
-
throw {
|
20
|
-
error:
|
21
|
-
"threadID should be of type Number or String and not " +
|
22
|
-
utils.getType(threadID) +
|
23
|
-
"."
|
24
|
-
};
|
25
|
-
}
|
26
|
-
if (
|
27
|
-
utils.getType(userID) !== "Number" &&
|
28
|
-
utils.getType(userID) !== "String"
|
29
|
-
) {
|
30
|
-
throw {
|
31
|
-
error:
|
32
|
-
"userID should be of type Number or String and not " +
|
33
|
-
utils.getType(userID) +
|
34
|
-
"."
|
35
|
-
};
|
36
|
-
}
|
37
|
-
|
38
|
-
let resolveFunc = function() {};
|
39
|
-
let rejectFunc = function() {};
|
40
|
-
const returnPromise = new Promise(function(resolve, reject) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
function removeUserFromGroupNoMqtt(userID, threadID, callback) {
|
8
|
+
if (!callback && (getType(threadID) === "Function" || getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
9
|
+
if (getType(threadID) !== "Number" && getType(threadID) !== "String") throw { error: "threadID should be of type Number or String and not " + getType(threadID) + "." };
|
10
|
+
if (getType(userID) !== "Number" && getType(userID) !== "String") throw { error: "userID should be of type Number or String and not " + getType(userID) + "." };
|
11
|
+
var resolveFunc = function () { };
|
12
|
+
var rejectFunc = function () { };
|
13
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
41
14
|
resolveFunc = resolve;
|
42
15
|
rejectFunc = reject;
|
43
16
|
});
|
44
|
-
|
45
17
|
if (!callback) {
|
46
|
-
callback = function(err,
|
47
|
-
if (err)
|
48
|
-
|
49
|
-
}
|
50
|
-
resolveFunc(friendList);
|
18
|
+
callback = function (err, data) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc(data);
|
51
21
|
};
|
52
22
|
}
|
53
|
-
|
54
|
-
const form = {
|
23
|
+
var form = {
|
55
24
|
uid: userID,
|
56
25
|
tid: threadID
|
57
26
|
};
|
58
|
-
|
59
27
|
defaultFuncs
|
60
28
|
.post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
|
61
|
-
.then(
|
62
|
-
.then(function(resData) {
|
63
|
-
if (!resData) {
|
64
|
-
|
65
|
-
}
|
66
|
-
if (resData.error) {
|
67
|
-
throw resData;
|
68
|
-
}
|
69
|
-
|
29
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
30
|
+
.then(function (resData) {
|
31
|
+
if (!resData) throw { error: "Remove from group failed." };
|
32
|
+
if (resData.error) throw resData;
|
70
33
|
return callback();
|
71
34
|
})
|
72
|
-
.catch(function(err) {
|
35
|
+
.catch(function (err) {
|
73
36
|
log.error("removeUserFromGroup", err);
|
74
37
|
return callback(err);
|
75
38
|
});
|
76
|
-
|
77
39
|
return returnPromise;
|
78
40
|
};
|
41
|
+
function removeUserFromGroupMqtt(userID, threadID, callback) {
|
42
|
+
if (!ctx.mqttClient) {
|
43
|
+
throw new Error("Not connected to MQTT");
|
44
|
+
}
|
45
|
+
if (!callback && (getType(threadID) === "Function" || getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
46
|
+
if (getType(threadID) !== "Number" && getType(threadID) !== "String") throw { error: "threadID should be of type Number or String and not " + getType(threadID) + "." };
|
47
|
+
if (getType(userID) !== "Number" && getType(userID) !== "String") throw { error: "userID should be of type Number or String and not " + getType(userID) + "." };
|
48
|
+
var resolveFunc = function () { };
|
49
|
+
var rejectFunc = function () { };
|
50
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
51
|
+
resolveFunc = resolve;
|
52
|
+
rejectFunc = reject;
|
53
|
+
});
|
54
|
+
if (!callback) {
|
55
|
+
callback = function (err, data) {
|
56
|
+
if (err) return rejectFunc(err);
|
57
|
+
resolveFunc(data);
|
58
|
+
};
|
59
|
+
}
|
60
|
+
let count_req = 0;
|
61
|
+
var form = JSON.stringify({
|
62
|
+
"app_id": "2220391788200892",
|
63
|
+
"payload": JSON.stringify({
|
64
|
+
epoch_id: generateOfflineThreadingID(),
|
65
|
+
tasks: [
|
66
|
+
{
|
67
|
+
failure_count: null,
|
68
|
+
label: '140',
|
69
|
+
payload: JSON.stringify({
|
70
|
+
"thread_id": threadID,
|
71
|
+
"contact_id": userID,
|
72
|
+
"sync_group": 1
|
73
|
+
}),
|
74
|
+
queue_name: 'remove_participant_v2',
|
75
|
+
task_id: Math.random() * 1001 << 0
|
76
|
+
}
|
77
|
+
],
|
78
|
+
version_id: '8798795233522156'
|
79
|
+
}),
|
80
|
+
"request_id": ++count_req,
|
81
|
+
"type": 3
|
82
|
+
});
|
83
|
+
mqttClient.publish('/ls_req', form, (err, data) => {
|
84
|
+
if (err) {
|
85
|
+
callback(err, null);
|
86
|
+
rejectFunc(false);
|
87
|
+
} else {
|
88
|
+
callback(null, true);
|
89
|
+
resolveFunc(true);
|
90
|
+
}
|
91
|
+
});
|
92
|
+
return returnPromise;
|
93
|
+
};
|
94
|
+
return function removeUserFromGroup(userID, threadID, callback) {
|
95
|
+
if (ctx.mqttClient) {
|
96
|
+
try {
|
97
|
+
removeUserFromGroupMqtt(userID, threadID, callback);
|
98
|
+
} catch (e) {
|
99
|
+
removeUserFromGroupNoMqtt(userID, threadID, callback);
|
100
|
+
}
|
101
|
+
} else {
|
102
|
+
removeUserFromGroupNoMqtt(userID, threadID, callback);
|
103
|
+
}
|
104
|
+
};
|
79
105
|
};
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
|
-
const utils = require("../../utils");
|
3
2
|
const log = require("npmlog");
|
4
|
-
|
3
|
+
const { parseAndCheckLogin, saveCookies } = require("../../utils/client");
|
5
4
|
module.exports = function(defaultFuncs, api, ctx) {
|
6
5
|
return function resolvePhotoUrl(photoID, callback) {
|
7
6
|
let resolveFunc = function() {};
|
@@ -24,7 +23,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
24
23
|
.get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
|
25
24
|
photo_id: photoID
|
26
25
|
})
|
27
|
-
.then(
|
26
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
28
27
|
.then(resData => {
|
29
28
|
if (resData.error) {
|
30
29
|
throw resData;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const
|
4
|
-
|
3
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
5
4
|
module.exports = function(defaultFuncs, api, ctx) {
|
6
5
|
return function searchForThread(name, callback) {
|
7
6
|
let resolveFunc = function() {};
|
@@ -34,7 +33,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
34
33
|
ctx.jar,
|
35
34
|
tmpForm
|
36
35
|
)
|
37
|
-
.then(
|
36
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
38
37
|
.then(function(resData) {
|
39
38
|
if (resData.error) {
|
40
39
|
throw resData;
|