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