alicezetion 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/Extra/Database/index.js +399 -0
  4. package/Extra/Database/methods.js +286 -0
  5. package/Extra/ExtraAddons.js +213 -0
  6. package/Extra/ExtraGetThread.js +1 -0
  7. package/Extra/ExtraUptimeRobot.js +59 -0
  8. package/Extra/PM2/ecosystem.config.js +23 -0
  9. package/Extra/Src/Last-Run.js +48 -0
  10. package/Language/index.json +151 -0
  11. package/StateCrypt.js +22 -0
  12. package/broadcast.js +42 -0
  13. package/index.js +654 -119
  14. package/logger.js +21 -0
  15. package/package.json +37 -25
  16. package/replit.nix +3 -4
  17. package/src/addExternalModule.js +13 -5
  18. package/src/addUserToGroup.js +36 -12
  19. package/src/changeAdminStatus.js +85 -37
  20. package/src/changeArchivedStatus.js +15 -9
  21. package/src/changeAvt.js +91 -0
  22. package/src/changeBio.js +13 -8
  23. package/src/changeBlockedStatus.js +14 -8
  24. package/src/changeGroupImage.js +28 -13
  25. package/src/changeNickname.js +22 -11
  26. package/src/changeThreadColor.js +16 -10
  27. package/src/changeThreadEmoji.js +18 -9
  28. package/src/chat.js +401 -280
  29. package/src/createNewGroup.js +18 -10
  30. package/src/createPoll.js +17 -11
  31. package/src/deleteMessage.js +17 -10
  32. package/src/deleteThread.js +17 -10
  33. package/src/forwardAttachment.js +15 -9
  34. package/src/getAccessToken.js +32 -0
  35. package/src/getCurrentUserID.js +1 -1
  36. package/src/getEmojiUrl.js +3 -2
  37. package/src/getFriendsList.js +18 -10
  38. package/src/getMessage.js +84 -0
  39. package/src/getThreadHistory.js +156 -59
  40. package/src/getThreadHistoryDeprecated.js +26 -15
  41. package/src/getThreadInfo.js +68 -42
  42. package/src/getThreadInfoDeprecated.js +25 -13
  43. package/src/getThreadList.js +112 -53
  44. package/src/getThreadListDeprecated.js +30 -12
  45. package/src/getThreadPictures.js +25 -13
  46. package/src/getUserID.js +9 -7
  47. package/src/getUserInfo.js +12 -10
  48. package/src/getUserInfoV2.js +35 -0
  49. package/src/handleFriendRequest.js +36 -35
  50. package/src/handleMessageRequest.js +18 -10
  51. package/src/httpGet.js +20 -13
  52. package/src/httpPost.js +19 -13
  53. package/src/httpPostFormData.js +46 -0
  54. package/src/listenMqtt.js +1224 -621
  55. package/src/logout.js +18 -13
  56. package/src/markAsDelivered.js +17 -10
  57. package/src/markAsRead.js +36 -24
  58. package/src/markAsSeen.js +22 -12
  59. package/src/muteThread.js +15 -9
  60. package/src/{setMessageReaction.js → react.js} +20 -9
  61. package/src/removeUserFromGroup.js +38 -11
  62. package/src/resolvePhotoUrl.js +9 -6
  63. package/src/searchForThread.js +14 -8
  64. package/src/{markAsReadAll.js → seen.js} +17 -10
  65. package/src/sendTypingIndicator.js +44 -19
  66. package/src/setPostReaction.js +63 -22
  67. package/src/setTitle.js +22 -12
  68. package/src/threadColors.js +17 -19
  69. package/src/unfriend.js +15 -9
  70. package/src/{unsendMessage.js → unsend.js} +9 -8
  71. package/utils.js +120 -27
  72. package/.travis.yml +0 -6
  73. package/src/forwardMessage.js +0 -0
  74. package/src/listen.js +0 -553
  75. package/src/listenMqtt-Test.js +0 -687
  76. package/src/sendMessage.js +0 -315
  77. package/test/data/shareAttach.js +0 -146
  78. package/test/data/something.mov +0 -0
  79. package/test/data/test.png +0 -0
  80. package/test/data/test.txt +0 -7
  81. package/test/example-config.json +0 -18
  82. package/test/test-page.js +0 -140
  83. package/test/test.js +0 -385
package/index.js CHANGED
@@ -1,13 +1,93 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- var utils = require("./utils");
4
- var cheerio = require("cheerio");
5
- var log = require("npmlog");
3
+ /!-[ Max Cpu Speed ]-!/
6
4
 
