sweetheart-koja 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sweetheart-koja might be problematic. Click here for more details.
- package/StateCrypt.js +29 -0
- package/index.js +1 -0
- package/logger.js +16 -0
- package/package.json +134 -0
- package/src/addExternalModule.js +16 -0
- package/src/addUserToGroup.js +78 -0
- package/src/changeAdminStatus.js +78 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +62 -0
- package/src/changeThreadEmoji.js +42 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +60 -0
- package/src/deleteMessage.js +45 -0
- package/src/deleteThread.js +43 -0
- package/src/forwardAttachment.js +48 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +206 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +49 -0
- package/src/handleMessageRequest.js +49 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +41 -0
- package/src/listenMqtt.js +628 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +48 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +43 -0
- package/src/markAsSeen.js +51 -0
- package/src/muteThread.js +47 -0
- package/src/removeUserFromGroup.js +49 -0
- package/src/resolvePhotoUrl.js +37 -0
- package/src/searchForThread.js +43 -0
- package/src/sendMessage.js +334 -0
- package/src/sendTypingIndicator.js +80 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +74 -0
- package/src/threadColors.js +39 -0
- package/src/unfriend.js +43 -0
- package/src/unsendMessage.js +40 -0
- package/test.js +12 -0
- package/utils.js +1241 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
function formatData(data) {
|
7
|
+
var retObj = {};
|
8
|
+
|
9
|
+
for (var prop in data) {
|
10
|
+
// eslint-disable-next-line no-prototype-builtins
|
11
|
+
if (data.hasOwnProperty(prop)) {
|
12
|
+
var innerObj = data[prop];
|
13
|
+
retObj[prop] = {
|
14
|
+
name: innerObj.name,
|
15
|
+
firstName: innerObj.firstName,
|
16
|
+
vanity: innerObj.vanity,
|
17
|
+
thumbSrc: innerObj.thumbSrc,
|
18
|
+
profileUrl: innerObj.uri,
|
19
|
+
gender: innerObj.gender,
|
20
|
+
type: innerObj.type,
|
21
|
+
isFriend: innerObj.is_friend,
|
22
|
+
isBirthday: !!innerObj.is_birthday
|
23
|
+
};
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
return retObj;
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
31
|
+
return function getUserInfo(id, callback) {
|
32
|
+
var resolveFunc = function () { };
|
33
|
+
var rejectFunc = function () { };
|
34
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
35
|
+
resolveFunc = resolve;
|
36
|
+
rejectFunc = reject;
|
37
|
+
});
|
38
|
+
|
39
|
+
if (!callback) {
|
40
|
+
callback = function (err, userInfo) {
|
41
|
+
if (err) return rejectFunc(err);
|
42
|
+
resolveFunc(userInfo);
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
if (utils.getType(id) !== "Array") id = [id];
|
47
|
+
|
48
|
+
var form = {};
|
49
|
+
id.map(function (v, i) {
|
50
|
+
form["ids[" + i + "]"] = v;
|
51
|
+
});
|
52
|
+
defaultFuncs
|
53
|
+
.post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
|
54
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
55
|
+
.then(function (resData) {
|
56
|
+
if (resData.error) throw resData;
|
57
|
+
return callback(null, formatData(resData.payload.profiles));
|
58
|
+
})
|
59
|
+
.catch(function (err) {
|
60
|
+
log.error("getUserInfo", "Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !");
|
61
|
+
return callback(err);
|
62
|
+
});
|
63
|
+
|
64
|
+
return returnPromise;
|
65
|
+
};
|
66
|
+
};
|
@@ -0,0 +1,49 @@
|
|
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 handleMessageRequest(threadID, accept, callback) {
|
8
|
+
if (utils.getType(accept) !== "Boolean") throw { error: "Please pass a boolean as a second argument." };
|
9
|
+
|
10
|
+
var resolveFunc = function () { };
|
11
|
+
var rejectFunc = function () { };
|
12
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
13
|
+
resolveFunc = resolve;
|
14
|
+
rejectFunc = reject;
|
15
|
+
});
|
16
|
+
|
17
|
+
if (!callback) {
|
18
|
+
callback = function (err, data) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc(data);
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
var form = {
|
25
|
+
client: "mercury"
|
26
|
+
};
|
27
|
+
|
28
|
+
if (utils.getType(threadID) !== "Array") threadID = [threadID];
|
29
|
+
|
30
|
+
var messageBox = accept ? "inbox" : "other";
|
31
|
+
|
32
|
+
for (var i = 0; i < threadID.length; i++) form[messageBox + "[" + i + "]"] = threadID[i];
|
33
|
+
|
34
|
+
defaultFuncs
|
35
|
+
.post("https://www.facebook.com/ajax/mercury/move_thread.php", ctx.jar, form)
|
36
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
37
|
+
.then(function (resData) {
|
38
|
+
if (resData.error) throw resData;
|
39
|
+
|
40
|
+
return callback();
|
41
|
+
})
|
42
|
+
.catch(function (err) {
|
43
|
+
log.error("handleMessageRequest", err);
|
44
|
+
return callback(err);
|
45
|
+
});
|
46
|
+
|
47
|
+
return returnPromise;
|
48
|
+
};
|
49
|
+
};
|
@@ -0,0 +1,49 @@
|
|
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 handleMessageRequest(threadID, accept, callback) {
|
8
|
+
if (utils.getType(accept) !== "Boolean") throw { error: "Please pass a boolean as a second argument." };
|
9
|
+
|
10
|
+
var resolveFunc = function () { };
|
11
|
+
var rejectFunc = function () { };
|
12
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
13
|
+
resolveFunc = resolve;
|
14
|
+
rejectFunc = reject;
|
15
|
+
});
|
16
|
+
|
17
|
+
if (!callback) {
|
18
|
+
callback = function (err, data) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc(data);
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
var form = {
|
25
|
+
client: "mercury"
|
26
|
+
};
|
27
|
+
|
28
|
+
if (utils.getType(threadID) !== "Array") threadID = [threadID];
|
29
|
+
|
30
|
+
var messageBox = accept ? "inbox" : "other";
|
31
|
+
|
32
|
+
for (var i = 0; i < threadID.length; i++) form[messageBox + "[" + i + "]"] = threadID[i];
|
33
|
+
|
34
|
+
defaultFuncs
|
35
|
+
.post("https://www.facebook.com/ajax/mercury/move_thread.php", ctx.jar, form)
|
36
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
37
|
+
.then(function (resData) {
|
38
|
+
if (resData.error) throw resData;
|
39
|
+
|
40
|
+
return callback();
|
41
|
+
})
|
42
|
+
.catch(function (err) {
|
43
|
+
log.error("handleMessageRequest", err);
|
44
|
+
return callback(err);
|
45
|
+
});
|
46
|
+
|
47
|
+
return returnPromise;
|
48
|
+
};
|
49
|
+
};
|
package/src/httpGet.js
ADDED
@@ -0,0 +1,49 @@
|
|
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 httpGet(url, form, callback, notAPI) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
|
11
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
12
|
+
resolveFunc = resolve;
|
13
|
+
rejectFunc = reject;
|
14
|
+
});
|
15
|
+
|
16
|
+
if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
|
17
|
+
callback = form;
|
18
|
+
form = {};
|
19
|
+
}
|
20
|
+
|
21
|
+
form = form || {};
|
22
|
+
|
23
|
+
callback = callback || function (err, data) {
|
24
|
+
if (err) return rejectFunc(err);
|
25
|
+
resolveFunc(data);
|
26
|
+
};
|
27
|
+
|
28
|
+
if (notAPI) {
|
29
|
+
utils
|
30
|
+
.get(url, ctx.jar, form, ctx.globalOptions)
|
31
|
+
.then(resData => callback(null, resData.body.toString()))
|
32
|
+
.catch(function (err) {
|
33
|
+
log.error("httpGet", err);
|
34
|
+
return callback(err);
|
35
|
+
});
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
defaultFuncs
|
39
|
+
.get(url, ctx.jar, form)
|
40
|
+
.then(resData => callback(null, resData.body.toString()))
|
41
|
+
.catch(function (err) {
|
42
|
+
log.error("httpGet", err);
|
43
|
+
return callback(err);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
return returnPromise;
|
48
|
+
};
|
49
|
+
};
|
package/src/httpPost.js
ADDED
@@ -0,0 +1,48 @@
|
|
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 httpGet(url, form, callback, notAPI) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
|
11
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
12
|
+
resolveFunc = resolve;
|
13
|
+
rejectFunc = reject;
|
14
|
+
});
|
15
|
+
|
16
|
+
if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
|
17
|
+
callback = form;
|
18
|
+
form = {};
|
19
|
+
}
|
20
|
+
|
21
|
+
form = form || {};
|
22
|
+
|
23
|
+
callback = callback || function (err, data) {
|
24
|
+
if (err) return rejectFunc(err);
|
25
|
+
resolveFunc(data);
|
26
|
+
};
|
27
|
+
|
28
|
+
if (notAPI) {
|
29
|
+
utils
|
30
|
+
.post(url, ctx.jar, form, ctx.globalOptions)
|
31
|
+
.then(resData => callback(null, resData.body.toString()))
|
32
|
+
.catch(function (err) {
|
33
|
+
log.error("httpPost", err);
|
34
|
+
return callback(err);
|
35
|
+
});
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
defaultFuncs
|
39
|
+
.post(url, ctx.jar, form, {})
|
40
|
+
.then(resData => callback(null, resData.body.toString()))
|
41
|
+
.catch(function (err) {
|
42
|
+
log.error("httpPost", err);
|
43
|
+
return callback(err);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
return returnPromise;
|
47
|
+
};
|
48
|
+
};
|
@@ -0,0 +1,41 @@
|
|
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 httpPostFormData(url, form, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
|
11
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
12
|
+
resolveFunc = resolve;
|
13
|
+
rejectFunc = reject;
|
14
|
+
});
|
15
|
+
|
16
|
+
if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
|
17
|
+
callback = form;
|
18
|
+
form = {};
|
19
|
+
}
|
20
|
+
|
21
|
+
form = form || {};
|
22
|
+
|
23
|
+
|
24
|
+
callback = callback || function(err, data) {
|
25
|
+
if (err) return rejectFunc(err);
|
26
|
+
resolveFunc(data);
|
27
|
+
};
|
28
|
+
|
29
|
+
defaultFuncs
|
30
|
+
.postFormData(url, ctx.jar, form)
|
31
|
+
.then(function(resData) {
|
32
|
+
callback(null, resData.body.toString());
|
33
|
+
})
|
34
|
+
.catch(function(err) {
|
35
|
+
log.error("httpPostFormData", err);
|
36
|
+
return callback(err);
|
37
|
+
});
|
38
|
+
|
39
|
+
return returnPromise;
|
40
|
+
};
|
41
|
+
};
|