js-confuser 1.4.3 → 1.5.0

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/README.md +5 -2
  3. package/dev.js +4 -5
  4. package/dist/compiler.js +1 -1
  5. package/dist/constants.js +1 -1
  6. package/dist/index.js +5 -5
  7. package/dist/obfuscator.js +11 -3
  8. package/dist/options.js +1 -1
  9. package/dist/parser.js +2 -2
  10. package/dist/precedence.js +1 -1
  11. package/dist/presets.js +3 -3
  12. package/dist/probability.js +7 -1
  13. package/dist/transforms/calculator.js +15 -3
  14. package/dist/transforms/controlFlowFlattening/controlFlowFlattening.js +79 -17
  15. package/dist/transforms/dispatcher.js +3 -1
  16. package/dist/transforms/flatten.js +2 -2
  17. package/dist/transforms/hideInitializingCode.js +8 -3
  18. package/dist/transforms/identifier/globalConcealing.js +3 -1
  19. package/dist/transforms/identifier/nameRecycling.js +2 -1
  20. package/dist/transforms/lock/integrity.js +2 -1
  21. package/dist/transforms/lock/lock.js +2 -2
  22. package/dist/transforms/rgf.js +11 -8
  23. package/dist/transforms/stack.js +2 -1
  24. package/dist/transforms/string/stringConcealing.js +3 -3
  25. package/dist/transforms/transform.js +32 -8
  26. package/dist/traverse.js +4 -2
  27. package/dist/types.js +5 -1
  28. package/dist/util/compare.js +4 -4
  29. package/dist/util/gen.js +66 -47
  30. package/dist/util/identifiers.js +4 -4
  31. package/dist/util/insert.js +25 -16
  32. package/dist/util/object.js +3 -1
  33. package/dist/util/random.js +5 -5
  34. package/dist/util/scope.js +1 -1
  35. package/package.json +11 -11
  36. package/samples/high.js +1 -198
  37. package/samples/low.js +1 -26
  38. package/samples/medium.js +1 -40
  39. package/src/presets.ts +3 -3
  40. package/src/transforms/calculator.ts +36 -5
  41. package/src/transforms/controlFlowFlattening/controlFlowFlattening.ts +86 -0
  42. package/src/transforms/transform.ts +10 -2
@@ -27,9 +27,9 @@ var _insert = require("../util/insert");
27
27
 
28
28
  var _transform = _interopRequireDefault(require("./transform"));
29
29
 
30
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
30
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
31
 
32
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
32
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
33
 
34
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
35
 
