fca-priyansh 15.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Extra/Balancer.js +49 -0
- package/Extra/Bypass/956/index.js +234 -0
- package/Extra/Bypass/test/aaaa.json +170 -0
- package/Extra/Bypass/test/index.js +188 -0
- package/Extra/Database/index.js +249 -140
- package/Extra/ExtraAddons.js +35 -33
- package/Extra/ExtraFindUID.js +3 -1
- package/Extra/ExtraGetThread.js +303 -56
- package/Extra/ExtraUptimeRobot.js +15 -3
- package/Extra/Html/Classic/script.js +3 -3
- package/Extra/Security/AES_256_GCM/index.js +0 -0
- package/Extra/Security/Base/Step_1.js +6 -0
- package/Extra/Security/Base/Step_2.js +22 -0
- package/Extra/Security/Base/Step_3.js +22 -0
- package/Extra/Security/Base/index.js +191 -0
- package/Extra/Security/Index.js +5 -146
- package/Extra/Security/Step_1.js +4 -9
- package/Extra/Security/Step_2.js +2 -0
- package/Extra/Security/Step_3.js +4 -2
- package/Extra/Src/Change_Environment.js +1 -1
- package/Extra/Src/Check_Update.js +67 -0
- package/Extra/Src/History.js +2 -2
- package/Extra/Src/Instant_Update.js +65 -0
- package/Extra/Src/Premium.js +35 -38
- package/Extra/Src/Release_Memory.js +160 -0
- package/Extra/Src/Websocket.js +213 -0
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/test.js +28 -0
- package/Extra/Src/uuid.js +1 -1
- package/Func/AcceptAgreement.js +4 -5
- package/Func/ClearCache.js +7 -7
- package/Func/ReportV1.js +5 -5
- package/LICENSE +1 -4
- package/Language/index.json +59 -8
- package/Main.js +1444 -0
- package/README.md +198 -1
- package/broadcast.js +43 -37
- package/index.js +305 -1709
- package/logger.js +4 -4
- package/package.json +16 -11
- package/src/Dev_Horizon_Data.js +3 -3
- package/src/Dev_getThreadInfoOLD.js +422 -0
- package/src/Dev_shareTest2.js +68 -0
- package/src/Dev_shareTest3.js +71 -0
- package/src/Premium.js +8 -13
- package/src/Screenshot.js +4 -6
- package/src/editMessage.js +53 -0
- package/src/getAccessToken.js +0 -4
- package/src/getFriendsList.js +1 -1
- package/src/getMessage.js +26 -3
- package/src/getThreadHistory.js +1 -1
- package/src/getThreadInfo.js +237 -161
- package/src/getThreadInfoOLD.js +422 -0
- package/src/getThreadMain.js +1 -1
- package/src/getUID.js +3 -3
- package/src/getUserInfo.js +56 -73
- package/src/getUserInfoMain.js +2 -2
- package/src/getUserInfoV2.js +0 -4
- package/src/getUserInfoV3.js +3 -3
- package/src/getUserInfoV4.js +5 -5
- package/src/getUserInfoV5.js +4 -4
- package/src/listenMqtt.js +905 -625
- package/src/listenMqttV1.js +846 -0
- package/src/sendMessage.js +54 -2
- package/src/sendMqttMessage.js +71 -0
- package/src/setPostReaction.js +3 -3
- package/src/shareContact.js +55 -0
- package/src/shareLink.js +58 -0
- package/src/unsendMessage.js +28 -20
- package/src/unsendMqttMessage.js +66 -0
- package/utils.js +1567 -138
- package/.gitattributes +0 -2
- package/gitattributes +0 -2
- package/gitignore.txt +0 -10
package/Main.js
ADDED
@@ -0,0 +1,1444 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
//-[ Require config and use ]-!/
|
4
|
+
|
5
|
+
if (global.Fca.Require.Priyansh.Config != 'default') {
|
6
|
+
//do ssth
|
7
|
+
}
|
8
|
+
|
9
|
+
const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.Priyansh.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, writeFileSync } = require('fs-extra'),
|
22
|
+
Database = require("./Extra/Database"),
|
23
|
+
readline = require("readline"),
|
24
|
+
chalk = require("chalk"),
|
25
|
+
figlet = require("figlet"),
|
26
|
+
os = require("os"),
|
27
|
+
deasync = require('deasync'),
|
28
|
+
Security = require("./Extra/Security/Base"),
|
29
|
+
{ getAll, deleteAll } = require('./Extra/ExtraGetThread'),
|
30
|
+
ws = require('ws'),
|
31
|
+
Websocket = require('./Extra/Src/Websocket'),
|
32
|
+
Convert = require('ansi-to-html');
|
33
|
+
|
34
|
+
//-[ Set Variable For Process ]-!/
|
35
|
+
|
36
|
+
log.maxRecordSize = 100;
|
37
|
+
var checkVerified = null;
|
38
|
+
const Boolean_Option = ['online','selfListen','listenEvents','updatePresence','forceLogin','autoMarkDelivery','autoMarkRead','listenTyping','autoReconnect','emitReady'];
|
39
|
+
|
40
|
+
//-[ Set And Check Template HTML ]-!/
|
41
|
+
|
42
|
+
const css = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'style.css'));
|
43
|
+
const js = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'script.js'));
|
44
|
+
|
45
|
+
//-[ Function Generate HTML Template ]-!/
|
46
|
+
|
47
|
+
/**
|
48
|
+
* It returns a string of HTML code.
|
49
|
+
* @param UserName - The username of the user
|
50
|
+
* @param Type - The type of user, either "Free" or "Premium"
|
51
|
+
* @param link - The link to the music you want to play
|
52
|
+
* @returns A HTML file
|
53
|
+
*/
|
54
|
+
|
55
|
+
function ClassicHTML(UserName,Type,link) {
|
56
|
+
return `<!DOCTYPE html>
|
57
|
+
<html lang="en" >
|
58
|
+
<head>
|
59
|
+
<meta charset="UTF-8">
|
60
|
+
<title>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>Horizon User Infomation</h2>
|
67
|
+
<h3>UserName: ${UserName} | Type: ${Type}</h3>
|
68
|
+
<canvas id="myCanvas"></canvas>
|
69
|
+
<script src="./script.js"></script>
|
70
|
+
<footer class="footer">
|
71
|
+
<div id="music">
|
72
|
+
<audio autoplay="false" controls="true" loop="true" src="${link}" __idm_id__="5070849">Your browser does not support the audio element.</audio>
|
73
|
+
<br><b>Session ID:</b> ${global.Fca.Require.Security.create().uuid}<br>
|
74
|
+
<br>Thanks For Using <b>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
|
+
default: {
|
103
|
+
res.writeHead(200, "OK", { "Content-Type": "text/html" });
|
104
|
+
res.write(ClassicHTML(global.Fca.Require.Priyansh.HTML.UserName, "Premium Access", global.Fca.Require.Priyansh.HTML.MusicLink));
|
105
|
+
}
|
106
|
+
}
|
107
|
+
res.end();
|
108
|
+
})
|
109
|
+
var Server;
|
110
|
+
if (global.Fca.Require.Priyansh.HTML.HTML) Server= express.listen(express.get('DFP'));
|
111
|
+
|
112
|
+
/*
|
113
|
+
function escapeHTML(input) {
|
114
|
+
const entityMap = {'&': '&','<': '<','>': '>','"': '"',"'": '\''};
|
115
|
+
return String(input).replace(/[&<>"'`=\/]/g, function(s) {
|
116
|
+
return entityMap[s];
|
117
|
+
});
|
118
|
+
}
|
119
|
+
//avoid html injection
|
120
|
+
|
121
|
+
if (global.Fca.Require.Priyansh.Websocket_Extension.Status) {
|
122
|
+
var convert = new Convert();
|
123
|
+
if (Server != undefined) {
|
124
|
+
const WebSocket = new ws.Server({ noServer: true });
|
125
|
+
const { Client, WSS } = Websocket.connect(WebSocket);
|
126
|
+
Server.on('upgrade', (req, socket, head) => {
|
127
|
+
const escapedReq = escapeHTML(req);
|
128
|
+
const escapedSocket = escapeHTML(socket);
|
129
|
+
const escapedHead = escapeHTML(head);
|
130
|
+
WSS.handleUpgrade(escapedReq, escapedSocket, escapedHead, (wss) => {
|
131
|
+
const escapedWss = escapeHTML(wss);
|
132
|
+
const escapedReq = escapeHTML(req);
|
133
|
+
|
134
|
+
escapedWss.emit('connection', escapedWss, escapedReq);
|
135
|
+
});
|
136
|
+
});
|
137
|
+
console._log = console.__log
|
138
|
+
console.log = function(data) {
|
139
|
+
const All = Object.keys(Client)
|
140
|
+
console._log.apply(data,arguments)
|
141
|
+
try {
|
142
|
+
const log = (convert.toHtml(data) || data || "Nothing to show")
|
143
|
+
console.history.push(log)
|
144
|
+
if (console.history.length > 80) {
|
145
|
+
console.history.shift();
|
146
|
+
}
|
147
|
+
for (let i of All) {
|
148
|
+
if (Client[i].Status) {
|
149
|
+
Client[i].Websocket.send(JSON.stringify({ Type: "Console", Data: log }));
|
150
|
+
}
|
151
|
+
else continue;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
catch (e) {
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
else {
|
160
|
+
const WebSocket = new ws.Server({ port: 80 });
|
161
|
+
const { Client } = Websocket.connect(WebSocket);
|
162
|
+
console._log = console.__log
|
163
|
+
console.log = function(data) {
|
164
|
+
const All = Object.keys(Client)
|
165
|
+
console._log.apply(data,arguments)
|
166
|
+
try {
|
167
|
+
const log = convert.toHtml(data)
|
168
|
+
console.history.push(log)
|
169
|
+
if (console.history.length > 80) {
|
170
|
+
console.history.shift();
|
171
|
+
}
|
172
|
+
for (let i of All) {
|
173
|
+
if (Client[i].Status) {
|
174
|
+
Client[i].Websocket.send(JSON.stringify({ Type: "Console", Data: log }));
|
175
|
+
}
|
176
|
+
else continue;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
catch (e) {
|
180
|
+
return
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
}
|
186
|
+
**/
|
187
|
+
//-[ Function setOptions ]-!/
|
188
|
+
|
189
|
+
/**
|
190
|
+
* @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
|
191
|
+
* @param {{ [x: string]: any; logLevel?: any; forceLogin?: boolean; userAgent?: any; pauseLog?: any; logRecordSize?: any; pageID?: any; proxy?: any; }} options
|
192
|
+
*/
|
193
|
+
|
194
|
+
function setOptions(globalOptions, options) {
|
195
|
+
Object.keys(options).map(function(key) {
|
196
|
+
switch (Boolean_Option.includes(key)) {
|
197
|
+
case true: {
|
198
|
+
globalOptions[key] = Boolean(options[key]);
|
199
|
+
break;
|
200
|
+
}
|
201
|
+
case false: {
|
202
|
+
switch (key) {
|
203
|
+
case 'pauseLog': {
|
204
|
+
if (options.pauseLog) log.pause();
|
205
|
+
else log.resume();
|
206
|
+
break;
|
207
|
+
}
|
208
|
+
case 'logLevel': {
|
209
|
+
log.level = options.logLevel;
|
210
|
+
globalOptions.logLevel = options.logLevel;
|
211
|
+
break;
|
212
|
+
}
|
213
|
+
case 'logRecordSize': {
|
214
|
+
log.maxRecordSize = options.logRecordSize;
|
215
|
+
globalOptions.logRecordSize = options.logRecordSize;
|
216
|
+
break;
|
217
|
+
}
|
218
|
+
case 'pageID': {
|
219
|
+
globalOptions.pageID = options.pageID.toString();
|
220
|
+
break;
|
221
|
+
}
|
222
|
+
case 'userAgent': {
|
223
|
+
globalOptions.userAgent = (options.userAgent || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36');
|
224
|
+
break;
|
225
|
+
}
|
226
|
+
case 'proxy': {
|
227
|
+
if (typeof options.proxy != "string") {
|
228
|
+
delete globalOptions.proxy;
|
229
|
+
utils.setProxy();
|
230
|
+
} else {
|
231
|
+
globalOptions.proxy = options.proxy;
|
232
|
+
utils.setProxy(globalOptions.proxy);
|
233
|
+
}
|
234
|
+
break;
|
235
|
+
}
|
236
|
+
default: {
|
237
|
+
log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
|
238
|
+
break;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
break;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
});
|
245
|
+
}
|
246
|
+
|
247
|
+
function BypassAutomationNotification(resp, jar, globalOptions, appstate,ID) {
|
248
|
+
global.Fca.BypassAutomationNotification = BypassAutomationNotification
|
249
|
+
try {
|
250
|
+
let UID;
|
251
|
+
if (ID) UID = ID
|
252
|
+
else {
|
253
|
+
UID = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
|
254
|
+
UID = UID.value;
|
255
|
+
}
|
256
|
+
if (resp !== undefined) {
|
257
|
+
if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
258
|
+
if (resp.request.uri.href.includes('601051028565049')) {
|
259
|
+
const fb_dtsg = utils.getFrom(resp.body, '["DTSGInitData",[],{"token":"', '","');
|
260
|
+
const jazoest = utils.getFrom(resp.body, 'jazoest=', '",');
|
261
|
+
const lsd = utils.getFrom(resp.body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
262
|
+
|
263
|
+
const FormBypass = {
|
264
|
+
av: UID,
|
265
|
+
fb_dtsg, jazoest, lsd,
|
266
|
+
fb_api_caller_class: "RelayModern",
|
267
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
268
|
+
variables: JSON.stringify({}),
|
269
|
+
server_timestamps: true,
|
270
|
+
doc_id: 6339492849481770
|
271
|
+
}
|
272
|
+
return utils.post("https://www.facebook.com/api/graphql/", jar, FormBypass, globalOptions)
|
273
|
+
.then(utils.saveCookies(jar)).then(function(res) {
|
274
|
+
global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.Bypass_AutoNoti);
|
275
|
+
return process.exit(1);
|
276
|
+
});
|
277
|
+
}
|
278
|
+
else {
|
279
|
+
return resp;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
else {
|
283
|
+
return resp
|
284
|
+
}
|
285
|
+
}
|
286
|
+
else {
|
287
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(function(res) {
|
288
|
+
if (res.request.uri && res.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
289
|
+
if (res.request.uri.href.includes('601051028565049')) return { Status: true, Body: res.body }
|
290
|
+
else return { Status: false, Body: res.body }
|
291
|
+
}
|
292
|
+
else return { Status: false, Body: res.body }
|
293
|
+
}).then(function(res) {
|
294
|
+
if (res.Status === true) {
|
295
|
+
const fb_dtsg = utils.getFrom(res.Body, '["DTSGInitData",[],{"token":"', '","');
|
296
|
+
const jazoest = utils.getFrom(res.Body, 'jazoest=', '",');
|
297
|
+
const lsd = utils.getFrom(res.Body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
298
|
+
|
299
|
+
const FormBypass = {
|
300
|
+
av: UID,
|
301
|
+
fb_dtsg, jazoest, lsd,
|
302
|
+
fb_api_caller_class: "RelayModern",
|
303
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
304
|
+
variables: JSON.stringify({}),
|
305
|
+
server_timestamps: true,
|
306
|
+
doc_id: 6339492849481770
|
307
|
+
}
|
308
|
+
return utils.post("https://www.facebook.com/api/graphql/", jar, FormBypass, globalOptions).then(utils.saveCookies(jar))
|
309
|
+
.then(res => {
|
310
|
+
global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.Bypass_AutoNoti);
|
311
|
+
return res
|
312
|
+
})
|
313
|
+
}
|
314
|
+
else return res;
|
315
|
+
|
316
|
+
})
|
317
|
+
.then(function(res) {
|
318
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar))
|
319
|
+
})
|
320
|
+
.then(function(res) {
|
321
|
+
return process.exit(1)
|
322
|
+
})
|
323
|
+
}
|
324
|
+
}
|
325
|
+
catch (e) {
|
326
|
+
console.log(e)
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
//-[ Function BuildAPI ]-!/
|
331
|
+
|
332
|
+
/**
|
333
|
+
* @param {any} globalOptions
|
334
|
+
* @param {string} html
|
335
|
+
* @param {{ getCookies: (arg0: string) => any[]; }} jar
|
336
|
+
*/
|
337
|
+
|
338
|
+
function buildAPI(globalOptions, html, jar, bypass_region) {
|
339
|
+
//new feat
|
340
|
+
const fb_dtsg = utils.getFroms(html, '["DTSGInitData",[],{"token":"', '","')[0]; //nhăm nhăm nhăm nhăm
|
341
|
+
|
342
|
+
//check tiktik
|
343
|
+
var userID;
|
344
|
+
var cookie = jar.getCookies("https://www.facebook.com");
|
345
|
+
//.log(cookie)
|
346
|
+
var maybeUser = cookie.filter(function(val) { return val.cookieString().split("=")[0] === "c_user"; });
|
347
|
+
var maybeTiktik = cookie.filter(function(val) { return val.cookieString().split("=")[0] === "i_user"; });
|
348
|
+
if (maybeUser.length === 0 && maybeTiktik.length === 0) {
|
349
|
+
if (global.Fca.Require.Priyansh.AutoLogin) {
|
350
|
+
return global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.AutoLogin, function() {
|
351
|
+
global.Fca.Action('AutoLogin')
|
352
|
+
});
|
353
|
+
}
|
354
|
+
else if (!global.Fca.Require.Priyansh.AutoLogin) {
|
355
|
+
return global.Fca.Require.logger.Error(global.Fca.Require.Language.Index.ErrAppState);
|
356
|
+
}
|
357
|
+
}
|
358
|
+
else {
|
359
|
+
if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
|
360
|
+
|
361
|
+
if (maybeTiktik[0] && maybeTiktik[0].cookieString().includes('i_user')) {
|
362
|
+
userID = maybeTiktik[0].cookieString().split("=")[1].toString();
|
363
|
+
|
364
|
+
}
|
365
|
+
else userID = maybeUser[0].cookieString().split("=")[1].toString();
|
366
|
+
process.env['UID'] = logger.Normal(getText(Language.UID,userID), userID);
|
367
|
+
|
368
|
+
try {
|
369
|
+
clearInterval(checkVerified);
|
370
|
+
} catch (e) {
|
371
|
+
console.log(e);
|
372
|
+
}
|
373
|
+
|
374
|
+
var clientID = (Math.random() * 2147483648 | 0).toString(16);
|
375
|
+
|
376
|
+
var CHECK_MQTT = {
|
377
|
+
oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
|
378
|
+
newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
|
379
|
+
legacyFBMQTTMatch: html.match(/\["MqttWebConfig",\[\],{"fbid":"(.*?)","appID":219994525426954,"endpoint":"(.*?)","pollingEndpoint":"(.*?)"/)
|
380
|
+
}
|
381
|
+
|
382
|
+
// tổng hợp danh sách region never die của Kanzu =))
|
383
|
+
/**
|
384
|
+
* PRN = Pacific Northwest Region (Khu vực Tây Bắc Thái Bình Dương)
|
385
|
+
* VLL = Valley Region
|
386
|
+
* ASH = Ashburn Region
|
387
|
+
* DFW = Dallas/Fort Worth Region
|
388
|
+
* LLA = Los Angeles Region
|
389
|
+
* FRA = Frankfurt
|
390
|
+
* SIN = Singapore
|
391
|
+
* NRT = Tokyo (Japan)
|
392
|
+
* HKG = Hong Kong
|
393
|
+
* SYD = Sydney
|
394
|
+
*/
|
395
|
+
|
396
|
+
let Slot = Object.keys(CHECK_MQTT);
|
397
|
+
var mqttEndpoint,region,irisSeqID;
|
398
|
+
Object.keys(CHECK_MQTT).map(function(MQTT) {
|
399
|
+
if (CHECK_MQTT[MQTT] && !region) {
|
400
|
+
switch (Slot.indexOf(MQTT)) {
|
401
|
+
case 0: {
|
402
|
+
irisSeqID = CHECK_MQTT[MQTT][1];
|
403
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/");
|
404
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
405
|
+
return;
|
406
|
+
}
|
407
|
+
case 1: {
|
408
|
+
irisSeqID = CHECK_MQTT[MQTT][2];
|
409
|
+
mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
|
410
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
411
|
+
return;
|
412
|
+
}
|
413
|
+
case 2: {
|
414
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/"); //is important lmao f?
|
415
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
416
|
+
return;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
return;
|
420
|
+
}
|
421
|
+
});
|
422
|
+
|
423
|
+
const regions = [
|
424
|
+
{
|
425
|
+
code: "PRN",
|
426
|
+
name: "Pacific Northwest Region",
|
427
|
+
location: "Khu vực Tây Bắc Thái Bình Dương"
|
428
|
+
},
|
429
|
+
{
|
430
|
+
code: "VLL",
|
431
|
+
name: "Valley Region",
|
432
|
+
location: "Valley"
|
433
|
+
},
|
434
|
+
{
|
435
|
+
code: "ASH",
|
436
|
+
name: "Ashburn Region",
|
437
|
+
location: "Ashburn"
|
438
|
+
},
|
439
|
+
{
|
440
|
+
code: "DFW",
|
441
|
+
name: "Dallas/Fort Worth Region",
|
442
|
+
location: "Dallas/Fort Worth"
|
443
|
+
},
|
444
|
+
{
|
445
|
+
code: "LLA",
|
446
|
+
name: "Los Angeles Region",
|
447
|
+
location: "Los Angeles"
|
448
|
+
},
|
449
|
+
{
|
450
|
+
code: "FRA",
|
451
|
+
name: "Frankfurt",
|
452
|
+
location: "Frankfurt"
|
453
|
+
},
|
454
|
+
{
|
455
|
+
code: "SIN",
|
456
|
+
name: "Singapore",
|
457
|
+
location: "Singapore"
|
458
|
+
},
|
459
|
+
{
|
460
|
+
code: "NRT",
|
461
|
+
name: "Tokyo",
|
462
|
+
location: "Japan"
|
463
|
+
},
|
464
|
+
{
|
465
|
+
code: "HKG",
|
466
|
+
name: "Hong Kong",
|
467
|
+
location: "Hong Kong"
|
468
|
+
},
|
469
|
+
{
|
470
|
+
code: "SYD",
|
471
|
+
name: "Sydney",
|
472
|
+
location: "Sydney"
|
473
|
+
},
|
474
|
+
{
|
475
|
+
code: "PNB",
|
476
|
+
name: "Pacific Northwest - Beta",
|
477
|
+
location: "Pacific Northwest "
|
478
|
+
}
|
479
|
+
];
|
480
|
+
|
481
|
+
if (!region) {
|
482
|
+
region = ['prn',"pnb","vll","hkg","sin"][Math.random()*5|0];
|
483
|
+
|
484
|
+
}
|
485
|
+
if (!mqttEndpoint) {
|
486
|
+
mqttEndpoint = "wss://edge-chat.facebook.com/chat?region=" + region;
|
487
|
+
}
|
488
|
+
|
489
|
+
const Location = regions.find(r => r.code === region.toUpperCase());
|
490
|
+
logger.Normal(getText(Language.Area,(Location == undefined ? region.toUpperCase() : Location.name)));
|
491
|
+
|
492
|
+
var ctx = {
|
493
|
+
userID: userID,
|
494
|
+
jar: jar,
|
495
|
+
clientID: clientID,
|
496
|
+
globalOptions: globalOptions,
|
497
|
+
loggedIn: true,
|
498
|
+
access_token: 'NONE',
|
499
|
+
clientMutationId: 0,
|
500
|
+
mqttClient: undefined,
|
501
|
+
lastSeqId: irisSeqID,
|
502
|
+
syncToken: undefined,
|
503
|
+
mqttEndpoint: mqttEndpoint,
|
504
|
+
region: region,
|
505
|
+
firstListen: true,
|
506
|
+
req_ID: 0,
|
507
|
+
callback_Task: {},
|
508
|
+
fb_dtsg //i love u
|
509
|
+
};
|
510
|
+
|
511
|
+
var api = {
|
512
|
+
setOptions: setOptions.bind(null, globalOptions),
|
513
|
+
getAppState: function getAppState() {
|
514
|
+
return utils.getAppState(jar);
|
515
|
+
}
|
516
|
+
};
|
517
|
+
if (region && mqttEndpoint) {
|
518
|
+
//do sth
|
519
|
+
}
|
520
|
+
else {
|
521
|
+
if (bypass_region) {
|
522
|
+
logger.Normal(Language.NoAreaDataBypass);
|
523
|
+
}
|
524
|
+
else {
|
525
|
+
log.warn("login", getText(Language.NoAreaData));
|
526
|
+
api["htmlData"] = html;
|
527
|
+
}
|
528
|
+
}
|
529
|
+
|
530
|
+
var defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
531
|
+
|
532
|
+
fs.readdirSync(__dirname + "/src").filter((/** @type {string} */File) => File.endsWith(".js") && !File.includes('Dev_')).map((/** @type {string} */File) => {
|
533
|
+
if (File == 'getThreadInfo.js' && global.Fca.Require.Priyansh.AntiGetInfo.AntiGetThreadInfo != true || File == 'getUserInfo.js' && global.Fca.Require.Priyansh.AntiGetInfo.AntiGetUserInfo != true) api[File.split('.').slice(0, -1).join('.')] = require('./src/' + (File.includes('getThreadInfo') ? 'getThreadMain.js' : 'getUserInfoMain.js'))(defaultFuncs, api, ctx)
|
534
|
+
else api[File.split('.').slice(0, -1).join('.')] = require('./src/' + File)(defaultFuncs, api, ctx)
|
535
|
+
});
|
536
|
+
|
537
|
+
return {
|
538
|
+
ctx,
|
539
|
+
defaultFuncs,
|
540
|
+
api
|
541
|
+
};
|
542
|
+
}
|
543
|
+
}
|
544
|
+
|
545
|
+
//-[ Function makeLogin ]-!/
|
546
|
+
|
547
|
+
/**
|
548
|
+
* @param {{ setCookie: (arg0: any, arg1: string) => void; }} jar
|
549
|
+
* @param {any} email
|
550
|
+
* @param {any} password
|
551
|
+
* @param {{ forceLogin: any; }} loginOptions
|
552
|
+
* @param {(err: any, api: any) => any} callback
|
553
|
+
* @param {any} prCallback
|
554
|
+
*/
|
555
|
+
|
556
|
+
function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
557
|
+
return function(res) {
|
558
|
+
var html = res.body,$ = cheerio.load(html),arr = [];
|
559
|
+
|
560
|
+
$("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
561
|
+
|
562
|
+
arr = arr.filter(function(v) {
|
563
|
+
return v.val && v.val.length;
|
564
|
+
});
|
565
|
+
var form = utils.arrToForm(arr);
|
566
|
+
form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
567
|
+
form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
|
568
|
+
form.email = email;
|
569
|
+
form.pass = password;
|
570
|
+
form.default_persistent = '0';
|
571
|
+
form.locale = 'en_US';
|
572
|
+
form.timezone = '240';
|
573
|
+
form.lgnjs = ~~(Date.now() / 1000);
|
574
|
+
|
575
|
+
html.split("\"_js_").slice(1).map((val) => {
|
576
|
+
jar.setCookie(utils.formatCookie(JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]"), "facebook"),"https://www.facebook.com")
|
577
|
+
});
|
578
|
+
|
579
|
+
logger.Normal(Language.OnLogin);
|
580
|
+
return utils
|
581
|
+
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
582
|
+
.then(utils.saveCookies(jar))
|
583
|
+
.then(function(/** @type {{ headers: any; }} */res) {
|
584
|
+
var headers = res.headers;
|
585
|
+
if (!headers.location) throw { error: Language.InvaildAccount };
|
586
|
+
|
587
|
+
// This means the account has login approvals turned on.
|
588
|
+
if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
|
589
|
+
logger.Warning(Language.TwoAuth);
|
590
|
+
var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
|
591
|
+
|
592
|
+
return utils
|
593
|
+
.get(headers.location, jar, null, loginOptions)
|
594
|
+
.then(utils.saveCookies(jar))
|
595
|
+
.then(function(res) {
|
596
|
+
if (!Database().get('ThroughAcc')) {
|
597
|
+
Database().set('ThroughAcc', email);
|
598
|
+
}
|
599
|
+
else {
|
600
|
+
if (String((Database().get('ThroughAcc'))).replace(RegExp('"','g'), '') != String(email).replace(RegExp('"','g'), '')) {
|
601
|
+
Database().set('ThroughAcc', email);
|
602
|
+
if (Database().get('Through2Fa')) {
|
603
|
+
Database().delete('Through2Fa');
|
604
|
+
}
|
605
|
+
}
|
606
|
+
}
|
607
|
+
var html = res.body,$ = cheerio.load(html), arr = [];
|
608
|
+
$("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
609
|
+
arr = arr.filter(v => { return v.val && v.val.length });
|
610
|
+
var form = utils.arrToForm(arr);
|
611
|
+
if (html.indexOf("checkpoint/?next") > -1) {
|
612
|
+
setTimeout(() => {
|
613
|
+
checkVerified = setInterval((_form) => {}, 5000, {
|
614
|
+
fb_dtsg: form.fb_dtsg,
|
615
|
+
jazoest: form.jazoest,
|
616
|
+
dpr: 1
|
617
|
+
});
|
618
|
+
}, 2500);
|
619
|
+
switch (global.Fca.Require.Priyansh.Login2Fa) {
|
620
|
+
case true: {
|
621
|
+
const question = question => {
|
622
|
+
const rl = readline.createInterface({
|
623
|
+
input: process.stdin,
|
624
|
+
output: process.stdout
|
625
|
+
});
|
626
|
+
var done,answ;
|
627
|
+
rl.question(question, answer => {
|
628
|
+
rl.close();
|
629
|
+
answ = answer;
|
630
|
+
done = true
|
631
|
+
})
|
632
|
+
deasync.loopWhile(function(){
|
633
|
+
return !done;
|
634
|
+
});
|
635
|
+
return answ;
|
636
|
+
};
|
637
|
+
try {
|
638
|
+
const Old_Cookie = Database().get('Through2Fa');
|
639
|
+
if (Old_Cookie) {
|
640
|
+
Old_Cookie.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
|
641
|
+
let str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
642
|
+
jar.setCookie(str, "http://" + c.domain);
|
643
|
+
});
|
644
|
+
let Form = utils.arrToForm(arr);
|
645
|
+
Form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
646
|
+
Form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
|
647
|
+
Form.email = email;
|
648
|
+
Form.pass = password;
|
649
|
+
Form.default_persistent = '0';
|
650
|
+
Form.locale = 'en_US';
|
651
|
+
Form.timezone = '240';
|
652
|
+
Form.lgnjs = ~~(Date.now() / 1000);
|
653
|
+
return utils
|
654
|
+
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, Form, loginOptions)
|
655
|
+
.then(utils.saveCookies(jar))
|
656
|
+
.then(function(res) {
|
657
|
+
let headers = res.headers
|
658
|
+
if (!headers['set-cookie'][0].includes('deleted')) {
|
659
|
+
logger.Warning(Language.ErrThroughCookies, function() {
|
660
|
+
Database().delete('Through2Fa');
|
661
|
+
});
|
662
|
+
process.exit(1);
|
663
|
+
}
|
664
|
+
if (headers.location && headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
|
665
|
+
return utils
|
666
|
+
.get(headers.location, jar, null, loginOptions)
|
667
|
+
.then(utils.saveCookies(jar))
|
668
|
+
.then(function(res) {
|
669
|
+
var html = res.body,$ = cheerio.load(html), arr = [];
|
670
|
+
$("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
671
|
+
arr = arr.filter(v => { return v.val && v.val.length });
|
672
|
+
var Form = utils.arrToForm(arr);
|
673
|
+
|
674
|
+
if (html.indexOf("checkpoint/?next") > -1) {
|
675
|
+
setTimeout(() => {
|
676
|
+
checkVerified = setInterval((_form) => {}, 5000, {
|
677
|
+
fb_dtsg: Form.fb_dtsg,
|
678
|
+
jazoest: Form.jazoest,
|
679
|
+
dpr: 1
|
680
|
+
});
|
681
|
+
}, 2500);
|
682
|
+
|
683
|
+
if (!res.headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
|
684
|
+
try {
|
685
|
+
delete Form.name_action_selected;
|
686
|
+
Form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
687
|
+
return utils
|
688
|
+
.post(nextURL, jar, Form, loginOptions)
|
689
|
+
.then(utils.saveCookies(jar))
|
690
|
+
.then(function() {
|
691
|
+
Form['submit[This was me]'] = "This was me";
|
692
|
+
return utils.post(nextURL, jar, Form, loginOptions).then(utils.saveCookies(jar));
|
693
|
+
})
|
694
|
+
.then(function() {
|
695
|
+
delete Form['submit[This was me]'];
|
696
|
+
Form.name_action_selected = 'save_device';
|
697
|
+
Form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
698
|
+
return utils.post(nextURL, jar, Form, loginOptions).then(utils.saveCookies(jar));
|
699
|
+
})
|
700
|
+
.then(function(res) {
|
701
|
+
var headers = res.headers;
|
702
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
|
703
|
+
Database().delete('Through2Fa');
|
704
|
+
process.exit(1);
|
705
|
+
}
|
706
|
+
var appState = utils.getAppState(jar,false);
|
707
|
+
Database().set('Through2Fa', appState);
|
708
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
709
|
+
})
|
710
|
+
.catch((e) => callback(e));
|
711
|
+
}
|
712
|
+
catch (e) {
|
713
|
+
console.log(e)
|
714
|
+
}
|
715
|
+
}
|
716
|
+
}
|
717
|
+
})
|
718
|
+
}
|
719
|
+
return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
|
720
|
+
})
|
721
|
+
.catch((e) => console.log(e));
|
722
|
+
}
|
723
|
+
}
|
724
|
+
catch (e) {
|
725
|
+
Database().delete('Through2Fa');
|
726
|
+
}
|
727
|
+
const Otp_code = require('totp-generator');
|
728
|
+
const Code = global.Fca.Require.Priyansh.AuthString.includes('|') == false ? Otp_code(global.Fca.Require.Priyansh.AuthString.includes(" ") ? global.Fca.Require.Priyansh.AuthString.replace(RegExp(" ", 'g'), "") : global.Fca.Require.Priyansh.AuthString) : question(Language.EnterSecurityCode);
|
729
|
+
try {
|
730
|
+
const approvals = function(N_Code) {
|
731
|
+
form.approvals_code = N_Code;
|
732
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
733
|
+
var prResolve,prReject;
|
734
|
+
var rtPromise = new Promise((resolve, reject) => { prResolve = resolve; prReject = reject; });
|
735
|
+
|
736
|
+
if (typeof N_Code == "string") {
|
737
|
+
utils
|
738
|
+
.post(nextURL, jar, form, loginOptions)
|
739
|
+
.then(utils.saveCookies(jar))
|
740
|
+
.then(function(res) {
|
741
|
+
var $ = cheerio.load(res.body);
|
742
|
+
var error = $("#approvals_code").parent().attr("data-xui-error");
|
743
|
+
if (error) {
|
744
|
+
logger.Warning(Language.InvaildTwoAuthCode,function() { approvals(question(Language.EnterSecurityCode)) }); //bruh loop
|
745
|
+
};
|
746
|
+
})
|
747
|
+
.then(function() {
|
748
|
+
delete form.no_fido;delete form.approvals_code;
|
749
|
+
form.name_action_selected = 'save_device'; //'save_device' || 'dont_save;
|
750
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
751
|
+
})
|
752
|
+
.then(function(res) {
|
753
|
+
var headers = res.headers;
|
754
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
|
755
|
+
try {
|
756
|
+
delete form.name_action_selected;
|
757
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
758
|
+
return utils
|
759
|
+
.post(nextURL, jar, form, loginOptions)
|
760
|
+
.then(utils.saveCookies(jar))
|
761
|
+
.then(function() {
|
762
|
+
form['submit[This was me]'] = "This was me";
|
763
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
764
|
+
})
|
765
|
+
.then(function() {
|
766
|
+
delete form['submit[This was me]'];
|
767
|
+
form.name_action_selected = 'save_device';
|
768
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
769
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
770
|
+
})
|
771
|
+
.then(function(res) {
|
772
|
+
var headers = res.headers;
|
773
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: "wtf ??:D" };
|
774
|
+
var appState = utils.getAppState(jar,false);
|
775
|
+
Database().set('Through2Fa', appState);
|
776
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
777
|
+
})
|
778
|
+
.catch((e) => callback(e));
|
779
|
+
}
|
780
|
+
catch (e) {
|
781
|
+
console.log(e)
|
782
|
+
}
|
783
|
+
}
|
784
|
+
var appState = utils.getAppState(jar,false);
|
785
|
+
if (callback === prCallback) {
|
786
|
+
callback = function(err, api) {
|
787
|
+
if (err) return prReject(err);
|
788
|
+
return prResolve(api);
|
789
|
+
};
|
790
|
+
}
|
791
|
+
Database().set('Through2Fa', appState);
|
792
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
793
|
+
})
|
794
|
+
.catch(function(err) {
|
795
|
+
if (callback === prCallback) prReject(err);
|
796
|
+
else callback(err);
|
797
|
+
});
|
798
|
+
}
|
799
|
+
else {
|
800
|
+
utils
|
801
|
+
.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" })
|
802
|
+
.then(utils.saveCookies(jar))
|
803
|
+
.then(function(res) {
|
804
|
+
try {
|
805
|
+
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
806
|
+
} catch (ex) {
|
807
|
+
clearInterval(checkVerified);
|
808
|
+
logger.Warning(Language.VerifiedCheck);
|
809
|
+
if (callback === prCallback) {
|
810
|
+
callback = function(err, api) {
|
811
|
+
if (err) return prReject(err);
|
812
|
+
return prResolve(api);
|
813
|
+
};
|
814
|
+
}
|
815
|
+
let appState = utils.getAppState(jar,false);
|
816
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
817
|
+
}
|
818
|
+
})
|
819
|
+
.catch((ex) => {
|
820
|
+
log.error("login", ex);
|
821
|
+
if (callback === prCallback) prReject(ex);
|
822
|
+
else callback(ex);
|
823
|
+
});
|
824
|
+
}
|
825
|
+
return rtPromise;
|
826
|
+
}
|
827
|
+
return approvals(Code)
|
828
|
+
}
|
829
|
+
catch (e) {
|
830
|
+
logger.Error(e)
|
831
|
+
logger.Error();
|
832
|
+
process.exit(0);
|
833
|
+
}
|
834
|
+
}
|
835
|
+
case false: {
|
836
|
+
throw {
|
837
|
+
error: 'login-approval',
|
838
|
+
continue: function submit2FA(code) {
|
839
|
+
form.approvals_code = code;
|
840
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
|
841
|
+
var prResolve,prReject;
|
842
|
+
var rtPromise = new Promise((resolve, reject) => { prResolve = resolve; prReject = reject; });
|
843
|
+
if (typeof code == "string") {
|
844
|
+
utils
|
845
|
+
.post(nextURL, jar, form, loginOptions)
|
846
|
+
.then(utils.saveCookies(jar))
|
847
|
+
.then(function(/** @type {{ body: string | Buffer; }} */res) {
|
848
|
+
var $ = cheerio.load(res.body);
|
849
|
+
var error = $("#approvals_code").parent().attr("data-xui-error");
|
850
|
+
if (error) {
|
851
|
+
throw {
|
852
|
+
error: 'login-approval',
|
853
|
+
errordesc: Language.InvaildTwoAuthCode,
|
854
|
+
lerror: error,
|
855
|
+
continue: submit2FA
|
856
|
+
};
|
857
|
+
}
|
858
|
+
})
|
859
|
+
.then(function() {
|
860
|
+
delete form.no_fido;delete form.approvals_code;
|
861
|
+
form.name_action_selected = 'dont_save'; //'save_device' || 'dont_save;
|
862
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
863
|
+
})
|
864
|
+
.then(function(res) {
|
865
|
+
var headers = res.headers;
|
866
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: Language.ApprovalsErr };
|
867
|
+
var appState = utils.getAppState(jar,false);
|
868
|
+
if (callback === prCallback) {
|
869
|
+
callback = function(err, api) {
|
870
|
+
if (err) return prReject(err);
|
871
|
+
return prResolve(api);
|
872
|
+
};
|
873
|
+
}
|
874
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
875
|
+
})
|
876
|
+
.catch(function(err) {
|
877
|
+
if (callback === prCallback) prReject(err);
|
878
|
+
else callback(err);
|
879
|
+
});
|
880
|
+
} else {
|
881
|
+
utils
|
882
|
+
.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" })
|
883
|
+
.then(utils.saveCookies(jar))
|
884
|
+
.then((res) => {
|
885
|
+
try {
|
886
|
+
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
887
|
+
} catch (ex) {
|
888
|
+
clearInterval(checkVerified);
|
889
|
+
logger.Warning(Language.VerifiedCheck);
|
890
|
+
if (callback === prCallback) {
|
891
|
+
callback = function(err, api) {
|
892
|
+
if (err) return prReject(err);
|
893
|
+
return prResolve(api);
|
894
|
+
};
|
895
|
+
}
|
896
|
+
return loginHelper(utils.getAppState(jar,false), email, password, loginOptions, callback);
|
897
|
+
}
|
898
|
+
})
|
899
|
+
.catch((ex) => {
|
900
|
+
log.error("login", ex);
|
901
|
+
if (callback === prCallback) prReject(ex);
|
902
|
+
else callback(ex);
|
903
|
+
});
|
904
|
+
}
|
905
|
+
return rtPromise;
|
906
|
+
}
|
907
|
+
};
|
908
|
+
}
|
909
|
+
}
|
910
|
+
} else {
|
911
|
+
if (!loginOptions.forceLogin) throw { error: Language.ForceLoginNotEnable };
|
912
|
+
|
913
|
+
if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
|
914
|
+
else form['submit[This Is Okay]'] = "This Is Okay";
|
915
|
+
|
916
|
+
return utils
|
917
|
+
.post(nextURL, jar, form, loginOptions)
|
918
|
+
.then(utils.saveCookies(jar))
|
919
|
+
.then(function() {
|
920
|
+
form.name_action_selected = 'dont_save';
|
921
|
+
|
922
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
923
|
+
})
|
924
|
+
.then(function(res) {
|
925
|
+
var headers = res.headers;
|
926
|
+
|
927
|
+
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
|
928
|
+
|
929
|
+
var appState = utils.getAppState(jar,false);
|
930
|
+
|
931
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
932
|
+
})
|
933
|
+
.catch((e) => callback(e));
|
934
|
+
}
|
935
|
+
});
|
936
|
+
}
|
937
|
+
return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
|
938
|
+
});
|
939
|
+
};
|
940
|
+
}
|
941
|
+
|
942
|
+
//-[ Function backup ]-!/
|
943
|
+
|
944
|
+
/**
|
945
|
+
* @param {string} data
|
946
|
+
* @param {any} globalOptions
|
947
|
+
* @param {any} callback
|
948
|
+
* @param {any} prCallback
|
949
|
+
*/
|
950
|
+
|
951
|
+
function backup(data,globalOptions, callback, prCallback) {
|
952
|
+
try {
|
953
|
+
var appstate;
|
954
|
+
try {
|
955
|
+
appstate = JSON.parse(data)
|
956
|
+
}
|
957
|
+
catch(e) {
|
958
|
+
appstate = data;
|
959
|
+
}
|
960
|
+
logger.Warning(Language.BackupNoti);
|
961
|
+
try {
|
962
|
+
loginHelper(appstate,null,null,globalOptions, callback, prCallback)
|
963
|
+
}
|
964
|
+
catch (e) {
|
965
|
+
logger.Error(Language.ErrBackup);
|
966
|
+
process.exit(0);
|
967
|
+
}
|
968
|
+
}
|
969
|
+
catch (e) {
|
970
|
+
return logger.Error();
|
971
|
+
}
|
972
|
+
}
|
973
|
+
|
974
|
+
//-[ function loginHelper ]-!/
|
975
|
+
|
976
|
+
/**
|
977
|
+
* @param {string | any[]} appState
|
978
|
+
* @param {any} email
|
979
|
+
* @param {any} password
|
980
|
+
* @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
|
981
|
+
* @param {(arg0: any, arg1: undefined) => void} callback
|
982
|
+
* @param {(error: any, api: any) => any} [prCallback]
|
983
|
+
*/
|
984
|
+
|
985
|
+
function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
986
|
+
var mainPromise = null;
|
987
|
+
var jar = utils.getJar();
|
988
|
+
|
989
|
+
try {
|
990
|
+
if (appState) {
|
991
|
+
logger.Normal(Language.OnProcess);
|
992
|
+
switch (Database().has("FBKEY")) {
|
993
|
+
case true: {
|
994
|
+
process.env.FBKEY = Database().get("FBKEY");
|
995
|
+
}
|
996
|
+
break;
|
997
|
+
case false: {
|
998
|
+
const SecurityKey = global.Fca.Require.Security.create().apiKey;
|
999
|
+
process.env['FBKEY'] = SecurityKey;
|
1000
|
+
Database().set('FBKEY', SecurityKey);
|
1001
|
+
}
|
1002
|
+
break;
|
1003
|
+
default: {
|
1004
|
+
const SecurityKey = global.Fca.Require.Security.create().apiKey;
|
1005
|
+
process.env['FBKEY'] = SecurityKey;
|
1006
|
+
Database().set('FBKEY', SecurityKey);
|
1007
|
+
}
|
1008
|
+
}
|
1009
|
+
try {
|
1010
|
+
switch (global.Fca.Require.Priyansh.EncryptFeature) {
|
1011
|
+
case true: {
|
1012
|
+
appState = JSON.parse(JSON.stringify(appState, null, "\t"));
|
1013
|
+
switch (utils.getType(appState)) {
|
1014
|
+
case "Array": {
|
1015
|
+
switch (utils.getType(appState[0])) {
|
1016
|
+
case "Object": {
|
1017
|
+
logger.Normal(Language.NotReadyToDecrypt);
|
1018
|
+
}
|
1019
|
+
break;
|
1020
|
+
case "String": {
|
1021
|
+
appState = Security(appState,process.env['FBKEY'],'Decrypt');
|
1022
|
+
logger.Normal(Language.DecryptSuccess);
|
1023
|
+
}
|
1024
|
+
break;
|
1025
|
+
default: {
|
1026
|
+
logger.Warning(Language.InvaildAppState);
|
1027
|
+
process.exit(0)
|
1028
|
+
}
|
1029
|
+
}
|
1030
|
+
}
|
1031
|
+
break;
|
1032
|
+
default: {
|
1033
|
+
logger.Warning(Language.InvaildAppState);
|
1034
|
+
process.exit(0)
|
1035
|
+
}
|
1036
|
+
}
|
1037
|
+
}
|
1038
|
+
break;
|
1039
|
+
case false: {
|
1040
|
+
switch (utils.getType(appState)) {
|
1041
|
+
case "Array": {
|
1042
|
+
switch (utils.getType(appState[0])) {
|
1043
|
+
case "Object": {
|
1044
|
+
logger.Normal(Language.EncryptStateOff);
|
1045
|
+
}
|
1046
|
+
break;
|
1047
|
+
case "String": {
|
1048
|
+
appState = Security(appState,process.env['FBKEY'],'Decrypt');
|
1049
|
+
logger.Normal(Language.EncryptStateOff);
|
1050
|
+
logger.Normal(Language.DecryptSuccess);
|
1051
|
+
}
|
1052
|
+
break;
|
1053
|
+
default: {
|
1054
|
+
logger.Warning(Language.InvaildAppState);
|
1055
|
+
process.exit(0)
|
1056
|
+
}
|
1057
|
+
}
|
1058
|
+
}
|
1059
|
+
break;
|
1060
|
+
default: {
|
1061
|
+
logger.Warning(Language.InvaildAppState);
|
1062
|
+
process.exit(0)
|
1063
|
+
}
|
1064
|
+
}
|
1065
|
+
}
|
1066
|
+
break;
|
1067
|
+
default: {
|
1068
|
+
logger.Warning(getText(Language.IsNotABoolean,global.Fca.Require.Priyansh.EncryptFeature))
|
1069
|
+
process.exit(0);
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
}
|
1073
|
+
catch (e) {
|
1074
|
+
console.log(e);
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
try {
|
1078
|
+
appState = JSON.parse(appState);
|
1079
|
+
}
|
1080
|
+
catch (e) {
|
1081
|
+
try {
|
1082
|
+
appState = appState;
|
1083
|
+
}
|
1084
|
+
catch (e) {
|
1085
|
+
return logger.Error();
|
1086
|
+
}
|
1087
|
+
}
|
1088
|
+
try {
|
1089
|
+
global.Fca.Data.AppState = appState;
|
1090
|
+
appState.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
|
1091
|
+
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
1092
|
+
jar.setCookie(str, "http://" + c.domain);
|
1093
|
+
});
|
1094
|
+
Database().set('Backup', appState);
|
1095
|
+
mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
|
1096
|
+
}
|
1097
|
+
catch (e) {
|
1098
|
+
try {
|
1099
|
+
if (Database().has('Backup')) {
|
1100
|
+
return backup(Database().get('Backup'),globalOptions, callback, prCallback);
|
1101
|
+
}
|
1102
|
+
else {
|
1103
|
+
logger.Warning(Language.ErrBackup);
|
1104
|
+
process.exit(0);
|
1105
|
+
}
|
1106
|
+
}
|
1107
|
+
catch (e) {
|
1108
|
+
logger.Warning(Language.ErrBackup);
|
1109
|
+
process.exit(0);
|
1110
|
+
}
|
1111
|
+
}
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
else {
|
1115
|
+
mainPromise = utils
|
1116
|
+
.get("https://www.facebook.com/Lazic.Kanzu", null, null, globalOptions, { noRef: true }) // for fixing
|
1117
|
+
.then(utils.saveCookies(jar))
|
1118
|
+
.then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
|
1119
|
+
.then(function() {
|
1120
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
|
1121
|
+
});
|
1122
|
+
}
|
1123
|
+
} catch (e) {
|
1124
|
+
console.log(e);
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
function CheckAndFixErr(res, fastSwitch) {
|
1128
|
+
if (fastSwitch) return res;
|
1129
|
+
let reg_antierr = /7431627028261359627/gs; // =))))))
|
1130
|
+
if (reg_antierr.test(res.body)) {
|
1131
|
+
const Data = JSON.stringify(res.body);
|
1132
|
+
const Dt_Check = Data.split('2Fhome.php&gfid=')[1];
|
1133
|
+
if (Dt_Check == undefined) return res
|
1134
|
+
const fid = Dt_Check.split("\\\\")[0];//fix sau
|
1135
|
+
if (Dt_Check == undefined || Dt_Check == "") return res
|
1136
|
+
const final_fid = fid.split(`\\`)[0];
|
1137
|
+
if (final_fid == undefined || final_fid == '') return res;
|
1138
|
+
const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
|
1139
|
+
bypass_region_err = true;
|
1140
|
+
return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
|
1141
|
+
}
|
1142
|
+
else return res
|
1143
|
+
}
|
1144
|
+
|
1145
|
+
function Redirect(res,fastSwitch) {
|
1146
|
+
if (fastSwitch) return res;
|
1147
|
+
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
1148
|
+
redirect = reg.exec(res.body);
|
1149
|
+
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions)
|
1150
|
+
return res;
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
let redirect = [1, "https://m.facebook.com/"];
|
1154
|
+
let bypass_region_err = false;
|
1155
|
+
var ctx,api;
|
1156
|
+
mainPromise = mainPromise
|
1157
|
+
.then(res => Redirect(res))
|
1158
|
+
.then(res => CheckAndFixErr(res))
|
1159
|
+
//fix via login with defaut UA return WWW.facebook.com not m.facebook.com
|
1160
|
+
.then(function(res) {
|
1161
|
+
if (global.OnAutoLoginProcess) return res;
|
1162
|
+
else {
|
1163
|
+
let Regex_Via = /MPageLoadClientMetrics/gs; //default for normal account, can easily get region, without this u can't get region in some case but u can run normal
|
1164
|
+
if (!Regex_Via.test(res.body)) {
|
1165
|
+
//www.facebook.com
|
1166
|
+
globalOptions.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.2849.68";
|
1167
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
|
1168
|
+
}
|
1169
|
+
else return res
|
1170
|
+
}
|
1171
|
+
})
|
1172
|
+
.then(res => BypassAutomationNotification(res, jar, globalOptions, appState))
|
1173
|
+
.then(res => Redirect(res, global.OnAutoLoginProcess))
|
1174
|
+
.then(res => CheckAndFixErr(res, global.OnAutoLoginProcess))
|
1175
|
+
// .then(res => {
|
1176
|
+
// return utils.get('https://www.facebook.com/', jar, null, globalOptions, {}).then(utils.saveCookies(jar));
|
1177
|
+
// })
|
1178
|
+
// .then(function(res) {
|
1179
|
+
// let reg_old_web = /Switch Default Site/gs;
|
1180
|
+
// if (reg_old_web.test(res.body)) {
|
1181
|
+
// let Data_Resp = JSON.stringify(res.body);
|
1182
|
+
// const link = Data_Resp.split('settings/site')[1].split("\"")[0].replace('\\', '')
|
1183
|
+
// const redirect_link2 = redirect[1] + "settings/site" + utils.cleanHTML(link)
|
1184
|
+
// console.log(redirect_link2)
|
1185
|
+
// return utils.get("https://www.facebook.com/", jar, null, globalOptions).then(utils.saveCookies(jar)); // try ag
|
1186
|
+
// }
|
1187
|
+
// else return res;
|
1188
|
+
// })
|
1189
|
+
// .then(function(res) {
|
1190
|
+
// var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
1191
|
+
// redirect = reg.exec(res.body);
|
1192
|
+
// if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
|
1193
|
+
// return res;
|
1194
|
+
// })
|
1195
|
+
.then(function(res){
|
1196
|
+
var html = res.body,Obj = buildAPI(globalOptions, html, jar,bypass_region_err);
|
1197
|
+
ctx = Obj.ctx;
|
1198
|
+
api = Obj.api;
|
1199
|
+
return res;
|
1200
|
+
});
|
1201
|
+
if (globalOptions.pageID) {
|
1202
|
+
mainPromise = mainPromise
|
1203
|
+
.then(function() {
|
1204
|
+
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
1205
|
+
})
|
1206
|
+
.then(function(resData) {
|
1207
|
+
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
1208
|
+
url = url.substring(0, url.length - 1);
|
1209
|
+
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
1210
|
+
});
|
1211
|
+
}
|
1212
|
+
mainPromise
|
1213
|
+
.then(async() => {
|
1214
|
+
logger.Normal(getText(Language.LocalVersion,global.Fca.Version));
|
1215
|
+
logger.Normal(getText(Language.CountTime,global.Fca.Data.CountTime()))
|
1216
|
+
logger.Normal(Language.WishMessage[Math.floor(Math.random()*Language.WishMessage.length)]);
|
1217
|
+
require('./Extra/ExtraUptimeRobot')();
|
1218
|
+
callback(null, api);
|
1219
|
+
}).catch(function(/** @type {{ error: any; }} */e) {
|
1220
|
+
log.error("login", e.error || e);
|
1221
|
+
callback(e);
|
1222
|
+
});
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
|
1226
|
+
/**
|
1227
|
+
* It asks the user for their account and password, and then saves it to the database.
|
1228
|
+
*/
|
1229
|
+
|
1230
|
+
function setUserNameAndPassWord() {
|
1231
|
+
let rl = readline.createInterface({
|
1232
|
+
input: process.stdin,
|
1233
|
+
output: process.stdout
|
1234
|
+
});
|
1235
|
+
|
1236
|
+
console.clear();
|
1237
|
+
console.log(figlet.textSync('Horizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }));
|
1238
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Operating System: " + chalk.bold.red(os.type()));
|
1239
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Machine Version: " + chalk.bold.red(os.version()));
|
1240
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Fca Version: " + chalk.bold.red(global.Fca.Version) + '\n');
|
1241
|
+
try {
|
1242
|
+
rl.question(Language.TypeAccount, (Account) => {
|
1243
|
+
if (!Account.includes("@") && global.Fca.Require.utils.getType(parseInt(Account)) != "Number") return logger.Normal(Language.TypeAccountError, function () { process.exit(1) }); //Very Human
|
1244
|
+
else rl.question(Language.TypePassword, function (Password) {
|
1245
|
+
rl.close();
|
1246
|
+
try {
|
1247
|
+
Database().set("Account", Account);
|
1248
|
+
Database().set("Password", Password);
|
1249
|
+
}
|
1250
|
+
catch (e) {
|
1251
|
+
logger.Warning(Language.ErrDataBase);
|
1252
|
+
logger.Error();
|
1253
|
+
process.exit(0);
|
1254
|
+
}
|
1255
|
+
if (global.Fca.Require.Priyansh.ResetDataLogin) {
|
1256
|
+
global.Fca.Require.Priyansh.ResetDataLogin = false;
|
1257
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + '/PriyanshFca.json', JSON.stringify(global.Fca.Require.Priyansh, null, 4));
|
1258
|
+
}
|
1259
|
+
logger.Success(Language.SuccessSetData);
|
1260
|
+
process.exit(1);
|
1261
|
+
});
|
1262
|
+
})
|
1263
|
+
}
|
1264
|
+
catch (e) {
|
1265
|
+
logger.Error(e)
|
1266
|
+
}
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
/**
|
1270
|
+
* @param {{ email: any; password: any; appState: any; }} loginData
|
1271
|
+
* @param {{}} options
|
1272
|
+
* @param {(error: any, api: any) => any} callback
|
1273
|
+
*/
|
1274
|
+
|
1275
|
+
function login(loginData, options, callback) {
|
1276
|
+
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
1277
|
+
callback = options;
|
1278
|
+
options = {};
|
1279
|
+
}
|
1280
|
+
|
1281
|
+
var globalOptions = {
|
1282
|
+
selfListen: false,
|
1283
|
+
listenEvents: true,
|
1284
|
+
listenTyping: false,
|
1285
|
+
updatePresence: false,
|
1286
|
+
forceLogin: false,
|
1287
|
+
autoMarkDelivery: false,
|
1288
|
+
autoMarkRead: false,
|
1289
|
+
autoReconnect: true,
|
1290
|
+
logRecordSize: 100,
|
1291
|
+
online: false,
|
1292
|
+
emitReady: false,
|
1293
|
+
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"
|
1294
|
+
};
|
1295
|
+
|
1296
|
+
var prCallback = null;
|
1297
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
1298
|
+
var rejectFunc = null;
|
1299
|
+
var resolveFunc = null;
|
1300
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
1301
|
+
resolveFunc = resolve;
|
1302
|
+
rejectFunc = reject;
|
1303
|
+
});
|
1304
|
+
prCallback = function(error, api) {
|
1305
|
+
if (error) return rejectFunc(error);
|
1306
|
+
return resolveFunc(api);
|
1307
|
+
};
|
1308
|
+
callback = prCallback;
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
if (loginData.email && loginData.password) {
|
1312
|
+
setOptions(globalOptions, {
|
1313
|
+
logLevel: "silent",
|
1314
|
+
forceLogin: true,
|
1315
|
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
|
1316
|
+
});
|
1317
|
+
loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1318
|
+
}
|
1319
|
+
else if (loginData.appState) {
|
1320
|
+
setOptions(globalOptions, options);
|
1321
|
+
let All = (getAll()).filter(i => i.data !== null);
|
1322
|
+
All = All.filter(i => i.data.messageCount !== undefined)
|
1323
|
+
if (All.length >= 1) {
|
1324
|
+
deleteAll(All.map(obj => obj.data.threadID));
|
1325
|
+
}
|
1326
|
+
/*
|
1327
|
+
if (global.Fca.Require.FastConfig.Websocket_Extension.Status) {
|
1328
|
+
const UserName = Database().get('Ws_UserName');
|
1329
|
+
const PassWord = Database().get("Ws_PassWord");
|
1330
|
+
if (!UserName || !PassWord || global.Fca.Require.FastConfig.Websocket_Extension.ResetData) {
|
1331
|
+
const question = question => {
|
1332
|
+
const rl = readline.createInterface({
|
1333
|
+
input: process.stdin,
|
1334
|
+
output: process.stdout
|
1335
|
+
});
|
1336
|
+
var done,answ;
|
1337
|
+
rl.question(question, answer => {
|
1338
|
+
rl.close();
|
1339
|
+
answ = answer;
|
1340
|
+
done = true
|
1341
|
+
})
|
1342
|
+
deasync.loopWhile(function(){
|
1343
|
+
return !done;
|
1344
|
+
});
|
1345
|
+
return answ;
|
1346
|
+
};
|
1347
|
+
console.clear();
|
1348
|
+
console.log(figlet.textSync('Horizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }));
|
1349
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Operating System: " + chalk.bold.red(os.type()));
|
1350
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Machine Version: " + chalk.bold.red(os.version()));
|
1351
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Fca Version: " + chalk.bold.red(global.Fca.Version) + '\n');
|
1352
|
+
const UserName = question(Language.Ws_TypeUserName);
|
1353
|
+
const PassWord = question(Language.Ws_TypePassWord);
|
1354
|
+
if (!UserName || !PassWord) {
|
1355
|
+
logger.Warning("Dangerous action detected! Proceeding to automatically disable websocket_extension.");
|
1356
|
+
global.Fca.Require.FastConfig.Websocket_Extension.Status = false;
|
1357
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/PriyanshFca.json", JSON.stringify(global.Fca.Require.FastConfig, null, "\t"));
|
1358
|
+
}
|
1359
|
+
else {
|
1360
|
+
try {
|
1361
|
+
Database().set('Ws_UserName', UserName);
|
1362
|
+
Database().set('Ws_PassWord', PassWord);
|
1363
|
+
logger.Success(Language.Ws_Success, function() {
|
1364
|
+
const speakeasy = require('speakeasy');
|
1365
|
+
const secret = (speakeasy.generateSecret({ length: 20 }));
|
1366
|
+
logger.Warning(getText(Language.Ws_2Fa, secret.base32))
|
1367
|
+
Database().set('Ws_2Fa', secret.base32);
|
1368
|
+
if (global.Fca.Require.FastConfig.Websocket_Extension.ResetData) {
|
1369
|
+
global.Fca.Require.FastConfig.Websocket_Extension.ResetData = false;
|
1370
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + '/PriyanshFca.json', JSON.stringify(global.Fca.Require.FastConfig, null, 4));
|
1371
|
+
}
|
1372
|
+
question("Enter To Continue!");
|
1373
|
+
const ask = function() {
|
1374
|
+
const TFa_Check = question(Language.Ws_2Fa_Check)
|
1375
|
+
if (TFa_Check != speakeasy.totp({
|
1376
|
+
secret: secret.base32,
|
1377
|
+
encoding: 'base32'
|
1378
|
+
})) {
|
1379
|
+
logger.Warning("Mã Không Đúng vui lòng nhập lại(Incorrect code, please enter again.)")
|
1380
|
+
ask();
|
1381
|
+
}
|
1382
|
+
else {
|
1383
|
+
logger.Success("Success!");
|
1384
|
+
process.exit(1);
|
1385
|
+
}
|
1386
|
+
}
|
1387
|
+
return ask();
|
1388
|
+
});
|
1389
|
+
}
|
1390
|
+
catch (e) {
|
1391
|
+
console.log(e)
|
1392
|
+
logger.Warning("Error, auto turn off Websocket_extension");
|
1393
|
+
global.Fca.Require.FastConfig.Websocket_Extension.Status = false;
|
1394
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + "/PriyanshFca.json", JSON.stringify(global.Fca.Require.FastConfig, null, "\t"));
|
1395
|
+
process.exit(1);
|
1396
|
+
}
|
1397
|
+
}
|
1398
|
+
}
|
1399
|
+
}
|
1400
|
+
**/
|
1401
|
+
switch (global.Fca.Require.Priyansh.AutoLogin) {
|
1402
|
+
case true: {
|
1403
|
+
if (global.Fca.Require.Priyansh.ResetDataLogin) return setUserNameAndPassWord();
|
1404
|
+
else {
|
1405
|
+
try {
|
1406
|
+
const TempState = Database().get("TempState")
|
1407
|
+
if (TempState) {
|
1408
|
+
try {
|
1409
|
+
loginData.appState = JSON.parse(TempState);
|
1410
|
+
}
|
1411
|
+
catch (_) {
|
1412
|
+
loginData.appState = TempState;
|
1413
|
+
}
|
1414
|
+
Database().delete("TempState");
|
1415
|
+
}
|
1416
|
+
}
|
1417
|
+
catch (e) {
|
1418
|
+
console.log(e)
|
1419
|
+
Database().delete("TempState");
|
1420
|
+
logger.Warning(Language.ErrDataBase);
|
1421
|
+
logger.Error();
|
1422
|
+
process.exit(0);
|
1423
|
+
}
|
1424
|
+
try {
|
1425
|
+
if (Database().has('Account') && Database().has('Password')) return loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1426
|
+
else return setUserNameAndPassWord();
|
1427
|
+
}
|
1428
|
+
catch (e) {
|
1429
|
+
console.log(e)
|
1430
|
+
logger.Warning(Language.ErrDataBase);
|
1431
|
+
logger.Error();
|
1432
|
+
process.exit(0);
|
1433
|
+
}
|
1434
|
+
}
|
1435
|
+
}
|
1436
|
+
case false: {
|
1437
|
+
return loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1438
|
+
}
|
1439
|
+
}
|
1440
|
+
}
|
1441
|
+
return returnPromise;
|
1442
|
+
}
|
1443
|
+
|
1444
|
+
module.exports = login;
|