xynginc 1.0.83 → 1.0.85

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.
@@ -1,9 +1,9 @@
1
1
  import { Logger } from "./logger";
2
2
  import * as https from "https";
3
- import * as fs from "fs";
4
- import * as path from "path";
5
- import * as os from "os";
6
3
  import { BINARY_NAME, BINARY_DIR, GITHUB_REPO } from "./constant";
4
+ import { __strl__ } from "strulink";
5
+ const fs = __sys__.fs;
6
+ const path = __sys__.path;
7
7
  /**
8
8
  * Downloads the xynginc binary from GitHub releases.
9
9
  *
@@ -11,8 +11,8 @@ import { BINARY_NAME, BINARY_DIR, GITHUB_REPO } from "./constant";
11
11
  * @returns The path to the downloaded binary.
12
12
  */
13
13
  export async function downloadBinary(version) {
14
- const platform = os.platform();
15
- const arch = os.arch();
14
+ const platform = __sys__.os.platform();
15
+ const arch = __sys__.os.arch();
16
16
  if (platform !== "linux") {
17
17
  throw new Error(`[XyNginC] Unsupported platform: ${platform}. Only Linux is supported.`);
18
18
  }
@@ -20,11 +20,9 @@ export async function downloadBinary(version) {
20
20
  const downloadUrl = version === "latest"
21
21
  ? `https://github.com/${GITHUB_REPO}/releases/latest/download/${binaryName}`
22
22
  : `https://github.com/${GITHUB_REPO}/releases/download/${version}/${binaryName}`;
23
- Logger.info(`[XyNginC] Downloading from: ${downloadUrl}`);
23
+ Logger.info(`[XyNginC] Downloading from: ${__strl__.createUrl(downloadUrl).hostname}`);
24
24
  // Create bin directory
25
- if (!fs.existsSync(BINARY_DIR)) {
26
- fs.mkdirSync(BINARY_DIR, { recursive: true });
27
- }
25
+ fs.writeIfNotExistsSync(BINARY_DIR, { recursive: true });
28
26
  const localPath = path.join(BINARY_DIR, BINARY_NAME);
29
27
  return new Promise((resolve, reject) => {
30
28
  function download(url) {
@@ -44,15 +42,14 @@ export async function downloadBinary(version) {
44
42
  const file = fs.createWriteStream(localPath);
45
43
  response.pipe(file);
46
44
  file.on("finish", () => {
47
- file.close();
48
- fs.chmodSync(localPath, 0o755); // Make executable
45
+ file.close(); //
46
+ fs.chmod(localPath, "755"); // Make executable (octal version: 0o755)
49
47
  Logger.success("[XyNginC] ✓ Binary downloaded successfully");
50
48
  resolve(localPath);
51
49
  });
52
50
  })
53
51
  .on("error", (err) => {
54
- if (fs.existsSync(localPath))
55
- fs.unlinkSync(localPath);
52
+ fs.rmIfExists(localPath);
56
53
  reject(err);
57
54
  });
58
55
  }
@@ -1,9 +1,9 @@
1
- import fs from "fs";
2
- import path from "path";
3
1
  import { Logger } from "./logger";
4
2
  import { execAsync } from "./execAsync";
5
3
  import { BINARY_DIR, BINARY_NAME } from "./constant";
6
4
  import { downloadBinary } from "./downloadBinary";
5
+ const fs = __sys__.fs;
6
+ const path = __sys__.path;
7
7
  /**
8
8
  * Ensures the xynginc binary exists.
9
9
  * It checks the custom path, the system PATH, and the local bin directory.
@@ -16,14 +16,14 @@ import { downloadBinary } from "./downloadBinary";
16
16
  */
17
17
  export async function ensureBinary(customPath, autoDownload, version) {
18
18
  // 1. Try custom path
19
- if (customPath && fs.existsSync(customPath)) {
19
+ if (customPath && fs.exists(customPath)) {
20
20
  return customPath;
21
21
  }
22
22
  // 2. Try PATH
23
23
  try {
24
24
  const { stdout } = await execAsync("which xynginc");
25
25
  const globalPath = stdout.trim();
26
- if (globalPath && fs.existsSync(globalPath)) {
26
+ if (globalPath && fs.exists(globalPath)) {
27
27
  return globalPath;
28
28
  }
29
29
  }
@@ -32,7 +32,7 @@ export async function ensureBinary(customPath, autoDownload, version) {
32
32
  }
33
33
  // 3. Try local bin directory
34
34
  const localPath = path.join(BINARY_DIR, BINARY_NAME);
35
- if (fs.existsSync(localPath)) {
35
+ if (fs.exists(localPath)) {
36
36
  return localPath;
37
37
  }
38
38
  // 4. Auto-download if enabled
@@ -1,3 +1,5 @@
1
+ import { __strl__ } from "strulink";
2
+ import { Interface } from "reliant-type";
1
3
  /**
2
4
  * Validates the plugin configuration.
3
5
  *
@@ -5,29 +7,47 @@
5
7
  * @throws Error if the configuration is invalid.
6
8
  */
7
9
  export function validateConfig(config) {
8
- if (!config.domains || config.domains.length === 0) {
10
+ const d = config.domains;
11
+ if (!d || d.length === 0) {
9
12
  throw new Error("[XyNginC] Configuration error: 'domains' array cannot be empty");
10
13
  }
11
- for (const domain of config.domains) {
12
- if (!domain.domain || typeof domain.domain !== "string") {
14
+ for (const d2 of d) {
15
+ if (!d2.domain || typeof d2.domain !== "string") {
13
16
  throw new Error("[XyNginC] Configuration error: 'domain' must be a non-empty string");
14
17
  }
15
- if (!domain.port ||
16
- typeof domain.port !== "number" ||
17
- domain.port < 1 ||
18
- domain.port > 65535) {
19
- throw new Error(`[XyNginC] Configuration error: 'port' must be between 1-65535 for ${domain.domain}`);
18
+ const vd = __strl__.checkUrl(d2.domain, { requireProtocol: false });
19
+ if (!vd.isValid) {
20
+ const EDOMAIN = vd?.validationDetails?.domain;
21
+ if (EDOMAIN) {
22
+ console.error("[XYNGINC::STRULINK:EDOMAIN]: ", EDOMAIN);
23
+ throw new Error("[XYNGINC::STRULINK:EDOMAIN]" + vd?.cause);
24
+ }
25
+ throw new Error(vd?.cause);
20
26
  }
21
- if (domain.ssl && !domain.email) {
22
- throw new Error(`[XyNginC] Configuration error: 'email' is required when SSL is enabled for ${domain.domain}`);
27
+ if (!d2.port ||
28
+ typeof d2.port !== "number" ||
29
+ d2.port < 1 ||
30
+ d2.port > 65535) {
31
+ throw new Error(`[XyNginC] Configuration error: 'port' must be between 1-65535 for ${d2.domain}`);
32
+ }
33
+ if (d2.ssl && !d2.email) {
34
+ throw new Error(`[XyNginC] Configuration error: 'email' is required when SSL is enabled for ${d2.domain}`);
35
+ }
36
+ const emailInterface = Interface({
37
+ email: "email",
38
+ });
39
+ const vmail = emailInterface.safeParse({ email: d2.email || "" });
40
+ if (!vmail.success) {
41
+ console.error(vmail.errors.join("\n"));
42
+ throw new Error(`[XyNginC] Configuration error: 'email' is invalid for ${d2.domain}`);
23
43
  }
24
44
  // Set default host to localhost if not provided
25
- if (!domain.host) {
26
- domain.host = "localhost";
45
+ if (!d2.host) {
46
+ d2.host = "localhost";
27
47
  }
28
48
  // Set default maxBodySize if not provided
29
- if (!domain.maxBodySize) {
30
- domain.maxBodySize = "20M";
49
+ if (!d2.maxBodySize) {
50
+ d2.maxBodySize = "20M";
31
51
  }
32
52
  }
33
53
  }
@@ -31,6 +31,11 @@ export async function startXNCPlugin(server, options) {
31
31
  // 1. Ensure binary exists
32
32
  const binary = await ensureBinary(binaryPath, autoDownload, version);
33
33
  Logger.success(`[XyNginC] ✓ Binary located: ${binary}`);
34
+ __sys__.vars.update({
35
+ xynginc: {
36
+ binary,
37
+ },
38
+ });
34
39
  // 2. Check system requirements
35
40
  Logger.info("[XyNginC] Checking system requirements...");
36
41
  // Check if requirements are satisfied
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xynginc",
3
- "version": "1.0.83",
4
- "description": "XyPriss Nginx Controller - Automatic Nginx & SSL management for XyPriss servers",
3
+ "version": "1.0.85",
4
+ "description": "XyPriss Nginx Controller - Automatic Nginx \u0026 SSL management for XyPriss servers",
5
5
  "author": "Seth Eleazar - iDevo",
6
6
  "license": "NOSL",
7
7
  "main": "dist/index.js",
@@ -10,13 +10,14 @@
10
10
  "dist",
11
11
  "scripts",
12
12
  "README.md",
13
- "xypriss.plugin.xsig"
13
+ "xypriss.plugin.xsig",
14
+ "xypriss.config.jsonc"
14
15
  ],
15
16
  "bin": {
16
17
  "xynginc": "./bin/xynginc"
17
18
  },
18
19
  "engines": {
19
- "node": ">=18.0.0"
20
+ "node": "\u003e=18.0.0"
20
21
  },
21
22
  "repository": {
22
23
  "type": "git",
@@ -32,17 +33,19 @@
32
33
  "plugin"
33
34
  ],
34
35
  "scripts": {
35
- "build": "tsc && xfpm run build:multi",
36
- "build:all": "xfpm run build:go && xfpm run build",
37
- "build:go": "cd core-go && go build -o xynginc && cp xynginc ../bin/",
36
+ "build": "tsc \u0026\u0026 xfpm run build:multi",
37
+ "build:all": "xfpm run build:go \u0026\u0026 xfpm run build",
38
+ "build:go": "cd core-go \u0026\u0026 go build -o xynginc \u0026\u0026 cp xynginc ../bin/",
38
39
  "build:multi": "bash scripts/build.sh",
39
40
  "dev": "tsc --watch",
40
41
  "install:manual": "sudo bash scripts/install.sh",
41
42
  "postinstall": "node scripts/postinstall.js",
42
- "prepublishOnly": "xfpm run build && xfpm sign ./ --min-version 1.0.81 --fix"
43
+ "prepublishOnly": "xfpm run build \u0026\u0026 xfpm sign ./ --min-version 1.0.81 --fix"
43
44
  },
44
45
  "dependencies": {
45
- "xypriss": "^9.9.4",
46
+ "reliant-type": "^2.1.5",
47
+ "strulink": "^1.2.0",
48
+ "xypriss": "^9.9.5",
46
49
  "xypriss-security": "^2.1.16"
47
50
  },
48
51
  "devDependencies": {
@@ -55,4 +58,4 @@
55
58
  "XHS.HOOK.LIFECYCLE.SERVER_READY"
56
59
  ]
57
60
  }
58
- }
61
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$internal": {
3
+ "xynginc": {
4
+ "type": "plugin",
5
+ },
6
+ },
7
+ }
@@ -1,11 +1,11 @@
1
1
  --- XYPRISS SIGNATURE (G3) ---
2
- Manifest: xynginc@1.0.83
2
+ Manifest: xynginc@1.0.85
3
3
  Min-Engine: 1.0.81
4
- Fingerprint: sha256:2e05c6c4adffc16ce7cc1e172e212f7a0ef1c08545612ce7170d7c96ac36d8f1
4
+ Fingerprint: sha256:bb6ea669ad840648968355d3deb2ad767b4e3867029bd28935337d44dae87002
5
5
  Identity: ed25519:a58b17a3e46302dd3ae5538bc9b8b991c57f4c5fe2e7d8ac41803de818d947f4
6
6
  Privileges: XHS.HOOK.HTTP.REQUEST,XHS.HOOK.LIFECYCLE.SERVER_READY
7
- Expires: 2027-04-28T09:43:22Z
7
+ Expires: 2027-04-28T13:46:27Z
8
8
  Revision: sha256:none
9
9
  --- BEGIN CRYPTOGRAPHIC PROOF ---
10
- base64:htZVWcVTy/7PLFvF+PQf7S5TZttaVNj2cjs292cawK/QC/bz1xDMtURQCH+nKHh3GnMsspmUWtLFPeZolg8yDA==
10
+ base64:LxbunS3M7aPEOokSUj69R9Ht2nSWB8TLzAiVWAwB4tD3BhGgkTAUZW47ULmzibDaTDeclleLSMHiFa3bpvXXDA==
11
11
  --- END XYPRISS SIGNATURE ---