fca-anup-candy 0.0.1-security → 10.0.1

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

Potentially problematic release.


This version of fca-anup-candy might be problematic. Click here for more details.

Files changed (106) hide show
  1. package/Extra/Database/index.js +469 -0
  2. package/Extra/ExtraAddons.js +80 -0
  3. package/Extra/ExtraFindUID.js +62 -0
  4. package/Extra/ExtraGetThread.js +118 -0
  5. package/Extra/ExtraScreenShot.js +430 -0
  6. package/Extra/ExtraUptimeRobot.js +38 -0
  7. package/Extra/Html/Classic/script.js +119 -0
  8. package/Extra/Html/Classic/style.css +8 -0
  9. package/Extra/Security/Index.js +146 -0
  10. package/Extra/Security/Step_1.js +6 -0
  11. package/Extra/Security/Step_2.js +22 -0
  12. package/Extra/Security/Step_3.js +22 -0
  13. package/Extra/Src/Change_Environment.js +24 -0
  14. package/Extra/Src/Check_Update.js +67 -0
  15. package/Extra/Src/Instant_Update.js +64 -0
  16. package/Extra/Src/Last-Run.js +65 -0
  17. package/Extra/Src/Premium.js +81 -0
  18. package/Extra/Src/Release_Memory.js +41 -0
  19. package/Extra/Src/uuid.js +137 -0
  20. package/Func/AcceptAgreement.js +32 -0
  21. package/Func/ClearCache.js +64 -0
  22. package/Func/ReportV1.js +54 -0
  23. package/Index.js +350 -0
  24. package/Language/index.json +205 -0
  25. package/Main.js +1099 -0
  26. package/README.md +133 -3
  27. package/SECURITY.md +17 -0
  28. package/broadcast.js +40 -0
  29. package/logger.js +66 -0
  30. package/package.json +89 -3
  31. package/src/Dev_Horizon_Data.js +125 -0
  32. package/src/Premium.js +30 -0
  33. package/src/Screenshot.js +83 -0
  34. package/src/addExternalModule.js +16 -0
  35. package/src/addUserToGroup.js +79 -0
  36. package/src/changeAdminStatus.js +79 -0
  37. package/src/changeArchivedStatus.js +41 -0
  38. package/src/changeAvt.js +85 -0
  39. package/src/changeBio.js +65 -0
  40. package/src/changeBlockedStatus.js +36 -0
  41. package/src/changeGroupImage.js +106 -0
  42. package/src/changeNickname.js +45 -0
  43. package/src/changeThreadColor.js +62 -0
  44. package/src/changeThreadEmoji.js +42 -0
  45. package/src/createNewGroup.js +70 -0
  46. package/src/createPoll.js +60 -0
  47. package/src/deleteMessage.js +45 -0
  48. package/src/deleteThread.js +43 -0
  49. package/src/forwardAttachment.js +48 -0
  50. package/src/getAccessToken.js +28 -0
  51. package/src/getCurrentUserID.js +7 -0
  52. package/src/getEmojiUrl.js +27 -0
  53. package/src/getFriendsList.js +73 -0
  54. package/src/getMessage.js +80 -0
  55. package/src/getThreadHistory.js +537 -0
  56. package/src/getThreadInfo.js +412 -0
  57. package/src/getThreadList.js +213 -0
  58. package/src/getThreadMain.js +220 -0
  59. package/src/getThreadPictures.js +59 -0
  60. package/src/getUID.js +59 -0
  61. package/src/getUserID.js +62 -0
  62. package/src/getUserInfo.js +113 -0
  63. package/src/getUserInfoMain.js +65 -0
  64. package/src/getUserInfoV2.js +32 -0
  65. package/src/getUserInfoV3.js +63 -0
  66. package/src/getUserInfoV4.js +55 -0
  67. package/src/getUserInfoV5.js +61 -0
  68. package/src/handleFriendRequest.js +46 -0
  69. package/src/handleMessageRequest.js +49 -0
  70. package/src/httpGet.js +49 -0
  71. package/src/httpPost.js +48 -0
  72. package/src/httpPostFormData.js +41 -0
  73. package/src/listenMqtt.js +697 -0
  74. package/src/logout.js +68 -0
  75. package/src/markAsDelivered.js +48 -0
  76. package/src/markAsRead.js +70 -0
  77. package/src/markAsReadAll.js +43 -0
  78. package/src/markAsSeen.js +51 -0
  79. package/src/muteThread.js +47 -0
  80. package/src/removeUserFromGroup.js +49 -0
  81. package/src/resolvePhotoUrl.js +37 -0
  82. package/src/searchForThread.js +43 -0
  83. package/src/sendMessage.js +334 -0
  84. package/src/sendTypingIndicator.js +80 -0
  85. package/src/setMessageReaction.js +109 -0
  86. package/src/setPostReaction.js +102 -0
  87. package/src/setTitle.js +74 -0
  88. package/src/threadColors.js +39 -0
  89. package/src/unfriend.js +43 -0
  90. package/src/unsendMessage.js +40 -0
  91. package/test/Aliya_Database/A_README.md +1 -0
  92. package/test/Aliya_Database/Database.db +0 -0
  93. package/test/Database_Test.js +4 -0
  94. package/test/Db2.js +530 -0
  95. package/test/data/shareAttach.js +146 -0
  96. package/test/data/something.mov +0 -0
  97. package/test/data/test.png +0 -0
  98. package/test/data/test.txt +7 -0
  99. package/test/env/.env +0 -0
  100. package/test/example-config.json +18 -0
  101. package/test/example-db.db +0 -0
  102. package/test/memoryleak.js +18 -0
  103. package/test/test-page.js +140 -0
  104. package/test/test.js +385 -0
  105. package/test/testv2.js +18 -0
  106. package/utils.js +1628 -0
