shadowx-fca 8.0.0

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 (174) hide show
  1. package/README.md +1066 -0
  2. package/build/messagix.dll +0 -0
  3. package/build/messagix.so +0 -0
  4. package/checkUpdate.js +393 -0
  5. package/config.json +17 -0
  6. package/e2ee.js +563 -0
  7. package/e2eetest.js +356 -0
  8. package/index.js +611 -0
  9. package/lib/index.mjs +1412 -0
  10. package/logger.js +500 -0
  11. package/package.json +65 -0
  12. package/src/GetBotInfo.js +66 -0
  13. package/src/OldMessage.js +182 -0
  14. package/src/Screenshot.js +83 -0
  15. package/src/addExternalModule.js +13 -0
  16. package/src/addUserToGroup.js +33 -0
  17. package/src/approveGroupJoinRequests.js +18 -0
  18. package/src/changeAdminStatus.js +16 -0
  19. package/src/changeArchivedStatus.js +17 -0
  20. package/src/changeAvatar.js +136 -0
  21. package/src/changeAvatarV2.js +86 -0
  22. package/src/changeAvt.js +85 -0
  23. package/src/changeBio.js +76 -0
  24. package/src/changeBlockedStatus.js +20 -0
  25. package/src/changeBlockedStatusMqtt.js +80 -0
  26. package/src/changeCover.js +72 -0
  27. package/src/changeGroupImage.js +16 -0
  28. package/src/changeName.js +79 -0
  29. package/src/changeNickname.js +16 -0
  30. package/src/changeThreadColor.js +15 -0
  31. package/src/changeThreadEmoji.js +15 -0
  32. package/src/changeThreadMemberNickname.js +6 -0
  33. package/src/changeUsername.js +59 -0
  34. package/src/createCommentPost.js +230 -0
  35. package/src/createNewGroup.js +38 -0
  36. package/src/createNote.js +35 -0
  37. package/src/createPoll.js +27 -0
  38. package/src/createPost.js +276 -0
  39. package/src/createThemeAI.js +129 -0
  40. package/src/data/cache/system/data.json +4 -0
  41. package/src/data/cache/system/datahandle.js +21 -0
  42. package/src/data/getThreadInfo.json +1 -0
  43. package/src/deleteComment.js +23 -0
  44. package/src/deleteMessage.js +15 -0
  45. package/src/deleteThread.js +15 -0
  46. package/src/denyGroupJoinRequests.js +18 -0
  47. package/src/e2ee/crypto.js +173 -0
  48. package/src/e2ee/index.js +144 -0
  49. package/src/e2ee/proto/ArmadilloApplication.proto +281 -0
  50. package/src/e2ee/proto/ArmadilloICDC.proto +14 -0
  51. package/src/e2ee/proto/ConsumerApplication.proto +232 -0
  52. package/src/e2ee/proto/MessageApplication.proto +82 -0
  53. package/src/e2ee/proto/MessageTransport.proto +77 -0
  54. package/src/e2ee/proto/WACommon.proto +66 -0
  55. package/src/e2ee/proto/WAMediaTransport.proto +176 -0
  56. package/src/e2ee/proto/proto-writer.ts +76 -0
  57. package/src/e2ee/protocol.js +196 -0
  58. package/src/e2ee/ratchet.js +219 -0
  59. package/src/e2ee/store.js +182 -0
  60. package/src/e2ee.js +8 -0
  61. package/src/editMessage.js +56 -0
  62. package/src/editMessageOld.js +67 -0
  63. package/src/enableReactions.js +24 -0
  64. package/src/follow.js +74 -0
  65. package/src/followUser.js +23 -0
  66. package/src/forwardAttachment.js +16 -0
  67. package/src/friendList.js +98 -0
  68. package/src/getAccess.js +112 -0
  69. package/src/getAppState.js +13 -0
  70. package/src/getAvatarUser.js +11 -0
  71. package/src/getBio.js +24 -0
  72. package/src/getBotInitialData.js +42 -0
  73. package/src/getCtx.js +5 -0
  74. package/src/getCurrentUserID.js +6 -0
  75. package/src/getEmojiUrl.js +29 -0
  76. package/src/getFriendsList.js +36 -0
  77. package/src/getMessage.js +37 -0
  78. package/src/getNotes.js +17 -0
  79. package/src/getOptions.js +5 -0
  80. package/src/getPinnedMessages.js +33 -0
  81. package/src/getPostInfo.js +17 -0
  82. package/src/getProfileInfo.js +17 -0
  83. package/src/getPublicData.js +25 -0
  84. package/src/getRegion.js +7 -0
  85. package/src/getRepInfo.js +17 -0
  86. package/src/getStickerPacks.js +25 -0
  87. package/src/getStickers.js +39 -0
  88. package/src/getStoryReactions.js +18 -0
  89. package/src/getThreadHistory.js +45 -0
  90. package/src/getThreadHistoryDeprecated.js +71 -0
  91. package/src/getThreadInfo.js +73 -0
  92. package/src/getThreadInfoDeprecated.js +56 -0
  93. package/src/getThreadList.js +76 -0
  94. package/src/getThreadListDeprecated.js +46 -0
  95. package/src/getThreadPictures.js +59 -0
  96. package/src/getThreadTheme.js +77 -0
  97. package/src/getUID.js +17 -0
  98. package/src/getUserID.js +17 -0
  99. package/src/getUserInfo.js +28 -0
  100. package/src/handleFriendRequest.js +21 -0
  101. package/src/handleMessageRequest.js +15 -0
  102. package/src/httpGet.js +13 -0
  103. package/src/httpPost.js +12 -0
  104. package/src/httpPostFormData.js +12 -0
  105. package/src/listenE2EE.js +75 -0
  106. package/src/listenMqtt.js +802 -0
  107. package/src/listenNotification.js +85 -0
  108. package/src/logout.js +22 -0
  109. package/src/markAsDelivered.js +17 -0
  110. package/src/markAsRead.js +14 -0
  111. package/src/markAsReadAll.js +15 -0
  112. package/src/markAsSeen.js +15 -0
  113. package/src/metaTheme.js +185 -0
  114. package/src/muteThread.js +52 -0
  115. package/src/note.js +228 -0
  116. package/src/pin.js +53 -0
  117. package/src/pinMessage.js +6 -0
  118. package/src/postComment.js +29 -0
  119. package/src/postFormData.js +46 -0
  120. package/src/reactToComment.js +31 -0
  121. package/src/reactToPost.js +32 -0
  122. package/src/refreshFb_dtsg.js +31 -0
  123. package/src/removeSuspiciousAccount.js +74 -0
  124. package/src/removeUserFromGroup.js +15 -0
  125. package/src/reply.js +442 -0
  126. package/src/resolvePhotoUrl.js +15 -0
  127. package/src/searchForThread.js +20 -0
  128. package/src/searchFriends.js +28 -0
  129. package/src/searchStickers.js +53 -0
  130. package/src/send.js +46 -0
  131. package/src/sendAudio.js +8 -0
  132. package/src/sendBroadcast.js +93 -0
  133. package/src/sendButtons.js +161 -0
  134. package/src/sendComment.js +159 -0
  135. package/src/sendEmoji.js +10 -0
  136. package/src/sendFile.js +9 -0
  137. package/src/sendFriendRequest.js +33 -0
  138. package/src/sendGif.js +24 -0
  139. package/src/sendImage.js +9 -0
  140. package/src/sendLocation.js +9 -0
  141. package/src/sendMessage.js +487 -0
  142. package/src/sendMessage1.js +309 -0
  143. package/src/sendMessageMqtt.js +68 -0
  144. package/src/sendSticker.js +8 -0
  145. package/src/sendTypingIndicator.js +36 -0
  146. package/src/sendTypingIndicatorV2.js +28 -0
  147. package/src/sendVideo.js +9 -0
  148. package/src/sessionGuard.js +130 -0
  149. package/src/setActiveStatus.js +16 -0
  150. package/src/setMessageReaction.js +61 -0
  151. package/src/setMessageReactionMqtt.js +62 -0
  152. package/src/setOptions.js +22 -0
  153. package/src/setPollVote.js +17 -0
  154. package/src/setPostReaction.js +112 -0
  155. package/src/setProfileGuard.js +44 -0
  156. package/src/setProfileLock.js +93 -0
  157. package/src/setStoryReaction.js +129 -0
  158. package/src/setStorySeen.js +99 -0
  159. package/src/setThreadTheme.js +17 -0
  160. package/src/setTitle.js +15 -0
  161. package/src/shareContact.js +33 -0
  162. package/src/shareLink.js +8 -0
  163. package/src/sharePost.js +31 -0
  164. package/src/stopListenMqtt.js +23 -0
  165. package/src/storyManager.js +353 -0
  166. package/src/suggestFriend.js +128 -0
  167. package/src/threadColors.js +131 -0
  168. package/src/unfollowUser.js +23 -0
  169. package/src/unfriend.js +15 -0
  170. package/src/unpinMessage.js +6 -0
  171. package/src/unsendMessage.js +14 -0
  172. package/src/uploadAttachment.js +58 -0
  173. package/src/uploadImageToImgbb.js +29 -0
  174. package/utils.js +2945 -0
