node-ainzfb-new 1.6.2902-test → 1.6.2911-test

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/package.json +7 -7
  2. package/src/addExternalModule.js +13 -6
  3. package/src/addUserToGroup.js +35 -12
  4. package/src/changeAdminStatus.js +32 -16
  5. package/src/changeArchivedStatus.js +15 -9
  6. package/src/changeAvt.js +75 -69
  7. package/src/changeBio.js +12 -8
  8. package/src/changeBlockedStatus.js +14 -8
  9. package/src/changeGroupImage.js +27 -13
  10. package/src/changeNickname.js +19 -10
  11. package/src/changeThreadColor.js +15 -10
  12. package/src/changeThreadEmoji.js +17 -9
  13. package/src/createNewGroup.js +18 -10
  14. package/src/createPoll.js +16 -11
  15. package/src/deleteMessage.js +16 -10
  16. package/src/deleteThread.js +16 -10
  17. package/src/forwardAttachment.js +14 -9
  18. package/src/getAccessToken.js +21 -21
  19. package/src/getCurrentUserID.js +1 -1
  20. package/src/getEmojiUrl.js +3 -2
  21. package/src/getFriendsList.js +18 -10
  22. package/src/getMessage.js +52 -48
  23. package/src/getThreadHistory.js +156 -59
  24. package/src/getThreadHistoryDeprecated.js +26 -15
  25. package/src/getThreadInfo.js +3423 -18
  26. package/src/getThreadInfoDeprecated.js +25 -13
  27. package/src/getThreadList.js +112 -53
  28. package/src/getThreadListDeprecated.js +30 -12
  29. package/src/getThreadPictures.js +25 -13
  30. package/src/getUserID.js +7 -7
  31. package/src/getUserInfo.js +12 -9
  32. package/src/getUserInfoV2.js +19 -22
  33. package/src/handleFriendRequest.js +10 -9
  34. package/src/handleMessageRequest.js +16 -10
  35. package/src/httpGet.js +18 -13
  36. package/src/httpPost.js +18 -13
  37. package/src/httpPostFormData.js +14 -9
  38. package/src/listenMqtt.js +1218 -571
  39. package/src/logout.js +18 -13
  40. package/src/markAsDelivered.js +16 -10
  41. package/src/markAsRead.js +36 -24
  42. package/src/markAsReadAll.js +14 -10
  43. package/src/markAsSeen.js +18 -11
  44. package/src/muteThread.js +12 -8
  45. package/src/removeUserFromGroup.js +33 -10
  46. package/src/resolvePhotoUrl.js +8 -6
  47. package/src/searchForThread.js +13 -8
  48. package/src/sendMessage.js +172 -78
  49. package/src/sendTypingIndicator.js +29 -14
  50. package/src/setMessageReaction.js +13 -8
  51. package/src/setPostReaction.js +97 -95
  52. package/src/setTitle.js +18 -12
  53. package/src/threadColors.js +17 -17
  54. package/src/unfriend.js +14 -9
  55. package/src/unsendMessage.js +7 -7
  56. package/utils.js +2 -2
@@ -4,99 +4,101 @@
4
4
  * do not remove the author name to get more updates
5
5
  */
6
6
 
7
- "use strict";
7
+ "use strict";
8
8
 
