alicezetion 1.3.5 → 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 -560
  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,579 +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 'online':
25
- globalOptions.online = Boolean(options.online);
26
- break;
27
- case 'logLevel':
28
- log.level = options.logLevel;
29
- globalOptions.logLevel = options.logLevel;
30
- break;
31
- case 'logRecordSize':
32
- log.maxRecordSize = options.logRecordSize;
33
- globalOptions.logRecordSize = options.logRecordSize;
34
- break;
35
- case 'selfListen':
36
- globalOptions.selfListen = Boolean(options.selfListen);
37
- break;
38
- case 'listenEvents':
39
- globalOptions.listenEvents = Boolean(options.listenEvents);
40
- break;
41
- case 'pageID':
42
- globalOptions.pageID = options.pageID.toString();
43
- break;
44
- case 'updatePresence':
45
- globalOptions.updatePresence = Boolean(options.updatePresence);
46
- break;
47
- case 'forceLogin':
48
- globalOptions.forceLogin = Boolean(options.forceLogin);
49
- break;
50
- case 'userAgent':
51
- globalOptions.userAgent = options.userAgent;
52
- break;
53
- case 'autoMarkDelivery':
54
- globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
55
- break;
56
- case 'autoMarkRead':
57
- globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
58
- break;
59
- case 'listenTyping':
60
- globalOptions.listenTyping = Boolean(options.listenTyping);
61
- break;
62
- case 'proxy':
63
- if (typeof options.proxy != "string") {
64
- delete globalOptions.proxy;
65
- utils.setProxy();
66
- } else {
67
- globalOptions.proxy = options.proxy;
68
- 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;
74
+ }
75
+ }
76
+ else {
77
+ hours = 0;
78
+ }
79
+ return `${hours} Hours`;
80
+ }
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
+ });
103
+ }
104
+ break;
105
+ default: {
106
+ require('npmlog').Error("Invalid Message!");
107
+ };
69
108
  }
70
- break;
71
- case 'autoReconnect':
72
- globalOptions.autoReconnect = Boolean(options.autoReconnect);
73
- break;
74
- case 'emitReady':
75
- globalOptions.emitReady = Boolean(options.emitReady);
76
- break;
77
- default:
78
- log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
79
- break;
80
109
  }
81
- });
82
- }
83
-
84
- function buildAPI(globalOptions, html, jar) {
85
- var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function (val) {
86
- return val.cookieString().split("=")[0] === "c_user";
87
- });
88
-
89
- if (maybeCookie.length === 0) {
90
- 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." };
91
- }
92
-
93
- if (html.indexOf("/checkpoint/block/?next") > -1) {
94
- log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
95
- }
96
-
97
- var userID = maybeCookie[0].cookieString().split("=")[1].toString();
110
+ });
98
111
 
99
- try {
100
- clearInterval(checkVerified);
101
- } catch (_) { }
102
-
103
- var clientID = (Math.random() * 2147483648 | 0).toString(16);
104
-
105
-
106
- let oldFBMQTTMatch = html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);
107
- let mqttEndpoint = null;
108
- let region = null;
109
- let irisSeqID = null;
110
- var noMqttData = null;
111
-
112
- if (oldFBMQTTMatch) {
113
- irisSeqID = oldFBMQTTMatch[1];
114
- mqttEndpoint = oldFBMQTTMatch[2];
115
- region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
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
- } else {
123
- let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
124
- if (legacyFBMQTTMatch) {
125
- mqttEndpoint = legacyFBMQTTMatch[4];
126
- region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
127
- } else {
128
- noMqttData = html;
129
- }
130
- }
131
- }
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);
132
118
 
133
- // All data available to api functions
134
- var ctx = {
135
- userID: userID,
136
- jar: jar,
137
- clientID: clientID,
138
- globalOptions: globalOptions,
139
- loggedIn: true,
140
- access_token: 'NONE',
141
- clientMutationId: 0,
142
- mqttClient: undefined,
143
- lastSeqId: irisSeqID,
144
- syncToken: undefined,
145
- mqttEndpoint,
146
- region,
147
- firstListen: true
148
- };
149
119
 
150
- var api = {
151
- setOptions: setOptions.bind(null, globalOptions),
152
- getAppState: function getAppState() {
153
- return utils.getAppState(jar);
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);
154
123
  }
155
- };
156
124
 
