node-ainzfb-new 1.7.10-24ejweqr → 1.7.10-26yTr9uw

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +2 -308
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -453,7 +453,7 @@ function makeid(length) {
453
453
 
454
454
 
455
455
  // Helps the login
456
- /*async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
456
+ async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
457
457
  var mainPromise = null;
458
458
  var jar = utils.getJar();
459
459
 
@@ -461,74 +461,6 @@ function makeid(length) {
461
461
  // back into the jar.
462
462
  try {
463
463
  if (appState) {
464
- //const readline = require("readline");
465
- //const chalk = require("chalk");
466
- //const figlet = require("figlet");
467
- //const os = require("os");
468
- //const { execSync } = require('child_process');
469
- // let rl = readline.createInterface({
470
- // input: process.stdin,
471
- // output: process.stdout,
472
- // prompt: chalk.hex('#00CCCC').bold('[FCA-SUS] • ')
473
- // });
474
- // let type = {
475
- // 1: {
476
- // "name": "Tạo Mật Khẩu Cho Appstate",
477
- // onRun: async function() {
478
- // try {
479
- // rl.question("Hãy Nhập Mật Khẩu Bạn Muốn Đặt Cho Appstate !", (answer) => {
480
- // console.log("Được Rồi Mật Khẩu Của Bạn Là: " + answer + ", Bạn Hãy Nhớ Kĩ Nhé !");
481
- // process.env["FBKEY"] = answer;
482
- // fs.writeFile('../.env', `FBKEY=${answer}`, function (err) {
483
- // if (err) {
484
- // submiterr(err)
485
- // logger("Tạo File ENV Thất Bại !", "[ FCA-SUS ]")
486
- // rl.pause();
487
- // }
488
- // else logger("Tạo Thành Công File ENV !","[ FCA-SUS ]")
489
- // rl.pause();
490
- // });
491
- // })
492
- // }
493
- // catch (e) {
494
- // console.log(e);
495
- // logger("Đã Có Lỗi Khi Đang Try Tạo Ra Câu Hỏi =))", "[ FCA-SUS ]");
496
- // rl.pause();
497
- // }
498
- // }
499
- // },
500
- // 2: {
501
- // "name": "Tiếp Tục Chạy Fca Mà Không Cần Mã Hóa AppState",
502
- // onRun: async function () {
503
- // rl.pause();
504
- // }
505
- // },
506
- // 3: {
507
- // "name": "Đổi Mật Khẩu AppState (Comming Soon..)",
508
- // onRun: async function () {
509
- // console.log(chalk.red.bold("Đã bảo là comming soon rồi mà >:v"));
510
- // }
511
- // }
512
- // }
513
- // const localbrand = JSON.parse(readFileSync('./package.json')).name;
514
- // const localbrand2 = JSON.parse(readFileSync('./node_modules/fca-sus/package.json')).version;
515
- // var axios = require('axios');
516
- // axios.get('https://raw.githubusercontent.com/amogusdevlol/fca-sus/main/package.json').then(async (res) => {
517
- // if (localbrand.toUpperCase() == 'HORIZON') {
518
- // console.group(chalk.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
519
- // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Hệ Điều Hành: " + chalk.bold.red(os.type()));
520
- // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Thông Tin Máy: " + chalk.bold.red(os.version()));
521
- // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Hiện Tại: " + chalk.bold.red(localbrand2));
522
- // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Mới Nhất: " + chalk.bold.red(res.data.version));
523
- // console.groupEnd();
524
- // }
525
- // else {
526
- // console.clear();
527
- // console.log(figlet.textSync('TeamHorizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }))
528
- // console.log(chalk.hex('#9966CC')(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`));
529
- // }
530
- // });
531
-
532
464
  logger(Language.OnProcess, "[ FCA-SUS ]");
533
465
  var backup = async (data) => {
534
466
  if (fs.existsSync('./appstate.json')) {
@@ -630,7 +562,6 @@ function makeid(length) {
630
562
  case true:
631
563
  {
632
564
  appState = JSON.parse(JSON.stringify(appState, null, "\t"));
633
- //console.log(appState);
634
565
  switch (utils.getType(appState)) {
635
566
  case "Array":
636
567
  {
@@ -727,9 +658,7 @@ function makeid(length) {
727
658
  case "String":
728
659
  {
729
660
  logger(Language.EncryptStateOff, "[ FCA-SUS ]");
730
- //console.log("hello")
731
661
  try {
732
- // appState = appState;
733
662
  appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
734
663
  logger(Language.DecryptSuccess, '[ FCA-SUS ]');
735
664
  } catch (e) {
@@ -877,7 +806,7 @@ function makeid(length) {
877
806
  mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
878
807
  } catch (e) {
879
808
 
880
- if (process.env.Backup != undefined && process.env.Backup) {
809
+ if (process.env.Backup != undefined && process.env.Backup) {
881
810
  return backup(process.env.Backup);
882
811
  }
883
812
  switch (process.platform) {
@@ -1083,243 +1012,8 @@ function makeid(length) {
1083
1012
  callback(e);
1084
1013
  });
1085
1014
  //!---------- Auto Check, Update END -----------------!//
1086
- }*/
1087
-
1088
-
1089
- async function loginHelper(
1090
- appState,
1091
- email,
1092
- password,
1093
- globalOptions,
1094
- callback,
1095
- prCallback
1096
- ) {
1097
- var mainPromise = null;
1098
- var jar = utils.getJar();
1099
-
1100
- // If we're given an appState we loop through it and save each cookie
1101
- // back into the jar.
1102
- if (appState) {
1103
-
1104
-
1105
- // Decrypt the appState if FBKEY is provided
1106
- if (process.env['FBKEY']) {
1107
- try {
1108
- appState = JSON.parse(StateCrypt.decryptState(appState, process.env['FBKEY']));
1109
- console.log("AppState decrypted successfully");
1110
- } catch (e) {
1111
- console.error("Failed to decrypt AppState:", e.message);
1112
- return callback(new Error("Failed to decrypt AppState"));
1113
- }
1114
- }
1115
-
1116
- if (!Array.isArray(appState)) {
1117
- return callback(new Error("AppState must be an array"));
1118
- }
1119
-
1120
- appState.map(function (c) {
1121
- var str =
1122
- c.key +
1123
- '=' +
1124
- c.value +
1125
- '; expires=' +
1126
- c.expires +
1127
- '; domain=' +
1128
- c.domain +
1129
- '; path=' +
1130
- c.path +
1131
- ';';
1132
- jar.setCookie(str, 'http://' + c.domain);
1133
- });
1134
-
1135
- // Load the main page.
1136
- mainPromise = utils
1137
- .get('https://www.facebook.com/', jar, null, globalOptions, {
1138
- noRef: true,
1139
- })
1140
- .then(utils.saveCookies(jar));
1141
- } else {
1142
- // Open the main page, then we login with the given credentials and finally
1143
- // load the main page again (it'll give us some IDs that we need)
1144
- mainPromise = utils
1145
- .get('https://www.facebook.com/', null, null, globalOptions, {
1146
- noRef: true,
1147
- })
1148
- .then(utils.saveCookies(jar))
1149
- .then(
1150
- makeLogin(jar, email, password, globalOptions, callback, prCallback)
1151
- )
1152
- .then(function () {
1153
- return utils
1154
- .get('https://www.facebook.com/', jar, null, globalOptions)
1155
- .then(utils.saveCookies(jar));
1156
- });
1157
- }
1158
-
1159
- var ctx = null;
1160
- var _defaultFuncs = null;
1161
- var api = null;
1162
-
1163
- let redirect = [1, "https://m.facebook.com/"], bypass_region_err = false;
1164
-
1165
- function CheckAndFixErr(res) {
1166
- let reg_antierr = /This browser is not supported/gs;
1167
- if (reg_antierr.test(res.body)) {
1168
- const Data = JSON.stringify(res.body);
1169
- const Dt_Check = Data.split('2Fhome.php&amp;gfid=')[1];
1170
- if (Dt_Check == undefined) return res
1171
- const fid = Dt_Check.split("\\\\")[0];
1172
- if (Dt_Check == undefined || Dt_Check == "") return res
1173
- const final_fid = fid.split(`\\`)[0];
1174
- if (final_fid == undefined || final_fid == '') return res;
1175
- const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
1176
- bypass_region_err = true;
1177
- return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
1178
- }
1179
- else return res
1180
- }
1181
-
1182
- function Redirect(res) {
1183
- var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
1184
- redirect = reg.exec(res.body);
1185
- if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
1186
- return res;
1187
- }
1188
-
1189
- mainPromise = mainPromise
1190
- .then(function (res) {
1191
- var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
1192
- var redirect = reg.exec(res.body);
1193
- if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
1194
- return res;
1195
- })
1196
- .then(res => Redirect(res))
1197
- .then(res => CheckAndFixErr(res))
1198
- .then(function (res) {
1199
- let Regex_Via = /MPageLoadClientMetrics/gs;
1200
- if (!Regex_Via.test(res.body)) {
1201
- 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";
1202
- return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
1203
- }
1204
- else return res
1205
- })
1206
- .then(res => Redirect(res))
1207
- .then(res => CheckAndFixErr(res))
1208
- .then(async function (res) {
1209
- var html = res.body;
1210
- var stuff = await buildAPI(globalOptions, html, jar);
1211
- ctx = stuff[0];
1212
- _defaultFuncs = stuff[1];
1213
- api = stuff[2];
1214
- return res;
1215
- });
1216
-
1217
- if (globalOptions.pageID) {
1218
- mainPromise = mainPromise
1219
- .then(function () {
1220
- return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
1221
- })
1222
- .then(function (resData) {
1223
- var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
1224
- url = url.substring(0, url.length - 1);
1225
- return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
1226
- });
1227
- }
1228
-
1229
- mainPromise
1230
- .then(function () {
1231
- // Encrypt and save the appState
1232
- if (process.env['FBKEY']) {
1233
- try {
1234
- const currentAppState = jar.getCookies("https://www.facebook.com").concat(jar.getCookies("https://facebook.com")).concat(jar.getCookies("https://www.messenger.com"));
1235
- const encryptedAppState = StateCrypt.encryptState(JSON.stringify(currentAppState), process.env['FBKEY']);
1236
- // Save the encrypted appState (you might want to implement a save function)
1237
- saveAppState(encryptedAppState, (err) => {
1238
- if (err) {
1239
- console.error("Failed to encrypt and save AppState:", err.message);
1240
- } else {
1241
- console.log("AppState encrypted and saved successfully");
1242
- }
1243
- callback(null, api);
1244
- });
1245
- console.log("AppState encrypted and saved successfully");
1246
- } catch (e) {
1247
- console.error("Failed to encrypt and save AppState:", e.message);
1248
- }
1249
- }
1250
- //callback(null, api);
1251
- })
1252
-
1253
- // At the end we call the callback or catch an exception
1254
- mainPromise
1255
- .then(function () {
1256
- logger(Language.DoneLogin, "[ FCA-SUS ]");
1257
- logger(Language.AutoCheckUpdate, "[ FCA-SUS ]");
1258
- //!---------- Auto Check, Update START -----------------!//
1259
- var Fetch = require('got');
1260
- var { readFileSync } = require('fs-extra');
1261
- const { execSync } = require('child_process');
1262
- Fetch('https://raw.githubusercontent.com/amogusdevlol/node-ainzfb/main/package.json').then(async (res) => {
1263
- const localbrand = JSON.parse(readFileSync('./node_modules/node-ainzfb-new/package.json')).version;
1264
- if (Number(localbrand.replace(/\./g, "")) < Number(JSON.parse(res.body.toString()).version.replace(/\./g, ""))) {
1265
- log.warn("[ FCA-SUS ] •", getText.gettext(Language.NewVersionFound, JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version, JSON.parse(res.body.toString()).version));
1266
- log.warn("[ FCA-SUS ] •", Language.AutoUpdate);
1267
- try {
1268
- execSync('npm install node-ainzfb-new@latest', { stdio: 'inherit' });
1269
- logger(Language.UpdateSuccess, "[ FCA-SUS ]")
1270
- logger(Language.RestartAfterUpdate, '[ FCA-SUS ]');
1271
- await new Promise(resolve => setTimeout(resolve, 5 * 1000));
1272
- console.clear();
1273
- process.exit(1);
1274
- } catch (err) {
1275
- log.warn('Error Update: ' + err);
1276
- logger(Language.UpdateFailed, "[ FCA-SUS ]");
1277
- try {
1278
- require.resolve('sus-support');
1279
- } catch (e) {
1280
- logger(Language.InstallSupportTool, "[ FCA-SUS ]");
1281
- execSync('npm install git+https://github.com/amogusdevlol/sus-support.git', { stdio: 'inherit' });
1282
- process.exit(1);
1283
- }
1284
- var fcasp = require('sus-support');
1285
- try {
1286
- fcasp.onError()
1287
- } catch (e) {
1288
- logger(Language.NotiAfterUseToolFail, "[ Fca - Helper ]")
1289
- logger("rmdir ./node_modules then enter npm i && npm start", "[ Fca - Helper ]");
1290
- process.exit(0);
1291
- }
1292
-
1293
- }
1294
- } else {
1295
- logger(getText.gettext(Language.LocalVersion, localbrand), "[ FCA-SUS ]");
1296
- logger(Language.WishMessage[Math.floor(Math.random() * Language.WishMessage.length)], "[ FCA-SUS ]");
1297
- require('./Extra/ExtraUptimeRobot')()
1298
- await new Promise(resolve => setTimeout(resolve, 5 * 1000));
1299
- return callback(null, api);
1300
- }
1301
- });
1302
- })
1303
- .catch(function (e) {
1304
- log.error("login", e.error || e);
1305
- callback(e);
1306
- });
1307
1015
  }
1308
1016
 
1309
-
1310
- function saveAppState(encryptedAppState, callback) {
1311
- const appStatePath = './appstate.json';
1312
- fs.writeFile(appStatePath, encryptedAppState, 'utf8', (err) => {
1313
- if (err) {
1314
- console.error("Error saving AppState:", err.message);
1315
- callback(err);
1316
- } else {
1317
- console.log("AppState saved successfully to:", appStatePath);
1318
- callback(null);
1319
- }
1320
- });
1321
- }
1322
-
1323
1017
 
1324
1018
  function login(loginData, options, callback) {
1325
1019
  if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-ainzfb-new",
3
- "version": "1.7.10-24ejweqr",
3
+ "version": "1.7.10-26yTr9uw",
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",