isoy 1.1.1

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