@cexy/hoonfca 1.0.7 → 2.0.1

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 (191) hide show
  1. package/LICENSE +3 -0
  2. package/examples/login-with-cookies.js +102 -0
  3. package/examples/verify.js +70 -0
  4. package/index.js +2 -8
  5. package/package.json +82 -61
  6. package/src/{api/action → apis}/addExternalModule.js +24 -25
  7. package/src/apis/addUserToGroup.js +108 -0
  8. package/src/apis/changeAdminStatus.js +148 -0
  9. package/src/apis/changeArchivedStatus.js +61 -0
  10. package/src/apis/changeAvatar.js +103 -0
  11. package/src/apis/changeBio.js +69 -0
  12. package/src/apis/changeBlockedStatus.js +54 -0
  13. package/src/apis/changeGroupImage.js +136 -0
  14. package/src/apis/changeThreadColor.js +116 -0
  15. package/src/apis/changeThreadEmoji.js +53 -0
  16. package/src/apis/comment.js +207 -0
  17. package/src/apis/createAITheme.js +129 -0
  18. package/src/apis/createNewGroup.js +79 -0
  19. package/src/apis/createPoll.js +73 -0
  20. package/src/apis/deleteMessage.js +44 -0
  21. package/src/apis/deleteThread.js +52 -0
  22. package/src/apis/e2ee.js +17 -0
  23. package/src/apis/editMessage.js +70 -0
  24. package/src/apis/emoji.js +124 -0
  25. package/src/apis/fetchThemeData.js +82 -0
  26. package/src/apis/follow.js +81 -0
  27. package/src/apis/forwardMessage.js +52 -0
  28. package/src/apis/friend.js +243 -0
  29. package/src/apis/gcmember.js +122 -0
  30. package/src/apis/gcname.js +123 -0
  31. package/src/apis/gcrule.js +119 -0
  32. package/src/apis/getAccess.js +111 -0
  33. package/src/apis/getBotInfo.js +88 -0
  34. package/src/apis/getBotInitialData.js +43 -0
  35. package/src/apis/getFriendsList.js +79 -0
  36. package/src/apis/getMessage.js +423 -0
  37. package/src/apis/getTheme.js +95 -0
  38. package/src/apis/getThemeInfo.js +116 -0
  39. package/src/apis/getThreadHistory.js +239 -0
  40. package/src/apis/getThreadInfo.js +267 -0
  41. package/src/apis/getThreadList.js +232 -0
  42. package/src/apis/getThreadPictures.js +58 -0
  43. package/src/apis/getUserID.js +117 -0
  44. package/src/apis/getUserInfo.js +513 -0
  45. package/src/{api/users → apis}/getUserInfoV2.js +146 -134
  46. package/src/apis/handleMessageRequest.js +50 -0
  47. package/src/apis/httpGet.js +63 -0
  48. package/src/apis/httpPost.js +89 -0
  49. package/src/apis/httpPostFormData.js +69 -0
  50. package/src/apis/listenMqtt.js +1236 -0
  51. package/src/apis/listenSpeed.js +179 -0
  52. package/src/apis/logout.js +87 -0
  53. package/src/apis/markAsDelivered.js +47 -0
  54. package/src/{api/messaging → apis}/markAsRead.js +99 -88
  55. package/src/apis/markAsReadAll.js +40 -0
  56. package/src/apis/markAsSeen.js +70 -0
  57. package/src/apis/mqttDeltaValue.js +278 -0
  58. package/src/apis/muteThread.js +45 -0
  59. package/src/apis/nickname.js +132 -0
  60. package/src/apis/notes.js +163 -0
  61. package/src/apis/pinMessage.js +150 -0
  62. package/src/apis/produceMetaTheme.js +180 -0
  63. package/src/apis/realtime.js +182 -0
  64. package/src/apis/removeUserFromGroup.js +117 -0
  65. package/src/apis/resolvePhotoUrl.js +58 -0
  66. package/src/apis/searchForThread.js +154 -0
  67. package/src/apis/sendMessage.js +354 -0
  68. package/src/apis/sendMessageMqtt.js +249 -0
  69. package/src/apis/sendTypingIndicator.js +91 -0
  70. package/src/apis/setMessageReaction.js +27 -0
  71. package/src/apis/setMessageReactionMqtt.js +61 -0
  72. package/src/apis/setThreadTheme.js +260 -0
  73. package/src/apis/setThreadThemeMqtt.js +94 -0
  74. package/src/apis/share.js +107 -0
  75. package/src/apis/shareContact.js +66 -0
  76. package/src/apis/stickers.js +257 -0
  77. package/src/apis/story.js +181 -0
  78. package/src/apis/theme.js +233 -0
  79. package/src/apis/unfriend.js +47 -0
  80. package/src/apis/unsendMessage.js +17 -0
  81. package/src/engine/client.js +92 -0
  82. package/src/engine/models/buildAPI.js +152 -0
  83. package/src/engine/models/loginHelper.js +519 -0
  84. package/src/engine/models/setOptions.js +88 -0
  85. package/src/security/e2ee.js +109 -0
  86. package/src/types/index.d.ts +498 -0
  87. package/src/utils/antiSuspension.js +506 -0
  88. package/src/utils/auth-helpers.js +149 -0
  89. package/src/utils/autoReLogin.js +336 -0
  90. package/src/utils/axios.js +436 -0
  91. package/src/utils/cache.js +54 -0
  92. package/src/utils/clients.js +282 -0
  93. package/src/utils/constants.js +410 -23
  94. package/src/utils/formatters/data/formatAttachment.js +370 -0
  95. package/src/utils/formatters/data/formatDelta.js +109 -0
  96. package/src/utils/formatters/index.js +159 -0
  97. package/src/utils/formatters/value/formatCookie.js +91 -0
  98. package/src/utils/formatters/value/formatDate.js +36 -0
  99. package/src/utils/formatters/value/formatID.js +16 -0
  100. package/src/utils/formatters.js +1373 -0
  101. package/src/utils/headers.js +214 -99
  102. package/src/utils/index.js +153 -0
  103. package/src/utils/monitoring.js +333 -0
  104. package/src/utils/rateLimiter.js +319 -0
  105. package/src/utils/tokenRefresh.js +657 -0
  106. package/src/utils/user-agents.js +238 -0
  107. package/src/utils/validation.js +157 -0
  108. package/CHANGELOG.md +0 -181
  109. package/DOCS.md +0 -2636
  110. package/LICENSE-MIT +0 -21
  111. package/README.md +0 -632
  112. package/func/checkUpdate.js +0 -233
  113. package/func/logger.js +0 -48
  114. package/index.d.ts +0 -746
  115. package/module/config.js +0 -67
  116. package/module/login.js +0 -154
  117. package/module/loginHelper.js +0 -1034
  118. package/module/options.js +0 -54
  119. package/src/api/action/changeAvatar.js +0 -137
  120. package/src/api/action/changeBio.js +0 -75
  121. package/src/api/action/enableAutoSaveAppState.js +0 -73
  122. package/src/api/action/getCurrentUserID.js +0 -7
  123. package/src/api/action/handleFriendRequest.js +0 -57
  124. package/src/api/action/logout.js +0 -76
  125. package/src/api/action/refreshFb_dtsg.js +0 -48
  126. package/src/api/action/setPostReaction.js +0 -106
  127. package/src/api/action/unfriend.js +0 -54
  128. package/src/api/http/httpGet.js +0 -46
  129. package/src/api/http/httpPost.js +0 -52
  130. package/src/api/http/postFormData.js +0 -47
  131. package/src/api/messaging/addUserToGroup.js +0 -68
  132. package/src/api/messaging/changeAdminStatus.js +0 -122
  133. package/src/api/messaging/changeArchivedStatus.js +0 -55
  134. package/src/api/messaging/changeBlockedStatus.js +0 -48
  135. package/src/api/messaging/changeGroupImage.js +0 -90
  136. package/src/api/messaging/changeNickname.js +0 -70
  137. package/src/api/messaging/changeThreadColor.js +0 -79
  138. package/src/api/messaging/changeThreadEmoji.js +0 -106
  139. package/src/api/messaging/createNewGroup.js +0 -88
  140. package/src/api/messaging/createPoll.js +0 -43
  141. package/src/api/messaging/createThemeAI.js +0 -98
  142. package/src/api/messaging/deleteMessage.js +0 -56
  143. package/src/api/messaging/deleteThread.js +0 -56
  144. package/src/api/messaging/editMessage.js +0 -68
  145. package/src/api/messaging/forwardAttachment.js +0 -51
  146. package/src/api/messaging/getEmojiUrl.js +0 -29
  147. package/src/api/messaging/getFriendsList.js +0 -82
  148. package/src/api/messaging/getMessage.js +0 -829
  149. package/src/api/messaging/getThemePictures.js +0 -62
  150. package/src/api/messaging/handleMessageRequest.js +0 -65
  151. package/src/api/messaging/markAsDelivered.js +0 -57
  152. package/src/api/messaging/markAsReadAll.js +0 -49
  153. package/src/api/messaging/markAsSeen.js +0 -61
  154. package/src/api/messaging/muteThread.js +0 -50
  155. package/src/api/messaging/removeUserFromGroup.js +0 -106
  156. package/src/api/messaging/resolvePhotoUrl.js +0 -43
  157. package/src/api/messaging/scheduler.js +0 -264
  158. package/src/api/messaging/searchForThread.js +0 -52
  159. package/src/api/messaging/sendMessage.js +0 -272
  160. package/src/api/messaging/sendTypingIndicator.js +0 -67
  161. package/src/api/messaging/setMessageReaction.js +0 -76
  162. package/src/api/messaging/setTitle.js +0 -119
  163. package/src/api/messaging/shareContact.js +0 -49
  164. package/src/api/messaging/threadColors.js +0 -128
  165. package/src/api/messaging/unsendMessage.js +0 -81
  166. package/src/api/messaging/uploadAttachment.js +0 -94
  167. package/src/api/socket/core/connectMqtt.js +0 -255
  168. package/src/api/socket/core/emitAuth.js +0 -106
  169. package/src/api/socket/core/getSeqID.js +0 -40
  170. package/src/api/socket/core/getTaskResponseData.js +0 -22
  171. package/src/api/socket/core/markDelivery.js +0 -12
  172. package/src/api/socket/core/parseDelta.js +0 -391
  173. package/src/api/socket/detail/buildStream.js +0 -208
  174. package/src/api/socket/detail/constants.js +0 -24
  175. package/src/api/socket/listenMqtt.js +0 -364
  176. package/src/api/socket/middleware/index.js +0 -216
  177. package/src/api/threads/getThreadHistory.js +0 -664
  178. package/src/api/threads/getThreadInfo.js +0 -438
  179. package/src/api/threads/getThreadList.js +0 -293
  180. package/src/api/threads/getThreadPictures.js +0 -78
  181. package/src/api/users/getUserID.js +0 -65
  182. package/src/api/users/getUserInfo.js +0 -327
  183. package/src/core/sendReqMqtt.js +0 -96
  184. package/src/database/models/index.js +0 -87
  185. package/src/database/models/thread.js +0 -45
  186. package/src/database/models/user.js +0 -46
  187. package/src/database/threadData.js +0 -98
  188. package/src/database/userData.js +0 -89
  189. package/src/utils/client.js +0 -320
  190. package/src/utils/format.js +0 -1115
  191. package/src/utils/request.js +0 -305
