@dacely/toildefender 0.1.7 → 0.1.8
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/package.json +6 -6
- package/processors/preprocessing.js +11 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dacely/toildefender",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Modern JavaScript code protection, bytecode virtualization, and obfuscation for the Toil tech stack.",
|
|
5
5
|
"author": "Dacely",
|
|
6
6
|
"contributors": [
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@babel/parser": "^8.0.0",
|
|
65
65
|
"escodegen": "^2.1.0",
|
|
66
|
-
"escope": "
|
|
66
|
+
"escope": "^4.0.0",
|
|
67
67
|
"esprima": "^4.0.1",
|
|
68
68
|
"esshorten": "1.1.1",
|
|
69
|
-
"estraverse": "
|
|
70
|
-
"expr-eval": "
|
|
71
|
-
"lodash": "4.
|
|
72
|
-
"minimist": "1.2.
|
|
69
|
+
"estraverse": "^5.3.0",
|
|
70
|
+
"expr-eval-fork": "^3.0.3",
|
|
71
|
+
"lodash": "^4.18.1",
|
|
72
|
+
"minimist": "^1.2.8"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=24.11.0",
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
var _ = require("lodash");
|
|
4
4
|
|
|
5
|
-
var { Parser: Parser } = require("expr-eval");
|
|
5
|
+
var { Parser: Parser } = require("expr-eval-fork");
|
|
6
6
|
|
|
7
7
|
const DEFAULT_PREPROCESSOR_VARIABLES = {
|
|
8
8
|
"true": 1,
|
|
9
9
|
"false": 0
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
function normalizeConditionSyntax(condition) {
|
|
13
|
+
return condition
|
|
14
|
+
.replace(/&&/g, " and ")
|
|
15
|
+
.replace(/\|\|/g, " or ")
|
|
16
|
+
.replace(/!(?!=)/g, " not ");
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
/**
|
|
13
20
|
* Generates code from an array of text nodes.
|
|
14
21
|
* @param {TextNode[]} nodes
|
|
@@ -119,8 +126,9 @@ class IfBlockNode extends BlockNode {
|
|
|
119
126
|
*/
|
|
120
127
|
evalCond(defines) {
|
|
121
128
|
let condition = this.condition;
|
|
122
|
-
condition = condition.replace(/!defined\(([\w\d]+)\)
|
|
123
|
-
condition = condition.replace(/defined\(([\w\d]+)\)
|
|
129
|
+
condition = condition.replace(/!defined\(([\w\d]+)\)/g, (match, p1) => !defines.hasOwnProperty(p1) ? "true" : "false");
|
|
130
|
+
condition = condition.replace(/defined\(([\w\d]+)\)/g, (match, p1) => defines.hasOwnProperty(p1) ? "true" : "false");
|
|
131
|
+
condition = normalizeConditionSyntax(condition);
|
|
124
132
|
return Parser.evaluate(condition, defines);
|
|
125
133
|
}
|
|
126
134
|
/**
|