capfb 0.0.1-security → 1.4.91-beta

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of capfb might be problematic. Click here for more details.

Files changed (78) hide show
  1. package/.gitattributes +2 -0
  2. package/.github/dependabot.yml +11 -0
  3. package/.github/workflows/nodejs.yml +26 -0
  4. package/.github/workflows/npmpublish.yml +30 -0
  5. package/CHANGELOG.md +2 -0
  6. package/DOCS.md +1738 -0
  7. package/Extra/Database/index.js +399 -0
  8. package/Extra/Database/methods.js +286 -0
  9. package/Extra/ExtraAddons.js +78 -0
  10. package/Extra/ExtraAddonsDeprecated.js +213 -0
  11. package/Extra/ExtraGetThread.js +1 -0
  12. package/Extra/ExtraUptimeRobot.js +59 -0
  13. package/Extra/PM2/ecosystem.config.js +23 -0
  14. package/Extra/Src/Last-Run.js +48 -0
  15. package/LICENSE-MIT +21 -0
  16. package/Language/index.json +151 -0
  17. package/README.md +225 -3
  18. package/StateCrypt.js +22 -0
  19. package/broadcast.js +42 -0
  20. package/index-backup.js +1089 -0
  21. package/index.js +1130 -0
  22. package/logger.js +21 -0
  23. package/package.json +88 -3
  24. package/src/addExternalModule.js +16 -0
  25. package/src/addUserToGroup.js +78 -0
  26. package/src/changeAdminStatus.js +79 -0
  27. package/src/changeArchivedStatus.js +41 -0
  28. package/src/changeBio.js +65 -0
  29. package/src/changeBlockedStatus.js +36 -0
  30. package/src/changeGroupImage.js +106 -0
  31. package/src/changeNickname.js +45 -0
  32. package/src/changeThreadColor.js +62 -0
  33. package/src/changeThreadEmoji.js +42 -0
  34. package/src/createNewGroup.js +70 -0
  35. package/src/createPoll.js +60 -0
  36. package/src/deleteMessage.js +45 -0
  37. package/src/deleteThread.js +43 -0
  38. package/src/forwardAttachment.js +48 -0
  39. package/src/getAccessToken.js +32 -0
  40. package/src/getAccessTokenDeprecated.js +31 -0
  41. package/src/getCurrentUserID.js +7 -0
  42. package/src/getEmojiUrl.js +27 -0
  43. package/src/getFriendsList.js +73 -0
  44. package/src/getMessage.js +80 -0
  45. package/src/getThreadHistory.js +537 -0
  46. package/src/getThreadHistoryDeprecated.js +71 -0
  47. package/src/getThreadInfo.js +197 -0
  48. package/src/getThreadInfoDeprecated.js +56 -0
  49. package/src/getThreadList.js +213 -0
  50. package/src/getThreadListDeprecated.js +46 -0
  51. package/src/getThreadPictures.js +59 -0
  52. package/src/getUserID.js +62 -0
  53. package/src/getUserInfo.js +65 -0
  54. package/src/getUserInfoV2.js +35 -0
  55. package/src/handleFriendRequest.js +46 -0
  56. package/src/handleMessageRequest.js +49 -0
  57. package/src/httpGet.js +49 -0
  58. package/src/httpPost.js +48 -0
  59. package/src/httpPostFormData.js +41 -0
  60. package/src/listenMqtt.js +633 -0
  61. package/src/logout.js +68 -0
  62. package/src/markAsDelivered.js +48 -0
  63. package/src/markAsRead.js +70 -0
  64. package/src/markAsReadAll.js +43 -0
  65. package/src/markAsSeen.js +51 -0
  66. package/src/muteThread.js +47 -0
  67. package/src/removeUserFromGroup.js +49 -0
  68. package/src/resolvePhotoUrl.js +37 -0
  69. package/src/searchForThread.js +43 -0
  70. package/src/sendMessage.js +342 -0
  71. package/src/sendTypingIndicator.js +80 -0
  72. package/src/setMessageReaction.js +109 -0
  73. package/src/setPostReaction.js +102 -0
  74. package/src/setTitle.js +74 -0
  75. package/src/threadColors.js +39 -0
  76. package/src/unfriend.js +43 -0
  77. package/src/unsendMessage.js +40 -0
  78. package/utils.js +1284 -0
