alicezetion 1.5.3 → 1.5.5

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