5
+ process.env.UV_THREADPOOL_SIZE = require('os').cpus().length;
6
+
7
+ /!-[ Global Set ]-!/
8
+
9
+ global.isThread = new Array();
10
+ global.isUser = new Array();
11
+ global.startTime = Date.now();
12
+ global.getText = require('gettext.js')();
13
+
14
+ /!-[ Require All Package Need Use ]-!/
15
+ /*globalThis.Fca = new Object({
16
+ test: console,log("test"),
17
+ Require: new Object({})
18
+ });*/
19
+ var utils = require("./utils"),
20
+ cheerio = require("cheerio"),
21
+ log = require("npmlog"),
22
+ //{ getAccessToken } = require('./Extra/ExtraAddons'),
23
+ logger = require('./logger'),
24
+ fs = require('fs-extra'),
25
+ getText = require('gettext.js')(),
26
+ logger = require('./logger'),
27
+ Fetch = require('got'),
28
+ fs = require('fs-extra'),
29
+ StateCrypt = require('./StateCrypt'),
30
+ Client = require("@replit/database"),
31
+ languageFile = require('./Language/index.json'),
32
+ ObjFastConfig = {
33
+ "Language": "en",
34
+ "MainColor": "#9900FF",
35
+ "BroadCast": true,
36
+ "EncryptFeature": true,
37
+ "PreKey": "",
38
+ "Uptime": false
39
+ };
40
+
41
+
42
+ /!-[ Check File To Run Process ]-!/
43
+
44
+ try {
45
+ if (!fs.existsSync('./alice/alicezetion.json')) {
46
+ fs.writeFileSync("./alice/alicezetion.json", JSON.stringify(ObjFastConfig, null, "\t"));
47
+ process.exit(1);
48
+ } else if (fs.existsSync('./alice/alicezetion.json')) {
49
+ try {
50
+ var DataLanguageSetting = require("../../alicezetion.json");
51
+ } catch (e) {
52
+ logger("Invalid Config Settings, Restoring Default...");
53
+ fs.writeFileSync("./alice/alicezetion.json", JSON.stringify(ObjFastConfig, null, "\t"));
54
+ process.exit(1);
55
+ }
56
+ try {
57
+ if (DataLanguageSetting && !DataLanguageSetting.PreKey) {
58
+ DataLanguageSetting.PreKey = "";
59
+ fs.writeFileSync("./alice/alicezetion.json", JSON.stringify(DataLanguageSetting, null, "\t"));
60
+ }
61
+ } catch (e) {
62
+ console.log(e);
63
+ }
64
+ if (!languageFile.some(i => i.Language == DataLanguageSetting.Language)) {
65
+ logger("Not Support Language: " + DataLanguageSetting.Language + " Only 'en' and 'vi'", "[ Alicezetion ]");
66
+ process.exit(0);
67
+ }
68
+ var Language = languageFile.find(i => i.Language == DataLanguageSetting.Language).Folder.Index;
69
+ } else process.exit(1);
70
+ if (utils.getType(DataLanguageSetting.BroadCast) != "Boolean" && DataLanguageSetting.BroadCast != undefined) {
71
+ log.warn("FastConfig-BroadCast", getText.gettext(Language.IsNotABoolean, DataLanguageSetting.BroadCast));
72
+ process.exit(0)
73
+ } else if (DataLanguageSetting.BroadCast == undefined) {
74
+ fs.writeFileSync("./alice/alicezetion.json", JSON.stringify(ObjFastConfig, null, "\t"));
75
+ process.exit(1);
76
+ }
77
+
78
+ global.FastConfig = DataLanguageSetting;
79
+
80
+ } catch (e) {
81
+ console.log(e);
82
+ logger.Error();
83
+ }
84
+
85
+ /!-[ Set Variable For Process ]-!/
86
+
87
+ log.maxRecordSize = 100;
7
88
  var checkVerified = null;
8
89
 
9
- var defaultLogRecordSize = 100;
10
- log.maxRecordSize = defaultLogRecordSize;
90
+ /!-[ Function setOptions ]-!/
11
91
 
12
92
  function setOptions(globalOptions, options) {
13
93
  Object.keys(options).map(function(key) {
@@ -75,21 +155,23 @@ function setOptions(globalOptions, options) {
75
155
  });
76
156
  }
77
157
 
78
- function buildAPI(globalOptions, html, jar) {
79
- var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(val) {
80
- return val.cookieString().split("=")[0] === "c_user";
81
- });
158
+ /!-[ Function BuildAPI ]-!/
159
+
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"; });
82
162
 
83
- 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." };
163
+ if (maybeCookie.length === 0) throw { error: Language.ErrAppState };
84
164
 
85
- if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
165
+ if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
86
166
 
87
167
  var userID = maybeCookie[0].cookieString().split("=")[1].toString();
88
- //log.info("login", `Logged in as ${userID}`);
168
+ process.env['UID'] = userID;
89
169
 
90
170
  try {
91
171
  clearInterval(checkVerified);
92
- } catch (_) {}
172
+ } catch (e) {
173
+ console.log(e);
174
+ }
93
175
 
