rapido-fca 0.0.2 → 0.0.4

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.
Files changed (81) hide show
  1. package/index.js +419 -415
  2. package/package.json +16 -15
  3. package/src/addExternalModule.js +19 -23
  4. package/src/addUserToGroup.js +99 -97
  5. package/src/changeAdminStatus.js +86 -62
  6. package/src/changeArchivedStatus.js +49 -49
  7. package/src/changeAvatar.js +118 -108
  8. package/src/changeAvatarV2.js +86 -0
  9. package/src/changeAvt.js +85 -0
  10. package/src/changeBio.js +63 -64
  11. package/src/changeBlockedStatus.js +40 -38
  12. package/src/changeBlockedStatusMqtt.js +80 -0
  13. package/src/changeCover.js +72 -0
  14. package/src/changeGroupImage.js +129 -126
  15. package/src/changeName.js +79 -0
  16. package/src/changeNickname.js +49 -49
  17. package/src/changeThreadColor.js +53 -53
  18. package/src/changeThreadEmoji.js +45 -45
  19. package/src/changeUsername.js +59 -0
  20. package/src/createCommentPost.js +230 -0
  21. package/src/createNewGroup.js +74 -72
  22. package/src/createPoll.js +59 -59
  23. package/src/createPost.js +276 -0
  24. package/src/deleteMessage.js +50 -50
  25. package/src/deleteThread.js +50 -50
  26. package/src/editMessage.js +51 -49
  27. package/src/editMessageOld.js +67 -0
  28. package/src/follow.js +74 -0
  29. package/src/forwardAttachment.js +54 -54
  30. package/src/getAccess.js +112 -0
  31. package/src/getAvatarUser.js +78 -0
  32. package/src/getCurrentUserID.js +3 -3
  33. package/src/getEmojiUrl.js +17 -17
  34. package/src/getFriendsList.js +67 -67
  35. package/src/getMessage.js +806 -767
  36. package/src/getRegion.js +7 -0
  37. package/src/getThreadHistory.js +656 -642
  38. package/src/getThreadHistoryDeprecated.js +71 -0
  39. package/src/getThreadInfo.js +1 -1
  40. package/src/getThreadInfoDeprecated.js +56 -0
  41. package/src/getThreadList.js +199 -227
  42. package/src/getThreadListDeprecated.js +46 -0
  43. package/src/getThreadPictures.js +51 -71
  44. package/src/getUID.js +119 -0
  45. package/src/getUserID.js +53 -58
  46. package/src/getUserInfo.js +52 -60
  47. package/src/handleFriendRequest.js +41 -65
  48. package/src/handleMessageRequest.js +42 -60
  49. package/src/httpGet.js +49 -57
  50. package/src/httpPost.js +48 -57
  51. package/src/listenMqtt.js +827 -895
  52. package/src/logout.js +61 -61
  53. package/src/markAsDelivered.js +42 -53
  54. package/src/markAsRead.js +59 -69
  55. package/src/markAsReadAll.js +32 -42
  56. package/src/markAsSeen.js +43 -54
  57. package/src/muteThread.js +40 -47
  58. package/src/refreshFb_dtsg.js +77 -69
  59. package/src/removeUserFromGroup.js +67 -67
  60. package/src/resolvePhotoUrl.js +34 -34
  61. package/src/searchForThread.js +43 -43
  62. package/src/searchStickers.js +53 -0
  63. package/src/sendMessage.js +80 -228
  64. package/src/sendMessageMqtt.js +322 -0
  65. package/src/sendTypingIndicator.js +86 -88
  66. package/src/sendTypingIndicatorV2.js +28 -0
  67. package/src/setMessageReaction.js +110 -109
  68. package/src/setMessageReactionMqtt.js +62 -0
  69. package/src/setPostReaction.js +90 -87
  70. package/src/setStoryReaction.js +64 -0
  71. package/src/setTitle.js +76 -72
  72. package/src/shareContact.js +110 -0
  73. package/src/shareLink.js +59 -0
  74. package/src/stopListenMqtt.js +23 -0
  75. package/src/threadColors.js +121 -121
  76. package/src/unfriend.js +43 -43
  77. package/src/unsendMessage.js +34 -38
  78. package/src/uploadAttachment.js +79 -81
  79. package/utils.js +2732 -1401
  80. package/LICENSE +0 -21
  81. package/src/httpPostFormData.js +0 -63
