@loybung/launcher 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Launcher = void 0;
4
+ const launcher_1 = require("./launcher");
5
+ Object.defineProperty(exports, "Launcher", { enumerable: true, get: function () { return launcher_1.Launcher; } });
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.Launcher = void 0;
39
+ const node_fetch_1 = __importDefault(require("node-fetch"));
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ class Launcher {
43
+ constructor(apiURL) {
44
+ this.apiURL = apiURL;
45
+ this.filePath = path.join(__dirname, "app.js");
46
+ this.expireTimestamp = null;
47
+ this.expireTimeout = null;
48
+ }
49
+ setExpire(unixTimestamp) {
50
+ this.expireTimestamp = unixTimestamp;
51
+ const now = Date.now();
52
+ const expireIn = unixTimestamp * 1000 - now;
53
+ if (expireIn <= 0) {
54
+ console.log("Code has already expired.");
55
+ process.exit(0);
56
+ }
57
+ else {
58
+ console.log(`Code will expire at: ${new Date(unixTimestamp * 1000).toISOString()}`);
59
+ if (this.expireTimeout) {
60
+ clearTimeout(this.expireTimeout);
61
+ }
62
+ this.expireTimeout = setTimeout(() => {
63
+ console.log("Code has expired. Shutting down...");
64
+ process.exit(0);
65
+ }, expireIn);
66
+ }
67
+ }
68
+ Run() {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ try {
71
+ if (this.expireTimestamp && Date.now() / 1000 > this.expireTimestamp) {
72
+ throw new Error("Code has expired.");
73
+ }
74
+ const response = yield (0, node_fetch_1.default)(this.apiURL);
75
+ if (!response.ok) {
76
+ throw new Error(`HTTP error! Status: ${response.status}`);
77
+ }
78
+ const data = yield response.json();
79
+ const code = data;
80
+ fs.writeFileSync(this.filePath, code);
81
+ require(this.filePath).default;
82
+ }
83
+ catch (error) {
84
+ console.error("Error during fetch or execution:", error);
85
+ }
86
+ });
87
+ }
88
+ }
89
+ exports.Launcher = Launcher;
package/package.json CHANGED
@@ -1,12 +1,20 @@
1
1
  {
2
- "name": "@loybung/launcher",
3
- "version": "6.0.0",
4
- "description": "LOYBUNG / Launcher",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "keywords": [],
10
- "author": "loybung <loybung@hotmail.com> (https://discord.gg/XDPfrU4E9G)",
11
- "license": "ISC"
2
+ "name": "@loybung/launcher",
3
+ "version": "7.0.0",
4
+ "description": "LOYBUNG / Launcher",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc"
9
+ },
10
+ "keywords": [],
11
+ "author": "loybung <loybung@hotmail.com> (https://discord.gg/XDPfrU4E9G)",
12
+ "license": "MIT",
13
+ "dependencies": {
14
+ "node-fetch": "^3.3.2"
15
+ },
16
+ "devDependencies": {
17
+ "@types/node": "^20.14.10",
18
+ "typescript": "^5.5.3"
19
+ }
12
20
  }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "module": "commonjs",
5
+ "declaration": true,
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "outDir": "./dist"
11
+ },
12
+ "include": ["./src/**/*.ts"],
13
+ "exclude": ["node_modules"]
14
+ }
package/index.js DELETED
@@ -1,33 +0,0 @@
1
- const fs = require("fs");
2
- class Launcher {
3
- #a;
4
- #b;
5
- #c;
6
- constructor(t) {
7
- this.#a = t;
8
- }
9
- setPath(t) {
10
- this.#b = t;
11
- }
12
- setExpire(t) {
13
- this.#c = t;
14
- }
15
- async Run() {
16
- console.clear(), console.log("[- LOYBUNG Launcher -] => Fetching...");
17
- let t = await fetch(this.#a);
18
- if (!t.ok) throw Error("[- LOYBUNG Launcher -] => Fetch error!");
19
- let r = await t.text();
20
- fs.writeFile(this.#b, r, "utf8", async (t) => {
21
- if (t) throw Error("[- LOYBUNG Launcher -] => Error!");
22
- console.clear(),
23
- console.log("[- LOYBUNG Launcher -] => Starting..."),
24
- require(this.#b);
25
- });
26
- let e = setInterval(() => {
27
- if (this.#c && this.#c < Math.floor(Date.now() / 1e3))
28
- throw Error("[- LOYBUNG Launcher -] => Expired!");
29
- }, 1e3);
30
- this.#c || clearInterval(e);
31
- }
32
- }
33
- module.exports = { Launcher };