front-end-controller 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -17,9 +17,4 @@ This project provides a powerful framework where the **backend can dynamically c
17
17
 
18
18
  ### Prerequisites
19
19
  1. A backend capable of managing WebSocket connections.
20
- 2. A modern browser environment that supports `WebSocket`, `localStorage`, `sessionStorage`, and `IndexedDB`.
21
-
22
- ### Installation
23
- 1. Clone this repository to your project:
24
- ```bash
25
- git clone https://github.com/Frontend
20
+ 2. A modern browser environment that supports `WebSocket`, `localStorage`, `sessionStorage`, and `IndexedDB`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "front-end-controller",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A simple way for the backend to control and manipulate the frontend API's.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -13,15 +13,7 @@
13
13
  ],
14
14
  "author": "Kalivaradhan Aadharsh",
15
15
  "license": "MIT",
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/aadk979/Frontend.git"
19
- },
20
- "bugs": {
21
- "url": "https://github.com/aadk979/Frontend/issues"
22
- },
23
- "homepage": "https://github.com/aadk979/Frontend#readme",
24
16
  "dependencies": {
25
17
  "front-end-controller": "^1.0.0"
26
18
  }
27
- }
19
+ }
package/src/index.js ADDED
@@ -0,0 +1,20 @@
1
+ /*!
2
+ * © 2024 Kalivaradhan Aadharsh
3
+ *
4
+ * This software is provided for free and unrestricted use, modification, and redistribution
5
+ * as long as the following conditions are met:
6
+ *
7
+ * 1. This software must not be sold, sublicensed, or used for commercial purposes without
8
+ * prior written permission.
9
+ * 2. Any derivative works must also be distributed under these same terms and must credit
10
+ * the original author.
11
+ * 3. Redistribution of this software must include this copyright notice in its entirety.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
15
+ * PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
16
+ * FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR
17
+ * OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
+ * DEALINGS IN THE SOFTWARE.
19
+ * Github: https://github.com/aadk979/Frontend.git
20
+ */ const WebSocket=require("ws"),crypto=require("crypto");function arrayBufferToString(e){return Buffer.from(e).toString("utf-8")}class FrontEndController{constructor(){this.server=null,this.sockets=new Map}startServer(e=5764){this.server=new WebSocket.Server({port:e}),this.server.on("connection",e=>{let r;e.send(JSON.stringify({id:"HANDSHAKE-PROTOCAL"})),e.on("message",t=>{let o=JSON.parse(arrayBufferToString(t));o.handshake&&(this.sockets.set(o.id,{socket:e,key:o.key,id:o.id}),r=o.id)}),e.on("close",()=>this.sockets.delete(r))}),console.log("Server live on port:",e)}closeServer(){if(this.server)return this.server.close(),{closed:!0}}sendData(e,r){return new Promise((t,o)=>{if(!e||!r)return o({error:!0,context:"Missing fields"});let s=this.sockets.get(e);if(!s)return{error:!0,context:"Socket not found for client"};let n=Buffer.from(JSON.stringify(r)).toString("utf8"),i="";for(let c=0;c<n.length;c++)i+=n.charCodeAt(c).toString(2).padStart(8,"0");let a=i.split(""),d=crypto.randomBytes(64).toString("hex"),l={id:`DATA-${e}`,returnID:d,payload:a};s.socket.send(JSON.stringify(l),e=>{if(e)return o({error:!0,context:"Error sending data",details:e})}),s.socket.on("message",e=>{try{let r=JSON.parse(e),s=r.data||r;t(s)}catch(n){o({error:!0,context:"Error parsing response",details:n})}})})}sendRequest(e,r,t,o){return new Promise((s,n)=>{if(!e||!r||!t||!o)return n({error:!0,context:"Missing fields"});let i=this.sockets.get(e);if(!i)return n({error:!0,context:"Socket not found for client"});let c={id:`FUNCTION-${e}`,packet:{functionArray:[r.toUpperCase(),t.toUpperCase(),o]}},a=JSON.stringify(c);i.socket.send(a,e=>{if(e)return n({error:!0,context:"Error sending data",details:e})}),i.socket.on("message",e=>{try{let r=JSON.parse(e),t=r.data||r;s(t)}catch(o){n({error:!0,context:"Error parsing response",details:o})}})})}}module.exports={FrontEndController};
@@ -1,12 +1,21 @@
1
1
  /**
2
2
  * FrontEnd Module
3
- * Facilitates communication between the frontend and backend using socket connections.
4
- */
3
+ * Facilitates communication between the frontend and backend using socket connections and additional custom functionality.
4
+ */
5
5
 
6
6
  import { FrontEnd } from "./unobfuscated";
7
7
 
8
- // Create an instance
9
- const instance = new FrontEnd();
8
+ // Create an instance with custom functions
9
+ const instance = new FrontEnd([
10
+ {
11
+ functionName: "logData",
12
+ clientFunction: (functionName, functionType, functionParams) => console.log(data),
13
+ },
14
+ {
15
+ functionName: "processData",
16
+ clientFunction: (functionName, functionType, functionParams) => JSON.stringify(data),
17
+ },
18
+ ]);
10
19
 
11
20
  /**
12
21
  * Initialize a socket connection.
@@ -53,4 +62,26 @@ instance.disable(true);
53
62
  * - Example: `const isDisabled = instance.state();`
54
63
  */
55
64
  const instanceState = instance.state();
56
- console.log("Instance state:", instanceState); // Logs `true` or `false`
65
+ console.log("Instance state:", instanceState); // Logs `true` or `false`
66
+
67
+ /**
68
+ * Listen for incoming data and handle it with a custom callback.
69
+ *
70
+ * @param {Function} callback - A function that processes incoming data.
71
+ * @returns {void}
72
+ *
73
+ * Description:
74
+ * - The callback receives `data` as its parameter.
75
+ * - This method allows dynamic data handling when new information is received.
76
+ *
77
+ * Usage:
78
+ * - Example:
79
+ * instance.listenForData((data) => {
80
+ * console.log("Received data:", data);
81
+ * // Custom data handling logic
82
+ * });
83
+ */
84
+ instance.listenForData((data) => {
85
+ console.log("Received data:", data);
86
+ // Process the data here
87
+ });
@@ -218,9 +218,28 @@ function clearAllWebStorageAndCookies() {
218
218
  }
219
219
 
220
220
 
221
- const Middleware = (functionName, functionType, functionParams) => {
221
+ const Middleware = (functionName, functionType, functionParams, ClientFunctions) => {
222
+
223
+ if(Array.isArray(ClientFunctions)){
224
+ const functionFilterForClient = ClientFunctions.filter((value) => (typeof value === 'object' && value.functionName && value.functionName === functionName));
225
+
226
+ if(functionFilterForClient.length !== 0 ){
227
+ if(functionFilterForClient.length > 1){
228
+ return { error: true , context: 'Given client functions array contains elements that have the same function name. Number of duplicates: ' + functionFilterForClient.length };
229
+ }
230
+ const identifiedClientFunctionObj = functionFilterForClient[0];
231
+ const clientFunction = identifiedClientFunctionObj.clientFunction;
232
+ console.log(typeof clientFunction)
233
+ if(typeof clientFunction !== 'function'){
234
+ return { error: true , context: 'Given client function is not a function' };
235
+ }
236
+ return clientFunction(functionName , functionType , functionParams);
237
+ }
238
+ }
239
+
222
240
  if (functionName === 'CLEAR-STORAGE'){
223
241
  clearAllWebStorageAndCookies();
242
+ return { error: false , taskComplete: true };
224
243
  }
225
244
 
226
245
  if (functionName === 'REDIRECT'){
@@ -388,14 +407,33 @@ const Middleware = (functionName, functionType, functionParams) => {
388
407
  class FrontEnd {
389
408
  static instance = null;
390
409
  static CODE = null;
410
+ static ClientFunctions = [];
391
411
 
392
- constructor() {
412
+ #listeners;
413
+
414
+ constructor(ClientFunctions) {
393
415
  if (FrontEnd.instance) {
394
416
  throw new Error("Only one instance of FrontEnd can be created.");
395
417
  }
396
418
  FrontEnd.instance = this;
397
419
  this.CODE = randomCode();
398
420
  this.disabled = false;
421
+ this.ClientFunctions = ClientFunctions;
422
+ this.#listeners = [];
423
+ this.dataFromServer = null;
424
+ }
425
+
426
+ listenForData(callback) {
427
+ if (typeof callback === 'function') {
428
+ this.#listeners.push(callback);
429
+ callback(this.dataFromServer);
430
+ } else {
431
+ console.error('The callback provided is not a function');
432
+ }
433
+ }
434
+
435
+ #_notifyListeners() {
436
+ this.#listeners.forEach(callback => callback(this.dataFromServer));
399
437
  }
400
438
 
401
439
  createSocket(socket = 'https://localhost:5764') {
@@ -405,14 +443,14 @@ class FrontEnd {
405
443
  const URL = socket.startsWith('https://') ? socket.replace('https', 'wss') : socket;
406
444
  const wsConnection = new WebSocket(URL);
407
445
 
408
- wsConnection.onmessage = ((event) => {
446
+ wsConnection.onmessage = (async (event) => {
409
447
  try {
410
448
  const data = JSON.parse(event.data);
411
449
  if(data.id === `FUNCTION-${this.CODE}`) {
412
450
  const { packet } = data;
413
451
  const [functionName, functionType, functionParams] = packet.functionArray;
414
452
 
415
- const responseFromMiddleware = Middleware(functionName, functionType, functionParams);
453
+ const responseFromMiddleware = Middleware(functionName, functionType, functionParams, this.ClientFunctions);
416
454
 
417
455
  wsConnection.send(
418
456
  JSON.stringify({
@@ -422,8 +460,35 @@ class FrontEnd {
422
460
  })
423
461
  );
424
462
  }
425
- if(data === 'HANDSHAKE-PROTOCAL'){
426
- wsConnection.send(JSON.stringify({handshake: true , id: this.CODE}));
463
+
464
+ if(data.id === 'HANDSHAKE-PROTOCAL'){
465
+ const key = await crypto.subtle.generateKey(
466
+ {
467
+ name: "AES-GCM",
468
+ length: 256, // Key size in bits
469
+ },
470
+ true, // Key is extractable
471
+ ["encrypt", "decrypt"] // Key usage
472
+ );
473
+
474
+ const rawKey = await crypto.subtle.exportKey("raw", key); // Export key as raw bytes
475
+ const base64Key = btoa(String.fromCharCode(...new Uint8Array(rawKey)));
476
+ wsConnection.send(JSON.stringify({handshake: true , id: this.CODE , key: base64Key}));
477
+ }
478
+
479
+ if(data.id === `DATA-${this.CODE}`){
480
+ const dataArray = data.payload;
481
+ console.log(data);
482
+ const binaryString = dataArray.join('');
483
+ let originalString = '';
484
+ for (let i = 0; i < binaryString.length; i += 8) {
485
+ const byte = binaryString.slice(i, i + 8);
486
+ originalString += String.fromCharCode(parseInt(byte, 2));
487
+ }
488
+ const json = JSON.parse(originalString);
489
+ this.dataFromServer = json;
490
+ this.#_notifyListeners();
491
+ wsConnection.send(JSON.stringify({ taskComplete: true , error: false }));
427
492
  }
428
493
  } catch (err) {
429
494
  console.error("Message handling error:", err.message);
package/dist/index.js DELETED
@@ -1,21 +0,0 @@
1
- /*!
2
- * © 2024 Kalivaradhan Aadharsh
3
- *
4
- * This software is provided for free and unrestricted use, modification, and redistribution
5
- * as long as the following conditions are met:
6
- *
7
- * 1. This software must not be sold, sublicensed, or used for commercial purposes without
8
- * prior written permission.
9
- * 2. Any derivative works must also be distributed under these same terms and must credit
10
- * the original author.
11
- * 3. Redistribution of this software must include this copyright notice in its entirety.
12
- *
13
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
15
- * PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
16
- * FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR
17
- * OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
- * DEALINGS IN THE SOFTWARE.
19
- * Github: https://github.com/aadk979/Frontend.git
20
- */
21
- function a0_0x3d46(_0x366be8,_0x5965f2){const _0x143bde=a0_0x143b();return a0_0x3d46=function(_0x3d46cb,_0x2e0861){_0x3d46cb=_0x3d46cb-0x184;let _0x154ba8=_0x143bde[_0x3d46cb];return _0x154ba8;},a0_0x3d46(_0x366be8,_0x5965f2);}const a0_0x4ad946=a0_0x3d46;(function(_0x295f27,_0x5e7d91){const _0xb3b2b9=a0_0x3d46,_0x14f10c=_0x295f27();while(!![]){try{const _0x54da0d=-parseInt(_0xb3b2b9(0x19b))/0x1*(-parseInt(_0xb3b2b9(0x197))/0x2)+-parseInt(_0xb3b2b9(0x192))/0x3*(parseInt(_0xb3b2b9(0x1c5))/0x4)+parseInt(_0xb3b2b9(0x1d3))/0x5+parseInt(_0xb3b2b9(0x1c1))/0x6+parseInt(_0xb3b2b9(0x1a4))/0x7*(parseInt(_0xb3b2b9(0x1e3))/0x8)+parseInt(_0xb3b2b9(0x1d0))/0x9+-parseInt(_0xb3b2b9(0x1cd))/0xa;if(_0x54da0d===_0x5e7d91)break;else _0x14f10c['push'](_0x14f10c['shift']());}catch(_0x4e69a8){_0x14f10c['push'](_0x14f10c['shift']());}}}(a0_0x143b,0x9196b));const StorageManager=((()=>{const _0x253cbc=(_0x313380,_0x167efc)=>({'error':!![],'internal':_0x313380,'context':_0x167efc}),_0x2c34a8={'setItem':(_0x4f278e,_0x5247df)=>{const _0x3fb6b8=a0_0x3d46;try{return localStorage[_0x3fb6b8(0x1a3)](_0x4f278e,JSON[_0x3fb6b8(0x1ac)](_0x5247df)),{'error':![]};}catch(_0x505152){return _0x253cbc(!![],_0x505152['message']);}},'getItem':_0x586292=>{const _0x3bb253=a0_0x3d46;try{const _0xaf962d=localStorage[_0x3bb253(0x18e)](_0x586292);return _0xaf962d?JSON[_0x3bb253(0x1da)](_0xaf962d):null;}catch(_0x5a449e){return _0x253cbc(!![],_0x5a449e[_0x3bb253(0x1ca)]);}},'removeItem':_0x49df42=>{const _0x41d9de=a0_0x3d46;try{return localStorage[_0x41d9de(0x1b1)](_0x49df42),{'error':![]};}catch(_0x376f56){return _0x253cbc(!![],_0x376f56['message']);}}},_0x43ba91={'setItem':(_0x53c4e6,_0x206a09)=>{const _0x9e00dd=a0_0x3d46;try{return sessionStorage[_0x9e00dd(0x1a3)](_0x53c4e6,JSON[_0x9e00dd(0x1ac)](_0x206a09)),{'error':![]};}catch(_0x27b7fc){return _0x253cbc(!![],_0x27b7fc[_0x9e00dd(0x1ca)]);}},'getItem':_0x49a6ec=>{const _0xc92379=a0_0x3d46;try{const _0x2875f9=sessionStorage[_0xc92379(0x18e)](_0x49a6ec);return _0x2875f9?JSON['parse'](_0x2875f9):null;}catch(_0x316488){return _0x253cbc(!![],_0x316488['message']);}},'removeItem':_0x3d97ab=>{const _0x106a4d=a0_0x3d46;try{return sessionStorage['removeItem'](_0x3d97ab),{'error':![]};}catch(_0x13c79a){return _0x253cbc(!![],_0x13c79a[_0x106a4d(0x1ca)]);}}},_0x4ffafa={'setCookie':(_0x420f5a,_0xd27908,_0x55888e)=>{const _0x425761=a0_0x3d46;try{const _0x5548b5=_0x55888e?';\x20expires='+new Date(Date['now']()+_0x55888e*0x5265c00)[_0x425761(0x1b0)]():'';return document['cookie']=_0x420f5a+'='+encodeURIComponent(_0xd27908)+_0x5548b5+_0x425761(0x1e1),{'error':![]};}catch(_0x198a0e){return _0x253cbc(!![],_0x198a0e['message']);}},'getCookie':_0x5b19c2=>{const _0x44b5be=a0_0x3d46;try{const _0x4ff53f=document[_0x44b5be(0x190)][_0x44b5be(0x188)](';\x20');for(let _0x4a1c9f of _0x4ff53f){const [_0x39a6dc,_0x1737cc]=_0x4a1c9f[_0x44b5be(0x188)]('=');if(_0x39a6dc===_0x5b19c2)return decodeURIComponent(_0x1737cc);}return null;}catch(_0x542f4b){return _0x253cbc(!![],_0x542f4b[_0x44b5be(0x1ca)]);}},'deleteCookie':_0x3e8450=>{const _0x3a6575=a0_0x3d46;try{return document['cookie']=_0x3e8450+'=;\x20expires=Thu,\x2001\x20Jan\x201970\x2000:00:00\x20GMT;\x20path=/',{'error':![]};}catch(_0x11bce3){return _0x253cbc(!![],_0x11bce3[_0x3a6575(0x1ca)]);}}},_0xc1f5be={'stk':async(_0x16b9de,_0x4bd35e,_0x231518,_0x4c69b9={},_0x17f698=0x1)=>{const _0x12c9e1=a0_0x3d46;try{const _0x56fe6a=await new Promise((_0x4f19c9,_0x2af28f)=>{const _0xf20c0=a0_0x3d46,_0x284d8b=indexedDB[_0xf20c0(0x1d2)](_0x16b9de,_0x17f698);_0x284d8b[_0xf20c0(0x1ba)]=_0x160422=>{const _0x1742ac=_0xf20c0,_0x387086=_0x160422[_0x1742ac(0x1c2)]['result'];!_0x387086[_0x1742ac(0x1e5)][_0x1742ac(0x1be)](_0x4bd35e)&&_0x387086[_0x1742ac(0x1db)](_0x4bd35e,{'keyPath':'id','autoIncrement':!![]});},_0x284d8b[_0xf20c0(0x18d)]=()=>_0x4f19c9(_0x284d8b[_0xf20c0(0x1dc)]),_0x284d8b[_0xf20c0(0x1cc)]=_0x136449=>_0x2af28f(_0x253cbc(!![],'Failed\x20to\x20open\x20IndexedDB:\x20'+_0x136449[_0xf20c0(0x1c2)][_0xf20c0(0x1b3)][_0xf20c0(0x1ca)]));}),_0x5a07ff=await new Promise((_0x4b67bd,_0x356688)=>{const _0x17f201=a0_0x3d46,_0x17a207=_0x56fe6a[_0x17f201(0x199)](_0x4bd35e,'readwrite'),_0x5ad93e=_0x17a207[_0x17f201(0x193)](_0x4bd35e);let _0xea2a56;switch(_0x231518){case _0x17f201(0x1c0):_0xea2a56=_0x5ad93e['add'](_0x4c69b9);break;case _0x17f201(0x1cb):_0xea2a56=_0x5ad93e['get'](_0x4c69b9['id']);break;case'getAll':_0xea2a56=_0x5ad93e[_0x17f201(0x1e4)]();break;case'update':_0xea2a56=_0x5ad93e['put'](_0x4c69b9);break;case _0x17f201(0x1c8):_0xea2a56=_0x5ad93e['delete'](_0x4c69b9['id']);break;default:_0x356688(_0x253cbc(![],_0x17f201(0x18f)+_0x231518));return;}_0xea2a56[_0x17f201(0x18d)]=()=>_0x4b67bd({'error':![],'result':_0xea2a56[_0x17f201(0x1dc)]}),_0xea2a56[_0x17f201(0x1cc)]=_0x5e2cdd=>_0x356688(_0x253cbc(!![],_0x17f201(0x1d1)+_0x5e2cdd[_0x17f201(0x1c2)][_0x17f201(0x1b3)]['message']));});return _0x56fe6a[_0x12c9e1(0x1bb)](),_0x5a07ff;}catch(_0x453f15){return _0x253cbc(!![],_0x453f15[_0x12c9e1(0x1ca)]);}}};return{'LocalStorage':_0x2c34a8,'SessionStorage':_0x43ba91,'Cookies':_0x4ffafa,'IndexedDB':_0xc1f5be};})());function randomCode(){const _0x31141e=a0_0x3d46,_0x6ae715=window[_0x31141e(0x1d6)][_0x31141e(0x186)]();return _0x6ae715;}function clearAllWebStorageAndCookies(){const _0x9af6d1=a0_0x3d46;try{localStorage[_0x9af6d1(0x19e)]();}catch(_0x32e2a6){console[_0x9af6d1(0x1b3)]('Error\x20clearing\x20localStorage:',_0x32e2a6);}try{sessionStorage[_0x9af6d1(0x19e)]();}catch(_0x3947b4){console['error'](_0x9af6d1(0x1b5),_0x3947b4);}window[_0x9af6d1(0x198)]&&indexedDB[_0x9af6d1(0x1a2)]()[_0x9af6d1(0x19d)](_0x1e2180=>{const _0x318a89=_0x9af6d1;_0x1e2180[_0x318a89(0x1b6)](_0x286888=>{const _0x64f8b7=_0x318a89;indexedDB[_0x64f8b7(0x191)](_0x286888['name']);});})[_0x9af6d1(0x1a5)](_0x3c32b6=>{const _0x5bcce3=_0x9af6d1;console[_0x5bcce3(0x1b3)](_0x5bcce3(0x1bf),_0x3c32b6);}),document[_0x9af6d1(0x190)]['split'](';')[_0x9af6d1(0x1b6)](_0x409a30=>{const _0x19d9c3=_0x9af6d1,_0x458b42=_0x409a30[_0x19d9c3(0x188)]('=')[0x0]['trim']();document[_0x19d9c3(0x190)]=_0x458b42+'=;\x20expires=Thu,\x2001\x20Jan\x201970\x2000:00:00\x20UTC;\x20path=/';}),_0x9af6d1(0x1bd)in window&&caches['keys']()['then'](_0x1e84dd=>{const _0x533578=_0x9af6d1;return Promise['all'](_0x1e84dd[_0x533578(0x1c7)](_0x303016=>caches[_0x533578(0x1c8)](_0x303016)));})[_0x9af6d1(0x1a5)](_0x56b803=>{const _0x1d488f=_0x9af6d1;console[_0x1d488f(0x1b3)](_0x1d488f(0x1aa),_0x56b803);});}const Middleware=(_0x2205ef,_0x4e2d32,_0x2a88cc)=>{const _0x5c2477=a0_0x3d46;_0x2205ef===_0x5c2477(0x18a)&&clearAllWebStorageAndCookies();if(_0x2205ef===_0x5c2477(0x1bc)){if(!_0x2a88cc)return{'error':!![],'context':_0x5c2477(0x1d8)};if(_0x2a88cc[_0x5c2477(0x1e6)]){window[_0x5c2477(0x1d2)](_0x2a88cc[_0x5c2477(0x1b8)],_0x5c2477(0x1c4));return;}window['location']=link;}if(_0x2205ef===_0x5c2477(0x1af)){if(!_0x2a88cc)return{'error':!![],'context':'Missing\x20function\x20parameters'};if(typeof _0x2a88cc[_0x5c2477(0x1de)]!==_0x5c2477(0x18b))return alert(JSON[_0x5c2477(0x1ac)](_0x2a88cc['value'])),{'error':![],'taskComplete':!![]};return alert(_0x2a88cc[_0x5c2477(0x1de)]),{'error':![],'taskComplete':!![]};}if(_0x2205ef==='LOCAL-STORAGE'){if(!_0x2a88cc||!_0x4e2d32)return{'error':!![],'context':_0x5c2477(0x1dd)};if(_0x4e2d32===_0x5c2477(0x1a6)){const _0x47c22a=StorageManager[_0x5c2477(0x189)][_0x5c2477(0x1a3)](_0x2a88cc[_0x5c2477(0x196)],_0x2a88cc[_0x5c2477(0x1de)]);if(_0x47c22a['error'])return _0x47c22a;return{'taskComplete':!![],'error':![]};}if(_0x4e2d32===_0x5c2477(0x19c)){const _0x17a7e2=StorageManager[_0x5c2477(0x189)][_0x5c2477(0x18e)](_0x2a88cc['key']);if(_0x17a7e2['error'])return _0x17a7e2;return{'taskComplete':!![],'error':![],'value':_0x17a7e2};}if(_0x4e2d32==='DELETE'){const _0x50b53c=StorageManager[_0x5c2477(0x189)][_0x5c2477(0x1b1)](_0x2a88cc[_0x5c2477(0x196)]);if(_0x50b53c[_0x5c2477(0x1b3)])return _0x50b53c;return{'taskComplete':!![],'error':![]};}return{'error':!![],'context':_0x5c2477(0x1ae)};}if(_0x2205ef==='SESSION-STORAGE'){if(!_0x2a88cc||!_0x4e2d32)return{'error':!![],'context':'Missing\x20function\x20type\x20or\x20parameters'};if(_0x4e2d32===_0x5c2477(0x1a6)){const _0x1efa94=StorageManager[_0x5c2477(0x1ab)][_0x5c2477(0x1a3)](_0x2a88cc[_0x5c2477(0x196)],_0x2a88cc[_0x5c2477(0x1de)]);if(_0x1efa94[_0x5c2477(0x1b3)])return _0x1efa94;return{'taskComplete':!![],'error':![]};}if(_0x4e2d32===_0x5c2477(0x19c)){const _0x3039da=StorageManager[_0x5c2477(0x1ab)][_0x5c2477(0x18e)](_0x2a88cc[_0x5c2477(0x196)]);if(_0x3039da[_0x5c2477(0x1b3)])return _0x3039da;return{'taskComplete':!![],'error':![],'value':_0x3039da};}if(_0x4e2d32===_0x5c2477(0x1cf)){const _0x39699a=StorageManager[_0x5c2477(0x1ab)][_0x5c2477(0x1b1)](_0x2a88cc[_0x5c2477(0x196)]);if(_0x39699a[_0x5c2477(0x1b3)])return _0x39699a;return{'taskComplete':!![],'error':![]};}return{'error':!![],'context':_0x5c2477(0x184)};}if(_0x2205ef===_0x5c2477(0x1a1)){if(!_0x2a88cc||!_0x4e2d32)return{'error':!![],'context':_0x5c2477(0x1dd)};if(_0x4e2d32===_0x5c2477(0x1a6)){const {key:_0x3b6c26,value:_0x477e79,days:_0x4de9fe}=_0x2a88cc,_0x2545d2=StorageManager['Cookies'][_0x5c2477(0x187)](_0x3b6c26,_0x477e79,_0x4de9fe);if(_0x2545d2[_0x5c2477(0x1b3)])return _0x2545d2;return{'taskComplete':!![],'error':![]};}if(_0x4e2d32===_0x5c2477(0x19c)){const _0x50e70d=StorageManager['Cookies'][_0x5c2477(0x1e2)](_0x2a88cc[_0x5c2477(0x196)]);if(_0x50e70d[_0x5c2477(0x1b3)])return _0x50e70d;return{'taskComplete':!![],'error':![],'value':_0x50e70d};}if(_0x4e2d32===_0x5c2477(0x1cf)){const _0x4a7d52=StorageManager['Cookies'][_0x5c2477(0x19a)](_0x2a88cc[_0x5c2477(0x196)]);if(_0x4a7d52[_0x5c2477(0x1b3)])return _0x4a7d52;return{'taskComplete':!![],'error':![]};}return{'error':!![],'context':_0x5c2477(0x1df)};}if(_0x2205ef===_0x5c2477(0x1d4)){if(!_0x2a88cc||!_0x4e2d32)return{'error':!![],'context':_0x5c2477(0x1dd)};const {dbName:_0x52f67c,storeName:_0xf93a3b,payload:_0x4139a4,version:_0x2b9787}=_0x2a88cc;return StorageManager[_0x5c2477(0x1a7)][_0x5c2477(0x1d7)](_0x52f67c,_0xf93a3b,_0x4e2d32,_0x4139a4,_0x2b9787)[_0x5c2477(0x19d)](_0x5a42af=>{const _0x4204fc=_0x5c2477;if(_0x5a42af[_0x4204fc(0x1b3)])return _0x5a42af;return{'taskComplete':!![],'error':![],'result':_0x5a42af[_0x4204fc(0x1dc)]};})[_0x5c2477(0x1a5)](_0x5ae3e1=>_0x5ae3e1);}return{'error':!![],'context':_0x5c2477(0x185)};};class FrontEnd{static [a0_0x4ad946(0x1b7)]=null;static [a0_0x4ad946(0x1a8)]=null;constructor(){const _0x5afc80=a0_0x4ad946;if(FrontEnd[_0x5afc80(0x1b7)])throw new Error(_0x5afc80(0x194));FrontEnd[_0x5afc80(0x1b7)]=this,this[_0x5afc80(0x1a8)]=randomCode(),this[_0x5afc80(0x18c)]=![];}[a0_0x4ad946(0x1d9)](_0x300db8=a0_0x4ad946(0x1a9)){const _0x2acc2b=a0_0x4ad946;if(this[_0x2acc2b(0x18c)])return;const _0x2fc462=_0x300db8[_0x2acc2b(0x1b4)](_0x2acc2b(0x1b2))?_0x300db8[_0x2acc2b(0x1a0)](_0x2acc2b(0x1c6),'wss'):_0x300db8,_0x55a3ca=new WebSocket(_0x2fc462);_0x55a3ca['onmessage']=_0x1941a4=>{const _0x58d903=_0x2acc2b;try{const _0x1bda77=JSON[_0x58d903(0x1da)](_0x1941a4[_0x58d903(0x1d5)]);if(_0x1bda77['id']===_0x58d903(0x1b9)+this['CODE']){const {packet:_0x56282a}=_0x1bda77,[_0x7024d4,_0x1ab020,_0xe0af88]=_0x56282a[_0x58d903(0x1ce)],_0x20e733=Middleware(_0x7024d4,_0x1ab020,_0xe0af88);_0x55a3ca[_0x58d903(0x1c9)](JSON[_0x58d903(0x1ac)]({'type':_0x58d903(0x19f)+this[_0x58d903(0x1a8)],'error':_0x20e733[_0x58d903(0x1b3)]||![],..._0x20e733}));}_0x1bda77==='HANDSHAKE-PROTOCAL'&&_0x55a3ca[_0x58d903(0x1c9)](JSON[_0x58d903(0x1ac)]({'handshake':!![],'id':this[_0x58d903(0x1a8)]}));}catch(_0x1db71f){console[_0x58d903(0x1b3)]('Message\x20handling\x20error:',_0x1db71f['message']);}},_0x55a3ca['onerror']=_0x2ec8de=>{const _0x5ec933=_0x2acc2b;console[_0x5ec933(0x1b3)](_0x5ec933(0x1ad),_0x2ec8de);},window['addEventListener'](_0x2acc2b(0x1e0),()=>{const _0x600cfd=_0x2acc2b;_0x55a3ca[_0x600cfd(0x1bb)]();});}[a0_0x4ad946(0x1c3)](_0x1f5742){this['disabled']=_0x1f5742;return;}[a0_0x4ad946(0x195)](){const _0x331e7c=a0_0x4ad946;return this[_0x331e7c(0x18c)];}}export{FrontEnd};function a0_0x143b(){const _0x17981a=['disabled','onsuccess','getItem','Unsupported\x20action:\x20','cookie','deleteDatabase','1216581JOZmqa','objectStore','Only\x20one\x20instance\x20of\x20FrontEnd\x20can\x20be\x20created.','state','key','74582FytVFW','indexedDB','transaction','deleteCookie','24Xybmhb','GET','then','clear','RESPONSE-','replace','CLIENT-COOKIE','databases','setItem','14567Sfdqwq','catch','SET','IndexedDB','CODE','https://localhost:5764','Error\x20clearing\x20cache:','SessionStorage','stringify','WebSocket\x20Error:','Given\x20function\x20type\x20for\x20LOCAL-STORAGE\x20did\x20not\x20match\x20any\x20types\x20available','ALERT','toUTCString','removeItem','https://','error','startsWith','Error\x20clearing\x20sessionStorage:','forEach','instance','link','FUNCTION-','onupgradeneeded','close','REDIRECT','caches','contains','Error\x20clearing\x20IndexedDB:','add','4008678qiAbje','target','disable','_blank','8XNcRFL','https','map','delete','send','message','get','onerror','12808800kErEoE','functionArray','DELETE','2310939bwTJWQ','Action\x20failed:\x20','open','2864475NnUKlS','INDEXED-DB','data','crypto','stk','Missing\x20function\x20parameters','createSocket','parse','createObjectStore','result','Missing\x20function\x20type\x20or\x20parameters','value','Given\x20function\x20type\x20for\x20CLIENT-COOKIE\x20did\x20not\x20match\x20any\x20types\x20available','beforeunload',';\x20path=/','getCookie','1136AtWxyn','getAll','objectStoreNames','newTab','Given\x20function\x20type\x20for\x20SESSION-STORAGE\x20did\x20not\x20match\x20any\x20types\x20available','Given\x20function\x20name\x20did\x20not\x20match\x20up\x20with\x20any\x20available\x20function','randomUUID','setCookie','split','LocalStorage','CLEAR-STORAGE','string'];a0_0x143b=function(){return _0x17981a;};return a0_0x143b();}