9
- var utils = require("../utils");
10
- var log = require("npmlog");
11
-
12
- function formatData(resData) {
13
- return {
14
- viewer_feedback_reaction_info: resData.feedback_react.feedback.viewer_feedback_reaction_info,
15
- supported_reactions: resData.feedback_react.feedback.supported_reactions,
16
- top_reactions: resData.feedback_react.feedback.top_reactions.edges,
17
- reaction_count: resData.feedback_react.feedback.reaction_count
18
- };
19
- }
20
-
21
- module.exports = function(defaultFuncs, api, ctx) {
22
- return function setPostReaction(postID, type, callback) {
23
- var resolveFunc = function(){};
24
- var rejectFunc = function(){};
25
- var returnPromise = new Promise(function (resolve, reject) {
26
- resolveFunc = resolve;
27
- rejectFunc = reject;
28
- });
29
-
30
- if (!callback) {
31
- if (utils.getType(type) === "Function" || utils.getType(type) === "AsyncFunction") {
32
- callback = type;
33
- type = 0;
34
- }
35
- else {
36
- callback = function (err, data) {
37
- if (err) {
38
- return rejectFunc(err);
39
- }
40
- resolveFunc(data);
41
- };
42
- }
43
- }
44
-
45
- var map = {
46
- unlike: 0,
47
- like: 1,
48
- heart: 2,
49
- love: 16,
50
- haha: 4,
51
- wow: 3,
52
- sad: 7,
53
- angry: 8
54
- };
55
-
56
- if (utils.getType(type) !== "Number" && utils.getType(type) === "String") {
57
- type = map[type.toLowerCase()];
58
- }
59
- else {
60
- throw {
61
- error: "setPostReaction: Invalid reaction type"
62
- };
63
- }
64
-
65
- var form = {
66
- av: ctx.userID,
67
- fb_api_caller_class: "RelayModern",
68
- fb_api_req_friendly_name: "CometUFIFeedbackReactMutation",
69
- doc_id: "4769042373179384",
70
- variables: JSON.stringify({
71
- input: {
72
- actor_id: ctx.userID,
73
- feedback_id: (new Buffer.from("feedback:" + postID)).toString("base64"),
74
- feedback_reaction: type,
75
- feedback_source: "OBJECT",
76
- is_tracking_encrypted: true,
77
- tracking: [],
78
- session_id: "f7dd50dd-db6e-4598-8cd9-561d5002b423",
79
- client_mutation_id: Math.round(Math.random() * 19).toString()
80
- },
81
- useDefaultActor: false,
82
- scale: 3
83
- })
84
- };
85
-
86
- defaultFuncs
87
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
88
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
89
- .then(function(resData) {
90
- if (resData.errors) {
91
- throw resData;
92
- }
93
- return callback(null, formatData(resData.data));
94
- })
95
- .catch(function(err) {
96
- log.error("setPostReaction", err);
97
- return callback(err);
98
- });
99
-
100
- return returnPromise;
101
- };
102
- };
9
+ var utils = require("../utils");
10
+ var log = require("npmlog");
11
+
12
+ function formatData(resData) {
13
+ return {
14
+ viewer_feedback_reaction_info:
15
+ resData.feedback_react.feedback.viewer_feedback_reaction_info,
16
+ supported_reactions: resData.feedback_react.feedback.supported_reactions,
17
+ top_reactions: resData.feedback_react.feedback.top_reactions.edges,
18
+ reaction_count: resData.feedback_react.feedback.reaction_count
19
+ };
20
+ }
21
+
22
+ module.exports = function(defaultFuncs, api, ctx) {
23
+ return function setPostReaction(postID, type, callback) {
24
+ var resolveFunc = function() {};
25
+ var rejectFunc = function() {};
26
+ var returnPromise = new Promise(function(resolve, reject) {
27
+ resolveFunc = resolve;
28
+ rejectFunc = reject;
29
+ });
30
+
31
+ if (!callback) {
32
+ if (
33
+ utils.getType(type) === "Function" ||
34
+ utils.getType(type) === "AsyncFunction"
35
+ ) {
36
+ callback = type;
37
+ type = 0;
38
+ } else {
39
+ callback = function(err, data) {
40
+ if (err) {
41
+ return rejectFunc(err);
42
+ }
43
+ resolveFunc(data);
44
+ };
45
+ }
46
+ }
47
+
48
+ var map = {
49
+ unlike: 0,
50
+ like: 1,
51
+ heart: 2,
52
+ love: 16,
53
+ haha: 4,
54
+ wow: 3,
55
+ sad: 7,
56
+ angry: 8
57
+ };
58
+
59
+ if (utils.getType(type) !== "Number" && utils.getType(type) === "String") {
60
+ type = map[type.toLowerCase()];
61
+ } else {
62
+ throw {
63
+ error: "setPostReaction: Invalid reaction type"
64
+ };
65
+ }
66
+
67
+ var form = {
68
+ av: ctx.userID,
69
+ fb_api_caller_class: "RelayModern",
70
+ fb_api_req_friendly_name: "CometUFIFeedbackReactMutation",
71
+ doc_id: "4769042373179384",
72
+ variables: JSON.stringify({
73
+ input: {
74
+ actor_id: ctx.userID,
75
+ feedback_id: new Buffer.from("feedback:" + postID).toString("base64"),
76
+ feedback_reaction: type,
77
+ feedback_source: "OBJECT",
78
+ is_tracking_encrypted: true,
79
+ tracking: [],
80
+ session_id: "f7dd50dd-db6e-4598-8cd9-561d5002b423",
81
+ client_mutation_id: Math.round(Math.random() * 19).toString()
82
+ },
83
+ useDefaultActor: false,
84
+ scale: 3
85
+ })
86
+ };
87
+
88
+ defaultFuncs
89
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
90
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
91
+ .then(function(resData) {
92
+ if (resData.errors) {
93
+ throw resData;
94
+ }
95
+ return callback(null, formatData(resData.data));
96
+ })
97
+ .catch(function(err) {
98
+ log.error("setPostReaction", err);
99
+ return callback(err);
100
+ });
101
+
102
+ return returnPromise;
103
+ };
104
+ };
package/src/setTitle.js CHANGED
@@ -3,24 +3,24 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function setTitle(newTitle, threadID, callback) {
8
8
  if (
9
9
  !callback &&
10
10
  (utils.getType(threadID) === "Function" ||
11
11
  utils.getType(threadID) === "AsyncFunction")
12
- ) throw { error: "please pass a threadID as a second argument." };
12
+ )
13
+ throw { error: "please pass a threadID as a second argument." };
13
14
 
