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,79 @@
1
+ 'use strict';
2
+
3
+ const { generateOfflineThreadingID, getCurrentTimestamp, getGUID } = 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 changeBlockedStatusMqtt(userID, status, type, callback) {
16
+ if (!ctx.mqttClient) {
17
+ throw new Error('Not connected to MQTT');
18
+ }
19
+
20
+ ctx.wsReqNumber += 1;
21
+ ctx.wsTaskNumber += 1;
22
+
23
+ const label = '334';
24
+ let userBlockAction = 0;
25
+
26
+ switch (type) {
27
+ case 'messenger':
28
+ if (status) {
29
+ userBlockAction = 1; // Block
30
+ } else {
31
+ userBlockAction = 0; // Unblock
32
+ }
33
+ break;
34
+ case 'facebook':
35
+ if (status) {
36
+ userBlockAction = 3; // Block
37
+ } else {
38
+ userBlockAction = 2; // Unblock
39
+ }
40
+ break;
41
+ default:
42
+ throw new Error('Invalid type');
43
+ }
44
+
45
+ const taskPayload = {
46
+ blockee_id: userID,
47
+ request_id: getGUID(),
48
+ user_block_action: userBlockAction,
49
+ };
50
+
51
+ const payload = JSON.stringify(taskPayload);
52
+ const version = '25393437286970779';
53
+
54
+ const task = {
55
+ failure_count: null,
56
+ label: label,
57
+ payload: payload,
58
+ queue_name: 'native_sync_block',
59
+ task_id: ctx.wsTaskNumber,
60
+ };
61
+
62
+ const content = {
63
+ app_id: '2220391788200892',
64
+ payload: JSON.stringify({
65
+ tasks: [task],
66
+ epoch_id: parseInt(generateOfflineThreadingID()),
67
+ version_id: version,
68
+ }),
69
+ request_id: ctx.wsReqNumber,
70
+ type: 3,
71
+ };
72
+
73
+ if (isCallable(callback)) {
74
+ // to be implemented
75
+ }
76
+
77
+ ctx.mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
78
+ };
79
+ };
@@ -0,0 +1,73 @@
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 changeCover(image, callback) {
8
+ var cb;
9
+ var rt = new Promise(function (resolve, reject) {
10
+ cb = (error, url) => error ? reject(error) : resolve(url);
11
+ });
12
+
13
+ if (typeof image == 'function') {
14
+ callback = image;
15
+ image = null;
16
+ }
17
+ if (typeof callback == 'function') cb = callback;
18
+ if (!utils.isReadableStream(image)) {
19
+ var error = 'image should be a readable stream, not ' + utils.getType(image);
20
+ log.error('changeCover', error);
21
+ cb(error);
22
+ }
23
+ else {
24
+ http
25
+ .postFormData('https://www.facebook.com/profile/picture/upload/', ctx.jar, {
26
+ profile_id: ctx.userID,
27
+ photo_source: 57,
28
+ av: ctx.userID,
29
+ file: image
30
+ })
31
+ .then(utils.parseAndCheckLogin(ctx, http))
32
+ .then(function (res) {
33
+ if (res.error || res.errors || !res.payload)
34
+ throw res;
35
+
36
+ var vari = {
37
+ input: {
38
+ attribution_id_v2: `ProfileCometCollectionRoot.react,comet.profile.collection.photos_by,unexpected,${Date.now()},770083,,;ProfileCometCollectionRoot.react,comet.profile.collection.photos_albums,unexpected,${Date.now()},470774,,;ProfileCometCollectionRoot.react,comet.profile.collection.photos,unexpected,${Date.now()},94740,,;ProfileCometCollectionRoot.react,comet.profile.collection.saved_reels_on_profile,unexpected,${Date.now()},89669,,;ProfileCometCollectionRoot.react,comet.profile.collection.reels_tab,unexpected,${Date.now()},152201,,`,
39
+ cover_photo_id: res.payload.fbid,
40
+ focus: {
41
+ x: 0.5,
42
+ y: 1
43
+ },
44
+ target_user_id: ctx.userID,
45
+ actor_id: ctx.userID,
46
+ client_mutation_id: Math.round(Math.random() * 19).toString()
47
+ },
48
+ scale: 1,
49
+ contextualProfileContext: null
50
+ }
51
+ return http
52
+ .post('https://www.facebook.com/api/graphql', ctx.jar, {
53
+ doc_id: 8247793861913071,
54
+ server_timestamps: true,
55
+ fb_api_req_friendly_name: 'ProfileCometCoverPhotoUpdateMutation',
56
+ variables: JSON.stringify(vari)
57
+ })
58
+ .then(utils.parseAndCheckLogin(ctx, http));
59
+ })
60
+ .then(function (res) {
61
+ if (res.errors)
62
+ throw res;
63
+ return cb(null, res.data.user_update_cover_photo.user.cover_photo.photo.url);
64
+ })
65
+ .catch(function (err) {
66
+ log.error('changeCover', err);
67
+ return cb(err);
68
+ });
69
+ }
70
+
71
+ return rt;
72
+ }
73
+ }
@@ -0,0 +1,79 @@
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 changeName(input, format, callback) {
8
+ var cb;
9
+ var rt = new Promise(function (resolve, reject) {
10
+ cb = error => error ? reject(error) : resolve();
11
+ });
12
+
13
+ if (typeof input == 'function') {
14
+ callback = input;
15
+ input = null;
16
+ }
17
+ if (typeof format == 'function') {
18
+ callback = format;
19
+ format = 'complete';
20
+ }
21
+ if (typeof callback == 'function') cb = callback;
22
+ if (utils.getType(input) != 'Object') {
23
+ var error = 'name must be an object, not ' + utils.getType(input);
24
+ log('changeName', error);
25
+ return cb(error);
26
+ }
27
+
28
+ var { first_name, middle_name, last_name } = input;
29
+ if (!first_name || !last_name) {
30
+ log.error('changeName', 'name is not be accepted');
31
+ return cb('name is not be accepted');
32
+ }
33
+
34
+ middle_name = middle_name || '';
35
+
36
+ var full_name =
37
+ format == 'complete' ? last_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + first_name :
38
+ format == 'standard' ? last_name + ' ' + first_name :
39
+ format == 'reversed' ? first_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + last_name :
40
+ last_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + first_name;
41
+
42
+ var form = {
43
+ fb_api_caller_class: 'RelayModern',
44
+ fb_api_req_friendly_name: 'useFXIMUpdateNameMutation',
45
+ variables: JSON.stringify({
46
+ client_mutation_id: utils.getGUID(),
47
+ family_device_id: "device_id_fetch_datr",
48
+ identity_ids: [ctx.userID],
49
+ full_name,
50
+ first_name,
51
+ middle_name,
52
+ last_name,
53
+ interface: 'FB_WEB'
54
+ }),
55
+ server_timestamps: true,
56
+ doc_id: '5763510853763960'
57
+ }
58
+
59
+ http
60
+ .post('https://accountscenter.facebook.com/api/graphql/', ctx.jar, form, null, null, {
61
+ Origin: 'https://accountscenter.facebook.com',
62
+ Referer: `https://accountscenter.facebook.com/profiles/${ctx.userID}/name`
63
+ })
64
+ .then(utils.parseAndCheckLogin(ctx, http))
65
+ .then(function (res) {
66
+ if (res.errors)
67
+ throw res;
68
+ else if (res.data.fxim_update_identity_name.error)
69
+ throw res.data.fxim_update_identity_name.error;
70
+ return cb();
71
+ })
72
+ .catch(function (err) {
73
+ log.error('changeName', err);
74
+ return cb(err);
75
+ });
76
+
77
+ return rt;
78
+ }
79
+ }
@@ -0,0 +1,228 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils.js');
4
+ var log = require('npmlog');
5
+
6
+ module.exports = function (http, api, ctx) {
7
+ function handleUpload(msg, form) {
8
+ var cb;
9
+ var uploads = [];
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ cb = error => error ? reject(error) : resolve();
12
+ });
13
+
14
+ for (let item of msg.attachments) {
15
+ if (!utils.isReadableStream(item))
16
+ return cb({ error: 'image should be a readable stream and not ' + utils.getType(image) });
17
+
18
+ var httpData = http
19
+ .postFormData('https://www.facebook.com/ajax/ufi/upload/', ctx.jar, {
20
+ profile_id: ctx.userID,
21
+ source: 19,
22
+ target_id: ctx.userID,
23
+ file: item
24
+ })
25
+ .then(utils.parseAndCheckLogin(ctx, http))
26
+ .then(function (res) {
27
+ if (res.errors || res.error || !res.payload)
28
+ throw res;
29
+
30
+ return {
31
+ media: {
32
+ id: res.payload.fbid
33
+ }
34
+ }
35
+ })
36
+ .catch(cb);
37
+
38
+ uploads.push(httpData);
39
+ }
40
+
41
+ Promise
42
+ .all(uploads)
43
+ .then(function (main) {
44
+ main.forEach(item => form.input.attachments.push(item));
45
+
46
+ return cb();
47
+ })
48
+ .catch(cb);
49
+
50
+ return returnPromise;
51
+ }
52
+
53
+ function handleURL(msg, form) {
54
+ if (typeof msg.url == 'string') {
55
+ form.input.attachments = [
56
+ {
57
+ link: {
58
+ external: {
59
+ url: msg.url
60
+ }
61
+ }
62
+ }
63
+ ];
64
+ }
65
+ }
66
+
67
+ function handleMentions(msg, form) {
68
+ for (let item of msg.mentions) {
69
+ var { tag, id, fromIndex } = item;
70
+
71
+ if (typeof tag != 'string')
72
+ throw 'Mention tag must be string';
73
+ if (!id)
74
+ throw 'id must be string';
75
+ var offset = msg.body.indexOf(tag, fromIndex || 0);
76
+ if (offset < 0)
77
+ throw 'Mention for "' + tag + '" not found in message string.';
78
+ form.input.message.ranges.push({
79
+ entity: { id },
80
+ length: tag.length,
81
+ offset
82
+ });
83
+ }
84
+ }
85
+
86
+ function handleSticker(msg, form) {
87
+ if (msg.sticker) {
88
+ form.input.attachments = [
89
+ {
90
+ media: {
91
+ id: msg.sticker
92
+ }
93
+ }
94
+ ];
95
+ }
96
+ }
97
+
98
+ function createContent(form) {
99
+ var cb;
100
+ var returnPromise = new Promise(function (resolve, reject) {
101
+ cb = (error, info) => info ? resolve(info) : reject(error);
102
+ });
103
+
104
+ http
105
+ .post('https://www.facebook.com/api/graphql/', ctx.jar, {
106
+ fb_api_caller_class: 'RelayModern',
107
+ fb_api_req_friendly_name: 'useCometUFICreateCommentMutation',
108
+ variables: JSON.stringify(form),
109
+ server_timestamps: !0,
110
+ doc_id: 6993516810709754
111
+ })
112
+ .then(utils.parseAndCheckLogin(ctx, http))
113
+ .then(function (res) {
114
+ if (res.errors)
115
+ throw res;
116
+
117
+ var res = res.data.comment_create;
118
+ var info = {
119
+ id: res.feedback_comment_edge.node.id,
120
+ url: res.feedback_comment_edge.node.feedback.url,
121
+ count: res.feedback.total_comment_count
122
+ }
123
+ return cb(null, info);
124
+ })
125
+ .catch(cb);
126
+
127
+ return returnPromise;
128
+ }
129
+
130
+ return function createCommentPost(msg, postID, callback, replyCommentID) {
131
+ var cb;
132
+ var returnPromise = new Promise(function (resolve, reject) {
133
+ cb = (error, info) => info ? resolve(info) : reject(error);
134
+ });
135
+
136
+ if (typeof msg == 'function') {
137
+ var error = 'Message must be a string or object!!';
138
+ log.error('createCommentPost', error);
139
+ return msg(error);
140
+ }
141
+ if (typeof postID == 'function') {
142
+ var error = 'postID must be a string!!';
143
+ log.error('createCommentPost', error);
144
+ return postID(error);
145
+ }
146
+ if (typeof callback == 'string') {
147
+ replyCommentID = callback;
148
+ callback = null;
149
+ }
150
+ if (typeof callback == 'function')
151
+ cb = calback;
152
+
153
+ var MessageType = utils.getType(msg);
154
+
155
+ if (MessageType == 'String')
156
+ msg = {
157
+ body: msg,
158
+ attachments: [],
159
+ mentions: [],
160
+ sticker: null,
161
+ url: null
162
+ }
163
+ else if (MessageType == 'Object') {
164
+ msg.mentions ? !Array.isArray(msg.mentions) ? msg.mentions = [msg.mentions] : null : msg.mentions = [];
165
+ msg.attachments ? !Array.isArray(msg.attachments) ? msg.attachments = [msg.attachments] : null : msg.attachments = [];
166
+ isNaN(msg.sticker) ? msg.sticker = null : null;
167
+ msg.body ? typeof msg.body == 'object' ? msg.body = JSON.stringify(msg.body) : null : msg.body = '';
168
+ } else {
169
+ var error = 'Message must be a string or object!!';
170
+ log.error('createCommentPost', error);
171
+ return cb(error);
172
+ }
173
+ if (typeof postID != 'string') {
174
+ var error = 'postID must be a string!!';
175
+ log.error('createCommentPost', error);
176
+ return cb(error);
177
+ }
178
+
179
+ if (typeof replyCommentID != 'string')
180
+ replyCommentID = null;
181
+
182
+ var form = {
183
+ feedLocation: 'NEWSFEED',
184
+ feedbackSource: 1,
185
+ groupID: null,
186
+ input: {
187
+ client_mutation_id: Math.round(Math.random() * 19).toString(),
188
+ actor_id: ctx.userID,
189
+ attachments: [],
190
+ feedback_id: Buffer.from('feedback:' + postID).toString('base64'),
191
+ formatting_style: null,
192
+ message: {
193
+ ranges: [],
194
+ text: msg.body
195
+ },
196
+ reply_comment_parent_fbid: replyCommentID ? isNaN(replyCommentID) ? replyCommentID : Buffer.from('comment:' + postID + '_' + replyCommentID).toString('base64') : null,
197
+ reply_target_clicked: !!replyCommentID,
198
+ attribution_id_v2:
199
+ 'CometHomeRoot.react,comet.home,via_cold_start,'
200
+ + Date.now()
201
+ + ',156248,4748854339,,',
202
+ vod_video_timestamp: null,
203
+ feedback_referrer: '/',
204
+ is_tracking_encrypted: !0,
205
+ tracking: [],
206
+ feedback_source: 'NEWS_FEED',
207
+ idempotence_token: 'client:' + utils.getGUID(),
208
+ session_id: utils.getGUID()
209
+ },
210
+ inviteShortLinkKey: null,
211
+ renderLocation: null,
212
+ scale: 1,
213
+ useDefaultActor: !1,
214
+ focusCommentID: null
215
+ }
216
+ handleUpload(msg, form)
217
+ .then(_ => handleURL(msg, form))
218
+ .then(_ => handleMentions(msg, form))
219
+ .then(_ => handleSticker(msg, form))
220
+ .then(_ => createContent(form))
221
+ .then(info => cb(null, info))
222
+ .catch(function (err) {
223
+ log.error('createCommentPost', err);
224
+ return cb(null, err);
225
+ })
226
+ return returnPromise;
227
+ }
228
+ }
@@ -0,0 +1,56 @@
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 createPollMqtt(title, options, threadID, callback) {
16
+ if (!ctx.mqttClient) {
17
+ throw new Error('Not connected to MQTT');
18
+ }
19
+
20
+ ctx.wsReqNumber += 1;
21
+ ctx.wsTaskNumber += 1;
22
+
23
+ const taskPayload = {
24
+ question_text: title,
25
+ thread_key: threadID,
26
+ options: options,
27
+ sync_group: 1,
28
+ };
29
+
30
+ const task = {
31
+ failure_count: null,
32
+ label: '163',
33
+ payload: JSON.stringify(taskPayload),
34
+ queue_name: 'poll_creation',
35
+ task_id: ctx.wsTaskNumber,
36
+ };
37
+
38
+ const content = {
39
+ app_id: '2220391788200892',
40
+ payload: JSON.stringify({
41
+ data_trace_id: null,
42
+ epoch_id: parseInt(generateOfflineThreadingID()),
43
+ tasks: [task],
44
+ version_id: '7158486590867448',
45
+ }),
46
+ request_id: ctx.wsReqNumber,
47
+ type: 3,
48
+ };
49
+
50
+ if (isCallable(callback)) {
51
+ // to be implemented
52
+ }
53
+
54
+ ctx.mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
55
+ };
56
+ };