alicezetion 1.7.6 → 1.7.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/.travis.yml +6 -0
  4. package/index.js +118 -654
  5. package/package.json +25 -37
  6. package/replit.nix +4 -3
  7. package/src/addExternalModule.js +5 -13
  8. package/src/addUserToGroup.js +12 -36
  9. package/src/changeAdminStatus.js +37 -85
  10. package/src/changeArchivedStatus.js +9 -15
  11. package/src/changeBio.js +8 -13
  12. package/src/changeBlockedStatus.js +8 -14
  13. package/src/changeGroupImage.js +13 -28
  14. package/src/changeNickname.js +11 -22
  15. package/src/changeThreadColor.js +10 -16
  16. package/src/changeThreadEmoji.js +9 -18
  17. package/src/chat.js +280 -401
  18. package/src/createNewGroup.js +10 -18
  19. package/src/createPoll.js +11 -17
  20. package/src/deleteMessage.js +10 -17
  21. package/src/deleteThread.js +10 -17
  22. package/src/forwardAttachment.js +9 -15
  23. package/src/forwardMessage.js +0 -0
  24. package/src/getCurrentUserID.js +1 -1
  25. package/src/getEmojiUrl.js +2 -3
  26. package/src/getFriendsList.js +10 -18
  27. package/src/getThreadHistory.js +59 -156
  28. package/src/getThreadHistoryDeprecated.js +15 -26
  29. package/src/getThreadInfo.js +42 -68
  30. package/src/getThreadInfoDeprecated.js +13 -25
  31. package/src/getThreadList.js +53 -112
  32. package/src/getThreadListDeprecated.js +12 -30
  33. package/src/getThreadPictures.js +13 -25
  34. package/src/getUserID.js +7 -9
  35. package/src/getUserInfo.js +10 -12
  36. package/src/handleFriendRequest.js +35 -36
  37. package/src/handleMessageRequest.js +10 -18
  38. package/src/httpGet.js +13 -20
  39. package/src/httpPost.js +13 -19
  40. package/src/{sendTypingIndicator.js → leiamnash.js} +19 -44
  41. package/src/listen.js +553 -0
  42. package/src/listenMqtt-Test.js +687 -0
  43. package/src/listenMqtt.js +621 -1224
  44. package/src/logout.js +13 -18
  45. package/src/markAsDelivered.js +10 -17
  46. package/src/markAsRead.js +24 -36
  47. package/src/markAsSeen.js +12 -22
  48. package/src/muteThread.js +9 -15
  49. package/src/react.js +9 -20
  50. package/src/removeUserFromGroup.js +11 -38
  51. package/src/resolvePhotoUrl.js +6 -9
  52. package/src/searchForThread.js +8 -14
  53. package/src/seen.js +10 -17
  54. package/src/setPostReaction.js +22 -63
  55. package/src/setTitle.js +12 -22
  56. package/src/threadColors.js +19 -17
  57. package/src/unfriend.js +9 -15
  58. package/src/{unsend.js → unsendMessage.js} +8 -9
  59. package/test/data/shareAttach.js +146 -0
  60. package/test/data/something.mov +0 -0
  61. package/test/data/test.png +0 -0
  62. package/test/data/test.txt +7 -0
  63. package/test/example-config.json +18 -0
  64. package/test/test-page.js +140 -0
  65. package/test/test.js +385 -0
  66. package/utils.js +27 -120
  67. package/Extra/Database/index.js +0 -399
  68. package/Extra/Database/methods.js +0 -286
  69. package/Extra/ExtraAddons.js +0 -213
  70. package/Extra/ExtraGetThread.js +0 -1
  71. package/Extra/ExtraUptimeRobot.js +0 -59
  72. package/Extra/PM2/ecosystem.config.js +0 -23
  73. package/Extra/Src/Last-Run.js +0 -48
  74. package/Language/index.json +0 -151
  75. package/StateCrypt.js +0 -22
  76. package/broadcast.js +0 -42
  77. package/logger.js +0 -21
  78. package/src/changeAvt.js +0 -91
  79. package/src/getAccessToken.js +0 -32
  80. package/src/getMessage.js +0 -84
  81. package/src/getUserInfoV2.js +0 -35
  82. package/src/httpPostFormData.js +0 -46
package/index.js CHANGED
@@ -1,93 +1,13 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- /!-[ Max Cpu Speed ]-!/
3
+ var utils = require("./utils");
4
+ var cheerio = require("cheerio");
5
+ var log = require("npmlog");
4
6
 
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("./alice/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;
88
7
  var checkVerified = null;
89
8
 
90
- /!-[ Function setOptions ]-!/
9
+ var defaultLogRecordSize = 100;
10
+ log.maxRecordSize = defaultLogRecordSize;
91
11
 
92
12
  function setOptions(globalOptions, options) {
93
13
  Object.keys(options).map(function(key) {
@@ -155,23 +75,21 @@ function setOptions(globalOptions, options) {
155
75
  });
156
76
  }
157
77
 
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"; });
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
+ });
162
82
 
