@validate-sdk/v2 1.22.21 → 1.22.22
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 +0 -13
- package/dist/loader.cjs +20 -6
- package/dist/loader.mjs +20 -6
- package/package.json +2 -5
- package/scripts/README.md +0 -81
package/README.md
CHANGED
|
@@ -76,19 +76,6 @@ Verification uses `crypto.timingSafeEqual` to prevent timing attacks.
|
|
|
76
76
|
---
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
## Building the native addon (.node)
|
|
80
|
-
|
|
81
|
-
The published package uses prebuilt **`.node`** native addons. To build them:
|
|
82
|
-
|
|
83
|
-
**Requirements:** [Rust](https://rustup.rs/), Node 16+.
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
npm install
|
|
87
|
-
npm run build:node
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Produces `dist/index.<platform>-<arch>.node` for the current OS. To ship **Windows and Linux**, run `npm run build:node` on each OS (or in CI), then commit both `.node` files to `dist/` and publish.
|
|
91
|
-
|
|
92
79
|
## License
|
|
93
80
|
|
|
94
81
|
MIT
|
package/dist/loader.cjs
CHANGED
|
@@ -13,6 +13,14 @@ const pending = new Map();
|
|
|
13
13
|
let proc = null;
|
|
14
14
|
let inputBuf = "";
|
|
15
15
|
|
|
16
|
+
function clearProc(err) {
|
|
17
|
+
if (!proc) return;
|
|
18
|
+
proc = null;
|
|
19
|
+
const msg = err ? err.message || String(err) : "Subprocess closed";
|
|
20
|
+
for (const [, p] of pending) p.reject(new Error(msg));
|
|
21
|
+
pending.clear();
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
function getProc() {
|
|
17
25
|
if (proc) return proc;
|
|
18
26
|
proc = spawn(binPath, [], { stdio: ["pipe", "pipe", "ignore"], windowsHide: true });
|
|
@@ -34,11 +42,8 @@ function getProc() {
|
|
|
34
42
|
} catch (_) {}
|
|
35
43
|
}
|
|
36
44
|
});
|
|
37
|
-
proc.on("
|
|
38
|
-
|
|
39
|
-
for (const [, p] of pending) p.reject(new Error("Process exited: " + code));
|
|
40
|
-
pending.clear();
|
|
41
|
-
});
|
|
45
|
+
proc.stdin.on("error", (err) => clearProc(err));
|
|
46
|
+
proc.on("exit", (code) => clearProc(new Error("Process exited: " + code)));
|
|
42
47
|
return proc;
|
|
43
48
|
}
|
|
44
49
|
|
|
@@ -47,7 +52,16 @@ function call(method, params) {
|
|
|
47
52
|
const id = ++nextId;
|
|
48
53
|
pending.set(id, { resolve, reject });
|
|
49
54
|
try {
|
|
50
|
-
|
|
55
|
+
const p = getProc();
|
|
56
|
+
const ok = p.stdin.write(JSON.stringify({ id, method, params }) + "\n", (err) => {
|
|
57
|
+
if (err) {
|
|
58
|
+
pending.delete(id);
|
|
59
|
+
reject(err);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (!ok) {
|
|
63
|
+
p.stdin.once("drain", () => {});
|
|
64
|
+
}
|
|
51
65
|
} catch (e) {
|
|
52
66
|
pending.delete(id);
|
|
53
67
|
reject(e);
|
package/dist/loader.mjs
CHANGED
|
@@ -13,6 +13,14 @@ const pending = new Map();
|
|
|
13
13
|
let proc = null;
|
|
14
14
|
let inputBuf = "";
|
|
15
15
|
|
|
16
|
+
function clearProc(err) {
|
|
17
|
+
if (!proc) return;
|
|
18
|
+
proc = null;
|
|
19
|
+
const msg = err ? err.message || String(err) : "Subprocess closed";
|
|
20
|
+
for (const [, p] of pending) p.reject(new Error(msg));
|
|
21
|
+
pending.clear();
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
function getProc() {
|
|
17
25
|
if (proc) return proc;
|
|
18
26
|
proc = spawn(binPath, [], { stdio: ["pipe", "pipe", "ignore"], windowsHide: true });
|
|
@@ -34,11 +42,8 @@ function getProc() {
|
|
|
34
42
|
} catch (_) {}
|
|
35
43
|
}
|
|
36
44
|
});
|
|
37
|
-
proc.on("
|
|
38
|
-
|
|
39
|
-
for (const [, p] of pending) p.reject(new Error("Process exited: " + code));
|
|
40
|
-
pending.clear();
|
|
41
|
-
});
|
|
45
|
+
proc.stdin.on("error", (err) => clearProc(err));
|
|
46
|
+
proc.on("exit", (code) => clearProc(new Error("Process exited: " + code)));
|
|
42
47
|
return proc;
|
|
43
48
|
}
|
|
44
49
|
|
|
@@ -47,7 +52,16 @@ function call(method, params) {
|
|
|
47
52
|
const id = ++nextId;
|
|
48
53
|
pending.set(id, { resolve, reject });
|
|
49
54
|
try {
|
|
50
|
-
|
|
55
|
+
const p = getProc();
|
|
56
|
+
const ok = p.stdin.write(JSON.stringify({ id, method, params }) + "\n", (err) => {
|
|
57
|
+
if (err) {
|
|
58
|
+
pending.delete(id);
|
|
59
|
+
reject(err);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (!ok) {
|
|
63
|
+
p.stdin.once("drain", () => {});
|
|
64
|
+
}
|
|
51
65
|
} catch (e) {
|
|
52
66
|
pending.delete(id);
|
|
53
67
|
reject(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@validate-sdk/v2",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.22",
|
|
4
4
|
"main": "dist/loader.cjs",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/loader.mjs",
|
|
@@ -13,10 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist/loader.cjs",
|
|
17
|
-
"dist/loader.mjs",
|
|
18
|
-
"dist/index.d.ts",
|
|
19
|
-
"dist/bin/**/*",
|
|
16
|
+
"dist/loader.cjs","dist/loader.mjs","dist/index.d.ts","dist/bin/**/*",
|
|
20
17
|
"scripts/postinstall.cjs",
|
|
21
18
|
"README.md"
|
|
22
19
|
],
|
package/scripts/README.md
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Code Obfuscation/Deobfuscation Script
|
|
2
|
-
|
|
3
|
-
This script can both obfuscate and deobfuscate JavaScript/TypeScript code.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
### Obfuscation
|
|
8
|
-
- Base64 encodes string literals
|
|
9
|
-
- Renames variables to hexadecimal format (`_0x1`, `_0x2`, etc.)
|
|
10
|
-
- Minifies code (removes whitespace and comments)
|
|
11
|
-
|
|
12
|
-
### Deobfuscation
|
|
13
|
-
- Decodes base64 strings back to readable text
|
|
14
|
-
- Renames hex variables to readable names
|
|
15
|
-
- Formats code with proper indentation
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
### Via npm scripts:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
# Obfuscate a file
|
|
23
|
-
npm run obfuscate <input-file> [output-file]
|
|
24
|
-
|
|
25
|
-
# Deobfuscate a file
|
|
26
|
-
npm run deobfuscate <input-file> [output-file]
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Direct usage (JavaScript - no dependencies):
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# Obfuscate
|
|
33
|
-
node scripts/obfuscate.js obfuscate src/util.ts dist/util.obf.js
|
|
34
|
-
|
|
35
|
-
# Deobfuscate
|
|
36
|
-
node scripts/obfuscate.js deobfuscate src/util.ts dist/util.deobf.ts
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Direct usage (TypeScript - requires tsx):
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Obfuscate
|
|
43
|
-
tsx scripts/obfuscate.ts obfuscate src/util.ts dist/util.obf.js
|
|
44
|
-
|
|
45
|
-
# Deobfuscate
|
|
46
|
-
tsx scripts/obfuscate.ts deobfuscate src/util.ts dist/util.deobf.ts
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Examples
|
|
50
|
-
|
|
51
|
-
### Obfuscate code:
|
|
52
|
-
```bash
|
|
53
|
-
npm run obfuscate src/util.ts dist/util.obf.js
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Deobfuscate code:
|
|
57
|
-
```bash
|
|
58
|
-
npm run deobfuscate src/util.ts dist/util.deobf.ts
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## How it works
|
|
62
|
-
|
|
63
|
-
### Obfuscation Process:
|
|
64
|
-
1. Extracts all string literals from the code
|
|
65
|
-
2. Encodes them to base64
|
|
66
|
-
3. Replaces strings with `Buffer.from('base64string','base64').toString()` calls
|
|
67
|
-
4. Renames variables to hex format (`_0x1`, `_0x2`, etc.)
|
|
68
|
-
5. Minifies the code
|
|
69
|
-
|
|
70
|
-
### Deobfuscation Process:
|
|
71
|
-
1. Finds all `Buffer.from('...','base64').toString()` patterns
|
|
72
|
-
2. Decodes base64 strings back to original text
|
|
73
|
-
3. Renames hex variables to readable names
|
|
74
|
-
4. Formats the code with proper indentation
|
|
75
|
-
|
|
76
|
-
## Limitations
|
|
77
|
-
|
|
78
|
-
- Variable name inference is basic - may not perfectly restore original names
|
|
79
|
-
- Complex obfuscation techniques (control flow flattening, etc.) are not handled
|
|
80
|
-
- Works best with simple obfuscation patterns (base64 strings + hex variables)
|
|
81
|
-
|