14
-
15
- var resolveFunc = function () { };
16
- var rejectFunc = function () { };
17
- var returnPromise = new Promise(function (resolve, reject) {
15
+ var resolveFunc = function() {};
16
+ var rejectFunc = function() {};
17
+ var returnPromise = new Promise(function(resolve, reject) {
18
18
  resolveFunc = resolve;
19
19
  rejectFunc = reject;
20
20
  });
21
21
 
22
22
  if (!callback) {
23
- callback = function (err, data) {
23
+ callback = function(err, data) {
24
24
  if (err) return rejectFunc(err);
25
25
  resolveFunc(data);
26
26
  };
@@ -56,15 +56,21 @@ module.exports = function (defaultFuncs, api, ctx) {
56
56
  };
57
57
 
58
58
  defaultFuncs
59
- .post("https://www.facebook.com/messaging/set_thread_name/", ctx.jar, form)
59
+ .post(
60
+ "https://www.facebook.com/messaging/set_thread_name/",
61
+ ctx.jar,
62
+ form
63
+ )
60
64
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
61
- .then(function (resData) {
62
- if (resData.error && resData.error === 1545012) throw { error: "Cannot change chat title: Not member of chat." };
63
- if (resData.error && resData.error === 1545003) throw { error: "Cannot set title of single-user chat." };
65
+ .then(function(resData) {
66
+ if (resData.error && resData.error === 1545012)
67
+ throw { error: "Cannot change chat title: Not member of chat." };
68
+ if (resData.error && resData.error === 1545003)
69
+ throw { error: "Cannot set title of single-user chat." };
64
70
  if (resData.error) throw resData;
65
71
  return callback();
66
72
  })
67
- .catch(function (err) {
73
+ .catch(function(err) {
68
74
  log.error("setTitle", err);
69
75
  return callback(err);
70
76
  });
@@ -18,22 +18,22 @@ module.exports = function(_defaultFuncs, _api, _ctx) {
18
18
  ////Cameo: "#d4a88c",
19
19
  ////BrilliantRose: "#ff5ca1",
20
20
  ////BilobaFlower: "#a695c7"
21
- DefaultBlue: "196241301102133",
22
- HotPink: "169463077092846",
23
- AquaBlue: "2442142322678320",
24
- BrightPurple: "234137870477637",
25
- CoralPink: "980963458735625",
26
- Orange: "175615189761153",
27
- Green: "2136751179887052",
21
+ DefaultBlue: "196241301102133",
22
+ HotPink: "169463077092846",
23
+ AquaBlue: "2442142322678320",
24
+ BrightPurple: "234137870477637",
25
+ CoralPink: "980963458735625",
26
+ Orange: "175615189761153",
27
+ Green: "2136751179887052",
28
28
  LavenderPurple: "2058653964378557",
29
- Red: "2129984390566328",
30
- Yellow: "174636906462322",
31
- TealBlue: "1928399724138152",
32
- Aqua: "417639218648241",
33
- Mango: "930060997172551",
34
- Berry: "164535220883264",
35
- Citrus: "370940413392601",
36
- Candy: "205488546921017",
37
- StarWars: "809305022860427"
29
+ Red: "2129984390566328",
30
+ Yellow: "174636906462322",
31
+ TealBlue: "1928399724138152",
32
+ Aqua: "417639218648241",
33
+ Mango: "930060997172551",
34
+ Berry: "164535220883264",
35
+ Citrus: "370940413392601",
36
+ Candy: "205488546921017",
37
+ StarWars: "809305022860427"
38
38
  };
39
- };
39
+ };
package/src/unfriend.js CHANGED
@@ -3,17 +3,17 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function unfriend(userID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
 
15
15
  if (!callback) {
16
- callback = function (err, friendList) {
16
+ callback = function(err, friendList) {
17
17
  if (err) return rejectFunc(err);
18
18
  resolveFunc(friendList);
19
19
  };
@@ -23,17 +23,22 @@ module.exports = function (defaultFuncs, api, ctx) {
23
23
  uid: userID,
24
24
  unref: "bd_friends_tab",
25
25
  floc: "friends_tab",
26
- "nctr[_mod]": "pagelet_timeline_app_collection_" + ctx.userID + ":2356318349:2"
26
+ "nctr[_mod]":
27
+ "pagelet_timeline_app_collection_" + ctx.userID + ":2356318349:2"
27
28
  };
28
29
 
29
30
  defaultFuncs
30
- .post("https://www.facebook.com/ajax/profile/removefriendconfirm.php", ctx.jar, form)
31
+ .post(
32
+ "https://www.facebook.com/ajax/profile/removefriendconfirm.php",
33
+ ctx.jar,
34
+ form
35
+ )
31
36
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
32
- .then(function (resData) {
37
+ .then(function(resData) {
33
38
  if (resData.error) throw resData;
34
39
  return callback();
35
40
  })
36
- .catch(function (err) {
41
+ .catch(function(err) {
37
42
  log.error("unfriend", err);
38
43
  return callback(err);
39
44
  });
@@ -3,17 +3,17 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function unsendMessage(messageID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
 
15
15
  if (!callback) {
16
- callback = function (err, friendList) {
16
+ callback = function(err, friendList) {
17
17
  if (err) return rejectFunc(err);
18
18
  resolveFunc(friendList);
19
19
  };
@@ -26,11 +26,11 @@ module.exports = function (defaultFuncs, api, ctx) {
26
26
  defaultFuncs
27
27
  .post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, form)
28
28
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
- .then(function (resData) {
29
+ .then(function(resData) {
30
30
  if (resData.error) throw resData;
31
31
  return callback();
32
32
  })
33
- .catch(function (err) {
33
+ .catch(function(err) {
34
34
  log.error("unsendMessage", err);
35
35
  return callback(err);
36
36
  });
package/utils.js CHANGED
@@ -22,8 +22,8 @@ function getHeaders(url, options, ctx, customHeader) {
22
22
  Origin: "https://www.facebook.com",
23
23
  "User-Agent": options.userAgent,
24
24
  Connection: "keep-alive",
25
- "sec-fetch-site": 'same-origin',
26
- "sec-fetch-mode": 'cors'
25
+ //"sec-fetch-site": 'same-origin',
26
+ //"sec-fetch-mode": 'cors'
27
27
  };
28
28
  if (customHeader) Object.assign(headers, customHeader);
29
29