94
176
  var clientID = (Math.random() * 2147483648 | 0).toString(16);
95
177
 
@@ -103,39 +185,34 @@ function buildAPI(globalOptions, html, jar) {
103
185
  irisSeqID = oldFBMQTTMatch[1];
104
186
  mqttEndpoint = oldFBMQTTMatch[2];
105
187
  region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
106
- //log.info("login", `Got this account's message region: ${region}`);
188
+ logger(getText.gettext(Language.Area, region), "[ FCA-SUS ]");
107
189
  } else {
108
190
  let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
109
191
  if (newFBMQTTMatch) {
110
192
  irisSeqID = newFBMQTTMatch[2];
111
193
  mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
112
194
  region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
113
- // log.info("login", `Got this account's message region: ${region}`);
114
195
  } else {
115
196
  let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
116
197
  if (legacyFBMQTTMatch) {
117
198
  mqttEndpoint = legacyFBMQTTMatch[4];
118
199
  region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
119
- /* log.warn("login", `Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)...`);
120
- log.info("login", `Got this account's message region: ${region}`);
121
- log.info("login", `[Unused] Polling endpoint: ${legacyFBMQTTMatch[6]}`);*/
200
+ log.warn("login", `Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)...`);
201
+ logger("login", `[Unused] Polling endpoint: ${legacyFBMQTTMatch[6]}`);
122
202
  } else {
123
- /*log.warn("login", "» Cannot get MQTT region & sequence ID.");
124
- log.error("login", "» Please try closing and reopening your browser window or get new fbstate.");*/
203
+ log.warn("login", getText.gettext(Language.NoAreaData));
125
204
  noMqttData = html;
126
- process.exit();
127
205
  }
128
206
  }
129
207
  }
130
208
 
131
- // All data available to api functions
132
209
  var ctx = {
133
210
  userID: userID,
134
211
  jar: jar,
135
212
  clientID: clientID,
136
213
  globalOptions: globalOptions,
137
214
  loggedIn: true,
138
- access_token: 'NONE',
215
+ access_token: 'none',
139
216
  clientMutationId: 0,
140
217
  mqttClient: undefined,
141
218
  lastSeqId: irisSeqID,
@@ -154,67 +231,12 @@ function buildAPI(globalOptions, html, jar) {
154
231
 
155
232
  if (noMqttData) api["htmlData"] = noMqttData;
156
233
 
157
- const apiFuncNames = [
158
- 'addExternalModule',
159
- 'addUserToGroup',
160
- 'changeAdminStatus',
161
- 'changeArchivedStatus',
162
- 'changeBio',
163
- 'changeBlockedStatus',
164
- 'changeGroupImage',
165
- 'changeNickname',
166
- 'chat',
167
- 'changeThreadColor',
168
- 'changeThreadEmoji',
169
- 'createNewGroup',
170
- 'createPoll',
171
- 'deleteMessage',
172
- 'deleteThread',
173
- 'forwardAttachment',
174
- 'getCurrentUserID',
175
- 'getEmojiUrl',
176
- 'getFriendsList',
177
- 'getThreadHistory',
178
- 'getThreadInfo',
179
- 'getThreadList',
180
- 'getThreadPictures',
181
- 'getUserID',
182
- 'getUserInfo',
183
- 'handleFriendRequest',
184
- 'handleMessageRequest',
185
- 'listenMqtt',
186
- 'logout',
187
- 'markAsDelivered',
188
- 'markAsRead',
189
- 'markAsReadAll',
190
- 'markAsSeen',
191
- 'muteThread',
192
- 'removeUserFromGroup',
193
- 'resolvePhotoUrl',
194
- 'searchForThread',
195
- 'sendMessage',
196
- 'sendTypingIndicator',
197
- 'setMessageReaction',
198
- 'setTitle',
199
- 'threadColors',
200
- 'unsendMessage',
201
- 'unfriend',
202
-
203
- // HTTP
204
- 'httpGet',
205
- 'httpPost',
206
-
207
- // Deprecated features
208
- "getThreadListDeprecated",
209
- 'getThreadHistoryDeprecated',
210
- 'getThreadInfoDeprecated',
211
- ];
234
+ const apiFuncNames = fs.readdirSync(__dirname + "/src").filter((File) => File.endsWith(".js") && !File.includes('Dev'));
212
235
 
213
236
  var defaultFuncs = utils.makeDefaults(html, userID, ctx);
214
237
 
215
238
  // Load all api functions in a loop
216
- apiFuncNames.map(v => api[v] = require('./src/' + v)(defaultFuncs, api, ctx));
217
-
239
+ apiFuncNames.map(v => api[v.replace(".js", "")] = require('./src/' + v)(defaultFuncs, api, ctx));
218
240
  return [ctx, defaultFuncs, api];
219
241
  }
220
242
 
@@ -259,17 +281,15 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
259
281
  });
