js-confuser 1.5.2 → 1.5.3
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
|
@@ -126,7 +126,7 @@ class Shuffle extends _transform.default {
|
|
|
126
126
|
if (varDeclarator.type == "VariableDeclarator") {
|
|
127
127
|
var varDec = parents[2];
|
|
128
128
|
|
|
129
|
-
if (varDec.type == "VariableDeclaration") {
|
|
129
|
+
if (varDec.type == "VariableDeclaration" && varDec.kind !== "const") {
|
|
130
130
|
var body = parents[3];
|
|
131
131
|
|
|
132
132
|
if (varDec.declarations.length == 1 && Array.isArray(body) && varDeclarator.id.type === "Identifier" && varDeclarator.init === object) {
|
package/package.json
CHANGED
|
@@ -149,7 +149,7 @@ export default class Shuffle extends Transform {
|
|
|
149
149
|
var varDeclarator = parents[0];
|
|
150
150
|
if (varDeclarator.type == "VariableDeclarator") {
|
|
151
151
|
var varDec = parents[2];
|
|
152
|
-
if (varDec.type == "VariableDeclaration") {
|
|
152
|
+
if (varDec.type == "VariableDeclaration" && varDec.kind !== "const") {
|
|
153
153
|
var body = parents[3];
|
|
154
154
|
if (
|
|
155
155
|
varDec.declarations.length == 1 &&
|
|
@@ -89,3 +89,29 @@ it("should shuffle arrays based on hash and unshuffle incorrect if changed", asy
|
|
|
89
89
|
|
|
90
90
|
expect(different).toStrictEqual(true);
|
|
91
91
|
});
|
|
92
|
+
|
|
93
|
+
// https://github.com/MichaelXF/js-confuser/issues/48
|
|
94
|
+
it("Should properly apply to const variables", async () => {
|
|
95
|
+
var code = `
|
|
96
|
+
const TEST_ARRAY = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
97
|
+
|
|
98
|
+
input(TEST_ARRAY);
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
var output = await JsConfuser(code, {
|
|
102
|
+
target: "browser",
|
|
103
|
+
shuffle: true,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(output).toContain("TEST_ARRAY=function");
|
|
107
|
+
expect(output).not.toContain("1,2,3,4,5,6,7,8,9");
|
|
108
|
+
|
|
109
|
+
var value;
|
|
110
|
+
function input(valueIn) {
|
|
111
|
+
value = valueIn;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
eval(output);
|
|
115
|
+
|
|
116
|
+
expect(value).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
117
|
+
});
|