rapido-fca 0.0.5 → 0.0.7
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/index.js +20 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
var utils = require("./utils");
|
|
4
4
|
var cheerio = require("cheerio");
|
|
5
5
|
var log = require("npmlog");
|
|
6
|
+
/*var { getThemeColors } = require("../../func/utils/log.js");
|
|
7
|
+
var logger = require("../../func/utils/log.js");
|
|
8
|
+
var { cra, cv, cb, co } = getThemeColors();*/
|
|
6
9
|
log.maxRecordSize = 100;
|
|
7
10
|
var checkVerified = null;
|
|
8
11
|
const Boolean_Option = ['online', 'selfListen', 'listenEvents', 'updatePresence', 'forceLogin', 'autoMarkDelivery', 'autoMarkRead', 'listenTyping', 'autoReconnect', 'emitReady'];
|
|
@@ -111,10 +114,10 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
111
114
|
}
|
|
112
115
|
} catch { }
|
|
113
116
|
if (fb_dtsg) {
|
|
114
|
-
log
|
|
117
|
+
console.log("Found fb_dtsg!");
|
|
115
118
|
}
|
|
116
119
|
} catch (e) {
|
|
117
|
-
log
|
|
120
|
+
console.log("Error finding fb_dtsg:", e);
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
extractFromHTML();
|
|
@@ -123,13 +126,13 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
123
126
|
var userCookie = cookies.find(cookie => cookie.cookieString().startsWith("c_user="));
|
|
124
127
|
var tiktikCookie = cookies.find(cookie => cookie.cookieString().startsWith("i_user="));
|
|
125
128
|
if (!userCookie && !tiktikCookie) {
|
|
126
|
-
return log.error("
|
|
129
|
+
return log.error("Error! Your cookiestate is not valid!");
|
|
127
130
|
}
|
|
128
131
|
if (html.includes("/checkpoint/block/?next")) {
|
|
129
|
-
return log.error('
|
|
132
|
+
return log.error('error', "Appstate is dead rechange it!", 'error');
|
|
130
133
|
}
|
|
131
134
|
userID = (tiktikCookie || userCookie).cookieString().split("=")[1];
|
|
132
|
-
log
|
|
135
|
+
//logger.log(`${cra(`[ CONNECT ]`)} Logged in as ${userID}`, "DATABASE");
|
|
133
136
|
try { clearInterval(checkVerified); } catch (_) { }
|
|
134
137
|
const clientID = (Math.random() * 2147483648 | 0).toString(16);
|
|
135
138
|
let mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=pnb&sid=${userID}`;
|
|
@@ -138,8 +141,8 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
138
141
|
try {
|
|
139
142
|
const endpointMatch = html.match(/"endpoint":"([^"]+)"/);
|
|
140
143
|
if (endpointMatch.input.includes("601051028565049")) {
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
console.log(`login error.`);
|
|
145
|
+
ditconmemay = true;
|
|
143
146
|
}
|
|
144
147
|
if (endpointMatch) {
|
|
145
148
|
mqttEndpoint = endpointMatch[1].replace(/\\\//g, '/');
|
|
@@ -147,9 +150,9 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
147
150
|
region = url.searchParams.get('region')?.toUpperCase() || "PNB";
|
|
148
151
|
}
|
|
149
152
|
} catch (e) {
|
|
150
|
-
log
|
|
153
|
+
console.log('Using default MQTT endpoint');
|
|
151
154
|
}
|
|
152
|
-
log.info(
|
|
155
|
+
log.info('Logging in...');
|
|
153
156
|
var ctx = {
|
|
154
157
|
userID: userID,
|
|
155
158
|
jar: jar,
|
|
@@ -211,10 +214,11 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
211
214
|
|
|
212
215
|
return newDtsg;
|
|
213
216
|
} catch (e) {
|
|
214
|
-
log
|
|
217
|
+
console.log("Error getting fresh dtsg:", e);
|
|
215
218
|
return null;
|
|
216
219
|
}
|
|
217
220
|
};
|
|
221
|
+
//if (noMqttData) api.htmlData = noMqttData;
|
|
218
222
|
require('fs').readdirSync(__dirname + '/src/').filter(v => v.endsWith('.js')).forEach(v => { api[v.replace('.js', '')] = require(`./src/${v}`)(utils.makeDefaults(html, userID, ctx), api, ctx); });
|
|
219
223
|
api.listen = api.listenMqtt;
|
|
220
224
|
return {
|
|
@@ -247,7 +251,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
|
247
251
|
const cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
|
|
248
252
|
jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
|
|
249
253
|
});
|
|
250
|
-
log.info("
|
|
254
|
+
log.info("Logging in...");
|
|
251
255
|
const loginRes = await utils.post(
|
|
252
256
|
"https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110",
|
|
253
257
|
jar,
|
|
@@ -258,7 +262,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
|
258
262
|
const headers = loginRes.headers;
|
|
259
263
|
if (!headers.location) throw new Error("Wrong username/password.");
|
|
260
264
|
if (headers.location.includes('https://www.facebook.com/checkpoint/')) {
|
|
261
|
-
log.info("
|
|
265
|
+
log.info("login", "You have login approvals turned on.");
|
|
262
266
|
const checkpointRes = await utils.get(headers.location, jar, null, loginOptions);
|
|
263
267
|
await utils.saveCookies(jar)(checkpointRes);
|
|
264
268
|
const checkpointHtml = checkpointRes.body;
|
|
@@ -318,6 +322,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
|
318
322
|
};
|
|
319
323
|
}
|
|
320
324
|
|
|
325
|
+
|
|
321
326
|
function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
|
322
327
|
let mainPromise = null;
|
|
323
328
|
const jar = utils.getJar();
|
|
@@ -392,7 +397,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
|
392
397
|
|
|
393
398
|
mainPromise
|
|
394
399
|
.then(async () => {
|
|
395
|
-
log.info(
|
|
400
|
+
log.info('Login successful');
|
|
396
401
|
callback(null, api);
|
|
397
402
|
})
|
|
398
403
|
.catch(e => {
|
|
@@ -400,6 +405,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
|
400
405
|
});
|
|
401
406
|
}
|
|
402
407
|
|
|
408
|
+
|
|
403
409
|
function login(loginData, options, callback) {
|
|
404
410
|
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
|
405
411
|
callback = options;
|
|
@@ -450,4 +456,5 @@ function login(loginData, options, callback) {
|
|
|
450
456
|
return returnPromise;
|
|
451
457
|
}
|
|
452
458
|
|
|
459
|
+
|
|
453
460
|
module.exports = login;
|