package/index.js ADDED
@@ -0,0 +1,1130 @@
1
+ 'use strict';
2
+
3
+ /!-[ Max Cpu Speed ]-!/
4
+
5
+ process.env.UV_THREADPOOL_SIZE = require('os').cpus().length;
6
+
7
+ /!-[ Global Set ]-!/
8
+
9
+ global.isThread = new Array();
10
+ global.isUser = new Array();
11
+ global.startTime = Date.now();
12
+ global.Data = new Object();
13
+ global.getText = require('gettext.js')();
14
+
15
+ /!-[ Require All Package Need Use ]-!/
16
+ /*globalThis.Fca = new Object({
17
+ test: console,log("test"),
18
+ Require: new Object({})
19
+ });*/
20
+ var utils = require("./utils"),
21
+ cheerio = require("cheerio"),
22
+ log = require("npmlog"),
23
+ // { getAccessToken } = require('./Extra/ExtraAddons'),
24
+ logger = require('./logger'),
25
+ fs = require('fs-extra'),
26
+ getText = require('gettext.js')(),
27
+ logger = require('./logger'),
28
+ Fetch = require('got'),
29
+ fs = require('fs-extra'),
30
+ StateCrypt = require('./StateCrypt'),
31
+ Client = require("@replit/database"),
32
+ languageFile = require('./Language/index.json'),
33
+ ObjFastConfig = {
34
+ "Language": "en",
35
+ "MainColor": "#9900FF",
36
+ "BroadCast": true,
37
+ "EncryptFeature": true,
38
+ "PreKey": "",
39
+ "Uptime": false,
40
+ "AuthString": "SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png Please remove this !, Recommend If You Using getUserInfoV2",
41
+ };
42
+
43
+
44
+ /!-[ Check File To Run Process ]-!/
45
+
46
+ try {
47
+ if (!fs.existsSync('./FastConfigFca.json')) {
48
+ fs.writeFileSync("./FastConfigFca.json", JSON.stringify(ObjFastConfig, null, "\t"));
49
+ process.exit(1);
50
+ } else if (fs.existsSync('./FastConfigFca.json')) {
51
+ try {
52
+ var DataLanguageSetting = require("../../FastConfigFca.json");
53
+ } catch (e) {
54
+ logger("Invalid Config Settings, Restoring Default...");
55
+ fs.writeFileSync("./FastConfigFca.json", JSON.stringify(ObjFastConfig, null, "\t"));
56
+ process.exit(1);
57
+ }
58
+ try {
59
+ if (DataLanguageSetting && !DataLanguageSetting.PreKey) {
60
+ DataLanguageSetting.PreKey = "";
61
+ fs.writeFileSync("./FastConfigFca.json", JSON.stringify(DataLanguageSetting, null, "\t"));
62
+ }
63
+ } catch (e) {
64
+ console.log(e);
65
+ }
66
+ if (!languageFile.some(i => i.Language == DataLanguageSetting.Language)) {
67
+ logger("Not Support Language: " + DataLanguageSetting.Language + " Only 'en' and 'vi'", "[ FCA-SUS ]");
68
+ process.exit(0);
69
+ }
70
+ var Language = languageFile.find(i => i.Language == DataLanguageSetting.Language).Folder.Index;
71
+ } else process.exit(1);
72
+ if (utils.getType(DataLanguageSetting.BroadCast) != "Boolean" && DataLanguageSetting.BroadCast != undefined) {
73
+ log.warn("FastConfig-BroadCast", getText.gettext(Language.IsNotABoolean, DataLanguageSetting.BroadCast));
74
+ process.exit(0)
75
+ } else if (DataLanguageSetting.BroadCast == undefined) {
76
+ fs.writeFileSync("./FastConfigFca.json", JSON.stringify(ObjFastConfig, null, "\t"));
77
+ process.exit(1);
78
+ }
79
+
80
+ global.FastConfig = DataLanguageSetting;
81
+
82
+ } catch (e) {
83
+ console.log(e);
84
+ logger.Error();
85
+ }
86
+
87
+ /!-[ Set Variable For Process ]-!/
88
+
89
+ log.maxRecordSize = 100;
90
+ var checkVerified = null;
91
+ var Boolean_Option = ['online','selfListen','listenEvents','updatePresence','forceLogin','autoMarkDelivery','autoMarkRead','listenTyping','autoReconnect','emitReady'];
92
+
93
+ /!-[ Function setOptions ]-!/
94
+
95
+ function setOptions(globalOptions, options) {
96
+ Object.keys(options).map(function(key) {
97
+ switch (Boolean_Option.includes(key)) {
98
+ case true: {
99
+ globalOptions[key] = Boolean(options[key]);
100
+ break;
101
+ }
102
+ case false: {
103
+ switch (key) {
104
+ case 'pauseLog': {
105
+ if (options.pauseLog) log.pause();
106
+ else log.resume();
107
+ break;
108
+ }
109
+ case 'logLevel': {
110
+ log.level = options.logLevel;
111
+ globalOptions.logLevel = options.logLevel;
112
+ break;
113
+ }
114
+ case 'logRecordSize': {
115
+ log.maxRecordSize = options.logRecordSize;
116
+ globalOptions.logRecordSize = options.logRecordSize;
117
+ break;
118
+ }
119
+ case 'pageID': {
120
+ globalOptions.pageID = options.pageID.toString();
121
+ break;
122
+ }
123
+ case 'userAgent': {
124
+ globalOptions.userAgent = (options.userAgent || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36');
125
+ break;
126
+ }
127
+ case 'proxy': {
128
+ if (typeof options.proxy != "string") {
129
+ delete globalOptions.proxy;
130
+ utils.setProxy();
131
+ } else {
132
+ globalOptions.proxy = options.proxy;
133
+ utils.setProxy(globalOptions.proxy);
134
+ }
135
+ break;
136
+ }
137
+ default: {
138
+ log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
139
+ break;
140
+ }
141
+ }
142
+ break;
143
+ }
144
+ }
145
+ });
146
+ }
147
+
148
+ /!-[ Function BuildAPI ]-!/
149
+
150
+ async function buildAPI(globalOptions, html, jar) {
151
+ var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(val) { return val.cookieString().split("=")[0] === "c_user"; });
152
+
153
+ if (maybeCookie.length === 0) throw { error: Language.ErrAppState };
154
+
155
+ if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
156
+
157
+ var userID = maybeCookie[0].cookieString().split("=")[1].toString();
158
+ logger(getText.gettext(Language.UID, userID), "[ FCA-SUS ]");
159
+ process.env['UID'] = userID;
160
+
161
+ try {
162
+ clearInterval(checkVerified);
163
+ } catch (e) {
164
+ console.log(e);
165
+ }
166
+
167
+ var clientID = (Math.random() * 2147483648 | 0).toString(16);
168
+
169
+
170
+ var CHECK_MQTT = {
171
+ oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
172
+ newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
173
+ legacyFBMQTTMatch: html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/)
174
+ }
175
+
176
+ let Slot = Object.keys(CHECK_MQTT);
177
+
178
+ var mqttEndpoint,region,irisSeqID;
179
+ Object.keys(CHECK_MQTT).map(function(MQTT) {
180
+ if (CHECK_MQTT[MQTT] && !region) {
181
+ switch (Slot.indexOf(MQTT)) {
182
+ case 0: {
183
+ irisSeqID = CHECK_MQTT[MQTT][1];
184
+ mqttEndpoint = CHECK_MQTT[MQTT][2];
185
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
186
+ return;
187
+ }
188
+ case 1: {
189
+ irisSeqID = CHECK_MQTT[MQTT][2];
190
+ mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
191
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
192
+ return;
193
+ }
194
+ case 2: {
195
+ mqttEndpoint = CHECK_MQTT[MQTT][4];
196
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
197
+ return;
198
+ }
199
+ }
200
+ return;
201
+ }
202
+ });
203
+
204
+ /* var ctx = {
205
+ userID: userID,
206
+ jar: jar,
207
+ clientID: clientID,
208
+ globalOptions: globalOptions,
209
+ loggedIn: true,
210
+ //access_token: await getAccessToken(),
211
+ clientMutationId: 0,
212
+ mqttClient: undefined,
213
+ lastSeqId: irisSeqID,
214
+ syncToken: undefined,
215
+ mqttEndpoint,
216
+ region,
217
+ firstListen: true
218
+ };*/
219
+
220
+ var ctx = {
221
+ userID: userID,
222
+ jar: jar,
223
+ clientID: clientID,
224
+ globalOptions: globalOptions,
225
+ loggedIn: true,
226
+ access_token: 'NONE',
227
+ clientMutationId: 0,
228
+ mqttClient: undefined,
229
+ lastSeqId: irisSeqID,
230
+ syncToken: undefined,
231
+ mqttEndpoint: mqttEndpoint,
232
+ region: region,
233
+ firstListen: true
234
+ };
235
+
236
+ var api = {
237
+ setOptions: setOptions.bind(null, globalOptions),
238
+ getAppState: function getAppState() {
239
+ return utils.getAppState(jar);
240
+ }
241
+ };
242
+
243
+ var api = {
244
+ setOptions: setOptions.bind(null, globalOptions),
245
+ getAppState: function getAppState() {
246
+ return utils.getAppState(jar);
247
+ }
248
+ };
249
+
250
+ if (noMqttData) api["htmlData"] = noMqttData;
251
+
252
+ const apiFuncNames = fs.readdirSync(__dirname + "/src").filter((File) => File.endsWith(".js") && !File.includes('Dev'));
253
+
254
+ var defaultFuncs = utils.makeDefaults(html, userID, ctx);
255
+
256
+ // Load all api functions in a loop
257
+ apiFuncNames.map(v => api[v.replace(".js", "")] = require('./src/' + v)(defaultFuncs, api, ctx));
258
+ return [ctx, defaultFuncs, api];
259
+ }
260
+
261
+
262
+
263
+ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
264
+ return function(res) {
265
+ var html = res.body;
266
+ var $ = cheerio.load(html);
267
+ var arr = [];
268
+
269
+ // This will be empty, but just to be sure we leave it
270
+ $("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
271
+
272
+ arr = arr.filter(function(v) {
273
+ return v.val && v.val.length;
274
+ });
275
+
276
+ var form = utils.arrToForm(arr);
277
+ form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
278
+ form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
279
+ form.email = email;
280
+ form.pass = password;
281
+ form.default_persistent = '0';
282
+ form.lgnrnd = utils.getFrom(html, "name=\"lgnrnd\" value=\"", "\"");
283
+ form.locale = 'en_US';
284
+ form.timezone = '240';
285
+ form.lgnjs = ~~(Date.now() / 1000);
286
+
287
+
288
+ // Getting cookies from the HTML page... (kill me now plz)
289
+ // we used to get a bunch of cookies in the headers of the response of the
290
+ // request, but FB changed and they now send those cookies inside the JS.
291
+ // They run the JS which then injects the cookies in the page.
292
+ // The "solution" is to parse through the html and find those cookies
293
+ // which happen to be conveniently indicated with a _js_ in front of their
294
+ // variable name.
295
+ //
296
+ // ---------- Very Hacky Part Starts -----------------
297
+ var willBeCookies = html.split("\"_js_");
298
+ willBeCookies.slice(1).map(function(val) {
299
+ var cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
300
+ jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
301
+ });
302
+ // ---------- Very Hacky Part Ends -----------------
303
+
304
+ logger(Language.OnLogin, "[ FCA-SUS ]");
305
+ return utils
306
+ .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
307
+ .then(utils.saveCookies(jar))
308
+ .then(function(res) {
309
+ var headers = res.headers;
310
+ if (!headers.location) throw { error: Language.InvaildAccount };
311
+
312
+ // This means the account has login approvals turned on.
313
+ if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
314
+ logger(Language.TwoAuth, "[ FCA-SUS ]");
315
+ var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
316
+
317
+ return utils
318
+ .get(headers.location, jar, null, loginOptions)
319
+ .then(utils.saveCookies(jar))
320
+ .then(function(res) {
321
+ var html = res.body;
322
+ // Make the form in advance which will contain the fb_dtsg and nh
323
+ var $ = cheerio.load(html);
324
+ var arr = [];
325
+ $("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
326
+
327
+ arr = arr.filter(function(v) {
328
+ return v.val && v.val.length;
329
+ });
330
+
331
+ var form = utils.arrToForm(arr);
332
+ if (html.indexOf("checkpoint/?next") > -1) {
333
+ setTimeout(() => {
334
+ checkVerified = setInterval((_form) => {}, 5000, {
335
+ fb_dtsg: form.fb_dtsg,
336
+ jazoest: form.jazoest,
337
+ dpr: 1
338
+ });
339
+ }, 2500);
340
+ throw {
341
+ error: 'login-approval',
342
+ continue: function submit2FA(code) {
343
+ form.approvals_code = code;
344
+ form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
345
+ var prResolve = null;
346
+ var prReject = null;
347
+ var rtPromise = new Promise(function(resolve, reject) {
348
+ prResolve = resolve;
349
+ prReject = reject;
350
+ });
351
+ if (typeof code == "string") {
352
+ utils
353
+ .post(nextURL, jar, form, loginOptions)
354
+ .then(utils.saveCookies(jar))
355
+ .then(function(res) {
356
+ var $ = cheerio.load(res.body);
357
+ var error = $("#approvals_code").parent().attr("data-xui-error");
358
+ if (error) {
359
+ throw {
360
+ error: 'login-approval',
361
+ errordesc: Language.InvaildTwoAuthCode,
362
+ lerror: error,
363
+ continue: submit2FA
364
+ };
365
+ }
366
+ })
367
+ .then(function() {
368
+ // Use the same form (safe I hope)
369
+ delete form.no_fido;
370
+ delete form.approvals_code;
371
+ form.name_action_selected = 'save_device'; //'save_device' || 'dont_save;
372
+
373
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
374
+ })
375
+ .then(function(res) {
376
+ var headers = res.headers;
377
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: Language.ApprovalsErr };
378
+
379
+ var appState = utils.getAppState(jar);
380
+
381
+ if (callback === prCallback) {
382
+ callback = function(err, api) {
383
+ if (err) return prReject(err);
384
+ return prResolve(api);
385
+ };
386
+ }
387
+
388
+ // Simply call loginHelper because all it needs is the jar
389
+ // and will then complete the login process
390
+ return loginHelper(appState, email, password, loginOptions, callback);
391
+ })
392
+ .catch(function(err) {
393
+ // Check if using Promise instead of callback
394
+ if (callback === prCallback) prReject(err);
395
+ else callback(err);
396
+ });
397
+ } else {
398
+ utils
399
+ .post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions, null, { "Referer": "https://www.facebook.com/checkpoint/?next" })
400
+ .then(utils.saveCookies(jar))
401
+ .then(res => {
402
+ try {
403
+ JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
404
+ } catch (ex) {
405
+ clearInterval(checkVerified);
406
+ logger(Language.VerifiedCheck, "[ FCA-SUS ]");
407
+ if (callback === prCallback) {
408
+ callback = function(err, api) {
409
+ if (err) return prReject(err);
410
+ return prResolve(api);
411
+ };
412
+ }
413
+ return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
414
+ }
415
+ })
416
+ .catch(ex => {
417
+ log.error("login", ex);
418
+ if (callback === prCallback) prReject(ex);
419
+ else callback(ex);
420
+ });
421
+ }
422
+ return rtPromise;
423
+ }
424
+ };
425
+ } else {
426
+ if (!loginOptions.forceLogin) throw { error: Language.ForceLoginNotEnable };
427
+
428
+ if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
429
+ else form['submit[This Is Okay]'] = "This Is Okay";
430
+
431
+ return utils
432
+ .post(nextURL, jar, form, loginOptions)
433
+ .then(utils.saveCookies(jar))
434
+ .then(function() {
435
+ // Use the same form (safe I hope)
436
+ form.name_action_selected = 'save_device';
437
+
438
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
439
+ })
440
+ .then(function(res) {
441
+ var headers = res.headers;
442
+
443
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
444
+
445
+ var appState = utils.getAppState(jar);
446
+
447
+ // Simply call loginHelper because all it needs is the jar
448
+ // and will then complete the login process
449
+ return loginHelper(appState, email, password, loginOptions, callback);
450
+ })
451
+ .catch(e => callback(e));
452
+ }
453
+ });
454
+ }
455
+
456
+ return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
457
+ });
458
+ };
459
+ }
460
+
461
+ function makeid(length) {
462
+ var result = '';
463
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
464
+ var charactersLength = characters.length;
465
+ for (var i = 0; i < length; i++) {
466
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
467
+ }
468
+ return result;
469
+ }
470
+
471
+
472
+ // Helps the login
473
+ async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
474
+ var mainPromise = null;
475
+ var jar = utils.getJar();
476
+
477
+ // If we're given an appState we loop through it and save each cookie
478
+ // back into the jar.
479
+ try {
480
+ if (appState) {
481
+ //const readline = require("readline");
482
+ //const chalk = require("chalk");
483
+ //const figlet = require("figlet");
484
+ //const os = require("os");
485
+ //const { execSync } = require('child_process');
486
+ // let rl = readline.createInterface({
487
+ // input: process.stdin,
488
+ // output: process.stdout,
489
+ // prompt: chalk.hex('#00CCCC').bold('[FCA-SUS] • ')
490
+ // });
491
+ // let type = {
492
+ // 1: {
493
+ // "name": "Tạo Mật Khẩu Cho Appstate",
494
+ // onRun: async function() {
495
+ // try {
496
+ // rl.question("Hãy Nhập Mật Khẩu Bạn Muốn Đặt Cho Appstate !", (answer) => {
497
+ // console.log("Được Rồi Mật Khẩu Của Bạn Là: " + answer + ", Bạn Hãy Nhớ Kĩ Nhé !");
498
+ // process.env["FBKEY"] = answer;
499
+ // fs.writeFile('../.env', `FBKEY=${answer}`, function (err) {
500
+ // if (err) {
501
+ // submiterr(err)
502
+ // logger("Tạo File ENV Thất Bại !", "[ FCA-SUS ]")
503
+ // rl.pause();
504
+ // }
505
+ // else logger("Tạo Thành Công File ENV !","[ FCA-SUS ]")
506
+ // rl.pause();
507
+ // });
508
+ // })
509
+ // }
510
+ // catch (e) {
511
+ // console.log(e);
512
+ // logger("Đã Có Lỗi Khi Đang Try Tạo Ra Câu Hỏi =))", "[ FCA-SUS ]");
513
+ // rl.pause();
514
+ // }
515
+ // }
516
+ // },
517
+ // 2: {
518
+ // "name": "Tiếp Tục Chạy Fca Mà Không Cần Mã Hóa AppState",
519
+ // onRun: async function () {
520
+ // rl.pause();
521
+ // }
522
+ // },
523
+ // 3: {
524
+ // "name": "Đổi Mật Khẩu AppState (Comming Soon..)",
525
+ // onRun: async function () {
526
+ // console.log(chalk.red.bold("Đã bảo là comming soon rồi mà >:v"));
527
+ // }
528
+ // }
529
+ // }
530
+ // const localbrand = JSON.parse(readFileSync('./package.json')).name;
531
+ // const localbrand2 = JSON.parse(readFileSync('./node_modules/fca-sus/package.json')).version;
532
+ // var axios = require('axios');
533
+ // axios.get('https://raw.githubusercontent.com/amogusdevlol/fca-sus/main/package.json').then(async (res) => {
534
+ // if (localbrand.toUpperCase() == 'HORIZON') {
535
+ // console.group(chalk.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
536
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Hệ Điều Hành: " + chalk.bold.red(os.type()));
537
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Thông Tin Máy: " + chalk.bold.red(os.version()));
538
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Hiện Tại: " + chalk.bold.red(localbrand2));
539
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Mới Nhất: " + chalk.bold.red(res.data.version));
540
+ // console.groupEnd();
541
+ // }
542
+ // else {
543
+ // console.clear();
544
+ // console.log(figlet.textSync('TeamHorizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }))
545
+ // console.log(chalk.hex('#9966CC')(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`));
546
+ // }
547
+ // });
548
+
549
+ logger(Language.OnProcess, "[ FCA-SUS ]");
550
+ var backup = async(data) => {
551
+ if (fs.existsSync('./appstate.json')) {
552
+ try {
553
+ fs.writeFileSync('./appstate.json', data);
554
+ } catch (e) {
555
+ fs.writeFileSync('./appstate.json', JSON.stringify(data, null, "\t"));
556
+ }
557
+ logger(Language.BackupNoti, "[ FCA-SUS ]");
558
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
559
+ process.exit(1);
560
+ } else if (fs.existsSync('./Facebook.json')) {
561
+ try {
562
+ fs.writeFileSync('./Facebook.json', data);
563
+ } catch (e) {
564
+ fs.writeFileSync('./Facebook.json', JSON.stringify(data, null, "\t"));
565
+ }
566
+ logger(Language.BackupNoti, "[ FCA-SUS ]");
567
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
568
+ process.exit(1);
569
+ } else if (fs.existsSync('fbstate.json')) {
570
+ try {
571
+ fs.writeFileSync('./fbstate.json', data);
572
+ } catch (e) {
573
+ fs.writeFileSync('./fbstate.json', JSON.stringify(data), null, "\t");
574
+ }
575
+ logger(Language.BackupNoti, "[ FCA-SUS ]");
576
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
577
+ process.exit(1);
578
+ } else return logger.Error();
579
+ }
580
+
581
+ switch (process.platform) {
582
+ case "win32":
583
+ {
584
+ try {
585
+ var { body } = await Fetch('https://decrypt-appstate-production.up.railway.app/getKey');
586
+ process.env['FBKEY'] = JSON.parse(body).Data;
587
+ } catch (e) {
588
+ logger(Language.ErrGetPassWord);
589
+ logger.Error();
590
+ process.exit(1);
591
+ }
592
+ }
593
+ break;
594
+ case "linux":
595
+ {
596
+ if (process.env["REPL_ID"] == undefined) {
597
+ try {
598
+ var { body } = await Fetch.get('https://decrypt-appstate-production.up.railway.app/getKey');
599
+ process.env['FBKEY'] = JSON.parse(body).Data;
600
+ } catch (e) {
601
+ logger(Language.ErrGetPassWord, '[ FCA-SUS ]');
602
+ logger.Error();
603
+ process.exit(1);
604
+ }
605
+ } else {
606
+ try {
607
+ const client = new Client();
608
+ let key = await client.get("FBKEY");
609
+ if (!key) {
610
+ await client.set("FBKEY", makeid(49));
611
+ let key = await client.get("FBKEY");
612
+ process.env['FBKEY'] = key;
613
+ } else {
614
+ process.env['FBKEY'] = key;
615
+ }
616
+ } catch (e) {
617
+ logger(Language.ErrGenerateKey, '[ FCA-SUS ]');
618
+ logger(e, '[ FCA-SUS ]');
619
+ logger.Error();
620
+ process.exit(0)
621
+ }
622
+ }
623
+ }
624
+ break;
625
+ case "android":
626
+ {
627
+ try {
628
+ var { body } = await Fetch.get('https://decrypt-appstate-production.up.railway.app/getKey');
629
+ process.env['FBKEY'] = JSON.parse(body).Data;
630
+ } catch (e) {
631
+ logger(Language.ErrGetPassWord, '[ FCA-SUS ]');
632
+ return logger.Error();
633
+ }
634
+ }
635
+ break;
636
+ default:
637
+ {
638
+ logger(Language.UnsupportedDevice, '[ FCA-SUS ]');
639
+ logger.Error();
640
+ process.exit(0);
641
+ }
642
+ }
643
+
644
+ try {
645
+ switch (require("../../FastConfigFca.json").EncryptFeature) {
646
+ case true:
647
+ {
648
+ appState = JSON.parse(JSON.stringify(appState, null, "\t"));
649
+ switch (utils.getType(appState)) {
650
+ case "Array":
651
+ {
652
+ logger(Language.NotReadyToDecrypt, '[ FCA-SUS ]');
653
+ }
654
+ break;
655
+ case "String":
656
+ {
657
+ try {
658
+ appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
659
+ logger(Language.DecryptSuccess, '[ FCA-SUS ]');
660
+ } catch (e) {
661
+ if (process.env.Backup != undefined && process.env.Backup) {
662
+ backup(process.env.Backup);
663
+ } else switch (process.platform) {
664
+ case "win32":
665
+ {
666
+ try {
667
+ if (fs.existsSync('./backupappstate.json')) {
668
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
669
+ return backup(content);
670
+ }
671
+ } catch (e) {
672
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
673
+ logger.Error();
674
+ process.exit(0);
675
+ }
676
+ }
677
+ break;
678
+ case "linux":
679
+ {
680
+ if (process.env["REPL_ID"] == undefined) {
681
+ try {
682
+ if (fs.existsSync('./backupappstate.json')) {
683
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
684
+ return backup(content);
685
+ }
686
+ } catch (e) {
687
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
688
+ logger.Error();
689
+ process.exit(0);
690
+ }
691
+ } else {
692
+ try {
693
+ const client = new Client();
694
+ let key = await client.get("Backup");
695
+ if (key) {
696
+ return backup(JSON.stringify(key));
697
+ } else {
698
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
699
+ }
700
+ } catch (e) {
701
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
702
+ }
703
+ }
704
+ }
705
+ break;
706
+ case "android":
707
+ {
708
+ try {
709
+ if (fs.existsSync('./backupappstate.json')) {
710
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
711
+ return backup(content);
712
+ }
713
+ } catch (e) {
714
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
715
+ logger.Error();
716
+ process.exit(0);
717
+ }
718
+ }
719
+ }
720
+ logger(Language.DecryptFailed, '[ FCA-SUS ]');
721
+ return logger.Error();
722
+ }
723
+ logger(getText.gettext(Language.YourAppStatePass, process.env.FBKEY), '[ FCA-SUS ]');
724
+ }
725
+ break;
726
+ default:
727
+ {
728
+ logger(Language.InvaildAppState, "[ FCA-SUS ]");
729
+ process.exit(0)
730
+ }
731
+ }
732
+ }
733
+ break;
734
+ case false:
735
+ {
736
+ switch (utils.getType(appState)) {
737
+ case "Array":
738
+ {
739
+ logger(Language.EncryptStateOff, "[ FCA-SUS ]");
740
+ }
741
+ break;
742
+ case "String":
743
+ {
744
+ logger(Language.EncryptStateOff, "[ FCA-SUS ]");
745
+ try {
746
+ appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
747
+ logger(Language.DecryptSuccess, '[ FCA-SUS ]');
748
+ } catch (e) {
749
+ if (process.env.Backup != undefined && process.env.Backup) {
750
+ backup(process.env.Backup);
751
+ } else switch (process.platform) {
752
+ case "win32":
753
+ {
754
+ try {
755
+ if (fs.existsSync('./backupappstate.json')) {
756
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
757
+ return backup(content);
758
+ }
759
+ } catch (e) {
760
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
761
+ logger.Error();
762
+ process.exit(0);
763
+ }
764
+ }
765
+ break;
766
+ case "linux":
767
+ {
768
+ if (process.env["REPL_ID"] == undefined) {
769
+ try {
770
+ if (fs.existsSync('./backupappstate.json')) {
771
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
772
+ return backup(content);
773
+ }
774
+ } catch (e) {
775
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
776
+ logger.Error();
777
+ process.exit(0);
778
+ }
779
+ } else {
780
+ try {
781
+ const client = new Client();
782
+ let key = await client.get("Backup");
783
+ if (key) {
784
+ return backup(JSON.stringify(key));
785
+ } else {
786
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
787
+ }
788
+ } catch (e) {
789
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
790
+ }
791
+ }
792
+ }
793
+ break;
794
+ case "android":
795
+ {
796
+ try {
797
+ if (fs.existsSync('./backupappstate.json')) {
798
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
799
+ return backup(content);
800
+ }
801
+ } catch (e) {
802
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
803
+ logger.Error();
804
+ process.exit(0);
805
+ }
806
+ }
807
+ }
808
+ logger(Language.DecryptFailed, '[ FCA-SUS ]');
809
+ return logger.Error();
810
+ }
811
+ }
812
+ break;
813
+ default:
814
+ {
815
+ logger(Language.InvaildAppState, "[ FCA-SUS ]");
816
+ process.exit(0)
817
+ }
818
+ }
819
+ }
820
+ break;
821
+ default:
822
+ {
823
+ logger(getText.gettext(Language.IsNotABoolean, require("../../FastConfigFca.json").EncryptFeature), "[ FCA-SUS ]")
824
+ process.exit(0);
825
+ }
826
+ }
827
+ } catch (e) {
828
+ console.log(e);
829
+ }
830
+
831
+ try {
832
+ appState = JSON.parse(appState);
833
+ } catch (e) {
834
+ try {
835
+ appState = appState;
836
+ } catch (e) {
837
+ return logger.Error();
838
+ }
839
+ }
840
+ try {
841
+ appState.map(function(c) {
842
+ var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
843
+ jar.setCookie(str, "http://" + c.domain);
844
+ });
845
+ switch (process.platform) {
846
+ case "win32":
847
+ {
848
+ try {
849
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
850
+ process.env.Backup = JSON.stringify(appState, null, "\t");
851
+ } catch (e) {
852
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
853
+ }
854
+ }
855
+ break;
856
+ case "linux":
857
+ {
858
+ if (process.env["REPL_ID"] == undefined) {
859
+ try {
860
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
861
+ process.env.Backup = JSON.stringify(appState, null, "\t");
862
+ } catch (e) {
863
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
864
+ }
865
+ } else {
866
+ try {
867
+ if (fs.existsSync('./backupappstate.json')) {
868
+ fs.unlinkSync('./backupappstate.json');
869
+ }
870
+ const client = new Client();
871
+ await client.set("Backup", appState);
872
+ process.env.Backup = JSON.stringify(appState, null, "\t");
873
+ } catch (e) {
874
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
875
+ }
876
+ }
877
+ }
878
+ break;
879
+ case "android":
880
+ {
881
+ try {
882
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
883
+ process.env.Backup = JSON.stringify(appState, null, "\t");
884
+ } catch (e) {
885
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
886
+ }
887
+ }
888
+ }
889
+
890
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
891
+ } catch (e) {
892
+
893
+ if (process.env.Backup != undefined && process.env.Backup) {
894
+ return backup(process.env.Backup);
895
+ }
896
+ switch (process.platform) {
897
+ case "win32":
898
+ {
899
+ try {
900
+ if (fs.existsSync('./backupappstate.json')) {
901
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
902
+ return backup(content);
903
+ }
904
+ } catch (e) {
905
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
906
+ logger.Error();
907
+ process.exit(0);
908
+ }
909
+ }
910
+ break;
911
+ case "linux":
912
+ {
913
+ if (process.env["REPL_ID"] == undefined) {
914
+ try {
915
+ if (fs.existsSync('./backupappstate.json')) {
916
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
917
+ return backup(content);
918
+ }
919
+ } catch (e) {
920
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
921
+ logger.Error();
922
+ process.exit(0);
923
+ }
924
+ } else {
925
+ try {
926
+ const client = new Client();
927
+ let key = await client.get("Backup");
928
+ if (key) {
929
+ backup(JSON.stringify(key));
930
+ } else {
931
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
932
+ }
933
+ } catch (e) {
934
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
935
+ }
936
+ }
937
+ }
938
+ break;
939
+ case "android":
940
+ {
941
+ try {
942
+ if (fs.existsSync('./backupappstate.json')) {
943
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
944
+ return backup(content);
945
+ }
946
+ } catch (e) {
947
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
948
+ logger.Error();
949
+ process.exit(0);
950
+ }
951
+ }
952
+ break;
953
+ }
954
+
955
+ console.log(e);
956
+ return logger(Language.ScreenShotConsoleAndSendToAdmin, '[ FCA-HSP ]');
957
+ }
958
+ } else {
959
+ // Open the main page, then we login with the given credentials and finally
960
+ // load the main page again (it'll give us some IDs that we need)
961
+ mainPromise = utils
962
+ .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
963
+ .then(utils.saveCookies(jar))
964
+ .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
965
+ .then(function() {
966
+ return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
967
+ });
968
+ }
969
+ } catch (e) {
970
+ console.log(e);
971
+ }
972
+
973
+ var ctx,api;
974
+ mainPromise = mainPromise
975
+ .then(function(/** @type {{ body: string; }} */res) {
976
+ var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/,redirect = reg.exec(res.body);
977
+ if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
978
+ return res;
979
+ })
980
+ .then(function(/** @type {{ body: any; }} */res) {
981
+ var html = res.body,Obj = buildAPI(globalOptions, html, jar);
982
+ ctx = Obj.ctx;
983
+ api = Obj.api;
984
+ process.env.api = Obj.api;
985
+ return res;
986
+ });
987
+
988
+ /*var ctx = null;
989
+ var _defaultFuncs = null;
990
+ var api = null;
991
+
992
+ mainPromise = mainPromise
993
+ .then(function(res) {
994
+ // Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
995
+ var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
996
+ var redirect = reg.exec(res.body);
997
+ if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
998
+ return res;
999
+ })
1000
+ .then(async function(res) {
1001
+ var html = res.body;
1002
+ var stuff = await buildAPI(globalOptions, html, jar);
1003
+ ctx = stuff[0];
1004
+ _defaultFuncs = stuff[1];
1005
+ api = stuff[2];
1006
+ return res;
1007
+ });*/
1008
+ // given a pageID we log in as a page
1009
+ if (globalOptions.pageID) {
1010
+ mainPromise = mainPromise
1011
+ .then(function() {
1012
+ return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
1013
+ })
1014
+ .then(function(resData) {
1015
+ var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
1016
+ url = url.substring(0, url.length - 1);
1017
+ return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
1018
+ });
1019
+ }
1020
+
1021
+ // At the end we call the callback or catch an exception
1022
+ mainPromise
1023
+ .then(function() {
1024
+ logger(Language.DoneLogin, "[ FCA-SUS ]");
1025
+ logger(Language.AutoCheckUpdate, "[ FCA-SUS ]");
1026
+ //!---------- Auto Check, Update START -----------------!//
1027
+ var Fetch = require('got');
1028
+ var { readFileSync } = require('fs-extra');
1029
+ const { execSync } = require('child_process');
1030
+ Fetch('https://raw.githubusercontent.com/amogusdevlol/node-ainzfb/main/package.json').then(async(res) => {
1031
+ const localbrand = JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version;
1032
+ if (Number(localbrand.replace(/\./g, "")) < Number(JSON.parse(res.body.toString()).version.replace(/\./g, ""))) {
1033
+ log.warn("[ FCA-SUS ] •", getText.gettext(Language.NewVersionFound, JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version, JSON.parse(res.body.toString()).version));
1034
+ log.warn("[ FCA-SUS ] •", Language.AutoUpdate);
1035
+ try {
1036
+ execSync('npm install node-ainzfb@latest', { stdio: 'inherit' });
1037
+ logger(Language.UpdateSuccess, "[ FCA-SUS ]")
1038
+ logger(Language.RestartAfterUpdate, '[ FCA-SUS ]');
1039
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
1040
+ console.clear();
1041
+ process.exit(1);
1042
+ } catch (err) {
1043
+ log.warn('Error Update: ' + err);
1044
+ logger(Language.UpdateFailed, "[ FCA-SUS ]");
1045
+ try {
1046
+ require.resolve('sus-support');
1047
+ } catch (e) {
1048
+ logger(Language.InstallSupportTool, "[ FCA-SUS ]");
1049
+ execSync('npm install git+https://github.com/amogusdevlol/sus-support.git', { stdio: 'inherit' });
1050
+ process.exit(1);
1051
+ }
1052
+ var fcasp = require('sus-support');
1053
+ try {
1054
+ fcasp.onError()
1055
+ } catch (e) {
1056
+ logger(Language.NotiAfterUseToolFail, "[ Fca - Helper ]")
1057
+ logger("rmdir ./node_modules then enter npm i && npm start", "[ Fca - Helper ]");
1058
+ process.exit(0);
1059
+ }
1060
+
1061
+ }
1062
+ } else {
1063
+ logger(getText.gettext(Language.LocalVersion, localbrand), "[ FCA-SUS ]");
1064
+ logger(Language.WishMessage[Math.floor(Math.random() * Language.WishMessage.length)], "[ FCA-SUS ]");
1065
+ require('./Extra/ExtraUptimeRobot')()
1066
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
1067
+ callback(null, api);
1068
+ }
1069
+ });
1070
+ }).catch(function(e) {
1071
+ log.error("login", e.error || e);
1072
+ callback(e);
1073
+ });
1074
+ //!---------- Auto Check, Update END -----------------!//
1075
+ }
1076
+
1077
+ function login(loginData, options, callback) {
1078
+ if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
1079
+ callback = options;
1080
+ options = {};
1081
+ }
1082
+
1083
+ var globalOptions = {
1084
+ selfListen: false,
1085
+ listenEvents: true,
1086
+ listenTyping: false,
1087
+ updatePresence: false,
1088
+ forceLogin: false,
1089
+ autoMarkDelivery: false,
1090
+ autoMarkRead: false,
1091
+ autoReconnect: true,
1092
+ logRecordSize: 100,
1093
+ online: false,
1094
+ emitReady: false,
1095
+ userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8"
1096
+ };
1097
+
1098
+ //! bằng 1 cách nào đó tắt online sẽ đánh lừa được facebook :v
1099
+ //! phải có that có this chứ :v
1100
+
1101
+ if (loginData.email && loginData.password) {
1102
+ setOptions(globalOptions, {
1103
+ logLevel: "silent",
1104
+ forceLogin: true,
1105
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
1106
+ });
1107
+ }
1108
+ else if (loginData.appState) {
1109
+ setOptions(globalOptions, options);
1110
+ }
1111
+
1112
+ var prCallback = null;
1113
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
1114
+ var rejectFunc = null;
1115
+ var resolveFunc = null;
1116
+ var returnPromise = new Promise(function(resolve, reject) {
1117
+ resolveFunc = resolve;
1118
+ rejectFunc = reject;
1119
+ });
1120
+ prCallback = function(error, api) {
1121
+ if (error) return rejectFunc(error);
1122
+ return resolveFunc(api);
1123
+ };
1124
+ callback = prCallback;
1125
+ }
1126
+ loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
1127
+ return returnPromise;
1128
+ }
1129
+
1130
+ module.exports = login;