fca-sakibin-remarsted 3.5.2

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