157
- if (noMqttData) {
158
- api["htmlData"] = noMqttData;
159
- }
160
-
161
- const apiFuncNames = [
162
- 'addExternalModule',
163
- 'addUserToGroup',
164
- 'changeAdminStatus',
165
- 'changeArchivedStatus',
166
- 'changeBio',
167
- 'changeBlockedStatus',
168
- 'changeGroupImage',
169
- 'changeNickname',
170
- 'changeThreadColor',
171
- 'changeThreadEmoji',
172
- 'createNewGroup',
173
- 'createPoll',
174
- 'deleteMessage',
175
- 'deleteThread',
176
- 'forwardAttachment',
177
- 'getCurrentUserID',
178
- 'getEmojiUrl',
179
- 'getFriendsList',
180
- 'getThreadHistory',
181
- 'getThreadInfo',
182
- 'getThreadList',
183
- 'getThreadPictures',
184
- 'getUserID',
185
- 'getUserInfo',
186
- 'handleMessageRequest',
187
- 'listenMqtt',
188
- 'logout',
189
- 'markAsDelivered',
190
- 'markAsRead',
191
- 'markAsReadAll',
192
- 'markAsSeen',
193
- 'muteThread',
194
- 'removeUserFromGroup',
195
- 'resolvePhotoUrl',
196
- 'searchForThread',
197
- 'chat',
198
- 'sendTypingIndicator',
199
- 'setMessageReaction',
200
- 'setTitle',
201
- 'threadColors',
202
- 'unsendMessage',
203
-
204
- // HTTP
205
- 'httpGet',
206
- 'httpPost',
207
-
208
- // Deprecated features
209
- "getThreadListDeprecated",
210
- 'getThreadHistoryDeprecated',
211
- 'getThreadInfoDeprecated',
212
- ];
213
-
214
- var defaultFuncs = utils.makeDefaults(html, userID, ctx);
215
-
216
- // Load all api functions in a loop
217
- apiFuncNames.map(function (v) {
218
- api[v] = require('./leiamnash/' + v)(defaultFuncs, api, ctx);
219
- });
220
-
221
- return [ctx, defaultFuncs, api];
125
+ try {
126
+ var Data_Setting = require(process.cwd() + "/alice/database/alicization.json");
222
127
  }
