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