fb-anya 0.0.1-security → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fb-anya might be problematic. Click here for more details.
- package/.cache/replit/__replit_disk_meta.json +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/nix/env.json +1 -0
- package/.gitattributes +2 -0
- package/Extra/ExtraAddons.js +78 -0
- package/Extra/ExtraFindUID.js +60 -0
- package/Extra/ExtraGetThread.js +118 -0
- package/Extra/ExtraTranslate.js +62 -0
- package/Extra/ExtraUptimeRobot.js +59 -0
- package/Extra/Html/Classic/script.js +231 -0
- package/Extra/Html/Classic/style.css +149 -0
- package/Extra/PM2/ecosystem.config.js +23 -0
- package/Extra/Security/Index.js +174 -0
- package/Extra/Security/Step_1.js +15 -0
- package/Extra/Security/Step_2.js +23 -0
- package/Extra/Security/Step_3.js +23 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/Premium.js +85 -0
- package/Extra/Src/SecurityCheck.js +2 -0
- package/Func/AcceptAgreement.js +33 -0
- package/Func/ClearCache.js +63 -0
- package/Func/ReportV1.js +54 -0
- package/Language/index.json +176 -0
- package/OldSecurity.js +100 -0
- package/README.md +16 -3
- package/Settings/Database.js +21 -0
- package/Settings/Location.js +60 -0
- package/Settings/Location.json +24 -0
- package/Settings/Settings.js +60 -0
- package/StateCrypt.js +98 -0
- package/broadcast.js +38 -0
- package/index.js +1451 -0
- package/logger.js +65 -0
- package/package-anya/Database-Anya/index.js +358 -0
- package/package-anya/Database-Anya/package.json +63 -0
- package/package-anya/Database-Anya/readme.md +8 -0
- package/package-anya/anya-sp/README.md +11 -0
- package/package-anya/anya-sp/desktop.ini +2 -0
- package/package-anya/anya-sp/index.js +41 -0
- package/package-anya/anya-sp/logger.js +16 -0
- package/package-anya/anya-sp/package.json +54 -0
- package/package.json +84 -4
- package/src/K2IMG.js +8 -0
- package/src/Premium.js +30 -0
- package/src/Screenshot.js +77 -0
- package/src/T2S.js +8 -0
- package/src/addExternalModule.js +16 -0
- package/src/addUserToGroup.js +79 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +62 -0
- package/src/changeThreadEmoji.js +42 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +60 -0
- package/src/deleteMessage.js +45 -0
- package/src/deleteThread.js +43 -0
- package/src/desktop.ini +2 -0
- package/src/forwardAttachment.js +48 -0
- package/src/getAccessToken.js +32 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getMessage.js +80 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadInfo.js +346 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadMain.js +219 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +129 -0
- package/src/getUserInfoMain.js +65 -0
- package/src/getUserInfoV2.js +35 -0
- package/src/getUserInfoV3.js +63 -0
- package/src/getUserInfoV4.js +55 -0
- package/src/getUserInfoV5.js +61 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +49 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +41 -0
- package/src/listenMqtt.js +725 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +48 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +43 -0
- package/src/markAsSeen.js +51 -0
- package/src/muteThread.js +47 -0
- package/src/removeUserFromGroup.js +49 -0
- package/src/resolvePhotoUrl.js +37 -0
- package/src/searchForThread.js +43 -0
- package/src/sendMessage.js +334 -0
- package/src/sendTypingIndicator.js +80 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +74 -0
- package/src/threadColors.js +39 -0
- package/src/unfriend.js +43 -0
- package/src/unsendMessage.js +40 -0
- package/utils.js +1648 -0
package/index.js
ADDED
@@ -0,0 +1,1451 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Developers: @KanzuWakazaki - @HarryWakazaki
|
5
|
+
** A few words about developer appstate security.
|
6
|
+
*! Statement renouncing responsibility for the security of appstate encryption of the following operating systems: windows, Android, Linux operating systems,.. (maybe repl.it?),
|
7
|
+
*! because the above operating systems are private (except rep.it if the fraudster does not own your account or invite link to join).
|
8
|
+
*! If the intruder owns the computer, these private operating systems,the security of this fca cannot guarantee 100% of the time.
|
9
|
+
** If the grammar is wrong, please understand because I'm just a kid 🍵.
|
10
|
+
*/
|
11
|
+
|
12
|
+
/!-[ Max Cpu Speed ]-!/
|
13
|
+
|
14
|
+
process.env.UV_THREADPOOL_SIZE = require('os').cpus().length;
|
15
|
+
|
16
|
+
/!-[ Global Set ]-!/
|
17
|
+
|
18
|
+
global.Fca = new Object({
|
19
|
+
isThread: new Array(),
|
20
|
+
isUser: new Array(),
|
21
|
+
startTime: Date.now(),
|
22
|
+
Setting: new Map(),
|
23
|
+
Require: new Object({
|
24
|
+
fs: require("fs"),
|
25
|
+
Fetch: require('got'),
|
26
|
+
log: require("npmlog"),
|
27
|
+
utils: require("./utils"),
|
28
|
+
logger: require('./logger'),
|
29
|
+
Security: require("uuid-apikey"),
|
30
|
+
languageFile: require('./Language/index.json'),
|
31
|
+
Database: require("./package-anya/Database-Anya")
|
32
|
+
}),
|
33
|
+
getText: function(/** @type {any[]} */...Data) {
|
34
|
+
var Main = (Data.splice(0,1)).toString();
|
35
|
+
for (let i = 0; i < Data.length; i++) Main = Main.replace(RegExp(`%${i + 1}`, 'g'), Data[i]);
|
36
|
+
return Main;
|
37
|
+
},
|
38
|
+
Data: new Object({
|
39
|
+
ObjFastConfig: {
|
40
|
+
"Language": "en",
|
41
|
+
"PreKey": "",
|
42
|
+
"AutoUpdate": true,
|
43
|
+
"MainColor": "#9900FF",
|
44
|
+
"MainName": "[ FB-ANYA ]",
|
45
|
+
"Uptime": false,
|
46
|
+
"Config": "default",
|
47
|
+
"Login2Fa": false,
|
48
|
+
"AutoLogin": false,
|
49
|
+
"BroadCast": true,
|
50
|
+
"AuthString": "SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png Please remove this !, Recommend If You Using getUserInfoV2",
|
51
|
+
"EncryptFeature": true,
|
52
|
+
"ResetDataLogin": false,
|
53
|
+
"AutoRestartMinutes": 0,
|
54
|
+
"HTML": {
|
55
|
+
"HTML": true,
|
56
|
+
"UserName": "Guest",
|
57
|
+
"MusicLink": ""
|
58
|
+
}
|
59
|
+
},
|
60
|
+
CountTime: function() {
|
61
|
+
var fs = global.Fca.Require.fs;
|
62
|
+
if (fs.existsSync(__dirname + '/CountTime.json')) {
|
63
|
+
try {
|
64
|
+
var data = Number(fs.readFileSync(__dirname + '/CountTime.json', 'utf8')),
|
65
|
+
hours = Math.floor(data / (60 * 60));
|
66
|
+
}
|
67
|
+
catch (e) {
|
68
|
+
fs.writeFileSync(__dirname + '/CountTime.json', 0);
|
69
|
+
hours = 0;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
hours = 0;
|
74
|
+
}
|
75
|
+
return `${hours} Hours`;
|
76
|
+
}
|
77
|
+
}),
|
78
|
+
AutoLogin: async function () {
|
79
|
+
var Database = global.Fca.Require.Database;
|
80
|
+
var logger = global.Fca.Require.logger;
|
81
|
+
var Email = (await global.Fca.Require.Database.get('Account')).replace(RegExp('"', 'g'), ''); //hmm IDK
|
82
|
+
var PassWord = (await global.Fca.Require.Database.get('Password')).replace(RegExp('"', 'g'), '');
|
83
|
+
login({ email: Email, password: PassWord},async (error, api) => {
|
84
|
+
if (error) {
|
85
|
+
logger.Error(JSON.stringify(error,null,2), function() { logger.Error("AutoLogin Failed!", function() { process.exit(0); }) });
|
86
|
+
}
|
87
|
+
try {
|
88
|
+
await Database.set("TempState", api.getAppState());
|
89
|
+
}
|
90
|
+
catch(e) {
|
91
|
+
logger.Warning(global.Fca.Require.Language.Index.ErrDatabase);
|
92
|
+
logger.Error();
|
93
|
+
process.exit(0);
|
94
|
+
}
|
95
|
+
process.exit(1);
|
96
|
+
});
|
97
|
+
}
|
98
|
+
});
|
99
|
+
|
100
|
+
/!-[ Check File To Run Process ]-!/
|
101
|
+
|
102
|
+
let Boolean_Fca = ["AutoUpdate","Uptime","BroadCast","EncryptFeature","AutoLogin","ResetDataLogin","Login2Fa"];
|
103
|
+
let String_Fca = ["MainName","PreKey","Language","AuthString","Config"]
|
104
|
+
let Number_Fca = ["AutoRestartMinutes"];
|
105
|
+
let All_Variable = Boolean_Fca.concat(String_Fca,Number_Fca);
|
106
|
+
|
107
|
+
try {
|
108
|
+
if (!global.Fca.Require.fs.existsSync('./FastConfigFca.json')) {
|
109
|
+
global.Fca.Require.fs.writeFileSync("./FastConfigFca.json", JSON.stringify(global.Fca.Data.ObjFastConfig, null, "\t"));
|
110
|
+
process.exit(1);
|
111
|
+
}
|
112
|
+
|
113
|
+
try {
|
114
|
+
var DataLanguageSetting = require("../../FastConfigFca.json");
|
115
|
+
}
|
116
|
+
catch (e) {
|
117
|
+
global.Fca.Require.logger.Error('Detect Your FastConfigFca Settings Invalid!, Carry out default restoration');
|
118
|
+
global.Fca.Require.fs.writeFileSync("./FastConfigFca.json", JSON.stringify(global.Fca.Data.ObjFastConfig, null, "\t"));
|
119
|
+
process.exit(1)
|
120
|
+
}
|
121
|
+
if (global.Fca.Require.fs.existsSync('./FastConfigFca.json')) {
|
122
|
+
try {
|
123
|
+
if (!DataLanguageSetting.Config || global.Fca.Require.utils.getType(DataLanguageSetting.Config) != 'String') {
|
124
|
+
DataLanguageSetting.Config = "default"
|
125
|
+
global.Fca.Require.fs.writeFileSync("./FastConfigFca.json", JSON.stringify(DataLanguageSetting, null, "\t"));
|
126
|
+
}
|
127
|
+
}
|
128
|
+
catch (e) {
|
129
|
+
console.log(e);
|
130
|
+
}
|
131
|
+
if (!global.Fca.Require.languageFile.some((/** @type {{ Language: string; }} */i) => i.Language == DataLanguageSetting.Language)) {
|
132
|
+
global.Fca.Require.logger.Warning("Not Support Language: " + DataLanguageSetting.Language + " Only 'en' and 'vi'");
|
133
|
+
process.exit(0);
|
134
|
+
}
|
135
|
+
var Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == DataLanguageSetting.Language).Folder.Index;
|
136
|
+
global.Fca.Require.Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == DataLanguageSetting.Language).Folder;
|
137
|
+
} else process.exit(1);
|
138
|
+
for (let i in DataLanguageSetting) {
|
139
|
+
if (Boolean_Fca.includes(i)) {
|
140
|
+
if (global.Fca.Require.utils.getType(DataLanguageSetting[i]) != "Boolean") return logger.Error(i + " Is Not A Boolean, Need To Be true Or false !", function() { process.exit(0) });
|
141
|
+
else continue;
|
142
|
+
}
|
143
|
+
else if (String_Fca.includes(i)) {
|
144
|
+
if (global.Fca.Require.utils.getType(DataLanguageSetting[i]) != "String") return logger.Error(i + " Is Not A String, Need To Be String!", function() { process.exit(0) });
|
145
|
+
else continue;
|
146
|
+
}
|
147
|
+
else if (Number_Fca.includes(i)) {
|
148
|
+
if (global.Fca.Require.utils.getType(DataLanguageSetting[i]) != "Number") return logger.Error(i + " Is Not A Number, Need To Be Number !", function() { process.exit(0) });
|
149
|
+
else continue;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
for (let i of All_Variable) {
|
153
|
+
if (!DataLanguageSetting[All_Variable[i]] == undefined) {
|
154
|
+
DataLanguageSetting[All_Variable[i]] = global.Fca.Data.ObjFastConfig[All_Variable[i]];
|
155
|
+
global.Fca.Require.fs.writeFileSync("./FastConfigFca.json", JSON.stringify(DataLanguageSetting, null, "\t"));
|
156
|
+
}
|
157
|
+
else continue;
|
158
|
+
}
|
159
|
+
global.Fca.Require.FastConfig = DataLanguageSetting;
|
160
|
+
}
|
161
|
+
catch (e) {
|
162
|
+
console.log(e);
|
163
|
+
global.Fca.Require.logger.Error();
|
164
|
+
}
|
165
|
+
|
166
|
+
/!-[ Require All Package Need Use ]-!/
|
167
|
+
|
168
|
+
var utils = global.Fca.Require.utils,
|
169
|
+
logger = global.Fca.Require.logger,
|
170
|
+
fs = global.Fca.Require.fs,
|
171
|
+
getText = global.Fca.getText,
|
172
|
+
log = global.Fca.Require.log,
|
173
|
+
Fetch = global.Fca.Require.Fetch,
|
174
|
+
express = require("express")(),
|
175
|
+
{ join } = require('path'),
|
176
|
+
cheerio = require("cheerio"),
|
177
|
+
StateCrypt = require('./OldSecurity'),
|
178
|
+
{ readFileSync } = require('fs-extra'),
|
179
|
+
Database = require("./package-anya/Database-Anya"),
|
180
|
+
readline = require("readline"),
|
181
|
+
chalk = require("chalk"),
|
182
|
+
figlet = require("figlet"),
|
183
|
+
os = require("os"),
|
184
|
+
Security = require("./Extra/Security/Index");
|
185
|
+
|
186
|
+
/!-[ Set Variable For Process ]-!/
|
187
|
+
|
188
|
+
log.maxRecordSize = 100;
|
189
|
+
var checkVerified = null;
|
190
|
+
var Boolean_Option = ['online','selfListen','listenEvents','updatePresence','forceLogin','autoMarkDelivery','autoMarkRead','listenTyping','autoReconnect','emitReady'];
|
191
|
+
|
192
|
+
/!-[ Set And Check Template HTML ]-!/
|
193
|
+
|
194
|
+
var css = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'style.css'));
|
195
|
+
var js = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'script.js'));
|
196
|
+
|
197
|
+
/!-[ Function Generate HTML Template ]-!/
|
198
|
+
|
199
|
+
/**
|
200
|
+
* It returns a string of HTML code.
|
201
|
+
* @param UserName - The username of the user
|
202
|
+
* @param Type - The type of user, either "Free" or "Premium"
|
203
|
+
* @param link - The link to the music you want to play
|
204
|
+
* @returns A HTML file
|
205
|
+
*/
|
206
|
+
|
207
|
+
function ClassicHTML(UserName,Type,link) {
|
208
|
+
return `<!DOCTYPE html>
|
209
|
+
<html lang="en">
|
210
|
+
<head>
|
211
|
+
<title>Choru TikTokers</title>
|
212
|
+
<link rel="shortcut icon" href="https://i.imgur.com/74HcgfV.jpeg">
|
213
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
214
|
+
|
215
|
+
<link rel="stylesheet" href="../CHORUYTAPI/css/owl.carousel.min.css" />
|
216
|
+
<link rel="stylesheet" href="../CHORUYTAPI/css/superslides.css" />
|
217
|
+
<link
|
218
|
+
rel="stylesheet"
|
219
|
+
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
220
|
+
/>
|
221
|
+
<link
|
222
|
+
rel="stylesheet"
|
223
|
+
href="https://use.fontawesome.com/releases/v5.10.2/css/all.css"
|
224
|
+
/>
|
225
|
+
<link
|
226
|
+
rel="stylesheet"
|
227
|
+
href="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css"
|
228
|
+
/>
|
229
|
+
<link rel="stylesheet" href="style.css" />
|
230
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
231
|
+
</head>
|
232
|
+
|
233
|
+
<body>
|
234
|
+
<!-- Navbar -->
|
235
|
+
<nav id="navigation" class="navbar navbar-expand-lg">
|
236
|
+
<a class="navbar-brand" href="#">Choru TikTokers Api</a>
|
237
|
+
|
238
|
+
<button
|
239
|
+
class="navbar-toggler"
|
240
|
+
type="button"
|
241
|
+
data-toggle="collapse"
|
242
|
+
data-target="#navbarNav"
|
243
|
+
aria-controls="navbarNav"
|
244
|
+
aria-expanded="false"
|
245
|
+
aria-label="Toggle navigation"
|
246
|
+
>
|
247
|
+
<span class="navbar-toggler-icon"></span>
|
248
|
+
</button>
|
249
|
+
|
250
|
+
<div class="collapse navbar-collapse" id="navbarNav">
|
251
|
+
<ul class="navbar-nav">
|
252
|
+
<li class="nav-item active">
|
253
|
+
<a class="nav-link" href="https://github.com/ChoruTiktokers182"
|
254
|
+
>github<span class="sr-only"></span
|
255
|
+
></a>
|
256
|
+
</li>
|
257
|
+
<li class="nav-item">
|
258
|
+
<a class="nav-link" href="https://www.facebook.com/profile.php?id=100084149373287&mibextid=ZbWKwL">facebook</a>
|
259
|
+
</li>
|
260
|
+
<li class="nav-item">
|
261
|
+
<a class="nav-link" href="https://replit.com/@VEGITO-OFFICIAL">replit vegito</a>
|
262
|
+
</li>
|
263
|
+
<li class="nav-item">
|
264
|
+
<a class="nav-link" href="https://replit.com/@Anya-official">replit anya</a>
|
265
|
+
</li>
|
266
|
+
<li class="nav-item">
|
267
|
+
<a class="nav-link" href="../Choru/Choru.html">api</a>
|
268
|
+
</li>
|
269
|
+
</ul>
|
270
|
+
</div>
|
271
|
+
</nav>
|
272
|
+
<!-- Stats -->
|
273
|
+
<div id="stats" class="statsSection section">
|
274
|
+
<div class="container">
|
275
|
+
<div class="row">
|
276
|
+
<div class="col-md-3 col-sm-6">
|
277
|
+
<div class="squareItem">
|
278
|
+
<div class="squareInnerContainer">
|
279
|
+
<div class="squareIcon">
|
280
|
+
<i class="fas fa-globe"></i>
|
281
|
+
</div>
|
282
|
+
<div class="squareContent">
|
283
|
+
<h2 class="counter">3367</h2>
|
284
|
+
<h3>total request</h3>
|
285
|
+
</div>
|
286
|
+
</div>
|
287
|
+
</div>
|
288
|
+
</div>
|
289
|
+
|
290
|
+
<div class="col-md-3 col-sm-6">
|
291
|
+
<div class="squareItem">
|
292
|
+
<div class="squareInnerContainer">
|
293
|
+
<div class="squareIcon">
|
294
|
+
<i class="fas fa-address-book"></i>
|
295
|
+
</div>
|
296
|
+
<div class="squareContent">
|
297
|
+
<h2 class="counter">567</h2>
|
298
|
+
<h3>total users</h3>
|
299
|
+
</div>
|
300
|
+
</div>
|
301
|
+
</div>
|
302
|
+
</div>
|
303
|
+
|
304
|
+
<div class="col-md-3 col-sm-6">
|
305
|
+
<div class="squareItem">
|
306
|
+
|
307
|
+
</div>
|
308
|
+
</div>
|
309
|
+
</div>
|
310
|
+
</div>
|
311
|
+
|
312
|
+
<!-- Contact -->
|
313
|
+
<div id="contact" class="contactSection section">
|
314
|
+
<div class="col-md-12 text-center">
|
315
|
+
<h3 class="subHeading">request now</h3>
|
316
|
+
<p>free public api that can be used for your project </p>
|
317
|
+
<a href="https://choruyt.okslangako.repl.co" class="contactButton"
|
318
|
+
>open api</a
|
319
|
+
>
|
320
|
+
</div>
|
321
|
+
</div>
|
322
|
+
|
323
|
+
<!-- Copyright -->
|
324
|
+
|
325
|
+
<div class="copyrightSection">
|
326
|
+
<div class="col-md-12 text-center">
|
327
|
+
<p>
|
328
|
+
Choru TikTokers
|
329
|
+
</p>
|
330
|
+
</div>
|
331
|
+
</div>
|
332
|
+
|
333
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/countup.js/1.8.2/countUp.min.js"></script>
|
334
|
+
<script src="../CHORUYTAPI/js/countUp-jquery.js"></script>
|
335
|
+
<script src="../CHORUYTAPI/js/jquery.superslides.min.js"></script>
|
336
|
+
<script src="../CHORUYTAPI/js/owl.carousel.min.js"></script>
|
337
|
+
<script src="../CHORUYTAPI/js/jquery.easypiechart.min.js"></script>
|
338
|
+
<script src="../CHORUYTAPI/js/typed.min.js"></script>
|
339
|
+
<script
|
340
|
+
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
|
341
|
+
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
342
|
+
crossorigin="anonymous"
|
343
|
+
></script>
|
344
|
+
<script
|
345
|
+
src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
|
346
|
+
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
|
347
|
+
crossorigin="anonymous"
|
348
|
+
></script>
|
349
|
+
<script
|
350
|
+
type="text/javascript"
|
351
|
+
src="https://unpkg.com/isotope-layout@3.0.6/dist/isotope.pkgd.min.js"
|
352
|
+
></script>
|
353
|
+
<script src="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>
|
354
|
+
<script src="../CHORUYTAPI/js/script.js"></script>
|
355
|
+
</body>
|
356
|
+
</html>`
|
357
|
+
//lazy to change
|
358
|
+
}
|
359
|
+
|
360
|
+
/!-[ Stating Http Infomation ]-!/
|
361
|
+
|
362
|
+
express.set('DFP', (process.env.PORT || process.env.port || 1932));
|
363
|
+
express.use(function(req, res, next) {
|
364
|
+
switch (req.url.split('?')[0]) {
|
365
|
+
case '/script.js': {
|
366
|
+
res.writeHead(200, { 'Content-Type': 'text/javascript' });
|
367
|
+
res.write(js);
|
368
|
+
break;
|
369
|
+
}
|
370
|
+
case '/style.css': {
|
371
|
+
res.writeHead(200, { 'Content-Type': 'text/css' });
|
372
|
+
res.write(css);
|
373
|
+
break;
|
374
|
+
}
|
375
|
+
// case '/History': {
|
376
|
+
// if (req.query.PassWord == process.env.REPL_OWNER) {
|
377
|
+
// res.writeHead(200, { 'Content-Type': 'application/json charset=utf-8' });
|
378
|
+
// res.write(JSON.stringify(console.history,null,2),'utf8');
|
379
|
+
// res.end();
|
380
|
+
// }
|
381
|
+
// else res.json({
|
382
|
+
// Status: false,
|
383
|
+
// Error: "Thiếu Params ?PassWord=PassWordCuaBan =))"
|
384
|
+
// });
|
385
|
+
// break;
|
386
|
+
// }
|
387
|
+
default: {
|
388
|
+
res.writeHead(200, "OK", { "Content-Type": "text/html" });
|
389
|
+
res.write(ClassicHTML(global.Fca.Require.FastConfig.HTML.UserName, global.Fca.Data.PremText.includes("Premium") ? "Premium": "Free", global.Fca.Require.FastConfig.HTML.MusicLink));
|
390
|
+
}
|
391
|
+
}
|
392
|
+
res.end();
|
393
|
+
})
|
394
|
+
|
395
|
+
global.Fca.Require.Web = express;
|
396
|
+
|
397
|
+
/!-[ Function setOptions ]-!/
|
398
|
+
|
399
|
+
/**
|
400
|
+
* @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
|
401
|
+
* @param {{ [x: string]: any; logLevel?: any; forceLogin?: boolean; userAgent?: any; pauseLog?: any; logRecordSize?: any; pageID?: any; proxy?: any; }} options
|
402
|
+
*/
|
403
|
+
|
404
|
+
function setOptions(globalOptions, options) {
|
405
|
+
Object.keys(options).map(function(key) {
|
406
|
+
switch (Boolean_Option.includes(key)) {
|
407
|
+
case true: {
|
408
|
+
globalOptions[key] = Boolean(options[key]);
|
409
|
+
break;
|
410
|
+
}
|
411
|
+
case false: {
|
412
|
+
switch (key) {
|
413
|
+
case 'pauseLog': {
|
414
|
+
if (options.pauseLog) log.pause();
|
415
|
+
else log.resume();
|
416
|
+
break;
|
417
|
+
}
|
418
|
+
case 'logLevel': {
|
419
|
+
log.level = options.logLevel;
|
420
|
+
globalOptions.logLevel = options.logLevel;
|
421
|
+
break;
|
422
|
+
}
|
423
|
+
case 'logRecordSize': {
|
424
|
+
log.maxRecordSize = options.logRecordSize;
|
425
|
+
globalOptions.logRecordSize = options.logRecordSize;
|
426
|
+
break;
|
427
|
+
}
|
428
|
+
case 'pageID': {
|
429
|
+
globalOptions.pageID = options.pageID.toString();
|
430
|
+
break;
|
431
|
+
}
|
432
|
+
case 'userAgent': {
|
433
|
+
globalOptions.userAgent = (options.userAgent || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36');
|
434
|
+
break;
|
435
|
+
}
|
436
|
+
case 'proxy': {
|
437
|
+
if (typeof options.proxy != "string") {
|
438
|
+
delete globalOptions.proxy;
|
439
|
+
utils.setProxy();
|
440
|
+
} else {
|
441
|
+
globalOptions.proxy = options.proxy;
|
442
|
+
utils.setProxy(globalOptions.proxy);
|
443
|
+
}
|
444
|
+
break;
|
445
|
+
}
|
446
|
+
default: {
|
447
|
+
log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
|
448
|
+
break;
|
449
|
+
}
|
450
|
+
}
|
451
|
+
break;
|
452
|
+
}
|
453
|
+
}
|
454
|
+
});
|
455
|
+
}
|
456
|
+
|
457
|
+
/!-[ Function BuildAPI ]-!/
|
458
|
+
|
459
|
+
/**
|
460
|
+
* @param {any} globalOptions
|
461
|
+
* @param {string} html
|
462
|
+
* @param {{ getCookies: (arg0: string) => any[]; }} jar
|
463
|
+
*/
|
464
|
+
|
465
|
+
function buildAPI(globalOptions, html, jar) {
|
466
|
+
var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(/** @type {{ cookieString: () => string; }} */val) { return val.cookieString().split("=")[0] === "c_user"; });
|
467
|
+
|
468
|
+
if (maybeCookie.length === 0) {
|
469
|
+
switch (global.Fca.Require.FastConfig.AutoLogin) {
|
470
|
+
case true: {
|
471
|
+
global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.AutoLogin, function() {
|
472
|
+
return global.Fca.AutoLogin();
|
473
|
+
});
|
474
|
+
break;
|
475
|
+
}
|
476
|
+
case false: {
|
477
|
+
throw { error: global.Fca.Require.Language.Index.ErrAppState };
|
478
|
+
|
479
|
+
}
|
480
|
+
}
|
481
|
+
}
|
482
|
+
|
483
|
+
if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
|
484
|
+
|
485
|
+
var userID = maybeCookie[0].cookieString().split("=")[1].toString();
|
486
|
+
process.env['UID'] = logger.Normal(getText(Language.UID,userID), userID);
|
487
|
+
|
488
|
+
try {
|
489
|
+
clearInterval(checkVerified);
|
490
|
+
} catch (e) {
|
491
|
+
console.log(e);
|
492
|
+
}
|
493
|
+
|
494
|
+
var clientID = (Math.random() * 2147483648 | 0).toString(16);
|
495
|
+
|
496
|
+
var CHECK_MQTT = {
|
497
|
+
oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
|
498
|
+
newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
|
499
|
+
legacyFBMQTTMatch: html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/)
|
500
|
+
}
|
501
|
+
|
502
|
+
let Slot = Object.keys(CHECK_MQTT);
|
503
|
+
|
504
|
+
var mqttEndpoint,region,irisSeqID;
|
505
|
+
Object.keys(CHECK_MQTT).map(function(MQTT) {
|
506
|
+
if (CHECK_MQTT[MQTT] && !region) {
|
507
|
+
switch (Slot.indexOf(MQTT)) {
|
508
|
+
case 0: {
|
509
|
+
irisSeqID = CHECK_MQTT[MQTT][1];
|
510
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2];
|
511
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
512
|
+
return;
|
513
|
+
}
|
514
|
+
case 1: {
|
515
|
+
irisSeqID = CHECK_MQTT[MQTT][2];
|
516
|
+
mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
|
517
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
518
|
+
return;
|
519
|
+
}
|
520
|
+
case 2: {
|
521
|
+
mqttEndpoint = CHECK_MQTT[MQTT][4];
|
522
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
523
|
+
return;
|
524
|
+
}
|
525
|
+
}
|
526
|
+
return;
|
527
|
+
}
|
528
|
+
});
|
529
|
+
|
530
|
+
var ctx = {
|
531
|
+
userID: userID,
|
532
|
+
jar: jar,
|
533
|
+
clientID: clientID,
|
534
|
+
globalOptions: globalOptions,
|
535
|
+
loggedIn: true,
|
536
|
+
access_token: 'NONE',
|
537
|
+
clientMutationId: 0,
|
538
|
+
mqttClient: undefined,
|
539
|
+
lastSeqId: irisSeqID,
|
540
|
+
syncToken: undefined,
|
541
|
+
mqttEndpoint: mqttEndpoint,
|
542
|
+
region: region,
|
543
|
+
firstListen: true
|
544
|
+
};
|
545
|
+
|
546
|
+
var api = {
|
547
|
+
setOptions: setOptions.bind(null, globalOptions),
|
548
|
+
getAppState: function getAppState() {
|
549
|
+
return utils.getAppState(jar);
|
550
|
+
}
|
551
|
+
};
|
552
|
+
|
553
|
+
if (region && mqttEndpoint) {
|
554
|
+
//do sth
|
555
|
+
}
|
556
|
+
else {
|
557
|
+
log.warn("login", getText(Language.NoAreaData));
|
558
|
+
api["htmlData"] = html;
|
559
|
+
}
|
560
|
+
|
561
|
+
var defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
562
|
+
|
563
|
+
fs.readdirSync(__dirname + "/src").filter((/** @type {string} */File) => File.endsWith(".js") && !File.includes('Dev_')).map((/** @type {string} */File) => api[File.split('.').slice(0, -1).join('.')] = require('./src/' + File)(defaultFuncs, api, ctx));
|
564
|
+
|
565
|
+
return {
|
566
|
+
ctx,
|
567
|
+
defaultFuncs,
|
568
|
+
api
|
569
|
+
};
|
570
|
+
}
|
571
|
+
|
572
|
+
/!-[ Function makeLogin ]-!/
|
573
|
+
|
574
|
+
/**
|
575
|
+
* @param {{ setCookie: (arg0: any, arg1: string) => void; }} jar
|
576
|
+
* @param {any} email
|
577
|
+
* @param {any} password
|
578
|
+
* @param {{ forceLogin: any; }} loginOptions
|
579
|
+
* @param {(err: any, api: any) => any} callback
|
580
|
+
* @param {any} prCallback
|
581
|
+
*/
|
582
|
+
|
583
|
+
function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
584
|
+
return function(/** @type {{ body: any; }} */res) {
|
585
|
+
var html = res.body,$ = cheerio.load(html),arr = [];
|
586
|
+
|
587
|
+
$("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
588
|
+
|
589
|
+
arr = arr.filter(function(v) {
|
590
|
+
return v.val && v.val.length;
|
591
|
+
});
|
592
|
+
|
593
|
+
var form = utils.arrToForm(arr);
|
594
|
+
form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
595
|
+
form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
|
596
|
+
form.email = email;
|
597
|
+
form.pass = password;
|
598
|
+
form.default_persistent = '0';
|
599
|
+
form.locale = 'en_US';
|
600
|
+
form.timezone = '240';
|
601
|
+
form.lgnjs = ~~(Date.now() / 1000);
|
602
|
+
|
603
|
+
html.split("\"_js_").slice(1).map((/** @type {any} */val) => {
|
604
|
+
jar.setCookie(utils.formatCookie(JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]"), "facebook"),"https://www.facebook.com")
|
605
|
+
});
|
606
|
+
|
607
|
+
logger.Normal(Language.OnLogin);
|
608
|
+
return utils
|
609
|
+
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
610
|
+
.then(utils.saveCookies(jar))
|
611
|
+
.then(function(/** @type {{ headers: any; }} */res) {
|
612
|
+
var headers = res.headers;
|
613
|
+
if (!headers.location) throw { error: Language.InvaildAccount };
|
614
|
+
|
615
|
+
// This means the account has login approvals turned on.
|
616
|
+
if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
|
617
|
+
logger.Warning(Language.TwoAuth);
|
618
|
+
var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
|
619
|
+
|
620
|
+
return utils
|
621
|
+
.get(headers.location, jar, null, loginOptions)
|
622
|
+
.then(utils.saveCookies(jar))
|
623
|
+
.then(async function(/** @type {{ body: any; }} */res) {
|
624
|
+
if (!await Database.get('ThroughAcc')) {
|
625
|
+
await Database.set('ThroughAcc', email);
|
626
|
+
}
|
627
|
+
else {
|
628
|
+
if (String((await Database.get('ThroughAcc'))).replace(RegExp('"','g'), '') != String(email).replace(RegExp('"','g'), '')) {
|
629
|
+
await Database.set('ThroughAcc', email);
|
630
|
+
if (await Database.get('Through2Fa')) {
|
631
|
+
await Database.delete('Through2Fa');
|
632
|
+
}
|
633
|
+
}
|
634
|
+
}
|
635
|
+
var html = res.body,$ = cheerio.load(html), arr = [];
|
636
|
+
$("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
637
|
+
arr = arr.filter(v => { return v.val && v.val.length });
|
638
|
+
var form = utils.arrToForm(arr);
|
639
|
+
if (html.indexOf("checkpoint/?next") > -1) {
|
640
|
+
setTimeout(() => {
|
641
|
+
checkVerified = setInterval((_form) => {}, 5000, {
|
642
|
+
fb_dtsg: form.fb_dtsg,
|
643
|
+
jazoest: form.jazoest,
|
644
|
+
dpr: 1
|
645
|
+
});
|
646
|
+
}, 2500);
|
647
|
+
switch (global.Fca.Require.FastConfig.Login2Fa) {
|
648
|
+
case true: {
|
649
|
+
try {
|
650
|
+
const question = question => {
|
651
|
+
const rl = readline.createInterface({
|
652
|
+
input: process.stdin,
|
653
|
+
output: process.stdout
|
654
|
+
});
|
655
|
+
return new Promise(resolve => {
|
656
|
+
rl.question(question, answer => {
|
657
|
+
rl.close();
|
658
|
+
return resolve(answer);
|
659
|
+
});
|
660
|
+
});
|
661
|
+
};
|
662
|
+
async function EnterSecurityCode() {
|
663
|
+
try {
|
664
|
+
var Through2Fa = await Database.get('Through2Fa');
|
665
|
+
if (Through2Fa) {
|
666
|
+
Through2Fa.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
|
667
|
+
let str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
668
|
+
jar.setCookie(str, "http://" + c.domain);
|
669
|
+
})
|
670
|
+
var from2 = utils.arrToForm(arr);
|
671
|
+
from2.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
672
|
+
from2.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
|
673
|
+
from2.email = email;
|
674
|
+
from2.pass = password;
|
675
|
+
from2.default_persistent = '0';
|
676
|
+
from2.locale = 'en_US';
|
677
|
+
from2.timezone = '240';
|
678
|
+
from2.lgnjs = ~~(Date.now() / 1000);
|
679
|
+
return utils
|
680
|
+
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, from2, loginOptions)
|
681
|
+
.then(utils.saveCookies(jar))
|
682
|
+
.then(function(/** @type {{ headers: any; }} */res) {
|
683
|
+
var headers = res.headers;
|
684
|
+
if (!headers['set-cookie'][0].includes('deleted')) {
|
685
|
+
logger.Warning(Language.ErrThroughCookies, async function() {
|
686
|
+
await Database.delete('Through2Fa');
|
687
|
+
});
|
688
|
+
process.exit(1);
|
689
|
+
}
|
690
|
+
if (headers.location && headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
|
691
|
+
return utils
|
692
|
+
.get(headers.location, jar, null, loginOptions)
|
693
|
+
.then(utils.saveCookies(jar))
|
694
|
+
.then(function(/** @type {{ body: any; }} */res) {
|
695
|
+
var html = res.body,$ = cheerio.load(html), arr = [];
|
696
|
+
$("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
697
|
+
arr = arr.filter(v => { return v.val && v.val.length });
|
698
|
+
var from2 = utils.arrToForm(arr);
|
699
|
+
|
700
|
+
if (html.indexOf("checkpoint/?next") > -1) {
|
701
|
+
setTimeout(() => {
|
702
|
+
checkVerified = setInterval((_form) => {}, 5000, {
|
703
|
+
fb_dtsg: from2.fb_dtsg,
|
704
|
+
jazoest: from2.jazoest,
|
705
|
+
dpr: 1
|
706
|
+
});
|
707
|
+
}, 2500);
|
708
|
+
if (!res.headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
|
709
|
+
try {
|
710
|
+
delete from2.name_action_selected;
|
711
|
+
from2['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
712
|
+
return utils
|
713
|
+
.post(nextURL, jar, from2, loginOptions)
|
714
|
+
.then(utils.saveCookies(jar))
|
715
|
+
.then(function() {
|
716
|
+
from2['submit[This was me]'] = "This was me";
|
717
|
+
return utils.post(nextURL, jar, from2, loginOptions).then(utils.saveCookies(jar));
|
718
|
+
})
|
719
|
+
.then(function() {
|
720
|
+
delete from2['submit[This was me]'];
|
721
|
+
from2.name_action_selected = 'save_device';
|
722
|
+
from2['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
723
|
+
return utils.post(nextURL, jar, from2, loginOptions).then(utils.saveCookies(jar));
|
724
|
+
})
|
725
|
+
.then(async function(/** @type {{ headers: any; body: string | string[]; }} */res) {
|
726
|
+
var headers = res.headers;
|
727
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: "wtf ??:D" };
|
728
|
+
var appState = utils.getAppState(jar,false);
|
729
|
+
await Database.set('Through2Fa', appState);
|
730
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
731
|
+
})
|
732
|
+
.catch((/** @type {any} */e) => callback(e));
|
733
|
+
}
|
734
|
+
catch (e) {
|
735
|
+
console.log(e)
|
736
|
+
}
|
737
|
+
}
|
738
|
+
}
|
739
|
+
})
|
740
|
+
}
|
741
|
+
return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
|
742
|
+
}).catch((/** @type {any} */e) => console.log(e));
|
743
|
+
}
|
744
|
+
}
|
745
|
+
catch (e) {
|
746
|
+
await Database.delete('Through2Fa');
|
747
|
+
}
|
748
|
+
var code = await question(Language.EnterSecurityCode);
|
749
|
+
try {
|
750
|
+
form.approvals_code = code;
|
751
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
752
|
+
var prResolve,prReject;
|
753
|
+
var rtPromise = new Promise((resolve, reject) => { prResolve = resolve; prReject = reject; });
|
754
|
+
if (typeof code == "string") { //always strings
|
755
|
+
utils
|
756
|
+
.post(nextURL, jar, form, loginOptions)
|
757
|
+
.then(utils.saveCookies(jar))
|
758
|
+
.then(function(/** @type {{ body: string | Buffer; }} */res) {
|
759
|
+
var $ = cheerio.load(res.body);
|
760
|
+
var error = $("#approvals_code").parent().attr("data-xui-error");
|
761
|
+
if (error) {
|
762
|
+
logger.Warning(Language.InvaildTwoAuthCode,function() { EnterSecurityCode(); }); //bruh loop
|
763
|
+
};
|
764
|
+
})
|
765
|
+
.then(function() {
|
766
|
+
delete form.no_fido;delete form.approvals_code;
|
767
|
+
form.name_action_selected = 'save_device'; //'save_device' || 'dont_save;
|
768
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
769
|
+
})
|
770
|
+
.then(async function(/** @type {{ headers: any; body: string | string[]; }} */res) {
|
771
|
+
var headers = res.headers;
|
772
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
|
773
|
+
try {
|
774
|
+
delete form.name_action_selected;
|
775
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
776
|
+
return utils
|
777
|
+
.post(nextURL, jar, form, loginOptions)
|
778
|
+
.then(utils.saveCookies(jar))
|
779
|
+
.then(function() {
|
780
|
+
form['submit[This was me]'] = "This was me";
|
781
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
782
|
+
})
|
783
|
+
.then(function() {
|
784
|
+
delete form['submit[This was me]'];
|
785
|
+
form.name_action_selected = 'save_device';
|
786
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
787
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
788
|
+
})
|
789
|
+
.then(async function(/** @type {{ headers: any; body: string | string[]; }} */res) {
|
790
|
+
var headers = res.headers;
|
791
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: "wtf ??:D" };
|
792
|
+
var appState = utils.getAppState(jar,false);
|
793
|
+
await Database.set('Through2Fa', appState);
|
794
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
795
|
+
})
|
796
|
+
.catch((/** @type {any} */e) => callback(e));
|
797
|
+
}
|
798
|
+
catch (e) {
|
799
|
+
console.log(e)
|
800
|
+
}
|
801
|
+
}
|
802
|
+
var appState = utils.getAppState(jar,false);
|
803
|
+
if (callback === prCallback) {
|
804
|
+
callback = function(/** @type {any} */err, /** @type {any} */api) {
|
805
|
+
if (err) return prReject(err);
|
806
|
+
return prResolve(api);
|
807
|
+
};
|
808
|
+
}
|
809
|
+
await Database.set('Through2Fa', appState);
|
810
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
811
|
+
})
|
812
|
+
.catch(function(/** @type {any} */err) {
|
813
|
+
if (callback === prCallback) prReject(err);
|
814
|
+
else callback(err);
|
815
|
+
});
|
816
|
+
} else {
|
817
|
+
utils
|
818
|
+
.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" })
|
819
|
+
.then(utils.saveCookies(jar))
|
820
|
+
.then(async function(/** @type {{ body: string; }} */res) {
|
821
|
+
try {
|
822
|
+
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
823
|
+
} catch (ex) {
|
824
|
+
clearInterval(checkVerified);
|
825
|
+
logger.Warning(Language.VerifiedCheck);
|
826
|
+
if (callback === prCallback) {
|
827
|
+
callback = function(/** @type {any} */err, /** @type {any} */api) {
|
828
|
+
if (err) return prReject(err);
|
829
|
+
return prResolve(api);
|
830
|
+
};
|
831
|
+
}
|
832
|
+
let appState = utils.getAppState(jar,false);
|
833
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
834
|
+
}
|
835
|
+
})
|
836
|
+
.catch((/** @type {any} */ex) => {
|
837
|
+
log.error("login", ex);
|
838
|
+
if (callback === prCallback) prReject(ex);
|
839
|
+
else callback(ex);
|
840
|
+
});
|
841
|
+
}
|
842
|
+
return rtPromise;
|
843
|
+
}
|
844
|
+
catch (e) {
|
845
|
+
logger.Error(e)
|
846
|
+
logger.Error()
|
847
|
+
process.exit(0)
|
848
|
+
}
|
849
|
+
}
|
850
|
+
await EnterSecurityCode()
|
851
|
+
}
|
852
|
+
catch (e) {
|
853
|
+
logger.Error(e)
|
854
|
+
logger.Error();
|
855
|
+
process.exit(0);
|
856
|
+
}
|
857
|
+
}
|
858
|
+
break;
|
859
|
+
case false: {
|
860
|
+
throw {
|
861
|
+
error: 'login-approval',
|
862
|
+
continue: function submit2FA(/** @type {any} */code) {
|
863
|
+
form.approvals_code = code;
|
864
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
|
865
|
+
var prResolve,prReject;
|
866
|
+
var rtPromise = new Promise((resolve, reject) => { prResolve = resolve; prReject = reject; });
|
867
|
+
if (typeof code == "string") {
|
868
|
+
utils
|
869
|
+
.post(nextURL, jar, form, loginOptions)
|
870
|
+
.then(utils.saveCookies(jar))
|
871
|
+
.then(function(/** @type {{ body: string | Buffer; }} */res) {
|
872
|
+
var $ = cheerio.load(res.body);
|
873
|
+
var error = $("#approvals_code").parent().attr("data-xui-error");
|
874
|
+
if (error) {
|
875
|
+
throw {
|
876
|
+
error: 'login-approval',
|
877
|
+
errordesc: Language.InvaildTwoAuthCode,
|
878
|
+
lerror: error,
|
879
|
+
continue: submit2FA
|
880
|
+
};
|
881
|
+
}
|
882
|
+
})
|
883
|
+
.then(function() {
|
884
|
+
delete form.no_fido;delete form.approvals_code;
|
885
|
+
form.name_action_selected = 'dont_save'; //'save_device' || 'dont_save;
|
886
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
887
|
+
})
|
888
|
+
.then(function(/** @type {{ headers: any; body: string | string[]; }} */res) {
|
889
|
+
var headers = res.headers;
|
890
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: Language.ApprovalsErr };
|
891
|
+
var appState = utils.getAppState(jar,false);
|
892
|
+
if (callback === prCallback) {
|
893
|
+
callback = function(/** @type {any} */err, /** @type {any} */api) {
|
894
|
+
if (err) return prReject(err);
|
895
|
+
return prResolve(api);
|
896
|
+
};
|
897
|
+
}
|
898
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
899
|
+
})
|
900
|
+
.catch(function(/** @type {any} */err) {
|
901
|
+
if (callback === prCallback) prReject(err);
|
902
|
+
else callback(err);
|
903
|
+
});
|
904
|
+
} else {
|
905
|
+
utils
|
906
|
+
.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" })
|
907
|
+
.then(utils.saveCookies(jar))
|
908
|
+
.then((/** @type {{ body: string; }} */res) => {
|
909
|
+
try {
|
910
|
+
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
911
|
+
} catch (ex) {
|
912
|
+
clearInterval(checkVerified);
|
913
|
+
logger.Warning(Language.VerifiedCheck);
|
914
|
+
if (callback === prCallback) {
|
915
|
+
callback = function(/** @type {any} */err, /** @type {any} */api) {
|
916
|
+
if (err) return prReject(err);
|
917
|
+
return prResolve(api);
|
918
|
+
};
|
919
|
+
}
|
920
|
+
return loginHelper(utils.getAppState(jar,false), email, password, loginOptions, callback);
|
921
|
+
}
|
922
|
+
})
|
923
|
+
.catch((/** @type {any} */ex) => {
|
924
|
+
log.error("login", ex);
|
925
|
+
if (callback === prCallback) prReject(ex);
|
926
|
+
else callback(ex);
|
927
|
+
});
|
928
|
+
}
|
929
|
+
return rtPromise;
|
930
|
+
}
|
931
|
+
};
|
932
|
+
}
|
933
|
+
}
|
934
|
+
} else {
|
935
|
+
if (!loginOptions.forceLogin) throw { error: Language.ForceLoginNotEnable };
|
936
|
+
|
937
|
+
if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
|
938
|
+
else form['submit[This Is Okay]'] = "This Is Okay";
|
939
|
+
|
940
|
+
return utils
|
941
|
+
.post(nextURL, jar, form, loginOptions)
|
942
|
+
.then(utils.saveCookies(jar))
|
943
|
+
.then(function() {
|
944
|
+
form.name_action_selected = 'dont_save';
|
945
|
+
|
946
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
947
|
+
})
|
948
|
+
.then(function(/** @type {{ headers: any; body: string | string[]; }} */res) {
|
949
|
+
var headers = res.headers;
|
950
|
+
|
951
|
+
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
|
952
|
+
|
953
|
+
var appState = utils.getAppState(jar,false);
|
954
|
+
|
955
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
956
|
+
})
|
957
|
+
.catch((/** @type {any} */e) => callback(e));
|
958
|
+
}
|
959
|
+
});
|
960
|
+
}
|
961
|
+
return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
|
962
|
+
});
|
963
|
+
};
|
964
|
+
}
|
965
|
+
|
966
|
+
/!-[ Function backup ]-!/
|
967
|
+
|
968
|
+
/**
|
969
|
+
* @param {string} data
|
970
|
+
* @param {any} globalOptions
|
971
|
+
* @param {any} callback
|
972
|
+
* @param {any} prCallback
|
973
|
+
*/
|
974
|
+
|
975
|
+
function backup(data,globalOptions, callback, prCallback) {
|
976
|
+
try {
|
977
|
+
var appstate;
|
978
|
+
try {
|
979
|
+
appstate = JSON.parse(data)
|
980
|
+
}
|
981
|
+
catch(e) {
|
982
|
+
appstate = data;
|
983
|
+
}
|
984
|
+
logger.Warning(Language.BackupNoti);
|
985
|
+
try {
|
986
|
+
loginHelper(appstate,null,null,globalOptions, callback, prCallback)
|
987
|
+
}
|
988
|
+
catch (e) {
|
989
|
+
logger.Error(Language.ErrBackup);
|
990
|
+
process.exit(0);
|
991
|
+
}
|
992
|
+
}
|
993
|
+
catch (e) {
|
994
|
+
return logger.Error();
|
995
|
+
}
|
996
|
+
}
|
997
|
+
|
998
|
+
/!-[ async function loginHelper ]-!/
|
999
|
+
|
1000
|
+
/**
|
1001
|
+
* @param {string | any[]} appState
|
1002
|
+
* @param {any} email
|
1003
|
+
* @param {any} password
|
1004
|
+
* @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
|
1005
|
+
* @param {(arg0: any, arg1: undefined) => void} callback
|
1006
|
+
* @param {(error: any, api: any) => any} [prCallback]
|
1007
|
+
*/
|
1008
|
+
|
1009
|
+
async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
1010
|
+
var mainPromise = null;
|
1011
|
+
var jar = utils.getJar();
|
1012
|
+
|
1013
|
+
if (fs.existsSync('./backupappstate.json')) {
|
1014
|
+
fs.unlinkSync('./backupappstate.json');
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
try {
|
1018
|
+
if (appState) {
|
1019
|
+
logger.Normal(Language.OnProcess);
|
1020
|
+
switch (await Database.has("FBKEY")) {
|
1021
|
+
case true: {
|
1022
|
+
process.env.FBKEY = await Database.get("FBKEY");
|
1023
|
+
}
|
1024
|
+
break;
|
1025
|
+
case false: {
|
1026
|
+
const SecurityKey = global.Fca.Require.Security.create().apiKey;
|
1027
|
+
process.env['FBKEY'] = SecurityKey;
|
1028
|
+
await Database.set('FBKEY', SecurityKey);
|
1029
|
+
}
|
1030
|
+
break;
|
1031
|
+
default: {
|
1032
|
+
const SecurityKey = global.Fca.Require.Security.create().apiKey;
|
1033
|
+
process.env['FBKEY'] = SecurityKey;
|
1034
|
+
await Database.set('FBKEY', SecurityKey);
|
1035
|
+
}
|
1036
|
+
}
|
1037
|
+
try {
|
1038
|
+
switch (global.Fca.Require.FastConfig.EncryptFeature) {
|
1039
|
+
case true: {
|
1040
|
+
appState = JSON.parse(JSON.stringify(appState, null, "\t"));
|
1041
|
+
switch (utils.getType(appState)) {
|
1042
|
+
case "Array": {
|
1043
|
+
switch (utils.getType(appState[0])) {
|
1044
|
+
case "Object": {
|
1045
|
+
logger.Normal(Language.NotReadyToDecrypt);
|
1046
|
+
}
|
1047
|
+
break;
|
1048
|
+
case "String": {
|
1049
|
+
appState = Security(appState,process.env['FBKEY'],'Decrypt');
|
1050
|
+
logger.Normal(Language.DecryptSuccess);
|
1051
|
+
}
|
1052
|
+
}
|
1053
|
+
}
|
1054
|
+
break;
|
1055
|
+
case "Object": {
|
1056
|
+
try {
|
1057
|
+
appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
|
1058
|
+
logger.Normal(Language.DecryptSuccess);
|
1059
|
+
}
|
1060
|
+
catch (e) {
|
1061
|
+
if (process.env.Backup != undefined && process.env.Backup) {
|
1062
|
+
await backup(process.env.Backup,globalOptions, callback, prCallback);
|
1063
|
+
}
|
1064
|
+
else {
|
1065
|
+
try {
|
1066
|
+
if (await Database.has('Backup')) {
|
1067
|
+
return await backup(await Database.get('Backup'),globalOptions, callback, prCallback);
|
1068
|
+
}
|
1069
|
+
else {
|
1070
|
+
logger.Normal(Language.ErrBackup);
|
1071
|
+
process.exit(0);
|
1072
|
+
}
|
1073
|
+
}
|
1074
|
+
catch (e) {
|
1075
|
+
logger.Warning(Language.ErrBackup);
|
1076
|
+
logger.Error();
|
1077
|
+
process.exit(0);
|
1078
|
+
}
|
1079
|
+
}
|
1080
|
+
logger.Warning(Language.DecryptFailed);
|
1081
|
+
return logger.Error();
|
1082
|
+
}
|
1083
|
+
}
|
1084
|
+
break;
|
1085
|
+
case "String": {
|
1086
|
+
try {
|
1087
|
+
appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
|
1088
|
+
logger.Normal(Language.DecryptSuccess);
|
1089
|
+
}
|
1090
|
+
catch (e) {
|
1091
|
+
if (process.env.Backup != undefined && process.env.Backup) {
|
1092
|
+
await backup(process.env.Backup,globalOptions, callback, prCallback);
|
1093
|
+
}
|
1094
|
+
else {
|
1095
|
+
try {
|
1096
|
+
if (await Database.has('Backup')) {
|
1097
|
+
return await backup(await Database.get('Backup'),globalOptions, callback, prCallback);
|
1098
|
+
}
|
1099
|
+
else {
|
1100
|
+
logger.Normal(Language.ErrBackup);
|
1101
|
+
process.exit(0);
|
1102
|
+
}
|
1103
|
+
}
|
1104
|
+
catch (e) {
|
1105
|
+
logger.Warning(Language.ErrBackup);
|
1106
|
+
logger.Error();
|
1107
|
+
process.exit(0);
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
logger.Warning(Language.DecryptFailed);
|
1111
|
+
return logger.Error();
|
1112
|
+
}
|
1113
|
+
}
|
1114
|
+
break;
|
1115
|
+
default: {
|
1116
|
+
logger.Warning(Language.InvaildAppState);
|
1117
|
+
process.exit(0)
|
1118
|
+
}
|
1119
|
+
}
|
1120
|
+
}
|
1121
|
+
break;
|
1122
|
+
case false: {
|
1123
|
+
switch (utils.getType(appState)) {
|
1124
|
+
case "Array": {
|
1125
|
+
logger.Normal(Language.EncryptStateOff);
|
1126
|
+
}
|
1127
|
+
break;
|
1128
|
+
case "Object": {
|
1129
|
+
logger.Normal(Language.EncryptStateOff);
|
1130
|
+
try {
|
1131
|
+
appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
|
1132
|
+
logger.Normal(Language.DecryptSuccess);
|
1133
|
+
}
|
1134
|
+
catch (e) {
|
1135
|
+
if (process.env.Backup != undefined && process.env.Backup) {
|
1136
|
+
await backup(process.env.Backup,globalOptions, callback, prCallback);
|
1137
|
+
}
|
1138
|
+
else {
|
1139
|
+
try {
|
1140
|
+
if (await Database.has('Backup')) {
|
1141
|
+
return await backup(await Database.get('Backup'),globalOptions, callback, prCallback);
|
1142
|
+
}
|
1143
|
+
else {
|
1144
|
+
logger.Warning(Language.ErrBackup);
|
1145
|
+
process.exit(0);
|
1146
|
+
}
|
1147
|
+
}
|
1148
|
+
catch (e) {
|
1149
|
+
logger.Warning(Language.ErrBackup);
|
1150
|
+
logger.Error();
|
1151
|
+
process.exit(0);
|
1152
|
+
}
|
1153
|
+
}
|
1154
|
+
logger.Warning(Language.DecryptFailed);
|
1155
|
+
return logger.Error();
|
1156
|
+
}
|
1157
|
+
}
|
1158
|
+
break;
|
1159
|
+
default: {
|
1160
|
+
logger.Warning(Language.InvaildAppState);
|
1161
|
+
process.exit(0)
|
1162
|
+
}
|
1163
|
+
}
|
1164
|
+
}
|
1165
|
+
break;
|
1166
|
+
default: {
|
1167
|
+
logger.Warning(getText(Language.IsNotABoolean,global.Fca.Require.FastConfig.EncryptFeature))
|
1168
|
+
process.exit(0);
|
1169
|
+
}
|
1170
|
+
}
|
1171
|
+
}
|
1172
|
+
catch (e) {
|
1173
|
+
console.log(e);
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
try {
|
1177
|
+
appState = JSON.parse(appState);
|
1178
|
+
}
|
1179
|
+
catch (e) {
|
1180
|
+
try {
|
1181
|
+
appState = appState;
|
1182
|
+
}
|
1183
|
+
catch (e) {
|
1184
|
+
return logger.Error();
|
1185
|
+
}
|
1186
|
+
}
|
1187
|
+
try {
|
1188
|
+
global.Fca.Data.AppState = appState;
|
1189
|
+
appState.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
|
1190
|
+
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
1191
|
+
jar.setCookie(str, "http://" + c.domain);
|
1192
|
+
});
|
1193
|
+
process.env.Backup = appState;
|
1194
|
+
await Database.set('Backup', appState);
|
1195
|
+
mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
|
1196
|
+
} catch (e) {
|
1197
|
+
if (process.env.Backup != undefined && process.env.Backup) {
|
1198
|
+
return await backup(process.env.Backup,globalOptions, callback, prCallback);
|
1199
|
+
}
|
1200
|
+
try {
|
1201
|
+
if (await Database.has('Backup')) {
|
1202
|
+
return await backup(await Database.get('Backup'),globalOptions, callback, prCallback);
|
1203
|
+
}
|
1204
|
+
else {
|
1205
|
+
logger.Warning(Language.ErrBackup);
|
1206
|
+
process.exit(0);
|
1207
|
+
}
|
1208
|
+
}
|
1209
|
+
catch (e) {
|
1210
|
+
logger.Warning(Language.ErrBackup);
|
1211
|
+
logger.Error();
|
1212
|
+
process.exit(0);
|
1213
|
+
}
|
1214
|
+
return logger.Warning(Language.ErrBackup); // unreachable 👑
|
1215
|
+
}
|
1216
|
+
} else {
|
1217
|
+
mainPromise = utils
|
1218
|
+
.get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
|
1219
|
+
.then(utils.saveCookies(jar))
|
1220
|
+
.then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
|
1221
|
+
.then(function() {
|
1222
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
|
1223
|
+
});
|
1224
|
+
}
|
1225
|
+
} catch (e) {
|
1226
|
+
console.log(e);
|
1227
|
+
}
|
1228
|
+
var ctx,api;
|
1229
|
+
mainPromise = mainPromise
|
1230
|
+
.then(function(/** @type {{ body: string; }} */res) {
|
1231
|
+
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/,redirect = reg.exec(res.body);
|
1232
|
+
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
|
1233
|
+
return res;
|
1234
|
+
})
|
1235
|
+
.then(function(/** @type {{ body: any; }} */res) {
|
1236
|
+
var html = res.body,Obj = buildAPI(globalOptions, html, jar);
|
1237
|
+
ctx = Obj.ctx;
|
1238
|
+
api = Obj.api;
|
1239
|
+
process.env.api = Obj.api;
|
1240
|
+
return res;
|
1241
|
+
});
|
1242
|
+
if (globalOptions.pageID) {
|
1243
|
+
mainPromise = mainPromise
|
1244
|
+
.then(function() {
|
1245
|
+
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
1246
|
+
})
|
1247
|
+
.then(function(/** @type {{ body: any; }} */resData) {
|
1248
|
+
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
1249
|
+
url = url.substring(0, url.length - 1);
|
1250
|
+
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
1251
|
+
});
|
1252
|
+
}
|
1253
|
+
mainPromise
|
1254
|
+
.then(function() {
|
1255
|
+
var { readFileSync } = require('fs-extra');
|
1256
|
+
const { execSync } = require('child_process');
|
1257
|
+
Fetch('https://raw.githubusercontent.com/ChoruTiktokers182/fb-anya/main/package.json').then(async (/** @type {{ body: { toString: () => string; }; }} */res) => {
|
1258
|
+
const localVersion = JSON.parse(readFileSync('./node_modules/fca-ANYA-remake/package.json')).version;
|
1259
|
+
if (Number(localVersion.replace(/\./g,"")) < Number(JSON.parse(res.body.toString()).version.replace(/\./g,"")) ) {
|
1260
|
+
log.warn("[ FCA-ANYA ] •",getText(Language.NewVersionFound,JSON.parse(readFileSync('./node_modules/fb-anya/package.json')).version,JSON.parse(res.body.toString()).version));
|
1261
|
+
if (global.Fca.Require.FastConfig.AutoUpdate == true) {
|
1262
|
+
log.warn("[ FB-ANYA ] •",Language.AutoUpdate);
|
1263
|
+
try {
|
1264
|
+
execSync('npm install fb-anya@latest', { stdio: 'inherit' });
|
1265
|
+
logger.Success(Language.UpdateSuccess)
|
1266
|
+
logger.Normal(Language.RestartAfterUpdate);
|
1267
|
+
await new Promise(resolve => setTimeout(resolve,5*1000));
|
1268
|
+
console.clear();process.exit(1);
|
1269
|
+
}
|
1270
|
+
catch (err) {
|
1271
|
+
log.warn('Error Update: ' + err);
|
1272
|
+
logger.Normal(Language.UpdateFailed);
|
1273
|
+
try {
|
1274
|
+
require.resolve('horizon-sp');
|
1275
|
+
}
|
1276
|
+
catch (e) {
|
1277
|
+
logger.Normal(Language.InstallSupportTool);
|
1278
|
+
execSync('npm install ./package-anya/anya-sp', { stdio: 'inherit' });
|
1279
|
+
process.exit(1);
|
1280
|
+
}
|
1281
|
+
fcasp = require('./package-anya/anya-sp');
|
1282
|
+
try {
|
1283
|
+
fcasp.onError()
|
1284
|
+
}
|
1285
|
+
catch (e) {
|
1286
|
+
logger.Normal(Language.NotiAfterUseToolFail, "[ FB - Helper ]")
|
1287
|
+
logger.Normal("rmdir ./node_modules after type npm i && npm start","[ FB - Helper ]");
|
1288
|
+
process.exit(0);
|
1289
|
+
}
|
1290
|
+
}
|
1291
|
+
}
|
1292
|
+
}
|
1293
|
+
else {
|
1294
|
+
logger.Normal(getText(Language.LocalVersion,localVersion));
|
1295
|
+
logger.Normal(getText(Language.CountTime,global.Fca.Data.CountTime()))
|
1296
|
+
logger.Normal(Language.WishMessage[Math.floor(Math.random()*Language.WishMessage.length)]);
|
1297
|
+
require('./Extra/ExtraUptimeRobot')();
|
1298
|
+
DataLanguageSetting.HTML.HTML==true? global.Fca.Require.Web.listen(global.Fca.Require.Web.get('DFP')) : global.Fca.Require.Web = null;
|
1299
|
+
callback(null, api);
|
1300
|
+
}
|
1301
|
+
});
|
1302
|
+
}).catch(function(/** @type {{ error: any; }} */e) {
|
1303
|
+
log.error("login", e.error || e);
|
1304
|
+
callback(e);
|
1305
|
+
});
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
/**
|
1309
|
+
* It asks the user for their account and password, and then saves it to the database.
|
1310
|
+
*/
|
1311
|
+
|
1312
|
+
function setUserNameAndPassWord() {
|
1313
|
+
let rl = readline.createInterface({
|
1314
|
+
input: process.stdin,
|
1315
|
+
output: process.stdout
|
1316
|
+
});
|
1317
|
+
let localbrand2 = JSON.parse(readFileSync('./node_modules/fca-anya-remake/package.json')).version;
|
1318
|
+
console.clear();
|
1319
|
+
console.log(figlet.textSync('Horizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }));
|
1320
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Operating System: " + chalk.bold.red(os.type()));
|
1321
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Machine Version: " + chalk.bold.red(os.version()));
|
1322
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Fca Version: " + chalk.bold.red(localbrand2) + '\n');
|
1323
|
+
try {
|
1324
|
+
rl.question(Language.TypeAccount, (Account) => {
|
1325
|
+
if (!Account.includes("@") && global.Fca.Require.utils.getType(parseInt(Account)) != "Number") return logger.Normal(Language.TypeAccountError, function () { process.exit(1) }); //Very Human
|
1326
|
+
else rl.question(Language.TypePassword,async function (Password) {
|
1327
|
+
rl.close();
|
1328
|
+
try {
|
1329
|
+
await Database.set("Account", Account);
|
1330
|
+
await Database.set("Password", Password);
|
1331
|
+
}
|
1332
|
+
catch (e) {
|
1333
|
+
logger.Warning(Language.ErrDataBase);
|
1334
|
+
logger.Error();
|
1335
|
+
process.exit(0);
|
1336
|
+
}
|
1337
|
+
if (global.Fca.Require.FastConfig.ResetDataLogin) {
|
1338
|
+
global.Fca.Require.FastConfig.ResetDataLogin = false;
|
1339
|
+
global.Fca.Require.fs.writeFileSync('./FastConfigFca.json', JSON.stringify(global.Fca.Require.FastConfig, null, 4));
|
1340
|
+
}
|
1341
|
+
logger.Success(Language.SuccessSetData);
|
1342
|
+
process.exit(1);
|
1343
|
+
});
|
1344
|
+
})
|
1345
|
+
}
|
1346
|
+
catch (e) {
|
1347
|
+
logger.Error(e)
|
1348
|
+
}
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
/**
|
1352
|
+
* @param {{ email: any; password: any; appState: any; }} loginData
|
1353
|
+
* @param {{}} options
|
1354
|
+
* @param {(error: any, api: any) => any} callback
|
1355
|
+
*/
|
1356
|
+
|
1357
|
+
function login(loginData, options, callback) {
|
1358
|
+
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
1359
|
+
callback = options;
|
1360
|
+
options = {};
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
var globalOptions = {
|
1364
|
+
selfListen: false,
|
1365
|
+
listenEvents: true,
|
1366
|
+
listenTyping: false,
|
1367
|
+
updatePresence: false,
|
1368
|
+
forceLogin: false,
|
1369
|
+
autoMarkDelivery: false,
|
1370
|
+
autoMarkRead: false,
|
1371
|
+
autoReconnect: true,
|
1372
|
+
logRecordSize: 100,
|
1373
|
+
online: false,
|
1374
|
+
emitReady: false,
|
1375
|
+
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"
|
1376
|
+
};
|
1377
|
+
|
1378
|
+
if (loginData.email && loginData.password) {
|
1379
|
+
setOptions(globalOptions, {
|
1380
|
+
logLevel: "silent",
|
1381
|
+
forceLogin: true,
|
1382
|
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
|
1383
|
+
});
|
1384
|
+
}
|
1385
|
+
else if (loginData.appState) {
|
1386
|
+
setOptions(globalOptions, options);
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
var prCallback = null;
|
1390
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
1391
|
+
var rejectFunc = null;
|
1392
|
+
var resolveFunc = null;
|
1393
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
1394
|
+
resolveFunc = resolve;
|
1395
|
+
rejectFunc = reject;
|
1396
|
+
});
|
1397
|
+
prCallback = function(/** @type {any} */error, /** @type {any} */api) {
|
1398
|
+
if (error) return rejectFunc(error);
|
1399
|
+
return resolveFunc(api);
|
1400
|
+
};
|
1401
|
+
callback = prCallback;
|
1402
|
+
}
|
1403
|
+
|
1404
|
+
(async function() {
|
1405
|
+
var Premium = require("./Extra/Src/Premium");
|
1406
|
+
global.Fca.Data.PremText = await Premium(global.Fca.Require.Security.create().uuid) || "Sanaol sayo";
|
1407
|
+
if (!loginData.email && !loginData.password) {
|
1408
|
+
switch (global.Fca.Require.FastConfig.AutoLogin) {
|
1409
|
+
case true: {
|
1410
|
+
if (global.Fca.Require.FastConfig.ResetDataLogin) return setUserNameAndPassWord();
|
1411
|
+
else {
|
1412
|
+
try {
|
1413
|
+
if (await Database.get("TempState")) {
|
1414
|
+
try {
|
1415
|
+
loginData.appState = JSON.parse(await Database.get("TempState"));
|
1416
|
+
}
|
1417
|
+
catch (_) {
|
1418
|
+
loginData.appState = await Database.get("TempState");
|
1419
|
+
}
|
1420
|
+
await Database.delete("TempState");
|
1421
|
+
}
|
1422
|
+
}
|
1423
|
+
catch (e) {
|
1424
|
+
console.log(e)
|
1425
|
+
await Database.delete("TempState");
|
1426
|
+
logger.Warning(Language.ErrDataBase);
|
1427
|
+
logger.Error();
|
1428
|
+
process.exit(0);
|
1429
|
+
}
|
1430
|
+
try {
|
1431
|
+
if (await Database.has('Account') && await Database.has('Password')) return loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1432
|
+
else return setUserNameAndPassWord();
|
1433
|
+
}
|
1434
|
+
catch (e) {
|
1435
|
+
logger.Warning(Language.ErrDataBase);
|
1436
|
+
logger.Error();
|
1437
|
+
process.exit(0);
|
1438
|
+
}
|
1439
|
+
}
|
1440
|
+
}
|
1441
|
+
case false: {
|
1442
|
+
loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
}
|
1446
|
+
else loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1447
|
+
})()
|
1448
|
+
return returnPromise;
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
module.exports = login;
|