223
-
224
- function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
225
- return function (res) {
226
- var html = res.body;
227
- var $ = cheerio.load(html);
228
- var arr = [];
229
-
230
- // This will be empty, but just to be sure we leave it
231
- $("#login_form input").map(function (i, v) {
232
- arr.push({ val: $(v).val(), name: $(v).attr("name") });
233
- });
234
-
235
- arr = arr.filter(function (v) {
236
- return v.val && v.val.length;
237
- });
238
-
239
- var form = utils.arrToForm(arr);
240
- form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
241
- form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
242
- form.email = email;
243
- form.pass = password;
244
- form.default_persistent = '0';
245
- form.lgnrnd = utils.getFrom(html, "name=\"lgnrnd\" value=\"", "\"");
246
- form.locale = 'en_US';
247
- form.timezone = '240';
248
- form.lgnjs = ~~(Date.now() / 1000);
249
-
250
-
251
- // Getting cookies from the HTML page... (kill me now plz)
252
- // we used to get a bunch of cookies in the headers of the response of the
253
- // request, but FB changed and they now send those cookies inside the JS.
254
- // They run the JS which then injects the cookies in the page.
255
- // The "solution" is to parse through the html and find those cookies
256
- // which happen to be conveniently indicated with a _js_ in front of their
257
- // variable name.
258
- //
259
- // ---------- Very Hacky Part Starts -----------------
260
- var willBeCookies = html.split("\"_js_");
261
- willBeCookies.slice(1).map(function (val) {
262
- var cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
263
- jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
264
- });
265
- // ---------- Very Hacky Part Ends -----------------
266
-
267
- return utils
268
- .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
269
- .then(utils.saveCookies(jar))
270
- .then(function (res) {
271
- var headers = res.headers;
272
- if (!headers.location) {
273
- throw { error: "Wrong username/password." };
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
142
+
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
+ }
274
163
  }
275
164
 
276
- // This means the account has login approvals turned on.
277
- if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
278
- var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
279
-
280
- return utils
281
- .get(headers.location, jar, null, loginOptions)
282
- .then(utils.saveCookies(jar))
283
- .then(function (res) {
284
- var html = res.body;
285
- // Make the form in advance which will contain the fb_dtsg and nh
286
- var $ = cheerio.load(html);
287
- var arr = [];
288
- $("form input").map(function (i, v) {
289
- arr.push({ val: $(v).val(), name: $(v).attr("name") });
290
- });
291
-
292
- arr = arr.filter(function (v) {
293
- return v.val && v.val.length;
294
- });
295
-
296
- var form = utils.arrToForm(arr);
297
- if (html.indexOf("checkpoint/?next") > -1) {
298
- setTimeout(() => {
299
- checkVerified = setInterval((_form) => {}, 5000, {
300
- fb_dtsg: form.fb_dtsg,
301
- jazoest: form.jazoest,
302
- dpr: 1
303
- });
304
- }, 2500);
305
- throw {
306
- error: 'login-approval',
307
- continue: function submit2FA(code) {
308
- form.approvals_code = code;
309
- form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
310
- var prResolve = null;
311
- var prReject = null;
312
- var rtPromise = new Promise(function (resolve, reject) {
313
- prResolve = resolve;
314
- prReject = reject;
315
- });
316
- if (typeof code == "string") {
317
- utils
318
- .post(nextURL, jar, form, loginOptions)
319
- .then(utils.saveCookies(jar))
320
- .then(function (res) {
321
- var $ = cheerio.load(res.body);
322
- var error = $("#approvals_code").parent().attr("data-xui-error");
323
- if (error) {
324
- throw {
325
- error: 'login-approval',
326
- errordesc: "Invalid 2FA code.",
327
- lerror: error,
328
- continue: submit2FA
329
- };
330
- }
331
- })
332
- .then(function () {
333
- // Use the same form (safe I hope)
334
- delete form.no_fido;
335
- delete form.approvals_code;
336
- form.name_action_selected = 'dont_save'; //'save_device';
337
-
338
- return utils
339
- .post(nextURL, jar, form, loginOptions)
340
- .then(utils.saveCookies(jar));
341
- })
342
- .then(function (res) {
343
- var headers = res.headers;
344
- if (!headers.location && res.body.indexOf('Review Recent Login') > -1) {
345
- throw { error: "Something went wrong with login approvals." };
346
- }
347
-
348
- var appState = utils.getAppState(jar);
349
-
350
- if (callback === prCallback) {
351
- callback = function (err, api) {
352
- if (err) {
353
- return prReject(err);
354
- }
355
- return prResolve(api);
356
- };
357
- }
358
-
359
- // Simply call loginHelper because all it needs is the jar
360
- // and will then complete the login process
361
- return loginHelper(appState, email, password, loginOptions, callback);
362
- })
363
- .catch(function (err) {
364
- // Check if using Promise instead of callback
365
- if (callback === prCallback) {
366
- prReject(err);
367
- } else {
368
- callback(err);
369
- }
370
- });
371
- } else {
372
- utils
373
- .post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions, null, {
374
- "Referer": "https://www.facebook.com/checkpoint/?next"
375
- })
376
- .then(utils.saveCookies(jar))
377
- .then(res => {
378
- try {
379
- JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
380
- } catch (ex) {
381
- clearInterval(checkVerified);
382
- if (callback === prCallback) {
383
- callback = function (err, api) {
384
- if (err) {
385
- return prReject(err);
386
- }
387
- return prResolve(api);
388
- };
389
- }
390
- return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
391
- }
392
- })
393
- .catch(ex => {
394
- log.error("login", ex);
395
- if (callback === prCallback) {
396
- prReject(ex);
397
- } else {
398
- callback(ex);
399
- }
400
- });
401
- }
402
- return rtPromise;
403
- }
404
- };
405
- } else {
406
- if (!loginOptions.forceLogin) {
407
- throw { error: "Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again." };
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"));
408
172
  }
409
- if (html.indexOf("Suspicious Login Attempt") > -1) {
410
- form['submit[This was me]'] = "This was me";
411
- } else {
412
- form['submit[This Is Okay]'] = "This Is Okay";
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"));
413
180
  }
414
-
415
- return utils
416
- .post(nextURL, jar, form, loginOptions)
417
- .then(utils.saveCookies(jar))
418
- .then(function () {
419
- // Use the same form (safe I hope)
420
- form.name_action_selected = 'save_device';
421
-
422
- return utils
423
- .post(nextURL, jar, form, loginOptions)
424
- .then(utils.saveCookies(jar));
425
- })
426
- .then(function (res) {
427
- var headers = res.headers;
428
-
429
- if (!headers.location && res.body.indexOf('Review Recent Login') > -1) {
430
- throw { error: "Something went wrong with review recent login." };
431
- }
432
-
433
- var appState = utils.getAppState(jar);
434
-
435
- // Simply call loginHelper because all it needs is the jar
436
- // and will then complete the login process
437
- return loginHelper(appState, email, password, loginOptions, callback);
438
- })
439
- .catch(function (e) {
440
- callback(e);
441
- });
442
- }
443
- });
181
+ }
444
182
  }
