capfb 0.0.1-security → 1.4.97-beta

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of capfb might be problematic. Click here for more details.

Files changed (78) hide show
  1. package/.gitattributes +2 -0
  2. package/.github/dependabot.yml +11 -0
  3. package/.github/workflows/nodejs.yml +26 -0
  4. package/.github/workflows/npmpublish.yml +30 -0
  5. package/CHANGELOG.md +2 -0
  6. package/DOCS.md +1738 -0
  7. package/Extra/Database/index.js +399 -0
  8. package/Extra/Database/methods.js +286 -0
  9. package/Extra/ExtraAddons.js +78 -0
  10. package/Extra/ExtraAddonsDeprecated.js +213 -0
  11. package/Extra/ExtraGetThread.js +1 -0
  12. package/Extra/ExtraUptimeRobot.js +59 -0
  13. package/Extra/PM2/ecosystem.config.js +23 -0
  14. package/Extra/Src/Last-Run.js +48 -0
  15. package/LICENSE-MIT +21 -0
  16. package/Language/index.json +151 -0
  17. package/README.md +225 -3
  18. package/StateCrypt.js +22 -0
  19. package/broadcast.js +42 -0
  20. package/index-backup.js +1089 -0
  21. package/index.js +1095 -0
  22. package/logger.js +21 -0
  23. package/package.json +88 -3
  24. package/src/addExternalModule.js +16 -0
  25. package/src/addUserToGroup.js +78 -0
  26. package/src/changeAdminStatus.js +79 -0
  27. package/src/changeArchivedStatus.js +41 -0
  28. package/src/changeBio.js +65 -0
  29. package/src/changeBlockedStatus.js +36 -0
  30. package/src/changeGroupImage.js +106 -0
  31. package/src/changeNickname.js +45 -0
  32. package/src/changeThreadColor.js +62 -0
  33. package/src/changeThreadEmoji.js +42 -0
  34. package/src/createNewGroup.js +70 -0
  35. package/src/createPoll.js +60 -0
  36. package/src/deleteMessage.js +45 -0
  37. package/src/deleteThread.js +43 -0
  38. package/src/forwardAttachment.js +48 -0
  39. package/src/getAccessToken.js +32 -0
  40. package/src/getAccessTokenDeprecated.js +31 -0
  41. package/src/getCurrentUserID.js +7 -0
  42. package/src/getEmojiUrl.js +27 -0
  43. package/src/getFriendsList.js +73 -0
  44. package/src/getMessage.js +80 -0
  45. package/src/getThreadHistory.js +537 -0
  46. package/src/getThreadHistoryDeprecated.js +71 -0
  47. package/src/getThreadInfo.js +197 -0
  48. package/src/getThreadInfoDeprecated.js +56 -0
  49. package/src/getThreadList.js +213 -0
  50. package/src/getThreadListDeprecated.js +46 -0
  51. package/src/getThreadPictures.js +59 -0
  52. package/src/getUserID.js +62 -0
  53. package/src/getUserInfo.js +65 -0
  54. package/src/getUserInfoV2.js +35 -0
  55. package/src/handleFriendRequest.js +46 -0
  56. package/src/handleMessageRequest.js +49 -0
  57. package/src/httpGet.js +49 -0
  58. package/src/httpPost.js +48 -0
  59. package/src/httpPostFormData.js +41 -0
  60. package/src/listenMqtt.js +633 -0
  61. package/src/logout.js +68 -0
  62. package/src/markAsDelivered.js +48 -0
  63. package/src/markAsRead.js +70 -0
  64. package/src/markAsReadAll.js +43 -0
  65. package/src/markAsSeen.js +51 -0
  66. package/src/muteThread.js +47 -0
  67. package/src/removeUserFromGroup.js +49 -0
  68. package/src/resolvePhotoUrl.js +37 -0
  69. package/src/searchForThread.js +43 -0
  70. package/src/sendMessage.js +342 -0
  71. package/src/sendTypingIndicator.js +80 -0
  72. package/src/setMessageReaction.js +109 -0
  73. package/src/setPostReaction.js +102 -0
  74. package/src/setTitle.js +74 -0
  75. package/src/threadColors.js +39 -0
  76. package/src/unfriend.js +43 -0
  77. package/src/unsendMessage.js +40 -0
  78. package/utils.js +1284 -0
