fca-horidai-remastered 1.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/CountTime.json +1 -0
  2. package/Extra/Balancer.js +49 -0
  3. package/Extra/Database/index.js +4 -4
  4. package/Extra/ExtraGetThread.js +22 -22
  5. package/Extra/Security/Base/index.js +5 -5
  6. package/Extra/Src/Release_Memory.js +5 -5
  7. package/Extra/Src/Websocket.js +3 -3
  8. package/Language/index.json +10 -4
  9. package/Main.js +209 -29
  10. package/index.js +11 -11
  11. package/package.json +7 -7
  12. package/src/acpUsers.js +40 -0
  13. package/src/addFriends.js +37 -0
  14. package/src/changeAvatar.js +93 -0
  15. package/src/changeBlockedStatusMqtt.js +79 -0
  16. package/src/changeCover.js +73 -0
  17. package/src/changeName.js +79 -0
  18. package/src/createCommentPost.js +228 -0
  19. package/src/createPollMqtt.js +56 -0
  20. package/src/createPost.js +277 -0
  21. package/src/createPostGroup.js +79 -0
  22. package/src/forwardMessage.js +60 -0
  23. package/src/getAcceptList.js +38 -0
  24. package/src/getThreadInfoDeprecated.js +56 -0
  25. package/src/listenMqtt.js +38 -18
  26. package/src/pinMessage.js +58 -0
  27. package/src/refreshFb_dtsg.js +81 -0
  28. package/src/sendComment.js +161 -0
  29. package/src/setMessageReactionMqtt.js +62 -0
  30. package/src/setStoryReaction.js +53 -0
  31. package/src/setTheme.js +310 -0
  32. package/src/unsendMessage.js +28 -20
  33. package/src/unsendMessageMqtt.js +59 -0
  34. package/src/unsendMqttMessage.js +66 -0
  35. package/src/uploadAttachment.js +95 -0
  36. package/test/Db2.js +4 -4
  37. package/test/Horizon_Database/Database.sqlite +0 -0
  38. package/test/Horizon_Database/SyntheticDatabase.sqlite +0 -0
  39. package/utils.js +45 -6
  40. package/.gitattributes +0 -2
  41. package/LICENSE +0 -21
  42. package/README.md +0 -152
  43. package/SECURITY.md +0 -18
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
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
+ });
21
+
22
+ if (utils.getType(obj) === "Function" || utils.getType(obj) === "AsyncFunction") {
23
+ callback = obj;
24
+ obj = {};
25
+ }
26
+
27
+ if (!obj) {
28
+ obj = {};
29
+ }
30
+
31
+ if (utils.getType(obj) !== "Object") {
32
+ throw new utils.CustomError("the first parameter must be an object or a callback function");
33
+ }
34
+
35
+ if (!callback) {
36
+ callback = function (err, friendList) {
37
+ if (err) {
38
+ return rejectFunc(err);
39
+ }
40
+ resolveFunc(friendList);
41
+ };
42
+ }
43
+
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
+ }
78
+
79
+ return returnPromise;
80
+ };
81
+ };
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+ var bluebird = require("bluebird");
6
+
7
+ module.exports = function (defaultFuncs, api, ctx) {
8
+ function getGUID() {
9
+ let _0x161e32 = Date.now(),
10
+ _0x4ec135 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
11
+ /[xy]/g,
12
+ function (_0x32f946) {
13
+ let _0x141041 = Math.floor((_0x161e32 + Math.random() * 16) % 16);
14
+ _0x161e32 = Math.floor(_0x161e32 / 16);
15
+ let _0x31fcdd = (
16
+ _0x32f946 == "x" ? _0x141041 : (_0x141041 & 0x3) | 0x8
17
+ ).toString(16);
18
+ return _0x31fcdd;
19
+ },
20
+ );
21
+ return _0x4ec135;
22
+ }
23
+
24
+ function uploadAttachment(attachment, callback) {
25
+ var uploads = [];
26
+
27
+ // create an array of promises
28
+ if (!utils.isReadableStream(attachment)) {
29
+ throw {
30
+ error:
31
+ "Attachment should be a readable stream and not " +
32
+ utils.getType(attachment) +
33
+ ".",
34
+ };
35
+ }
36
+
37
+ var form = {
38
+ file: attachment,
39
+ av: api.getCurrentUserID(),
40
+ profile_id: api.getCurrentUserID(),
41
+ source: "19",
42
+ target_id: api.getCurrentUserID(),
43
+ __user: api.getCurrentUserID(),
44
+ __a: "1",
45
+ };
46
+
47
+ uploads.push(
48
+ defaultFuncs
49
+ .postFormData(
50
+ "https://www.facebook.com/ajax/ufi/upload",
51
+ ctx.jar,
52
+ form,
53
+ {},
54
+ )
55
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
56
+ .then(function (resData) {
57
+ if (resData.error) {
58
+ throw resData;
59
+ }
60
+
61
+ // We have to return the data unformatted unless we want to change it
62
+ // back in sendMessage.
63
+ return resData.payload;
64
+ }),
65
+ );
66
+
67
+ // resolve all promises
68
+ bluebird
69
+ .all(uploads)
70
+ .then(function (resData) {
71
+ callback(null, resData);
72
+ })
73
+ .catch(function (err) {
74
+ log.error("uploadAttachment", err);
75
+ return callback(err);
76
+ });
77
+ }
78
+
79
+ async function sendCommentToFb(postId, text, fileID) {
80
+ const feedback_id = Buffer.from("feedback:" + postId).toString("base64");
81
+
82
+ const ss1 = getGUID();
83
+ const ss2 = getGUID();
84
+
85
+ const form = {
86
+ av: api.getCurrentUserID(),
87
+ fb_api_req_friendly_name: "CometUFICreateCommentMutation",
88
+ fb_api_caller_class: "RelayModern",
89
+ doc_id: "4744517358977326",
90
+ variables: JSON.stringify({
91
+ displayCommentsFeedbackContext: null,
92
+ displayCommentsContextEnableComment: null,
93
+ displayCommentsContextIsAdPreview: null,
94
+ displayCommentsContextIsAggregatedShare: null,
95
+ displayCommentsContextIsStorySet: null,
96
+ feedLocation: "TIMELINE",
97
+ feedbackSource: 0,
98
+ focusCommentID: null,
99
+ includeNestedComments: false,
100
+ input: {
101
+ attachments: fileID ? [{ media: { id: fileID } }] : null,
102
+ feedback_id: feedback_id,
103
+ formatting_style: null,
104
+ message: {
105
+ ranges: [],
106
+ text: text,
107
+ },
108
+ is_tracking_encrypted: true,
109
+ tracking: [],
110
+ feedback_source: "PROFILE",
111
+ idempotence_token: "client:" + ss1,
112
+ session_id: ss2,
113
+ actor_id: api.getCurrentUserID(),
114
+ client_mutation_id: Math.round(Math.random() * 19),
115
+ },
116
+ scale: 3,
117
+ useDefaultActor: false,
118
+ UFI2CommentsProvider_commentsKey: "ProfileCometTimelineRoute",
119
+ }),
120
+ };
121
+
122
+ const res = JSON.parse(
123
+ await api.httpPost("https://www.facebook.com/api/graphql/", form),
124
+ );
125
+ return res;
126
+ }
127
+
128
+ return async function sendComment(content, postId, callback) {
129
+ if (typeof content === "object") {
130
+ var text = content.body || "";
131
+ if (content.attachment) {
132
+ if (!utils.isReadableStream(content.attachment)) {
133
+ throw new Error("Attachment must be a ReadableStream");
134
+ }
135
+
136
+ uploadAttachment(content.attachment, async function (err, files) {
137
+ if (err) {
138
+ return callback(err);
139
+ }
140
+
141
+ await sendCommentToFb(postId, text, files[0].fbid)
142
+ .then((res) => {
143
+ return callback(null, res);
144
+ })
145
+ .catch((err) => {
146
+ return callback(err);
147
+ });
148
+ });
149
+ }
150
+ } else if (typeof content === "string") {
151
+ var text = content;
152
+ await sendCommentToFb(postId, text, null)
153
+ .then((res) => {
154
+ return callback(null, res);
155
+ })
156
+ .catch((err) => {
157
+ return callback(err);
158
+ });
159
+ } else throw new Error("Invalid content");
160
+ };
161
+ };
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ const { generateOfflineThreadingID, getCurrentTimestamp } = require('../utils');
4
+
5
+ function isCallable(func) {
6
+ try {
7
+ Reflect.apply(func, null, []);
8
+ return true;
9
+ } catch (error) {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ module.exports = function (defaultFuncs, api, ctx) {
15
+ return function setMessageReactionMqtt(reaction, messageID, threadID, callback) {
16
+ if (!ctx.mqttClient) {
17
+ throw new Error('Not connected to MQTT');
18
+ }
19
+
20
+ ctx.wsReqNumber += 1;
21
+ let taskNumber = ++ctx.wsTaskNumber;
22
+
23
+ const taskPayload = {
24
+ thread_key: threadID,
25
+ timestamp_ms: getCurrentTimestamp(),
26
+ message_id: messageID,
27
+ reaction: reaction,
28
+ actor_id: ctx.userID,
29
+ reaction_style: null,
30
+ sync_group: 1,
31
+ send_attribution: Math.random() < 0.5 ? 65537 : 524289
32
+ };
33
+
34
+ const task = {
35
+ failure_count: null,
36
+ label: '29',
37
+ payload: JSON.stringify(taskPayload),
38
+ queue_name: JSON.stringify(['reaction', messageID]),
39
+ task_id: taskNumber,
40
+ };
41
+
42
+ const content = {
43
+ app_id: '2220391788200892',
44
+ payload: JSON.stringify({
45
+ data_trace_id: null,
46
+ epoch_id: parseInt(generateOfflineThreadingID()),
47
+ tasks: [task],
48
+ version_id: '7158486590867448',
49
+ }),
50
+ request_id: ctx.wsReqNumber,
51
+ type: 3,
52
+ };
53
+
54
+ if (isCallable(callback)) {
55
+ ctx["tasks"].set(taskNumber, {
56
+ type: 'set_message_reaction',
57
+ callback: callback
58
+ });
59
+ }
60
+ ctx.mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
61
+ };
62
+ };
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils');
4
+ var log = require('npmlog');
5
+
6
+ module.exports = function (http, api, ctx) {
7
+ return function setStoryReaction(storyID, react, callback) {
8
+ var cb;
9
+ var rtPromise = new Promise(function (resolve, reject) {
10
+ cb = error => error ? reject(error) : resolve();
11
+ });
12
+
13
+ if (typeof react == 'function') {
14
+ callback = react;
15
+ react = null;
16
+ }
17
+ if (typeof callback == 'function') cb = callback;
18
+ if (typeof react != 'string') react = '👍';
19
+
20
+ var form = {
21
+ fb_api_req_friendly_name: 'useStoriesSendReplyMutation',
22
+ variables: JSON.stringify({
23
+ input: {
24
+ attribution_id_v2: `StoriesCometSuspenseRoot.react,comet.stories.viewer,unexpected,${Date.now()},538296,,;CometHomeRoot.react,comet.home,via_cold_start,${Date.now()},850302,4748854339,`,
25
+ lightweight_reaction_actions: {
26
+ offsets: [0],
27
+ reaction: react
28
+ },
29
+ message: react,
30
+ story_id: storyID,
31
+ story_reply_type: "LIGHT_WEIGHT",
32
+ actor_id: ctx.userID,
33
+ client_mutation_id: Math.round(Math.random() * 19).toString()
34
+ }
35
+ }),
36
+ doc_id: 4826141330837571
37
+ }
38
+
39
+ http
40
+ .post('https://www.facebook.com/api/graphql/', ctx.jar, form)
41
+ .then(utils.parseAndCheckLogin(ctx, http))
42
+ .then(function (res) {
43
+ if (res.errors) throw res;
44
+ return cb();
45
+ })
46
+ .catch(function (err) {
47
+ log.error('setPostReaction', err);
48
+ return cb(err);
49
+ });
50
+
51
+ return rtPromise;
52
+ }
53
+ }
@@ -0,0 +1,310 @@
1
+ 'use strict';
2
+
3
+ const { generateOfflineThreadingID, getCurrentTimestamp } = require('../utils');
4
+
5
+ function isCallable(func) {
6
+ try {
7
+ Reflect.apply(func, null, []);
8
+ return true;
9
+ } catch (error) {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ const themes = [
15
+ {
16
+ "id": "3650637715209675",
17
+ "name": "Besties"
18
+ },
19
+ {
20
+ "id": "769656934577391",
21
+ "name": "Women's History Month"
22
+ },
23
+ {
24
+ "id": "702099018755409",
25
+ "name": "Dune: Part Two"
26
+ },
27
+ {
28
+ "id": "1480404512543552",
29
+ "name": "Avatar: The Last Airbender"
30
+ },
31
+ {
32
+ "id": "952656233130616",
33
+ "name": "J.Lo"
34
+ },
35
+ {
36
+ "id": "741311439775765",
37
+ "name": "Love"
38
+ },
39
+ {
40
+ "id": "215565958307259",
41
+ "name": "Bob Marley: One Love"
42
+ },
43
+ {
44
+ "id": "194982117007866",
45
+ "name": "Football"
46
+ },
47
+ {
48
+ "id": "1743641112805218",
49
+ "name": "Soccer"
50
+ },
51
+ {
52
+ "id": "730357905262632",
53
+ "name": "Mean Girls"
54
+ },
55
+ {
56
+ "id": "1270466356981452",
57
+ "name": "Wonka"
58
+ },
59
+ {
60
+ "id": "704702021720552",
61
+ "name": "Pizza"
62
+ },
63
+ {
64
+ "id": "1013083536414851",
65
+ "name": "Wish"
66
+ },
67
+ {
68
+ "id": "359537246600743",
69
+ "name": "Trolls"
70
+ },
71
+ {
72
+ "id": "173976782455615",
73
+ "name": "The Marvels"
74
+ },
75
+ {
76
+ "id": "2317258455139234",
77
+ "name": "One Piece"
78
+ },
79
+ {
80
+ "id": "6685081604943977",
81
+ "name": "1989"
82
+ },
83
+ {
84
+ "id": "1508524016651271",
85
+ "name": "Avocado"
86
+ },
87
+ {
88
+ "id": "265997946276694",
89
+ "name": "Loki Season 2"
90
+ },
91
+ {
92
+ "id": "6584393768293861",
93
+ "name": "olivia rodrigo"
94
+ },
95
+ {
96
+ "id": "845097890371902",
97
+ "name": "Baseball"
98
+ },
99
+ {
100
+ "id": "292955489929680",
101
+ "name": "Lollipop"
102
+ },
103
+ {
104
+ "id": "976389323536938",
105
+ "name": "Loops"
106
+ },
107
+ {
108
+ "id": "810978360551741",
109
+ "name": "Parenthood"
110
+ },
111
+ {
112
+ "id": "195296273246380",
113
+ "name": "Bubble Tea"
114
+ },
115
+ {
116
+ "id": "6026716157422736",
117
+ "name": "Basketball"
118
+ },
119
+ {
120
+ "id": "693996545771691",
121
+ "name": "Elephants & Flowers"
122
+ },
123
+ {
124
+ "id": "390127158985345",
125
+ "name": "Chill"
126
+ },
127
+ {
128
+ "id": "365557122117011",
129
+ "name": "Support"
130
+ },
131
+ {
132
+ "id": "339021464972092",
133
+ "name": "Music"
134
+ },
135
+ {
136
+ "id": "1060619084701625",
137
+ "name": "Lo-Fi"
138
+ },
139
+ {
140
+ "id": "3190514984517598",
141
+ "name": "Sky"
142
+ },
143
+ {
144
+ "id": "627144732056021",
145
+ "name": "Celebration"
146
+ },
147
+ {
148
+ "id": "275041734441112",
149
+ "name": "Care"
150
+ },
151
+ {
152
+ "id": "3082966625307060",
153
+ "name": "Astrology"
154
+ },
155
+ {
156
+ "id": "539927563794799",
157
+ "name": "Cottagecore"
158
+ },
159
+ {
160
+ "id": "527564631955494",
161
+ "name": "Ocean"
162
+ },
163
+ {
164
+ "id": "230032715012014",
165
+ "name": "Tie-Dye"
166
+ },
167
+ {
168
+ "id": "788274591712841",
169
+ "name": "Monochrome"
170
+ },
171
+ {
172
+ "id": "3259963564026002",
173
+ "name": "Default"
174
+ },
175
+ {
176
+ "id": "724096885023603",
177
+ "name": "Berry"
178
+ },
179
+ {
180
+ "id": "624266884847972",
181
+ "name": "Candy"
182
+ },
183
+ {
184
+ "id": "273728810607574",
185
+ "name": "Unicorn"
186
+ },
187
+ {
188
+ "id": "262191918210707",
189
+ "name": "Tropical"
190
+ },
191
+ {
192
+ "id": "2533652183614000",
193
+ "name": "Maple"
194
+ },
195
+ {
196
+ "id": "909695489504566",
197
+ "name": "Sushi"
198
+ },
199
+ {
200
+ "id": "582065306070020",
201
+ "name": "Rocket"
202
+ },
203
+ {
204
+ "id": "557344741607350",
205
+ "name": "Citrus"
206
+ },
207
+ {
208
+ "id": "280333826736184",
209
+ "name": "Lollipop"
210
+ },
211
+ {
212
+ "id": "271607034185782",
213
+ "name": "Shadow"
214
+ },
215
+ {
216
+ "id": "1257453361255152",
217
+ "name": "Rose"
218
+ },
219
+ {
220
+ "id": "571193503540759",
221
+ "name": "Lavender"
222
+ },
223
+ {
224
+ "id": "2873642949430623",
225
+ "name": "Tulip"
226
+ },
227
+ {
228
+ "id": "3273938616164733",
229
+ "name": "Classic"
230
+ },
231
+ {
232
+ "id": "403422283881973",
233
+ "name": "Apple"
234
+ },
235
+ {
236
+ "id": "3022526817824329",
237
+ "name": "Peach"
238
+ },
239
+ {
240
+ "id": "672058580051520",
241
+ "name": "Honey"
242
+ },
243
+ {
244
+ "id": "3151463484918004",
245
+ "name": "Kiwi"
246
+ },
247
+ {
248
+ "id": "736591620215564",
249
+ "name": "Ocean"
250
+ },
251
+ {
252
+ "id": "193497045377796",
253
+ "name": "Grape"
254
+ }
255
+ ];
256
+
257
+ module.exports = function (defaultFuncs, api, ctx) {
258
+ return function setTheme(themeID, threadID, callback) {
259
+ if (!ctx.mqttClient) {
260
+ throw new Error('Not connected to MQTT');
261
+ }
262
+
263
+ ctx.wsReqNumber += 1;
264
+ ctx.wsTaskNumber += 1;
265
+
266
+ let selectedThemeID;
267
+
268
+ if (!themeID) {
269
+ // If no theme ID is provided, select a random theme from the themes array
270
+ const randomIndex = Math.floor(Math.random() * themes.length);
271
+ selectedThemeID = themes[randomIndex].id;
272
+ } else {
273
+ selectedThemeID = themeID;
274
+ }
275
+
276
+ const taskPayload = {
277
+ thread_key: threadID,
278
+ theme_fbid: selectedThemeID,
279
+ source: null,
280
+ sync_group: 1,
281
+ payload: null,
282
+ };
283
+
284
+ const task = {
285
+ failure_count: null,
286
+ label: '43',
287
+ payload: JSON.stringify(taskPayload),
288
+ queue_name: 'thread_theme',
289
+ task_id: ctx.wsTaskNumber,
290
+ };
291
+
292
+ const content = {
293
+ app_id: '2220391788200892',
294
+ payload: JSON.stringify({
295
+ data_trace_id: null,
296
+ epoch_id: parseInt(generateOfflineThreadingID()),
297
+ tasks: [task],
298
+ version_id: '25095469420099952',
299
+ }),
300
+ request_id: ctx.wsReqNumber,
301
+ type: 3,
302
+ };
303
+
304
+ if (isCallable(callback)) {
305
+ // to be implemented
306
+ }
307
+
308
+ ctx.mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
309
+ };
310
+ };