meta-horizon-remake 0.0.1-security.0 → 1.0.2

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

Potentially problematic release.


This version of meta-horizon-remake might be problematic. Click here for more details.

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