@@ -1,81 +1,89 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
4
+ // @NethWs3Dev
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- /**
8
- * Refreshes the fb_dtsg and jazoest values.
9
- * @param {Function} callback
10
- * @returns {Promise}
11
- * @description if you don't update the value of fb_dtsg and jazoest for a long time an error "Please try closing and re-opening your browser window" will appear
12
- * @description you should refresh it every 48h or less
13
- */
14
- return function refreshFb_dtsg(obj, callback) {
15
- let resolveFunc = function () { };
16
- let rejectFunc = function () { };
17
- const returnPromise = new Promise(function (resolve, reject) {
18
- resolveFunc = resolve;
19
- rejectFunc = reject;
20
- });
7
+ /**
8
+ * Refreshes the fb_dtsg and jazoest values.
9
+ * @param {Function} callback
10
+ * @returns {Promise}
11
+ * @description if you don't update the value of fb_dtsg and jazoest for a long time an error "Please try closing and re-opening your browser window" will appear
12
+ * @description you should refresh it every 48h or less
13
+ */
14
+ return function refreshFb_dtsg(obj, callback) {
15
+ let resolveFunc = function () {};
16
+ let rejectFunc = function () {};
17
+ const returnPromise = new Promise(function (resolve, reject) {
18
+ resolveFunc = resolve;
19
+ rejectFunc = reject;
20
+ });
21
21
 
22
- if (utils.getType(obj) === "Function" || utils.getType(obj) === "AsyncFunction") {
23
- callback = obj;
24
- obj = {};
25
- }
22
+ if (
23
+ utils.getType(obj) === "Function" ||
24
+ utils.getType(obj) === "AsyncFunction"
25
+ ) {
26
+ callback = obj;
27
+ obj = {};
28
+ }
26
29
 
27
- if (!obj) {
28
- obj = {};
29
- }
30
+ if (!obj) {
31
+ obj = {};
32
+ }
30
33
 
31
- if (utils.getType(obj) !== "Object") {
32
- throw new utils.CustomError("the first parameter must be an object or a callback function");
33
- }
34
+ if (utils.getType(obj) !== "Object") {
35
+ throw new utils.CustomError(
36
+ "the first parameter must be an object or a callback function",
37
+ );
38
+ }
34
39
 
35
- if (!callback) {
36
- callback = function (err, friendList) {
37
- if (err) {
38
- return rejectFunc(err);
39
- }
40
- resolveFunc(friendList);
41
- };
42
- }
40
+ if (!callback) {
41
+ callback = function (err, friendList) {
42
+ if (err) {
43
+ return rejectFunc(err);
44
+ }
45
+ resolveFunc(friendList);
46
+ };
47
+ }
43
48
 
44
- if (Object.keys(obj).length == 0) {
45
- utils
46
- .get('https://m.facebook.com/', ctx.jar, null, ctx.globalOptions, { noRef: true })
47
- .then(function (resData) {
48
- const html = resData.body;
49
- const fb_dtsg = utils.getFrom(html, 'name="fb_dtsg" value="', '"');
50
- const jazoest = utils.getFrom(html, 'name="jazoest" value="', '"');
51
- if (!fb_dtsg) {
52
- throw new utils.CustomError("Could not find fb_dtsg in HTML after requesting https://www.facebook.com/");
53
- }
54
- ctx.fb_dtsg = fb_dtsg;
55
- ctx.jazoest = jazoest;
56
- callback(null, {
57
- data: {
58
- fb_dtsg: fb_dtsg,
59
- jazoest: jazoest
60
- },
61
- message: "refreshed fb_dtsg and jazoest"
62
- });
63
- })
64
- .catch(function (err) {
65
- log.error("refreshFb_dtsg", err);
66
- return callback(err);
67
- });
68
- }
69
- else {
70
- Object.keys(obj).forEach(function (key) {
71
- ctx[key] = obj[key];
72
- });
73
- callback(null, {
74
- data: obj,
75
- message: "refreshed " + Object.keys(obj).join(", ")
76
- });
77
- }
49
+ if (Object.keys(obj).length == 0) {
50
+ utils
51
+ .get("https://m.facebook.com/", ctx.jar, null, ctx.globalOptions, {
52
+ noRef: true,
53
+ })
54
+ .then(function (resData) {
55
+ const html = resData.body;
56
+ const fb_dtsg = utils.getFrom(html, 'name="fb_dtsg" value="', '"');
57
+ const jazoest = utils.getFrom(html, 'name="jazoest" value="', '"');
58
+ if (!fb_dtsg) {
59
+ throw new utils.CustomError(
60
+ "Could not find fb_dtsg in HTML after requesting https://www.facebook.com/",
61
+ );
62
+ }
63
+ ctx.fb_dtsg = fb_dtsg;
64
+ ctx.jazoest = jazoest;
65
+ callback(null, {
66
+ data: {
67
+ fb_dtsg: fb_dtsg,
68
+ jazoest: jazoest,
69
+ },
70
+ message: "refreshed fb_dtsg and jazoest",
71
+ });
72
+ })
73
+ .catch(function (err) {
74
+ console.error("refreshFb_dtsg", err);
75
+ return callback(err);
76
+ });
77
+ } else {
78
+ Object.keys(obj).forEach(function (key) {
79
+ ctx[key] = obj[key];
80
+ });
81
+ callback(null, {
82
+ data: obj,
83
+ message: "refreshed " + Object.keys(obj).join(", "),
84
+ });
85
+ }
78
86
 
79
- return returnPromise;
80
- };
87
+ return returnPromise;
88
+ };
81
89
  };