package/Main.js ADDED
@@ -0,0 +1,1099 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Developers: @Anup - @Aliya
5
+ ** A few words about developer appstate security.
6
+ *! Statement renouncing responsibility for the security of appstate encryption of the following operating systems: windows, Android, Linux operating systems,.. (maybe repl.it?),
7
+ *! because the above operating systems are private (except rep.it if the fraudster does not own your account or invite link to join).
8
+ *! If the intruder owns the computer, these private operating systems,the security of this fca cannot guarantee 100% of the time.
9
+ ** If the grammar is wrong, please understand because I'm just a kid 🍵.
10
+ */
11
+
12
+ /!-[ Require config and use ]-!/
13
+
14
+ if (global.Fca.Require.FastConfig.Config != 'default') {
15
+ //do ssth
16
+ }
17
+
18
+ const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.FastConfig.Language).Folder.Index;
19
+
20
+ /!-[ Require All Package Need Use ]-!/
21
+
22
+ var utils = global.Fca.Require.utils,
23
+ logger = global.Fca.Require.logger,
24
+ fs = global.Fca.Require.fs,
25
+ getText = global.Fca.getText,
26
+ log = global.Fca.Require.log,
27
+ express = require("express")(),
28
+ { join } = require('path'),
29
+ cheerio = require("cheerio"),
30
+ StateCrypt = {},
31
+ { readFileSync } = require('fs-extra'),
32
+ Database = require("./Extra/Database"),
33
+ readline = require("readline"),
34
+ chalk = require("chalk"),
35
+ figlet = require("figlet"),
36
+ os = require("os"),
37
+ Security = require("./Extra/Security/Index");
38
+
39
+ /!-[ Set Variable For Process ]-!/
40
+
41
+ log.maxRecordSize = 100;
42
+ var checkVerified = null;
43
+ var Boolean_Option = ['online','selfListen','listenEvents','updatePresence','forceLogin','autoMarkDelivery','autoMarkRead','listenTyping','autoReconnect','emitReady'];
44
+
45
+ /!-[ Set And Check Template HTML ]-!/
46
+
47
+ var css = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'style.css'));
48
+ var js = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'script.js'));
49
+
50
+ /!-[ Function Generate HTML Template ]-!/
51
+
52
+ /**
53
+ * It returns a string of HTML code.
54
+ * @param UserName - The username of the user
55
+ * @param Type - The type of user, either "Free" or "Premium"
56
+ * @param link - The link to the music you want to play
57
+ * @returns A HTML file
58
+ */
59
+
60
+ function ClassicHTML(UserName,Type,link) {
61
+ return `<!DOCTYPE html>
62
+ <html lang="en" >
63
+ <head>
64
+ <meta charset="UTF-8">
65
+ <title>Dark Rulex</title>
66
+ <link rel="stylesheet" href="./style.css">
67
+ </head>
68
+ <body>
69
+ <center>
70
+ <marquee><b>waiting for u :d</b></marquee>
71
+ <h2>Dark User Infomation</h2>
72
+ <h3>UserName: ${UserName} | Type: ${Type}</h3>
73
+ <canvas id="myCanvas"></canvas>
74
+ <script src="./script.js"></script>
75
+ <footer class="footer">
76
+ <div id="music">
77
+ <audio autoplay="false" controls="true" loop="true" src="${link}" __idm_id__="5070849">Your browser does not support the audio element.</audio>
78
+ <br><b>Session ID:</b> ${global.Fca.Require.Security.create().uuid}<br>
79
+ <br>Thanks For Using <b>Fca-Anup-Candy</b> - From <b>Anup Aliya</b> <3<br>
80
+ </div>
81
+ </footer>
82
+ </div>
83
+ </center>
84
+ </html>
85
+ </body>`
86
+ //lazy to change
87
+ }
88
+
89
+ /!-[ Stating Http Infomation ]-!/
90
+
91
+ express.set('DFP', (process.env.PORT || process.env.port || 1932));
92
+ express.use(function(req, res, next) {
93
+ switch (req.url.split('?')[0]) {
94
+ case '/script.js': {
95
+ res.writeHead(200, { 'Content-Type': 'text/javascript' });
96
+ res.write(js);
97
+ break;
98
+ }
99
+ case '/style.css': {
100
+ res.writeHead(200, { 'Content-Type': 'text/css' });
101
+ res.write(css);
102
+ break;
103
+ }
104
+ // case '/History': {
105
+ // if (req.query.PassWord == process.env.REPL_OWNER) {
106
+ // res.writeHead(200, { 'Content-Type': 'application/json charset=utf-8' });
107
+ // res.write(JSON.stringify(console.history,null,2),'utf8');
108
+ // res.end();
109
+ // }
110
+ // else res.json({
111
+ // Status: false,
112
+ // Error: "Thiếu Params ?PassWord=PassWordCuaBan =))"
113
+ // });
114
+ // break;
115
+ // }
116
+ default: {
117
+ res.writeHead(200, "OK", { "Content-Type": "text/html" });
118
+ res.write(ClassicHTML(global.Fca.Require.FastConfig.HTML.UserName, global.Fca.Data.PremText.includes("Premium") ? "Premium": "Free", global.Fca.Require.FastConfig.HTML.MusicLink));
119
+ }
120
+ }
121
+ res.end();
122
+ })
123
+
124
+ global.Fca.Require.Web = express;
125
+
126
+ /!-[ Function setOptions ]-!/
127
+
128
+ /**
129
+ * @param {{ [x: string]: boolean; selfListen?: boolean; listenEvents?: boolean; listenTyping?: boolean; updatePresence?: boolean; forceLogin?: boolean; autoMarkDelivery?: boolean; autoMarkRead?: boolean; autoReconnect?: boolean; logRecordSize: any; online?: boolean; emitReady?: boolean; userAgent: any; logLevel?: any; pageID?: any; proxy?: any; }} globalOptions
130
+ * @param {{ [x: string]: any; logLevel?: any; forceLogin?: boolean; userAgent?: any; pauseLog?: any; logRecordSize?: any; pageID?: any; proxy?: any; }} options
131
+ */
132
+
133
+ function setOptions(globalOptions, options) {
134
+ Object.keys(options).map(function(key) {
135
+ switch (Boolean_Option.includes(key)) {
136
+ case true: {
137
+ globalOptions[key] = Boolean(options[key]);
138
+ break;
139
+ }
140
+ case false: {
141
+ switch (key) {
142
+ case 'pauseLog': {
143
+ if (options.pauseLog) log.pause();
144
+ else log.resume();
145
+ break;
146
+ }
147
+ case 'logLevel': {
148
+ log.level = options.logLevel;
149
+ globalOptions.logLevel = options.logLevel;
150
+ break;
151
+ }
152
+ case 'logRecordSize': {
153
+ log.maxRecordSize = options.logRecordSize;
154
+ globalOptions.logRecordSize = options.logRecordSize;
155
+ break;
156
+ }
157
+ case 'pageID': {
158
+ globalOptions.pageID = options.pageID.toString();
159
+ break;
160
+ }
161
+ case 'userAgent': {
162
+ 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');
163
+ break;
164
+ }
165
+ case 'proxy': {
166
+ if (typeof options.proxy != "string") {
167
+ delete globalOptions.proxy;
168
+ utils.setProxy();
169
+ } else {
170
+ globalOptions.proxy = options.proxy;
171
+ utils.setProxy(globalOptions.proxy);
172
+ }
173
+ break;
174
+ }
175
+ default: {
176
+ log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
177
+ break;
178
+ }
179
+ }
180
+ break;
181
+ }
182
+ }
183
+ });
184
+ }
185
+
186
+ /!-[ Function BuildAPI ]-!/
187
+
188
+ /**
189
+ * @param {any} globalOptions
190
+ * @param {string} html
191
+ * @param {{ getCookies: (arg0: string) => any[]; }} jar
192
+ */
193
+
194
+ function buildAPI(globalOptions, html, jar) {
195
+ var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(/** @type {{ cookieString: () => string; }} */val) { return val.cookieString().split("=")[0] === "c_user"; });
196
+
197
+ if (maybeCookie.length === 0) {
198
+ if (global.Fca.Require.FastConfig.AutoLogin) {
199
+ return global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.AutoLogin, function() {
200
+ return global.Fca.Action('AutoLogin')
201
+ });
202
+ }
203
+ else if (!global.Fca.Require.FastConfig.AutoLogin) {
204
+ return global.Fca.Require.logger.Error(global.Fca.Require.Language.Index.ErrAppState);
205
+ }
206
+ return;
207
+ }
208
+ else {
209
+ if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
210
+
211
+ var userID = maybeCookie[0].cookieString().split("=")[1].toString();
212
+ process.env['UID'] = logger.Normal(getText(Language.UID,userID), userID);
213
+
214
+ try {
215
+ clearInterval(checkVerified);
216
+ } catch (e) {
217
+ console.log(e);
218
+ }
219
+
220
+ var clientID = (Math.random() * 2147483648 | 0).toString(16);
221
+
222
+ var CHECK_MQTT = {
223
+ oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
224
+ newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
225
+ legacyFBMQTTMatch: html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/)
226
+ }
227
+
228
+ let Slot = Object.keys(CHECK_MQTT);
229
+
230
+ var mqttEndpoint,region,irisSeqID;
231
+ Object.keys(CHECK_MQTT).map(function(MQTT) {
232
+ if (CHECK_MQTT[MQTT] && !region) {
233
+ switch (Slot.indexOf(MQTT)) {
234
+ case 0: {
235
+ irisSeqID = CHECK_MQTT[MQTT][1];
236
+ mqttEndpoint = CHECK_MQTT[MQTT][2];
237
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
238
+ return;
239
+ }
240
+ case 1: {
241
+ irisSeqID = CHECK_MQTT[MQTT][2];
242
+ mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
243
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
244
+ return;
245
+ }
246
+ case 2: {
247
+ mqttEndpoint = CHECK_MQTT[MQTT][4];
248
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
249
+ return;
250
+ }
251
+ }
252
+ return;
253
+ }
254
+ });
255
+
256
+ var ctx = {
257
+ userID: userID,
258
+ jar: jar,
259
+ clientID: clientID,
260
+ globalOptions: globalOptions,
261
+ loggedIn: true,
262
+ access_token: 'NONE',
263
+ clientMutationId: 0,
264
+ mqttClient: undefined,
265
+ lastSeqId: irisSeqID,
266
+ syncToken: undefined,
267
+ mqttEndpoint: mqttEndpoint,
268
+ region: region,
269
+ firstListen: true
270
+ };
271
+
272
+ var api = {
273
+ setOptions: setOptions.bind(null, globalOptions),
274
+ getAppState: function getAppState() {
275
+ return utils.getAppState(jar);
276
+ }
277
+ };
278
+
279
+ if (region && mqttEndpoint) {
280
+ //do sth
281
+ }
282
+ else {
283
+ log.warn("login", getText(Language.NoAreaData));
284
+ api["htmlData"] = html;
285
+ }
286
+
287
+ var defaultFuncs = utils.makeDefaults(html, userID, ctx);
288
+
289
+ fs.readdirSync(__dirname + "/src").filter((/** @type {string} */File) => File.endsWith(".js") && !File.includes('Dev_')).map((/** @type {string} */File) => {
290
+ if (File == 'getThreadInfo.js' && global.Fca.Require.FastConfig.AntiGetInfo.AntiGetThreadInfo != true || File == 'getUserInfo.js' && global.Fca.Require.FastConfig.AntiGetInfo.AntiGetUserInfo != true) api[File.split('.').slice(0, -1).join('.')] = require('./src/' + (File.includes('getThreadInfo') ? 'getThreadMain.js' : 'getUserInfoMain.js'))(defaultFuncs, api, ctx)
291
+ else api[File.split('.').slice(0, -1).join('.')] = require('./src/' + File)(defaultFuncs, api, ctx)
292
+ });
293
+
294
+ return {
295
+ ctx,
296
+ defaultFuncs,
297
+ api
298
+ };
299
+ }
300
+ }
301
+
302
+ /!-[ Function makeLogin ]-!/
303
+
304
+ /**
305
+ * @param {{ setCookie: (arg0: any, arg1: string) => void; }} jar
306
+ * @param {any} email
307
+ * @param {any} password
308
+ * @param {{ forceLogin: any; }} loginOptions
309
+ * @param {(err: any, api: any) => any} callback
310
+ * @param {any} prCallback
311
+ */
312
+
313
+ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
314
+ return function(/** @type {{ body: any; }} */res) {
315
+ var html = res.body,$ = cheerio.load(html),arr = [];
316
+
317
+ $("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
318
+
319
+ arr = arr.filter(function(v) {
320
+ return v.val && v.val.length;
321
+ });
322
+
323
+ var form = utils.arrToForm(arr);
324
+ form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
325
+ form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
326
+ form.email = email;
327
+ form.pass = password;
328
+ form.default_persistent = '0';
329
+ form.locale = 'en_US';
330
+ form.timezone = '240';
331
+ form.lgnjs = ~~(Date.now() / 1000);
332
+
333
+ html.split("\"_js_").slice(1).map((/** @type {any} */val) => {
334
+ jar.setCookie(utils.formatCookie(JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]"), "facebook"),"https://www.facebook.com")
335
+ });
336
+
337
+ logger.Normal(Language.OnLogin);
338
+ return utils
339
+ .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
340
+ .then(utils.saveCookies(jar))
341
+ .then(function(/** @type {{ headers: any; }} */res) {
342
+ var headers = res.headers;
343
+ if (!headers.location) throw { error: Language.InvaildAccount };
344
+
345
+ // This means the account has login approvals turned on.
346
+ if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
347
+ logger.Warning(Language.TwoAuth);
348
+ var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
349
+
350
+ return utils
351
+ .get(headers.location, jar, null, loginOptions)
352
+ .then(utils.saveCookies(jar))
353
+ .then(async function(/** @type {{ body: any; }} */res) {
354
+ if (!Database().get('ThroughAcc')) {
355
+ Database().set('ThroughAcc', email);
356
+ }
357
+ else {
358
+ if (String((Database().get('ThroughAcc'))).replace(RegExp('"','g'), '') != String(email).replace(RegExp('"','g'), '')) {
359
+ Database().set('ThroughAcc', email);
360
+ if (Database().get('Through2Fa')) {
361
+ Database().delete('Through2Fa');
362
+ }
363
+ }
364
+ }
365
+ var html = res.body,$ = cheerio.load(html), arr = [];
366
+ $("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
367
+ arr = arr.filter(v => { return v.val && v.val.length });
368
+ var form = utils.arrToForm(arr);
369
+ if (html.indexOf("checkpoint/?next") > -1) {
370
+ setTimeout(() => {
371
+ checkVerified = setInterval((_form) => {}, 5000, {
372
+ fb_dtsg: form.fb_dtsg,
373
+ jazoest: form.jazoest,
374
+ dpr: 1
375
+ });
376
+ }, 2500);
377
+ switch (global.Fca.Require.FastConfig.Login2Fa) {
378
+ case true: {
379
+ try {
380
+ const question = question => {
381
+ const rl = readline.createInterface({
382
+ input: process.stdin,
383
+ output: process.stdout
384
+ });
385
+ return new Promise(resolve => {
386
+ rl.question(question, answer => {
387
+ rl.close();
388
+ return resolve(answer);
389
+ });
390
+ });
391
+ };
392
+ async function EnterSecurityCode() {
393
+ try {
394
+ var Through2Fa = Database().get('Through2Fa');
395
+ if (Through2Fa) {
396
+ Through2Fa.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
397
+ let str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
398
+ jar.setCookie(str, "http://" + c.domain);
399
+ })
400
+ var from2 = utils.arrToForm(arr);
401
+ from2.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
402
+ from2.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
403
+ from2.email = email;
404
+ from2.pass = password;
405
+ from2.default_persistent = '0';
406
+ from2.locale = 'en_US';
407
+ from2.timezone = '240';
408
+ from2.lgnjs = ~~(Date.now() / 1000);
409
+ return utils
410
+ .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, from2, loginOptions)
411
+ .then(utils.saveCookies(jar))
412
+ .then(function(/** @type {{ headers: any; }} */res) {
413
+ var headers = res.headers;
414
+ if (!headers['set-cookie'][0].includes('deleted')) {
415
+ logger.Warning(Language.ErrThroughCookies, async function() {
416
+ Database().delete('Through2Fa');
417
+ });
418
+ process.exit(1);
419
+ }
420
+ if (headers.location && headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
421
+ return utils
422
+ .get(headers.location, jar, null, loginOptions)
423
+ .then(utils.saveCookies(jar))
424
+ .then(function(/** @type {{ body: any; }} */res) {
425
+ var html = res.body,$ = cheerio.load(html), arr = [];
426
+ $("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
427
+ arr = arr.filter(v => { return v.val && v.val.length });
428
+ var from2 = utils.arrToForm(arr);
429
+
430
+ if (html.indexOf("checkpoint/?next") > -1) {
431
+ setTimeout(() => {
432
+ checkVerified = setInterval((_form) => {}, 5000, {
433
+ fb_dtsg: from2.fb_dtsg,
434
+ jazoest: from2.jazoest,
435
+ dpr: 1
436
+ });
437
+ }, 2500);
438
+ if (!res.headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
439
+ try {
440
+ delete from2.name_action_selected;
441
+ from2['submit[Continue]'] = $("#checkpointSubmitButton").html();
442
+ return utils
443
+ .post(nextURL, jar, from2, loginOptions)
444
+ .then(utils.saveCookies(jar))
445
+ .then(function() {
446
+ from2['submit[This was me]'] = "This was me";
447
+ return utils.post(nextURL, jar, from2, loginOptions).then(utils.saveCookies(jar));
448
+ })
449
+ .then(function() {
450
+ delete from2['submit[This was me]'];
451
+ from2.name_action_selected = 'save_device';
452
+ from2['submit[Continue]'] = $("#checkpointSubmitButton").html();
453
+ return utils.post(nextURL, jar, from2, loginOptions).then(utils.saveCookies(jar));
454
+ })
455
+ .then(async function(/** @type {{ headers: any; body: string | string[]; }} */res) {
456
+ var headers = res.headers;
457
+ if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: "wtf ??:D" };
458
+ var appState = utils.getAppState(jar,false);
459
+ Database().set('Through2Fa', appState);
460
+ return loginHelper(appState, email, password, loginOptions, callback);
461
+ })
462
+ .catch((/** @type {any} */e) => callback(e));
463
+ }
464
+ catch (e) {
465
+ console.log(e)
466
+ }
467
+ }
468
+ }
469
+ })
470
+ }
471
+ return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
472
+ }).catch((/** @type {any} */e) => console.log(e));
473
+ }
474
+ }
475
+ catch (e) {
476
+ Database().delete('Through2Fa');
477
+ }
478
+ var code = await question(Language.EnterSecurityCode);
479
+ try {
480
+ form.approvals_code = code;
481
+ form['submit[Continue]'] = $("#checkpointSubmitButton").html();
482
+ var prResolve,prReject;
483
+ var rtPromise = new Promise((resolve, reject) => { prResolve = resolve; prReject = reject; });
484
+ if (typeof code == "string") { //always strings
485
+ utils
486
+ .post(nextURL, jar, form, loginOptions)
487
+ .then(utils.saveCookies(jar))
488
+ .then(function(/** @type {{ body: string | Buffer; }} */res) {
489
+ var $ = cheerio.load(res.body);
490
+ var error = $("#approvals_code").parent().attr("data-xui-error");
491
+ if (error) {
492
+ logger.Warning(Language.InvaildTwoAuthCode,function() { EnterSecurityCode(); }); //bruh loop
493
+ };
494
+ })
495
+ .then(function() {
496
+ delete form.no_fido;delete form.approvals_code;
497
+ form.name_action_selected = 'save_device'; //'save_device' || 'dont_save;
498
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
499
+ })
500
+ .then(async function(/** @type {{ headers: any; body: string | string[]; }} */res) {
501
+ var headers = res.headers;
502
+ if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
503
+ try {
504
+ delete form.name_action_selected;
505
+ form['submit[Continue]'] = $("#checkpointSubmitButton").html();
506
+ return utils
507
+ .post(nextURL, jar, form, loginOptions)
508
+ .then(utils.saveCookies(jar))
509
+ .then(function() {
510
+ form['submit[This was me]'] = "This was me";
511
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
512
+ })
513
+ .then(function() {
514
+ delete form['submit[This was me]'];
515
+ form.name_action_selected = 'save_device';
516
+ form['submit[Continue]'] = $("#checkpointSubmitButton").html();
517
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
518
+ })
519
+ .then(async function(/** @type {{ headers: any; body: string | string[]; }} */res) {
520
+ var headers = res.headers;
521
+ if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: "wtf ??:D" };
522
+ var appState = utils.getAppState(jar,false);
523
+ Database().set('Through2Fa', appState);
524
+ return loginHelper(appState, email, password, loginOptions, callback);
525
+ })
526
+ .catch((/** @type {any} */e) => callback(e));
527
+ }
528
+ catch (e) {
529
+ console.log(e)
530
+ }
531
+ }
532
+ var appState = utils.getAppState(jar,false);
533
+ if (callback === prCallback) {
534
+ callback = function(/** @type {any} */err, /** @type {any} */api) {
535
+ if (err) return prReject(err);
536
+ return prResolve(api);
537
+ };
538
+ }
539
+ Database().set('Through2Fa', appState);
540
+ return loginHelper(appState, email, password, loginOptions, callback);
541
+ })
542
+ .catch(function(/** @type {any} */err) {
543
+ if (callback === prCallback) prReject(err);
544
+ else callback(err);
545
+ });
546
+ } else {
547
+ utils
548
+ .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" })
549
+ .then(utils.saveCookies(jar))
550
+ .then(async function(/** @type {{ body: string; }} */res) {
551
+ try {
552
+ JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
553
+ } catch (ex) {
554
+ clearInterval(checkVerified);
555
+ logger.Warning(Language.VerifiedCheck);
556
+ if (callback === prCallback) {
557
+ callback = function(/** @type {any} */err, /** @type {any} */api) {
558
+ if (err) return prReject(err);
559
+ return prResolve(api);
560
+ };
561
+ }
562
+ let appState = utils.getAppState(jar,false);
563
+ return loginHelper(appState, email, password, loginOptions, callback);
564
+ }
565
+ })
566
+ .catch((/** @type {any} */ex) => {
567
+ log.error("login", ex);
568
+ if (callback === prCallback) prReject(ex);
569
+ else callback(ex);
570
+ });
571
+ }
572
+ return rtPromise;
573
+ }
574
+ catch (e) {
575
+ logger.Error(e)
576
+ logger.Error()
577
+ process.exit(0)
578
+ }
579
+ }
580
+ await EnterSecurityCode()
581
+ }
582
+ catch (e) {
583
+ logger.Error(e)
584
+ logger.Error();
585
+ process.exit(0);
586
+ }
587
+ }
588
+ break;
589
+ case false: {
590
+ throw {
591
+ error: 'login-approval',
592
+ continue: function submit2FA(/** @type {any} */code) {
593
+ form.approvals_code = code;
594
+ form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
595
+ var prResolve,prReject;
596
+ var rtPromise = new Promise((resolve, reject) => { prResolve = resolve; prReject = reject; });
597
+ if (typeof code == "string") {
598
+ utils
599
+ .post(nextURL, jar, form, loginOptions)
600
+ .then(utils.saveCookies(jar))
601
+ .then(function(/** @type {{ body: string | Buffer; }} */res) {
602
+ var $ = cheerio.load(res.body);
603
+ var error = $("#approvals_code").parent().attr("data-xui-error");
604
+ if (error) {
605
+ throw {
606
+ error: 'login-approval',
607
+ errordesc: Language.InvaildTwoAuthCode,
608
+ lerror: error,
609
+ continue: submit2FA
610
+ };
611
+ }
612
+ })
613
+ .then(function() {
614
+ delete form.no_fido;delete form.approvals_code;
615
+ form.name_action_selected = 'dont_save'; //'save_device' || 'dont_save;
616
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
617
+ })
618
+ .then(function(/** @type {{ headers: any; body: string | string[]; }} */res) {
619
+ var headers = res.headers;
620
+ if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: Language.ApprovalsErr };
621
+ var appState = utils.getAppState(jar,false);
622
+ if (callback === prCallback) {
623
+ callback = function(/** @type {any} */err, /** @type {any} */api) {
624
+ if (err) return prReject(err);
625
+ return prResolve(api);
626
+ };
627
+ }
628
+ return loginHelper(appState, email, password, loginOptions, callback);
629
+ })
630
+ .catch(function(/** @type {any} */err) {
631
+ if (callback === prCallback) prReject(err);
632
+ else callback(err);
633
+ });
634
+ } else {
635
+ utils
636
+ .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" })
637
+ .then(utils.saveCookies(jar))
638
+ .then((/** @type {{ body: string; }} */res) => {
639
+ try {
640
+ JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
641
+ } catch (ex) {
642
+ clearInterval(checkVerified);
643
+ logger.Warning(Language.VerifiedCheck);
644
+ if (callback === prCallback) {
645
+ callback = function(/** @type {any} */err, /** @type {any} */api) {
646
+ if (err) return prReject(err);
647
+ return prResolve(api);
648
+ };
649
+ }
650
+ return loginHelper(utils.getAppState(jar,false), email, password, loginOptions, callback);
651
+ }
652
+ })
653
+ .catch((/** @type {any} */ex) => {
654
+ log.error("login", ex);
655
+ if (callback === prCallback) prReject(ex);
656
+ else callback(ex);
657
+ });
658
+ }
659
+ return rtPromise;
660
+ }
661
+ };
662
+ }
663
+ }
664
+ } else {
665
+ if (!loginOptions.forceLogin) throw { error: Language.ForceLoginNotEnable };
666
+
667
+ if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
668
+ else form['submit[This Is Okay]'] = "This Is Okay";
669
+
670
+ return utils
671
+ .post(nextURL, jar, form, loginOptions)
672
+ .then(utils.saveCookies(jar))
673
+ .then(function() {
674
+ form.name_action_selected = 'dont_save';
675
+
676
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
677
+ })
678
+ .then(function(/** @type {{ headers: any; body: string | string[]; }} */res) {
679
+ var headers = res.headers;
680
+
681
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
682
+
683
+ var appState = utils.getAppState(jar,false);
684
+
685
+ return loginHelper(appState, email, password, loginOptions, callback);
686
+ })
687
+ .catch((/** @type {any} */e) => callback(e));
688
+ }
689
+ });
690
+ }
691
+ return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
692
+ });
693
+ };
694
+ }
695
+
696
+ /!-[ Function backup ]-!/
697
+
698
+ /**
699
+ * @param {string} data
700
+ * @param {any} globalOptions
701
+ * @param {any} callback
702
+ * @param {any} prCallback
703
+ */
704
+
705
+ function backup(data,globalOptions, callback, prCallback) {
706
+ try {
707
+ var appstate;
708
+ try {
709
+ appstate = JSON.parse(data)
710
+ }
711
+ catch(e) {
712
+ appstate = data;
713
+ }
714
+ logger.Warning(Language.BackupNoti);
715
+ try {
716
+ loginHelper(appstate,null,null,globalOptions, callback, prCallback)
717
+ }
718
+ catch (e) {
719
+ logger.Error(Language.ErrBackup);
720
+ process.exit(0);
721
+ }
722
+ }
723
+ catch (e) {
724
+ return logger.Error();
725
+ }
726
+ }
727
+
728
+ /!-[ async function loginHelper ]-!/
729
+
730
+ /**
731
+ * @param {string | any[]} appState
732
+ * @param {any} email
733
+ * @param {any} password
734
+ * @param {{ selfListen?: boolean; listenEvents?: boolean; listenTyping?: boolean; updatePresence?: boolean; forceLogin?: boolean; autoMarkDelivery?: boolean; autoMarkRead?: boolean; autoReconnect?: boolean; logRecordSize?: number; online?: boolean; emitReady?: boolean; userAgent?: string; pageID?: any; }} globalOptions
735
+ * @param {(arg0: any, arg1: undefined) => void} callback
736
+ * @param {(error: any, api: any) => any} [prCallback]
737
+ */
738
+
739
+ async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
740
+ var mainPromise = null;
741
+ var jar = utils.getJar();
742
+
743
+ if (fs.existsSync('./backupappstate.json')) {
744
+ fs.unlinkSync('./backupappstate.json');
745
+ }
746
+
747
+ try {
748
+ if (appState) {
749
+ logger.Normal(Language.OnProcess);
750
+ switch (Database().has("FBKEY")) {
751
+ case true: {
752
+ process.env.FBKEY = Database().get("FBKEY");
753
+ }
754
+ break;
755
+ case false: {
756
+ const SecurityKey = global.Fca.Require.Security.create().apiKey;
757
+ process.env['FBKEY'] = SecurityKey;
758
+ Database().set('FBKEY', SecurityKey);
759
+ }
760
+ break;
761
+ default: {
762
+ const SecurityKey = global.Fca.Require.Security.create().apiKey;
763
+ process.env['FBKEY'] = SecurityKey;
764
+ Database().set('FBKEY', SecurityKey);
765
+ }
766
+ }
767
+ try {
768
+ switch (global.Fca.Require.FastConfig.EncryptFeature) {
769
+ case true: {
770
+ appState = JSON.parse(JSON.stringify(appState, null, "\t"));
771
+ switch (utils.getType(appState)) {
772
+ case "Array": {
773
+ switch (utils.getType(appState[0])) {
774
+ case "Object": {
775
+ logger.Normal(Language.NotReadyToDecrypt);
776
+ }
777
+ break;
778
+ case "String": {
779
+ appState = Security(appState,process.env['FBKEY'],'Decrypt');
780
+ logger.Normal(Language.DecryptSuccess);
781
+ }
782
+ }
783
+ }
784
+ break;
785
+ default: {
786
+ logger.Warning(Language.InvaildAppState);
787
+ process.exit(0)
788
+ }
789
+ }
790
+ }
791
+ break;
792
+ case false: {
793
+ switch (utils.getType(appState)) {
794
+ case "Array": {
795
+ logger.Normal(Language.EncryptStateOff);
796
+ }
797
+ break;
798
+ case "Object": {
799
+ logger.Normal(Language.EncryptStateOff);
800
+ try {
801
+ appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
802
+ logger.Normal(Language.DecryptSuccess);
803
+ }
804
+ catch (e) {
805
+ if (process.env.Backup != undefined && process.env.Backup) {
806
+ await backup(process.env.Backup,globalOptions, callback, prCallback);
807
+ }
808
+ else {
809
+ try {
810
+ if (Database().has('Backup')) {
811
+ return await backup(Database().get('Backup'),globalOptions, callback, prCallback);
812
+ }
813
+ else {
814
+ logger.Warning(Language.ErrBackup);
815
+ process.exit(0);
816
+ }
817
+ }
818
+ catch (e) {
819
+ logger.Warning(Language.ErrBackup);
820
+ logger.Error();
821
+ process.exit(0);
822
+ }
823
+ }
824
+ logger.Warning(Language.DecryptFailed);
825
+ return logger.Error();
826
+ }
827
+ }
828
+ break;
829
+ default: {
830
+ logger.Warning(Language.InvaildAppState);
831
+ process.exit(0)
832
+ }
833
+ }
834
+ }
835
+ break;
836
+ default: {
837
+ logger.Warning(getText(Language.IsNotABoolean,global.Fca.Require.FastConfig.EncryptFeature))
838
+ process.exit(0);
839
+ }
840
+ }
841
+ }
842
+ catch (e) {
843
+ console.log(e);
844
+ }
845
+
846
+ try {
847
+ appState = JSON.parse(appState);
848
+ }
849
+ catch (e) {
850
+ try {
851
+ appState = appState;
852
+ }
853
+ catch (e) {
854
+ return logger.Error();
855
+ }
856
+ }
857
+ try {
858
+ global.Fca.Data.AppState = appState;
859
+ appState.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
860
+ var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
861
+ jar.setCookie(str, "http://" + c.domain);
862
+ });
863
+ process.env.Backup = appState;
864
+ Database().set('Backup', appState);
865
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
866
+ } catch (e) {
867
+ console.log(e)
868
+ if (process.env.Backup != undefined && process.env.Backup) {
869
+ return await backup(process.env.Backup,globalOptions, callback, prCallback);
870
+ }
871
+ try {
872
+ if (Database().has('Backup')) {
873
+ return await backup(Database().get('Backup'),globalOptions, callback, prCallback);
874
+ }
875
+ else {
876
+ logger.Warning(Language.ErrBackup);
877
+ process.exit(0);
878
+ }
879
+ }
880
+ catch (e) {
881
+ logger.Warning(Language.ErrBackup);
882
+ process.exit(0);
883
+ }
884
+ return logger.Warning(Language.ErrBackup); // unreachable 👑
885
+ }
886
+ } else {
887
+ mainPromise = utils
888
+ .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
889
+ .then(utils.saveCookies(jar))
890
+ .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
891
+ .then(function() {
892
+ return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
893
+ });
894
+ }
895
+ } catch (e) {
896
+ console.log(e);
897
+ }
898
+
899
+
900
+ var ctx,api;
901
+ mainPromise = mainPromise
902
+ .then(function(/** @type {{ body: string; }} */res) {
903
+ var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/,redirect = reg.exec(res.body);
904
+ if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
905
+ return res;
906
+ })
907
+ .then(function(/** @type {{ body: any; }} */res) {
908
+ var html = res.body,Obj = buildAPI(globalOptions, html, jar);
909
+ ctx = Obj.ctx;
910
+ api = Obj.api;
911
+ process.env.api = Obj.api;
912
+ return res;
913
+ });
914
+ if (globalOptions.pageID) {
915
+ mainPromise = mainPromise
916
+ .then(function() {
917
+ return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
918
+ })
919
+ .then(function(/** @type {{ body: any; }} */resData) {
920
+ var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
921
+ url = url.substring(0, url.length - 1);
922
+ return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
923
+ });
924
+ }
925
+ mainPromise
926
+ .then(async function() {
927
+ logger.Normal(getText(Language.LocalVersion,global.Fca.Version));
928
+ logger.Normal(getText(Language.CountTime,global.Fca.Data.CountTime()))
929
+ logger.Normal(Language.WishMessage[Math.floor(Math.random()*Language.WishMessage.length)]);
930
+ require('./Extra/ExtraUptimeRobot')();
931
+ global.Fca.Require.FastConfig.HTML.HTML==true? global.Fca.Require.Web.listen(global.Fca.Require.Web.get('DFP')) : global.Fca.Require.Web = null;
932
+ callback(null, api);
933
+ }).catch(function(/** @type {{ error: any; }} */e) {
934
+ log.error("login", e.error || e);
935
+ callback(e);
936
+ });
937
+ }
938
+
939
+ /**
940
+ * It asks the user for their account and password, and then saves it to the database.
941
+ */
942
+
943
+ function setUserNameAndPassWord() {
944
+ let rl = readline.createInterface({
945
+ input: process.stdin,
946
+ output: process.stdout
947
+ });
948
+ let localbrand2 = global.Fca.Version
949
+ console.clear();
950
+ console.log(figlet.textSync('Aliya', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }));
951
+ console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Operating System: " + chalk.bold.red(os.type()));
952
+ console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Machine Version: " + chalk.bold.red(os.version()));
953
+ console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Fca Version: " + chalk.bold.red(localbrand2) + '\n');
954
+ try {
955
+ rl.question(Language.TypeAccount, (Account) => {
956
+ if (!Account.includes("@") && global.Fca.Require.utils.getType(parseInt(Account)) != "Number") return logger.Normal(Language.TypeAccountError, function () { process.exit(1) }); //Very Human
957
+ else rl.question(Language.TypePassword,async function (Password) {
958
+ rl.close();
959
+ try {
960
+ Database().set("Account", Account);
961
+ Database().set("Password", Password);
962
+ }
963
+ catch (e) {
964
+ logger.Warning(Language.ErrDataBase);
965
+ logger.Error();
966
+ process.exit(0);
967
+ }
968
+ if (global.Fca.Require.FastConfig.ResetDataLogin) {
969
+ global.Fca.Require.FastConfig.ResetDataLogin = false;
970
+ global.Fca.Require.fs.writeFileSync(process.cwd() + '/Aliya.json', JSON.stringify(global.Fca.Require.FastConfig, null, 4));
971
+ }
972
+ logger.Success(Language.SuccessSetData);
973
+ process.exit(1);
974
+ });
975
+ })
976
+ }
977
+ catch (e) {
978
+ logger.Error(e)
979
+ }
980
+ }
981
+
982
+ /**
983
+ * @param {{ email: any; password: any; appState: any; }} loginData
984
+ * @param {{}} options
985
+ * @param {(error: any, api: any) => any} callback
986
+ */
987
+
988
+ function login(loginData, options, callback) {
989
+
990
+ if (utils.getType(loginData) == "Array") {
991
+ if (loginData.length == 3) {
992
+ options = loginData[1];
993
+ callback = loginData[2];
994
+ loginData = loginData[0]
995
+ }
996
+ else if (loginData.length == 2) {
997
+ options = loginData[1];
998
+ loginData = loginData[0]
999
+ }
1000
+ else {
1001
+ loginData = loginData[0]
1002
+ }
1003
+ }
1004
+
1005
+ if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
1006
+ callback = options;
1007
+ options = {};
1008
+ }
1009
+
1010
+ var globalOptions = {
1011
+ selfListen: false,
1012
+ listenEvents: true,
1013
+ listenTyping: false,
1014
+ updatePresence: false,
1015
+ forceLogin: false,
1016
+ autoMarkDelivery: false,
1017
+ autoMarkRead: false,
1018
+ autoReconnect: true,
1019
+ logRecordSize: 100,
1020
+ online: false,
1021
+ emitReady: false,
1022
+ 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"
1023
+ };
1024
+
1025
+ if (loginData.email && loginData.password) {
1026
+ setOptions(globalOptions, {
1027
+ logLevel: "silent",
1028
+ forceLogin: true,
1029
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
1030
+ });
1031
+ }
1032
+ else if (loginData.appState) {
1033
+ setOptions(globalOptions, options);
1034
+ }
1035
+
1036
+ var prCallback = null;
1037
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
1038
+ var rejectFunc = null;
1039
+ var resolveFunc = null;
1040
+ var returnPromise = new Promise(function(resolve, reject) {
1041
+ resolveFunc = resolve;
1042
+ rejectFunc = reject;
1043
+ });
1044
+ prCallback = function(/** @type {any} */error, /** @type {any} */api) {
1045
+ if (error) return rejectFunc(error);
1046
+ return resolveFunc(api);
1047
+ };
1048
+ callback = prCallback;
1049
+ }
1050
+
1051
+ (async function() {
1052
+ var Premium = require("./Extra/Src/Premium");
1053
+ global.Fca.Data.PremText = await Premium(global.Fca.Require.Security.create().uuid) || "You are using version: Free !";
1054
+ if (!loginData.email && !loginData.password) {
1055
+ switch (global.Fca.Require.FastConfig.AutoLogin) {
1056
+ case true: {
1057
+ if (global.Fca.Require.FastConfig.ResetDataLogin) return setUserNameAndPassWord();
1058
+ else {
1059
+ try {
1060
+ if (Database().get("TempState")) {
1061
+ try {
1062
+ loginData.appState = JSON.parse(Database().get("TempState"));
1063
+ }
1064
+ catch (_) {
1065
+ loginData.appState = Database().get("TempState");
1066
+ }
1067
+ Database().delete("TempState");
1068
+ }
1069
+ }
1070
+ catch (e) {
1071
+ console.log(e)
1072
+ Database().delete("TempState");
1073
+ logger.Warning(Language.ErrDataBase);
1074
+ logger.Error();
1075
+ process.exit(0);
1076
+ }
1077
+ try {
1078
+ if (Database().has('Account') && Database().has('Password')) return loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
1079
+ else return setUserNameAndPassWord();
1080
+ }
1081
+ catch (e) {
1082
+ console.log(e)
1083
+ logger.Warning(Language.ErrDataBase);
1084
+ logger.Error();
1085
+ process.exit(0);
1086
+ }
1087
+ }
1088
+ }
1089
+ case false: {
1090
+ loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
1091
+ }
1092
+ }
1093
+ }
1094
+ else loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
1095
+ })()
1096
+ return returnPromise;
1097
+ }
1098
+
1099
+ module.exports = login;