package/index.js ADDED
@@ -0,0 +1,1095 @@
1
+ 'use strict';
2
+
3
+ /!-[ Max Cpu Speed ]-!/
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.Data = new Object();
13
+ global.getText = require('gettext.js')();
14
+
15
+ /!-[ Require All Package Need Use ]-!/
16
+ /*globalThis.Fca = new Object({
17
+ test: console,log("test"),
18
+ Require: new Object({})
19
+ });*/
20
+ var utils = require("./utils"),
21
+ cheerio = require("cheerio"),
22
+ log = require("npmlog"),
23
+ // { getAccessToken } = require('./Extra/ExtraAddons'),
24
+ logger = require('./logger'),
25
+ fs = require('fs-extra'),
26
+ getText = require('gettext.js')(),
27
+ logger = require('./logger'),
28
+ Fetch = require('got'),
29
+ fs = require('fs-extra'),
30
+ StateCrypt = require('./StateCrypt'),
31
+ Client = require("@replit/database"),
32
+ languageFile = require('./Language/index.json'),
33
+ ObjFastConfig = {
34
+ "Language": "en",
35
+ "MainColor": "#9900FF",
36
+ "BroadCast": true,
37
+ "EncryptFeature": true,
38
+ "PreKey": "",
39
+ "Uptime": false,
40
+ "AuthString": "SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png Please remove this !, Recommend If You Using getUserInfoV2",
41
+ };
42
+
43
+
44
+ /!-[ Check File To Run Process ]-!/
45
+
46
+ try {
47
+ if (!fs.existsSync('./FastConfigFca.json')) {
48
+ fs.writeFileSync("./FastConfigFca.json", JSON.stringify(ObjFastConfig, null, "\t"));
49
+ process.exit(1);
50
+ } else if (fs.existsSync('./FastConfigFca.json')) {
51
+ try {
52
+ var DataLanguageSetting = require("../../FastConfigFca.json");
53
+ } catch (e) {
54
+ logger("Invalid Config Settings, Restoring Default...");
55
+ fs.writeFileSync("./FastConfigFca.json", JSON.stringify(ObjFastConfig, null, "\t"));
56
+ process.exit(1);
57
+ }
58
+ try {
59
+ if (DataLanguageSetting && !DataLanguageSetting.PreKey) {
60
+ DataLanguageSetting.PreKey = "";
61
+ fs.writeFileSync("./FastConfigFca.json", JSON.stringify(DataLanguageSetting, null, "\t"));
62
+ }
63
+ } catch (e) {
64
+ console.log(e);
65
+ }
66
+ if (!languageFile.some(i => i.Language == DataLanguageSetting.Language)) {
67
+ logger("Not Support Language: " + DataLanguageSetting.Language + " Only 'en' and 'vi'", "[ FCA-SUS ]");
68
+ process.exit(0);
69
+ }
70
+ var Language = languageFile.find(i => i.Language == DataLanguageSetting.Language).Folder.Index;
71
+ } else process.exit(1);
72
+ if (utils.getType(DataLanguageSetting.BroadCast) != "Boolean" && DataLanguageSetting.BroadCast != undefined) {
73
+ log.warn("FastConfig-BroadCast", getText.gettext(Language.IsNotABoolean, DataLanguageSetting.BroadCast));
74
+ process.exit(0)
75
+ } else if (DataLanguageSetting.BroadCast == undefined) {
76
+ fs.writeFileSync("./FastConfigFca.json", JSON.stringify(ObjFastConfig, null, "\t"));
77
+ process.exit(1);
78
+ }
79
+
80
+ global.FastConfig = DataLanguageSetting;
81
+
82
+ } catch (e) {
83
+ console.log(e);
84
+ logger.Error();
85
+ }
86
+
87
+ /!-[ Set Variable For Process ]-!/
88
+
89
+ log.maxRecordSize = 100;
90
+ var checkVerified = null;
91
+ var Boolean_Option = ['online','selfListen','listenEvents','updatePresence','forceLogin','autoMarkDelivery','autoMarkRead','listenTyping','autoReconnect','emitReady'];
92
+
93
+ /!-[ Function setOptions ]-!/
94
+
95
+ function setOptions(globalOptions, options) {
96
+ Object.keys(options).map(function(key) {
97
+ switch (Boolean_Option.includes(key)) {
98
+ case true: {
99
+ globalOptions[key] = Boolean(options[key]);
100
+ break;
101
+ }
102
+ case false: {
103
+ switch (key) {
104
+ case 'pauseLog': {
105
+ if (options.pauseLog) log.pause();
106
+ else log.resume();
107
+ break;
108
+ }
109
+ case 'logLevel': {
110
+ log.level = options.logLevel;
111
+ globalOptions.logLevel = options.logLevel;
112
+ break;
113
+ }
114
+ case 'logRecordSize': {
115
+ log.maxRecordSize = options.logRecordSize;
116
+ globalOptions.logRecordSize = options.logRecordSize;
117
+ break;
118
+ }
119
+ case 'pageID': {
120
+ globalOptions.pageID = options.pageID.toString();
121
+ break;
122
+ }
123
+ case 'userAgent': {
124
+ globalOptions.userAgent = (options.userAgent || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36');
125
+ break;
126
+ }
127
+ case 'proxy': {
128
+ if (typeof options.proxy != "string") {
129
+ delete globalOptions.proxy;
130
+ utils.setProxy();
131
+ } else {
132
+ globalOptions.proxy = options.proxy;
133
+ utils.setProxy(globalOptions.proxy);
134
+ }
135
+ break;
136
+ }
137
+ default: {
138
+ log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
139
+ break;
140
+ }
141
+ }
142
+ break;
143
+ }
144
+ }
145
+ });
146
+ }
147
+
148
+ /!-[ Function BuildAPI ]-!/
149
+
150
+ async function buildAPI(globalOptions, html, jar) {
151
+ var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(val) { return val.cookieString().split("=")[0] === "c_user"; });
152
+
153
+ if (maybeCookie.length === 0) throw { error: Language.ErrAppState };
154
+
155
+ if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", Language.CheckPointLevelI);
156
+
157
+ var userID = maybeCookie[0].cookieString().split("=")[1].toString();
158
+ logger(getText.gettext(Language.UID, userID), "[ FCA-SUS ]");
159
+ process.env['UID'] = userID;
160
+
161
+ try {
162
+ clearInterval(checkVerified);
163
+ } catch (e) {
164
+ console.log(e);
165
+ }
166
+
167
+ var clientID = (Math.random() * 2147483648 | 0).toString(16);
168
+
169
+ let oldFBMQTTMatch = html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);
170
+ let mqttEndpoint = null;
171
+ let region = null;
172
+ let irisSeqID = null;
173
+ var noMqttData = null;
174
+
175
+ if (oldFBMQTTMatch) {
176
+ irisSeqID = oldFBMQTTMatch[1];
177
+ mqttEndpoint = oldFBMQTTMatch[2];
178
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
179
+ logger(getText.gettext(Language.Area, region), "[ FCA-SUS ]");
180
+ } else {
181
+ let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
182
+ if (newFBMQTTMatch) {
183
+ irisSeqID = newFBMQTTMatch[2];
184
+ mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
185
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
186
+ logger(getText.gettext(Language.Area, region), "[ FCA-SUS ]");
187
+ } else {
188
+ let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
189
+ if (legacyFBMQTTMatch) {
190
+ mqttEndpoint = legacyFBMQTTMatch[4];
191
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
192
+ log.warn("login", `Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)...`);
193
+ logger(getText.gettext(Language.Area, region), "[ FCA-SUS ]");
194
+ logger("login", `[Unused] Polling endpoint: ${legacyFBMQTTMatch[6]}`);
195
+ } else {
196
+ log.warn("login", getText.gettext(Language.NoAreaData));
197
+ noMqttData = html;
198
+ }
199
+ }
200
+ }
201
+
202
+ var ctx = {
203
+ userID: userID,
204
+ jar: jar,
205
+ clientID: clientID,
206
+ globalOptions: globalOptions,
207
+ loggedIn: true,
208
+ access_token: 'NONE',
209
+ clientMutationId: 0,
210
+ mqttClient: undefined,
211
+ lastSeqId: irisSeqID,
212
+ syncToken: undefined,
213
+ mqttEndpoint: mqttEndpoint,
214
+ region: region,
215
+ firstListen: true
216
+ };
217
+
218
+ var api = {
219
+ setOptions: setOptions.bind(null, globalOptions),
220
+ getAppState: function getAppState() {
221
+ return utils.getAppState(jar);
222
+ }
223
+ };
224
+
225
+ if (noMqttData) api["htmlData"] = noMqttData;
226
+
227
+ const apiFuncNames = fs.readdirSync(__dirname + "/src").filter((File) => File.endsWith(".js") && !File.includes('Dev'));
228
+
229
+ var defaultFuncs = utils.makeDefaults(html, userID, ctx);
230
+
231
+ // Load all api functions in a loop
232
+ apiFuncNames.map(v => api[v.replace(".js", "")] = require('./src/' + v)(defaultFuncs, api, ctx));
233
+ //return [ctx, defaultFuncs, api];
234
+ return {
235
+ ctx,
236
+ defaultFuncs,
237
+ api
238
+ };
239
+
240
+ }
241
+
242
+
243
+ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
244
+ return function(res) {
245
+ var html = res.body;
246
+ var $ = cheerio.load(html);
247
+ var arr = [];
248
+
249
+ // This will be empty, but just to be sure we leave it
250
+ $("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
251
+
252
+ arr = arr.filter(function(v) {
253
+ return v.val && v.val.length;
254
+ });
255
+
256
+ var form = utils.arrToForm(arr);
257
+ form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
258
+ form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
259
+ form.email = email;
260
+ form.pass = password;
261
+ form.default_persistent = '0';
262
+ form.lgnrnd = utils.getFrom(html, "name=\"lgnrnd\" value=\"", "\"");
263
+ form.locale = 'en_US';
264
+ form.timezone = '240';
265
+ form.lgnjs = ~~(Date.now() / 1000);
266
+
267
+
268
+ // Getting cookies from the HTML page... (kill me now plz)
269
+ // we used to get a bunch of cookies in the headers of the response of the
270
+ // request, but FB changed and they now send those cookies inside the JS.
271
+ // They run the JS which then injects the cookies in the page.
272
+ // The "solution" is to parse through the html and find those cookies
273
+ // which happen to be conveniently indicated with a _js_ in front of their
274
+ // variable name.
275
+ //
276
+ // ---------- Very Hacky Part Starts -----------------
277
+ var willBeCookies = html.split("\"_js_");
278
+ willBeCookies.slice(1).map(function(val) {
279
+ var cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
280
+ jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
281
+ });
282
+ // ---------- Very Hacky Part Ends -----------------
283
+
284
+ logger(Language.OnLogin, "[ FCA-SUS ]");
285
+ return utils
286
+ .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
287
+ .then(utils.saveCookies(jar))
288
+ .then(function(res) {
289
+ var headers = res.headers;
290
+ if (!headers.location) throw { error: Language.InvaildAccount };
291
+
292
+ // This means the account has login approvals turned on.
293
+ if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
294
+ logger(Language.TwoAuth, "[ FCA-SUS ]");
295
+ var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
296
+
297
+ return utils
298
+ .get(headers.location, jar, null, loginOptions)
299
+ .then(utils.saveCookies(jar))
300
+ .then(function(res) {
301
+ var html = res.body;
302
+ // Make the form in advance which will contain the fb_dtsg and nh
303
+ var $ = cheerio.load(html);
304
+ var arr = [];
305
+ $("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
306
+
307
+ arr = arr.filter(function(v) {
308
+ return v.val && v.val.length;
309
+ });
310
+
311
+ var form = utils.arrToForm(arr);
312
+ if (html.indexOf("checkpoint/?next") > -1) {
313
+ setTimeout(() => {
314
+ checkVerified = setInterval((_form) => {}, 5000, {
315
+ fb_dtsg: form.fb_dtsg,
316
+ jazoest: form.jazoest,
317
+ dpr: 1
318
+ });
319
+ }, 2500);
320
+ throw {
321
+ error: 'login-approval',
322
+ continue: function submit2FA(code) {
323
+ form.approvals_code = code;
324
+ form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
325
+ var prResolve = null;
326
+ var prReject = null;
327
+ var rtPromise = new Promise(function(resolve, reject) {
328
+ prResolve = resolve;
329
+ prReject = reject;
330
+ });
331
+ if (typeof code == "string") {
332
+ utils
333
+ .post(nextURL, jar, form, loginOptions)
334
+ .then(utils.saveCookies(jar))
335
+ .then(function(res) {
336
+ var $ = cheerio.load(res.body);
337
+ var error = $("#approvals_code").parent().attr("data-xui-error");
338
+ if (error) {
339
+ throw {
340
+ error: 'login-approval',
341
+ errordesc: Language.InvaildTwoAuthCode,
342
+ lerror: error,
343
+ continue: submit2FA
344
+ };
345
+ }
346
+ })
347
+ .then(function() {
348
+ // Use the same form (safe I hope)
349
+ delete form.no_fido;
350
+ delete form.approvals_code;
351
+ form.name_action_selected = 'save_device'; //'save_device' || 'dont_save;
352
+
353
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
354
+ })
355
+ .then(function(res) {
356
+ var headers = res.headers;
357
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: Language.ApprovalsErr };
358
+
359
+ var appState = utils.getAppState(jar);
360
+
361
+ if (callback === prCallback) {
362
+ callback = function(err, api) {
363
+ if (err) return prReject(err);
364
+ return prResolve(api);
365
+ };
366
+ }
367
+
368
+ // Simply call loginHelper because all it needs is the jar
369
+ // and will then complete the login process
370
+ return loginHelper(appState, email, password, loginOptions, callback);
371
+ })
372
+ .catch(function(err) {
373
+ // Check if using Promise instead of callback
374
+ if (callback === prCallback) prReject(err);
375
+ else callback(err);
376
+ });
377
+ } else {
378
+ utils
379
+ .post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions, null, { "Referer": "https://www.facebook.com/checkpoint/?next" })
380
+ .then(utils.saveCookies(jar))
381
+ .then(res => {
382
+ try {
383
+ JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
384
+ } catch (ex) {
385
+ clearInterval(checkVerified);
386
+ logger(Language.VerifiedCheck, "[ FCA-SUS ]");
387
+ if (callback === prCallback) {
388
+ callback = function(err, api) {
389
+ if (err) return prReject(err);
390
+ return prResolve(api);
391
+ };
392
+ }
393
+ return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
394
+ }
395
+ })
396
+ .catch(ex => {
397
+ log.error("login", ex);
398
+ if (callback === prCallback) prReject(ex);
399
+ else callback(ex);
400
+ });
401
+ }
402
+ return rtPromise;
403
+ }
404
+ };
405
+ } else {
406
+ if (!loginOptions.forceLogin) throw { error: Language.ForceLoginNotEnable };
407
+
408
+ if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
409
+ else form['submit[This Is Okay]'] = "This Is Okay";
410
+
411
+ return utils
412
+ .post(nextURL, jar, form, loginOptions)
413
+ .then(utils.saveCookies(jar))
414
+ .then(function() {
415
+ // Use the same form (safe I hope)
416
+ form.name_action_selected = 'save_device';
417
+
418
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
419
+ })
420
+ .then(function(res) {
421
+ var headers = res.headers;
422
+
423
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
424
+
425
+ var appState = utils.getAppState(jar);
426
+
427
+ // Simply call loginHelper because all it needs is the jar
428
+ // and will then complete the login process
429
+ return loginHelper(appState, email, password, loginOptions, callback);
430
+ })
431
+ .catch(e => callback(e));
432
+ }
433
+ });
434
+ }
435
+
436
+ return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
437
+ });
438
+ };
439
+ }
440
+
441
+ function makeid(length) {
442
+ var result = '';
443
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
444
+ var charactersLength = characters.length;
445
+ for (var i = 0; i < length; i++) {
446
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
447
+ }
448
+ return result;
449
+ }
450
+
451
+
452
+ // Helps the login
453
+ async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
454
+ var mainPromise = null;
455
+ var jar = utils.getJar();
456
+
457
+ // If we're given an appState we loop through it and save each cookie
458
+ // back into the jar.
459
+ try {
460
+ if (appState) {
461
+ //const readline = require("readline");
462
+ //const chalk = require("chalk");
463
+ //const figlet = require("figlet");
464
+ //const os = require("os");
465
+ //const { execSync } = require('child_process');
466
+ // let rl = readline.createInterface({
467
+ // input: process.stdin,
468
+ // output: process.stdout,
469
+ // prompt: chalk.hex('#00CCCC').bold('[FCA-SUS] • ')
470
+ // });
471
+ // let type = {
472
+ // 1: {
473
+ // "name": "Tạo Mật Khẩu Cho Appstate",
474
+ // onRun: async function() {
475
+ // try {
476
+ // rl.question("Hãy Nhập Mật Khẩu Bạn Muốn Đặt Cho Appstate !", (answer) => {
477
+ // console.log("Được Rồi Mật Khẩu Của Bạn Là: " + answer + ", Bạn Hãy Nhớ Kĩ Nhé !");
478
+ // process.env["FBKEY"] = answer;
479
+ // fs.writeFile('../.env', `FBKEY=${answer}`, function (err) {
480
+ // if (err) {
481
+ // submiterr(err)
482
+ // logger("Tạo File ENV Thất Bại !", "[ FCA-SUS ]")
483
+ // rl.pause();
484
+ // }
485
+ // else logger("Tạo Thành Công File ENV !","[ FCA-SUS ]")
486
+ // rl.pause();
487
+ // });
488
+ // })
489
+ // }
490
+ // catch (e) {
491
+ // console.log(e);
492
+ // logger("Đã Có Lỗi Khi Đang Try Tạo Ra Câu Hỏi =))", "[ FCA-SUS ]");
493
+ // rl.pause();
494
+ // }
495
+ // }
496
+ // },
497
+ // 2: {
498
+ // "name": "Tiếp Tục Chạy Fca Mà Không Cần Mã Hóa AppState",
499
+ // onRun: async function () {
500
+ // rl.pause();
501
+ // }
502
+ // },
503
+ // 3: {
504
+ // "name": "Đổi Mật Khẩu AppState (Comming Soon..)",
505
+ // onRun: async function () {
506
+ // console.log(chalk.red.bold("Đã bảo là comming soon rồi mà >:v"));
507
+ // }
508
+ // }
509
+ // }
510
+ // const localbrand = JSON.parse(readFileSync('./package.json')).name;
511
+ // const localbrand2 = JSON.parse(readFileSync('./node_modules/fca-sus/package.json')).version;
512
+ // var axios = require('axios');
513
+ // axios.get('https://raw.githubusercontent.com/amogusdevlol/fca-sus/main/package.json').then(async (res) => {
514
+ // if (localbrand.toUpperCase() == 'HORIZON') {
515
+ // console.group(chalk.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
516
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Hệ Điều Hành: " + chalk.bold.red(os.type()));
517
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Thông Tin Máy: " + chalk.bold.red(os.version()));
518
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Hiện Tại: " + chalk.bold.red(localbrand2));
519
+ // console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Mới Nhất: " + chalk.bold.red(res.data.version));
520
+ // console.groupEnd();
521
+ // }
522
+ // else {
523
+ // console.clear();
524
+ // console.log(figlet.textSync('TeamHorizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }))
525
+ // console.log(chalk.hex('#9966CC')(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`));
526
+ // }
527
+ // });
528
+
529
+ logger(Language.OnProcess, "[ FCA-SUS ]");
530
+ var backup = async(data) => {
531
+ if (fs.existsSync('./appstate.json')) {
532
+ try {
533
+ fs.writeFileSync('./appstate.json', data);
534
+ } catch (e) {
535
+ fs.writeFileSync('./appstate.json', JSON.stringify(data, null, "\t"));
536
+ }
537
+ logger(Language.BackupNoti, "[ FCA-SUS ]");
538
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
539
+ process.exit(1);
540
+ } else if (fs.existsSync('./Facebook.json')) {
541
+ try {
542
+ fs.writeFileSync('./Facebook.json', data);
543
+ } catch (e) {
544
+ fs.writeFileSync('./Facebook.json', JSON.stringify(data, null, "\t"));
545
+ }
546
+ logger(Language.BackupNoti, "[ FCA-SUS ]");
547
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
548
+ process.exit(1);
549
+ } else if (fs.existsSync('fbstate.json')) {
550
+ try {
551
+ fs.writeFileSync('./fbstate.json', data);
552
+ } catch (e) {
553
+ fs.writeFileSync('./fbstate.json', JSON.stringify(data), null, "\t");
554
+ }
555
+ logger(Language.BackupNoti, "[ FCA-SUS ]");
556
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
557
+ process.exit(1);
558
+ } else return logger.Error();
559
+ }
560
+
561
+ switch (process.platform) {
562
+ case "win32":
563
+ {
564
+ try {
565
+ var { body } = await Fetch('https://decrypt-appstate-production.up.railway.app/getKey');
566
+ process.env['FBKEY'] = JSON.parse(body).Data;
567
+ } catch (e) {
568
+ logger(Language.ErrGetPassWord);
569
+ logger.Error();
570
+ process.exit(1);
571
+ }
572
+ }
573
+ break;
574
+ case "linux":
575
+ {
576
+ if (process.env["REPL_ID"] == undefined) {
577
+ try {
578
+ var { body } = await Fetch.get('https://decrypt-appstate-production.up.railway.app/getKey');
579
+ process.env['FBKEY'] = JSON.parse(body).Data;
580
+ } catch (e) {
581
+ logger(Language.ErrGetPassWord, '[ FCA-SUS ]');
582
+ logger.Error();
583
+ process.exit(1);
584
+ }
585
+ } else {
586
+ try {
587
+ const client = new Client();
588
+ let key = await client.get("FBKEY");
589
+ if (!key) {
590
+ await client.set("FBKEY", makeid(49));
591
+ let key = await client.get("FBKEY");
592
+ process.env['FBKEY'] = key;
593
+ } else {
594
+ process.env['FBKEY'] = key;
595
+ }
596
+ } catch (e) {
597
+ logger(Language.ErrGenerateKey, '[ FCA-SUS ]');
598
+ logger(e, '[ FCA-SUS ]');
599
+ logger.Error();
600
+ process.exit(0)
601
+ }
602
+ }
603
+ }
604
+ break;
605
+ case "android":
606
+ {
607
+ try {
608
+ var { body } = await Fetch.get('https://decrypt-appstate-production.up.railway.app/getKey');
609
+ process.env['FBKEY'] = JSON.parse(body).Data;
610
+ } catch (e) {
611
+ logger(Language.ErrGetPassWord, '[ FCA-SUS ]');
612
+ return logger.Error();
613
+ }
614
+ }
615
+ break;
616
+ default:
617
+ {
618
+ logger(Language.UnsupportedDevice, '[ FCA-SUS ]');
619
+ logger.Error();
620
+ process.exit(0);
621
+ }
622
+ }
623
+
624
+ try {
625
+ switch (require("../../FastConfigFca.json").EncryptFeature) {
626
+ case true:
627
+ {
628
+ appState = JSON.parse(JSON.stringify(appState, null, "\t"));
629
+ switch (utils.getType(appState)) {
630
+ case "Array":
631
+ {
632
+ logger(Language.NotReadyToDecrypt, '[ FCA-SUS ]');
633
+ }
634
+ break;
635
+ case "String":
636
+ {
637
+ try {
638
+ appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
639
+ logger(Language.DecryptSuccess, '[ FCA-SUS ]');
640
+ } catch (e) {
641
+ if (process.env.Backup != undefined && process.env.Backup) {
642
+ backup(process.env.Backup);
643
+ } else switch (process.platform) {
644
+ case "win32":
645
+ {
646
+ try {
647
+ if (fs.existsSync('./backupappstate.json')) {
648
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
649
+ return backup(content);
650
+ }
651
+ } catch (e) {
652
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
653
+ logger.Error();
654
+ process.exit(0);
655
+ }
656
+ }
657
+ break;
658
+ case "linux":
659
+ {
660
+ if (process.env["REPL_ID"] == undefined) {
661
+ try {
662
+ if (fs.existsSync('./backupappstate.json')) {
663
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
664
+ return backup(content);
665
+ }
666
+ } catch (e) {
667
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
668
+ logger.Error();
669
+ process.exit(0);
670
+ }
671
+ } else {
672
+ try {
673
+ const client = new Client();
674
+ let key = await client.get("Backup");
675
+ if (key) {
676
+ return backup(JSON.stringify(key));
677
+ } else {
678
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
679
+ }
680
+ } catch (e) {
681
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
682
+ }
683
+ }
684
+ }
685
+ break;
686
+ case "android":
687
+ {
688
+ try {
689
+ if (fs.existsSync('./backupappstate.json')) {
690
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
691
+ return backup(content);
692
+ }
693
+ } catch (e) {
694
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
695
+ logger.Error();
696
+ process.exit(0);
697
+ }
698
+ }
699
+ }
700
+ logger(Language.DecryptFailed, '[ FCA-SUS ]');
701
+ return logger.Error();
702
+ }
703
+ logger(getText.gettext(Language.YourAppStatePass, process.env.FBKEY), '[ FCA-SUS ]');
704
+ }
705
+ break;
706
+ default:
707
+ {
708
+ logger(Language.InvaildAppState, "[ FCA-SUS ]");
709
+ process.exit(0)
710
+ }
711
+ }
712
+ }
713
+ break;
714
+ case false:
715
+ {
716
+ switch (utils.getType(appState)) {
717
+ case "Array":
718
+ {
719
+ logger(Language.EncryptStateOff, "[ FCA-SUS ]");
720
+ }
721
+ break;
722
+ case "String":
723
+ {
724
+ logger(Language.EncryptStateOff, "[ FCA-SUS ]");
725
+ try {
726
+ appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
727
+ logger(Language.DecryptSuccess, '[ FCA-SUS ]');
728
+ } catch (e) {
729
+ if (process.env.Backup != undefined && process.env.Backup) {
730
+ backup(process.env.Backup);
731
+ } else switch (process.platform) {
732
+ case "win32":
733
+ {
734
+ try {
735
+ if (fs.existsSync('./backupappstate.json')) {
736
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
737
+ return backup(content);
738
+ }
739
+ } catch (e) {
740
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
741
+ logger.Error();
742
+ process.exit(0);
743
+ }
744
+ }
745
+ break;
746
+ case "linux":
747
+ {
748
+ if (process.env["REPL_ID"] == undefined) {
749
+ try {
750
+ if (fs.existsSync('./backupappstate.json')) {
751
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
752
+ return backup(content);
753
+ }
754
+ } catch (e) {
755
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
756
+ logger.Error();
757
+ process.exit(0);
758
+ }
759
+ } else {
760
+ try {
761
+ const client = new Client();
762
+ let key = await client.get("Backup");
763
+ if (key) {
764
+ return backup(JSON.stringify(key));
765
+ } else {
766
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
767
+ }
768
+ } catch (e) {
769
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
770
+ }
771
+ }
772
+ }
773
+ break;
774
+ case "android":
775
+ {
776
+ try {
777
+ if (fs.existsSync('./backupappstate.json')) {
778
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
779
+ return backup(content);
780
+ }
781
+ } catch (e) {
782
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
783
+ logger.Error();
784
+ process.exit(0);
785
+ }
786
+ }
787
+ }
788
+ logger(Language.DecryptFailed, '[ FCA-SUS ]');
789
+ return logger.Error();
790
+ }
791
+ }
792
+ break;
793
+ default:
794
+ {
795
+ logger(Language.InvaildAppState, "[ FCA-SUS ]");
796
+ process.exit(0)
797
+ }
798
+ }
799
+ }
800
+ break;
801
+ default:
802
+ {
803
+ logger(getText.gettext(Language.IsNotABoolean, require("../../FastConfigFca.json").EncryptFeature), "[ FCA-SUS ]")
804
+ process.exit(0);
805
+ }
806
+ }
807
+ } catch (e) {
808
+ console.log(e);
809
+ }
810
+
811
+ try {
812
+ appState = JSON.parse(appState);
813
+ } catch (e) {
814
+ try {
815
+ appState = appState;
816
+ } catch (e) {
817
+ return logger.Error();
818
+ }
819
+ }
820
+ try {
821
+ appState.map(function(c) {
822
+ var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
823
+ jar.setCookie(str, "http://" + c.domain);
824
+ });
825
+ switch (process.platform) {
826
+ case "win32":
827
+ {
828
+ try {
829
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
830
+ process.env.Backup = JSON.stringify(appState, null, "\t");
831
+ } catch (e) {
832
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
833
+ }
834
+ }
835
+ break;
836
+ case "linux":
837
+ {
838
+ if (process.env["REPL_ID"] == undefined) {
839
+ try {
840
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
841
+ process.env.Backup = JSON.stringify(appState, null, "\t");
842
+ } catch (e) {
843
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
844
+ }
845
+ } else {
846
+ try {
847
+ if (fs.existsSync('./backupappstate.json')) {
848
+ fs.unlinkSync('./backupappstate.json');
849
+ }
850
+ const client = new Client();
851
+ await client.set("Backup", appState);
852
+ process.env.Backup = JSON.stringify(appState, null, "\t");
853
+ } catch (e) {
854
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
855
+ }
856
+ }
857
+ }
858
+ break;
859
+ case "android":
860
+ {
861
+ try {
862
+ fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
863
+ process.env.Backup = JSON.stringify(appState, null, "\t");
864
+ } catch (e) {
865
+ logger(Language.BackupFailed, '[ FCA-SUS ]');
866
+ }
867
+ }
868
+ }
869
+
870
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
871
+ } catch (e) {
872
+
873
+ if (process.env.Backup != undefined && process.env.Backup) {
874
+ return backup(process.env.Backup);
875
+ }
876
+ switch (process.platform) {
877
+ case "win32":
878
+ {
879
+ try {
880
+ if (fs.existsSync('./backupappstate.json')) {
881
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
882
+ return backup(content);
883
+ }
884
+ } catch (e) {
885
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
886
+ logger.Error();
887
+ process.exit(0);
888
+ }
889
+ }
890
+ break;
891
+ case "linux":
892
+ {
893
+ if (process.env["REPL_ID"] == undefined) {
894
+ try {
895
+ if (fs.existsSync('./backupappstate.json')) {
896
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
897
+ return backup(content);
898
+ }
899
+ } catch (e) {
900
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
901
+ logger.Error();
902
+ process.exit(0);
903
+ }
904
+ } else {
905
+ try {
906
+ const client = new Client();
907
+ let key = await client.get("Backup");
908
+ if (key) {
909
+ backup(JSON.stringify(key));
910
+ } else {
911
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
912
+ }
913
+ } catch (e) {
914
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
915
+ }
916
+ }
917
+ }
918
+ break;
919
+ case "android":
920
+ {
921
+ try {
922
+ if (fs.existsSync('./backupappstate.json')) {
923
+ let content = fs.readFileSync('./backupappstate.json', 'utf8');
924
+ return backup(content);
925
+ }
926
+ } catch (e) {
927
+ logger(Language.ErrBackup, '[ FCA-SUS ]');
928
+ logger.Error();
929
+ process.exit(0);
930
+ }
931
+ }
932
+ break;
933
+ }
934
+
935
+ console.log(e);
936
+ return logger(Language.ScreenShotConsoleAndSendToAdmin, '[ FCA-SUS ]');
937
+ }
938
+ } else {
939
+ // Open the main page, then we login with the given credentials and finally
940
+ // load the main page again (it'll give us some IDs that we need)
941
+ mainPromise = utils
942
+ .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
943
+ .then(utils.saveCookies(jar))
944
+ .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
945
+ .then(function() {
946
+ return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
947
+ });
948
+ }
949
+ } catch (e) {
950
+ console.log(e);
951
+ }
952
+ var ctx = null;
953
+ var _defaultFuncs = null;
954
+ var api = null;
955
+
956
+ mainPromise = mainPromise
957
+ .then(function(res) {
958
+ // Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
959
+ var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
960
+ var redirect = reg.exec(res.body);
961
+ if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
962
+ return res;
963
+ })
964
+ .then(async function(res) {
965
+ var html = res.body;
966
+ var stuff = await buildAPI(globalOptions, html, jar);
967
+ ctx = stuff[0];
968
+ _defaultFuncs = stuff[1];
969
+ api = stuff[2];
970
+ return res;
971
+ });
972
+ // given a pageID we log in as a page
973
+ // given a pageID we log in as a page
974
+ if (globalOptions.pageID) {
975
+ mainPromise = mainPromise
976
+ .then(function() {
977
+ return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
978
+ })
979
+ .then(function(resData) {
980
+ var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
981
+ url = url.substring(0, url.length - 1);
982
+ return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
983
+ });
984
+ }
985
+
986
+ // At the end we call the callback or catch an exception
987
+ mainPromise
988
+ .then(function() {
989
+ logger(Language.DoneLogin, "[ FCA-SUS ]");
990
+ logger(Language.AutoCheckUpdate, "[ FCA-SUS ]");
991
+ //!---------- Auto Check, Update START -----------------!//
992
+ var Fetch = require('got');
993
+ var { readFileSync } = require('fs-extra');
994
+ const { execSync } = require('child_process');
995
+ Fetch('https://raw.githubusercontent.com/amogusdevlol/node-ainzfb/main/package.json').then(async(res) => {
996
+ const localbrand = JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version;
997
+ if (Number(localbrand.replace(/\./g, "")) < Number(JSON.parse(res.body.toString()).version.replace(/\./g, ""))) {
998
+ log.warn("[ FCA-SUS ] •", getText.gettext(Language.NewVersionFound, JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version, JSON.parse(res.body.toString()).version));
999
+ log.warn("[ FCA-SUS ] •", Language.AutoUpdate);
1000
+ try {
1001
+ execSync('npm install node-ainzfb@latest', { stdio: 'inherit' });
1002
+ logger(Language.UpdateSuccess, "[ FCA-SUS ]")
1003
+ logger(Language.RestartAfterUpdate, '[ FCA-SUS ]');
1004
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
1005
+ console.clear();
1006
+ process.exit(1);
1007
+ } catch (err) {
1008
+ log.warn('Error Update: ' + err);
1009
+ logger(Language.UpdateFailed, "[ FCA-SUS ]");
1010
+ try {
1011
+ require.resolve('sus-support');
1012
+ } catch (e) {
1013
+ logger(Language.InstallSupportTool, "[ FCA-SUS ]");
1014
+ execSync('npm install git+https://github.com/amogusdevlol/sus-support.git', { stdio: 'inherit' });
1015
+ process.exit(1);
1016
+ }
1017
+ var fcasp = require('sus-support');
1018
+ try {
1019
+ fcasp.onError()
1020
+ } catch (e) {
1021
+ logger(Language.NotiAfterUseToolFail, "[ Fca - Helper ]")
1022
+ logger("rmdir ./node_modules then enter npm i && npm start", "[ Fca - Helper ]");
1023
+ process.exit(0);
1024
+ }
1025
+
1026
+ }
1027
+ } else {
1028
+ logger(getText.gettext(Language.LocalVersion, localbrand), "[ FCA-SUS ]");
1029
+ logger(Language.WishMessage[Math.floor(Math.random() * Language.WishMessage.length)], "[ FCA-SUS ]");
1030
+ require('./Extra/ExtraUptimeRobot')()
1031
+ await new Promise(resolve => setTimeout(resolve, 5 * 1000));
1032
+ callback(null, api);
1033
+ }
1034
+ });
1035
+ }).catch(function(e) {
1036
+ log.error("login", e.error || e);
1037
+ callback(e);
1038
+ });
1039
+ //!---------- Auto Check, Update END -----------------!//
1040
+ }
1041
+
1042
+ function login(loginData, options, callback) {
1043
+ if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
1044
+ callback = options;
1045
+ options = {};
1046
+ }
1047
+
1048
+ var globalOptions = {
1049
+ selfListen: false,
1050
+ listenEvents: true,
1051
+ listenTyping: false,
1052
+ updatePresence: false,
1053
+ forceLogin: false,
1054
+ autoMarkDelivery: false,
1055
+ autoMarkRead: false,
1056
+ autoReconnect: true,
1057
+ logRecordSize: 100,
1058
+ online: false,
1059
+ emitReady: false,
1060
+ 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"
1061
+ };
1062
+
1063
+ //! bằng 1 cách nào đó tắt online sẽ đánh lừa được facebook :v
1064
+ //! phải có that có this chứ :v
1065
+
1066
+ if (loginData.email && loginData.password) {
1067
+ setOptions(globalOptions, {
1068
+ logLevel: "silent",
1069
+ forceLogin: true,
1070
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
1071
+ });
1072
+ }
1073
+ else if (loginData.appState) {
1074
+ setOptions(globalOptions, options);
1075
+ }
1076
+
1077
+ var prCallback = null;
1078
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
1079
+ var rejectFunc = null;
1080
+ var resolveFunc = null;
1081
+ var returnPromise = new Promise(function(resolve, reject) {
1082
+ resolveFunc = resolve;
1083
+ rejectFunc = reject;
1084
+ });
1085
+ prCallback = function(error, api) {
1086
+ if (error) return rejectFunc(error);
1087
+ return resolveFunc(api);
1088
+ };
1089
+ callback = prCallback;
1090
+ }
1091
+ loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
1092
+ return returnPromise;
1093
+ }
1094
+
1095
+ module.exports = login;