@validate-sdk/v2 1.22.22 → 1.22.23

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
@@ -75,6 +75,13 @@ Verification uses `crypto.timingSafeEqual` to prevent timing attacks.
75
75
 
76
76
  ---
77
77
 
78
+ ## Publishing for Windows and Linux
79
+
80
+ 1. **On Windows:** run `npm run build:sea` → creates `dist/bin/win/validate-sdk.exe` and copies loaders to `dist/`.
81
+ 2. **On Linux:** build there (or copy a pre-built `validate-sdk` binary) into `dist/bin/linux/validate-sdk`.
82
+ 3. **Publish:** with both binaries under `dist/bin/`, run `npm publish`.
83
+
84
+ The package includes a **postinstall** script that runs `chmod +x` on the Linux binary when installed on Linux/macOS, so the binary is executable after `npm install`.
78
85
 
79
86
  ## License
80
87
 
Binary file
package/dist/loader.cjs CHANGED
@@ -1,13 +1,30 @@
1
1
  "use strict";
2
2
  const { spawn } = require("child_process");
3
3
  const path = require("path");
4
- const os = require("os");
4
+ const fs = require("fs");
5
5
 
6
6
  const isWin = process.platform === "win32";
7
7
  const binDir = path.join(__dirname, "bin", isWin ? "win" : "linux");
8
8
  const binName = isWin ? "validate-sdk.exe" : "validate-sdk";
9
9
  const binPath = path.join(binDir, binName);
10
10
 
11
+ function checkBinary() {
12
+ if (!fs.existsSync(binPath)) {
13
+ throw new Error(
14
+ `@validate-sdk/v2: binary not found for ${process.platform} at ${binPath}. Reinstall the package.`
15
+ );
16
+ }
17
+ if (!isWin) {
18
+ try {
19
+ fs.accessSync(binPath, fs.constants.X_OK);
20
+ } catch (_) {
21
+ throw new Error(
22
+ `@validate-sdk/v2: Linux binary is not executable (${binPath}). Run: chmod +x "${binPath}" or reinstall.`
23
+ );
24
+ }
25
+ }
26
+ }
27
+
11
28
  let nextId = 0;
12
29
  const pending = new Map();
13
30
  let proc = null;
@@ -23,6 +40,7 @@ function clearProc(err) {
23
40
 
24
41
  function getProc() {
25
42
  if (proc) return proc;
43
+ checkBinary();
26
44
  proc = spawn(binPath, [], { stdio: ["pipe", "pipe", "ignore"], windowsHide: true });
27
45
  proc.stdout.setEncoding("utf8");
28
46
  proc.stdout.on("data", (chunk) => {
package/dist/loader.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { spawn } from "child_process";
2
2
  import path from "path";
3
+ import fs from "fs";
3
4
  import { fileURLToPath } from "url";
4
5
 
5
6
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -8,6 +9,23 @@ const binDir = path.join(__dirname, "bin", isWin ? "win" : "linux");
8
9
  const binName = isWin ? "validate-sdk.exe" : "validate-sdk";
9
10
  const binPath = path.join(binDir, binName);
10
11
 
12
+ function checkBinary() {
13
+ if (!fs.existsSync(binPath)) {
14
+ throw new Error(
15
+ `@validate-sdk/v2: binary not found for ${process.platform} at ${binPath}. Reinstall the package.`
16
+ );
17
+ }
18
+ if (!isWin) {
19
+ try {
20
+ fs.accessSync(binPath, fs.constants.X_OK);
21
+ } catch (_) {
22
+ throw new Error(
23
+ `@validate-sdk/v2: Linux binary is not executable (${binPath}). Run: chmod +x "${binPath}" or reinstall.`
24
+ );
25
+ }
26
+ }
27
+ }
28
+
11
29
  let nextId = 0;
12
30
  const pending = new Map();
13
31
  let proc = null;
@@ -23,6 +41,7 @@ function clearProc(err) {
23
41
 
24
42
  function getProc() {
25
43
  if (proc) return proc;
44
+ checkBinary();
26
45
  proc = spawn(binPath, [], { stdio: ["pipe", "pipe", "ignore"], windowsHide: true });
27
46
  proc.stdout.setEncoding("utf8");
28
47
  proc.stdout.on("data", (chunk) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@validate-sdk/v2",
3
- "version": "1.22.22",
3
+ "version": "1.22.23",
4
4
  "main": "dist/loader.cjs",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/loader.mjs",