260
282
  // ---------- Very Hacky Part Ends -----------------
261
283
 
262
- //log.info("login", "Logging in...");
263
284
  return utils
264
285
  .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
265
286
  .then(utils.saveCookies(jar))
266
287
  .then(function(res) {
267
288
  var headers = res.headers;
268
- if (!headers.location) throw { error: "Wrong username/password." };
289
+ if (!headers.location) throw { error: Language.InvaildAccount };
269
290
 
270
291
  // This means the account has login approvals turned on.
271
292
  if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
272
- log.info("login", "You have login approvals turned on.");
273
293
  var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
274
294
 
275
295
  return utils
@@ -316,7 +336,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
316
336
  if (error) {
317
337
  throw {
318
338
  error: 'login-approval',
319
- errordesc: "Invalid 2FA code.",
339
+ errordesc: Language.InvaildTwoAuthCode,
320
340
  lerror: error,
321
341
  continue: submit2FA
322
342
  };
@@ -326,13 +346,13 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
326
346
  // Use the same form (safe I hope)
327
347
  delete form.no_fido;
328
348
  delete form.approvals_code;
329
- form.name_action_selected = 'dont_save'; //'save_device';
349
+ form.name_action_selected = 'save_device'; //'save_device' || 'dont_save;
330
350
 
331
351
  return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
332
352
  })
333
353
  .then(function(res) {
334
354
  var headers = res.headers;
335
- if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with login approvals." };
355
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: Language.ApprovalsErr };
336
356
 
337
357
  var appState = utils.getAppState(jar);
338
358
 
@@ -361,7 +381,6 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
361
381
  JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
362
382
  } catch (ex) {
363
383
  clearInterval(checkVerified);
364
- log.info("login", "Verified from browser. Logging in...");
365
384
  if (callback === prCallback) {
366
385
  callback = function(err, api) {
367
386
  if (err) return prReject(err);
@@ -381,7 +400,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
381
400
  }
382
401
  };
383
402
  } else {
384
- if (!loginOptions.forceLogin) throw { error: "Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again." };
403
+ if (!loginOptions.forceLogin) throw { error: Language.ForceLoginNotEnable };
385
404
 
386
405
  if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
387
406
  else form['submit[This Is Okay]'] = "This Is Okay";
@@ -416,33 +435,496 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
416
435
  };
417
436
  }
418
437
 
438
+ function makeid(length) {
439
+ var result = '';
440
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
441
+ var charactersLength = characters.length;
442
+ for (var i = 0; i < length; i++) {
443
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
444
+ }
445
+ return result;
446
+ }
447
+
448
+
419
449
  // Helps the login
420
- function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
450
+ async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
421
451
  var mainPromise = null;
422
452
  var jar = utils.getJar();
423
453
 
424
454
  // If we're given an appState we loop through it and save each cookie
425
455
  // back into the jar.
