alicezetion 1.3.6 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/Extra/Database/index.js +469 -0
  4. package/Extra/ExtraAddons.js +82 -0
  5. package/Extra/ExtraFindUID.js +62 -0
  6. package/Extra/ExtraGetThread.js +340 -0
  7. package/Extra/ExtraScreenShot.js +430 -0
  8. package/Extra/ExtraUptimeRobot.js +38 -0
  9. package/Extra/Html/Classic/script.js +119 -0
  10. package/Extra/Html/Classic/style.css +8 -0
  11. package/Extra/Security/AES_256_GCM/index.js +0 -0
  12. package/Extra/Security/Base/Step_1.js +6 -0
  13. package/Extra/Security/Base/Step_2.js +22 -0
  14. package/Extra/Security/Base/Step_3.js +22 -0
  15. package/Extra/Security/Base/index.js +173 -0
  16. package/Extra/Security/Index.js +5 -0
  17. package/Extra/Security/Step_1.js +6 -0
  18. package/Extra/Security/Step_2.js +22 -0
  19. package/Extra/Security/Step_3.js +22 -0
  20. package/Extra/Src/Change_Environment.js +24 -0
  21. package/Extra/Src/Check_Update.js +67 -0
  22. package/Extra/Src/History.js +115 -0
  23. package/Extra/Src/Instant_Update.js +65 -0
  24. package/Extra/Src/Last-Run.js +65 -0
  25. package/Extra/Src/Premium.js +81 -0
  26. package/Extra/Src/Release_Memory.js +41 -0
  27. package/Extra/Src/Websocket.js +213 -0
  28. package/Extra/Src/image/checkmate.jpg +0 -0
  29. package/Extra/Src/uuid.js +137 -0
  30. package/Func/AcceptAgreement.js +31 -0
  31. package/Func/ClearCache.js +64 -0
  32. package/Func/ReportV1.js +54 -0
  33. package/Language/index.json +217 -0
  34. package/Main.js +1211 -0
  35. package/broadcast.js +40 -0
  36. package/index.js +367 -522
  37. package/leiamnash/Dev_Horizon_Data.js +125 -0
  38. package/leiamnash/Premium.js +25 -0
  39. package/leiamnash/Screenshot.js +83 -0
  40. package/leiamnash/addExternalModule.js +7 -10
  41. package/leiamnash/addUserToGroup.js +17 -51
  42. package/leiamnash/changeAdminStatus.js +0 -0
  43. package/leiamnash/changeArchivedStatus.js +12 -26
  44. package/leiamnash/changeAvt.js +85 -0
  45. package/leiamnash/changeBio.js +6 -18
  46. package/leiamnash/changeBlockedStatus.js +3 -14
  47. package/leiamnash/changeGroupImage.js +16 -39
  48. package/leiamnash/changeNickname.js +11 -25
  49. package/leiamnash/changeThreadColor.js +10 -19
  50. package/leiamnash/changeThreadEmoji.js +10 -23
  51. package/leiamnash/chat.js +111 -196
  52. package/leiamnash/createNewGroup.js +12 -28
  53. package/leiamnash/createPoll.js +13 -24
  54. package/leiamnash/deleteMessage.js +12 -23
  55. package/leiamnash/deleteThread.js +11 -24
  56. package/leiamnash/forwardAttachment.js +13 -25
  57. package/leiamnash/getAccessToken.js +28 -0
  58. package/leiamnash/getCurrentUserID.js +1 -1
  59. package/leiamnash/getEmojiUrl.js +2 -4
  60. package/leiamnash/getFriendsList.js +11 -22
  61. package/leiamnash/getMessage.js +80 -0
  62. package/leiamnash/getThreadHistory.js +59 -167
  63. package/leiamnash/getThreadInfo.js +247 -28
  64. package/leiamnash/getThreadList.js +41 -66
  65. package/leiamnash/getThreadMain.js +220 -0
  66. package/leiamnash/getThreadPictures.js +17 -37
  67. package/leiamnash/getUID.js +59 -0
  68. package/leiamnash/getUserID.js +9 -13
  69. package/leiamnash/getUserInfo.js +67 -26
  70. package/leiamnash/getUserInfoMain.js +65 -0
  71. package/leiamnash/getUserInfoV2.js +32 -0
  72. package/leiamnash/getUserInfoV3.js +63 -0
  73. package/leiamnash/getUserInfoV4.js +55 -0
  74. package/leiamnash/getUserInfoV5.js +61 -0
  75. package/leiamnash/handleFriendRequest.js +12 -27
  76. package/leiamnash/handleMessageRequest.js +15 -31
  77. package/leiamnash/httpGet.js +13 -16
  78. package/leiamnash/httpPost.js +12 -16
  79. package/leiamnash/httpPostFormData.js +41 -0
  80. package/leiamnash/listenMqtt.js +301 -200
  81. package/leiamnash/logout.js +13 -20
  82. package/leiamnash/markAsDelivered.js +11 -21
  83. package/leiamnash/markAsRead.js +11 -21
  84. package/leiamnash/markAsReadAll.js +11 -18
  85. package/leiamnash/markAsSeen.js +9 -17
  86. package/leiamnash/muteThread.js +10 -15
  87. package/leiamnash/removeUserFromGroup.js +15 -45
  88. package/leiamnash/resolvePhotoUrl.js +8 -16
  89. package/leiamnash/searchForThread.js +10 -20
  90. package/leiamnash/sendMessage.js +379 -0
  91. package/leiamnash/sendTypingIndicator.js +9 -32
  92. package/leiamnash/setMessageReaction.js +12 -20
  93. package/leiamnash/setPostReaction.js +100 -74
  94. package/leiamnash/setTitle.js +13 -25
  95. package/leiamnash/threadColors.js +18 -36
  96. package/leiamnash/unfriend.js +9 -18
  97. package/leiamnash/unsendMessage.js +8 -17
  98. package/logger.js +66 -0
  99. package/package.json +49 -34
  100. package/replit.nix +1 -3
  101. package/utils.js +593 -108
  102. package/leiamnash/getThreadHistoryDeprecated.js +0 -93
  103. package/leiamnash/getThreadInfoDeprecated.js +0 -80
  104. package/leiamnash/getThreadListDeprecated.js +0 -75