package/module/options.js DELETED
@@ -1,54 +0,0 @@
1
- const { setProxy } = require("../src/utils/request");
2
-
3
- const Boolean_Option = [
4
- "online",
5
- "selfListen",
6
- "listenEvents",
7
- "updatePresence",
8
- "forceLogin",
9
- "autoMarkDelivery",
10
- "autoMarkRead",
11
- "listenTyping",
12
- "autoReconnect",
13
- "emitReady",
14
- "selfListenEvent"
15
- ];
16
-
17
- function setOptions(globalOptions, options = {}) {
18
- for (const key of Object.keys(options)) {
19
- if (Boolean_Option.includes(key)) {
20
- globalOptions[key] = Boolean(options[key]);
21
- continue;
22
- }
23
-
24
- switch (key) {
25
- case "userAgent":
26
- globalOptions.userAgent =
27
- options.userAgent ||
28
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
29
- break;
30
-
31
- case "proxy":
32
- if (typeof options.proxy !== "string") {
33
- delete globalOptions.proxy;
34
- setProxy();
35
- } else {
36
- globalOptions.proxy = options.proxy;
37
- setProxy(options.proxy);
38
- }
39
- break;
40
-
41
- default:
42
- // Accept any future/custom option silently
43
- globalOptions[key] = options[key];
44
- break;
45
- }
46
- }
47
-
48
- return globalOptions;
49
- }
50
-
51
- module.exports = {
52
- setOptions,
53
- Boolean_Option
54
- };
@@ -1,137 +0,0 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { isReadableStream } = require("../../utils/constants");
5
- const { parseAndCheckLogin } = require("../../utils/client");
6
- const { formatID, getType } = require("../../utils/format");
7
- module.exports = function(defaultFuncs, api, ctx) {
8
- function handleUpload(image, callback) {
9
- const uploads = [];
10
-
11
- const form = {
12
- profile_id: ctx.userID,
13
- photo_source: 57,
14
- av: ctx.userID,
15
- file: image
16
- };
17
-
18
- uploads.push(
19
- defaultFuncs
20
- .postFormData(
21
- "https://www.facebook.com/profile/picture/upload/",
22
- ctx.jar,
23
- form,
24
- {}
25
- )
26
- .then(parseAndCheckLogin(ctx, defaultFuncs))
27
- .then(function(resData) {
28
- if (resData.error) {
29
- throw resData;
30
- }
31
- return resData;
32
- })
33
- );
34
-
35
- // resolve all promises
36
- Promise.all(uploads)
37
- .then(function(resData) {
38
- callback(null, resData);
39
- })
40
- .catch(function(err) {
41
- log.error("handleUpload", err);
42
- return callback(err);
43
- });
44
- }
45
-
46
- return function changeAvatar(
47
- image,
48
- caption = "",
49
- timestamp = null,
50
- callback
51
- ) {
52
- let resolveFunc = function() {};
53
- let rejectFunc = function() {};
54
- const returnPromise = new Promise(function(resolve, reject) {
55
- resolveFunc = resolve;
56
- rejectFunc = reject;
57
- });
58
-
59
- if (!timestamp && getType(caption) === "Number") {
60
- timestamp = caption;
61
- caption = "";
62
- }
63
-
64
- if (
65
- !timestamp &&
66
- !callback &&
67
- (getType(caption) == "Function" ||
68
- getType(caption) == "AsyncFunction")
69
- ) {
70
- callback = caption;
71
- caption = "";
72
- timestamp = null;
73
- }
74
-
75
- if (!callback)
76
- callback = function(err, data) {
77
- if (err) {
78
- return rejectFunc(err);
79
- }
80
- resolveFunc(data);
81
- };
82
-
83
- if (!isReadableStream(image))
84
- return callback("Image is not a readable stream");
85
-
86
- handleUpload(image, function(err, payload) {
87
- if (err) {
88
- return callback(err);
89
- }
90
-
91
- const form = {
92
- av: ctx.i_userID || ctx.userID,
93
- fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
94
- fb_api_caller_class: "RelayModern",
95
- doc_id: "5066134240065849",
96
- variables: JSON.stringify({
97
- input: {
98
- caption,
99
- existing_photo_id: payload[0].payload.fbid,
100
- expiration_time: timestamp,
101
- profile_id: ctx.i_userID || ctx.userID,
102
- profile_pic_method: "EXISTING",
103
- profile_pic_source: "TIMELINE",
104
- scaled_crop_rect: {
105
- height: 1,
106
- width: 1,
107
- x: 0,
108
- y: 0
109
- },
110
- skip_cropping: true,
111
- actor_id: ctx.i_userID || ctx.userID,
112
- client_mutation_id: Math.round(Math.random() * 19).toString()
113
- },
114
- isPage: false,
115
- isProfile: true,
116
- scale: 3
117
- })
118
- };
119
-
120
- defaultFuncs
121
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
122
- .then(parseAndCheckLogin(ctx, defaultFuncs))
123
- .then(function(resData) {
124
- if (resData.errors) {
125
- throw resData;
126
- }
127
- return callback(null, resData[0].data.profile_picture_set);
128
- })
129
- .catch(function(err) {
130
- log.error("changeAvatar", err);
131
- return callback(err);
132
- });
133
- });
134
-
135
- return returnPromise;
136
- };
137
- };
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { parseAndCheckLogin } = require("../../utils/client");
5
- const { getType } = require("../../utils/format");
6
- module.exports = function(defaultFuncs, api, ctx) {
7
- return function changeBio(bio, publish, 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
-
15
- if (!callback) {
16
- if (
17
- getType(publish) == "Function" ||
18
- getType(publish) == "AsyncFunction"
19
- ) {
20
- callback = publish;
21
- } else {
22
- callback = function(err) {
23
- if (err) {
24
- return rejectFunc(err);
25
- }
26
- resolveFunc();
27
- };
28
- }
29
- }
30
-
31
- if (getType(publish) != "Boolean") {
32
- publish = false;
33
- }
34
-
35
- if (getType(bio) != "String") {
36
- bio = "";
37
- publish = false;
38
- }
39
-
40
- const form = {
41
- fb_api_caller_class: "RelayModern",
42
- fb_api_req_friendly_name: "ProfileCometSetBioMutation",
43
- doc_id: "2725043627607610",
44
- variables: JSON.stringify({
45
- input: {
46
- bio: bio,
47
- publish_bio_feed_story: publish,
48
- actor_id: ctx.i_userID || ctx.userID,
49
- client_mutation_id: Math.round(Math.random() * 1024).toString()
50
- },
51
- hasProfileTileViewID: false,
52
- profileTileViewID: null,
53
- scale: 1
54
- }),
55
- av: ctx.i_userID || ctx.userID
56
- };
57
-
58
- defaultFuncs
59
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
60
- .then(parseAndCheckLogin(ctx, defaultFuncs))
61
- .then(function(resData) {
62
- if (resData.errors) {
63
- throw resData;
64
- }
65
-
66
- return callback();
67
- })
68
- .catch(function(err) {
69
- log.error("changeBio", err);
70
- return callback(err);
71
- });
72
-
73
- return returnPromise;
74
- };
75
- };
@@ -1,73 +0,0 @@
1
- "use strict";
2
- const fs = require("fs");
3
- const path = require("path");
4
- const logger = require("../../../func/logger");
5
-
6
- /**
7
- * Enable automatic AppState saving
8
- * @param {Object} options - Options for auto-save
9
- * @param {string} [options.filePath] - Path to save AppState (default: "appstate.json")
10
- * @param {number} [options.interval] - Save interval in milliseconds (default: 10 minutes)
11
- * @param {boolean} [options.saveOnLogin] - Save immediately on login (default: true)
12
- * @returns {Function} Function to disable auto-save
13
- */
14
- module.exports = function (defaultFuncs, api, ctx) {
15
- return function enableAutoSaveAppState(options = {}) {
16
- const filePath = options.filePath || path.join(process.cwd(), "appstate.json");
17
- const interval = options.interval || 10 * 60 * 1000; // 10 minutes default
18
- const saveOnLogin = options.saveOnLogin !== false; // default true
19
-
20
- // Save function
21
- function saveAppState() {
22
- try {
23
- const appState = api.getAppState();
24
- if (!appState || !appState.appState || appState.appState.length === 0) {
25
- logger("AppState is empty, skipping save", "warn");
26
- return;
27
- }
28
-
29
- const data = JSON.stringify(appState, null, 2);
30
- fs.writeFileSync(filePath, data, "utf8");
31
- logger(`AppState saved to ${filePath}`, "info");
32
- } catch (error) {
33
- logger(`Error saving AppState: ${error && error.message ? error.message : String(error)}`, "error");
34
- }
35
- }
36
-
37
- // Save immediately if requested
38
- let immediateSaveTimer = null;
39
- if (saveOnLogin) {
40
- // Delay a bit to ensure login is complete
41
- immediateSaveTimer = setTimeout(() => {
42
- saveAppState();
43
- immediateSaveTimer = null;
44
- }, 2000);
45
- }
46
-
47
- // Set up interval
48
- const intervalId = setInterval(saveAppState, interval);
49
- logger(`Auto-save AppState enabled: ${filePath} (every ${Math.round(interval / 1000 / 60)} minutes)`, "info");
50
-
51
- // Store interval ID for cleanup
52
- if (!ctx._autoSaveInterval) {
53
- ctx._autoSaveInterval = [];
54
- }
55
- ctx._autoSaveInterval.push(intervalId);
56
-
57
- // Return disable function
58
- return function disableAutoSaveAppState() {
59
- // Clear immediate save timer if still pending
60
- if (immediateSaveTimer) {
61
- clearTimeout(immediateSaveTimer);
62
- immediateSaveTimer = null;
63
- }
64
- // Clear interval
65
- clearInterval(intervalId);
66
- const index = ctx._autoSaveInterval ? ctx._autoSaveInterval.indexOf(intervalId) : -1;
67
- if (index !== -1) {
68
- ctx._autoSaveInterval.splice(index, 1);
69
- }
70
- logger("Auto-save AppState disabled", "info");
71
- };
72
- };
73
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = function(defaultFuncs, api, ctx) {
4
- return function getCurrentUserID() {
5
- return ctx.userID;
6
- };
7
- };
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { parseAndCheckLogin } = require("../../utils/client");
5
- const { getType } = require("../../utils/format");
6
- module.exports = function(defaultFuncs, api, ctx) {
7
- return function handleFriendRequest(userID, accept, callback) {
8
- if (getType(accept) !== "Boolean") {
9
- throw {
10
- error: "Please pass a boolean as a second argument."
11
- };
12
- }
13
-
14
- let resolveFunc = function() {};
15
- let rejectFunc = function() {};
16
- const returnPromise = new Promise(function(resolve, reject) {
17
- resolveFunc = resolve;
18
- rejectFunc = reject;
19
- });
20
-
21
- if (!callback) {
22
- callback = function(err, friendList) {
23
- if (err) {
24
- return rejectFunc(err);
25
- }
26
- resolveFunc(friendList);
27
- };
28
- }
29
-
30
- const form = {
31
- viewer_id: ctx.userID,
32
- "frefs[0]": "jwl",
33
- floc: "friend_center_requests",
34
- ref: "/reqs.php",
35
- action: accept ? "confirm" : "reject"
36
- };
37
-
38
- defaultFuncs
39
- .post("https://www.facebook.com/requests/friends/ajax/", ctx.jar, form)
40
- .then(parseAndCheckLogin(ctx, defaultFuncs))
41
- .then(function(resData) {
42
- if (resData.payload.err) {
43
- throw {
44
- err: resData.payload.err
45
- };
46
- }
47
-
48
- return callback();
49
- })
50
- .catch(function(err) {
51
- log.error("handleFriendRequest", err);
52
- return callback(err);
53
- });
54
-
55
- return returnPromise;
56
- };
57
- };
@@ -1,76 +0,0 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { parseAndCheckLogin } = require("../../utils/client");
5
- const { getFrom } = require("../../utils/constants");
6
- const { saveCookies } = require("../../utils/client");
7
- module.exports = function(defaultFuncs, api, ctx) {
8
- return function logout(callback) {
9
- let resolveFunc = function() {};
10
- let rejectFunc = function() {};
11
- const returnPromise = new Promise(function(resolve, reject) {
12
- resolveFunc = resolve;
13
- rejectFunc = reject;
14
- });
15
-
16
- if (!callback) {
17
- callback = function(err, friendList) {
18
- if (err) {
19
- return rejectFunc(err);
20
- }
21
- resolveFunc(friendList);
22
- };
23
- }
24
-
25
- const form = {
26
- pmid: "0"
27
- };
28
-
29
- defaultFuncs
30
- .post(
31
- "https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",
32
- ctx.jar,
33
- form
34
- )
35
- .then(parseAndCheckLogin(ctx, defaultFuncs))
36
- .then(function(resData) {
37
- const elem = resData.jsmods.instances[0][2][0].filter(function(v) {
38
- return v.value === "logout";
39
- })[0];
40
-
41
- const html = resData.jsmods.markup.filter(function(v) {
42
- return v[0] === elem.markup.__m;
43
- })[0][1].__html;
44
-
45
- const form = {
46
- fb_dtsg: getFrom(html, '"fb_dtsg" value="', '"'),
47
- ref: getFrom(html, '"ref" value="', '"'),
48
- h: getFrom(html, '"h" value="', '"')
49
- };
50
-
51
- return defaultFuncs
52
- .post("https://www.facebook.com/logout.php", ctx.jar, form)
53
- .then(saveCookies(ctx.jar));
54
- })
55
- .then(function(res) {
56
- if (!res.headers) {
57
- throw { error: "An error occurred when logging out." };
58
- }
59
-
60
- return defaultFuncs
61
- .get(res.headers.location, ctx.jar)
62
- .then(saveCookies(ctx.jar));
63
- })
64
- .then(function() {
65
- ctx.loggedIn = false;
66
- log.info("logout", "Logged out successfully.");
67
- callback();
68
- })
69
- .catch(function(err) {
70
- log.error("logout", err);
71
- return callback(err);
72
- });
73
-
74
- return returnPromise;
75
- };
76
- };
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { getFrom } = require("../../utils/constants");
5
- const { get } = require("../../utils/request")
6
- const { getType } = require("../../utils/format");
7
- module.exports = function (defaultFuncs, api, ctx) {
8
- return function refreshFb_dtsg(obj, callback) {
9
- if (typeof obj === "function") {
10
- callback = obj;
11
- obj = {};
12
- }
13
- if (!obj) obj = {};
14
- if (getType(obj) !== "Object") {
15
- throw new CustomError("The first parameter must be an object or a callback function");
16
- }
17
- let resolveFunc, rejectFunc;
18
- const returnPromise = new Promise((resolve, reject) => {
19
- resolveFunc = resolve;
20
- rejectFunc = reject;
21
- });
22
- if (!callback) {
23
- callback = (err, data) => err ? rejectFunc(err) : resolveFunc(data);
24
- }
25
- if (Object.keys(obj).length === 0) {
26
- get("https://www.facebook.com/", ctx.jar, null, ctx.globalOptions, { noRef: true }).then(({ data }) => {
27
- const fb_dtsg = getFrom(data, '["DTSGInitData",[],{"token":"', '","');
28
- const jazoest = getFrom(data, "jazoest=", '",');
29
- if (!fb_dtsg) throw new Error("Could not find fb_dtsg in HTML after requesting Facebook.");
30
- Object.assign(ctx, { fb_dtsg, jazoest });
31
- callback(null, {
32
- data: { fb_dtsg, jazoest },
33
- message: "Refreshed fb_dtsg and jazoest",
34
- });
35
- }).catch(err => {
36
- console.error("refreshFb_dtsg", err);
37
- callback(err);
38
- });
39
- } else {
40
- Object.assign(ctx, obj);
41
- callback(null, {
42
- data: obj,
43
- message: `Refreshed ${Object.keys(obj).join(", ")}`,
44
- });
45
- }
46
- return returnPromise;
47
- };
48
- };
@@ -1,106 +0,0 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { parseAndCheckLogin } = require("../../utils/client");
5
- const { getType } = require("../../utils/format");
6
- function formatData(resData) {
7
- return {
8
- viewer_feedback_reaction_info:
9
- resData.feedback_react.feedback.viewer_feedback_reaction_info,
10
- supported_reactions: resData.feedback_react.feedback.supported_reactions,
11
- top_reactions: resData.feedback_react.feedback.top_reactions.edges,
12
- reaction_count: resData.feedback_react.feedback.reaction_count
13
- };
14
- }
15
-
16
- module.exports = function(defaultFuncs, api, ctx) {
17
- return function setPostReaction(postID, type, callback) {
18
- let resolveFunc = function() {};
19
- let rejectFunc = function() {};
20
- const returnPromise = new Promise(function(resolve, reject) {
21
- resolveFunc = resolve;
22
- rejectFunc = reject;
23
- });
24
-
25
- if (!callback) {
26
- if (
27
- getType(type) === "Function" ||
28
- getType(type) === "AsyncFunction"
29
- ) {
30
- callback = type;
31
- type = 0;
32
- } else {
33
- callback = function(err, data) {
34
- if (err) {
35
- return rejectFunc(err);
36
- }
37
- resolveFunc(data);
38
- };
39
- }
40
- }
41
-
42
- const map = {
43
- unlike: 0,
44
- like: 1,
45
- heart: 2,
46
- love: 16,
47
- haha: 4,
48
- wow: 3,
49
- sad: 7,
50
- angry: 8
51
- };
52
-
53
- if (getType(type) !== "Number" && getType(type) === "String") {
54
- type = map[type.toLowerCase()];
55
- }
56
-
57
- if (getType(type) !== "Number" && getType(type) !== "String") {
58
- throw {
59
- error: "setPostReaction: Invalid reaction type"
60
- };
61
- }
62
-
63
- if (type != 0 && !type) {
64
- throw {
65
- error: "setPostReaction: Invalid reaction type"
66
- };
67
- }
68
-
69
- const form = {
70
- av: ctx.userID,
71
- fb_api_caller_class: "RelayModern",
72
- fb_api_req_friendly_name: "CometUFIFeedbackReactMutation",
73
- doc_id: "4769042373179384",
74
- variables: JSON.stringify({
75
- input: {
76
- actor_id: ctx.userID,
77
- feedback_id: Buffer.from("feedback:" + postID).toString("base64"),
78
- feedback_reaction: type,
79
- feedback_source: "OBJECT",
80
- is_tracking_encrypted: true,
81
- tracking: [],
82
- session_id: "f7dd50dd-db6e-4598-8cd9-561d5002b423",
83
- client_mutation_id: Math.round(Math.random() * 19).toString()
84
- },
85
- useDefaultActor: false,
86
- scale: 3
87
- })
88
- };
89
-
90
- defaultFuncs
91
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
92
- .then(parseAndCheckLogin(ctx, defaultFuncs))
93
- .then(function(resData) {
94
- if (resData.errors) {
95
- throw resData;
96
- }
97
- return callback(null, formatData(resData.data));
98
- })
99
- .catch(function(err) {
100
- log.error("setPostReaction", err);
101
- return callback(err);
102
- });
103
-
104
- return returnPromise;
105
- };
106
- };
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { parseAndCheckLogin } = require("../../utils/client");
5
- module.exports = function(defaultFuncs, api, ctx) {
6
- return function unfriend(userID, 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
-
14
- if (!callback) {
15
- callback = function(err, friendList) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc(friendList);
20
- };
21
- }
22
-
23
- const form = {
24
- uid: userID,
25
- unref: "bd_friends_tab",
26
- floc: "friends_tab",
27
- "nctr[_mod]":
28
- "pagelet_timeline_app_collection_" +
29
- ctx.userID +
30
- ":2356318349:2"
31
- };
32
-
33
- defaultFuncs
34
- .post(
35
- "https://www.facebook.com/ajax/profile/removefriendconfirm.php",
36
- ctx.jar,
37
- form
38
- )
39
- .then(parseAndCheckLogin(ctx, defaultFuncs))
40
- .then(function(resData) {
41
- if (resData.error) {
42
- throw resData;
43
- }
44
-
45
- return callback(null, true);
46
- })
47
- .catch(function(err) {
48
- log.error("unfriend", err);
49
- return callback(err);
50
- });
51
-
52
- return returnPromise;
53
- };
54
- };