@@ -122,11 +122,13 @@ class RGF extends _transform.default {
122
122
 
123
123
  while (true) {
124
124
  var hit = false;
125
- collect.forEach(({
126
- name,
127
- references: references1,
128
- location: location1
129
- }) => {
125
+ collect.forEach(_ref => {
126
+ let {
127
+ name,
128
+ references: references1,
129
+ location: location1
130
+ } = _ref;
131
+
130
132
  if (!references1.size && name) {
131
133
  collect.forEach(o => {
132
134
  if (o.location[0] !== location1[0] && o.references.size && o.references.delete(name)) {
@@ -193,9 +195,10 @@ class RGF extends _transform.default {
193
195
  var arrayExpression = (0, _gen.ArrayExpression)([]);
194
196
  var variableDeclaration = (0, _gen.VariableDeclaration)([(0, _gen.VariableDeclarator)((0, _gen.Identifier)(referenceArray), arrayExpression)]);
195
197
  (0, _insert.prepend)(contextObject, variableDeclaration);
196
- queue.forEach(([object, parents]) => {
198
+ queue.forEach(_ref2 => {
197
199
  var _object$id2;
198
200
 
201
+ let [object, parents] = _ref2;
199
202
  var name = object === null || object === void 0 ? void 0 : (_object$id2 = object.id) === null || _object$id2 === void 0 ? void 0 : _object$id2.name;
200
203
  var hasName = !!name;
201
204
  var params = object.params.map(x => x.name) || [];
@@ -136,7 +136,8 @@ class Stack extends _transform.default {
136
136
  return;
137
137
  }
138
138
 
139
- function numberLiteral(number, depth = 0) {
139
+ function numberLiteral(number) {
140
+ let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
140
141
  (0, _assert.ok)(number === number);
141
142
 
142
143
  if (typeof number !== "number" || !Object.keys(deadValues).length || depth > 5 || Math.random() > (depth == 0 ? 0.9 : 0.8 / (depth * 2))) {
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isModuleSource = isModuleSource;
7
6
  exports.default = void 0;
7
+ exports.isModuleSource = isModuleSource;
8
8
 
9
9
  var _assert = require("assert");
10
10
 
@@ -168,8 +168,8 @@ class StringConcealing extends _transform.default {
168
168
  callExpr = (0, _gen.CallExpression)((0, _gen.MemberExpression)((0, _gen.Identifier)(fnName), (0, _gen.Identifier)("apply"), false), [(0, _gen.ThisExpression)(), (0, _gen.ArrayExpression)([(0, _gen.Literal)(index)])]);
169
169
  } // use `.call`
170
170
  else if (Math.random() > 0.5) {
171
- callExpr = (0, _gen.CallExpression)((0, _gen.MemberExpression)((0, _gen.Identifier)(fnName), (0, _gen.Identifier)("call"), false), [(0, _gen.ThisExpression)(), (0, _gen.Literal)(index)]);
172
- }
171
+ callExpr = (0, _gen.CallExpression)((0, _gen.MemberExpression)((0, _gen.Identifier)(fnName), (0, _gen.Identifier)("call"), false), [(0, _gen.ThisExpression)(), (0, _gen.Literal)(index)]);
172
+ }
173
173
 
174
174
  var constantReference = parents.length && Math.random() > 0.5 / this.variablesMade;
175
175
 
@@ -85,7 +85,9 @@ class Transform {
85
85
  /**
86
86
  * Transformations to run at the same time (can cause conflicts so use sparingly)
87
87
  */
88
- constructor(obfuscator, priority = -1) {
88
+ constructor(obfuscator) {
89
+ let priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
90
+
89
91
  _defineProperty(this, "obfuscator", void 0);
90
92
 
91
93
  _defineProperty(this, "options", void 0);
@@ -209,12 +211,21 @@ class Transform {
209
211
  */
210
212
 
211
213
 
212
- getGenerator(offset = 0) {
214
+ getGenerator() {
215
+ let offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
213
216
  var count = offset;
217
+ var identifiers = new Set();
214
218
  return {
215
219
  generate: () => {
216
- count++;
217
- return this.generateIdentifier(-1, count);
220
+ var retValue;
221
+
222
+ do {
223
+ count++;
224
+ retValue = this.generateIdentifier(-1, count);
225
+ } while (identifiers.has(retValue));
226
+
227
+ identifiers.add(retValue);
228
+ return retValue;
218
229
  }
219
230
  };
220
231
  }
@@ -225,7 +236,10 @@ class Transform {
225
236
  */
226
237
 
227
238
 
228
- generateIdentifier(length = -1, count = -1) {
239
+ generateIdentifier() {
240
+ let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
241
+ let count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
242
+
229
243
  if (length == -1) {
230
244
  length = (0, _random.getRandomInteger)(6, 8);
231
245
  }
@@ -241,7 +255,9 @@ class Transform {
241
255
  var identifier;
242
256
 
243
257
  do {
244
- identifier = (0, _probability.ComputeProbabilityMap)(this.options.identifierGenerator, (mode = "randomized") => {
258
+ identifier = (0, _probability.ComputeProbabilityMap)(this.options.identifierGenerator, function () {
259
+ let mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "randomized";
260
+
245
261
  switch (mode) {
246
262
  case "randomized":
247
263
  var characters = "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
@@ -352,8 +368,12 @@ class Transform {
352
368
  */
353
369
 
354
370
 
355
- log(...messages) {
371
+ log() {
356
372
  if (this.options.verbose) {
373
+ for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
374
+ messages[_key] = arguments[_key];
375
+ }
376
+
357
377
  console.log("[" + this.className + "]", ...messages);
358
378
  }
359
379
  }
@@ -363,8 +383,12 @@ class Transform {
363
383
  */
364
384
 
365
385
 
366
- warn(...messages) {
386
+ warn() {
367
387
  if (this.options.verbose) {
388
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
389
+ messages[_key2] = arguments[_key2];
390
+ }
391
+
368
392
  console.log("[ WARN " + this.className + " ]", ...messages);
369
393
  }
370
394
  }
package/dist/traverse.js CHANGED
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = traverse;
6
7
  exports.getBlock = getBlock;
7
8
  exports.isBlock = isBlock;
8
9
  exports.walk = walk;
9
- exports.default = traverse;
10
10
 
11
11
  var _identifiers = require("./util/identifiers");
12
12
 
@@ -39,7 +39,9 @@ function isBlock(object) {
39
39
  return object && (object.type == "BlockStatement" || object.type == "Program");
40
40
  }
41
41
 
42
- function walk(object, parents, onEnter, seen = new Set()) {
42
+ function walk(object, parents, onEnter) {
43
+ let seen = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
44
+
43
45
  if (typeof object === "object" && object) {
44
46
  if (seen.has(object)) {
45
47
  console.log(object);
package/dist/types.js CHANGED
@@ -1 +1,5 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isEquivalent = isEquivalent;
7
- exports.isLoop = isLoop;
8
- exports.isValidIdentifier = isValidIdentifier;
9
- exports.isInsideType = isInsideType;
10
6
  exports.isDirective = isDirective;
7
+ exports.isEquivalent = isEquivalent;
11
8
  exports.isIndependent = isIndependent;
9
+ exports.isInsideType = isInsideType;
10
+ exports.isLoop = isLoop;
12
11
  exports.isPrimitive = isPrimitive;
12
+ exports.isValidIdentifier = isValidIdentifier;
13
13
 
14
14
  var _traverse = require("../traverse");
15
15
 
package/dist/util/gen.js CHANGED
@@ -3,51 +3,51 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Literal = Literal;
7
- exports.RegexLiteral = RegexLiteral;
8
- exports.Identifier = Identifier;
9
- exports.BlockStatement = BlockStatement;
10
- exports.LogicalExpression = LogicalExpression;
6
+ exports.AddComment = AddComment;
7
+ exports.ArrayExpression = ArrayExpression;
8
+ exports.ArrayPattern = ArrayPattern;
9
+ exports.AssignmentExpression = AssignmentExpression;
10
+ exports.AssignmentPattern = AssignmentPattern;
11
+ exports.AwaitExpression = AwaitExpression;
11
12
  exports.BinaryExpression = BinaryExpression;
12
- exports.ThisExpression = ThisExpression;
13
- exports.SwitchCase = SwitchCase;
14
- exports.SwitchDefaultCase = SwitchDefaultCase;
15
- exports.LabeledStatement = LabeledStatement;
16
- exports.SwitchStatement = SwitchStatement;
13
+ exports.BlockStatement = BlockStatement;
17
14
  exports.BreakStatement = BreakStatement;
18
- exports.Property = Property;
19
- exports.ObjectExpression = ObjectExpression;
20
- exports.VariableDeclarator = VariableDeclarator;
21
- exports.VariableDeclaration = VariableDeclaration;
22
- exports.ForStatement = ForStatement;
23
- exports.WhileStatement = WhileStatement;
24
- exports.IfStatement = IfStatement;
25
- exports.FunctionExpression = FunctionExpression;
26
- exports.FunctionDeclaration = FunctionDeclaration;
27
- exports.DebuggerStatement = DebuggerStatement;
28
- exports.ReturnStatement = ReturnStatement;
29
- exports.AwaitExpression = AwaitExpression;
15
+ exports.CallExpression = CallExpression;
16
+ exports.CatchClause = CatchClause;
17
+ exports.ClassDeclaration = ClassDeclaration;
30
18
  exports.ConditionalExpression = ConditionalExpression;
19
+ exports.DebuggerStatement = DebuggerStatement;
31
20
  exports.ExpressionStatement = ExpressionStatement;
32
- exports.UnaryExpression = UnaryExpression;
33
- exports.UpdateExpression = UpdateExpression;
34
- exports.SequenceExpression = SequenceExpression;
21
+ exports.ForStatement = ForStatement;
22
+ exports.FunctionDeclaration = FunctionDeclaration;
23
+ exports.FunctionExpression = FunctionExpression;
24
+ exports.Identifier = Identifier;
25
+ exports.IfStatement = IfStatement;
26
+ exports.LabeledStatement = LabeledStatement;
27
+ exports.Literal = Literal;
28
+ exports.LogicalExpression = LogicalExpression;
35
29
  exports.MemberExpression = MemberExpression;
36
- exports.CallExpression = CallExpression;
37
- exports.NewExpression = NewExpression;
38
- exports.AssignmentExpression = AssignmentExpression;
39
- exports.ArrayPattern = ArrayPattern;
40
- exports.ArrayExpression = ArrayExpression;
41
- exports.AssignmentPattern = AssignmentPattern;
42
- exports.AddComment = AddComment;
43
30
  exports.MethodDefinition = MethodDefinition;
44
- exports.ClassDeclaration = ClassDeclaration;
45
- exports.ThrowStatement = ThrowStatement;
46
- exports.WithStatement = WithStatement;
47
- exports.SpreadElement = SpreadElement;
31
+ exports.NewExpression = NewExpression;
32
+ exports.ObjectExpression = ObjectExpression;
33
+ exports.Property = Property;
34
+ exports.RegexLiteral = RegexLiteral;
48
35
  exports.RestElement = RestElement;
49
- exports.CatchClause = CatchClause;
36
+ exports.ReturnStatement = ReturnStatement;
37
+ exports.SequenceExpression = SequenceExpression;
38
+ exports.SpreadElement = SpreadElement;
39
+ exports.SwitchCase = SwitchCase;
40
+ exports.SwitchDefaultCase = SwitchDefaultCase;
41
+ exports.SwitchStatement = SwitchStatement;
42
+ exports.ThisExpression = ThisExpression;
43
+ exports.ThrowStatement = ThrowStatement;
50
44
  exports.TryStatement = TryStatement;
45
+ exports.UnaryExpression = UnaryExpression;
46
+ exports.UpdateExpression = UpdateExpression;
47
+ exports.VariableDeclaration = VariableDeclaration;
48
+ exports.VariableDeclarator = VariableDeclarator;
49
+ exports.WhileStatement = WhileStatement;
50
+ exports.WithStatement = WithStatement;
51
51
 
52
52
  var _assert = require("assert");
53
53
 
@@ -172,7 +172,9 @@ function BreakStatement(label) {
172
172
  };
173
173
  }
174
174
 
175
- function Property(key, value, computed = false) {
175
+ function Property(key, value) {
176
+ let computed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
177
+
176
178
  if (!key) {
177
179
  throw new Error("key is undefined");
178
180
  }
@@ -203,7 +205,9 @@ function ObjectExpression(properties) {
203
205
  };
204
206
  }
205
207
 
206
- function VariableDeclarator(id, init = null) {
208
+ function VariableDeclarator(id) {
209
+ let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
210
+
207
211
  if (typeof id === "string") {
208
212
  id = Identifier(id);
209
213
  }
@@ -215,7 +219,9 @@ function VariableDeclarator(id, init = null) {
215
219
  };
216
220
  }
217
221
 
218
- function VariableDeclaration(declarations, kind = "var") {
222
+ function VariableDeclaration(declarations) {
223
+ let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "var";
224
+
219
225
  if (!Array.isArray(declarations)) {
220
226
  declarations = [declarations];
221
227
  }
@@ -252,7 +258,9 @@ function WhileStatement(test, body) {
252
258
  };
253
259
  }
254
260
 
255
- function IfStatement(test, consequent, alternate = null) {
261
+ function IfStatement(test, consequent) {
262
+ let alternate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
263
+
256
264
  if (!test) {
257
265
  throw new Error("test is undefined");
258
266
  }
@@ -329,7 +337,9 @@ function DebuggerStatement() {
329
337
  };
330
338
  }
331
339
 
332
- function ReturnStatement(argument = null) {
340
+ function ReturnStatement() {
341
+ let argument = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
342
+
333
343
  if (argument) {
334
344
  (0, _assert.ok)(argument.type, "Argument should be a node");
335
345
  }
@@ -378,7 +388,8 @@ function UnaryExpression(operator, argument) {
378
388
  };
379
389
  }
380
390
 
381
- function UpdateExpression(operator, argument, prefix = false) {
391
+ function UpdateExpression(operator, argument) {
392
+ let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
382
393
  return {
383
394
  type: "UpdateExpression",
384
395
  operator,
@@ -402,7 +413,9 @@ function SequenceExpression(expressions) {
402
413
  };
403
414
  }
404
415
 
405
- function MemberExpression(object, property, computed = true) {
416
+ function MemberExpression(object, property) {
417
+ let computed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
418
+
406
419
  if (!object) {
407
420
  throw new Error("object undefined");
408
421
  }
@@ -497,7 +510,9 @@ function AddComment(node, text) {
497
510
  return node;
498
511
  }
499
512
 
500
- function MethodDefinition(identifier, functionExpression, kind, isStatic = true, computed = false) {
513
+ function MethodDefinition(identifier, functionExpression, kind) {
514
+ let isStatic = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
515
+ let computed = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
501
516
  return {
502
517
  type: "MethodDefinition",
503
518
  key: identifier,
@@ -508,7 +523,9 @@ function MethodDefinition(identifier, functionExpression, kind, isStatic = true,
508
523
  };
509
524
  }
510
525
 
511
- function ClassDeclaration(id, superClass = null, body = []) {
526
+ function ClassDeclaration(id) {
527
+ let superClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
528
+ let body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
512
529
  return {
513
530
  type: "ClassDeclaration",
514
531
  id: id,
@@ -563,7 +580,9 @@ function RestElement(argument) {
563
580
  };
564
581
  }
565
582
 
566
- function CatchClause(param = null, body) {
583
+ function CatchClause() {
584
+ let param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
585
+ let body = arguments.length > 1 ? arguments[1] : undefined;
567
586
  return {
568
587
  type: "CatchClause",
569
588
  param: param,
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.validateChain = validateChain;
7
- exports.getIdentifierInfo = getIdentifierInfo;
6
+ exports.containsLexicallyBoundVariables = containsLexicallyBoundVariables;
8
7
  exports.getDefiningIdentifier = getDefiningIdentifier;
9
- exports.isFunctionParameter = isFunctionParameter;
10
8
  exports.getFunctionParameters = getFunctionParameters;
11
- exports.containsLexicallyBoundVariables = containsLexicallyBoundVariables;
9
+ exports.getIdentifierInfo = getIdentifierInfo;
10
+ exports.isFunctionParameter = isFunctionParameter;
11
+ exports.validateChain = validateChain;
12
12
 
13
13
  var _assert = require("assert");
14
14
 
@@ -3,24 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isFunction = isFunction;
7
- exports.getFunction = getFunction;
8
- exports.getVarContext = getVarContext;
9
- exports.isVarContext = isVarContext;
10
- exports.isLexContext = isLexContext;
11
- exports.isContext = isContext;
6
+ exports.append = append;
7
+ exports.clone = clone;
8
+ exports.deleteDeclaration = deleteDeclaration;
9
+ exports.deleteDirect = deleteDirect;
10
+ exports.getBlockBody = getBlockBody;
12
11
  exports.getContexts = getContexts;
13
- exports.getLexContext = getLexContext;
14
12
  exports.getDefiningContext = getDefiningContext;
15
- exports.getReferencingContexts = getReferencingContexts;
16
- exports.getBlockBody = getBlockBody;
13
+ exports.getFunction = getFunction;
17
14
  exports.getIndexDirect = getIndexDirect;
18
- exports.deleteDeclaration = deleteDeclaration;
19
- exports.deleteDirect = deleteDirect;
20
- exports.prepend = prepend;
21
- exports.append = append;
22
- exports.clone = clone;
15
+ exports.getLexContext = getLexContext;
16
+ exports.getReferencingContexts = getReferencingContexts;
17
+ exports.getVarContext = getVarContext;
18
+ exports.isContext = isContext;
23
19
  exports.isForInitialize = isForInitialize;
20
+ exports.isFunction = isFunction;
21
+ exports.isLexContext = isLexContext;
22
+ exports.isVarContext = isVarContext;
23
+ exports.prepend = prepend;
24
24
 
25
25
  var _assert = require("assert");
26
26
 
@@ -250,9 +250,13 @@ function deleteDirect(object, parent) {
250
250
  }
251
251
  }
252
252
 
253
- function prepend(block, ...nodes) {
253
+ function prepend(block) {
254
254
  (0, _assert.ok)(!Array.isArray(block), "block should not be array");
255
255
 
256
+ for (var _len = arguments.length, nodes = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
257
+ nodes[_key - 1] = arguments[_key];
258
+ }
259
+
256
260
  if (block.type == "Program") {
257
261
  var decs = 0;
258
262
  block.body.forEach((stmt, i) => {
@@ -268,8 +272,13 @@ function prepend(block, ...nodes) {
268
272
  }
269
273
  }
270
274
 
271
- function append(block, ...nodes) {
275
+ function append(block) {
272
276
  (0, _assert.ok)(!Array.isArray(block), "block should not be array");
277
+
278
+ for (var _len2 = arguments.length, nodes = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
279
+ nodes[_key2 - 1] = arguments[_key2];
280
+ }
281
+
273
282
  getBlockBody(block).push(...nodes);
274
283
  }
275
284
 
@@ -24,7 +24,9 @@ function createObject(keys, values) {
24
24
  */
25
25
 
26
26
 
27
- function remove$Properties(object, seen = new Set()) {
27
+ function remove$Properties(object) {
28
+ let seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
29
+
28
30
  if (typeof object === "object" && object) {
29
31
  if (seen.has(object)) {// console.log(object);
30
32
  // throw new Error("Already seen");
@@ -3,15 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.alphabeticalGenerator = alphabeticalGenerator;
6
7
  exports.choice = choice;
7
- exports.shuffle = shuffle;
8
- exports.getRandomString = getRandomString;
9
8
  exports.getRandom = getRandom;
10
- exports.getRandomInteger = getRandomInteger;
11
- exports.splitIntoChunks = splitIntoChunks;
12
9
  exports.getRandomFalseExpression = getRandomFalseExpression;
10
+ exports.getRandomInteger = getRandomInteger;
11
+ exports.getRandomString = getRandomString;
13
12
  exports.getRandomTrueExpression = getRandomTrueExpression;
14
- exports.alphabeticalGenerator = alphabeticalGenerator;
13
+ exports.shuffle = shuffle;
14
+ exports.splitIntoChunks = splitIntoChunks;
15
15
 
16
16
  var _assert = require("assert");
17
17
 
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isLexicalScope = isLexicalScope;
7
6
  exports.getLexicalScope = getLexicalScope;
7
+ exports.isLexicalScope = isLexicalScope;
8
8
 
9
9
  var _traverse = require("../traverse");
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-confuser",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "JavaScript Obfuscation Tool.",
5
5
  "main": "dist/index.js",
6
6
  "types": "index.d.ts",
@@ -22,19 +22,19 @@
22
22
  "author": "MichaelXF",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "acorn": "^8.5.0",
25
+ "acorn": "^8.7.0",
26
26
  "escodegen": "^2.0.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@babel/cli": "^7.14.3",
30
- "@babel/core": "^7.12.13",
31
- "@babel/plugin-proposal-class-properties": "^7.13.0",
32
- "@babel/plugin-proposal-optional-chaining": "^7.14.2",
33
- "@babel/preset-env": "^7.12.13",
34
- "@babel/preset-typescript": "^7.12.1",
35
- "@babel/register": "^7.12.10",
36
- "@types/jest": "^26.0.23",
37
- "@types/node": "^15.6.1",
29
+ "@babel/cli": "^7.17.6",
30
+ "@babel/core": "^7.17.8",
31
+ "@babel/plugin-proposal-class-properties": "^7.16.7",
32
+ "@babel/plugin-proposal-optional-chaining": "^7.16.7",
33
+ "@babel/preset-env": "^7.16.11",
34
+ "@babel/preset-typescript": "^7.16.7",
35
+ "@babel/register": "^7.17.7",
36
+ "@types/jest": "^26.0.24",
37
+ "@types/node": "^15.14.9",
38
38
  "babel-jest": "^26.6.3",
39
39
  "jest": "^26.6.3"
40
40
  },