node-ainzfb-new 1.7.7-iu0tg78 → 1.7.10-11
Sign up to get free protection for your applications and to get access to all the features.
- package/DOCS.md +56 -25
- package/index.js +83 -41
- package/package.json +2 -2
- package/src/changeAvt.js +73 -73
- package/src/editMessage.js +84 -0
- package/src/getAccessToken.js +21 -21
- package/src/getThreadInfo.js +3423 -18
- package/src/getUserInfoV2.js +19 -22
- package/src/pinMessage.js +61 -0
- package/src/shareContact.js +56 -0
- package/src/shareLink.js +57 -0
- package/utils.js +1480 -1063
package/DOCS.md
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
* [`api.createPoll`](#createPoll)
|
14
14
|
* [`api.deleteMessage`](#deleteMessage)
|
15
15
|
* [`api.deleteThread`](#deleteThread)
|
16
|
+
* [`api.editMessage`](#editMessage)
|
16
17
|
* [`api.forwardAttachment`](#forwardAttachment)
|
17
18
|
* [`api.getAppState`](#getAppState)
|
18
19
|
* [`api.getCurrentUserID`](#getCurrentUserID)
|
@@ -104,7 +105,7 @@ __Arguments__
|
|
104
105
|
__Example (Email & Password)__
|
105
106
|
|
106
107
|
```js
|
107
|
-
const login = require("
|
108
|
+
const login = require("node-ainzfb-new");
|
108
109
|
|
109
110
|
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
110
111
|
if(err) return console.error(err);
|
@@ -116,7 +117,7 @@ __Example (Email & Password then save appState to file)__
|
|
116
117
|
|
117
118
|
```js
|
118
119
|
const fs = require("fs");
|
119
|
-
const login = require("
|
120
|
+
const login = require("node-ainzfb-new");
|
120
121
|
|
121
122
|
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
122
123
|
if(err) return console.error(err);
|
@@ -129,7 +130,7 @@ __Example (AppState loaded from file)__
|
|
129
130
|
|
130
131
|
```js
|
131
132
|
const fs = require("fs");
|
132
|
-
const login = require("
|
133
|
+
const login = require("node-ainzfb-new");
|
133
134
|
|
134
135
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
135
136
|
if(err) return console.error(err);
|
@@ -143,7 +144,7 @@ __Example__:
|
|
143
144
|
|
144
145
|
```js
|
145
146
|
const fs = require("fs");
|
146
|
-
const login = require("
|
147
|
+
const login = require("node-ainzfb-new");
|
147
148
|
const readline = require("readline");
|
148
149
|
|
149
150
|
var rl = readline.createInterface({
|
@@ -204,7 +205,7 @@ __Example__
|
|
204
205
|
|
205
206
|
```js
|
206
207
|
const fs = require("fs");
|
207
|
-
const login = require("
|
208
|
+
const login = require("node-ainzfb-new");
|
208
209
|
|
209
210
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, async function(err, api) {
|
210
211
|
if (err) return console.error(err);
|
@@ -236,7 +237,7 @@ __Example__
|
|
236
237
|
|
237
238
|
```js
|
238
239
|
const fs = require("fs");
|
239
|
-
const login = require("
|
240
|
+
const login = require("node-ainzfb-new");
|
240
241
|
|
241
242
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
242
243
|
if(err) return console.error(err);
|
@@ -276,7 +277,7 @@ __Example__
|
|
276
277
|
|
277
278
|
```js
|
278
279
|
const fs = require("fs");
|
279
|
-
const login = require("
|
280
|
+
const login = require("node-ainzfb-new");
|
280
281
|
|
281
282
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
282
283
|
if(err) return console.error(err);
|
@@ -304,7 +305,7 @@ __Example__
|
|
304
305
|
|
305
306
|
```js
|
306
307
|
const fs = require("fs");
|
307
|
-
const login = require("
|
308
|
+
const login = require("node-ainzfb-new");
|
308
309
|
|
309
310
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
310
311
|
if(err) return console.error(err);
|
@@ -334,7 +335,7 @@ __Example__
|
|
334
335
|
|
335
336
|
```js
|
336
337
|
const fs = require("fs");
|
337
|
-
const login = require("
|
338
|
+
const login = require("node-ainzfb-new");
|
338
339
|
|
339
340
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
340
341
|
if(err) return console.error(err);
|
@@ -363,7 +364,7 @@ __Example__
|
|
363
364
|
|
364
365
|
```js
|
365
366
|
const fs = require("fs");
|
366
|
-
const login = require("
|
367
|
+
const login = require("node-ainzfb-new");
|
367
368
|
|
368
369
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
369
370
|
if(err) return console.error(err);
|
@@ -403,7 +404,7 @@ __Example__
|
|
403
404
|
|
404
405
|
```js
|
405
406
|
const fs = require("fs");
|
406
|
-
const login = require("
|
407
|
+
const login = require("node-ainzfb-new");
|
407
408
|
|
408
409
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
409
410
|
if(err) return console.error(err);
|
@@ -431,7 +432,7 @@ __Arguments__
|
|
431
432
|
__Example__
|
432
433
|
```js
|
433
434
|
const fs = require("fs");
|
434
|
-
const login = require("
|
435
|
+
const login = require("node-ainzfb-new");
|
435
436
|
|
436
437
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
437
438
|
if(err) return console.error(err);
|
@@ -464,7 +465,7 @@ __Example__
|
|
464
465
|
|
465
466
|
```js
|
466
467
|
const fs = require("fs");
|
467
|
-
const login = require("
|
468
|
+
const login = require("node-ainzfb-new");
|
468
469
|
|
469
470
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
470
471
|
if(err) return console.error(err);
|
@@ -477,6 +478,36 @@ login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, ap
|
|
477
478
|
|
478
479
|
---------------------------------------
|
479
480
|
|
481
|
+
<a name="editMessage"></a>
|
482
|
+
### api.editMessage(body, messageID[, callback])
|
483
|
+
|
484
|
+
Edit your sent messages.
|
485
|
+
Note: This will only work if the message is sent by you and was sent less than 15 minutes ago.
|
486
|
+
|
487
|
+
__Arguments__
|
488
|
+
|
489
|
+
* `body` - A string of content you want to edit.
|
490
|
+
* `messageID` - The id of the message you want to edit (Only works for your own messages).
|
491
|
+
* `callback(err, obj)` - (Optional) A callback called when the operation is done and returns a object, maybe with an object representing an error.
|
492
|
+
|
493
|
+
__Example__
|
494
|
+
|
495
|
+
```js
|
496
|
+
const fs = require("fs");
|
497
|
+
const login = require("node-ainzfb-new");
|
498
|
+
|
499
|
+
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
500
|
+
if(err) return console.error(err);
|
501
|
+
|
502
|
+
api.editMessage("The message content will be changed", "mid.$gAA9RZho2tfKT6ECIqmNtvs6NIqUM", (err, obj) => {
|
503
|
+
if(err) return console.error(err.error);
|
504
|
+
console.log(obj);
|
505
|
+
});
|
506
|
+
});
|
507
|
+
```
|
508
|
+
|
509
|
+
---------------------------------------
|
510
|
+
|
480
511
|
<a name="forwardAttachment"></a>
|
481
512
|
### api.forwardAttachment(attachmentID, userOrUsers[, callback])
|
482
513
|
|
@@ -521,7 +552,7 @@ __Example__
|
|
521
552
|
|
522
553
|
```js
|
523
554
|
const fs = require("fs");
|
524
|
-
const login = require("
|
555
|
+
const login = require("node-ainzfb-new");
|
525
556
|
|
526
557
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
527
558
|
if(err) return console.error(err);
|
@@ -551,7 +582,7 @@ __Example__
|
|
551
582
|
|
552
583
|
```js
|
553
584
|
const fs = require("fs");
|
554
|
-
const login = require("
|
585
|
+
const login = require("node-ainzfb-new");
|
555
586
|
|
556
587
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
557
588
|
if(err) return console.error(err);
|
@@ -918,7 +949,7 @@ __Example__
|
|
918
949
|
|
919
950
|
```js
|
920
951
|
const fs = require("fs");
|
921
|
-
const login = require("
|
952
|
+
const login = require("node-ainzfb-new");
|
922
953
|
|
923
954
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
924
955
|
if(err) return console.error(err);
|
@@ -950,7 +981,7 @@ __Example__
|
|
950
981
|
|
951
982
|
```js
|
952
983
|
const fs = require("fs");
|
953
|
-
const login = require("
|
984
|
+
const login = require("node-ainzfb-new");
|
954
985
|
|
955
986
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
956
987
|
if(err) return console.error(err);
|
@@ -1317,7 +1348,7 @@ __Example__
|
|
1317
1348
|
|
1318
1349
|
```js
|
1319
1350
|
const fs = require("fs");
|
1320
|
-
const login = require("
|
1351
|
+
const login = require("node-ainzfb-new");
|
1321
1352
|
|
1322
1353
|
// Simple echo bot. He'll repeat anything that you say.
|
1323
1354
|
// Will stop when you say '/stop'
|
@@ -1412,7 +1443,7 @@ __Example__
|
|
1412
1443
|
|
1413
1444
|
```js
|
1414
1445
|
const fs = require("fs");
|
1415
|
-
const login = require("
|
1446
|
+
const login = require("node-ainzfb-new");
|
1416
1447
|
|
1417
1448
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
1418
1449
|
if(err) return console.error(err);
|
@@ -1457,7 +1488,7 @@ __Example__
|
|
1457
1488
|
|
1458
1489
|
```js
|
1459
1490
|
const fs = require("fs");
|
1460
|
-
const login = require("
|
1491
|
+
const login = require("node-ainzfb-new");
|
1461
1492
|
|
1462
1493
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
1463
1494
|
if(err) return console.error(err);
|
@@ -1545,7 +1576,7 @@ __Tip__: to find your own ID, you can look inside the cookies. The `userID` is u
|
|
1545
1576
|
__Example (Basic Message)__
|
1546
1577
|
```js
|
1547
1578
|
const fs = require("fs");
|
1548
|
-
const login = require("
|
1579
|
+
const login = require("node-ainzfb-new");
|
1549
1580
|
|
1550
1581
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
1551
1582
|
if(err) return console.error(err);
|
@@ -1559,7 +1590,7 @@ login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, ap
|
|
1559
1590
|
__Example (File upload)__
|
1560
1591
|
```js
|
1561
1592
|
const fs = require("fs");
|
1562
|
-
const login = require("
|
1593
|
+
const login = require("node-ainzfb-new");
|
1563
1594
|
|
1564
1595
|
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
1565
1596
|
if(err) return console.error(err);
|
@@ -1576,7 +1607,7 @@ login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, ap
|
|
1576
1607
|
|
1577
1608
|
__Example (Mention)__
|
1578
1609
|
```js
|
1579
|
-
const login = require("
|
1610
|
+
const login = require("node-ainzfb-new");
|
1580
1611
|
|
1581
1612
|
login({email: "EMAIL", password: "PASSWORD"}, (err, api) => {
|
1582
1613
|
if(err) return console.error(err);
|
@@ -1600,7 +1631,7 @@ login({email: "EMAIL", password: "PASSWORD"}, (err, api) => {
|
|
1600
1631
|
|
1601
1632
|
__Example (Location)__
|
1602
1633
|
```js
|
1603
|
-
const login = require("
|
1634
|
+
const login = require("node-ainzfb-new");
|
1604
1635
|
login({email: "EMAIL", password: "PASSWORD"}, (err, api) => {
|
1605
1636
|
if(err) return console.error(err);
|
1606
1637
|
var yourID = "000000000000000";
|
@@ -1683,7 +1714,7 @@ __Example__
|
|
1683
1714
|
|
1684
1715
|
```js
|
1685
1716
|
const fs = require("fs");
|
1686
|
-
const login = require("
|
1717
|
+
const login = require("node-ainzfb-new");
|
1687
1718
|
|
1688
1719
|
// Simple echo bot. This will send messages forever.
|
1689
1720
|
|
package/index.js
CHANGED
@@ -9,7 +9,7 @@ process.env.UV_THREADPOOL_SIZE = require('os').cpus().length;
|
|
9
9
|
global.isThread = new Array();
|
10
10
|
global.isUser = new Array();
|
11
11
|
global.startTime = Date.now();
|
12
|
-
global.getText =
|
12
|
+
global.getText = require('gettext.js')();
|
13
13
|
|
14
14
|
/!-[ Require All Package Need Use ]-!/
|
15
15
|
/*globalThis.Fca = new Object({
|
@@ -19,7 +19,7 @@ global.getText = require('gettext.js')();
|
|
19
19
|
var utils = require("./utils"),
|
20
20
|
cheerio = require("cheerio"),
|
21
21
|
log = require("npmlog"),
|
22
|
-
//{ getAccessToken } = require('./Extra/ExtraAddons'),
|
22
|
+
//{ getAccessToken } = require('./Extra/ExtraAddons'),
|
23
23
|
logger = require('./logger'),
|
24
24
|
fs = require('fs-extra'),
|
25
25
|
getText = require('gettext.js')(),
|
@@ -90,7 +90,7 @@ var checkVerified = null;
|
|
90
90
|
/!-[ Function setOptions ]-!/
|
91
91
|
|
92
92
|
function setOptions(globalOptions, options) {
|
93
|
-
Object.keys(options).map(function(key) {
|
93
|
+
Object.keys(options).map(function (key) {
|
94
94
|
switch (key) {
|
95
95
|
case 'pauseLog':
|
96
96
|
if (options.pauseLog) log.pause();
|
@@ -158,7 +158,7 @@ function setOptions(globalOptions, options) {
|
|
158
158
|
/!-[ Function BuildAPI ]-!/
|
159
159
|
|
160
160
|
async function buildAPI(globalOptions, html, jar) {
|
161
|
-
var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(val) { return val.cookieString().split("=")[0] === "c_user"; });
|
161
|
+
var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function (val) { return val.cookieString().split("=")[0] === "c_user"; });
|
162
162
|
|
163
163
|
if (maybeCookie.length === 0) throw { error: Language.ErrAppState };
|
164
164
|
|
@@ -222,7 +222,9 @@ async function buildAPI(globalOptions, html, jar) {
|
|
222
222
|
syncToken: undefined,
|
223
223
|
mqttEndpoint,
|
224
224
|
region,
|
225
|
-
firstListen: true
|
225
|
+
firstListen: true,
|
226
|
+
wsReqNumber: 0,
|
227
|
+
wsTaskNumber: 0
|
226
228
|
};
|
227
229
|
|
228
230
|
var api = {
|
@@ -244,7 +246,7 @@ async function buildAPI(globalOptions, html, jar) {
|
|
244
246
|
}
|
245
247
|
|
246
248
|
function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
247
|
-
return function(res) {
|
249
|
+
return function (res) {
|
248
250
|
var html = res.body;
|
249
251
|
var $ = cheerio.load(html);
|
250
252
|
var arr = [];
|
@@ -252,7 +254,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
252
254
|
// This will be empty, but just to be sure we leave it
|
253
255
|
$("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
254
256
|
|
255
|
-
arr = arr.filter(function(v) {
|
257
|
+
arr = arr.filter(function (v) {
|
256
258
|
return v.val && v.val.length;
|
257
259
|
});
|
258
260
|
|
@@ -278,7 +280,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
278
280
|
//
|
279
281
|
// ---------- Very Hacky Part Starts -----------------
|
280
282
|
var willBeCookies = html.split("\"_js_");
|
281
|
-
willBeCookies.slice(1).map(function(val) {
|
283
|
+
willBeCookies.slice(1).map(function (val) {
|
282
284
|
var cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
|
283
285
|
jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
|
284
286
|
});
|
@@ -288,7 +290,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
288
290
|
return utils
|
289
291
|
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
290
292
|
.then(utils.saveCookies(jar))
|
291
|
-
.then(function(res) {
|
293
|
+
.then(function (res) {
|
292
294
|
var headers = res.headers;
|
293
295
|
if (!headers.location) throw { error: Language.InvaildAccount };
|
294
296
|
|
@@ -300,21 +302,21 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
300
302
|
return utils
|
301
303
|
.get(headers.location, jar, null, loginOptions)
|
302
304
|
.then(utils.saveCookies(jar))
|
303
|
-
.then(function(res) {
|
305
|
+
.then(function (res) {
|
304
306
|
var html = res.body;
|
305
307
|
// Make the form in advance which will contain the fb_dtsg and nh
|
306
308
|
var $ = cheerio.load(html);
|
307
309
|
var arr = [];
|
308
310
|
$("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
309
311
|
|
310
|
-
arr = arr.filter(function(v) {
|
312
|
+
arr = arr.filter(function (v) {
|
311
313
|
return v.val && v.val.length;
|
312
314
|
});
|
313
315
|
|
314
316
|
var form = utils.arrToForm(arr);
|
315
317
|
if (html.indexOf("checkpoint/?next") > -1) {
|
316
318
|
setTimeout(() => {
|
317
|
-
checkVerified = setInterval((_form) => {}, 5000, {
|
319
|
+
checkVerified = setInterval((_form) => { }, 5000, {
|
318
320
|
fb_dtsg: form.fb_dtsg,
|
319
321
|
jazoest: form.jazoest,
|
320
322
|
dpr: 1
|
@@ -327,7 +329,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
327
329
|
form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
|
328
330
|
var prResolve = null;
|
329
331
|
var prReject = null;
|
330
|
-
var rtPromise = new Promise(function(resolve, reject) {
|
332
|
+
var rtPromise = new Promise(function (resolve, reject) {
|
331
333
|
prResolve = resolve;
|
332
334
|
prReject = reject;
|
333
335
|
});
|
@@ -335,7 +337,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
335
337
|
utils
|
336
338
|
.post(nextURL, jar, form, loginOptions)
|
337
339
|
.then(utils.saveCookies(jar))
|
338
|
-
.then(function(res) {
|
340
|
+
.then(function (res) {
|
339
341
|
var $ = cheerio.load(res.body);
|
340
342
|
var error = $("#approvals_code").parent().attr("data-xui-error");
|
341
343
|
if (error) {
|
@@ -347,7 +349,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
347
349
|
};
|
348
350
|
}
|
349
351
|
})
|
350
|
-
.then(function() {
|
352
|
+
.then(function () {
|
351
353
|
// Use the same form (safe I hope)
|
352
354
|
delete form.no_fido;
|
353
355
|
delete form.approvals_code;
|
@@ -355,14 +357,14 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
355
357
|
|
356
358
|
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
357
359
|
})
|
358
|
-
.then(function(res) {
|
360
|
+
.then(function (res) {
|
359
361
|
var headers = res.headers;
|
360
362
|
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: Language.ApprovalsErr };
|
361
363
|
|
362
364
|
var appState = utils.getAppState(jar);
|
363
365
|
|
364
366
|
if (callback === prCallback) {
|
365
|
-
callback = function(err, api) {
|
367
|
+
callback = function (err, api) {
|
366
368
|
if (err) return prReject(err);
|
367
369
|
return prResolve(api);
|
368
370
|
};
|
@@ -372,7 +374,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
372
374
|
// and will then complete the login process
|
373
375
|
return loginHelper(appState, email, password, loginOptions, callback);
|
374
376
|
})
|
375
|
-
.catch(function(err) {
|
377
|
+
.catch(function (err) {
|
376
378
|
// Check if using Promise instead of callback
|
377
379
|
if (callback === prCallback) prReject(err);
|
378
380
|
else callback(err);
|
@@ -388,7 +390,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
388
390
|
clearInterval(checkVerified);
|
389
391
|
logger(Language.VerifiedCheck, "[ FCA-SUS ]");
|
390
392
|
if (callback === prCallback) {
|
391
|
-
callback = function(err, api) {
|
393
|
+
callback = function (err, api) {
|
392
394
|
if (err) return prReject(err);
|
393
395
|
return prResolve(api);
|
394
396
|
};
|
@@ -414,13 +416,13 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
|
414
416
|
return utils
|
415
417
|
.post(nextURL, jar, form, loginOptions)
|
416
418
|
.then(utils.saveCookies(jar))
|
417
|
-
.then(function() {
|
419
|
+
.then(function () {
|
418
420
|
// Use the same form (safe I hope)
|
419
421
|
form.name_action_selected = 'save_device';
|
420
422
|
|
421
423
|
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
422
424
|
})
|
423
|
-
.then(function(res) {
|
425
|
+
.then(function (res) {
|
424
426
|
var headers = res.headers;
|
425
427
|
|
426
428
|
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
|
@@ -530,7 +532,7 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
530
532
|
// });
|
531
533
|
|
532
534
|
logger(Language.OnProcess, "[ FCA-SUS ]");
|
533
|
-
var backup = async(data) => {
|
535
|
+
var backup = async (data) => {
|
534
536
|
if (fs.existsSync('./appstate.json')) {
|
535
537
|
try {
|
536
538
|
fs.writeFileSync('./appstate.json', data);
|
@@ -578,9 +580,9 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
578
580
|
{
|
579
581
|
if (process.env["REPL_ID"] == undefined) {
|
580
582
|
try {
|
581
|
-
|
582
|
-
|
583
|
-
|
583
|
+
var { body } = await Fetch('https://sampleapi.netlify.app/.netlify/functions/api/generate/key');
|
584
|
+
|
585
|
+
process.env['FBKEY'] = JSON.parse(body).response.key;
|
584
586
|
} catch (e) {
|
585
587
|
logger(Language.ErrGetPassWord, '[ FCA-SUS ]');
|
586
588
|
logger.Error();
|
@@ -609,7 +611,7 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
609
611
|
case "android":
|
610
612
|
{
|
611
613
|
try {
|
612
|
-
|
614
|
+
var { body } = await Fetch('https://sampleapi.netlify.app/.netlify/functions/api/generate/key');
|
613
615
|
process.env['FBKEY'] = JSON.parse(body).response.key;
|
614
616
|
} catch (e) {
|
615
617
|
logger(Language.ErrGetPassWord, '[ FCA-SUS ]');
|
@@ -630,7 +632,7 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
630
632
|
case true:
|
631
633
|
{
|
632
634
|
appState = JSON.parse(JSON.stringify(appState, null, "\t"));
|
633
|
-
|
635
|
+
//console.log(appState);
|
634
636
|
switch (utils.getType(appState)) {
|
635
637
|
case "Array":
|
636
638
|
{
|
@@ -727,9 +729,9 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
727
729
|
case "String":
|
728
730
|
{
|
729
731
|
logger(Language.EncryptStateOff, "[ FCA-SUS ]");
|
730
|
-
|
732
|
+
//console.log("hello")
|
731
733
|
try {
|
732
|
-
|
734
|
+
// appState = appState;
|
733
735
|
appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
|
734
736
|
logger(Language.DecryptSuccess, '[ FCA-SUS ]');
|
735
737
|
} catch (e) {
|
@@ -825,7 +827,7 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
825
827
|
}
|
826
828
|
}
|
827
829
|
try {
|
828
|
-
appState.map(function(c) {
|
830
|
+
appState.map(function (c) {
|
829
831
|
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
830
832
|
jar.setCookie(str, "http://" + c.domain);
|
831
833
|
});
|
@@ -949,7 +951,7 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
949
951
|
.get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
|
950
952
|
.then(utils.saveCookies(jar))
|
951
953
|
.then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
|
952
|
-
.then(function() {
|
954
|
+
.then(function () {
|
953
955
|
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
|
954
956
|
});
|
955
957
|
}
|
@@ -960,15 +962,54 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
960
962
|
var _defaultFuncs = null;
|
961
963
|
var api = null;
|
962
964
|
|
965
|
+
let redirect = [1, "https://m.facebook.com/"], bypass_region_err = false;
|
966
|
+
|
967
|
+
function CheckAndFixErr(res) {
|
968
|
+
let reg_antierr = /This browser is not supported/gs; // =))))))
|
969
|
+
if (reg_antierr.test(res.body)) {
|
970
|
+
const Data = JSON.stringify(res.body);
|
971
|
+
const Dt_Check = Data.split('2Fhome.php&gfid=')[1];
|
972
|
+
if (Dt_Check == undefined) return res
|
973
|
+
const fid = Dt_Check.split("\\\\")[0];//fix sau
|
974
|
+
if (Dt_Check == undefined || Dt_Check == "") return res
|
975
|
+
const final_fid = fid.split(`\\`)[0];
|
976
|
+
if (final_fid == undefined || final_fid == '') return res;
|
977
|
+
const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
|
978
|
+
bypass_region_err = true;
|
979
|
+
return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
|
980
|
+
}
|
981
|
+
else return res
|
982
|
+
}
|
983
|
+
|
984
|
+
function Redirect(res) {
|
985
|
+
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
986
|
+
redirect = reg.exec(res.body);
|
987
|
+
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
|
988
|
+
return res;
|
989
|
+
}
|
990
|
+
|
963
991
|
mainPromise = mainPromise
|
964
|
-
.then(function(res) {
|
992
|
+
.then(function (res) {
|
965
993
|
// Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
|
966
994
|
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
967
995
|
var redirect = reg.exec(res.body);
|
968
996
|
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
|
969
997
|
return res;
|
970
998
|
})
|
971
|
-
.then(
|
999
|
+
.then(res => Redirect(res))
|
1000
|
+
.then(res => CheckAndFixErr(res))
|
1001
|
+
.then(function (res) {
|
1002
|
+
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
|
1003
|
+
if (!Regex_Via.test(res.body)) {
|
1004
|
+
//www.facebook.com
|
1005
|
+
globalOptions.userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1";
|
1006
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
|
1007
|
+
}
|
1008
|
+
else return res
|
1009
|
+
})
|
1010
|
+
.then(res => Redirect(res))
|
1011
|
+
.then(res => CheckAndFixErr(res))
|
1012
|
+
.then(async function (res) {
|
972
1013
|
var html = res.body;
|
973
1014
|
var stuff = await buildAPI(globalOptions, html, jar);
|
974
1015
|
ctx = stuff[0];
|
@@ -976,13 +1017,14 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
976
1017
|
api = stuff[2];
|
977
1018
|
return res;
|
978
1019
|
});
|
1020
|
+
|
979
1021
|
// given a pageID we log in as a page
|
980
1022
|
if (globalOptions.pageID) {
|
981
1023
|
mainPromise = mainPromise
|
982
|
-
.then(function() {
|
1024
|
+
.then(function () {
|
983
1025
|
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
984
1026
|
})
|
985
|
-
.then(function(resData) {
|
1027
|
+
.then(function (resData) {
|
986
1028
|
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
987
1029
|
url = url.substring(0, url.length - 1);
|
988
1030
|
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
@@ -991,14 +1033,14 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
991
1033
|
|
992
1034
|
// At the end we call the callback or catch an exception
|
993
1035
|
mainPromise
|
994
|
-
.then(function() {
|
1036
|
+
.then(function () {
|
995
1037
|
logger(Language.DoneLogin, "[ FCA-SUS ]");
|
996
1038
|
logger(Language.AutoCheckUpdate, "[ FCA-SUS ]");
|
997
1039
|
//!---------- Auto Check, Update START -----------------!//
|
998
1040
|
var Fetch = require('got');
|
999
1041
|
var { readFileSync } = require('fs-extra');
|
1000
1042
|
const { execSync } = require('child_process');
|
1001
|
-
Fetch('https://raw.githubusercontent.com/amogusdevlol/node-ainzfb/main/package.json').then(async(res) => {
|
1043
|
+
Fetch('https://raw.githubusercontent.com/amogusdevlol/node-ainzfb/main/package.json').then(async (res) => {
|
1002
1044
|
const localbrand = JSON.parse(readFileSync('./node_modules/node-ainzfb-new/package.json')).version;
|
1003
1045
|
if (Number(localbrand.replace(/\./g, "")) < Number(JSON.parse(res.body.toString()).version.replace(/\./g, ""))) {
|
1004
1046
|
log.warn("[ FCA-SUS ] •", getText.gettext(Language.NewVersionFound, JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version, JSON.parse(res.body.toString()).version));
|
@@ -1038,7 +1080,7 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
1038
1080
|
callback(null, api);
|
1039
1081
|
}
|
1040
1082
|
});
|
1041
|
-
}).catch(function(e) {
|
1083
|
+
}).catch(function (e) {
|
1042
1084
|
log.error("login", e.error || e);
|
1043
1085
|
callback(e);
|
1044
1086
|
});
|
@@ -1075,11 +1117,11 @@ function login(loginData, options, callback) {
|
|
1075
1117
|
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
1076
1118
|
var rejectFunc = null;
|
1077
1119
|
var resolveFunc = null;
|
1078
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
1120
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
1079
1121
|
resolveFunc = resolve;
|
1080
1122
|
rejectFunc = reject;
|
1081
1123
|
});
|
1082
|
-
prCallback = function(error, api) {
|
1124
|
+
prCallback = function (error, api) {
|
1083
1125
|
if (error) return rejectFunc(error);
|
1084
1126
|
return resolveFunc(api);
|
1085
1127
|
};
|
@@ -1089,4 +1131,4 @@ function login(loginData, options, callback) {
|
|
1089
1131
|
return returnPromise;
|
1090
1132
|
}
|
1091
1133
|
|
1092
|
-
module.exports = login;
|
1134
|
+
module.exports = login;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "node-ainzfb-new",
|
3
|
-
"version": "1.7.
|
3
|
+
"version": "1.7.10-11",
|
4
4
|
"description": "A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.",
|
5
5
|
"scripts": {
|
6
6
|
"test": "mocha",
|
@@ -39,7 +39,7 @@
|
|
39
39
|
"node-superfetch": "^0.2.3",
|
40
40
|
"npmlog": "latest",
|
41
41
|
"path": "latest",
|
42
|
-
"pretty-ms": "
|
42
|
+
"pretty-ms": "^7.0.1",
|
43
43
|
"pm2": "^5.3.0",
|
44
44
|
"request": "latest",
|
45
45
|
"semver": "latest",
|