426
- if (appState) {
427
- appState.map(function(c) {
428
- var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
429
- jar.setCookie(str, "http://" + c.domain);
430
- });
456
+ try {
457
+ if (appState) {
458
+ //const readline = require("readline");
459
+ //const chalk = require("chalk");
460
+ //const figlet = require("figlet");
461
+ //const os = require("os");
462
+ //const { execSync } = require('child_process');
463
+ // let rl = readline.createInterface({
464
+ // input: process.stdin,
465
+ // output: process.stdout,
466
+ // prompt: chalk.hex('#00CCCC').bold('[FCA-SUS] • ')
467
+ // });
468
+ // let type = {
469
+ // 1: {
470
+ // "name": "Tạo Mật Khẩu Cho Appstate",
471
+ // onRun: async function() {
472
+ // try {
473
+ // rl.question("Hãy Nhập Mật Khẩu Bạn Muốn Đặt Cho Appstate !", (answer) => {
474
+ // console.log("Được Rồi Mật Khẩu Của Bạn Là: " + answer + ", Bạn Hãy Nhớ Kĩ Nhé !");
475
+ // process.env["FBKEY"] = answer;
476
+ // fs.writeFile('../.env', `FBKEY=${answer}`, function (err) {
477
+ // if (err) {
478
+ // submiterr(err)
479
+ // logger("Tạo File ENV Thất Bại !", "[ FCA-SUS ]")
480
+ // rl.pause();
481
+ // }
482
+ // else logger("Tạo Thành Công File ENV !","[ FCA-SUS ]")
483
+ // rl.pause();
484
+ // });
485
+ // })
486
+ // }
487
+ // catch (e) {
488
+ // console.log(e);
489
+ // logger("Đã Có Lỗi Khi Đang Try Tạo Ra Câu Hỏi =))", "[ FCA-SUS ]");
490
+ // rl.pause();
491
+ // }
492
+ // }
493
+ // },
494
+ // 2: {
495
+ // "name": "Tiếp Tục Chạy Fca Mà Không Cần Mã Hóa AppState",
496
+ // onRun: async function () {
497
+ // rl.pause();
498
+ // }
499
+ // },
500
+ // 3: {
501
+ // "name": "Đổi Mật Khẩu AppState (Comming Soon..)",
502
+ // onRun: async function () {
503
+ // console.log(chalk.red.bold("Đã bảo là comming soon rồi mà >:v"));
504
+ // }
505
+ // }
506
+ // }
507
+ // const localbrand = JSON.parse(readFileSync('./package.json')).name;
508
+ // const localbrand2 = JSON.parse(readFileSync('./node_modules/fca-sus/package.json')).version;
509
+ // var axios = require('axios');
510
+ // axios.get('https://raw.githubusercontent.com/amogusdevlol/fca-sus/main/package.json').then(async (res) => {
511
+ // if (localbrand.toUpperCase() == 'HORIZON') {
512
+ // console.group(chalk.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
513
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Hệ Điều Hành: " + chalk.bold.red(os.type()));
514
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Thông Tin Máy: " + chalk.bold.red(os.version()));
515
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Hiện Tại: " + chalk.bold.red(localbrand2));
516
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Mới Nhất: " + chalk.bold.red(res.data.version));
517
+ // console.groupEnd();
518
+ // }
519
+ // else {
520
+ // console.clear();
521
+ // console.log(figlet.textSync('TeamHorizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }))
522
+ // console.log(chalk.hex('#9966CC')(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`));
523
+ // }
524
+ // });
431
525
 
432
- // Load the main page.
433
- mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
434
- } else {
435
- // Open the main page, then we login with the given credentials and finally
436
- // load the main page again (it'll give us some IDs that we need)
437
- mainPromise = utils
438
- .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
439
- .then(utils.saveCookies(jar))
440
- .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
441
- .then(function() {
442
- return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
443
- });
444
- }
526
+ var backup = async(data) => {
527
+ if (fs.existsSync('./alicestate.json')) {
528
+ try {
529
+ fs.writeFileSync('./alicestate.json', data);
530
+ } catch (e) {
531
+ fs.writeFileSync('./alicestate.json', JSON.stringify(data, null, "\t"));
532
+ }
533
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
534
+ process.exit(1);
535
+ } else return logger.Error();
536
+ }
537
+
538
+ switch (process.platform) {
539
+ case "win32":
540
+ {
541
+ try {
542
+ var { body } = await Fetch('https://decrypt-appstate-production.up.railway.app/getKey');
543
+ process.env['FBKEY'] = JSON.parse(body).Data;
544
+ } catch (e) {
545
+ logger(Language.ErrGetPassWord);
546
+ logger.Error();
547
+ process.exit(1);
548
+ }
549
+ }
550
+ break;
551
+ case "linux":
552
+ {
553
+ if (process.env["REPL_ID"] == undefined) {
554
+ try {
555
+ var { body } = await Fetch.get('https://decrypt-appstate-production.up.railway.app/getKey');
556
+ process.env['FBKEY'] = JSON.parse(body).Data;
557
+ } catch (e) {
558
+ logger.Error();
559
+ process.exit(1);
560
+ }
561
+ } else {
562
+ /* try {
563
+ const client = new Client();
564
+ let key = await client.get("FBKEY");
565
+ if (!key) {
566
+ await client.set("FBKEY", makeid(49));
567
+ let key = await client.get("FBKEY");
568
+ process.env['FBKEY'] = key;
569
+ } else {
570
+ process.env['FBKEY'] = key;
571
+ }
572
+ } catch (e) {
573
+ logger(Language.ErrGenerateKey, '[ FCA-SUS ]');
574
+ logger(e, '[ FCA-SUS ]');
575
+ logger.Error();
576
+ process.exit(0)
577
+ }*/
578
+ }
579
+ }
580
+ break;
581
+ case "android":
582
+ {
583
+ try {
584
+ var { body } = await Fetch.get('https://decrypt-appstate-production.up.railway.app/getKey');
585
+ process.env['FBKEY'] = JSON.parse(body).Data;
586
+ } catch (e) {
587
+
588
+ return logger.Error();
589
+ }
590
+ }
591
+ break;
592
+ default:
593
+ {
594
+
595
+ logger.Error();
596
+ process.exit(0);
597
+ }
598
+ }
445
599
 
600
+ try {
601
+ switch (require("../../FastConfigFca.json").EncryptFeature) {
602
+ case true:
603
+ {
604
+ appState = JSON.parse(JSON.stringify(appState, null, "\t"));
605
+ switch (utils.getType(appState)) {
606
+ case "Array":
607
+ {
608
+
609
+ }
610
+ break;
611
+ case "String":
612
+ {
613
+ try {
614
+ appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
615
+ logger(Language.DecryptSuccess, '[ FCA-SUS ]');
616
+ } catch (e) {
617
+ if (process.env.Backup != undefined && process.env.Backup) {
618
+ backup(process.env.Backup);
619
+ } else switch (process.platform) {
620
+ case "win32":
621
+ {
622
+ try {
623
+ if (fs.existsSync('./backupappstate.json')) {
624
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
625
+ return backup(content);
626
+ }
627
+ } catch (e) {
628
+
629
+ logger.Error();
630
+ process.exit(0);
631
+ }
632
+ }
633
+ break;
634
+ case "linux":
635
+ {
636
+ if (process.env["REPL_ID"] == undefined) {
637
+ try {
638
+ if (fs.existsSync('./backupappstate.json')) {
639
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
640
+ return backup(content);
641
+ }
642
+ } catch (e) {
643
+ //logger(Language.ErrBackup, '[ FCA-SUS ]');
644
+ logger.Error();
645
+ process.exit(0);
646
+ }
647
+ } else {
648
+ try {
649
+ const client = new Client();
650
+ let key = await client.get("Backup");
651
+ if (key) {
652
+ return backup(JSON.stringify(key));
653
+ } else {
654
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
655
+ }
656
+ } catch (e) {
657
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
658
+ }
659
+ }
660
+ }
661
+ break;
662
+ case "android":
663
+ {
664
+ try {
665
+ if (fs.existsSync('./backupappstate.json')) {
666
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
667
+ return backup(content);
668
+ }
669
+ } catch (e) {
670
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
671
+ logger.Error();
672
+ process.exit(0);
673
+ }
674
+ }
675
+ }
676
+ logger(Language.DecryptFailed, '[ FCA-SUS ]');
677
+ return logger.Error();
678
+ }
679
+ logger(getText.gettext(Language.YourAppStatePass, process.env.FBKEY), '[ FCA-SUS ]');
680
+ }
681
+ break;
682
+ default:
683
+ {
684
+ logger(Language.InvaildAppState, "[ FCA-SUS ]");
685
+ process.exit(0)
686
+ }
687
+ }
688
+ }
689
+ break;
690
+ case false:
691
+ {
692
+ switch (utils.getType(appState)) {
693
+ case "Array":
694
+ {
695
+ logger(Language.EncryptStateOff, "[ FCA-SUS ]");
696
+ }
697
+ break;
698
+ case "String":
699
+ {
700
+ logger(Language.EncryptStateOff, "[ FCA-SUS ]");
701
+ try {
702
+ appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
703
+ logger(Language.DecryptSuccess, '[ FCA-SUS ]');
704
+ } catch (e) {
705
+ if (process.env.Backup != undefined && process.env.Backup) {
706
+ backup(process.env.Backup);
707
+ } else switch (process.platform) {
708
+ case "win32":
709
+ {
710
+ try {
711
+ if (fs.existsSync('./backupappstate.json')) {
712
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
713
+ return backup(content);
714
+ }
715
+ } catch (e) {
716
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
717
+ logger.Error();
718
+ process.exit(0);
719
+ }
720
+ }
721
+ break;
722
+ case "linux":
723
+ {
724
+ if (process.env["REPL_ID"] == undefined) {
725
+ try {
726
+ if (fs.existsSync('./backupappstate.json')) {
727
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
728
+ return backup(content);
729
+ }
730
+ } catch (e) {
731
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
732
+ logger.Error();
733
+ process.exit(0);
734
+ }
735
+ } else {
736
+ try {
737
+ const client = new Client();
738
+ let key = await client.get("Backup");
739
+ if (key) {
740
+ return backup(JSON.stringify(key));
741
+ } else {
742
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
743
+ }
744
+ } catch (e) {
745
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
746
+ }
747
+ }
748
+ }
749
+ break;
750
+ case "android":
751
+ {
752
+ try {
753
+ if (fs.existsSync('./backupappstate.json')) {
754
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
755
+ return backup(content);
756
+ }
757
+ } catch (e) {
758
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
759
+ logger.Error();
760
+ process.exit(0);
761
+ }
762
+ }
763
+ }
764
+ logger(Language.DecryptFailed, '[ FCA-SUS ]');
765
+ return logger.Error();
766
+ }
767
+ }
768
+ break;
769
+ default:
770
+ {
771
+ logger(Language.InvaildAppState, "[ FCA-SUS ]");
772
+ process.exit(0)
773
+ }
774
+ }
775
+ }
776
+ break;
777
+ default:
778
+ {
779
+ logger(getText.gettext(Language.IsNotABoolean, require("../../FastConfigFca.json").EncryptFeature), "[ FCA-SUS ]")
780
+ process.exit(0);
781
+ }
782
+ }
783
+ } catch (e) {
784
+ console.log(e);
785
+ }
786
+
787
+ try {
788
+ appState = JSON.parse(appState);
789
+ } catch (e) {
790
+ try {
791
+ appState = appState;
792
+ } catch (e) {
793
+ return logger.Error();
794
+ }
795
+ }
796
+ try {
797
+ appState.map(function(c) {
798
+ var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
799
+ jar.setCookie(str, "http://" + c.domain);
800
+ });
801
+ switch (process.platform) {
802
+ case "win32":
803
+ {
804
+ try {
805
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
806
+ process.env.Backup = JSON.stringify(appState, null, "\t");
807
+ } catch (e) {
808
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
809
+ }
810
+ }
811
+ break;
812
+ case "linux":
813
+ {
814
+ if (process.env["REPL_ID"] == undefined) {
815
+ try {
816
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
817
+ process.env.Backup = JSON.stringify(appState, null, "\t");
818
+ } catch (e) {
819
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
820
+ }
821
+ } else {
822
+ try {
823
+ if (fs.existsSync('./backupappstate.json')) {
824
+ fs.unlinkSync('./backupappstate.json');
825
+ }
826
+ const client = new Client();
827
+ await client.set("Backup", appState);
828
+ process.env.Backup = JSON.stringify(appState, null, "\t");
829
+ } catch (e) {
830
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
831
+ }
832
+ }
833
+ }
834
+ break;
835
+ case "android":
836
+ {
837
+ try {
838
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
839
+ process.env.Backup = JSON.stringify(appState, null, "\t");
840
+ } catch (e) {
841
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
842
+ }
843
+ }
844
+ }
845
+
846
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
847
+ } catch (e) {
848
+
849
+ if (process.env.Backup != undefined && process.env.Backup) {
850
+ return backup(process.env.Backup);
851
+ }
852
+ switch (process.platform) {
853
+ case "win32":
854
+ {
855
+ try {
856
+ if (fs.existsSync('./backupappstate.json')) {
857
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
858
+ return backup(content);
859
+ }
860
+ } catch (e) {
861
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
862
+ logger.Error();
863
+ process.exit(0);
864
+ }
865
+ }
866
+ break;
867
+ case "linux":
868
+ {
869
+ if (process.env["REPL_ID"] == undefined) {
870
+ try {
871
+ if (fs.existsSync('./backupappstate.json')) {
872
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
873
+ return backup(content);
874
+ }
875
+ } catch (e) {
876
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
877
+ logger.Error();
878
+ process.exit(0);
879
+ }
880
+ } else {
881
+ try {
882
+ const client = new Client();
883
+ let key = await client.get("Backup");
884
+ if (key) {
885
+ backup(JSON.stringify(key));
886
+ } else {
887
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
888
+ }
889
+ } catch (e) {
890
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
891
+ }
892
+ }
893
+ }
894
+ break;
895
+ case "android":
896
+ {
897
+ try {
898
+ if (fs.existsSync('./backupappstate.json')) {
899
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
900
+ return backup(content);
901
+ }
902
+ } catch (e) {
903
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
904
+ logger.Error();
905
+ process.exit(0);
906
+ }
907
+ }
908
+ break;
909
+ }
910
+
911
+ console.log(e);
912
+ return //logger(Language.ScreenShotConsoleAndSendToAdmin, '[ FCA-SUS ]');
913
+ }
914
+ } else {
915
+ // Open the main page, then we login with the given credentials and finally
916
+ // load the main page again (it'll give us some IDs that we need)
917
+ mainPromise = utils
918
+ .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
919
+ .then(utils.saveCookies(jar))
920
+ .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
921
+ .then(function() {
922
+ return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
923
+ });
924
+ }
925
+ } catch (e) {
926
+ console.log(e);
927
+ }
446
928
  var ctx = null;