@@ -1,79 +1,79 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
4
+ // @NethWs3Dev
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function removeUserFromGroup(userID, threadID, callback) {
8
- if (
9
- !callback &&
10
- (utils.getType(threadID) === "Function" ||
11
- utils.getType(threadID) === "AsyncFunction")
12
- ) {
13
- throw { error: "please pass a threadID as a second argument." };
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
- }
7
+ return function removeUserFromGroup(userID, threadID, callback) {
8
+ if (
9
+ !callback &&
10
+ (utils.getType(threadID) === "Function" ||
11
+ utils.getType(threadID) === "AsyncFunction")
12
+ ) {
13
+ throw { error: "please pass a threadID as a second argument." };
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
37
 
38
- let resolveFunc = function () { };
39
- let rejectFunc = function () { };
40
- const returnPromise = new Promise(function (resolve, reject) {
41
- resolveFunc = resolve;
42
- rejectFunc = reject;
43
- });
38
+ let resolveFunc = function () {};
39
+ let rejectFunc = function () {};
40
+ const returnPromise = new Promise(function (resolve, reject) {
41
+ resolveFunc = resolve;
42
+ rejectFunc = reject;
43
+ });
44
44
 
45
- if (!callback) {
46
- callback = function (err, friendList) {
47
- if (err) {
48
- return rejectFunc(err);
49
- }
50
- resolveFunc(friendList);
51
- };
52
- }
45
+ if (!callback) {
46
+ callback = function (err, friendList) {
47
+ if (err) {
48
+ return rejectFunc(err);
49
+ }
50
+ resolveFunc(friendList);
51
+ };
52
+ }
53
53
 
54
- const form = {
55
- uid: userID,
56
- tid: threadID
57
- };
54
+ const form = {
55
+ uid: userID,
56
+ tid: threadID,
57
+ };
58
58
 
59
- defaultFuncs
60
- .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
61
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
- .then(function (resData) {
63
- if (!resData) {
64
- throw { error: "Remove from group failed." };
65
- }
66
- if (resData.error) {
67
- throw resData;
68
- }
59
+ defaultFuncs
60
+ .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
61
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
+ .then(function (resData) {
63
+ if (!resData) {
64
+ throw { error: "Remove from group failed." };
65
+ }
66
+ if (resData.error) {
67
+ throw resData;
68
+ }
69
69
 
70
- return callback();
71
- })
72
- .catch(function (err) {
73
- log.error("removeUserFromGroup", err);
74
- return callback(err);
75
- });
70
+ return callback();
71
+ })
72
+ .catch(function (err) {
73
+ console.error("removeUserFromGroup", err);
74
+ return callback(err);
75
+ });
76
76
 
77
- return returnPromise;
78
- };
77
+ return returnPromise;
78
+ };
79
79
  };
@@ -1,45 +1,45 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
4
+ // @NethWs3Dev
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function resolvePhotoUrl(photoID, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
7
+ return function resolvePhotoUrl(photoID, 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
14
 
15
- if (!callback) {
16
- callback = function (err, friendList) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
20
- resolveFunc(friendList);
21
- };
22
- }
15
+ if (!callback) {
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
21
+ };
22
+ }
23
23
 
24
- defaultFuncs
25
- .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
26
- photo_id: photoID
27
- })
28
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
- .then(resData => {
30
- if (resData.error) {
31
- throw resData;
32
- }
24
+ defaultFuncs
25
+ .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
26
+ photo_id: photoID,
27
+ })
28
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
+ .then((resData) => {
30
+ if (resData.error) {
31
+ throw resData;
32
+ }
33
33
 
34
- const photoUrl = resData.jsmods.require[0][3][0];
34
+ const photoUrl = resData.jsmods.require[0][3][0];
35
35
 
36
- return callback(null, photoUrl);
37
- })
38
- .catch(err => {
39
- log.error("resolvePhotoUrl", err);
40
- return callback(err);
41
- });
36
+ return callback(null, photoUrl);
37
+ })
38
+ .catch((err) => {
39
+ console.error("resolvePhotoUrl", err);
40
+ return callback(err);
41
+ });
42
42
 
