naughty-fb-chatify 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +22 -19
- package/package.json +1 -1
package/index.js
CHANGED
@@ -12,8 +12,9 @@ console.log(`┌─────────────────────
|
|
12
12
|
│ │
|
13
13
|
│ │
|
14
14
|
│ naughty-fb-chatify │
|
15
|
-
│ Version: 1.0.
|
15
|
+
│ Version: 1.0.3 │
|
16
16
|
└────────────────────────────────────────────────────────────────────────────────┘`);
|
17
|
+
const chalk = require("chalk");
|
17
18
|
var utils = require("./utils");
|
18
19
|
var cheerio = require("cheerio");
|
19
20
|
var log = require("npmlog");
|
@@ -80,7 +81,7 @@ function setOptions(globalOptions, options) {
|
|
80
81
|
globalOptions.emitReady = Boolean(options.emitReady);
|
81
82
|
break;
|
82
83
|
default:
|
83
|
-
|
84
|
+
console.log(`${chalk.bold.yellowBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`Unrecognized option given to setOptions:`)} ${chalk.bold.redBright(`${key}`)}`);
|
84
85
|
break;
|
85
86
|
}
|
86
87
|
});
|
@@ -92,15 +93,16 @@ function buildAPI(globalOptions, html, jar) {
|
|
92
93
|
});
|
93
94
|
|
94
95
|
if (maybeCookie.length === 0) {
|
95
|
-
|
96
|
+
console.log(`${chalk.bold.redBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`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.`)}`);
|
97
|
+
return null;
|
96
98
|
}
|
97
99
|
|
98
100
|
if (html.indexOf("/checkpoint/block/?next") > -1) {
|
99
|
-
log.
|
101
|
+
console.log(`${chalk.bold.red(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`Checkpoint detected. Please log in with a browser to verify.`)}`)
|
100
102
|
}
|
101
103
|
|
102
104
|
var userID = maybeCookie[0].cookieString().split("=")[1].toString();
|
103
|
-
log.
|
105
|
+
console.log(`${chalk.bold.cyan(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`Sucesfully Logged In As`)} ${chalk.bold.redBright(`${userID}`)}`)
|
104
106
|
|
105
107
|
try {
|
106
108
|
clearInterval(checkVerified);
|
@@ -119,24 +121,24 @@ function buildAPI(globalOptions, html, jar) {
|
|
119
121
|
irisSeqID = oldFBMQTTMatch[1];
|
120
122
|
mqttEndpoint = oldFBMQTTMatch[2];
|
121
123
|
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
122
|
-
log.
|
124
|
+
console.log(`${chalk.bold.cyan(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`Got this account's message region:`)} ${chalk.bold.redBright(`${region}`)}`);
|
123
125
|
} else {
|
124
126
|
let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
|
125
127
|
if (newFBMQTTMatch) {
|
126
128
|
irisSeqID = newFBMQTTMatch[2];
|
127
129
|
mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
|
128
130
|
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
129
|
-
log.
|
131
|
+
console.log(`${chalk.bold.cyan(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`Got this account's message region:`)} ${chalk.bold.redBright(`${region}`)}`);
|
130
132
|
} else {
|
131
133
|
let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
|
132
134
|
if (legacyFBMQTTMatch) {
|
133
135
|
mqttEndpoint = legacyFBMQTTMatch[4];
|
134
136
|
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
135
|
-
|
136
|
-
log.
|
137
|
-
log.
|
137
|
+
console.log(`${chalk.bold.yellowBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)...`)}`);
|
138
|
+
console.log(`${chalk.bold.cyan(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`Got this account's message region:`)} ${chalk.bold.redBright(`${region}`)}`);
|
139
|
+
console.log(`${chalk.bold.cyan(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.greenBright(`[Unused] Polling endpoint:`)} ${chalk.bold.redBright(`${legacyFBMQTTMatch[6]}`)}`);
|
138
140
|
} else {
|
139
|
-
log.
|
141
|
+
console.log(`${chalk.bold.yellowBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.cyanBright(`Cannot get MQTT region & sequence ID.`)}`);
|
140
142
|
noMqttData = html;
|
141
143
|
}
|
142
144
|
}
|
@@ -280,19 +282,20 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
280
282
|
});
|
281
283
|
// ---------- Very Hacky Part Ends -----------------
|
282
284
|
|
283
|
-
|
285
|
+
console.log(`${chalk.bold.magentaBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.cyanBright(`Logging In....`)}`);
|
284
286
|
return utils
|
285
287
|
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
286
288
|
.then(utils.saveCookies(jar))
|
287
289
|
.then(function (res) {
|
288
290
|
var headers = res.headers;
|
289
291
|
if (!headers.location) {
|
290
|
-
|
292
|
+
console.log(`${chalk.bold.redBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.yellowBright(`Your UserName or Password Is Incorrect`)}`);
|
293
|
+
return null;
|
291
294
|
}
|
292
295
|
|
293
296
|
// This means the account has login approvals turned on.
|
294
297
|
if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
|
295
|
-
log.
|
298
|
+
console.log(`${chalk.bold.redBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.yellowBright(`You have login approvals turned on`)}`);
|
296
299
|
var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
|
297
300
|
|
298
301
|
return utils
|
@@ -325,7 +328,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
325
328
|
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*()/, ""));
|
326
329
|
} catch (ex) {
|
327
330
|
clearInterval(checkVerified);
|
328
|
-
|
331
|
+
console.log(`${chalk.bold.magentaBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.cyanBright(`Verified from browser, Logging in...`)}`);
|
329
332
|
return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
|
330
333
|
}
|
331
334
|
})
|
@@ -415,7 +418,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
415
418
|
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
416
419
|
} catch (ex) {
|
417
420
|
clearInterval(checkVerified);
|
418
|
-
log.
|
421
|
+
console.log(`${chalk.bold.magentaBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.cyanBright(`Verified from browser, Logging in...`)}`);
|
419
422
|
if (callback === prCallback) {
|
420
423
|
callback = function (err, api) {
|
421
424
|
if (err) {
|
@@ -441,7 +444,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
441
444
|
};
|
442
445
|
} else {
|
443
446
|
if (!loginOptions.forceLogin) {
|
444
|
-
|
447
|
+
console.log(`${chalk.bold.redBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.yellowBright(`Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again.`)}`);
|
445
448
|
}
|
446
449
|
if (html.indexOf("Suspicious Login Attempt") > -1) {
|
447
450
|
form['submit[This was me]'] = "This was me";
|
@@ -464,7 +467,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
464
467
|
var headers = res.headers;
|
465
468
|
|
466
469
|
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) {
|
467
|
-
|
470
|
+
console.log(`${chalk.bold.redBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.yellowBright(`Something went wrong with review recent login.`)}`);
|
468
471
|
}
|
469
472
|
|
470
473
|
var appState = utils.getAppState(jar);
|
@@ -562,7 +565,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
562
565
|
// At the end we call the callback or catch an exception
|
563
566
|
mainPromise
|
564
567
|
.then(function () {
|
565
|
-
log.
|
568
|
+
console.log(`${chalk.bold.magentaBright(`[ NAUGHTY-FB-CHATIFY ] >> `)} ${chalk.redBright(`Done Logging In....`)}`);
|
566
569
|
return callback(null, api);
|
567
570
|
})
|
568
571
|
.catch(function (e) {
|