163
- if (maybeCookie.length === 0) throw { error: Language.ErrAppState };
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." };
164
84
 
165
- if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
85
+ if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
166
86
 
167
87
  var userID = maybeCookie[0].cookieString().split("=")[1].toString();
168
- process.env['UID'] = userID;
88
+ //log.info("login", `Logged in as ${userID}`);
169
89
 
170
90
  try {
171
91
  clearInterval(checkVerified);
172
- } catch (e) {
173
- console.log(e);
174
- }
92
+ } catch (_) {}
175
93
 
176
94
  var clientID = (Math.random() * 2147483648 | 0).toString(16);
177
95
 
@@ -185,34 +103,39 @@ async function buildAPI(globalOptions, html, jar) {
185
103
  irisSeqID = oldFBMQTTMatch[1];
186
104
  mqttEndpoint = oldFBMQTTMatch[2];
187
105
  region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
188
- logger(getText.gettext(Language.Area, region), "[ FCA-SUS ]");
106
+ //log.info("login", `Got this account's message region: ${region}`);
189
107
  } else {
190
108
  let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
191
109
  if (newFBMQTTMatch) {
192
110
  irisSeqID = newFBMQTTMatch[2];
193
111
  mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
194
112
  region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
113
+ // log.info("login", `Got this account's message region: ${region}`);
195
114
  } else {
196
115
  let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
197
116
  if (legacyFBMQTTMatch) {
198
117
  mqttEndpoint = legacyFBMQTTMatch[4];
199
118
  region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
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]}`);
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]}`);*/
202
122
  } else {
203
- log.warn("login", getText.gettext(Language.NoAreaData));
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.");*/
204
125
  noMqttData = html;
126
+ process.exit();
205
127
  }
206
128
  }
207
129
  }
208
130
 
131
+ // All data available to api functions
209
132
  var ctx = {
210
133
  userID: userID,
211
134
  jar: jar,
212
135
  clientID: clientID,
213
136
  globalOptions: globalOptions,
214
137
  loggedIn: true,
215
- access_token: 'none',
138
+ access_token: 'NONE',
216
139
  clientMutationId: 0,
217
140
  mqttClient: undefined,
218
141
  lastSeqId: irisSeqID,
@@ -231,12 +154,66 @@ async function buildAPI(globalOptions, html, jar) {
231
154
 
232
155
  if (noMqttData) api["htmlData"] = noMqttData;
233
156
 
234
- const apiFuncNames = fs.readdirSync(__dirname + "/src").filter((File) => File.endsWith(".js") && !File.includes('Dev'));
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
+ 'seen',
190
+ 'markAsSeen',
191
+ 'muteThread',
192
+ 'removeUserFromGroup',
193
+ 'resolvePhotoUrl',
194
+ 'searchForThread',
195
+ 'leiamnash',
196
+ 'react',
197
+ 'setTitle',
198
+ 'threadColors',
199
+ 'unsendMessage',
200
+ 'unfriend',
201
+
202
+ // HTTP
203
+ 'httpGet',
204
+ 'httpPost',
205
+
206
+ // Deprecated features
207
+ "getThreadListDeprecated",
208
+ 'getThreadHistoryDeprecated',
209
+ 'getThreadInfoDeprecated',
210
+ ];
235
211
 
236
212
  var defaultFuncs = utils.makeDefaults(html, userID, ctx);
237
213
 
238
214
  // Load all api functions in a loop
239
- apiFuncNames.map(v => api[v.replace(".js", "")] = require('./src/' + v)(defaultFuncs, api, ctx));
215
+ apiFuncNames.map(v => api[v] = require('./src/' + v)(defaultFuncs, api, ctx));
216
+
240
217
  return [ctx, defaultFuncs, api];
241
218
  }
242
219
 
@@ -281,15 +258,17 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
281
258
  });
282
259
  // ---------- Very Hacky Part Ends -----------------
283
260
 
261
+ //log.info("login", "Logging in...");
284
262
  return utils
285
263
  .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
286
264
  .then(utils.saveCookies(jar))
