fca-kaiyo 3.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 fca-kaiyo might be problematic. Click here for more details.
- package/.gitattributes +2 -0
- package/Extra/Database/index.js +469 -0
- package/Extra/ExtraAddons.js +82 -0
- package/Extra/ExtraFindUID.js +62 -0
- package/Extra/ExtraGetThread.js +340 -0
- package/Extra/ExtraScreenShot.js +430 -0
- package/Extra/ExtraUptimeRobot.js +38 -0
- package/Extra/Html/Classic/script.js +833 -0
- package/Extra/Html/Classic/style.css +1222 -0
- package/Extra/Security/Index.js +173 -0
- package/Extra/Security/Step_1.js +6 -0
- package/Extra/Security/Step_2.js +22 -0
- package/Extra/Security/Step_3.js +22 -0
- package/Extra/Src/Change_Environment.js +24 -0
- package/Extra/Src/Check_Update.js +66 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Instant_Update.js +64 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/Release_Memory.js +41 -0
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/uuid.js +137 -0
- package/Func/AcceptAgreement.js +31 -0
- package/Func/ClearCache.js +64 -0
- package/Func/ReportV1.js +54 -0
- package/Index.js +378 -0
- package/LICENSE +21 -0
- package/Language/index.json +224 -0
- package/Main.js +1110 -0
- package/README.md +144 -0
- package/broadcast.js +40 -0
- package/logger.js +66 -0
- package/package.json +227 -0
- package/src/Dev_Horizon_Data.js +125 -0
- package/src/Premium.js +25 -0
- package/src/Screenshot.js +83 -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/forwardAttachment.js +48 -0
- package/src/getAccessToken.js +28 -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 +425 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadMain.js +220 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +113 -0
- package/src/getUserInfoMain.js +65 -0
- package/src/getUserInfoV2.js +32 -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 +786 -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 +379 -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 +1684 -0
package/Main.js
ADDED
@@ -0,0 +1,1110 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/!-[ Require config and use ]-!/
|
4
|
+
|
5
|
+
if (global.Fca.Require.FastConfig.Config != 'default') {
|
6
|
+
//do ssth
|
7
|
+
}
|
8
|
+
|
9
|
+
const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.FastConfig.Language).Folder.Index;
|
10
|
+
|
11
|
+
/!-[ Require All Package Need Use ]-!/
|
12
|
+
|
13
|
+
var utils = global.Fca.Require.utils,
|
14
|
+
logger = global.Fca.Require.logger,
|
15
|
+
fs = global.Fca.Require.fs,
|
16
|
+
getText = global.Fca.getText,
|
17
|
+
log = global.Fca.Require.log,
|
18
|
+
express = require("express")(),
|
19
|
+
{ join } = require('path'),
|
20
|
+
cheerio = require("cheerio"),
|
21
|
+
{ readFileSync } = require('fs-extra'),
|
22
|
+
Database = require("./Extra/Database"),
|
23
|
+
readline = require("readline"),
|
24
|
+
chalk = require("chalk"),
|
25
|
+
figlet = require("figlet"),
|
26
|
+
os = require("os"),
|
27
|
+
deasync = require('deasync'),
|
28
|
+
Security = require("./Extra/Security/Index"),
|
29
|
+
{ getAll, deleteAll } = require('./Extra/ExtraGetThread');
|
30
|
+
|
31
|
+
/!-[ Set Variable For Process ]-!/
|
32
|
+
|
33
|
+
log.maxRecordSize = 100;
|
34
|
+
var checkVerified = null;
|
35
|
+
const Boolean_Option = ['online', 'selfListen', 'listenEvents', 'updatePresence', 'forceLogin', 'autoMarkDelivery', 'autoMarkRead', 'listenTyping', 'autoReconnect', 'emitReady'];
|
36
|
+
|
37
|
+
/!-[ Set And Check Template HTML ]-!/
|
38
|
+
|
39
|
+
const css = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'style.css'));
|
40
|
+
const js = readFileSync(join(__dirname, 'Extra', 'Html', 'Classic', 'script.js'));
|
41
|
+
|
42
|
+
/!-[ Function Generate HTML Template ]-!/
|
43
|
+
|
44
|
+
/**
|
45
|
+
* It returns a string of HTML code.
|
46
|
+
* @param UserName - The username of the user
|
47
|
+
* @param Type - The type of user, either "Free" or "Premium"
|
48
|
+
* @param link - The link to the music you want to play
|
49
|
+
* @returns A HTML file
|
50
|
+
*/
|
51
|
+
|
52
|
+
function ClassicHTML(Title, UserName, Description, FacebookLink, AvtLink) {
|
53
|
+
return `<!DOCTYPE HTML>
|
54
|
+
<html lang="en">
|
55
|
+
<head>
|
56
|
+
<title>${Title}</Title>
|
57
|
+
<meta charset="utf-8"/>
|
58
|
+
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
59
|
+
<meta name="color-scheme" content="light only"/>
|
60
|
+
<meta name="description" content="${Title}"/>
|
61
|
+
<meta property="og:site_name" content="${Title}"/>
|
62
|
+
<meta property="og:title" content="${Title}"/>
|
63
|
+
<meta property="og:type" content="website"/>
|
64
|
+
<meta property="og:description" content="${Title}"/>
|
65
|
+
<meta property="og:image:type" content="image/jpeg"/>
|
66
|
+
<meta property="og:image:width" content="1280"/>
|
67
|
+
<meta property="og:image:height" content="800"/>
|
68
|
+
<meta property="twitter:card" content="summary_large_image"/>
|
69
|
+
<link href="https://fonts.googleapis.com/css2?display=swap&family=Inter:ital,wght@0,500;0,600;1,500;1,600" rel="stylesheet" type="text/css"/>
|
70
|
+
<link rel="stylesheet" href="./style.css">
|
71
|
+
</head>
|
72
|
+
<body class="is-loading">
|
73
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 40 40" display="none" width="0" height="0">
|
74
|
+
<symbol id="icon-021973a1bb185878b41e1ef48ed6bbaa" viewBox="0 0 40 40">
|
75
|
+
<path d="M35.7,13c-1.6-2-3.8-3.5-6.5-4.7c-2.8-1.1-5.8-1.7-9-1.7c-2.4,0-4.8,0.3-7,1C10.9,8.2,9,9.2,7.4,10.3 c-1.6,1.2-2.9,2.5-3.8,4.1c-1,1.6-1.4,3.3-1.4,5c0,2,0.6,3.9,1.8,5.7c1.2,1.8,2.9,3.2,5,4.4c-0.1,0.5-0.3,1-0.5,1.5 c-0.2,0.5-0.4,0.9-0.5,1.2c-0.2,0.3-0.4,0.7-0.7,1c-0.3,0.4-0.5,0.6-0.6,0.8c-0.1,0.2-0.4,0.4-0.7,0.8c-0.3,0.4-0.5,0.6-0.6,0.7 c0,0-0.1,0.1-0.2,0.2C5,35.8,5,35.8,5,35.8L4.8,36c-0.1,0.1-0.1,0.2-0.1,0.2c0,0,0,0.1,0,0.2c0,0.1,0,0.2,0,0.2v0 c0.1,0.2,0.2,0.4,0.4,0.6c0.2,0.1,0.4,0.2,0.6,0.2C6.6,37.3,7.3,37.2,8,37c3.5-0.9,6.6-2.5,9.2-4.9c1,0.1,2,0.2,2.9,0.2 c3.3,0,6.3-0.6,9-1.7c2.8-1.1,4.9-2.7,6.5-4.7c1.6-2,2.4-4.1,2.4-6.5C38.1,17.1,37.3,14.9,35.7,13z"/>
|
76
|
+
</symbol>
|
77
|
+
<symbol id="icon-694b338299bf630d8d2ec9bd42d31dbe" viewBox="0 0 40 40">
|
78
|
+
<path d="M36.1,11.7v5c-3.3,0-6.3-1-8.8-2.8v12.9c0,6.5-5.2,11.7-11.7,11.7c-2.4,0-4.6-0.7-6.5-2c0,0,0,0,0,0 c-3.1-2.1-5.2-5.7-5.2-9.7c0-6.5,5.2-11.7,11.7-11.7c0.5,0,1.1,0,1.6,0.1v1.4c0,0,0,0,0,0v5c-0.5-0.2-1.1-0.3-1.6-0.3 c-2.9,0-5.3,2.4-5.3,5.4c0,2.1,1.2,3.9,2.9,4.8c0.7,0.4,1.5,0.6,2.4,0.6c2.9,0,5.3-2.4,5.3-5.3V1.5h6.3v0.8c0,0.2,0.1,0.5,0.1,0.7 c0.4,2.5,1.9,4.7,4,6c0,0,0.1,0.1,0.1,0.1c0,0-0.1-0.1-0.1-0.1c1.4,0.9,3,1.3,4.7,1.3V11.7"/>
|
79
|
+
</symbol>
|
80
|
+
<symbol id="icon-ee3f4c4dd1c95bbfa424b0cab69e93b3" viewBox="0 0 40 40">
|
81
|
+
<path d="M38.1,29.5c-0.1,0.1-0.1,0.2-0.2,0.3c-0.9,1.4-2.5,2.7-5.1,2.7l0,0c-1.7,0-3.3-0.4-5-2c-1.3-1.2-2.8-3.4-4-5.4 l-3.5-5.8c-0.1-0.2-0.2-0.3-0.3-0.5c-0.1,0.2-0.2,0.4-0.3,0.5l-1.2,2.2c-2.5,4.4-3.1,5.4-4.3,7c-2.2,2.9-4,4-6.4,4 c-2.9,0-4.7-1.2-5.8-3.1c-0.9-1.5-1.4-3.5-1.4-5.8c0-4.2,1.1-8.5,3.3-11.9c1.9-3,4.7-5.1,7.9-5.1c1.9,0,3.7,0.5,5.6,2.1 c1,0.8,2.1,1.9,3.2,3.3c0.9-1.2,1.9-2.4,3-3.3c1.6-1.4,3.3-2.1,5-2.1c2.9,0,5.6,1.7,7.7,4.8c2.3,3.4,3.4,7.7,3.4,12.1 C39.5,26,39,28,38.1,29.5z M16,13.1c-1-1.1-2.3-2.3-4.3-2.3c-1.7,0-3.1,1.2-4.3,2.9c-1.7,2.5-2.7,6.3-2.7,9.9c0,1.5,0.3,2.6,0.8,3.3 c0.6,0.9,1.4,1.3,2.2,1.3c1.1,0,2.1-0.3,4-2.9c1.6-2.1,3.4-5.2,4.6-7l1.7-2.5C17.2,14.6,16.5,13.7,16,13.1z M33.1,13.1 c-1.3-2-3-3.2-4.9-3.2c-2,0-3.6,1.5-5.5,4.2c-0.1,0.2-0.2,0.3-0.3,0.5c0.6,1,1.3,2,2,3.2l1,1.7c2.4,4,3.8,6.1,4.6,7.1 c1,1.3,1.8,1.6,2.7,1.6c2.4,0,3-2.2,3-4.7C35.8,19.9,34.9,16,33.1,13.1z"/>
|
82
|
+
</symbol>
|
83
|
+
<symbol id="icon-3b7eeeccbb457780f277fce4669f67a0" viewBox="0 0 40 40">
|
84
|
+
<path d="M33.2,8.3c-2.5-1.1-5.1-1.9-7.9-2.4c-0.3,0.6-0.7,1.4-1,2c-2.9-0.4-5.8-0.4-8.7,0c-0.3-0.6-0.7-1.4-1-2 c-2.8,0.5-5.4,1.3-7.9,2.4c-5,7.2-6.3,14.2-5.6,21.1c3.3,2.3,6.5,3.8,9.6,4.7c0.8-1,1.5-2.1,2.1-3.3c-1.1-0.4-2.2-0.9-3.2-1.5 c0.3-0.2,0.5-0.4,0.8-0.6c6.3,2.8,13,2.8,19.2,0c0.3,0.2,0.5,0.4,0.8,0.6c-1,0.6-2.1,1.1-3.2,1.5c0.6,1.1,1.3,2.2,2.1,3.3 c3.1-0.9,6.3-2.4,9.6-4.7C39.7,21.4,37.5,14.4,33.2,8.3z M13.7,25.1c-1.9,0-3.4-1.7-3.4-3.7s1.5-3.7,3.4-3.7c1.9,0,3.5,1.7,3.4,3.7 C17.1,23.4,15.6,25.1,13.7,25.1z M26.3,25.1c-1.9,0-3.4-1.7-3.4-3.7s1.5-3.7,3.4-3.7c1.9,0,3.5,1.7,3.4,3.7 C29.7,23.4,28.2,25.1,26.3,25.1z"/>
|
85
|
+
</symbol>
|
86
|
+
</svg>
|
87
|
+
<div id="wrapper">
|
88
|
+
<div id="main">
|
89
|
+
<div class="inner">
|
90
|
+
<div id="container02" class="container default full">
|
91
|
+
<div class="wrapper">
|
92
|
+
<div class="inner">
|
93
|
+
<div id="image05" class="image">
|
94
|
+
<span class="frame">
|
95
|
+
<img src="${AvtLink}" alt=""/>
|
96
|
+
</span>
|
97
|
+
</div>
|
98
|
+
<h2 id="text45">${UserName}</h2>
|
99
|
+
<p id="text46">
|
100
|
+
<span class="p">
|
101
|
+
${Description}
|
102
|
+
</span>
|
103
|
+
</p>
|
104
|
+
<ul id="buttons01" class="buttons">
|
105
|
+
<li>
|
106
|
+
<a href="${FacebookLink}" class="button n01">
|
107
|
+
<svg>
|
108
|
+
<use xlink:href="#icon-021973a1bb185878b41e1ef48ed6bbaa"></use>
|
109
|
+
</svg>
|
110
|
+
<span class="label">Contact For Me</span>
|
111
|
+
</a>
|
112
|
+
</li>
|
113
|
+
</ul>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
</div>
|
117
|
+
<div id="credits" class="icc-credits">
|
118
|
+
<span>
|
119
|
+
<a href="https://www.npmjs.com/package/fca-zeid">Made with Fca-Zeid</a>
|
120
|
+
</span>
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
</div>
|
124
|
+
</div>
|
125
|
+
<script src="./script.js"></script>
|
126
|
+
</body>
|
127
|
+
</html>`
|
128
|
+
}
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
/!-[ Stating Http Infomation ]-!/
|
133
|
+
|
134
|
+
express.set('DFP', (process.env.PORT || process.env.port || global.Fca.Require.FastConfig.HTML.Port));
|
135
|
+
|
136
|
+
express.use(function(req, res, next) {
|
137
|
+
switch (req.url.split('?')[0]) {
|
138
|
+
case '/script.js': {
|
139
|
+
res.writeHead(200, { 'Content-Type': 'text/javascript' });
|
140
|
+
res.write(js);
|
141
|
+
break;
|
142
|
+
}
|
143
|
+
case '/style.css': {
|
144
|
+
res.writeHead(200, { 'Content-Type': 'text/css' });
|
145
|
+
res.write(css);
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
// case '/History': {
|
149
|
+
// if (req.query.PassWord == process.env.REPL_OWNER) {
|
150
|
+
// res.writeHead(200, { 'Content-Type': 'application/json charset=utf-8' });
|
151
|
+
// res.write(JSON.stringify(console.history,null,2),'utf8');
|
152
|
+
// res.end();
|
153
|
+
// }
|
154
|
+
// else res.json({
|
155
|
+
// Status: false,
|
156
|
+
// Error: "Thiếu Params ?PassWord=PassWordCuaBan =))"
|
157
|
+
// });
|
158
|
+
// break;
|
159
|
+
// }
|
160
|
+
default: {
|
161
|
+
res.writeHead(200, "OK", { "Content-Type": "text/html" });
|
162
|
+
res.write(ClassicHTML(global.Fca.Require.FastConfig.HTML.Title, global.Fca.Require.FastConfig.HTML.UserName, global.Fca.Require.FastConfig.HTML.Description, global.Fca.Require.FastConfig.HTML.FacebookLink, global.Fca.Require.FastConfig.HTML.AvtLink));
|
163
|
+
}
|
164
|
+
}
|
165
|
+
res.end();
|
166
|
+
})
|
167
|
+
|
168
|
+
var Server;
|
169
|
+
if (global.Fca.Require.FastConfig.HTML.HTML) Server = express.listen(express.get('DFP'));
|
170
|
+
|
171
|
+
/ !-[Function setOptions] - !/
|
172
|
+
|
173
|
+
/**
|
174
|
+
* @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
|
175
|
+
* @param {{ [x: string]: any; logLevel?: any; forceLogin?: boolean; userAgent?: any; pauseLog?: any; logRecordSize?: any; pageID?: any; proxy?: any; }} options
|
176
|
+
*/
|
177
|
+
|
178
|
+
function setOptions(globalOptions, options) {
|
179
|
+
Object.keys(options).map(function(key) {
|
180
|
+
switch (Boolean_Option.includes(key)) {
|
181
|
+
case true: {
|
182
|
+
globalOptions[key] = Boolean(options[key]);
|
183
|
+
break;
|
184
|
+
}
|
185
|
+
case false: {
|
186
|
+
switch (key) {
|
187
|
+
case 'pauseLog': {
|
188
|
+
if (options.pauseLog) log.pause();
|
189
|
+
else log.resume();
|
190
|
+
break;
|
191
|
+
}
|
192
|
+
case 'logLevel': {
|
193
|
+
log.level = options.logLevel;
|
194
|
+
globalOptions.logLevel = options.logLevel;
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
case 'logRecordSize': {
|
198
|
+
log.maxRecordSize = options.logRecordSize;
|
199
|
+
globalOptions.logRecordSize = options.logRecordSize;
|
200
|
+
break;
|
201
|
+
}
|
202
|
+
case 'pageID': {
|
203
|
+
globalOptions.pageID = options.pageID.toString();
|
204
|
+
break;
|
205
|
+
}
|
206
|
+
case 'userAgent': {
|
207
|
+
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');
|
208
|
+
break;
|
209
|
+
}
|
210
|
+
case 'proxy': {
|
211
|
+
if (typeof options.proxy != "string") {
|
212
|
+
delete globalOptions.proxy;
|
213
|
+
utils.setProxy();
|
214
|
+
} else {
|
215
|
+
globalOptions.proxy = options.proxy;
|
216
|
+
utils.setProxy(globalOptions.proxy);
|
217
|
+
}
|
218
|
+
break;
|
219
|
+
}
|
220
|
+
default: {
|
221
|
+
log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
|
222
|
+
break;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
break;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
});
|
229
|
+
}
|
230
|
+
|
231
|
+
/!-[ Function BuildAPI ]-!/
|
232
|
+
|
233
|
+
/**
|
234
|
+
* @param {any} globalOptions
|
235
|
+
* @param {string} html
|
236
|
+
* @param {{ getCookies: (arg0: string) => any[]; }} jar
|
237
|
+
*/
|
238
|
+
|
239
|
+
function buildAPI(globalOptions, html, jar) {
|
240
|
+
var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(/** @type {{ cookieString: () => string; }} */val) { return val.cookieString().split("=")[0] === "c_user"; });
|
241
|
+
|
242
|
+
if (maybeCookie.length === 0) {
|
243
|
+
if (global.Fca.Require.FastConfig.AutoLogin) {
|
244
|
+
return global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.AutoLogin, function() {
|
245
|
+
global.Fca.Action('AutoLogin')
|
246
|
+
});
|
247
|
+
}
|
248
|
+
else if (!global.Fca.Require.FastConfig.AutoLogin) {
|
249
|
+
return global.Fca.Require.logger.Error(global.Fca.Require.Language.Index.ErrAppState);
|
250
|
+
}
|
251
|
+
}
|
252
|
+
else {
|
253
|
+
if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
|
254
|
+
|
255
|
+
var userID = maybeCookie[0].cookieString().split("=")[1].toString();
|
256
|
+
process.env['UID'] = logger.Normal(getText(Language.UID, userID), userID);
|
257
|
+
|
258
|
+
try {
|
259
|
+
clearInterval(checkVerified);
|
260
|
+
} catch (e) {
|
261
|
+
console.log(e);
|
262
|
+
}
|
263
|
+
|
264
|
+
var clientID = (Math.random() * 2147483648 | 0).toString(16);
|
265
|
+
|
266
|
+
var CHECK_MQTT = {
|
267
|
+
oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
|
268
|
+
newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
|
269
|
+
legacyFBMQTTMatch: html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/)
|
270
|
+
}
|
271
|
+
|
272
|
+
let Slot = Object.keys(CHECK_MQTT);
|
273
|
+
|
274
|
+
var mqttEndpoint, region, irisSeqID;
|
275
|
+
Object.keys(CHECK_MQTT).map(function(MQTT) {
|
276
|
+
if (CHECK_MQTT[MQTT] && !region) {
|
277
|
+
switch (Slot.indexOf(MQTT)) {
|
278
|
+
case 0: {
|
279
|
+
irisSeqID = CHECK_MQTT[MQTT][1];
|
280
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2];
|
281
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
282
|
+
return;
|
283
|
+
}
|
284
|
+
case 1: {
|
285
|
+
irisSeqID = CHECK_MQTT[MQTT][2];
|
286
|
+
mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
|
287
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
288
|
+
return;
|
289
|
+
}
|
290
|
+
case 2: {
|
291
|
+
mqttEndpoint = CHECK_MQTT[MQTT][4];
|
292
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
293
|
+
return;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
return;
|
297
|
+
}
|
298
|
+
});
|
299
|
+
|
300
|
+
var ctx = {
|
301
|
+
userID: userID,
|
302
|
+
jar: jar,
|
303
|
+
clientID: clientID,
|
304
|
+
globalOptions: globalOptions,
|
305
|
+
loggedIn: true,
|
306
|
+
access_token: 'NONE',
|
307
|
+
clientMutationId: 0,
|
308
|
+
mqttClient: undefined,
|
309
|
+
lastSeqId: irisSeqID,
|
310
|
+
syncToken: undefined,
|
311
|
+
mqttEndpoint: mqttEndpoint,
|
312
|
+
region: region,
|
313
|
+
firstListen: true
|
314
|
+
};
|
315
|
+
|
316
|
+
var api = {
|
317
|
+
setOptions: setOptions.bind(null, globalOptions),
|
318
|
+
getAppState: function getAppState() {
|
319
|
+
return utils.getAppState(jar);
|
320
|
+
}
|
321
|
+
};
|
322
|
+
|
323
|
+
if (region && mqttEndpoint) {
|
324
|
+
//do sth
|
325
|
+
}
|
326
|
+
else {
|
327
|
+
log.warn("login", getText(Language.NoAreaData));
|
328
|
+
api["htmlData"] = html;
|
329
|
+
}
|
330
|
+
|
331
|
+
var defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
332
|
+
|
333
|
+
fs.readdirSync(__dirname + "/src").filter((/** @type {string} */File) => File.endsWith(".js") && !File.includes('Dev_')).map((/** @type {string} */File) => {
|
334
|
+
if (File == 'getThreadInfo.js' && global.Fca.Require.FastConfig.AntiGetInfo.AntiGetThreadInfo != true || File == 'getUserInfo.js' && global.Fca.Require.FastConfig.AntiGetInfo.AntiGetUserInfo != true) api[File.split('.').slice(0, -1).join('.')] = require('./src/' + (File.includes('getThreadInfo') ? 'getThreadMain.js' : 'getUserInfoMain.js'))(defaultFuncs, api, ctx)
|
335
|
+
else api[File.split('.').slice(0, -1).join('.')] = require('./src/' + File)(defaultFuncs, api, ctx)
|
336
|
+
});
|
337
|
+
|
338
|
+
return {
|
339
|
+
ctx,
|
340
|
+
defaultFuncs,
|
341
|
+
api
|
342
|
+
};
|
343
|
+
}
|
344
|
+
}
|
345
|
+
|
346
|
+
/!-[ Function makeLogin ]-!/
|
347
|
+
|
348
|
+
/**
|
349
|
+
* @param {{ setCookie: (arg0: any, arg1: string) => void; }} jar
|
350
|
+
* @param {any} email
|
351
|
+
* @param {any} password
|
352
|
+
* @param {{ forceLogin: any; }} loginOptions
|
353
|
+
* @param {(err: any, api: any) => any} callback
|
354
|
+
* @param {any} prCallback
|
355
|
+
*/
|
356
|
+
|
357
|
+
function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
358
|
+
return function(res) {
|
359
|
+
var html = res.body, $ = cheerio.load(html), arr = [];
|
360
|
+
|
361
|
+
$("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
362
|
+
|
363
|
+
arr = arr.filter(function(v) {
|
364
|
+
return v.val && v.val.length;
|
365
|
+
});
|
366
|
+
var form = utils.arrToForm(arr);
|
367
|
+
form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
368
|
+
form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
|
369
|
+
form.email = email;
|
370
|
+
form.pass = password;
|
371
|
+
form.default_persistent = '0';
|
372
|
+
form.locale = 'en_US';
|
373
|
+
form.timezone = '240';
|
374
|
+
form.lgnjs = ~~(Date.now() / 1000);
|
375
|
+
|
376
|
+
html.split("\"_js_").slice(1).map((val) => {
|
377
|
+
jar.setCookie(utils.formatCookie(JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]"), "facebook"), "https://www.facebook.com")
|
378
|
+
});
|
379
|
+
|
380
|
+
logger.Normal(Language.OnLogin);
|
381
|
+
return utils
|
382
|
+
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
383
|
+
.then(utils.saveCookies(jar))
|
384
|
+
.then(function(/** @type {{ headers: any; }} */res) {
|
385
|
+
var headers = res.headers;
|
386
|
+
if (!headers.location) throw { error: Language.InvaildAccount };
|
387
|
+
|
388
|
+
// This means the account has login approvals turned on.
|
389
|
+
if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
|
390
|
+
logger.Warning(Language.TwoAuth);
|
391
|
+
var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
|
392
|
+
|
393
|
+
return utils
|
394
|
+
.get(headers.location, jar, null, loginOptions)
|
395
|
+
.then(utils.saveCookies(jar))
|
396
|
+
.then(function(res) {
|
397
|
+
if (!Database().get('ThroughAcc')) {
|
398
|
+
Database().set('ThroughAcc', email);
|
399
|
+
}
|
400
|
+
else {
|
401
|
+
if (String((Database().get('ThroughAcc'))).replace(RegExp('"', 'g'), '') != String(email).replace(RegExp('"', 'g'), '')) {
|
402
|
+
Database().set('ThroughAcc', email);
|
403
|
+
if (Database().get('Through2Fa')) {
|
404
|
+
Database().delete('Through2Fa');
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}
|
408
|
+
var html = res.body, $ = cheerio.load(html), arr = [];
|
409
|
+
$("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
410
|
+
arr = arr.filter(v => { return v.val && v.val.length });
|
411
|
+
var form = utils.arrToForm(arr);
|
412
|
+
if (html.indexOf("checkpoint/?next") > -1) {
|
413
|
+
setTimeout(() => {
|
414
|
+
checkVerified = setInterval((_form) => { }, 5000, {
|
415
|
+
fb_dtsg: form.fb_dtsg,
|
416
|
+
jazoest: form.jazoest,
|
417
|
+
dpr: 1
|
418
|
+
});
|
419
|
+
}, 2500);
|
420
|
+
switch (global.Fca.Require.FastConfig.Login2Fa) {
|
421
|
+
case true: {
|
422
|
+
const question = question => {
|
423
|
+
const rl = readline.createInterface({
|
424
|
+
input: process.stdin,
|
425
|
+
output: process.stdout
|
426
|
+
});
|
427
|
+
var done, answ;
|
428
|
+
rl.question(question, answer => {
|
429
|
+
rl.close();
|
430
|
+
answ = answer;
|
431
|
+
done = true
|
432
|
+
})
|
433
|
+
deasync.loopWhile(function() {
|
434
|
+
return !done;
|
435
|
+
});
|
436
|
+
return answ;
|
437
|
+
};
|
438
|
+
try {
|
439
|
+
const Old_Cookie = Database().get('Through2Fa');
|
440
|
+
if (Old_Cookie) {
|
441
|
+
Old_Cookie.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
|
442
|
+
let str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
443
|
+
jar.setCookie(str, "http://" + c.domain);
|
444
|
+
});
|
445
|
+
let Form = utils.arrToForm(arr);
|
446
|
+
Form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
447
|
+
Form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
|
448
|
+
Form.email = email;
|
449
|
+
Form.pass = password;
|
450
|
+
Form.default_persistent = '0';
|
451
|
+
Form.locale = 'en_US';
|
452
|
+
Form.timezone = '240';
|
453
|
+
Form.lgnjs = ~~(Date.now() / 1000);
|
454
|
+
return utils
|
455
|
+
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, Form, loginOptions)
|
456
|
+
.then(utils.saveCookies(jar))
|
457
|
+
.then(function(res) {
|
458
|
+
let headers = res.headers
|
459
|
+
if (!headers['set-cookie'][0].includes('deleted')) {
|
460
|
+
logger.Warning(Language.ErrThroughCookies, function() {
|
461
|
+
Database().delete('Through2Fa');
|
462
|
+
});
|
463
|
+
process.exit(1);
|
464
|
+
}
|
465
|
+
if (headers.location && headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
|
466
|
+
return utils
|
467
|
+
.get(headers.location, jar, null, loginOptions)
|
468
|
+
.then(utils.saveCookies(jar))
|
469
|
+
.then(function(res) {
|
470
|
+
var html = res.body, $ = cheerio.load(html), arr = [];
|
471
|
+
$("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
472
|
+
arr = arr.filter(v => { return v.val && v.val.length });
|
473
|
+
var Form = utils.arrToForm(arr);
|
474
|
+
|
475
|
+
if (html.indexOf("checkpoint/?next") > -1) {
|
476
|
+
setTimeout(() => {
|
477
|
+
checkVerified = setInterval((_form) => { }, 5000, {
|
478
|
+
fb_dtsg: Form.fb_dtsg,
|
479
|
+
jazoest: Form.jazoest,
|
480
|
+
dpr: 1
|
481
|
+
});
|
482
|
+
}, 2500);
|
483
|
+
|
484
|
+
if (!res.headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
|
485
|
+
try {
|
486
|
+
delete Form.name_action_selected;
|
487
|
+
Form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
488
|
+
return utils
|
489
|
+
.post(nextURL, jar, Form, loginOptions)
|
490
|
+
.then(utils.saveCookies(jar))
|
491
|
+
.then(function() {
|
492
|
+
Form['submit[This was me]'] = "This was me";
|
493
|
+
return utils.post(nextURL, jar, Form, loginOptions).then(utils.saveCookies(jar));
|
494
|
+
})
|
495
|
+
.then(function() {
|
496
|
+
delete Form['submit[This was me]'];
|
497
|
+
Form.name_action_selected = 'save_device';
|
498
|
+
Form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
499
|
+
return utils.post(nextURL, jar, Form, loginOptions).then(utils.saveCookies(jar));
|
500
|
+
})
|
501
|
+
.then(function(res) {
|
502
|
+
var headers = res.headers;
|
503
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
|
504
|
+
Database().delete('Through2Fa');
|
505
|
+
process.exit(1);
|
506
|
+
}
|
507
|
+
var appState = utils.getAppState(jar, false);
|
508
|
+
Database().set('Through2Fa', appState);
|
509
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
510
|
+
})
|
511
|
+
.catch((e) => callback(e));
|
512
|
+
}
|
513
|
+
catch (e) {
|
514
|
+
console.log(e)
|
515
|
+
}
|
516
|
+
}
|
517
|
+
}
|
518
|
+
})
|
519
|
+
}
|
520
|
+
return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
|
521
|
+
})
|
522
|
+
.catch((e) => console.log(e));
|
523
|
+
}
|
524
|
+
}
|
525
|
+
catch (e) {
|
526
|
+
Database().delete('Through2Fa');
|
527
|
+
}
|
528
|
+
const Otp_code = require('totp-generator');
|
529
|
+
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);
|
530
|
+
try {
|
531
|
+
const approvals = function(N_Code) {
|
532
|
+
form.approvals_code = N_Code;
|
533
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
534
|
+
var prResolve, prReject;
|
535
|
+
var rtPromise = new Promise((resolve, reject) => { prResolve = resolve; prReject = reject; });
|
536
|
+
|
537
|
+
if (typeof N_Code == "string") {
|
538
|
+
utils
|
539
|
+
.post(nextURL, jar, form, loginOptions)
|
540
|
+
.then(utils.saveCookies(jar))
|
541
|
+
.then(function(res) {
|
542
|
+
var $ = cheerio.load(res.body);
|
543
|
+
var error = $("#approvals_code").parent().attr("data-xui-error");
|
544
|
+
if (error) {
|
545
|
+
logger.Warning(Language.InvaildTwoAuthCode, function() { approvals(question(Language.EnterSecurityCode)) }); //bruh loop
|
546
|
+
};
|
547
|
+
})
|
548
|
+
.then(function() {
|
549
|
+
delete form.no_fido; delete form.approvals_code;
|
550
|
+
form.name_action_selected = 'save_device'; //'save_device' || 'dont_save;
|
551
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
552
|
+
})
|
553
|
+
.then(function(res) {
|
554
|
+
var headers = res.headers;
|
555
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) {
|
556
|
+
try {
|
557
|
+
delete form.name_action_selected;
|
558
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
559
|
+
return utils
|
560
|
+
.post(nextURL, jar, form, loginOptions)
|
561
|
+
.then(utils.saveCookies(jar))
|
562
|
+
.then(function() {
|
563
|
+
form['submit[This was me]'] = "This was me";
|
564
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
565
|
+
})
|
566
|
+
.then(function() {
|
567
|
+
delete form['submit[This was me]'];
|
568
|
+
form.name_action_selected = 'save_device';
|
569
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html();
|
570
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
571
|
+
})
|
572
|
+
.then(function(res) {
|
573
|
+
var headers = res.headers;
|
574
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: "wtf ??:D" };
|
575
|
+
var appState = utils.getAppState(jar, false);
|
576
|
+
Database().set('Through2Fa', appState);
|
577
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
578
|
+
})
|
579
|
+
.catch((e) => callback(e));
|
580
|
+
}
|
581
|
+
catch (e) {
|
582
|
+
console.log(e)
|
583
|
+
}
|
584
|
+
}
|
585
|
+
var appState = utils.getAppState(jar, false);
|
586
|
+
if (callback === prCallback) {
|
587
|
+
callback = function(err, api) {
|
588
|
+
if (err) return prReject(err);
|
589
|
+
return prResolve(api);
|
590
|
+
};
|
591
|
+
}
|
592
|
+
Database().set('Through2Fa', appState);
|
593
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
594
|
+
})
|
595
|
+
.catch(function(err) {
|
596
|
+
if (callback === prCallback) prReject(err);
|
597
|
+
else callback(err);
|
598
|
+
});
|
599
|
+
}
|
600
|
+
else {
|
601
|
+
utils
|
602
|
+
.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" })
|
603
|
+
.then(utils.saveCookies(jar))
|
604
|
+
.then(function(res) {
|
605
|
+
try {
|
606
|
+
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
607
|
+
} catch (ex) {
|
608
|
+
clearInterval(checkVerified);
|
609
|
+
logger.Warning(Language.VerifiedCheck);
|
610
|
+
if (callback === prCallback) {
|
611
|
+
callback = function(err, api) {
|
612
|
+
if (err) return prReject(err);
|
613
|
+
return prResolve(api);
|
614
|
+
};
|
615
|
+
}
|
616
|
+
let appState = utils.getAppState(jar, false);
|
617
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
618
|
+
}
|
619
|
+
})
|
620
|
+
.catch((ex) => {
|
621
|
+
log.error("login", ex);
|
622
|
+
if (callback === prCallback) prReject(ex);
|
623
|
+
else callback(ex);
|
624
|
+
});
|
625
|
+
}
|
626
|
+
return rtPromise;
|
627
|
+
}
|
628
|
+
return approvals(Code)
|
629
|
+
}
|
630
|
+
catch (e) {
|
631
|
+
logger.Error(e)
|
632
|
+
logger.Error();
|
633
|
+
process.exit(0);
|
634
|
+
}
|
635
|
+
}
|
636
|
+
case false: {
|
637
|
+
throw {
|
638
|
+
error: 'login-approval',
|
639
|
+
continue: function submit2FA(code) {
|
640
|
+
form.approvals_code = code;
|
641
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
|
642
|
+
var prResolve, prReject;
|
643
|
+
var rtPromise = new Promise((resolve, reject) => { prResolve = resolve; prReject = reject; });
|
644
|
+
if (typeof code == "string") {
|
645
|
+
utils
|
646
|
+
.post(nextURL, jar, form, loginOptions)
|
647
|
+
.then(utils.saveCookies(jar))
|
648
|
+
.then(function(/** @type {{ body: string | Buffer; }} */res) {
|
649
|
+
var $ = cheerio.load(res.body);
|
650
|
+
var error = $("#approvals_code").parent().attr("data-xui-error");
|
651
|
+
if (error) {
|
652
|
+
throw {
|
653
|
+
error: 'login-approval',
|
654
|
+
errordesc: Language.InvaildTwoAuthCode,
|
655
|
+
lerror: error,
|
656
|
+
continue: submit2FA
|
657
|
+
};
|
658
|
+
}
|
659
|
+
})
|
660
|
+
.then(function() {
|
661
|
+
delete form.no_fido; delete form.approvals_code;
|
662
|
+
form.name_action_selected = 'dont_save'; //'save_device' || 'dont_save;
|
663
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
664
|
+
})
|
665
|
+
.then(function(res) {
|
666
|
+
var headers = res.headers;
|
667
|
+
if (!headers.location && res.headers['set-cookie'][0].includes('checkpoint')) throw { error: Language.ApprovalsErr };
|
668
|
+
var appState = utils.getAppState(jar, false);
|
669
|
+
if (callback === prCallback) {
|
670
|
+
callback = function(err, api) {
|
671
|
+
if (err) return prReject(err);
|
672
|
+
return prResolve(api);
|
673
|
+
};
|
674
|
+
}
|
675
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
676
|
+
})
|
677
|
+
.catch(function(err) {
|
678
|
+
if (callback === prCallback) prReject(err);
|
679
|
+
else callback(err);
|
680
|
+
});
|
681
|
+
} else {
|
682
|
+
utils
|
683
|
+
.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" })
|
684
|
+
.then(utils.saveCookies(jar))
|
685
|
+
.then((res) => {
|
686
|
+
try {
|
687
|
+
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
688
|
+
} catch (ex) {
|
689
|
+
clearInterval(checkVerified);
|
690
|
+
logger.Warning(Language.VerifiedCheck);
|
691
|
+
if (callback === prCallback) {
|
692
|
+
callback = function(err, api) {
|
693
|
+
if (err) return prReject(err);
|
694
|
+
return prResolve(api);
|
695
|
+
};
|
696
|
+
}
|
697
|
+
return loginHelper(utils.getAppState(jar, false), email, password, loginOptions, callback);
|
698
|
+
}
|
699
|
+
})
|
700
|
+
.catch((ex) => {
|
701
|
+
log.error("login", ex);
|
702
|
+
if (callback === prCallback) prReject(ex);
|
703
|
+
else callback(ex);
|
704
|
+
});
|
705
|
+
}
|
706
|
+
return rtPromise;
|
707
|
+
}
|
708
|
+
};
|
709
|
+
}
|
710
|
+
}
|
711
|
+
} else {
|
712
|
+
if (!loginOptions.forceLogin) throw { error: Language.ForceLoginNotEnable };
|
713
|
+
|
714
|
+
if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
|
715
|
+
else form['submit[This Is Okay]'] = "This Is Okay";
|
716
|
+
|
717
|
+
return utils
|
718
|
+
.post(nextURL, jar, form, loginOptions)
|
719
|
+
.then(utils.saveCookies(jar))
|
720
|
+
.then(function() {
|
721
|
+
form.name_action_selected = 'dont_save';
|
722
|
+
|
723
|
+
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
724
|
+
})
|
725
|
+
.then(function(res) {
|
726
|
+
var headers = res.headers;
|
727
|
+
|
728
|
+
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
|
729
|
+
|
730
|
+
var appState = utils.getAppState(jar, false);
|
731
|
+
|
732
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
733
|
+
})
|
734
|
+
.catch((e) => callback(e));
|
735
|
+
}
|
736
|
+
});
|
737
|
+
}
|
738
|
+
return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
|
739
|
+
});
|
740
|
+
};
|
741
|
+
}
|
742
|
+
|
743
|
+
/!-[ Function backup ]-!/
|
744
|
+
|
745
|
+
/**
|
746
|
+
* @param {string} data
|
747
|
+
* @param {any} globalOptions
|
748
|
+
* @param {any} callback
|
749
|
+
* @param {any} prCallback
|
750
|
+
*/
|
751
|
+
|
752
|
+
function backup(data, globalOptions, callback, prCallback) {
|
753
|
+
try {
|
754
|
+
var appstate;
|
755
|
+
try {
|
756
|
+
appstate = JSON.parse(data)
|
757
|
+
}
|
758
|
+
catch (e) {
|
759
|
+
appstate = data;
|
760
|
+
}
|
761
|
+
logger.Warning(Language.BackupNoti);
|
762
|
+
try {
|
763
|
+
loginHelper(appstate, null, null, globalOptions, callback, prCallback)
|
764
|
+
}
|
765
|
+
catch (e) {
|
766
|
+
logger.Error(Language.ErrBackup);
|
767
|
+
process.exit(0);
|
768
|
+
}
|
769
|
+
}
|
770
|
+
catch (e) {
|
771
|
+
return logger.Error();
|
772
|
+
}
|
773
|
+
}
|
774
|
+
|
775
|
+
/!-[ function loginHelper ]-!/
|
776
|
+
|
777
|
+
/**
|
778
|
+
* @param {string | any[]} appState
|
779
|
+
* @param {any} email
|
780
|
+
* @param {any} password
|
781
|
+
* @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
|
782
|
+
* @param {(arg0: any, arg1: undefined) => void} callback
|
783
|
+
* @param {(error: any, api: any) => any} [prCallback]
|
784
|
+
*/
|
785
|
+
|
786
|
+
function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
787
|
+
var mainPromise = null;
|
788
|
+
var jar = utils.getJar();
|
789
|
+
|
790
|
+
try {
|
791
|
+
if (appState) {
|
792
|
+
logger.Normal(Language.OnProcess);
|
793
|
+
switch (Database().has("FBKEY")) {
|
794
|
+
case true: {
|
795
|
+
process.env.FBKEY = Database().get("FBKEY");
|
796
|
+
}
|
797
|
+
break;
|
798
|
+
case false: {
|
799
|
+
const SecurityKey = global.Fca.Require.Security.create().apiKey;
|
800
|
+
process.env['FBKEY'] = SecurityKey;
|
801
|
+
Database().set('FBKEY', SecurityKey);
|
802
|
+
}
|
803
|
+
break;
|
804
|
+
default: {
|
805
|
+
const SecurityKey = global.Fca.Require.Security.create().apiKey;
|
806
|
+
process.env['FBKEY'] = SecurityKey;
|
807
|
+
Database().set('FBKEY', SecurityKey);
|
808
|
+
}
|
809
|
+
}
|
810
|
+
try {
|
811
|
+
switch (global.Fca.Require.FastConfig.EncryptFeature) {
|
812
|
+
case true: {
|
813
|
+
appState = JSON.parse(JSON.stringify(appState, null, "\t"));
|
814
|
+
switch (utils.getType(appState)) {
|
815
|
+
case "Array": {
|
816
|
+
switch (utils.getType(appState[0])) {
|
817
|
+
case "Object": {
|
818
|
+
logger.Normal(Language.NotReadyToDecrypt);
|
819
|
+
}
|
820
|
+
break;
|
821
|
+
case "String": {
|
822
|
+
appState = Security(appState, process.env['FBKEY'], 'Decrypt');
|
823
|
+
logger.Normal(Language.DecryptSuccess);
|
824
|
+
}
|
825
|
+
break;
|
826
|
+
default: {
|
827
|
+
logger.Warning(Language.InvaildAppState);
|
828
|
+
process.exit(0)
|
829
|
+
}
|
830
|
+
}
|
831
|
+
}
|
832
|
+
break;
|
833
|
+
default: {
|
834
|
+
logger.Warning(Language.InvaildAppState);
|
835
|
+
process.exit(0)
|
836
|
+
}
|
837
|
+
}
|
838
|
+
}
|
839
|
+
break;
|
840
|
+
case false: {
|
841
|
+
switch (utils.getType(appState)) {
|
842
|
+
case "Array": {
|
843
|
+
switch (utils.getType(appState[0])) {
|
844
|
+
case "Object": {
|
845
|
+
logger.Normal(Language.EncryptStateOff);
|
846
|
+
}
|
847
|
+
break;
|
848
|
+
case "String": {
|
849
|
+
appState = Security(appState, process.env['FBKEY'], 'Decrypt');
|
850
|
+
logger.Normal(Language.EncryptStateOff);
|
851
|
+
logger.Normal(Language.DecryptSuccess);
|
852
|
+
}
|
853
|
+
break;
|
854
|
+
default: {
|
855
|
+
logger.Warning(Language.InvaildAppState);
|
856
|
+
process.exit(0)
|
857
|
+
}
|
858
|
+
}
|
859
|
+
}
|
860
|
+
break;
|
861
|
+
default: {
|
862
|
+
logger.Warning(Language.InvaildAppState);
|
863
|
+
process.exit(0)
|
864
|
+
}
|
865
|
+
}
|
866
|
+
}
|
867
|
+
break;
|
868
|
+
default: {
|
869
|
+
logger.Warning(getText(Language.IsNotABoolean, global.Fca.Require.FastConfig.EncryptFeature))
|
870
|
+
process.exit(0);
|
871
|
+
}
|
872
|
+
}
|
873
|
+
}
|
874
|
+
catch (e) {
|
875
|
+
console.log(e);
|
876
|
+
}
|
877
|
+
|
878
|
+
try {
|
879
|
+
appState = JSON.parse(appState);
|
880
|
+
}
|
881
|
+
catch (e) {
|
882
|
+
try {
|
883
|
+
appState = appState;
|
884
|
+
}
|
885
|
+
catch (e) {
|
886
|
+
return logger.Error();
|
887
|
+
}
|
888
|
+
}
|
889
|
+
try {
|
890
|
+
global.Fca.Data.AppState = appState;
|
891
|
+
appState.map(function(/** @type {{ key: string; value: string; expires: string; domain: string; path: string; }} */c) {
|
892
|
+
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
893
|
+
jar.setCookie(str, "http://" + c.domain);
|
894
|
+
});
|
895
|
+
Database().set('Backup', appState);
|
896
|
+
mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
|
897
|
+
}
|
898
|
+
catch (e) {
|
899
|
+
try {
|
900
|
+
if (Database().has('Backup')) {
|
901
|
+
return backup(Database().get('Backup'), globalOptions, callback, prCallback);
|
902
|
+
}
|
903
|
+
else {
|
904
|
+
logger.Warning(Language.ErrBackup);
|
905
|
+
process.exit(0);
|
906
|
+
}
|
907
|
+
}
|
908
|
+
catch (e) {
|
909
|
+
logger.Warning(Language.ErrBackup);
|
910
|
+
process.exit(0);
|
911
|
+
}
|
912
|
+
}
|
913
|
+
}
|
914
|
+
|
915
|
+
else {
|
916
|
+
mainPromise = utils
|
917
|
+
.get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
|
918
|
+
.then(utils.saveCookies(jar))
|
919
|
+
.then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
|
920
|
+
.then(function() {
|
921
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
|
922
|
+
});
|
923
|
+
}
|
924
|
+
} catch (e) {
|
925
|
+
console.log(e);
|
926
|
+
}
|
927
|
+
|
928
|
+
|
929
|
+
var ctx, api;
|
930
|
+
mainPromise = mainPromise
|
931
|
+
.then(function(res) {
|
932
|
+
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/, redirect = reg.exec(res.body);
|
933
|
+
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
|
934
|
+
return res;
|
935
|
+
})
|
936
|
+
.then(function(res) {
|
937
|
+
var html = res.body, Obj = buildAPI(globalOptions, html, jar);
|
938
|
+
ctx = Obj.ctx;
|
939
|
+
api = Obj.api;
|
940
|
+
process.env.api = Obj.api;
|
941
|
+
return res;
|
942
|
+
});
|
943
|
+
if (globalOptions.pageID) {
|
944
|
+
mainPromise = mainPromise
|
945
|
+
.then(function() {
|
946
|
+
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
947
|
+
})
|
948
|
+
.then(function(resData) {
|
949
|
+
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
950
|
+
url = url.substring(0, url.length - 1);
|
951
|
+
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
952
|
+
});
|
953
|
+
}
|
954
|
+
mainPromise
|
955
|
+
.then(async () => {
|
956
|
+
logger.Normal(getText(Language.LocalVersion, global.Fca.Version));
|
957
|
+
logger.Normal(getText(Language.CountTime, global.Fca.Data.CountTime()))
|
958
|
+
logger.Normal(Language.WishMessage[Math.floor(Math.random() * Language.WishMessage.length)]);
|
959
|
+
require('./Extra/ExtraUptimeRobot')();
|
960
|
+
callback(null, api);
|
961
|
+
}).catch(function(/** @type {{ error: any; }} */e) {
|
962
|
+
log.error("login", e.error || e);
|
963
|
+
callback(e);
|
964
|
+
});
|
965
|
+
}
|
966
|
+
|
967
|
+
/**
|
968
|
+
* It asks the user for their account and password, and then saves it to the database.
|
969
|
+
*/
|
970
|
+
|
971
|
+
function setUserNameAndPassWord() {
|
972
|
+
let rl = readline.createInterface({
|
973
|
+
input: process.stdin,
|
974
|
+
output: process.stdout
|
975
|
+
});
|
976
|
+
|
977
|
+
console.clear();
|
978
|
+
console.log(figlet.textSync('Zeid', { font: 'ANSI Shadow', horizontalLayout: 'default', verticalLayout: 'default', width: 0, whitespaceBreak: true }));
|
979
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Operating System: " + chalk.bold.red(os.type()));
|
980
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Machine Version: " + chalk.bold.red(os.version()));
|
981
|
+
console.log(chalk.bold.hex('#9900FF')("[</>]") + chalk.bold.yellow(' => ') + "Fca Version: " + chalk.bold.red(global.Fca.Version) + '\n');
|
982
|
+
try {
|
983
|
+
rl.question(Language.TypeAccount, (Account) => {
|
984
|
+
if (!Account.includes("@") && global.Fca.Require.utils.getType(parseInt(Account)) != "Number") return logger.Normal(Language.TypeAccountError, function() { process.exit(1) }); //Very Human
|
985
|
+
else rl.question(Language.TypePassword, function(Password) {
|
986
|
+
rl.close();
|
987
|
+
try {
|
988
|
+
Database().set("Account", Account);
|
989
|
+
Database().set("Password", Password);
|
990
|
+
}
|
991
|
+
catch (e) {
|
992
|
+
logger.Warning(Language.ErrDataBase);
|
993
|
+
logger.Error();
|
994
|
+
process.exit(0);
|
995
|
+
}
|
996
|
+
if (global.Fca.Require.FastConfig.ResetDataLogin) {
|
997
|
+
global.Fca.Require.FastConfig.ResetDataLogin = false;
|
998
|
+
global.Fca.Require.fs.writeFileSync(process.cwd() + '/ConfigFca.json', JSON.stringify(global.Fca.Require.FastConfig, null, 4));
|
999
|
+
}
|
1000
|
+
logger.Success(Language.SuccessSetData);
|
1001
|
+
process.exit(1);
|
1002
|
+
});
|
1003
|
+
})
|
1004
|
+
}
|
1005
|
+
catch (e) {
|
1006
|
+
logger.Error(e)
|
1007
|
+
}
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
/**
|
1011
|
+
* @param {{ email: any; password: any; appState: any; }} loginData
|
1012
|
+
* @param {{}} options
|
1013
|
+
* @param {(error: any, api: any) => any} callback
|
1014
|
+
*/
|
1015
|
+
|
1016
|
+
function login(loginData, options, callback) {
|
1017
|
+
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
1018
|
+
callback = options;
|
1019
|
+
options = {};
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
var globalOptions = {
|
1023
|
+
selfListen: false,
|
1024
|
+
listenEvents: true,
|
1025
|
+
listenTyping: false,
|
1026
|
+
updatePresence: false,
|
1027
|
+
forceLogin: false,
|
1028
|
+
autoMarkDelivery: false,
|
1029
|
+
autoMarkRead: false,
|
1030
|
+
autoReconnect: true,
|
1031
|
+
logRecordSize: 100,
|
1032
|
+
online: false,
|
1033
|
+
emitReady: false,
|
1034
|
+
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"
|
1035
|
+
};
|
1036
|
+
|
1037
|
+
var prCallback = null;
|
1038
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
1039
|
+
var rejectFunc = null;
|
1040
|
+
var resolveFunc = null;
|
1041
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
1042
|
+
resolveFunc = resolve;
|
1043
|
+
rejectFunc = reject;
|
1044
|
+
});
|
1045
|
+
prCallback = function(error, api) {
|
1046
|
+
if (error) return rejectFunc(error);
|
1047
|
+
return resolveFunc(api);
|
1048
|
+
};
|
1049
|
+
callback = prCallback;
|
1050
|
+
}
|
1051
|
+
|
1052
|
+
if (loginData.email && loginData.password) {
|
1053
|
+
setOptions(globalOptions, {
|
1054
|
+
logLevel: "silent",
|
1055
|
+
forceLogin: true,
|
1056
|
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
|
1057
|
+
});
|
1058
|
+
loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1059
|
+
}
|
1060
|
+
else if (loginData.appState) {
|
1061
|
+
setOptions(globalOptions, options);
|
1062
|
+
let All = (getAll()).filter(i => i.data.messageCount !== undefined);
|
1063
|
+
if (All.length >= 1) {
|
1064
|
+
deleteAll(All.map(obj => obj.data.threadID));
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
switch (global.Fca.Require.FastConfig.AutoLogin) {
|
1068
|
+
case true: {
|
1069
|
+
if (global.Fca.Require.FastConfig.ResetDataLogin) return setUserNameAndPassWord();
|
1070
|
+
else {
|
1071
|
+
try {
|
1072
|
+
const TempState = Database().get("TempState")
|
1073
|
+
if (TempState) {
|
1074
|
+
try {
|
1075
|
+
loginData.appState = JSON.parse(TempState);
|
1076
|
+
}
|
1077
|
+
catch (_) {
|
1078
|
+
loginData.appState = TempState;
|
1079
|
+
}
|
1080
|
+
Database().delete("TempState");
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
catch (e) {
|
1084
|
+
console.log(e)
|
1085
|
+
Database().delete("TempState");
|
1086
|
+
logger.Warning(Language.ErrDataBase);
|
1087
|
+
logger.Error();
|
1088
|
+
process.exit(0);
|
1089
|
+
}
|
1090
|
+
try {
|
1091
|
+
if (Database().has('Account') && Database().has('Password')) return loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1092
|
+
else return setUserNameAndPassWord();
|
1093
|
+
}
|
1094
|
+
catch (e) {
|
1095
|
+
console.log(e)
|
1096
|
+
logger.Warning(Language.ErrDataBase);
|
1097
|
+
logger.Error();
|
1098
|
+
process.exit(0);
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
}
|
1102
|
+
case false: {
|
1103
|
+
return loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
1104
|
+
}
|
1105
|
+
}
|
1106
|
+
}
|
1107
|
+
return returnPromise;
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
module.exports = login;
|