@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,16 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { isReadableStream } = require("../../utils/constants");
|
5
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
6
|
+
const { formatID, getType } = require("../../utils/format");
|
6
7
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
8
|
function handleUpload(image, callback) {
|
8
9
|
const uploads = [];
|
9
10
|
|
10
11
|
const form = {
|
11
|
-
profile_id: ctx.
|
12
|
+
profile_id: ctx.userID,
|
12
13
|
photo_source: 57,
|
13
|
-
av: ctx.
|
14
|
+
av: ctx.userID,
|
14
15
|
file: image
|
15
16
|
};
|
16
17
|
|
@@ -22,7 +23,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
22
23
|
form,
|
23
24
|
{}
|
24
25
|
)
|
25
|
-
.then(
|
26
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
26
27
|
.then(function(resData) {
|
27
28
|
if (resData.error) {
|
28
29
|
throw resData;
|
@@ -55,7 +56,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
55
56
|
rejectFunc = reject;
|
56
57
|
});
|
57
58
|
|
58
|
-
if (!timestamp &&
|
59
|
+
if (!timestamp && getType(caption) === "Number") {
|
59
60
|
timestamp = caption;
|
60
61
|
caption = "";
|
61
62
|
}
|
@@ -63,8 +64,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
63
64
|
if (
|
64
65
|
!timestamp &&
|
65
66
|
!callback &&
|
66
|
-
(
|
67
|
-
|
67
|
+
(getType(caption) == "Function" ||
|
68
|
+
getType(caption) == "AsyncFunction")
|
68
69
|
) {
|
69
70
|
callback = caption;
|
70
71
|
caption = "";
|
@@ -79,7 +80,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
79
80
|
resolveFunc(data);
|
80
81
|
};
|
81
82
|
|
82
|
-
if (!
|
83
|
+
if (!isReadableStream(image))
|
83
84
|
return callback("Image is not a readable stream");
|
84
85
|
|
85
86
|
handleUpload(image, function(err, payload) {
|
@@ -118,7 +119,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
118
119
|
|
119
120
|
defaultFuncs
|
120
121
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
121
|
-
.then(
|
122
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
122
123
|
.then(function(resData) {
|
123
124
|
if (resData.errors) {
|
124
125
|
throw resData;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
5
|
+
const { getType } = require("../../utils/format");
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function changeBio(bio, publish, callback) {
|
8
8
|
let resolveFunc = function() {};
|
@@ -14,8 +14,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
14
14
|
|
15
15
|
if (!callback) {
|
16
16
|
if (
|
17
|
-
|
18
|
-
|
17
|
+
getType(publish) == "Function" ||
|
18
|
+
getType(publish) == "AsyncFunction"
|
19
19
|
) {
|
20
20
|
callback = publish;
|
21
21
|
} else {
|
@@ -28,11 +28,11 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
28
28
|
}
|
29
29
|
}
|
30
30
|
|
31
|
-
if (
|
31
|
+
if (getType(publish) != "Boolean") {
|
32
32
|
publish = false;
|
33
33
|
}
|
34
34
|
|
35
|
-
if (
|
35
|
+
if (getType(bio) != "String") {
|
36
36
|
bio = "";
|
37
37
|
publish = false;
|
38
38
|
}
|
@@ -40,7 +40,6 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
40
40
|
const form = {
|
41
41
|
fb_api_caller_class: "RelayModern",
|
42
42
|
fb_api_req_friendly_name: "ProfileCometSetBioMutation",
|
43
|
-
// This doc_is is valid as of May 23, 2020
|
44
43
|
doc_id: "2725043627607610",
|
45
44
|
variables: JSON.stringify({
|
46
45
|
input: {
|
@@ -58,7 +57,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
58
57
|
|
59
58
|
defaultFuncs
|
60
59
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
61
|
-
.then(
|
60
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
62
61
|
.then(function(resData) {
|
63
62
|
if (resData.errors) {
|
64
63
|
throw resData;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
5
|
+
const { getType } = require("../../utils/format");
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function handleFriendRequest(userID, accept, callback) {
|
8
|
-
if (
|
8
|
+
if (getType(accept) !== "Boolean") {
|
9
9
|
throw {
|
10
10
|
error: "Please pass a boolean as a second argument."
|
11
11
|
};
|
@@ -28,7 +28,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
28
28
|
}
|
29
29
|
|
30
30
|
const form = {
|
31
|
-
viewer_id: ctx.
|
31
|
+
viewer_id: ctx.userID,
|
32
32
|
"frefs[0]": "jwl",
|
33
33
|
floc: "friend_center_requests",
|
34
34
|
ref: "/reqs.php",
|
@@ -37,7 +37,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
37
37
|
|
38
38
|
defaultFuncs
|
39
39
|
.post("https://www.facebook.com/requests/friends/ajax/", ctx.jar, form)
|
40
|
-
.then(
|
40
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
41
41
|
.then(function(resData) {
|
42
42
|
if (resData.payload.err) {
|
43
43
|
throw {
|
package/src/api/action/logout.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
5
|
+
const { getFrom } = require("../../utils/constants");
|
6
|
+
const { saveCookies } = require("../../utils/client");
|
6
7
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
8
|
return function logout(callback) {
|
8
9
|
let resolveFunc = function() {};
|
@@ -31,7 +32,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
31
32
|
ctx.jar,
|
32
33
|
form
|
33
34
|
)
|
34
|
-
.then(
|
35
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
35
36
|
.then(function(resData) {
|
36
37
|
const elem = resData.jsmods.instances[0][2][0].filter(function(v) {
|
37
38
|
return v.value === "logout";
|
@@ -42,14 +43,14 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
42
43
|
})[0][1].__html;
|
43
44
|
|
44
45
|
const form = {
|
45
|
-
fb_dtsg:
|
46
|
-
ref:
|
47
|
-
h:
|
46
|
+
fb_dtsg: getFrom(html, '"fb_dtsg" value="', '"'),
|
47
|
+
ref: getFrom(html, '"ref" value="', '"'),
|
48
|
+
h: getFrom(html, '"h" value="', '"')
|
48
49
|
};
|
49
50
|
|
50
51
|
return defaultFuncs
|
51
52
|
.post("https://www.facebook.com/logout.php", ctx.jar, form)
|
52
|
-
.then(
|
53
|
+
.then(saveCookies(ctx.jar));
|
53
54
|
})
|
54
55
|
.then(function(res) {
|
55
56
|
if (!res.headers) {
|
@@ -58,7 +59,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
58
59
|
|
59
60
|
return defaultFuncs
|
60
61
|
.get(res.headers.location, ctx.jar)
|
61
|
-
.then(
|
62
|
+
.then(saveCookies(ctx.jar));
|
62
63
|
})
|
63
64
|
.then(function() {
|
64
65
|
ctx.loggedIn = false;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { getFrom } = require("../../utils/constants");
|
5
|
+
const { get } = require("../../utils/request")
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function refreshFb_dtsg(obj, callback) {
|
8
8
|
let resolveFunc, rejectFunc;
|
@@ -11,15 +11,15 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
11
11
|
rejectFunc = reject;
|
12
12
|
});
|
13
13
|
if (
|
14
|
-
|
15
|
-
|
14
|
+
getType(obj) === "Function" ||
|
15
|
+
getType(obj) === "AsyncFunction"
|
16
16
|
) {
|
17
17
|
callback = obj;
|
18
18
|
obj = {};
|
19
19
|
}
|
20
20
|
if (!obj) obj = {};
|
21
|
-
if (
|
22
|
-
throw
|
21
|
+
if (getType(obj) !== "Object") {
|
22
|
+
throw Error(
|
23
23
|
"The first parameter must be an object or a callback function"
|
24
24
|
);
|
25
25
|
}
|
@@ -27,19 +27,24 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
27
27
|
callback = (err, data) => (err ? rejectFunc(err) : resolveFunc(data));
|
28
28
|
}
|
29
29
|
if (Object.keys(obj).length === 0) {
|
30
|
-
|
31
|
-
|
30
|
+
get(
|
31
|
+
"https://www.facebook.com/",
|
32
|
+
ctx.jar,
|
33
|
+
null,
|
34
|
+
ctx.globalOptions,
|
35
|
+
{
|
32
36
|
noRef: true
|
33
|
-
}
|
37
|
+
}
|
38
|
+
)
|
34
39
|
.then(resData => {
|
35
|
-
const fb_dtsg =
|
40
|
+
const fb_dtsg = getFrom(
|
36
41
|
resData.body,
|
37
42
|
'["DTSGInitData",[],{"token":"',
|
38
43
|
'","'
|
39
44
|
);
|
40
|
-
const jazoest =
|
45
|
+
const jazoest = getFrom(resData.body, "jazoest=", '",');
|
41
46
|
if (!fb_dtsg) {
|
42
|
-
throw
|
47
|
+
throw Error(
|
43
48
|
"Could not find fb_dtsg in HTML after requesting Facebook."
|
44
49
|
);
|
45
50
|
}
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
1
|
"use strict";
|
3
2
|
|
4
|
-
const utils = require("../../utils");
|
5
3
|
const log = require("npmlog");
|
6
|
-
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
5
|
+
const { getType } = require("../../utils/format");
|
7
6
|
function formatData(resData) {
|
8
7
|
return {
|
9
8
|
viewer_feedback_reaction_info:
|
@@ -25,8 +24,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
25
24
|
|
26
25
|
if (!callback) {
|
27
26
|
if (
|
28
|
-
|
29
|
-
|
27
|
+
getType(type) === "Function" ||
|
28
|
+
getType(type) === "AsyncFunction"
|
30
29
|
) {
|
31
30
|
callback = type;
|
32
31
|
type = 0;
|
@@ -51,11 +50,11 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
51
50
|
angry: 8
|
52
51
|
};
|
53
52
|
|
54
|
-
if (
|
53
|
+
if (getType(type) !== "Number" && getType(type) === "String") {
|
55
54
|
type = map[type.toLowerCase()];
|
56
55
|
}
|
57
56
|
|
58
|
-
if (
|
57
|
+
if (getType(type) !== "Number" && getType(type) !== "String") {
|
59
58
|
throw {
|
60
59
|
error: "setPostReaction: Invalid reaction type"
|
61
60
|
};
|
@@ -68,14 +67,14 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
68
67
|
}
|
69
68
|
|
70
69
|
const form = {
|
71
|
-
av: ctx.
|
70
|
+
av: ctx.userID,
|
72
71
|
fb_api_caller_class: "RelayModern",
|
73
72
|
fb_api_req_friendly_name: "CometUFIFeedbackReactMutation",
|
74
73
|
doc_id: "4769042373179384",
|
75
74
|
variables: JSON.stringify({
|
76
75
|
input: {
|
77
|
-
actor_id: ctx.
|
78
|
-
feedback_id:
|
76
|
+
actor_id: ctx.userID,
|
77
|
+
feedback_id: Buffer.from("feedback:" + postID).toString("base64"),
|
79
78
|
feedback_reaction: type,
|
80
79
|
feedback_source: "OBJECT",
|
81
80
|
is_tracking_encrypted: true,
|
@@ -90,7 +89,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
90
89
|
|
91
90
|
defaultFuncs
|
92
91
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
93
|
-
.then(
|
92
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
94
93
|
.then(function(resData) {
|
95
94
|
if (resData.errors) {
|
96
95
|
throw resData;
|
@@ -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 } = require("../../utils/client");
|
6
5
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
6
|
return function unfriend(userID, callback) {
|
8
7
|
let resolveFunc = function() {};
|
@@ -27,7 +26,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
27
26
|
floc: "friends_tab",
|
28
27
|
"nctr[_mod]":
|
29
28
|
"pagelet_timeline_app_collection_" +
|
30
|
-
|
29
|
+
ctx.userID +
|
31
30
|
":2356318349:2"
|
32
31
|
};
|
33
32
|
|
@@ -37,7 +36,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
37
36
|
ctx.jar,
|
38
37
|
form
|
39
38
|
)
|
40
|
-
.then(
|
39
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
41
40
|
.then(function(resData) {
|
42
41
|
if (resData.error) {
|
43
42
|
throw resData;
|
package/src/api/http/httpGet.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { get } = require("../../utils/request");
|
5
|
+
const { getType } = require("../../utils/format");
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function httpGet(url, form, customHeader, callback, notAPI) {
|
8
8
|
let resolveFunc = function() {};
|
@@ -14,16 +14,16 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
14
14
|
});
|
15
15
|
|
16
16
|
if (
|
17
|
-
|
18
|
-
|
17
|
+
getType(form) == "Function" ||
|
18
|
+
getType(form) == "AsyncFunction"
|
19
19
|
) {
|
20
20
|
callback = form;
|
21
21
|
form = {};
|
22
22
|
}
|
23
23
|
|
24
24
|
if (
|
25
|
-
|
26
|
-
|
25
|
+
getType(customHeader) == "Function" ||
|
26
|
+
getType(customHeader) == "AsyncFunction"
|
27
27
|
) {
|
28
28
|
callback = customHeader;
|
29
29
|
customHeader = {};
|
@@ -39,8 +39,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
39
39
|
};
|
40
40
|
|
41
41
|
if (notAPI) {
|
42
|
-
|
43
|
-
.get(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
42
|
+
get(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
44
43
|
.then(function(resData) {
|
45
44
|
callback(null, resData.data.toString());
|
46
45
|
})
|
package/src/api/http/httpPost.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
const log = require("npmlog");
|
5
|
-
|
4
|
+
const { post } = require("../../utils/request");
|
5
|
+
const { getType } = require("../../utils/format");
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function httpPost(url, form, customHeader, callback, notAPI) {
|
8
8
|
let resolveFunc = function() {};
|
@@ -14,16 +14,16 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
14
14
|
});
|
15
15
|
|
16
16
|
if (
|
17
|
-
|
18
|
-
|
17
|
+
getType(form) == "Function" ||
|
18
|
+
getType(form) == "AsyncFunction"
|
19
19
|
) {
|
20
20
|
callback = form;
|
21
21
|
form = {};
|
22
22
|
}
|
23
23
|
|
24
24
|
if (
|
25
|
-
|
26
|
-
|
25
|
+
getType(customHeader) == "Function" ||
|
26
|
+
getType(customHeader) == "AsyncFunction"
|
27
27
|
) {
|
28
28
|
callback = customHeader;
|
29
29
|
customHeader = {};
|
@@ -39,8 +39,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
39
39
|
};
|
40
40
|
|
41
41
|
if (notAPI) {
|
42
|
-
|
43
|
-
.post(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
42
|
+
post(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
44
43
|
.then(function(resData) {
|
45
44
|
callback(null, resData.data.toString());
|
46
45
|
})
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
const utils = require("../../utils");
|
4
3
|
var log = require("npmlog");
|
5
|
-
|
4
|
+
const { getType } = require("../../utils/format");
|
5
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function postFormData(url, form, callback) {
|
8
8
|
var resolveFunc = function() {};
|
@@ -15,8 +15,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
15
15
|
|
16
16
|
if (
|
17
17
|
!callback &&
|
18
|
-
(
|
19
|
-
|
18
|
+
(getType(form) == "Function" ||
|
19
|
+
getType(form) == "AsyncFunction")
|
20
20
|
) {
|
21
21
|
callback = form;
|
22
22
|
form = {};
|
@@ -33,8 +33,9 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
33
33
|
|
34
34
|
defaultFuncs
|
35
35
|
.postFormData(url, ctx.jar, form, {})
|
36
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
36
37
|
.then(function(resData) {
|
37
|
-
callback(null, resData
|
38
|
+
callback(null, resData);
|
38
39
|
})
|
39
40
|
.catch(function(err) {
|
40
41
|
log.error("postFormData", err);
|