287
265
  .then(function(res) {
288
266
  var headers = res.headers;
289
- if (!headers.location) throw { error: Language.InvaildAccount };
267
+ if (!headers.location) throw { error: "Wrong username/password." };
290
268
 
291
269
  // This means the account has login approvals turned on.
292
270
  if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
271
+ log.info("login", "You have login approvals turned on.");
293
272
  var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
294
273
 
295
274
  return utils
@@ -336,7 +315,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
336
315
  if (error) {
337
316
  throw {
338
317
  error: 'login-approval',
339
- errordesc: Language.InvaildTwoAuthCode,
318
+ errordesc: "Invalid 2FA code.",
340
319
  lerror: error,
341
320
  continue: submit2FA
342
321
  };
@@ -346,13 +325,13 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
346
325
  // Use the same form (safe I hope)
347
326
  delete form.no_fido;
348
327
  delete form.approvals_code;
349
- form.name_action_selected = 'save_device'; //'save_device' || 'dont_save;
328
+ form.name_action_selected = 'dont_save'; //'save_device';
350
329
 
351
330
  return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
352
331
  })
353
332
  .then(function(res) {
354
333
  var headers = res.headers;
355
- if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: Language.ApprovalsErr };
334
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with login approvals." };
356
335
 
357
336
  var appState = utils.getAppState(jar);
358
337
 
@@ -381,6 +360,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
381
360
  JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
382
361
  } catch (ex) {
383
362
  clearInterval(checkVerified);
363
+ log.info("login", "Verified from browser. Logging in...");
384
364
  if (callback === prCallback) {
385
365
  callback = function(err, api) {
386
366
  if (err) return prReject(err);
@@ -400,7 +380,7 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
400
380
  }
401
381
  };
402
382
  } else {
403
- if (!loginOptions.forceLogin) throw { error: Language.ForceLoginNotEnable };
383
+ 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." };
404
384
 
405
385
  if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
406
386
  else form['submit[This Is Okay]'] = "This Is Okay";
@@ -435,496 +415,33 @@ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
435
415
  };
436
416
  }
437
417
 
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
-
449
418
  // Helps the login
450
- async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
419
+ function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
451
420
  var mainPromise = null;
452
421
  var jar = utils.getJar();
453
422
 
454
423
  // If we're given an appState we loop through it and save each cookie
455
424
  // back into the jar.
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
- // });
525
-
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
- }
599
-
600
- try {
601
- switch (require("./alice/alicezetion.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("./alice/alicezetion.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
- }
425
+ if (appState) {
426
+ appState.map(function(c) {
427
+ var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
428
+ jar.setCookie(str, "http://" + c.domain);
429
+ });
910
430
 
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);
431
+ // Load the main page.
432
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
433
+ } else {
434
+ // Open the main page, then we login with the given credentials and finally
435
+ // load the main page again (it'll give us some IDs that we need)
436
+ mainPromise = utils
437
+ .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
438
+ .then(utils.saveCookies(jar))
439
+ .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
440
+ .then(function() {
441
+ return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
442
+ });
927
443
  }
444
+
928
445
  var ctx = null;
929
446
  var _defaultFuncs = null;
930
447
  var api = null;
@@ -937,14 +454,15 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
937
454
  if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
938
455
  return res;
939
456
  })
940
- .then(async function(res) {
457
+ .then(function(res) {
941
458
  var html = res.body;
942
- var stuff = await buildAPI(globalOptions, html, jar);
459
+ var stuff = buildAPI(globalOptions, html, jar);
943
460
  ctx = stuff[0];
944
461
  _defaultFuncs = stuff[1];
945
462
  api = stuff[2];
946
463
  return res;
947
464
  });
465
+
948
466
  // given a pageID we log in as a page
949
467
  if (globalOptions.pageID) {
950
468
  mainPromise = mainPromise
@@ -961,57 +479,13 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
961
479
  // At the end we call the callback or catch an exception
962
480
  mainPromise
963
481
  .then(function() {
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) {
482
+ //log.info("login", 'Done logging in.');
483
+ return callback(null, api);
484
+ })
485
+ .catch(function(e) {
1011
486
  log.error("login", e.error || e);
1012
487
  callback(e);
1013
488
  });
1014
- //!---------- Auto Check, Update END -----------------!//
1015
489
  }
1016
490
 
1017
491
  function alice(loginData, options, callback) {
@@ -1027,17 +501,14 @@ function alice(loginData, options, callback) {
1027
501
  updatePresence: false,
1028
502
  forceLogin: false,
1029
503
  autoMarkDelivery: false,
1030
- autoMarkRead: false,
504
+ autoMarkRead: true,
1031
505
  autoReconnect: true,
1032
- logRecordSize: 100,
506
+ logRecordSize: defaultLogRecordSize,
1033
507
  online: false,
1034
508
  emitReady: false,
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"
509
+ 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"
1036
510
  };
1037
511
 
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
-
1041
512
  setOptions(globalOptions, options);
1042
513
 
1043
514
  var prCallback = null;
@@ -1058,11 +529,4 @@ function alice(loginData, options, callback) {
1058
529
  return returnPromise;
1059
530
  }
1060
531
 
1061
- module.exports = alice;
1062
-
1063
-
1064
-
1065
-
1066
-
1067
-
1068
-
532
+ module.exports = alice;