fca-project-orion 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -2
- package/Extra/Database/index.js +468 -468
- package/Extra/ExtraAddons.js +81 -81
- package/Extra/ExtraFindUID.js +61 -61
- package/Extra/ExtraGetThread.js +339 -339
- package/Extra/ExtraScreenShot.js +430 -430
- package/Extra/ExtraUptimeRobot.js +37 -37
- package/Extra/Html/Classic/script.js +118 -118
- package/Extra/Html/Classic/style.css +7 -7
- package/Extra/Security/Base/Step_1.js +5 -5
- package/Extra/Security/Base/Step_2.js +22 -22
- package/Extra/Security/Base/Step_3.js +22 -22
- package/Extra/Security/Base/index.js +172 -172
- package/Extra/Security/Index.js +4 -4
- package/Extra/Security/Step_1.js +5 -5
- package/Extra/Security/Step_2.js +22 -22
- package/Extra/Security/Step_3.js +22 -22
- package/Extra/Src/Change_Environment.js +23 -23
- package/Extra/Src/Check_Update.js +65 -65
- package/Extra/Src/History.js +114 -114
- package/Extra/Src/Instant_Update.js +64 -64
- package/Extra/Src/Last-Run.js +64 -64
- package/Extra/Src/Premium.js +80 -80
- package/Extra/Src/Release_Memory.js +40 -40
- package/Extra/Src/Websocket.js +212 -212
- package/Extra/Src/uuid.js +137 -137
- package/Func/AcceptAgreement.js +31 -31
- package/Func/ClearCache.js +64 -64
- package/Func/ReportV1.js +54 -54
- package/LICENSE +21 -21
- package/Language/index.json +216 -216
- package/Main.js +1215 -1215
- package/README.md +138 -138
- package/SECURITY.md +18 -18
- package/broadcast.js +39 -39
- package/index.js +385 -385
- package/logger.js +66 -66
- package/package.json +93 -93
- package/src/Dev_Horizon_Data.js +124 -124
- package/src/Premium.js +24 -24
- package/src/Screenshot.js +82 -82
- package/src/addExternalModule.js +16 -16
- package/src/addUserToGroup.js +79 -79
- package/src/changeAdminStatus.js +79 -79
- package/src/changeArchivedStatus.js +41 -41
- package/src/changeAvt.js +84 -84
- package/src/changeBio.js +65 -65
- package/src/changeBlockedStatus.js +36 -36
- package/src/changeGroupImage.js +106 -106
- package/src/changeNickname.js +45 -45
- package/src/changeThreadColor.js +62 -62
- package/src/changeThreadEmoji.js +42 -42
- package/src/createNewGroup.js +70 -70
- package/src/createPoll.js +60 -60
- package/src/deleteMessage.js +45 -45
- package/src/deleteThread.js +43 -43
- package/src/forwardAttachment.js +48 -48
- package/src/getAccessToken.js +27 -27
- package/src/getCurrentUserID.js +7 -7
- package/src/getEmojiUrl.js +27 -27
- package/src/getFriendsList.js +73 -73
- package/src/getMessage.js +79 -79
- package/src/getThreadHistory.js +537 -537
- package/src/getThreadInfo.js +424 -424
- package/src/getThreadList.js +213 -213
- package/src/getThreadMain.js +219 -219
- package/src/getThreadPictures.js +59 -59
- package/src/getUID.js +58 -58
- package/src/getUserID.js +62 -62
- package/src/getUserInfo.js +113 -113
- package/src/getUserInfoMain.js +64 -64
- package/src/getUserInfoV2.js +31 -31
- package/src/getUserInfoV3.js +62 -62
- package/src/getUserInfoV4.js +54 -54
- package/src/getUserInfoV5.js +60 -60
- package/src/handleFriendRequest.js +46 -46
- package/src/handleMessageRequest.js +49 -49
- package/src/httpGet.js +49 -49
- package/src/httpPost.js +48 -48
- package/src/httpPostFormData.js +40 -40
- package/src/listenMqtt.js +786 -786
- package/src/logout.js +68 -68
- package/src/markAsDelivered.js +48 -48
- package/src/markAsRead.js +70 -70
- package/src/markAsReadAll.js +42 -42
- package/src/markAsSeen.js +51 -51
- package/src/muteThread.js +47 -47
- package/src/removeUserFromGroup.js +49 -49
- package/src/resolvePhotoUrl.js +37 -37
- package/src/searchForThread.js +43 -43
- package/src/sendMessage.js +378 -378
- package/src/sendTypingIndicator.js +80 -80
- package/src/setMessageReaction.js +109 -109
- package/src/setPostReaction.js +101 -101
- package/src/setTitle.js +74 -74
- package/src/threadColors.js +38 -38
- package/src/unfriend.js +43 -43
- package/src/unsendMessage.js +40 -40
- package/test/Database_Test.js +3 -3
- package/test/Db2.js +529 -529
- package/test/data/shareAttach.js +146 -146
- package/test/data/test.txt +7 -7
- package/test/example-config.json +18 -18
- package/test/memoryleak.js +18 -18
- package/test/test-page.js +140 -140
- package/test/test.js +385 -385
- package/test/testv2.js +17 -17
- package/utils.js +1682 -1682
package/Extra/Src/Websocket.js
CHANGED
@@ -1,213 +1,213 @@
|
|
1
|
-
// /**
|
2
|
-
// /* eslint-disable no-prototype-builtins */
|
3
|
-
// /* eslint-disable linebreak-style */
|
4
|
-
|
5
|
-
// const Eval = require('eval');
|
6
|
-
// const Database = require('../Database');
|
7
|
-
// global.ws = new Object({
|
8
|
-
// client: {},
|
9
|
-
// });
|
10
|
-
// const All_Session_ID = Database().get('Session_ID') || []; // [ { Session_ID: ".", TimeStamp: "" }]
|
11
|
-
// for (let v of All_Session_ID) {
|
12
|
-
// if (v.TimeStamp <= Date.now()) {
|
13
|
-
// const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
|
14
|
-
// All_Session_ID.splice(index,1);
|
15
|
-
// }
|
16
|
-
// else {
|
17
|
-
// setTimeout(() => {
|
18
|
-
// const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
|
19
|
-
// All_Session_ID.splice(index,1);
|
20
|
-
// }, v.TimeStamp - Date.now());
|
21
|
-
// }
|
22
|
-
// }
|
23
|
-
|
24
|
-
// Database().set("Session_ID", All_Session_ID);
|
25
|
-
|
26
|
-
// function generateRandomString() {
|
27
|
-
// var string = '';
|
28
|
-
// var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
29
|
-
// for (var i = 0; i < 16; i++) {
|
30
|
-
// if (i == 4 || i == 8 || i == 12) {
|
31
|
-
// string += '-';
|
32
|
-
// }
|
33
|
-
// var randomIndex = Math.floor(Math.random() * characters.length);
|
34
|
-
// string += characters.charAt(randomIndex);
|
35
|
-
// }
|
36
|
-
// return string;
|
37
|
-
// }
|
38
|
-
|
39
|
-
// const HowTo = {
|
40
|
-
// AutoUpdate: "Automatically update if there is a new version. (Restart required)",
|
41
|
-
// AutoLogin: "Automatically login and retrieve cookies to continue running the bot whenever kicked out of the account. (Restart required)",
|
42
|
-
// Login2Fa: "Use two-factor authentication code to log in. (Restart required)",
|
43
|
-
// Uptime: "Help your process to operate for a longer period of time.(Restart required)",
|
44
|
-
// BroadCast: "Receive messages from the server.(Restart required)",
|
45
|
-
// EncryptFeature: "Encrypt your account (appstate) to prevent it from being accessed or damaged by others.(Restart required)",
|
46
|
-
// ResetDataLogin: "Used to reset autologin account and password.(Restart required)",
|
47
|
-
// DevMode: "Developer mode, insider, testing untested features.(Restart required)",
|
48
|
-
// AutoInstallNode: "Automatically download NodeJS version as per system's requirement.(Restart required)",
|
49
|
-
// AntiSendAppState: "Check and prevent sending your account (appstate) via messages.",
|
50
|
-
// HTML: "Display the website of FCA.(Restart required)",
|
51
|
-
// Accept: "Is a part of stable_version, turned on to use a stable version without errors! (Restart required)",
|
52
|
-
// AntiGetThreadInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
|
53
|
-
// AntiGetUserInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
|
54
|
-
// Status: "Turn on/off the websocket-extension feature. (Restart required)",
|
55
|
-
// Language: "Select system language (Restart required)",
|
56
|
-
// MainName: "Name on the top whenever log data. (Restart required)",
|
57
|
-
// UserName: "Your name display in Express - HTML. (Restart required)",
|
58
|
-
// MusicLink: "Your music link. (Restart required)",
|
59
|
-
// AuthString: "Code to retrieve 2FA authenticator. (Restart required)",
|
60
|
-
// PreKey: "Obsolete feature.",
|
61
|
-
// Config: "Feature is delayed.",
|
62
|
-
// Version: "stable version - Stable_Version Feature. (Restart required)",
|
63
|
-
// Database_Type: "Type of database. (Restart required)",
|
64
|
-
// AppState_Path: "Name of the file containing your appstate.",
|
65
|
-
// AutoRestartMinutes: "Auto-restart after a certain number of minutes. (Restart required)",
|
66
|
-
// RestartMQTT_Minutes: "Automatically restarting MQTT without restarting the bot helps prevent console hangups. (Restart required)",
|
67
|
-
// Example: {
|
68
|
-
// Language: "vi or en",
|
69
|
-
// AuthString: "Like this SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png",
|
70
|
-
// Version: "Valid version: https://github.com/KanzuXHorizon/Global_Horizon/blob/main/InstantAction.json",
|
71
|
-
// Database_Type: "default or json",
|
72
|
-
// AppState_Path: "fbstate.json, appstate.json,...",
|
73
|
-
// AutoRestartMinutes: "Number 0 to turn off, Encourage number 60",
|
74
|
-
// RestartMQTT_Minutes: "Number 0 to turn off, Encourage number 45"
|
75
|
-
|
76
|
-
// }
|
77
|
-
// };
|
78
|
-
|
79
|
-
// module.exports.connect = function(WebSocket) {
|
80
|
-
// WebSocket.on('connection', function (Websocket, req) {
|
81
|
-
// var Ws_Client;
|
82
|
-
// if (!global.ws.client.hasOwnProperty(req.socket.remoteAddress)) {
|
83
|
-
// global.ws.client[req.socket.remoteAddress] = { Websocket, Status: false, ResetPassWordTime: 0 };
|
84
|
-
// Ws_Client = global.ws.client[req.socket.remoteAddress];
|
85
|
-
// }
|
86
|
-
// else {
|
87
|
-
// global.ws.client[req.socket.remoteAddress] = { Websocket, Status: global.ws.client[req.socket.remoteAddress].Status, ResetPassWordTime: global.ws.client[req.socket.remoteAddress].ResetPassWordTime };
|
88
|
-
// Ws_Client = global.ws.client[req.socket.remoteAddress];
|
89
|
-
// }
|
90
|
-
// Ws_Client.Websocket.send(JSON.stringify({ Status: "Username&PassWord"}));
|
91
|
-
// Ws_Client.Websocket.on('message', function(message) {
|
92
|
-
// message = JSON.parse(message);
|
93
|
-
// switch (message.type) {
|
94
|
-
// case "login": {
|
95
|
-
// if (!message.username || !message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 1 }));
|
96
|
-
// const User_UserName = Database().get('Ws_UserName');
|
97
|
-
// const User_PassWord = Database().get('Ws_PassWord');
|
98
|
-
// if (message.username != User_UserName || User_PassWord != message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 2}));
|
99
|
-
// const Format = {
|
100
|
-
// Session_ID: generateRandomString(),
|
101
|
-
// TimeStamp: Date.now() + 24 * 60 * 60 * 1000
|
102
|
-
// };
|
103
|
-
// All_Session_ID.push(Format);
|
104
|
-
// Database().set("Session_ID", All_Session_ID);
|
105
|
-
// global.ws.client[req.socket.remoteAddress].Status = true;
|
106
|
-
// setTimeout(() => {
|
107
|
-
// global.ws.client[req.socket.remoteAddress].Status = false;
|
108
|
-
// }, (Date.now() + 24 * 60 * 60 * 1000) - Date.now());
|
109
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Session_ID: Format.Session_ID, TimeStamp: Format.TimeStamp }));
|
110
|
-
// }
|
111
|
-
// case "check": {
|
112
|
-
// if (!message.Session_ID || !message.TimeStamp) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 3}));
|
113
|
-
// const Format = {
|
114
|
-
// Session_ID: message.Session_ID,
|
115
|
-
// TimeStamp: message.TimeStamp
|
116
|
-
// };
|
117
|
-
// if (Format.TimeStamp <= Date.now()) {
|
118
|
-
// let index = All_Session_ID.findIndex(i => i.Session_ID == Format.Session_ID);
|
119
|
-
// All_Session_ID.splice(index,1);
|
120
|
-
// Database().set("Session_ID", All_Session_ID);
|
121
|
-
// Ws_Client.Status = false;
|
122
|
-
// Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 4}));
|
123
|
-
// return delete global.ws.client[Format.Session_ID];
|
124
|
-
// }
|
125
|
-
// if (All_Session_ID.some(i => i.Session_ID == message.Session_ID)) {
|
126
|
-
// global.ws.client[req.socket.remoteAddress].Status = true;
|
127
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success" }));
|
128
|
-
// }
|
129
|
-
// else {
|
130
|
-
// global.ws.client[req.socket.remoteAddress].Status = false;
|
131
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 5 }));
|
132
|
-
// }
|
133
|
-
// }
|
134
|
-
// case "resetPassword": {
|
135
|
-
// if (!message.Otp || !message.NewPassword) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 7 }));
|
136
|
-
// if (global.ws.client[req.socket.remoteAddress].ResetPassWordTime == 3) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 9 }));
|
137
|
-
// const speakeasy = require('speakeasy');
|
138
|
-
// const secret = Database().get('Ws_2Fa');
|
139
|
-
// if (message.Otp != speakeasy.totp({
|
140
|
-
// secret: secret,
|
141
|
-
// encoding: 'base32'
|
142
|
-
// })) {
|
143
|
-
// global.ws.client[req.socket.remoteAddress].ResetPassWordTime += 1;
|
144
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 8 }));
|
145
|
-
// }
|
146
|
-
// else {
|
147
|
-
// Database().set('Ws_PassWord', message.NewPassword);
|
148
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Status: 'Success' }));
|
149
|
-
// }
|
150
|
-
// }
|
151
|
-
// default: {
|
152
|
-
// if (Ws_Client.Status != true) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 6 }));
|
153
|
-
// switch (message.type) {
|
154
|
-
// case "Command": {
|
155
|
-
// if (message.Data == "Stop") {
|
156
|
-
// return process.exit(0);
|
157
|
-
// }
|
158
|
-
// else Eval(message.Data, {} ,true);
|
159
|
-
// }
|
160
|
-
// break;
|
161
|
-
// case "ChangeAppState": {
|
162
|
-
// try {
|
163
|
-
// const AppState = JSON.stringify(JSON.parse(message.Data), null ,2);
|
164
|
-
// require('fs').writeFileSync(process.cwd() + `/${global.Fca.Require.FastConfig.Websocket_Extension.AppState_Path}`, AppState, 'utf-8');
|
165
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: 0 }));
|
166
|
-
// }
|
167
|
-
// catch (e) {
|
168
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: e }));
|
169
|
-
// }
|
170
|
-
// }
|
171
|
-
// case "GetDocument": {
|
172
|
-
|
173
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: HowTo }));
|
174
|
-
// }
|
175
|
-
// case "getFastConfig": {
|
176
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: global.Fca.Require.FastConfig }));
|
177
|
-
// }
|
178
|
-
// case "ping": {
|
179
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Pong" }));
|
180
|
-
// }
|
181
|
-
// case "FastConfig_Change": {
|
182
|
-
// const FastConfig_Path = require(process.cwd() + "/FastConfigFca.json");
|
183
|
-
// const FastConfig_Global = global.Fca.Require.FastConfig;
|
184
|
-
// const SetConfig = function(Name, Value, Path, Main_Path) {
|
185
|
-
// try {
|
186
|
-
// if (Path && Main_Path) {
|
187
|
-
// FastConfig_Path[Main_Path][Name] = Value;
|
188
|
-
// (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig = FastConfig_Path : '';
|
189
|
-
// }
|
190
|
-
// else {
|
191
|
-
// FastConfig_Path[Name] = Value;
|
192
|
-
// (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig[Name] = Value : '';
|
193
|
-
// }
|
194
|
-
// global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Path, null, "\t"));
|
195
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: `Success ${ (HowTo[Name]).includes('(Restart required)') == true ? 'RestartRequired' : ''}` }));
|
196
|
-
// }
|
197
|
-
// catch (e) {
|
198
|
-
// global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Global, null, "\t"));
|
199
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: e}));
|
200
|
-
// }
|
201
|
-
// };
|
202
|
-
// return SetConfig(message.Data.Name, message.Data.Value, message.Data.Path, message.Data.Main_Path);
|
203
|
-
// }
|
204
|
-
// case "All_logs": {
|
205
|
-
// return Ws_Client.Websocket.send(JSON.stringify({ Type: "Console", Data: console.history.join(" <br> ")}));
|
206
|
-
// }
|
207
|
-
// }
|
208
|
-
// }
|
209
|
-
// }
|
210
|
-
// });
|
211
|
-
// });
|
212
|
-
// return { Client: global.ws.client, WSS: WebSocket };
|
1
|
+
// /**
|
2
|
+
// /* eslint-disable no-prototype-builtins */
|
3
|
+
// /* eslint-disable linebreak-style */
|
4
|
+
|
5
|
+
// const Eval = require('eval');
|
6
|
+
// const Database = require('../Database');
|
7
|
+
// global.ws = new Object({
|
8
|
+
// client: {},
|
9
|
+
// });
|
10
|
+
// const All_Session_ID = Database().get('Session_ID') || []; // [ { Session_ID: ".", TimeStamp: "" }]
|
11
|
+
// for (let v of All_Session_ID) {
|
12
|
+
// if (v.TimeStamp <= Date.now()) {
|
13
|
+
// const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
|
14
|
+
// All_Session_ID.splice(index,1);
|
15
|
+
// }
|
16
|
+
// else {
|
17
|
+
// setTimeout(() => {
|
18
|
+
// const index = All_Session_ID.findIndex(i => i.Session_ID == v.Session_ID);
|
19
|
+
// All_Session_ID.splice(index,1);
|
20
|
+
// }, v.TimeStamp - Date.now());
|
21
|
+
// }
|
22
|
+
// }
|
23
|
+
|
24
|
+
// Database().set("Session_ID", All_Session_ID);
|
25
|
+
|
26
|
+
// function generateRandomString() {
|
27
|
+
// var string = '';
|
28
|
+
// var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
29
|
+
// for (var i = 0; i < 16; i++) {
|
30
|
+
// if (i == 4 || i == 8 || i == 12) {
|
31
|
+
// string += '-';
|
32
|
+
// }
|
33
|
+
// var randomIndex = Math.floor(Math.random() * characters.length);
|
34
|
+
// string += characters.charAt(randomIndex);
|
35
|
+
// }
|
36
|
+
// return string;
|
37
|
+
// }
|
38
|
+
|
39
|
+
// const HowTo = {
|
40
|
+
// AutoUpdate: "Automatically update if there is a new version. (Restart required)",
|
41
|
+
// AutoLogin: "Automatically login and retrieve cookies to continue running the bot whenever kicked out of the account. (Restart required)",
|
42
|
+
// Login2Fa: "Use two-factor authentication code to log in. (Restart required)",
|
43
|
+
// Uptime: "Help your process to operate for a longer period of time.(Restart required)",
|
44
|
+
// BroadCast: "Receive messages from the server.(Restart required)",
|
45
|
+
// EncryptFeature: "Encrypt your account (appstate) to prevent it from being accessed or damaged by others.(Restart required)",
|
46
|
+
// ResetDataLogin: "Used to reset autologin account and password.(Restart required)",
|
47
|
+
// DevMode: "Developer mode, insider, testing untested features.(Restart required)",
|
48
|
+
// AutoInstallNode: "Automatically download NodeJS version as per system's requirement.(Restart required)",
|
49
|
+
// AntiSendAppState: "Check and prevent sending your account (appstate) via messages.",
|
50
|
+
// HTML: "Display the website of FCA.(Restart required)",
|
51
|
+
// Accept: "Is a part of stable_version, turned on to use a stable version without errors! (Restart required)",
|
52
|
+
// AntiGetThreadInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
|
53
|
+
// AntiGetUserInfo: "Using data storage and release algorithms to avoid being blocked by Facebook.",
|
54
|
+
// Status: "Turn on/off the websocket-extension feature. (Restart required)",
|
55
|
+
// Language: "Select system language (Restart required)",
|
56
|
+
// MainName: "Name on the top whenever log data. (Restart required)",
|
57
|
+
// UserName: "Your name display in Express - HTML. (Restart required)",
|
58
|
+
// MusicLink: "Your music link. (Restart required)",
|
59
|
+
// AuthString: "Code to retrieve 2FA authenticator. (Restart required)",
|
60
|
+
// PreKey: "Obsolete feature.",
|
61
|
+
// Config: "Feature is delayed.",
|
62
|
+
// Version: "stable version - Stable_Version Feature. (Restart required)",
|
63
|
+
// Database_Type: "Type of database. (Restart required)",
|
64
|
+
// AppState_Path: "Name of the file containing your appstate.",
|
65
|
+
// AutoRestartMinutes: "Auto-restart after a certain number of minutes. (Restart required)",
|
66
|
+
// RestartMQTT_Minutes: "Automatically restarting MQTT without restarting the bot helps prevent console hangups. (Restart required)",
|
67
|
+
// Example: {
|
68
|
+
// Language: "vi or en",
|
69
|
+
// AuthString: "Like this SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z | https://i.imgur.com/RAg3rvw.png",
|
70
|
+
// Version: "Valid version: https://github.com/KanzuXHorizon/Global_Horizon/blob/main/InstantAction.json",
|
71
|
+
// Database_Type: "default or json",
|
72
|
+
// AppState_Path: "fbstate.json, appstate.json,...",
|
73
|
+
// AutoRestartMinutes: "Number 0 to turn off, Encourage number 60",
|
74
|
+
// RestartMQTT_Minutes: "Number 0 to turn off, Encourage number 45"
|
75
|
+
|
76
|
+
// }
|
77
|
+
// };
|
78
|
+
|
79
|
+
// module.exports.connect = function(WebSocket) {
|
80
|
+
// WebSocket.on('connection', function (Websocket, req) {
|
81
|
+
// var Ws_Client;
|
82
|
+
// if (!global.ws.client.hasOwnProperty(req.socket.remoteAddress)) {
|
83
|
+
// global.ws.client[req.socket.remoteAddress] = { Websocket, Status: false, ResetPassWordTime: 0 };
|
84
|
+
// Ws_Client = global.ws.client[req.socket.remoteAddress];
|
85
|
+
// }
|
86
|
+
// else {
|
87
|
+
// global.ws.client[req.socket.remoteAddress] = { Websocket, Status: global.ws.client[req.socket.remoteAddress].Status, ResetPassWordTime: global.ws.client[req.socket.remoteAddress].ResetPassWordTime };
|
88
|
+
// Ws_Client = global.ws.client[req.socket.remoteAddress];
|
89
|
+
// }
|
90
|
+
// Ws_Client.Websocket.send(JSON.stringify({ Status: "Username&PassWord"}));
|
91
|
+
// Ws_Client.Websocket.on('message', function(message) {
|
92
|
+
// message = JSON.parse(message);
|
93
|
+
// switch (message.type) {
|
94
|
+
// case "login": {
|
95
|
+
// if (!message.username || !message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 1 }));
|
96
|
+
// const User_UserName = Database().get('Ws_UserName');
|
97
|
+
// const User_PassWord = Database().get('Ws_PassWord');
|
98
|
+
// if (message.username != User_UserName || User_PassWord != message.password) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 2}));
|
99
|
+
// const Format = {
|
100
|
+
// Session_ID: generateRandomString(),
|
101
|
+
// TimeStamp: Date.now() + 24 * 60 * 60 * 1000
|
102
|
+
// };
|
103
|
+
// All_Session_ID.push(Format);
|
104
|
+
// Database().set("Session_ID", All_Session_ID);
|
105
|
+
// global.ws.client[req.socket.remoteAddress].Status = true;
|
106
|
+
// setTimeout(() => {
|
107
|
+
// global.ws.client[req.socket.remoteAddress].Status = false;
|
108
|
+
// }, (Date.now() + 24 * 60 * 60 * 1000) - Date.now());
|
109
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Session_ID: Format.Session_ID, TimeStamp: Format.TimeStamp }));
|
110
|
+
// }
|
111
|
+
// case "check": {
|
112
|
+
// if (!message.Session_ID || !message.TimeStamp) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 3}));
|
113
|
+
// const Format = {
|
114
|
+
// Session_ID: message.Session_ID,
|
115
|
+
// TimeStamp: message.TimeStamp
|
116
|
+
// };
|
117
|
+
// if (Format.TimeStamp <= Date.now()) {
|
118
|
+
// let index = All_Session_ID.findIndex(i => i.Session_ID == Format.Session_ID);
|
119
|
+
// All_Session_ID.splice(index,1);
|
120
|
+
// Database().set("Session_ID", All_Session_ID);
|
121
|
+
// Ws_Client.Status = false;
|
122
|
+
// Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 4}));
|
123
|
+
// return delete global.ws.client[Format.Session_ID];
|
124
|
+
// }
|
125
|
+
// if (All_Session_ID.some(i => i.Session_ID == message.Session_ID)) {
|
126
|
+
// global.ws.client[req.socket.remoteAddress].Status = true;
|
127
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success" }));
|
128
|
+
// }
|
129
|
+
// else {
|
130
|
+
// global.ws.client[req.socket.remoteAddress].Status = false;
|
131
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 5 }));
|
132
|
+
// }
|
133
|
+
// }
|
134
|
+
// case "resetPassword": {
|
135
|
+
// if (!message.Otp || !message.NewPassword) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 7 }));
|
136
|
+
// if (global.ws.client[req.socket.remoteAddress].ResetPassWordTime == 3) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 9 }));
|
137
|
+
// const speakeasy = require('speakeasy');
|
138
|
+
// const secret = Database().get('Ws_2Fa');
|
139
|
+
// if (message.Otp != speakeasy.totp({
|
140
|
+
// secret: secret,
|
141
|
+
// encoding: 'base32'
|
142
|
+
// })) {
|
143
|
+
// global.ws.client[req.socket.remoteAddress].ResetPassWordTime += 1;
|
144
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 8 }));
|
145
|
+
// }
|
146
|
+
// else {
|
147
|
+
// Database().set('Ws_PassWord', message.NewPassword);
|
148
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Status: 'Success' }));
|
149
|
+
// }
|
150
|
+
// }
|
151
|
+
// default: {
|
152
|
+
// if (Ws_Client.Status != true) return Ws_Client.Websocket.send(JSON.stringify({ Status: false, Code: 6 }));
|
153
|
+
// switch (message.type) {
|
154
|
+
// case "Command": {
|
155
|
+
// if (message.Data == "Stop") {
|
156
|
+
// return process.exit(0);
|
157
|
+
// }
|
158
|
+
// else Eval(message.Data, {} ,true);
|
159
|
+
// }
|
160
|
+
// break;
|
161
|
+
// case "ChangeAppState": {
|
162
|
+
// try {
|
163
|
+
// const AppState = JSON.stringify(JSON.parse(message.Data), null ,2);
|
164
|
+
// require('fs').writeFileSync(process.cwd() + `/${global.Fca.Require.FastConfig.Websocket_Extension.AppState_Path}`, AppState, 'utf-8');
|
165
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: 0 }));
|
166
|
+
// }
|
167
|
+
// catch (e) {
|
168
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Type: "ChangeAppState", Data: e }));
|
169
|
+
// }
|
170
|
+
// }
|
171
|
+
// case "GetDocument": {
|
172
|
+
|
173
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: HowTo }));
|
174
|
+
// }
|
175
|
+
// case "getFastConfig": {
|
176
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Success", Data: global.Fca.Require.FastConfig }));
|
177
|
+
// }
|
178
|
+
// case "ping": {
|
179
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Status: "Pong" }));
|
180
|
+
// }
|
181
|
+
// case "FastConfig_Change": {
|
182
|
+
// const FastConfig_Path = require(process.cwd() + "/FastConfigFca.json");
|
183
|
+
// const FastConfig_Global = global.Fca.Require.FastConfig;
|
184
|
+
// const SetConfig = function(Name, Value, Path, Main_Path) {
|
185
|
+
// try {
|
186
|
+
// if (Path && Main_Path) {
|
187
|
+
// FastConfig_Path[Main_Path][Name] = Value;
|
188
|
+
// (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig = FastConfig_Path : '';
|
189
|
+
// }
|
190
|
+
// else {
|
191
|
+
// FastConfig_Path[Name] = Value;
|
192
|
+
// (HowTo[Name]).includes('(Restart required)') == false ? global.Fca.Require.FastConfig[Name] = Value : '';
|
193
|
+
// }
|
194
|
+
// global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Path, null, "\t"));
|
195
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: `Success ${ (HowTo[Name]).includes('(Restart required)') == true ? 'RestartRequired' : ''}` }));
|
196
|
+
// }
|
197
|
+
// catch (e) {
|
198
|
+
// global.Fca.Require.fs.writeFileSync(process.cwd() + "/FastConfigFca.json", JSON.stringify(FastConfig_Global, null, "\t"));
|
199
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Type: 'Noti', Action: e}));
|
200
|
+
// }
|
201
|
+
// };
|
202
|
+
// return SetConfig(message.Data.Name, message.Data.Value, message.Data.Path, message.Data.Main_Path);
|
203
|
+
// }
|
204
|
+
// case "All_logs": {
|
205
|
+
// return Ws_Client.Websocket.send(JSON.stringify({ Type: "Console", Data: console.history.join(" <br> ")}));
|
206
|
+
// }
|
207
|
+
// }
|
208
|
+
// }
|
209
|
+
// }
|
210
|
+
// });
|
211
|
+
// });
|
212
|
+
// return { Client: global.ws.client, WSS: WebSocket };
|
213
213
|
// };
|