fca-arif-babu 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.upm/store.json +1 -0
- package/ARIF-FCA.json +4 -0
- package/CHANGELOG.md +2 -0
- package/{LICENSE.txt → LICENSE-MIT} +6 -6
- package/README.md +0 -4
- package/index.js +511 -414
- package/package.json +370 -86
- package/test/data/something.mov +1 -1
- package/utils.js +1393 -2918
- package/Extra/Balancer.js +0 -49
- package/Extra/Bypass/956/index.js +0 -234
- package/Extra/Bypass/test/aaaa.json +0 -169
- package/Extra/Bypass/test/index.js +0 -188
- package/Extra/Database/index.js +0 -469
- package/Extra/ExtraAddons.js +0 -82
- package/Extra/ExtraFindUID.js +0 -62
- package/Extra/ExtraGetThread.js +0 -365
- package/Extra/ExtraScreenShot.js +0 -430
- package/Extra/ExtraUptimeRobot.js +0 -38
- package/Extra/Html/Classic/script.js +0 -119
- package/Extra/Html/Classic/style.css +0 -8
- package/Extra/Security/AES_256_GCM/index.js +0 -1
- package/Extra/Security/Base/Step_1.js +0 -6
- package/Extra/Security/Base/Step_2.js +0 -22
- package/Extra/Security/Base/Step_3.js +0 -22
- package/Extra/Security/Base/index.js +0 -191
- package/Extra/Security/Step_1.js +0 -6
- package/Extra/Security/Step_2.js +0 -22
- package/Extra/Security/Step_3.js +0 -22
- package/Extra/Security/index.js +0 -5
- package/Extra/Src/Change_Environment.js +0 -24
- package/Extra/Src/Check_Update.js +0 -67
- package/Extra/Src/History.js +0 -115
- package/Extra/Src/Instant_Update.js +0 -65
- package/Extra/Src/Last-Run.js +0 -65
- package/Extra/Src/Premium.js +0 -81
- package/Extra/Src/Release_Memory.js +0 -160
- package/Extra/Src/Websocket.js +0 -213
- package/Extra/Src/image/62518eafb0670b697788ce4f9a4f71d1.jpg +0 -0
- package/Extra/Src/test.js +0 -28
- package/Extra/Src/uuid.js +0 -137
- package/Func/AcceptAgreement.js +0 -31
- package/Func/ClearCache.js +0 -64
- package/Func/ReportV1.js +0 -54
- package/Language/index.json +0 -228
- package/Main.js +0 -1290
- package/SECURITY.md +0 -17
- package/broadcast.js +0 -44
- package/logger.js +0 -66
- package/test/env/.env +0 -1
- package/test/testv2.js +0 -3
package/index.js
CHANGED
@@ -1,448 +1,545 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
const utils = require(
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("./utils");
|
4
|
+
const log = require("npmlog");
|
5
|
+
const fs = require('fs');
|
6
|
+
const path = require('path');
|
7
|
+
|
8
|
+
let checkVerified = null;
|
9
|
+
|
10
|
+
const defaultLogRecordSize = 100;
|
11
|
+
log.maxRecordSize = defaultLogRecordSize;
|
12
|
+
|
13
|
+
function setOptions(globalOptions, options) {
|
14
|
+
Object.keys(options).map(function (key) {
|
15
|
+
switch (key) {
|
16
|
+
case 'online':
|
17
|
+
globalOptions.online = Boolean(options.online);
|
18
|
+
break;
|
19
|
+
case 'logLevel':
|
20
|
+
log.level = options.logLevel;
|
21
|
+
globalOptions.logLevel = options.logLevel;
|
22
|
+
break;
|
23
|
+
case 'logRecordSize':
|
24
|
+
log.maxRecordSize = options.logRecordSize;
|
25
|
+
globalOptions.logRecordSize = options.logRecordSize;
|
26
|
+
break;
|
27
|
+
case 'selfListen':
|
28
|
+
globalOptions.selfListen = Boolean(options.selfListen);
|
29
|
+
break;
|
30
|
+
case 'selfListenEvent':
|
31
|
+
globalOptions.selfListenEvent = options.selfListenEvent;
|
32
|
+
break;
|
33
|
+
case 'listenEvents':
|
34
|
+
globalOptions.listenEvents = Boolean(options.listenEvents);
|
35
|
+
break;
|
36
|
+
case 'pageID':
|
37
|
+
globalOptions.pageID = options.pageID.toString();
|
38
|
+
break;
|
39
|
+
case 'updatePresence':
|
40
|
+
globalOptions.updatePresence = Boolean(options.updatePresence);
|
41
|
+
break;
|
42
|
+
case 'forceLogin':
|
43
|
+
globalOptions.forceLogin = Boolean(options.forceLogin);
|
44
|
+
break;
|
45
|
+
case 'userAgent':
|
46
|
+
globalOptions.userAgent = options.userAgent;
|
47
|
+
break;
|
48
|
+
case 'autoMarkDelivery':
|
49
|
+
globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
|
50
|
+
break;
|
51
|
+
case 'autoMarkRead':
|
52
|
+
globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
|
53
|
+
break;
|
54
|
+
case 'listenTyping':
|
55
|
+
globalOptions.listenTyping = Boolean(options.listenTyping);
|
56
|
+
break;
|
57
|
+
case 'proxy':
|
58
|
+
if (typeof options.proxy != "string") {
|
59
|
+
delete globalOptions.proxy;
|
60
|
+
utils.setProxy();
|
61
|
+
} else {
|
62
|
+
globalOptions.proxy = options.proxy;
|
63
|
+
utils.setProxy(globalOptions.proxy);
|
64
|
+
}
|
65
|
+
break;
|
66
|
+
case 'autoReconnect':
|
67
|
+
globalOptions.autoReconnect = Boolean(options.autoReconnect);
|
68
|
+
break;
|
69
|
+
case 'emitReady':
|
70
|
+
globalOptions.emitReady = Boolean(options.emitReady);
|
71
|
+
break;
|
72
|
+
default:
|
73
|
+
log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
//new update...
|
80
|
+
const configPath = process.cwd() + "/ARIF-FCA.json";
|
81
|
+
let bypassEnabled = false;
|
82
|
+
let autoRefreshEnabled = false;
|
83
|
+
|
84
|
+
if (!fs.existsSync(configPath)) {
|
85
|
+
const defaultConfig = {
|
86
|
+
BypassAutomationBehavior: true,
|
87
|
+
AutoRefreshFbDtsg: true,
|
88
|
+
};
|
89
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 4), "utf8");
|
90
|
+
}
|
91
|
+
|
92
|
+
try {
|
93
|
+
const config = require(configPath);
|
94
|
+
bypassEnabled = config.BypassAutomationBehavior || false;
|
95
|
+
autoRefreshEnabled = config.AutoRefreshFbDtsg || false;
|
96
|
+
} catch (error) {
|
97
|
+
bypassEnabled = false;
|
98
|
+
autoRefreshEnabled = false;
|
99
|
+
}
|
100
|
+
|
101
|
+
function BypassAutomationBehavior(resp, jar, globalOptions, appstate, ID) {
|
102
|
+
if (!bypassEnabled) {
|
103
|
+
log.info("login", "Bypass Currently Disabled.");
|
104
|
+
return resp;
|
105
|
+
} else {
|
106
|
+
log.info("login", "Bypass Currently Enabled.");
|
107
|
+
}
|
108
|
+
|
109
|
+
try {
|
110
|
+
let UID;
|
111
|
+
if (ID) UID = ID
|
112
|
+
else {
|
113
|
+
UID = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
|
114
|
+
UID = UID.value;
|
115
|
+
}
|
116
|
+
if (resp !== undefined) {
|
117
|
+
if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
118
|
+
if (resp.request.uri.href.includes('601051028565049')) {
|
119
|
+
const fb_dtsg = utils.getFrom(resp.body, '["DTSGInitData",[],{"token":"', '","');
|
120
|
+
const jazoest = utils.getFrom(resp.body, 'jazoest=', '",');
|
121
|
+
const lsd = utils.getFrom(resp.body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
122
|
+
|
123
|
+
const FormBypass = {
|
124
|
+
av: UID,
|
125
|
+
fb_dtsg, jazoest, lsd,
|
126
|
+
fb_api_caller_class: "RelayModern",
|
127
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
128
|
+
variables: JSON.stringify({}),
|
129
|
+
server_timestamps: true,
|
130
|
+
doc_id: 6339492849481770
|
131
|
+
}
|
132
|
+
return utils.post("https://www.facebook.com/api/graphql/", jar, FormBypass, globalOptions)
|
133
|
+
.then(utils.saveCookies(jar)).then(function(res) {
|
134
|
+
log.warn("login", "Checkpoint detected. Bypass done...");
|
135
|
+
return process.exit(1);
|
136
|
+
});
|
87
137
|
}
|
88
|
-
|
89
|
-
|
90
|
-
hours = 0;
|
138
|
+
else {
|
139
|
+
return resp;
|
91
140
|
}
|
92
141
|
}
|
93
142
|
else {
|
94
|
-
|
143
|
+
return resp
|
95
144
|
}
|
96
|
-
return `${hours} Hours`;
|
97
145
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
});
|
120
|
-
}
|
121
|
-
break;
|
122
|
-
case "Bypass": {
|
123
|
-
const Bypass_Module = require(`./Extra/Bypass/${Code}`);
|
124
|
-
const logger = global.Fca.Require.logger;
|
125
|
-
switch (Code) {
|
126
|
-
case 956: {
|
127
|
-
async function P1() {
|
128
|
-
return new Promise((resolve, reject) => {
|
129
|
-
try {
|
130
|
-
utils.get('https://www.facebook.com/checkpoint/828281030927956/?next=https%3A%2F%2Faccountscenter.facebook.com%2Fpassword_and_security', ctx.jar, null, ctx.globalOptions).then(function(data) {
|
131
|
-
resolve(Bypass_Module.Check(data.body));
|
132
|
-
})
|
133
|
-
}
|
134
|
-
catch (error) {
|
135
|
-
reject(error);
|
136
|
-
}
|
137
|
-
})
|
138
|
-
}
|
139
|
-
try {
|
140
|
-
const test = await P1();
|
141
|
-
if (test != null && test != '' && test != undefined) {
|
142
|
-
const resp = await Bypass_Module.Cook_And_Work(ctx, defaultFuncs)
|
143
|
-
if (resp == true) return logger.Success("Bypassing 956 successfully!", function() { return process.exit(1); })
|
144
|
-
else return logger.Error("Bypass 956 failed ! DO YOUR SELF :>", function() { process.exit(0) });
|
145
|
-
}
|
146
|
-
}
|
147
|
-
catch (e) {
|
148
|
-
logger.Error("Bypass 956 failed ! DO YOUR SELF :>", function() { process.exit(0) })
|
149
|
-
}
|
146
|
+
else {
|
147
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(function(res) {
|
148
|
+
if (res.request.uri && res.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
149
|
+
if (res.request.uri.href.includes('601051028565049')) return { Status: true, Body: res.body }
|
150
|
+
else return { Status: false, Body: res.body }
|
151
|
+
}
|
152
|
+
else return { Status: false, Body: res.body }
|
153
|
+
}).then(function(res) {
|
154
|
+
if (res.Status === true) {
|
155
|
+
const fb_dtsg = utils.getFrom(res.Body, '["DTSGInitData",[],{"token":"', '","');
|
156
|
+
const jazoest = utils.getFrom(res.Body, 'jazoest=', '",');
|
157
|
+
const lsd = utils.getFrom(res.Body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
158
|
+
|
159
|
+
const FormBypass = {
|
160
|
+
av: UID,
|
161
|
+
fb_dtsg, jazoest, lsd,
|
162
|
+
fb_api_caller_class: "RelayModern",
|
163
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
164
|
+
variables: JSON.stringify({}),
|
165
|
+
server_timestamps: true,
|
166
|
+
doc_id: 6339492849481770
|
150
167
|
}
|
168
|
+
return utils.post("https://www.facebook.com/api/graphql/", jar, FormBypass, globalOptions).then(utils.saveCookies(jar))
|
169
|
+
.then(res => {
|
170
|
+
log.warn("login", "Checkpoint detected. Bypass done.....");
|
171
|
+
return res
|
172
|
+
})
|
151
173
|
}
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
174
|
+
else return res;
|
175
|
+
|
176
|
+
})
|
177
|
+
.then(function(res) {
|
178
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar))
|
179
|
+
})
|
180
|
+
.then(function(res) {
|
181
|
+
return process.exit(1)
|
182
|
+
})
|
157
183
|
}
|
158
184
|
}
|
159
|
-
|
185
|
+
catch (e) {
|
186
|
+
console.log(e)
|
187
|
+
}
|
188
|
+
}
|
160
189
|
|
161
|
-
|
162
|
-
|
163
|
-
let String_Fca = ["MainName","PreKey","Language","AuthString","Config"]
|
164
|
-
let Number_Fca = ["AutoRestartMinutes","RestartMQTT_Minutes"];
|
165
|
-
let Object_Fca = ["HTML","Stable_Version","AntiGetInfo","Websocket_Extension", "CheckPointBypass", "AntiStuckAndMemoryLeak"];
|
166
|
-
let All_Variable = Boolean_Fca.concat(String_Fca,Number_Fca,Object_Fca);
|
190
|
+
function buildAPI(globalOptions, html, jar) {
|
191
|
+
const fb_dtsg = utils.getFroms(html, '["DTSGInitData",[],{"token":"', '","')[0]; //my brain is not braining on here.
|
167
192
|
|
193
|
+
const maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(val) {
|
194
|
+
return val.cookieString().split("=")[0] === "c_user";
|
195
|
+
});
|
168
196
|
|
169
|
-
if (
|
170
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ArifFca.json", JSON.stringify(global.Fca.Data.ObjArif, null, "\t"));
|
171
|
-
process.exit(1);
|
172
|
-
}
|
197
|
+
if (maybeCookie.length === 0) throw { error: "Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify." };
|
173
198
|
|
174
|
-
|
175
|
-
var Data_Setting = require(process.cwd() + "/ArifFca.json");
|
176
|
-
}
|
177
|
-
catch (e) {
|
178
|
-
global.Fca.Require.logger.Error('Detect Your ArifFca Settings Invalid!, Carry out default restoration');
|
179
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ArifFca.json", JSON.stringify(global.Fca.Data.ObjArif, null, "\t"));
|
180
|
-
process.exit(1)
|
181
|
-
}
|
182
|
-
if (global.Fca.Require.fs.existsSync(process.cwd() + '/ArifFca.json')) {
|
183
|
-
|
184
|
-
for (let i of All_Variable) {
|
185
|
-
if (Data_Setting[i] == undefined) {
|
186
|
-
Data_Setting[i] = global.Fca.Data.ObjArif[i];
|
187
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ArifFca.json", JSON.stringify(Data_Setting, null, "\t"));
|
188
|
-
}
|
189
|
-
else continue;
|
190
|
-
} //Check Variable
|
199
|
+
if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
|
191
200
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
else if (Object_Fca.includes(i)) {
|
206
|
-
if (global.Fca.Require.utils.getType(Data_Setting[i]) != "Object") {
|
207
|
-
Data_Setting[i] = global.Fca.Data.ObjArif[i];
|
208
|
-
global.Fca.Require.fs.writeFileSync(process.cwd() + "/ArifFca.json", JSON.stringify(Data_Setting, null, "\t"));
|
209
|
-
}
|
210
|
-
else continue;
|
211
|
-
}
|
201
|
+
const userID = maybeCookie[0].cookieString().split("=")[1].toString();
|
202
|
+
log.info("login", `Logged in as ${userID}`);
|
203
|
+
|
204
|
+
try {
|
205
|
+
clearInterval(checkVerified);
|
206
|
+
} catch (_) { }
|
207
|
+
|
208
|
+
const clientID = (Math.random() * 2147483648 | 0).toString(16);
|
209
|
+
|
210
|
+
const CHECK_MQTT = {
|
211
|
+
oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
|
212
|
+
newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
|
213
|
+
legacyFBMQTTMatch: html.match(/\["MqttWebConfig",\[\],{"fbid":"(.*?)","appID":219994525426954,"endpoint":"(.*?)","pollingEndpoint":"(.*?)"/)
|
212
214
|
}
|
213
215
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
216
|
+
// all available regions =))
|
217
|
+
/**
|
218
|
+
* PRN = Pacific Northwest Region
|
219
|
+
* VLL = Valley Region
|
220
|
+
* ASH = Ashburn Region
|
221
|
+
* DFW = Dallas/Fort Worth Region
|
222
|
+
* LLA = Los Angeles Region
|
223
|
+
* FRA = Frankfurt
|
224
|
+
* SIN = Singapore
|
225
|
+
* NRT = Tokyo (Japan)
|
226
|
+
* HKG = Hong Kong
|
227
|
+
* SYD = Sydney
|
228
|
+
*/
|
229
|
+
|
230
|
+
let Slot = Object.keys(CHECK_MQTT);
|
231
|
+
var mqttEndpoint,region,irisSeqID;
|
232
|
+
Object.keys(CHECK_MQTT).map(function(MQTT) {
|
233
|
+
if (CHECK_MQTT[MQTT] && !region) {
|
234
|
+
switch (Slot.indexOf(MQTT)) {
|
235
|
+
case 0: {
|
236
|
+
irisSeqID = CHECK_MQTT[MQTT][1];
|
237
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/");
|
238
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
239
|
+
return;
|
240
|
+
}
|
241
|
+
case 1: {
|
242
|
+
irisSeqID = CHECK_MQTT[MQTT][2];
|
243
|
+
mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
|
244
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
case 2: {
|
248
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/"); //this really important.
|
249
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
250
|
+
return;
|
251
|
+
}
|
229
252
|
}
|
253
|
+
return;
|
230
254
|
}
|
231
|
-
}
|
255
|
+
});
|
232
256
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
257
|
+
const regions = [
|
258
|
+
{
|
259
|
+
code: "PRN",
|
260
|
+
name: "Pacific Northwest Region",
|
261
|
+
location: "Khu vực Tây Bắc Thái Bình Dương"
|
262
|
+
},
|
263
|
+
{
|
264
|
+
code: "VLL",
|
265
|
+
name: "Valley Region",
|
266
|
+
location: "Valley"
|
267
|
+
},
|
268
|
+
{
|
269
|
+
code: "ASH",
|
270
|
+
name: "Ashburn Region",
|
271
|
+
location: "Ashburn"
|
272
|
+
},
|
273
|
+
{
|
274
|
+
code: "DFW",
|
275
|
+
name: "Dallas/Fort Worth Region",
|
276
|
+
location: "Dallas/Fort Worth"
|
277
|
+
},
|
278
|
+
{
|
279
|
+
code: "LLA",
|
280
|
+
name: "Los Angeles Region",
|
281
|
+
location: "Los Angeles"
|
282
|
+
},
|
283
|
+
{
|
284
|
+
code: "FRA",
|
285
|
+
name: "Frankfurt",
|
286
|
+
location: "Frankfurt"
|
287
|
+
},
|
288
|
+
{
|
289
|
+
code: "SIN",
|
290
|
+
name: "Singapore",
|
291
|
+
location: "Singapore"
|
292
|
+
},
|
293
|
+
{
|
294
|
+
code: "NRT",
|
295
|
+
name: "Tokyo",
|
296
|
+
location: "Japan"
|
297
|
+
},
|
298
|
+
{
|
299
|
+
code: "HKG",
|
300
|
+
name: "Hong Kong",
|
301
|
+
location: "Hong Kong"
|
302
|
+
},
|
303
|
+
{
|
304
|
+
code: "SYD",
|
305
|
+
name: "Sydney",
|
306
|
+
location: "Sydney"
|
307
|
+
},
|
308
|
+
{
|
309
|
+
code: "PNB",
|
310
|
+
name: "Pacific Northwest - Beta",
|
311
|
+
location: "Pacific Northwest "
|
312
|
+
}
|
313
|
+
];
|
245
314
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
var Convert = require('ansi-to-html');
|
250
|
-
var convert = new Convert();
|
251
|
-
console.__log = console.log;
|
252
|
-
console.log = function (data) {
|
253
|
-
const log = convert.toHtml(data)
|
254
|
-
console.history.push(log)
|
255
|
-
console.__log.apply(console,arguments)
|
256
|
-
if (console.history.length > 80) {
|
257
|
-
console.history.shift();
|
315
|
+
if (!region) {
|
316
|
+
region = ['prn',"pnb","vll","hkg","sin"][Math.random()*5|0];
|
317
|
+
|
258
318
|
}
|
259
|
-
|
260
|
-
|
261
|
-
|
319
|
+
if (!mqttEndpoint) {
|
320
|
+
mqttEndpoint = "wss://edge-chat.facebook.com/chat?region=" + region;
|
321
|
+
}
|
322
|
+
log.info('login', `Server region ${region}`);
|
323
|
+
|
324
|
+
const Location = regions.find(r => r.code === region.toUpperCase());
|
325
|
+
|
326
|
+
const ctx = {
|
327
|
+
userID: userID,
|
328
|
+
jar: jar,
|
329
|
+
clientID: clientID,
|
330
|
+
globalOptions: globalOptions,
|
331
|
+
loggedIn: true,
|
332
|
+
access_token: 'NONE',
|
333
|
+
clientMutationId: 0,
|
334
|
+
mqttClient: undefined,
|
335
|
+
lastSeqId: irisSeqID,
|
336
|
+
syncToken: undefined,
|
337
|
+
mqttEndpoint: mqttEndpoint,
|
338
|
+
region: region,
|
339
|
+
firstListen: true,
|
340
|
+
req_ID: 0,
|
341
|
+
callback_Task: {},
|
342
|
+
fb_dtsg
|
343
|
+
};
|
262
344
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
login = require('./Main');
|
345
|
+
const api = {
|
346
|
+
setOptions: setOptions.bind(null, globalOptions),
|
347
|
+
getAppState: function getAppState() {
|
348
|
+
return utils.getAppState(jar);
|
268
349
|
}
|
269
|
-
|
270
|
-
console.log(e)
|
271
|
-
}
|
272
|
-
//const fs = require('fs-extra');
|
273
|
-
//const got = require('got');
|
274
|
-
//const log = require('npmlog');
|
275
|
-
//const { execSync } = require('child_process');
|
276
|
-
require('./Extra/Database');
|
350
|
+
};
|
277
351
|
|
278
|
-
|
279
|
-
return got.get('https://github.com/KanzuXHorizon/Global_Horizon/raw/main/InstantAction.json').then(async function(res) {
|
280
|
-
if (global.Fca.Require.FastConfig.AutoInstallNode) {
|
281
|
-
switch (fs.existsSync(process.cwd() + "/replit.nix") && process.env["REPL_ID"] != undefined) {
|
282
|
-
case true: {
|
283
|
-
await require('./Extra/Src/Change_Environment.js')();
|
284
|
-
break;
|
285
|
-
}
|
286
|
-
case false: {
|
287
|
-
const NodeVersion = execSync('node -v').toString().replace(/(\r\n|\n|\r)/gm, "");
|
288
|
-
if (!NodeVersion.includes("v14") && !NodeVersion.includes("v16") && !Database(true).has('SkipReplitNix')) {
|
289
|
-
log.warn("[ FCA-UPDATE ] •",global.Fca.getText(Language.NodeVersionNotSupported, NodeVersion));
|
290
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
291
|
-
try {
|
292
|
-
switch (process.platform) {
|
293
|
-
case "win32": {
|
294
|
-
try {
|
295
|
-
//check if user using nvm
|
296
|
-
if (fs.existsSync(process.env.APPDATA + "/nvm/nvm.exe")) {
|
297
|
-
log.warn("[ FCA-UPDATE ] •", Language.UsingNVM);
|
298
|
-
process.exit(0);
|
299
|
-
}
|
300
|
-
//download NodeJS v14 for Windows and slient install
|
301
|
-
await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-x64.msi').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-x64.msi"));
|
302
|
-
log.info("[ FCA-UPDATE ] •", Language.DownloadingNode);
|
303
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
304
|
-
execSync('msiexec /i node-v14.17.0-x64.msi /qn');
|
305
|
-
log.info("[ FCA-UPDATE ] •", Language.NodeDownloadingComplete);
|
306
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
307
|
-
log.info("[ FCA-UPDATE ] •", Language.RestartRequire);
|
308
|
-
Database(true).set("NeedRebuild", true);
|
309
|
-
process.exit(0);
|
310
|
-
}
|
311
|
-
catch (e) {
|
312
|
-
log.error("[ FCA-UPDATE ] •",Language.ErrNodeDownload);
|
313
|
-
process.exit(0);
|
314
|
-
}
|
315
|
-
}
|
316
|
-
case "linux": {
|
317
|
-
|
318
|
-
try {
|
319
|
-
if (process.env["REPL_ID"] != undefined) {
|
320
|
-
log.warn("[ FCA-UPDATE ] •", "Look like you are using Replit, and didn't have replit.nix file in your project, i don't know how to help you, hmm i will help you pass this step, but you need to install NodeJS v14 by yourself, and restart your repl");
|
321
|
-
Database(true).set('SkipReplitNix', true);
|
322
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
323
|
-
process.exit(1);
|
324
|
-
}
|
325
|
-
//check if user using nvm
|
326
|
-
if (fs.existsSync(process.env.HOME + "/.nvm/nvm.sh")) {
|
327
|
-
log.warn("[ FCA-UPDATE ] •", Language.UsingNVM);
|
328
|
-
process.exit(0);
|
329
|
-
}
|
330
|
-
//download NodeJS v14 for Linux and slient install
|
331
|
-
await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-linux-x64.tar.xz"));
|
332
|
-
log.info("[ FCA-UPDATE ] •", Language.DownloadingNode);
|
333
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
334
|
-
execSync('tar -xf node-v14.17.0-linux-x64.tar.xz');
|
335
|
-
execSync('cd node-v14.17.0-linux-x64');
|
336
|
-
execSync('sudo cp -R * /usr/local/');
|
337
|
-
log.info("[ FCA-UPDATE ] •", Language.NodeDownloadingComplete);
|
338
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
339
|
-
log.info("[ FCA-UPDATE ] •",Language.RestartingN);
|
340
|
-
Database(true).set("NeedRebuild", true);
|
341
|
-
process.exit(1);
|
342
|
-
}
|
343
|
-
catch (e) {
|
344
|
-
log.error("[ FCA-UPDATE ] •",Language.ErrNodeDownload);
|
345
|
-
process.exit(0);
|
346
|
-
}
|
347
|
-
}
|
348
|
-
case "darwin": {
|
349
|
-
try {
|
350
|
-
//check if user using nvm
|
351
|
-
if (fs.existsSync(process.env.HOME + "/.nvm/nvm.sh")) {
|
352
|
-
log.warn("[ FCA-UPDATE ] •", Language.UsingNVM);
|
353
|
-
process.exit(0);
|
354
|
-
}
|
355
|
-
//download NodeJS v14 for MacOS and slient install
|
356
|
-
await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-darwin-x64.tar.gz').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-darwin-x64.tar.gz"));
|
357
|
-
log.info("[ FCA-UPDATE ] •", Language.DownloadingNode);
|
358
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
359
|
-
execSync('tar -xf node-v14.17.0-darwin-x64.tar.gz');
|
360
|
-
execSync('cd node-v14.17.0-darwin-x64');
|
361
|
-
execSync('sudo cp -R * /usr/local/');
|
362
|
-
log.info("[ FCA-UPDATE ] •", Language.NodeDownloadingComplete);
|
363
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
364
|
-
log.info("[ FCA-UPDATE ] •",Language.RestartingN);
|
365
|
-
Database(true).set("NeedRebuild", true);
|
366
|
-
process.exit(1);
|
367
|
-
}
|
368
|
-
catch (e) {
|
369
|
-
log.error("[ FCA-UPDATE ] •",Language.ErrNodeDownload);
|
370
|
-
process.exit(0);
|
371
|
-
}
|
372
|
-
}
|
373
|
-
}
|
374
|
-
}
|
375
|
-
catch (e) {
|
376
|
-
console.log(e);
|
377
|
-
log.error("[ FCA-UPDATE ] •","NodeJS v14 Installation Failed, Please Try Again and Contact fb.com/Lazic.Kanzu!");
|
378
|
-
process.exit(0);
|
379
|
-
}
|
380
|
-
}
|
381
|
-
}
|
382
|
-
}
|
352
|
+
if (region && mqttEndpoint) {
|
383
353
|
}
|
384
|
-
|
385
|
-
|
386
|
-
log.info("[ FCA-UPDATE ] •",Language.Rebuilding);
|
387
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
388
|
-
try {
|
389
|
-
execSync('npm rebuild', {stdio: 'inherit'});
|
354
|
+
else {
|
355
|
+
if (bypass_region) {
|
390
356
|
}
|
391
|
-
|
392
|
-
|
393
|
-
log.error("[ FCA-UPDATE ] •",Language.ErrRebuilding);
|
357
|
+
else {
|
358
|
+
api["htmlData"] = html;
|
394
359
|
}
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
}
|
360
|
+
};
|
361
|
+
// if (noMqttData) api["htmlData"] = noMqttData;
|
362
|
+
|
363
|
+
const defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
400
364
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
365
|
+
require('fs').readdirSync(__dirname + '/src/')
|
366
|
+
.filter((v) => v.endsWith('.js'))
|
367
|
+
.map((v) => {
|
368
|
+
const functionName = v.replace('.js', '');
|
369
|
+
api[functionName] = require('./src/' + v)(defaultFuncs, api, ctx);
|
370
|
+
});
|
371
|
+
|
372
|
+
//fix this error "Please try closing and re-opening your browser window" by automatically refreshing Fb_dtsg Between 48hr or less Automatically!
|
373
|
+
function scheduleRefresh() {
|
374
|
+
if (!autoRefreshEnabled) {
|
375
|
+
log.info("login", "Automatic refresh is Disabled");
|
376
|
+
|
377
|
+
|
378
|
+
return;
|
379
|
+
}
|
380
|
+
log.info("login", "Automatic refresh is Enabled");
|
381
|
+
|
382
|
+
const interval = Math.random() * 172800000;
|
383
|
+
setTimeout(() => {
|
384
|
+
api.refreshFb_dtsg()
|
385
|
+
.then(() => log.warn("login", "Fb_dtsg refreshed successfully."))
|
386
|
+
.catch((err) =>
|
387
|
+
log.error("login", "Error during Fb_dtsg refresh:", err)
|
388
|
+
)
|
389
|
+
.finally(scheduleRefresh);
|
390
|
+
}, interval);
|
391
|
+
}
|
392
|
+
|
393
|
+
scheduleRefresh();
|
394
|
+
|
395
|
+
return {
|
396
|
+
ctx: ctx,
|
397
|
+
defaultFuncs: defaultFuncs,
|
398
|
+
api: api
|
399
|
+
};
|
400
|
+
}
|
401
|
+
|
402
|
+
// unfortunately login via credentials no longer works,so instead of login via credentials, use login via appstate intead.
|
403
|
+
function loginHelper(appState, email, password, globalOptions, callback, prCallback ) {
|
404
|
+
let mainPromise = null;
|
405
|
+
const jar = utils.getJar();
|
406
|
+
|
407
|
+
// If we're given an appState we loop through it and save each cookie
|
408
|
+
// back into the jar.
|
409
|
+
if (appState) {
|
410
|
+
appState.map(function (c) {
|
411
|
+
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
412
|
+
jar.setCookie(str, "http://" + c.domain);
|
413
|
+
});
|
414
|
+
|
415
|
+
// Load the main page.
|
416
|
+
mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, {
|
417
|
+
noRef: true })
|
418
|
+
.then(utils.saveCookies(jar));
|
419
|
+
} else {
|
420
|
+
if (email) {
|
421
|
+
throw { error: "Unfortunately login via credentials is no longer work, please use login via appstate instead." };
|
422
|
+
}
|
423
|
+
else {
|
424
|
+
throw { error: "Please provide appstate." };
|
425
|
+
}
|
426
|
+
}
|
427
|
+
|
428
|
+
function CheckAndFixErr(res, fastSwitch) {
|
429
|
+
if (fastSwitch) return res;
|
430
|
+
let reg_antierr = /7431627028261359627/gs; // :>
|
431
|
+
if (reg_antierr.test(res.body)) {
|
432
|
+
const Data = JSON.stringify(res.body);
|
433
|
+
const Dt_Check = Data.split('2Fhome.php&gfid=')[1];
|
434
|
+
if (Dt_Check == undefined) return res
|
435
|
+
const fid = Dt_Check.split("\\\\")[0];//fix
|
436
|
+
if (Dt_Check == undefined || Dt_Check == "") return res
|
437
|
+
const final_fid = fid.split(`\\`)[0];
|
438
|
+
if (final_fid == undefined || final_fid == '') return res;
|
439
|
+
const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
|
440
|
+
bypass_region_err = true;
|
441
|
+
return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
|
416
442
|
}
|
417
|
-
else
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
443
|
+
else return res
|
444
|
+
}
|
445
|
+
|
446
|
+
function Redirect(res,fastSwitch) {
|
447
|
+
if (fastSwitch) return res;
|
448
|
+
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
449
|
+
redirect = reg.exec(res.body);
|
450
|
+
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions)
|
451
|
+
return res;
|
452
|
+
}
|
453
|
+
|
454
|
+
let redirect = [1, "https://m.facebook.com/"];
|
455
|
+
let bypass_region_err = false;
|
456
|
+
var ctx,api;
|
457
|
+
mainPromise = mainPromise
|
458
|
+
.then(res => Redirect(res))
|
459
|
+
.then(res => CheckAndFixErr(res))
|
460
|
+
//fix via login with defaut UA return WWW.facebook.com not m.facebook.com
|
461
|
+
.then(function(res) {
|
462
|
+
if (global.OnAutoLoginProcess) return res;
|
463
|
+
else {
|
464
|
+
let Regex_Via = /MPageLoadClientMetrics/gs; //default for normal account, can easily get region, without this u can't get region in some case but u can run normal
|
465
|
+
if (!Regex_Via.test(res.body)) {
|
466
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
|
467
|
+
}
|
468
|
+
else return res
|
423
469
|
}
|
424
|
-
}
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
470
|
+
})
|
471
|
+
.then(res => BypassAutomationBehavior(res, jar, globalOptions, appState))
|
472
|
+
.then(res => Redirect(res, global.OnAutoLoginProcess))
|
473
|
+
.then(res => CheckAndFixErr(res, global.OnAutoLoginProcess))
|
474
|
+
.then(function(res){
|
475
|
+
const html = res.body,Obj = buildAPI(globalOptions, html, jar,bypass_region_err);
|
476
|
+
ctx = Obj.ctx;
|
477
|
+
api = Obj.api;
|
478
|
+
return res;
|
479
|
+
});
|
480
|
+
if (globalOptions.pageID) {
|
481
|
+
mainPromise = mainPromise
|
482
|
+
.then(function() {
|
483
|
+
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
484
|
+
})
|
485
|
+
.then(function(resData) {
|
486
|
+
const url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
487
|
+
url = url.substring(0, url.length - 1);
|
488
|
+
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
489
|
+
});
|
432
490
|
}
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
491
|
+
// At the end we call the callback or catch an exception
|
492
|
+
mainPromise
|
493
|
+
.then(function () {
|
494
|
+
log.info("login", 'Done logging in.');
|
495
|
+
return callback(null, api);
|
496
|
+
})
|
497
|
+
.catch(function (e) {
|
498
|
+
log.error("login", e.error || e);
|
499
|
+
callback(e);
|
500
|
+
});
|
501
|
+
}
|
502
|
+
|
503
|
+
function login(loginData, options, callback) {
|
504
|
+
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
505
|
+
callback = options;
|
506
|
+
options = {};
|
444
507
|
}
|
445
|
-
|
446
|
-
|
508
|
+
|
509
|
+
const globalOptions = {
|
510
|
+
selfListen: false,
|
511
|
+
listenEvents: true,
|
512
|
+
listenTyping: false,
|
513
|
+
updatePresence: false,
|
514
|
+
forceLogin: false,
|
515
|
+
autoMarkDelivery: true,
|
516
|
+
autoMarkRead: false,
|
517
|
+
autoReconnect: true,
|
518
|
+
logRecordSize: defaultLogRecordSize,
|
519
|
+
online: true,
|
520
|
+
emitReady: false,
|
521
|
+
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 14.7; rv:132.0) Gecko/20100101 Firefox/132.0"
|
522
|
+
};
|
523
|
+
|
524
|
+
setOptions(globalOptions, options);
|
525
|
+
|
526
|
+
let prCallback = null;
|
527
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
528
|
+
let rejectFunc = null;
|
529
|
+
let resolveFunc = null;
|
530
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
531
|
+
resolveFunc = resolve;
|
532
|
+
rejectFunc = reject;
|
533
|
+
});
|
534
|
+
prCallback = function(error, api) {
|
535
|
+
if (error) return rejectFunc(error);
|
536
|
+
return resolveFunc(api);
|
537
|
+
};
|
538
|
+
callback = prCallback;
|
447
539
|
}
|
448
|
-
|
540
|
+
|
541
|
+
loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
542
|
+
return returnPromise;
|
543
|
+
}
|
544
|
+
|
545
|
+
module.exports = login;
|