445
183
 
446
- return utils
447
- .get('https://www.facebook.com/', jar, null, loginOptions)
448
- .then(utils.saveCookies(jar));
449
- });
450
- };
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;
451
191
  }
452
-
453
- // Helps the login
454
- function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
455
- var mainPromise = null;
456
- var jar = utils.getJar();
457
-
458
- // If we're given an appState we loop through it and save each cookie
459
- // back into the jar.
460
- if (appState) {
461
- appState.map(function (c) {
462
- var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
463
- jar.setCookie(str, "http://" + c.domain);
464
- });
465
-
466
- // Load the main page.
467
- mainPromise = utils
468
- .get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
469
- .then(utils.saveCookies(jar));
470
- } else {
471
- // Open the main page, then we login with the given credentials and finally
472
- // load the main page again (it'll give us some IDs that we need)
473
- mainPromise = utils
474
- .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
475
- .then(utils.saveCookies(jar))
476
- .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
477
- .then(function () {
478
- return utils
479
- .get('https://www.facebook.com/', jar, null, globalOptions)
480
- .then(utils.saveCookies(jar));
481
- });
482
- }
483
-
484
- var ctx = null;
485
- var _defaultFuncs = null;
486
- var api = null;
487
-
488
- mainPromise = mainPromise
489
- .then(function (res) {
490
- // Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
491
- var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
492
- var redirect = reg.exec(res.body);
493
- if (redirect && redirect[1]) {
494
- return utils
495
- .get(redirect[1], jar, null, globalOptions)
496
- .then(utils.saveCookies(jar));
497
- }
498
- return res;
499
- })
500
- .then(function (res) {
501
- var html = res.body;
502
- var stuff = buildAPI(globalOptions, html, jar);
503
- ctx = stuff[0];
504
- _defaultFuncs = stuff[1];
505
- api = stuff[2];
506
- return res;
507
- });
508
-
509
- // given a pageID we log in as a page
510
- if (globalOptions.pageID) {
511
- mainPromise = mainPromise
512
- .then(function () {
513
- return utils
514
- .get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
515
- })
516
- .then(function (resData) {
517
- var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
518
- url = url.substring(0, url.length - 1);
519
-
520
- return utils
521
- .get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
522
- });
523
- }
524
-
525
- // At the end we call the callback or catch an exception
526
- mainPromise
527
- .then(function () {
528
- return callback(null, api);
529
- })
530
- .catch(function (e) {
531
- log.error("login", e.error || e);
532
- callback(e);
533
- });
192
+ catch (e) {
193
+ console.log(e);
194
+ global.Fca.Require.logger.Error();
534
195
  }
535
196
 
536
- function login(loginData, options, callback) {
537
- if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
538
- callback = options;
539
- options = {};
540
- }
541
-
542
- var globalOptions = {
543
- selfListen: false,
544
- listenEvents: false,
545
- listenTyping: false,
546
- updatePresence: false,
547
- forceLogin: false,
548
- autoMarkDelivery: false,
549
- autoMarkRead: false,
550
- autoReconnect: true,
551
- logRecordSize: defaultLogRecordSize,
552
- online: false,
553
- emitReady: false,
554
- 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]"
555
- };
556
-
557
- setOptions(globalOptions, options);
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');
223
+ }
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
+ }
558
346
 
559
- var prCallback = null;
560
- if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
561
- var rejectFunc = null;
562
- var resolveFunc = null;
563
- var returnPromise = new Promise(function (resolve, reject) {
564
- resolveFunc = resolve;
565
- rejectFunc = reject;
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);
566
385
  });
567
- prCallback = function (error, api) {
568
- if (error) {
569
- return rejectFunc(error);
570
- }
571
- return resolveFunc(api);
572
- };
573
- callback = prCallback;
574
- }
575
- loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
576
- return returnPromise;
577
- }
578
-
579
- module.exports = login;
386
+ };