@@ -0,0 +1,62 @@
1
+
2
+ 'use strict';
3
+
4
+ const { generateOfflineThreadingID } = require('../utils');
5
+
6
+ function isCallable(func) {
7
+ try {
8
+ Reflect.apply(func, null, []);
9
+ return true;
10
+ } catch (error) {
11
+ return false;
12
+ }
13
+ }
14
+
15
+ module.exports = function (defaultFuncs, api, ctx) {
16
+ return function setMessageReactionMqtt(reaction, messageID, threadID, callback) {
17
+ if (!ctx.mqttClient) {
18
+ throw new Error('Not connected to MQTT');
19
+ }
20
+
21
+
22
+ ctx.wsReqNumber += 1;
23
+ ctx.wsTaskNumber += 1;
24
+
25
+ const taskPayload = {
26
+ thread_key: threadID,
27
+ timestamp_ms: Date.now(),
28
+ message_id: messageID,
29
+ reaction: reaction,
30
+ actor_id: ctx.userID,
31
+ reaction_style: null,
32
+ sync_group: 1,
33
+ send_attribution: Math.random() < 0.5 ? 65537 : 524289
34
+ };
35
+
36
+ const task = {
37
+ failure_count: null,
38
+ label: '29',
39
+ payload: JSON.stringify(taskPayload),
40
+ queue_name: JSON.stringify(['reaction', messageID]),
41
+ task_id: ctx.wsTaskNumber,
42
+ };
43
+
44
+ const content = {
45
+ app_id: '2220391788200892',
46
+ payload: JSON.stringify({
47
+ data_trace_id: null,
48
+ epoch_id: parseInt(generateOfflineThreadingID()),
49
+ tasks: [task],
50
+ version_id: '7158486590867448',
51
+ }),
52
+ request_id: ctx.wsReqNumber,
53
+ type: 3,
54
+ };
55
+
56
+ if (isCallable(callback)) {
57
+ ctx.reqCallbacks[ctx.wsReqNumber] = callback;
58
+ }
59
+
60
+ ctx.mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
61
+ };
62
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var logger = require("../logger");
3
+ var VALID_OPTIONS = new Set([
4
+ "logLevel", "listenEvents", "pageID", "updatePresence", "forceLogin",
5
+ "selfListen", "selfListenEvent", "listenTyping", "useWebhook",
6
+ "autoReconnect", "reconnectDelay", "mqttTimeout", "e2ee", "e2eeDevicePath",
7
+ "userAgent", "messageParseMode", "locale"
8
+ ]);
9
+ module.exports = function (defaultFuncs, api, ctx) {
10
+ return function setOptions(options) {
11
+ if (typeof options !== "object" || options === null) {
12
+ return logger.warn("setOptions", "Options must be an object");
13
+ }
14
+ for (var key in options) {
15
+ if (!VALID_OPTIONS.has(key)) {
16
+ logger.warn("setOptions", "Unknown option: " + key);
17
+ continue;
18
+ }
19
+ ctx.globalOptions[key] = options[key];
20
+ }
21
+ };
22
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var utils = require("../utils");
3
+ module.exports = function (defaultFuncs, api, ctx) {
4
+ return function setPollVote(pollID, optionIDs, newOptionNames, callback) {
5
+ if (typeof newOptionNames === "function") { callback = newOptionNames; newOptionNames = []; }
6
+ var { promise, callback: cb } = utils.wrapCallback(callback);
7
+ if (!Array.isArray(optionIDs)) optionIDs = [optionIDs];
8
+ var form = { question_id: pollID };
9
+ optionIDs.forEach((id, i) => { form["selected_options[" + i + "]"] = id; });
10
+ (newOptionNames || []).forEach((name, i) => { form["new_options_text[" + i + "]"] = name; });
11
+ defaultFuncs.post("https://www.facebook.com/messaging/group_polling/update_vote/", ctx.jar, form)
12
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
13
+ .then(resData => { if (resData.error) throw resData; cb(null, resData); })
14
+ .catch(err => cb(err));
15
+ return promise;
16
+ };
17
+ };
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @fix by NTKhang
3
+ * update as Thursday, 10 February 2022
4
+ * do not remove the author name to get more updates
5
+ */
6
+
7
+ "use strict";
8
+
9
+ const utils = require("../utils");
10
+ // @NethWs3Dev
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
+ let resolveFunc = function () {};
25
+ let rejectFunc = function () {};
26
+ const 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
+ const 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
+ }
62
+
63
+ if (utils.getType(type) !== "Number" && utils.getType(type) !== "String") {
64
+ throw {
65
+ error: "setPostReaction: Invalid reaction type",
66
+ };
67
+ }
68
+
69
+ if (type != 0 && !type) {
70
+ throw {
71
+ error: "setPostReaction: Invalid reaction type",
72
+ };
73
+ }
74
+
75
+ const form = {
76
+ av: ctx.userID,
77
+ fb_api_caller_class: "RelayModern",
78
+ fb_api_req_friendly_name: "CometUFIFeedbackReactMutation",
79
+ doc_id: "4769042373179384",
80
+ variables: JSON.stringify({
81
+ input: {
82
+ actor_id: ctx.userID,
83
+ feedback_id: new Buffer("feedback:" + postID).toString("base64"),
84
+ feedback_reaction: type,
85
+ feedback_source: "OBJECT",
86
+ is_tracking_encrypted: true,
87
+ tracking: [],
88
+ session_id: "f7dd50dd-db6e-4598-8cd9-561d5002b423",
89
+ client_mutation_id: Math.round(Math.random() * 19).toString(),
90
+ },
91
+ useDefaultActor: false,
92
+ scale: 3,
93
+ }),
94
+ };
95
+
96
+ defaultFuncs
97
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
98
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
99
+ .then(function (resData) {
100
+ if (resData.errors) {
101
+ throw resData;
102
+ }
103
+ return callback(null, formatData(resData.data));
104
+ })
105
+ .catch(function (err) {
106
+ console.error("setPostReaction", err);
107
+ return callback(err);
108
+ });
109
+
110
+ return returnPromise;
111
+ };
112
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ // @NethWs3Dev
5
+ module.exports = (defaultFuncs, api, ctx) => {
6
+ return (guard, callback = () => {}) => {
7
+ if (utils.getType(guard) !== "Boolean") {
8
+ throw {
9
+ error: "Please pass a boolean as a second argument.",
10
+ };
11
+ }
12
+ const uid = ctx.userID;
13
+ const form = {
14
+ av: uid,
15
+ variables: JSON.stringify({
16
+ input: {
17
+ is_shielded: guard ? true : false,
18
+ actor_id: uid,
19
+ client_mutation_id: "1"
20
+ },
21
+ scale: 1
22
+ }),
23
+ doc_id: "1477043292367183",
24
+ fb_api_req_friendly_name: "IsShieldedSetMutation",
25
+ fb_api_caller_class: "IsShieldedSetMutation"
26
+ }
27
+
28
+ return defaultFuncs
29
+ .post("https://www.facebook.com/api/graphql", ctx.jar, form)
30
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
31
+ .then(function(resData) {
32
+ if (resData.err) {
33
+ throw {
34
+ err: resData.err
35
+ };
36
+ }
37
+ return callback();
38
+ })
39
+ .catch(err => {
40
+ utils.error("setProfileGuard", err);
41
+ return callback(err);
42
+ });;
43
+ };
44
+ };
@@ -0,0 +1,93 @@
1
+ /**
2
+ * ===========================================================
3
+ * 🔰 Owner & Developer
4
+ * -----------------------------------------------------------
5
+ * 🕊️ Respect the creator & give proper credits if reused.
6
+ * ===========================================================
7
+ */
8
+ "use strict";
9
+
10
+ const utils = require("../utils");
11
+ const log = require("npmlog");
12
+
13
+ module.exports = function (defaultFuncs, api, ctx) {
14
+ return function setProfileLock(enable, 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
+
22
+ if (!callback) {
23
+ callback = function (err, data) {
24
+ if (err) {
25
+ return rejectFunc(err);
26
+ }
27
+ resolveFunc(data);
28
+ };
29
+ }
30
+
31
+ if (typeof enable !== "boolean") {
32
+ return callback(new Error("enable must be a boolean value"));
33
+ }
34
+
35
+ const form = {
36
+ av: ctx.userID,
37
+ __aaid: 0,
38
+ __user: ctx.userID,
39
+ __a: 1,
40
+ __req: utils.getGUID(),
41
+ __hs: ctx.fb_dtsg_ag,
42
+ dpr: 1,
43
+ __ccg: "EXCELLENT",
44
+ __rev: ctx.req_ID,
45
+ __s: utils.getGUID(),
46
+ __hsi: ctx.hsi,
47
+ __comet_req: 15,
48
+ fb_dtsg: ctx.fb_dtsg,
49
+ jazoest: utils.getJazoest(ctx.fb_dtsg),
50
+ lsd: ctx.fb_dtsg,
51
+ __spin_r: ctx.req_ID,
52
+ __spin_b: "trunk",
53
+ __spin_t: Date.now(),
54
+ __crn: "comet.fbweb.CometProfileTimelineListViewRoute",
55
+ fb_api_caller_class: "RelayModern",
56
+ fb_api_req_friendly_name: "WemPrivateSharingMutation",
57
+ server_timestamps: true,
58
+ variables: JSON.stringify({
59
+ enable: !enable
60
+ }),
61
+ doc_id: "9144138075685633"
62
+ };
63
+
64
+ defaultFuncs
65
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
66
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
67
+ .then(function (resData) {
68
+ if (resData.error) {
69
+ throw resData;
70
+ }
71
+
72
+ const result = resData?.data?.toggle_wem_private_sharing_control_enabled;
73
+
74
+ if (!result) {
75
+ throw new Error("Cannot toggle profile lock status");
76
+ }
77
+
78
+ return callback(null, {
79
+ private_sharing_enabled: result.private_sharing_enabled,
80
+ is_ppg_converter: result.is_ppg_converter,
81
+ is_ppg_user: result.is_ppg_user,
82
+ last_toggle_time: result.private_sharing_last_toggle_time,
83
+ owner_id: result.owner_id
84
+ });
85
+ })
86
+ .catch(function (err) {
87
+ log.error("setProfileLock", err);
88
+ return callback(err);
89
+ });
90
+
91
+ return returnPromise;
92
+ };
93
+ };
@@ -0,0 +1,129 @@
1
+ /**
2
+ * ===========================================================
3
+ * 🔰 Owner & Developer
4
+ * -----------------------------------------------------------
5
+ * 🕊️ Respect the creator & give proper credits if reused.
6
+ * ===========================================================
7
+ */
8
+ 'use strict';
9
+
10
+ var utils = require('../utils.js');
11
+ var log = require('npmlog');
12
+
13
+ module.exports = function(defaultFuncs, api, ctx) {
14
+ return function setStoryReaction(storyID, react, callback) {
15
+ var resolveFunc = function () { };
16
+ var rejectFunc = function () { };
17
+ var returnPromise = new Promise(function (resolve, reject) {
18
+ resolveFunc = resolve;
19
+ rejectFunc = reject;
20
+ });
21
+
22
+ if (typeof react == 'function') {
23
+ callback = react;
24
+ react = '❤️'; // Default heart reaction
25
+ }
26
+
27
+ if (!callback) {
28
+ callback = function (err, data) {
29
+ if (err) return rejectFunc(err);
30
+ resolveFunc(data);
31
+ };
32
+ }
33
+
34
+ if (!storyID) {
35
+ return callback({ error: "storyID is required" });
36
+ }
37
+
38
+ var reactionMap = {
39
+ 1: '👍',
40
+ 2: '❤️',
41
+ 3: '🤗',
42
+ 4: '😆',
43
+ 5: '😮',
44
+ 6: '😢',
45
+ 7: '😡',
46
+ 'like': '👍',
47
+ 'love': '❤️',
48
+ 'heart': '❤️',
49
+ 'haha': '😆',
50
+ 'wow': '😮',
51
+ 'sad': '😢',
52
+ 'angry': '😡'
53
+ };
54
+
55
+ var reaction = reactionMap[react] || react || '❤️';
56
+
57
+ var form = {
58
+ av: ctx.userID,
59
+ __aaid: 0,
60
+ __user: ctx.userID,
61
+ __a: 1,
62
+ __req: utils.getSignatureID(),
63
+ __hs: ctx.fb_dtsg_ag,
64
+ dpr: 1,
65
+ __ccg: "EXCELLENT",
66
+ __rev: ctx.req_ID,
67
+ __s: utils.getSignatureID(),
68
+ __hsi: ctx.hsi,
69
+ __comet_req: 15,
70
+ fb_dtsg: ctx.fb_dtsg,
71
+ jazoest: ctx.ttstamp,
72
+ lsd: ctx.fb_dtsg,
73
+ __spin_r: ctx.req_ID,
74
+ __spin_b: "trunk",
75
+ __spin_t: Date.now(),
76
+ fb_api_caller_class: "RelayModern",
77
+ fb_api_req_friendly_name: "useStoriesSendReplyMutation",
78
+ variables: JSON.stringify({
79
+ input: {
80
+ attribution_id_v2: `StoriesCometSuspenseRoot.react,comet.stories.viewer,unexpected,${Date.now()},356653,,;CometHomeRoot.react,comet.home,tap_tabbar,${Date.now()},109945,4748854339,,`,
81
+ lightweight_reaction_actions: {
82
+ offsets: [0],
83
+ reaction: reaction
84
+ },
85
+ message: reaction,
86
+ story_id: storyID,
87
+ story_reply_type: "LIGHT_WEIGHT",
88
+ actor_id: ctx.userID,
89
+ client_mutation_id: String(Math.floor(Math.random() * 16) + 1)
90
+ }
91
+ }),
92
+ server_timestamps: true,
93
+ doc_id: "9697491553691692"
94
+ };
95
+
96
+ defaultFuncs
97
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
98
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
99
+ .then(function (resData) {
100
+ if (resData.error) throw resData;
101
+
102
+ // Parse successful response
103
+ if (resData.data && resData.data.direct_message_reply) {
104
+ const replyData = resData.data.direct_message_reply;
105
+ return callback(null, {
106
+ success: true,
107
+ client_mutation_id: replyData.client_mutation_id,
108
+ story_id: replyData.story?.id || storyID,
109
+ reaction: reaction,
110
+ story_reactions: replyData.story?.story_card_info?.story_card_reactions?.edges || [],
111
+ timestamp: Date.now()
112
+ });
113
+ }
114
+
115
+ return callback(null, {
116
+ success: true,
117
+ reaction: reaction,
118
+ story_id: storyID,
119
+ timestamp: Date.now()
120
+ });
121
+ })
122
+ .catch(function (err) {
123
+ log.error("setStoryReaction", err);
124
+ return callback(err);
125
+ });
126
+
127
+ return returnPromise;
128
+ };
129
+ };
@@ -0,0 +1,99 @@
1
+
2
+ 'use strict';
3
+
4
+ var utils = require('../utils.js');
5
+ var log = require('npmlog');
6
+
7
+ module.exports = function(defaultFuncs, api, ctx) {
8
+
9
+ return function setStorySeen(storyID, callback) {
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
+ if (!storyID) {
25
+ return callback({ error: "storyID is required" });
26
+ }
27
+
28
+ // Extract bucket_id from story_id if needed
29
+ var bucketID = storyID;
30
+ if (typeof storyID === 'string' && storyID.includes(':')) {
31
+ // Extract bucket ID from the story ID pattern
32
+ try {
33
+ var decoded = Buffer.from(storyID, 'base64').toString('utf-8');
34
+ var match = decoded.match(/(\d+)/);
35
+ if (match) {
36
+ bucketID = match[1];
37
+ }
38
+ } catch (e) {
39
+ // Fallback to using story ID as bucket ID
40
+ bucketID = storyID;
41
+ }
42
+ }
43
+
44
+ var form = {
45
+ av: ctx.userID,
46
+ __aaid: 0,
47
+ __user: ctx.userID,
48
+ __a: 1,
49
+ __req: utils.getSignatureID(),
50
+ __hs: ctx.fb_dtsg_ag,
51
+ dpr: 1,
52
+ __ccg: "EXCELLENT",
53
+ __rev: ctx.req_ID,
54
+ __s: utils.getSignatureID(),
55
+ __hsi: ctx.hsi,
56
+ __comet_req: 15,
57
+ fb_dtsg: ctx.fb_dtsg,
58
+ jazoest: ctx.ttstamp,
59
+ lsd: ctx.fb_dtsg,
60
+ __spin_r: ctx.req_ID,
61
+ __spin_b: "trunk",
62
+ __spin_t: Date.now(),
63
+ fb_api_caller_class: "RelayModern",
64
+ fb_api_req_friendly_name: "storiesUpdateSeenStateMutation",
65
+ variables: JSON.stringify({
66
+ input: {
67
+ bucket_id: bucketID,
68
+ story_id: storyID,
69
+ actor_id: ctx.userID,
70
+ client_mutation_id: String(Math.floor(Math.random() * 16) + 1)
71
+ },
72
+ scale: 1
73
+ }),
74
+ server_timestamps: true,
75
+ doc_id: "9567413276713742"
76
+ };
77
+
78
+ defaultFuncs
79
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
80
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
81
+ .then(function (resData) {
82
+ if (resData.error) throw resData;
83
+
84
+ return callback(null, {
85
+ success: true,
86
+ story_id: storyID,
87
+ bucket_id: bucketID,
88
+ seen_time: Date.now(),
89
+ response: resData
90
+ });
91
+ })
92
+ .catch(function (err) {
93
+ log.error("setStorySeen", err);
94
+ return callback(err);
95
+ });
96
+
97
+ return returnPromise;
98
+ };
99
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var utils = require("../utils");
3
+ module.exports = function (defaultFuncs, api, ctx) {
4
+ return function setThreadTheme(themeID, threadID, callback) {
5
+ var { promise, callback: cb } = utils.wrapCallback(callback);
6
+ defaultFuncs.post("https://www.facebook.com/api/graphql/", ctx.jar, {
7
+ fb_api_req_friendly_name: "CometMessengerColorTetraSaveThemeMutation",
8
+ fb_api_caller_class: "RelayModern",
9
+ doc_id: "5785972814783490",
10
+ variables: JSON.stringify({ input: { actor_id: ctx.userID, client_mutation_id: String(ctx.clientMutationId++), thread_key: { thread_fbid: threadID }, theme_id: String(themeID) } })
11
+ })
12
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
13
+ .then(resData => { if (resData.error) throw resData; cb(null, resData); })
14
+ .catch(err => cb(err));
15
+ return promise;
16
+ };
17
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var utils = require("../utils");
3
+ module.exports = function (defaultFuncs, api, ctx) {
4
+ return function setTitle(newTitle, threadID, callback) {
5
+ var { promise, callback: cb } = utils.wrapCallback(callback);
6
+ defaultFuncs.post("https://www.facebook.com/messaging/set_thread_name/", ctx.jar, {
7
+ thread_name: newTitle,
8
+ thread_id: threadID
9
+ })
10
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
11
+ .then(resData => { if (resData.error) throw resData; cb(null, resData); })
12
+ .catch(err => cb(err));
13
+ return promise;
14
+ };
15
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var utils = require("../utils");
3
+ module.exports = function (defaultFuncs, api, ctx) {
4
+ return function shareContact(text, senderID, threadID, callback) {
5
+ var { promise, callback: cb } = utils.wrapCallback(callback);
6
+ var mqttClient = ctx.mqttClient || global.mqttClient;
7
+ if (!mqttClient) { cb({ error: "MQTT not connected" }); return promise; }
8
+ ctx.wsReqNumber = (ctx.wsReqNumber || 0) + 1;
9
+ ctx.wsTaskNumber = (ctx.wsTaskNumber || 0) + 1;
10
+ var queryPayload = { contact_id: senderID, sync_group: 1, text: text || "", thread_id: threadID };
11
+ var query = {
12
+ failure_count: null, label: '359',
13
+ payload: JSON.stringify(queryPayload),
14
+ queue_name: 'messenger_contact_sharing',
15
+ task_id: Math.random() * 1001 << 0
16
+ };
17
+ var content = {
18
+ app_id: '2220391788200892',
19
+ payload: JSON.stringify({
20
+ tasks: [query],
21
+ epoch_id: utils.generateOfflineThreadingID(),
22
+ version_id: '7214102258676893'
23
+ }),
24
+ request_id: ctx.wsReqNumber,
25
+ type: 3
26
+ };
27
+ if (typeof callback === "function") {
28
+ ctx.callback_Task[ctx.wsReqNumber] = { callback: cb, type: "shareContact" };
29
+ }
30
+ mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
31
+ return promise;
32
+ };
33
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var utils = require("../utils");
3
+ module.exports = function (defaultFuncs, api, ctx) {
4
+ return function shareLink(url, threadID, message, callback) {
5
+ if (typeof message === "function") { callback = message; message = ""; }
6
+ return api.sendMessage({ body: message || "", url }, threadID, callback);
7
+ };
8
+ };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var utils = require("../utils");
3
+ module.exports = function (defaultFuncs, api, ctx) {
4
+ return function sharePost(postID, message, callback) {
5
+ if (typeof message === "function") { callback = message; message = ""; }
6
+ var { promise, callback: cb } = utils.wrapCallback(callback);
7
+ defaultFuncs.post("https://www.facebook.com/api/graphql/", ctx.jar, {
8
+ fb_api_req_friendly_name: "ComposerStoryCreateMutation",
9
+ fb_api_caller_class: "RelayModern",
10
+ doc_id: "6678754238817627",
11
+ variables: JSON.stringify({
12
+ input: {
13
+ actor_id: ctx.userID,
14
+ client_mutation_id: String(ctx.clientMutationId++),
15
+ composer_entry_point: "inline_jenga",
16
+ with_tags_ids: [],
17
+ message: { ranges: [], text: message || "" },
18
+ audience: { undirected_target_type: "SELF" },
19
+ attached_story_fbid: String(postID),
20
+ is_default_story: true,
21
+ is_inline_share: true,
22
+ inline_share_target: { inline_share_target_fbid: String(postID) }
23
+ }
24
+ })
25
+ })
26
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
27
+ .then(resData => { if (resData.error) throw resData; cb(null, resData); })
28
+ .catch(err => cb(err));
29
+ return promise;
30
+ };
31
+ };