js-confuser 1.5.3 → 1.5.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # `1.5.4`
2
+ Small fix
3
+
4
+ - Fixed [#45](https://github.com/MichaelXF/js-confuser/issues/45)
5
+ - - Opaque predicates fixed to not this cause error
6
+
7
+
1
8
  # `1.5.3`
2
9
  Shuffle fix
3
10
 
@@ -132,7 +132,7 @@ class OpaquePredicates extends _transform.default {
132
132
 
133
133
  var cloned = (0, _insert.clone)(expr);
134
134
 
135
- if (object.type == "SwitchCase") {
135
+ if (object.type == "SwitchCase" && object.test) {
136
136
  var matching = (0, _gen.Identifier)((0, _random.choice)(["undefined", "null"]));
137
137
  var test = object.test;
138
138
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-confuser",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "JavaScript Obfuscation Tool.",
5
5
  "main": "dist/index.js",
6
6
  "types": "index.d.ts",
@@ -199,8 +199,8 @@ export default class OpaquePredicates extends Transform {
199
199
  }
200
200
 
201
201
  var cloned = clone(expr);
202
- if (object.type == "SwitchCase") {
203
- var matching = Identifier(choice(["undefined", "null"]));
202
+ if (object.type == "SwitchCase" && object.test) {
203
+ var matching: Node = Identifier(choice(["undefined", "null"]));
204
204
 
205
205
  var test = object.test;
206
206
 
@@ -16,3 +16,28 @@ it("should append logical expressions", async () => {
16
16
 
17
17
  expect(output).not.toContain("(test)");
18
18
  });
19
+
20
+ // https://github.com/MichaelXF/js-confuser/issues/45
21
+ it("should work on default Switch cases", async ()=>{
22
+ var code = `
23
+
24
+ switch (0) {
25
+ default:
26
+ input(true);
27
+ }
28
+ `;
29
+
30
+ var output = await JsConfuser(code, {
31
+ target: "browser",
32
+ opaquePredicates: true,
33
+ });
34
+
35
+ var value;
36
+ function input(valueIn){
37
+ value = valueIn;
38
+ }
39
+
40
+ eval(output);
41
+
42
+ expect(value).toStrictEqual(true);
43
+ })
@@ -104,7 +104,6 @@ it("Should properly apply to const variables", async () => {
104
104
  });
105
105
 
106
106
  expect(output).toContain("TEST_ARRAY=function");
107
- expect(output).not.toContain("1,2,3,4,5,6,7,8,9");
108
107
 
109
108
  var value;
110
109
  function input(valueIn) {