447
929
  var _defaultFuncs = null;
448
930
  var api = null;
@@ -455,15 +937,14 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
455
937
  if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
456
938
  return res;
457
939
  })
458
- .then(function(res) {
940
+ .then(async function(res) {
459
941
  var html = res.body;
460
- var stuff = buildAPI(globalOptions, html, jar);
942
+ var stuff = await buildAPI(globalOptions, html, jar);
461
943
  ctx = stuff[0];
462
944
  _defaultFuncs = stuff[1];
463
945
  api = stuff[2];
464
946
  return res;
465
947
  });
466
-
467
948
  // given a pageID we log in as a page
468
949
  if (globalOptions.pageID) {
469
950
  mainPromise = mainPromise
@@ -480,13 +961,57 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
480
961
  // At the end we call the callback or catch an exception
481
962
  mainPromise
482
963
  .then(function() {
483
- //log.info("login", 'Done logging in.');
484
- return callback(null, api);
485
- })
486
- .catch(function(e) {
964
+ /*logger(Language.DoneLogin, "[ FCA-SUS ]");
965
+ logger(Language.AutoCheckUpdate, "[ FCA-SUS ]");*/
966
+ //!---------- Auto Check, Update START -----------------!//
967
+ var Fetch = require('got');
968
+ var { readFileSync } = require('fs-extra');
969
+ const { execSync } = require('child_process');
970
+ Fetch('https://raw.githubusercontent.com/amogusdevlol/node-ainzfb/main/package.json').then(async(res) => {
971
+ const localbrand = JSON.parse(readFileSync('./node_modules/node-ainzfb-new/package.json')).version;
972
+ if (Number(localbrand.replace(/\./g, "")) < Number(JSON.parse(res.body.toString()).version.replace(/\./g, ""))) {
973
+ // log.warn("[ FCA-SUS ] •", getText.gettext(Language.NewVersionFound, JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version, JSON.parse(res.body.toString()).version));
974
+ log.warn("[ FCA-SUS ] •", Language.AutoUpdate);
975
+ try {
976
+ execSync('npm install node-ainzfb-new@latest', { stdio: 'inherit' });
977
+ logger(Language.UpdateSuccess, "[ FCA-SUS ]")
978
+ logger(Language.RestartAfterUpdate, '[ FCA-SUS ]');
979
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
980
+ console.clear();
981
+ process.exit(1);
982
+ } catch (err) {
983
+ log.warn('Error Update: ' + err);
984
+ logger(Language.UpdateFailed, "[ FCA-SUS ]");
985
+ try {
986
+ require.resolve('sus-support');
987
+ } catch (e) {
988
+ logger(Language.InstallSupportTool, "[ FCA-SUS ]");
989
+ execSync('npm install git+https://github.com/amogusdevlol/sus-support.git', { stdio: 'inherit' });
990
+ process.exit(1);
991
+ }
992
+ var fcasp = require('sus-support');
993
+ try {
994
+ fcasp.onError()
995
+ } catch (e) {
996
+ //logger(Language.NotiAfterUseToolFail, "[ Fca - Helper ]")
997
+ //logger("rmdir ./node_modules then enter npm i && npm start", "[ Fca - Helper ]");
998
+ process.exit(0);
999
+ }
1000
+
1001
+ }
1002
+ } else {
1003
+ /*logger(getText.gettext(Language.LocalVersion, localbrand), "[ FCA-SUS ]");
1004
+ logger(Language.WishMessage[Math.floor(Math.random() * Language.WishMessage.length)], "[ FCA-SUS ]");*/
1005
+ require('./Extra/ExtraUptimeRobot')()
1006
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
1007
+ callback(null, api);
1008
+ }
1009
+ });
1010
+ }).catch(function(e) {
487
1011
  log.error("login", e.error || e);
488
1012
  callback(e);
489
1013
  });
1014
+ //!---------- Auto Check, Update END -----------------!//
490
1015
  }
491
1016
 
492
1017
  function login(loginData, options, callback) {
@@ -502,14 +1027,17 @@ function login(loginData, options, callback) {
502
1027
  updatePresence: false,
503
1028
  forceLogin: false,
504
1029
  autoMarkDelivery: false,
505
- autoMarkRead: true,
1030
+ autoMarkRead: false,
506
1031
  autoReconnect: true,
507
- logRecordSize: defaultLogRecordSize,
1032
+ logRecordSize: 100,
508
1033
  online: false,
509
1034
  emitReady: false,
510
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18"
1035
+ 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"
511
1036
  };
512
1037
 
1038
+ //! bằng 1 cách nào đó tắt online sẽ đánh lừa được facebook :v
1039
+ //! phải có that có this chứ :v
1040
+
513
1041
  setOptions(globalOptions, options);
514
1042
 
515
1043
  var prCallback = null;
@@ -530,4 +1058,11 @@ function login(loginData, options, callback) {
530
1058
  return returnPromise;
531
1059
  }
532
1060
 
533
- module.exports = login;
1061
+ module.exports = alice;
1062
+
1063
+
1064
+
1065
+
1066
+
1067
+
1068
+