fca-dragon 1.0.0

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