fca-test-mtx 2.0.1

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