package/index.js CHANGED
@@ -1,541 +1,386 @@
1
- /*
2
-
3
- A L I C E » this project recode by one
4
- person LeiamNash
5
- this will only work on
6
- project alice
7
-
8
- */
9
-
10
- "use strict";
11
-
12
- var utils = require("./utils");
13
- var cheerio = require("cheerio");
14
- var log = require("npmlog");
15
-
16
- var checkVerified = null;
17
-
18
- var defaultLogRecordSize = 100;
19
- log.maxRecordSize = defaultLogRecordSize;
20
-
21
- function setOptions(globalOptions, options) {
22
- Object.keys(options).map(function(key) {
23
- switch (key) {
24
- case 'pauseLog':
25
- if (options.pauseLog) log.pause();
26
- break;
27
- case 'online':
28
- globalOptions.online = Boolean(options.online);
29
- break;
30
- case 'logLevel':
31
- log.level = options.logLevel;
32
- globalOptions.logLevel = options.logLevel;
33
- break;
34
- case 'logRecordSize':
35
- log.maxRecordSize = options.logRecordSize;
36
- globalOptions.logRecordSize = options.logRecordSize;
37
- break;
38
- case 'selfListen':
39
- globalOptions.selfListen = Boolean(options.selfListen);
40
- break;
41
- case 'listenEvents':
42
- globalOptions.listenEvents = Boolean(options.listenEvents);
43
- break;
44
- case 'pageID':
45
- globalOptions.pageID = options.pageID.toString();
46
- break;
47
- case 'updatePresence':
48
- globalOptions.updatePresence = Boolean(options.updatePresence);
49
- break;
50
- case 'forceLogin':
51
- globalOptions.forceLogin = Boolean(options.forceLogin);
52
- break;
53
- case 'userAgent':
54
- globalOptions.userAgent = options.userAgent;
55
- break;
56
- case 'autoMarkDelivery':
57
- globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
58
- break;
59
- case 'autoMarkRead':
60
- globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
61
- break;
62
- case 'listenTyping':
63
- globalOptions.listenTyping = Boolean(options.listenTyping);
64
- break;
65
- case 'proxy':
66
- if (typeof options.proxy != "string") {
67
- delete globalOptions.proxy;
68
- utils.setProxy();
69
- } else {
70
- globalOptions.proxy = options.proxy;
71
- utils.setProxy(globalOptions.proxy);
1
+ 'use strict';
2
+ /* eslint-disable linebreak-style */
3
+ const utils = require('./utils');
4
+ global.Fca = new Object({
5
+ isThread: new Array(),
6
+ isUser: new Array(),
7
+ startTime: Date.now(),
8
+ Setting: new Map(),
9
+ Version: require('./package.json').version,
10
+ Require: new Object({
11
+ fs: require("fs"),
12
+ Fetch: require('got'),
13
+ log: require("npmlog"),
14
+ utils: require("./utils.js"),
15
+ logger: require('./logger.js'),
16
+ languageFile: require('./Language/index.json'),
17
+ Security: require('./Extra/Src/uuid.js')
18
+ }),
19
+ getText: function(/** @type {any[]} */...Data) {
20
+ var Main = (Data.splice(0,1)).toString();
21
+ for (let i = 0; i < Data.length; i++) Main = Main.replace(RegExp(`%${i + 1}`, 'g'), Data[i]);
22
+ return Main;
23
+ },
24
+ Data: new Object({
25
+ ObjFastConfig: {
26
+ "Language": "vi",
27
+ "PreKey": "",
28
+ "AutoUpdate": true,
29
+ "MainColor": "#9900FF",
30
+ "MainName": "[ FCA-HZI ]",
31
+ "Uptime": false,
32
+ "Config": "default",
33
+ "DevMode": false,
34
+ "Login2Fa": false,
35
+ "AutoLogin": false,
36
+ "BroadCast": true,
37
+ "AuthString": "SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png Please remove this !, Recommend If You Using getUserInfoV2",
38
+ "EncryptFeature": true,
39
+ "ResetDataLogin": false,
40
+ "AutoInstallNode": false,
41
+ "AntiSendAppState": true,
42
+ "AutoRestartMinutes": 0,
43
+ "RestartMQTT_Minutes": 0,
44
+ "Websocket_Extension": {
45
+ "Status": false,
46
+ "ResetData": false,
47
+ "AppState_Path": "appstate.json"
48
+ },
49
+ "HTML": {
50
+ "HTML": true,
51
+ "UserName": "Guest",
52
+ "MusicLink": "https://drive.google.com/uc?id=1zlAALlxk1TnO7jXtEP_O6yvemtzA2ukA&export=download"
53
+ },
54
+ "AntiGetInfo": {
55
+ "Database_Type": "default", //json or default
56
+ "AntiGetThreadInfo": true,
57
+ "AntiGetUserInfo": true
58
+ },
59
+ "Stable_Version": {
60
+ "Accept": false,
61
+ "Version": ""
62
+ }
63
+ },
64
+ CountTime: function() {
65
+ var fs = global.Fca.Require.fs;
66
+ if (fs.existsSync(__dirname + '/CountTime.json')) {
67
+ try {
68
+ var data = Number(fs.readFileSync(__dirname + '/CountTime.json', 'utf8')),
69
+ hours = Math.floor(data / (60 * 60));
70
+ }
71
+ catch (e) {
72
+ fs.writeFileSync(__dirname + '/CountTime.json', 0);
73
+ hours = 0;
72
74
  }
73
- break;
74
- case 'autoReconnect':
75
- globalOptions.autoReconnect = Boolean(options.autoReconnect);
76
- break;
77
- case 'emitReady':
78
- globalOptions.emitReady = Boolean(options.emitReady);
79
- break;
80
- default:
81
- log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
82
- break;
75
+ }
76
+ else {
77
+ hours = 0;
78
+ }
79
+ return `${hours} Hours`;
83
80
  }
84
- });
85
- }
86
-
87
- function buildAPI(globalOptions, html, jar) {
88
- var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(val) {
89
- return val.cookieString().split("=")[0] === "c_user";
90
- });
91
-
92
- 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." };
93
-
94
- if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
95
-
96
- var userID = maybeCookie[0].cookieString().split("=")[1].toString();
97
- //log.info("login", `Logged in as ${userID}`);
98
-
99
- try {
100
- clearInterval(checkVerified);
101
- } catch (_) {}
102
-
103
- var clientID = (Math.random() * 2147483648 | 0).toString(16);
104
-
105
- let oldFBMQTTMatch = html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);
106
- let mqttEndpoint = null;
107
- let region = null;
108
- let irisSeqID = null;
109
- var noMqttData = null;
110
-
111
- if (oldFBMQTTMatch) {
112
- irisSeqID = oldFBMQTTMatch[1];
113
- mqttEndpoint = oldFBMQTTMatch[2];
114
- region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
115
- //log.info("login", `Got this account's message region: ${region}`);
116
- } else {
117
- let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
118
- if (newFBMQTTMatch) {
119
- irisSeqID = newFBMQTTMatch[2];
120
- mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
121
- region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
122
- log.info("login", `Got this account's message region: ${region}`);
123
- } else {
124
- let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
125
- if (legacyFBMQTTMatch) {
126
- mqttEndpoint = legacyFBMQTTMatch[4];
127
- region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
128
- log.warn("login", `Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)...`);
129
- log.info("login", `Got this account's message region: ${region}`);
130
- log.info("login", `[Unused] Polling endpoint: ${legacyFBMQTTMatch[6]}`);
131
- } else {
132
- log.warn("login", "» Cannot get MQTT region & sequence ID.");
133
- log.error("login", "» Please try closing and reopening your browser window or get new fbstate.");
134
- noMqttData = html;
135
- process.exit();
81
+ }),
82
+ Action: function(Type) {
83
+ switch (Type) {
84
+ case "AutoLogin": {
85
+ var Database = require('./Extra/Database');
86
+ var logger = global.Fca.Require.logger;
87
+ var Email = (Database().get('Account')).replace(RegExp('"', 'g'), ''); //hmm IDK
88
+ var PassWord = (Database().get('Password')).replace(RegExp('"', 'g'), '');
89
+ require('./Main')({ email: Email, password: PassWord},async (error, api) => {
90
+ if (error) {
91
+ logger.Error(JSON.stringify(error,null,2), function() { logger.Error("AutoLogin Failed!", function() { process.exit(0); }) });
92
+ }
93
+ try {
94
+ Database().set("TempState", Database().get('Through2Fa'));
95
+ }
96
+ catch(e) {
97
+ logger.Warning(global.Fca.Require.Language.Index.ErrDatabase);
98
+ logger.Error();
99
+ process.exit(0);
100
+ }
101
+ process.exit(1);
102
+ });
136
103
  }
104
+ break;
105
+ default: {
106
+ require('npmlog').Error("Invalid Message!");
107
+ };
137
108
  }
138
109
  }
110
+ });
139
111
 
140
- // All data available to api functions
141
- var ctx = {
142
- userID: userID,
143
- jar: jar,
144
- clientID: clientID,
145
- globalOptions: globalOptions,
146
- loggedIn: true,
147
- access_token: 'NONE',
148
- clientMutationId: 0,
149
- mqttClient: undefined,
150
- lastSeqId: irisSeqID,
151
- syncToken: undefined,
152
- mqttEndpoint,
153
- region,
154
- firstListen: true
155
- };
156
-
157
- var api = {
158
- setOptions: setOptions.bind(null, globalOptions),
159
- getAppState: function getAppState() {
160
- return utils.getAppState(jar);
161
- }
162
- };
163
-
164
- if (noMqttData) api["htmlData"] = noMqttData;
165
-
166
- const apiFuncNames = [
167
- 'addExternalModule',
168
- 'addUserToGroup',
169
- 'changeAdminStatus',
170
- 'changeArchivedStatus',
171
- 'changeBio',
172
- 'changeBlockedStatus',
173
- 'changeGroupImage',
174
- 'changeNickname',
175
- 'changeThreadColor',
176
- 'changeThreadEmoji',
177
- 'chat',
178
- 'createNewGroup',
179
- 'createPoll',
180
- 'deleteMessage',
181
- 'deleteThread',
182
- 'forwardAttachment',
183
- 'getCurrentUserID',
184
- 'getEmojiUrl',
185
- 'getFriendsList',
186
- 'getThreadHistory',
187
- 'getThreadInfo',
188
- 'getThreadList',
189
- 'getThreadPictures',
190
- 'getUserID',
191
- 'getUserInfo',
192
- 'handleFriendRequest',
193
- 'handleMessageRequest',
194
- 'listenMqtt',
195
- 'logout',
196
- 'markAsDelivered',
197
- 'markAsRead',
198
- 'markAsReadAll',
199
- 'markAsSeen',
200
- 'muteThread',
201
- 'removeUserFromGroup',
202
- 'resolvePhotoUrl',
203
- 'searchForThread',
204
- 'sendTypingIndicator',
205
- 'setMessageReaction',
206
- 'setTitle',
207
- 'threadColors',
208
- 'unsendMessage',
209
- 'unfriend',
112
+ try {
113
+ let Boolean_Fca = ["AntiSendAppState","AutoUpdate","Uptime","BroadCast","EncryptFeature","AutoLogin","ResetDataLogin","Login2Fa", "DevMode","AutoInstallNode"];
114
+ let String_Fca = ["MainName","PreKey","Language","AuthString","Config"]
115
+ let Number_Fca = ["AutoRestartMinutes","RestartMQTT_Minutes"];
116
+ let Object_Fca = ["HTML","Stable_Version","AntiGetInfo","Websocket_Extension"];
117
+ let All_Variable = Boolean_Fca.concat(String_Fca,Number_Fca,Object_Fca);
210
118
 
211
- // HTTP
212
- 'httpGet',
213
- 'httpPost',
214
119
 
215
- // Deprecated features
216
- "getThreadListDeprecated",
217
- 'getThreadHistoryDeprecated',
218
- 'getThreadInfoDeprecated',
219
- ];
220
-
221
- var defaultFuncs = utils.makeDefaults(html, userID, ctx);
222
-
223
- // Load all api functions in a loop
224
- apiFuncNames.map(v => api[v] = require('./leiamnash/' + v)(defaultFuncs, api, ctx));
120
+ if (!global.Fca.Require.fs.existsSync(process.cwd() + '/alice/database/alicization.json')) {
121
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/alice/database/alicization.json", JSON.stringify(global.Fca.Data.ObjFastConfig, null, "\t"));
122
+ process.exit(1);
123
+ }
225
124
 
226
- return [ctx, defaultFuncs, api];
125
+ try {
126
+ var Data_Setting = require(process.cwd() + "/alice/database/alicization.json");
227
127
  }
128
+ catch (e) {
129
+ global.Fca.Require.logger.Error('Detect Your alicization Settings Invalid!, Carry out default restoration');
130
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/alice/database/alicization.json", JSON.stringify(global.Fca.Data.ObjFastConfig, null, "\t"));
131
+ process.exit(1)
132
+ }
133
+ if (global.Fca.Require.fs.existsSync(process.cwd() + '/alice/database/alicization.json')) {
134
+
135
+ for (let i of All_Variable) {
136
+ if (Data_Setting[i] == undefined) {
137
+ Data_Setting[i] = global.Fca.Data.ObjFastConfig[i];
138
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/alice/database/alicization.json", JSON.stringify(Data_Setting, null, "\t"));
139
+ }
140
+ else continue;
141
+ } //Check Variable
228
142
 
229
- function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
230
- return function(res) {
231
- var html = res.body;
232
- var $ = cheerio.load(html);
233
- var arr = [];
234
-
235
- // This will be empty, but just to be sure we leave it
236
- $("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
237
-
238
- arr = arr.filter(function(v) {
239
- return v.val && v.val.length;
240
- });
241
-
242
- var form = utils.arrToForm(arr);
243
- form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
244
- form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
245
- form.email = email;
246
- form.pass = password;
247
- form.default_persistent = '0';
248
- form.lgnrnd = utils.getFrom(html, "name=\"lgnrnd\" value=\"", "\"");
249
- form.locale = 'en_US';
250
- form.timezone = '240';
251
- form.lgnjs = ~~(Date.now() / 1000);
252
-
253
-
254
- // Getting cookies from the HTML page... (kill me now plz)
255
- // we used to get a bunch of cookies in the headers of the response of the
256
- // request, but FB changed and they now send those cookies inside the JS.
257
- // They run the JS which then injects the cookies in the page.
258
- // The "solution" is to parse through the html and find those cookies
259
- // which happen to be conveniently indicated with a _js_ in front of their
260
- // variable name.
261
- //
262
- // ---------- Very Hacky Part Starts -----------------
263
- var willBeCookies = html.split("\"_js_");
264
- willBeCookies.slice(1).map(function(val) {
265
- var cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
266
- jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
267
- });
268
- // ---------- Very Hacky Part Ends -----------------
269
-
270
- log.info("login", "Logging in...");
271
- return utils
272
- .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
273
- .then(utils.saveCookies(jar))
274
- .then(function(res) {
275
- var headers = res.headers;
276
- if (!headers.location) throw { error: "Wrong username/password." };
277
-
278
- // This means the account has login approvals turned on.
279
- if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
280
- log.info("login", "You have login approvals turned on.");
281
- var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
282
-
283
- return utils
284
- .get(headers.location, jar, null, loginOptions)
285
- .then(utils.saveCookies(jar))
286
- .then(function(res) {
287
- var html = res.body;
288
- // Make the form in advance which will contain the fb_dtsg and nh
289
- var $ = cheerio.load(html);
290
- var arr = [];
291
- $("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
292
-
293
- arr = arr.filter(function(v) {
294
- return v.val && v.val.length;
295
- });
296
-
297
- var form = utils.arrToForm(arr);
298
- if (html.indexOf("checkpoint/?next") > -1) {
299
- setTimeout(() => {
300
- checkVerified = setInterval((_form) => {}, 5000, {
301
- fb_dtsg: form.fb_dtsg,
302
- jazoest: form.jazoest,
303
- dpr: 1
304
- });
305
- }, 2500);
306
- throw {
307
- error: 'login-approval',
308
- continue: function submit2FA(code) {
309
- form.approvals_code = code;
310
- form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
311
- var prResolve = null;
312
- var prReject = null;
313
- var rtPromise = new Promise(function(resolve, reject) {
314
- prResolve = resolve;
315
- prReject = reject;
316
- });
317
- if (typeof code == "string") {
318
- utils
319
- .post(nextURL, jar, form, loginOptions)
320
- .then(utils.saveCookies(jar))
321
- .then(function(res) {
322
- var $ = cheerio.load(res.body);
323
- var error = $("#approvals_code").parent().attr("data-xui-error");
324
- if (error) {
325
- throw {
326
- error: 'login-approval',
327
- errordesc: "Invalid 2FA code.",
328
- lerror: error,
329
- continue: submit2FA
330
- };
331
- }
332
- })
333
- .then(function() {
334
- // Use the same form (safe I hope)
335
- delete form.no_fido;
336
- delete form.approvals_code;
337
- form.name_action_selected = 'dont_save'; //'save_device';
338
-
339
- return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
340
- })
341
- .then(function(res) {
342
- var headers = res.headers;
343
- if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with login approvals." };
344
-
345
- var appState = utils.getAppState(jar);
346
-
347
- if (callback === prCallback) {
348
- callback = function(err, api) {
349
- if (err) return prReject(err);
350
- return prResolve(api);
351
- };
352
- }
353
-
354
- // Simply call loginHelper because all it needs is the jar
355
- // and will then complete the login process
356
- return loginHelper(appState, email, password, loginOptions, callback);
357
- })
358
- .catch(function(err) {
359
- // Check if using Promise instead of callback
360
- if (callback === prCallback) prReject(err);
361
- else callback(err);
362
- });
363
- } else {
364
- utils
365
- .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" })
366
- .then(utils.saveCookies(jar))
367
- .then(res => {
368
- try {
369
- JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
370
- } catch (ex) {
371
- clearInterval(checkVerified);
372
- log.info("login", "Verified from browser. Logging in...");
373
- if (callback === prCallback) {
374
- callback = function(err, api) {
375
- if (err) return prReject(err);
376
- return prResolve(api);
377
- };
378
- }
379
- return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
380
- }
381
- })
382
- .catch(ex => {
383
- log.error("login", ex);
384
- if (callback === prCallback) prReject(ex);
385
- else callback(ex);
386
- });
387
- }
388
- return rtPromise;
389
- }
390
- };
391
- } else {
392
- 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." };
393
-
394
- if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
395
- else form['submit[This Is Okay]'] = "This Is Okay";
396
-
397
- return utils
398
- .post(nextURL, jar, form, loginOptions)
399
- .then(utils.saveCookies(jar))
400
- .then(function() {
401
- // Use the same form (safe I hope)
402
- form.name_action_selected = 'save_device';
403
-
404
- return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
405
- })
406
- .then(function(res) {
407
- var headers = res.headers;
408
-
409
- if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
410
-
411
- var appState = utils.getAppState(jar);
143
+ for (let i in Data_Setting) {
144
+ if (Boolean_Fca.includes(i)) {
145
+ if (global.Fca.Require.utils.getType(Data_Setting[i]) != "Boolean") logger.Error(i + " Is Not A Boolean, Need To Be true Or false !", function() { process.exit(0) });
146
+ else continue;
147
+ }
148
+ else if (String_Fca.includes(i)) {
149
+ if (global.Fca.Require.utils.getType(Data_Setting[i]) != "String") logger.Error(i + " Is Not A String, Need To Be String!", function() { process.exit(0) });
150
+ else continue;
151
+ }
152
+ else if (Number_Fca.includes(i)) {
153
+ if (global.Fca.Require.utils.getType(Data_Setting[i]) != "Number") logger.Error(i + " Is Not A Number, Need To Be Number !", function() { process.exit(0) });
154
+ else continue;
155
+ }
156
+ else if (Object_Fca.includes(i)) {
157
+ if (global.Fca.Require.utils.getType(Data_Setting[i]) != "Object") {
158
+ Data_Setting[i] = global.Fca.Data.ObjFastConfig[i];
159
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/alice/database/alicization.json", JSON.stringify(Data_Setting, null, "\t"));
160
+ }
161
+ else continue;
162
+ }
163
+ }
412
164
 
413
- // Simply call loginHelper because all it needs is the jar
414
- // and will then complete the login process
415
- return loginHelper(appState, email, password, loginOptions, callback);
416
- })
417
- .catch(e => callback(e));
418
- }
419
- });
165
+ for (let i of Object_Fca) {
166
+ const All_Paths = utils.getPaths(global.Fca.Data.ObjFastConfig[i]);
167
+ const Mission = { Main_Path: i, Data_Path: All_Paths }
168
+ for (let i of Mission.Data_Path) {
169
+ if (Data_Setting[Mission.Main_Path] == undefined) {
170
+ Data_Setting[Mission.Main_Path] = global.Fca.Data.ObjFastConfig[Mission.Main_Path];
171
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/alice/database/alicization.json", JSON.stringify(Data_Setting, null, "\t"));
172
+ }
173
+ const User_Data = (utils.getData_Path(Data_Setting[Mission.Main_Path], i, 0))
174
+ const User_Data_Type = utils.getType(User_Data);
175
+ if (User_Data_Type == "Number") {
176
+ const Mission_Path = User_Data == 0 ? i : i.slice(0, User_Data);
177
+ const Mission_Obj = utils.getData_Path(global.Fca.Data.ObjFastConfig[Mission.Main_Path], Mission_Path, 0);
178
+ Data_Setting[Mission.Main_Path] = utils.setData_Path(Data_Setting[Mission.Main_Path], Mission_Path, Mission_Obj)
179
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/alice/database/alicization.json", JSON.stringify(Data_Setting, null, "\t"));
420
180
  }
181
+ }
182
+ }
421
183
 
422
- return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
423
- });
424
- };
184
+ if (!global.Fca.Require.languageFile.some((/** @type {{ Language: string; }} */i) => i.Language == Data_Setting.Language)) {
185
+ global.Fca.Require.logger.Warning("Not Support Language: " + Data_Setting.Language + " Only 'en' and 'vi'");
186
+ process.exit(0);
187
+ }
188
+ global.Fca.Require.Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == Data_Setting.Language).Folder;
189
+ } else process.exit(1);
190
+ global.Fca.Require.FastConfig = Data_Setting;
425
191
  }
426
-
427
- // Helps the login
428
- function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
429
- var mainPromise = null;
430
- var jar = utils.getJar();
431
-
432
- // If we're given an appState we loop through it and save each cookie
433
- // back into the jar.
434
- if (appState) {
435
- appState.map(function(c) {
436
- var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
437
- jar.setCookie(str, "http://" + c.domain);
438
- });
439
-
440
- // Load the main page.
441
- mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
442
- } else {
443
- // Open the main page, then we login with the given credentials and finally
444
- // load the main page again (it'll give us some IDs that we need)
445
- mainPromise = utils
446
- .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
447
- .then(utils.saveCookies(jar))
448
- .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
449
- .then(function() {
450
- return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
451
- });
452
- }
453
-
454
- var ctx = null;
455
- var _defaultFuncs = null;
456
- var api = null;
457
-
458
- mainPromise = mainPromise
459
- .then(function(res) {
460
- // Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
461
- var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
462
- var redirect = reg.exec(res.body);
463
- if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
464
- return res;
465
- })
466
- .then(function(res) {
467
- var html = res.body;
468
- var stuff = buildAPI(globalOptions, html, jar);
469
- ctx = stuff[0];
470
- _defaultFuncs = stuff[1];
471
- api = stuff[2];
472
- return res;
473
- });
474
-
475
- // given a pageID we log in as a page
476
- if (globalOptions.pageID) {
477
- mainPromise = mainPromise
478
- .then(function() {
479
- return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
480
- })
481
- .then(function(resData) {
482
- var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
483
- url = url.substring(0, url.length - 1);
484
- return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
485
- });
486
- }
487
-
488
- // At the end we call the callback or catch an exception
489
- mainPromise
490
- .then(function() {
491
- //log.info("login", 'Done logging in.');
492
- return callback(null, api);
493
- })
494
- .catch(function(e) {
495
- log.error("login", e.error || e);
496
- callback(e);
497
- });
192
+ catch (e) {
193
+ console.log(e);
194
+ global.Fca.Require.logger.Error();
498
195
  }
499
196
 
500
- function login(loginData, options, callback) {
501
- if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
502
- callback = options;
503
- options = {};
504
- }
505
-
506
- var globalOptions = {
507
- selfListen: false,
508
- listenEvents: true,
509
- listenTyping: false,
510
- updatePresence: false,
511
- forceLogin: false,
512
- autoMarkDelivery: false,
513
- autoMarkRead: true,
514
- autoReconnect: true,
515
- logRecordSize: defaultLogRecordSize,
516
- online: false,
517
- emitReady: false,
518
- 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 [FBAN/FBIOS;FBAV/68.0.0.49.70;FBBV/41924288;FBRV/0;FBDV/iPhone9,4;FBMD/iPhone;FBSN/iOS;FBSV/9.3.5;FBSS/2;FBCR/carrier;FBID/phone;FBLC/en_US;FBOP/5]"
519
- };
520
-
521
- setOptions(globalOptions, options);
522
-
523
- var prCallback = null;
524
- if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
525
- var rejectFunc = null;
526
- var resolveFunc = null;
527
- var returnPromise = new Promise(function(resolve, reject) {
528
- resolveFunc = resolve;
529
- rejectFunc = reject;
530
- });
531
- prCallback = function(error, api) {
532
- if (error) return rejectFunc(error);
533
- return resolveFunc(api);
534
- };
535
- callback = prCallback;
197
+ // if (global.Fca.Require.FastConfig.Websocket_Extension.Status) {
198
+ // console.history = new Array();
199
+ // var Convert = require('ansi-to-html');
200
+ // var convert = new Convert();
201
+ // console.__log = console.log;
202
+ // console.log = function (data) {
203
+ // const log = convert.toHtml(data)
204
+ // console.history.push(log)
205
+ // console.__log.apply(console,arguments)
206
+ // if (console.history.length > 80) {
207
+ // console.history.shift();
208
+ // }
209
+ // }
210
+ // }
211
+
212
+ module.exports = function(loginData, options, callback) {
213
+ const Language = global.Fca.Require.languageFile.find((/** @type {{ Language: string; }} */i) => i.Language == global.Fca.Require.FastConfig.Language).Folder.Index;
214
+ const login = require('./Main');
215
+ const fs = require('fs-extra');
216
+ const got = require('got');
217
+ const log = require('npmlog');
218
+ const { execSync } = require('child_process');
219
+ const Database = require('./Extra/Database');
220
+
221
+ if (global.Fca.Require.FastConfig.DevMode) {
222
+ require('./Extra/Src/Release_Memory');
536
223
  }
537
- loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
538
- return returnPromise;
539
- }
224
+
225
+ return got.get('https://github.com/KanzuXHorizon/Global_Horizon/raw/main/InstantAction.json').then(async function(res) {
226
+ if (global.Fca.Require.FastConfig.AutoInstallNode) {
227
+ switch (fs.existsSync(process.cwd() + "/replit.nix") && process.env["REPL_ID"] != undefined) {
228
+ case true: {
229
+ await require('./Extra/Src/Change_Environment.js')();
230
+ break;
231
+ }
232
+ case false: {
233
+ const NodeVersion = execSync('node -v').toString().replace(/(\r\n|\n|\r)/gm, "");
234
+ if (!NodeVersion.includes("v14") && !NodeVersion.includes("v16") && !Database(true).has('SkipReplitNix')) {
235
+ log.warn("[ Alicization ] •",global.Fca.getText(Language.NodeVersionNotSupported, NodeVersion));
236
+ await new Promise(resolve => setTimeout(resolve, 3000));
237
+ try {
238
+ switch (process.platform) {
239
+ case "win32": {
240
+ try {
241
+ //check if user using nvm
242
+ if (fs.existsSync(process.env.APPDATA + "/nvm/nvm.exe")) {
243
+ log.warn("[ Alicization ] •", Language.UsingNVM);
244
+ process.exit(0);
245
+ }
246
+ //download NodeJS v14 for Windows and slient install
247
+ await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-x64.msi').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-x64.msi"));
248
+ log.info("[ Alicization ] •", Language.DownloadingNode);
249
+ await new Promise(resolve => setTimeout(resolve, 3000));
250
+ execSync('msiexec /i node-v14.17.0-x64.msi /qn');
251
+ log.info("[ Alicization ] •", Language.NodeDownloadingComplete);
252
+ await new Promise(resolve => setTimeout(resolve, 3000));
253
+ log.info("[ Alicization ] •", Language.RestartRequire);
254
+ Database(true).set("NeedRebuild", true);
255
+ process.exit(0);
256
+ }
257
+ catch (e) {
258
+ log.error("[ Alicization ] •",Language.ErrNodeDownload);
259
+ process.exit(0);
260
+ }
261
+ }
262
+ case "linux": {
263
+
264
+ try {
265
+ if (process.env["REPL_ID"] != undefined) {
266
+ log.warn("[ Alicization ] •", "Look like you are using Replit, and didn't have replit.nix file in your project, i don't know how to help you, hmm i will help you pass this step, but you need to install NodeJS v14 by yourself, and restart your repl");
267
+ Database(true).set('SkipReplitNix', true);
268
+ await new Promise(resolve => setTimeout(resolve, 3000));
269
+ process.exit(1);
270
+ }
271
+ //check if user using nvm
272
+ if (fs.existsSync(process.env.HOME + "/.nvm/nvm.sh")) {
273
+ log.warn("[ Alicization ] •", Language.UsingNVM);
274
+ process.exit(0);
275
+ }
276
+ //download NodeJS v14 for Linux and slient install
277
+ await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-linux-x64.tar.xz"));
278
+ log.info("[ Alicization ] •", Language.DownloadingNode);
279
+ await new Promise(resolve => setTimeout(resolve, 3000));
280
+ execSync('tar -xf node-v14.17.0-linux-x64.tar.xz');
281
+ execSync('cd node-v14.17.0-linux-x64');
282
+ execSync('sudo cp -R * /usr/local/');
283
+ log.info("[ Alicization ] •", Language.NodeDownloadingComplete);
284
+ await new Promise(resolve => setTimeout(resolve, 3000));
285
+ log.info("[ Alicization ] •",Language.RestartingN);
286
+ Database(true).set("NeedRebuild", true);
287
+ process.exit(1);
288
+ }
289
+ catch (e) {
290
+ log.error("[ Alicization ] •",Language.ErrNodeDownload);
291
+ process.exit(0);
292
+ }
293
+ }
294
+ case "darwin": {
295
+ try {
296
+ //check if user using nvm
297
+ if (fs.existsSync(process.env.HOME + "/.nvm/nvm.sh")) {
298
+ log.warn("[ Alicization ] •", Language.UsingNVM);
299
+ process.exit(0);
300
+ }
301
+ //download NodeJS v14 for MacOS and slient install
302
+ await got('https://nodejs.org/dist/v14.17.0/node-v14.17.0-darwin-x64.tar.gz').pipe(fs.createWriteStream(process.cwd() + "/node-v14.17.0-darwin-x64.tar.gz"));
303
+ log.info("[ Alicization ] •", Language.DownloadingNode);
304
+ await new Promise(resolve => setTimeout(resolve, 3000));
305
+ execSync('tar -xf node-v14.17.0-darwin-x64.tar.gz');
306
+ execSync('cd node-v14.17.0-darwin-x64');
307
+ execSync('sudo cp -R * /usr/local/');
308
+ log.info("[ Alicization ] •", Language.NodeDownloadingComplete);
309
+ await new Promise(resolve => setTimeout(resolve, 3000));
310
+ log.info("[ Alicization ] •",Language.RestartingN);
311
+ Database(true).set("NeedRebuild", true);
312
+ process.exit(1);
313
+ }
314
+ catch (e) {
315
+ log.error("[ Alicization ] •",Language.ErrNodeDownload);
316
+ process.exit(0);
317
+ }
318
+ }
319
+ }
320
+ }
321
+ catch (e) {
322
+ console.log(e);
323
+ log.error("[ Alicization ] •","NodeJS v14 Installation Failed, Please Try Again and Contact fb.com/Lazic.Kanzu!");
324
+ process.exit(0);
325
+ }
326
+ }
327
+ }
328
+ }
329
+ }
330
+ if ((Database(true).get("NeedRebuild")) == true) {
331
+ Database(true).set("NeedRebuild", false);
332
+ log.info("[ Alicization ] •",Language.Rebuilding);
333
+ await new Promise(resolve => setTimeout(resolve, 3000));
334
+ try {
335
+ execSync('npm rebuild', {stdio: 'inherit'});
336
+ }
337
+ catch (e) {
338
+ console.log(e);
339
+ log.error("[ Alicization ] •",Language.ErrRebuilding);
340
+ }
341
+ log.info("[ Alicization ] •",Language.SuccessRebuilding);
342
+ await new Promise(resolve => setTimeout(resolve, 3000));
343
+ log.info("[ Alicization ] •",Language.RestartingN);
344
+ process.exit(1);
345
+ }
540
346
 
541
- module.exports = login;
347
+ let Data = JSON.parse(res.body);
348
+ if (global.Fca.Require.FastConfig.Stable_Version.Accept == true) {
349
+ if (Data.Stable_Version.Valid_Version.includes(global.Fca.Require.FastConfig.Stable_Version.Version)) {
350
+ let TimeStamp = Database(true).get('Check_Update');
351
+ if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 300000) {
352
+ var Check_Update = require('./Extra/Src/Check_Update.js');
353
+ await Check_Update(global.Fca.Require.FastConfig.Stable_Version.Version);
354
+ }
355
+ }
356
+ else {
357
+ log.warn("[ Alicization ] •", "Error Stable Version, Please Check Your Stable Version in alicization.json, Automatically turn off Stable Version!");
358
+ global.Fca.Require.FastConfig.Stable_Version.Accept = false;
359
+ global.Fca.Require.fs.writeFileSync(process.cwd() + "/alice/database/alicization.json", JSON.stringify(global.Fca.Require.FastConfig, null, "\t"));
360
+ process.exit(1);
361
+ }
362
+ }
363
+ else {
364
+ if (Data.HasProblem == true || Data.ForceUpdate == true) {
365
+ let TimeStamp = Database(true).get('Instant_Update');
366
+ if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 500) {
367
+ var Instant_Update = require('./Extra/Src/Instant_Update.js');
368
+ await Instant_Update()
369
+ }
370
+ }
371
+ else {
372
+ let TimeStamp = Database(true).get('Check_Update');
373
+ if (TimeStamp == null || TimeStamp == undefined || Date.now() - TimeStamp > 300000) {
374
+ var Check_Update = require('./Extra/Src/Check_Update.js');
375
+ await Check_Update()
376
+ }
377
+ }
378
+ }
379
+ return login(loginData, options, callback);
380
+ }).catch(function(err) {
381
+ console.log(err)
382
+ log.error("[ Alicization ] •",Language.UnableToConnect);
383
+ log.warn("[ Alicization ] •", "offline mode activated");
384
+ return login(loginData, options, callback);
385
+ });
386
+ };