43
- return returnPromise;
44
- };
43
+ return returnPromise;
44
+ };
45
45
  };
@@ -3,51 +3,51 @@
3
3
  const utils = require("../utils");
4
4
 
5
5
  module.exports = function (defaultFuncs, api, ctx) {
6
- return function searchForThread(name, callback) {
7
- let resolveFunc = function () { };
8
- let rejectFunc = function () { };
9
- const returnPromise = new Promise(function (resolve, reject) {
10
- resolveFunc = resolve;
11
- rejectFunc = reject;
12
- });
6
+ return function searchForThread(name, callback) {
7
+ let resolveFunc = function () {};
8
+ let rejectFunc = function () {};
9
+ const returnPromise = new Promise(function (resolve, reject) {
10
+ resolveFunc = resolve;
11
+ rejectFunc = reject;
12
+ });
13
13
 
14
- if (!callback) {
15
- callback = function (err, friendList) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc(friendList);
20
- };
21
- }
14
+ if (!callback) {
15
+ callback = function (err, friendList) {
16
+ if (err) {
17
+ return rejectFunc(err);
18
+ }
19
+ resolveFunc(friendList);
20
+ };
21
+ }
22
22
 
23
- const tmpForm = {
24
- client: "web_messenger",
25
- query: name,
26
- offset: 0,
27
- limit: 21,
28
- index: "fbid"
29
- };
23
+ const tmpForm = {
24
+ client: "web_messenger",
25
+ query: name,
26
+ offset: 0,
27
+ limit: 21,
28
+ index: "fbid",
29
+ };
30
30
 
31
- defaultFuncs
32
- .post(
33
- "https://www.facebook.com/ajax/mercury/search_threads.php",
34
- ctx.jar,
35
- tmpForm
36
- )
37
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
38
- .then(function (resData) {
39
- if (resData.error) {
40
- throw resData;
41
- }
42
- if (!resData.payload.mercury_payload.threads) {
43
- return callback({ error: "Could not find thread `" + name + "`." });
44
- }
45
- return callback(
46
- null,
47
- resData.payload.mercury_payload.threads.map(utils.formatThread)
48
- );
49
- });
31
+ defaultFuncs
32
+ .post(
33
+ "https://www.facebook.com/ajax/mercury/search_threads.php",
34
+ ctx.jar,
35
+ tmpForm,
36
+ )
37
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
38
+ .then(function (resData) {
39
+ if (resData.error) {
40
+ throw resData;
41
+ }
42
+ if (!resData.payload.mercury_payload.threads) {
43
+ return callback({ error: "Could not find thread `" + name + "`." });
44
+ }
45
+ return callback(
46
+ null,
47
+ resData.payload.mercury_payload.threads.map(utils.formatThread),
48
+ );
49
+ });
50
50
 
51
- return returnPromise;
52
- };
51
+ return returnPromise;
52
+ };
53
53
  };
@@ -0,0 +1,53 @@
1
+
2
+ 'use strict';
3
+
4
+ var utils = require('../utils.js');
5
+ var log = require('npmlog');
6
+
7
+ module.exports = function (http, api, ctx) {
8
+ function formatData(res) {
9
+ return {
10
+ id: res.node.id,
11
+ image: res.node.image,
12
+ package: res.node.pack != null ? {
13
+ name: res.node.pack.name,
14
+ id: res.node.pack.id
15
+ } : {},
16
+ label: res.node.label
17
+ };
18
+ }
19
+
20
+ return function searchStickers(query = '', callback) {
21
+ var cb;
22
+ var returnPromise = new Promise(function (resolve, reject) {
23
+ cb = function (error, data) {
24
+ data ? resolve(data) : reject(error);
25
+ }
26
+ });
27
+
28
+ if (typeof callback == 'function') cb = callback;
29
+
30
+ var form = {
31
+ fb_api_req_friendly_name: 'StickersFlyoutTagSelectorQuery',
32
+ variables: JSON.stringify({
33
+ stickerWidth: 64,
34
+ stickerHeight: 64,
35
+ stickerInterface: 'messages',
36
+ query
37
+ }),
38
+ doc_id: '4642836929159953'
39
+ }
40
+ http
41
+ .post('https://www.facebook.com/api/graphql/', ctx.jar, form)
42
+ .then(utils.parseAndCheckLogin(ctx, http))
43
+ .then(function (res) {
44
+ return cb(null, res.data.sticker_search.sticker_results.edges.map(formatData));
45
+ })
46
+ .catch(function (err) {
47
+ console.error('searchStickers', err);
48
+ return cb(err);
49
+ });
50
+ return returnPromise;
51
+ }
52
+ }
53
+