浏览代码

Merge pull request #118 from javascript-obfuscator/0.12.1-release

0.12.1 release
Timofey Kachalov 7 年之前
父节点
当前提交
5267bfe8c4
共有 98 个文件被更改,包括 564 次插入578 次删除
  1. 1 0
      .travis.yml
  2. 4 0
      CHANGELOG.md
  3. 0 0
      dist/index.js
  4. 13 14
      package.json
  5. 1 1
      scripts/tslint
  6. 1 1
      src/JavaScriptObfuscator.ts
  7. 1 1
      src/analyzers/stack-trace-analyzer/StackTraceAnalyzer.ts
  8. 2 1
      src/analyzers/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts
  9. 1 1
      src/analyzers/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts
  10. 2 2
      src/cli/JavaScriptObfuscatorCLI.ts
  11. 4 0
      src/cli/sanitizers/ArraySanitizer.ts
  12. 1 1
      src/custom-nodes/AbstractCustomNode.ts
  13. 1 1
      src/custom-nodes/AbstractCustomNodeGroup.ts
  14. 1 1
      src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts
  15. 1 10
      src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts
  16. 1 1
      src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts
  17. 1 1
      src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts
  18. 1 1
      src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts
  19. 1 1
      src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts
  20. 1 1
      src/custom-nodes/control-flow-flattening-nodes/StringLiteralNode.ts
  21. 1 1
      src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts
  22. 2 2
      src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts
  23. 1 1
      src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts
  24. 1 1
      src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts
  25. 1 1
      src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts
  26. 1 1
      src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts
  27. 1 1
      src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts
  28. 1 10
      src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts
  29. 1 1
      src/custom-nodes/domain-lock-nodes/DomainLockNode.ts
  30. 1 10
      src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts
  31. 1 1
      src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts
  32. 1 1
      src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts
  33. 1 10
      src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts
  34. 1 11
      src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts
  35. 1 1
      src/custom-nodes/string-array-nodes/StringArrayNode.ts
  36. 1 11
      src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts
  37. 3 12
      src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts
  38. 2 1
      src/decorators/Initializable.ts
  39. 4 4
      src/interfaces/node-transformers/INodeTransformer.d.ts
  40. 3 3
      src/interfaces/node-transformers/IVisitor.d.ts
  41. 1 1
      src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer.d.ts
  42. 2 1
      src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IObfuscatingReplacer.d.ts
  43. 1 1
      src/logger/Logger.ts
  44. 1 1
      src/node-transformers/AbstractNodeTransformer.ts
  45. 3 3
      src/node-transformers/TransformersRunner.ts
  46. 3 3
      src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts
  47. 9 7
      src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts
  48. 1 1
      src/node-transformers/control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.ts
  49. 1 1
      src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.ts
  50. 1 1
      src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.ts
  51. 1 1
      src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.ts
  52. 1 1
      src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.ts
  53. 1 1
      src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.ts
  54. 3 3
      src/node-transformers/converting-transformers/MemberExpressionTransformer.ts
  55. 3 3
      src/node-transformers/converting-transformers/MethodDefinitionTransformer.ts
  56. 3 3
      src/node-transformers/converting-transformers/TemplateLiteralTransformer.ts
  57. 12 11
      src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts
  58. 7 6
      src/node-transformers/obfuscating-transformers/CatchClauseTransformer.ts
  59. 21 19
      src/node-transformers/obfuscating-transformers/ClassDeclarationTransformer.ts
  60. 21 19
      src/node-transformers/obfuscating-transformers/FunctionDeclarationTransformer.ts
  61. 9 7
      src/node-transformers/obfuscating-transformers/FunctionTransformer.ts
  62. 9 7
      src/node-transformers/obfuscating-transformers/LabeledStatementTransformer.ts
  63. 4 4
      src/node-transformers/obfuscating-transformers/LiteralTransformer.ts
  64. 3 3
      src/node-transformers/obfuscating-transformers/ObjectExpressionTransformer.ts
  65. 21 16
      src/node-transformers/obfuscating-transformers/VariableDeclarationTransformer.ts
  66. 1 1
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/AbstractObfuscatingReplacer.ts
  67. 5 3
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/identifier-obfuscating-replacers/BaseIdentifierObfuscatingReplacer.ts
  68. 1 1
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/BooleanLiteralObfuscatingReplacer.ts
  69. 1 1
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/NumberLiteralObfuscatingReplacer.ts
  70. 1 10
      src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts
  71. 3 3
      src/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.ts
  72. 3 3
      src/node-transformers/preparing-transformers/ParentificationTransformer.ts
  73. 10 47
      src/node/NodeUtils.ts
  74. 1 1
      src/node/Nodes.ts
  75. 2 2
      src/options/Options.ts
  76. 1 1
      src/source-map/SourceMapCorrector.ts
  77. 1 1
      src/storages/ArrayStorage.ts
  78. 1 1
      src/storages/MapStorage.ts
  79. 1 1
      src/storages/control-flow/ControlFlowStorage.ts
  80. 1 10
      src/storages/custom-node-group/CustomNodeGroupStorage.ts
  81. 1 1
      src/storages/string-array/StringArrayStorage.ts
  82. 4 4
      src/templates/GlobalVariableTemplate1.ts
  83. 4 4
      src/templates/GlobalVariableTemplate2.ts
  84. 1 1
      src/templates/SingleNodeCallControllerTemplate.ts
  85. 6 6
      src/templates/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate.ts
  86. 1 1
      src/templates/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate.ts
  87. 1 1
      src/templates/debug-protection-nodes/debug-protection-function-node/DebuggerTemplate.ts
  88. 1 1
      src/templates/debug-protection-nodes/debug-protection-function-node/DebuggerTemplateNoEval.ts
  89. 1 1
      src/templates/domain-lock-nodes/domain-lock-node/DomainLockNodeTemplate.ts
  90. 2 2
      src/templates/string-array-nodes/string-array-calls-wrapper/StringArrayBase64DecodeNodeTemplate.ts
  91. 4 4
      src/templates/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate.ts
  92. 1 1
      src/utils/ArrayUtils.ts
  93. 1 1
      src/utils/CryptUtils.ts
  94. 2 4
      test/functional-tests/cli/JavaScriptObfuscatorCLI.spec.ts
  95. 12 1
      test/unit-tests/cli/sanitizers/ArraySanitizer.spec.ts
  96. 14 3
      tslint.json
  97. 2 2
      webpack.config.js
  98. 263 207
      yarn.lock

+ 1 - 0
.travis.yml

@@ -7,6 +7,7 @@ node_js:
   - "5"
   - "5"
   - "6"
   - "6"
   - "7"
   - "7"
+  - "9"
   - "stable"
   - "stable"
 
 
 cache:
 cache:

+ 4 - 0
CHANGELOG.md

@@ -1,5 +1,9 @@
 Change Log
 Change Log
 ===
 ===
+v0.12.1
+---
+* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/117
+
 v0.12.0
 v0.12.0
 ---
 ---
 * **New option:** `target` allows to set target environment for obfuscated code.
 * **New option:** `target` allows to set target environment for obfuscated code.

文件差异内容过多而无法显示
+ 0 - 0
dist/index.js


+ 13 - 14
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "javascript-obfuscator",
   "name": "javascript-obfuscator",
-  "version": "0.12.0",
+  "version": "0.12.1",
   "description": "JavaScript obfuscator",
   "description": "JavaScript obfuscator",
   "keywords": [
   "keywords": [
     "obfuscator",
     "obfuscator",
@@ -19,15 +19,15 @@
     "javascript-obfuscator": "./bin/javascript-obfuscator.js"
     "javascript-obfuscator": "./bin/javascript-obfuscator.js"
   },
   },
   "dependencies": {
   "dependencies": {
-    "chalk": "2.2.0",
-    "chance": "1.0.11",
+    "chalk": "2.3.0",
+    "chance": "1.0.12",
     "class-validator": "0.7.3",
     "class-validator": "0.7.3",
     "commander": "2.11.0",
     "commander": "2.11.0",
     "escodegen-wallaby": "1.6.12",
     "escodegen-wallaby": "1.6.12",
     "esmangle": "1.0.1",
     "esmangle": "1.0.1",
     "esprima": "4.0.0",
     "esprima": "4.0.0",
     "estraverse": "4.2.0",
     "estraverse": "4.2.0",
-    "inversify": "4.3.0",
+    "inversify": "4.5.0",
     "md5": "2.2.1",
     "md5": "2.2.1",
     "mkdirp": "0.5.1",
     "mkdirp": "0.5.1",
     "opencollective": "1.0.3",
     "opencollective": "1.0.3",
@@ -38,7 +38,6 @@
   },
   },
   "devDependencies": {
   "devDependencies": {
     "@types/chai": "4.0.4",
     "@types/chai": "4.0.4",
-    "@types/chalk": "0.4.31",
     "@types/chance": "0.7.35",
     "@types/chance": "0.7.35",
     "@types/commander": "2.11.0",
     "@types/commander": "2.11.0",
     "@types/escodegen": "0.0.6",
     "@types/escodegen": "0.0.6",
@@ -47,28 +46,28 @@
     "@types/estree": "0.0.38",
     "@types/estree": "0.0.38",
     "@types/md5": "2.1.32",
     "@types/md5": "2.1.32",
     "@types/mkdirp": "0.5.1",
     "@types/mkdirp": "0.5.1",
-    "@types/mocha": "2.2.43",
-    "@types/node": "8.0.44",
-    "@types/sinon": "2.3.6",
+    "@types/mocha": "2.2.44",
+    "@types/node": "8.0.47",
+    "@types/sinon": "2.3.7",
     "@types/string-template": "1.0.2",
     "@types/string-template": "1.0.2",
     "@types/webpack-env": "1.13.2",
     "@types/webpack-env": "1.13.2",
-    "awesome-typescript-loader": "3.2.3",
+    "awesome-typescript-loader": "3.3.0",
     "babel-cli": "6.26.0",
     "babel-cli": "6.26.0",
     "babel-loader": "7.1.2",
     "babel-loader": "7.1.2",
     "babel-plugin-array-includes": "2.0.3",
     "babel-plugin-array-includes": "2.0.3",
     "babel-preset-es2015": "6.24.1",
     "babel-preset-es2015": "6.24.1",
     "chai": "4.1.2",
     "chai": "4.1.2",
-    "coveralls": "3.0.0",
+    "coveralls": "2.13.3",
     "istanbul": "1.1.0-alpha.1",
     "istanbul": "1.1.0-alpha.1",
     "mocha": "4.0.1",
     "mocha": "4.0.1",
     "pre-commit": "1.2.2",
     "pre-commit": "1.2.2",
-    "sinon": "4.0.1",
+    "sinon": "4.1.1",
     "ts-node": "3.3.0",
     "ts-node": "3.3.0",
-    "tslint": "5.7.0",
+    "tslint": "5.8.0",
     "tslint-eslint-rules": "4.1.1",
     "tslint-eslint-rules": "4.1.1",
-    "tslint-language-service": "^0.9.6",
+    "tslint-language-service": "0.9.6",
     "tslint-webpack-plugin": "1.0.0",
     "tslint-webpack-plugin": "1.0.0",
-    "typescript": "2.5.3",
+    "typescript": "2.6.1",
     "webpack": "3.8.1",
     "webpack": "3.8.1",
     "webpack-node-externals": "1.6.0"
     "webpack-node-externals": "1.6.0"
   },
   },

+ 1 - 1
scripts/tslint

@@ -1,3 +1,3 @@
 #!/bin/bash
 #!/bin/bash
 
 
-$(yarn bin)/tslint src/**/*.ts --type-check --project tsconfig.json
+$(yarn bin)/tslint src/**/*.ts --project tsconfig.json

+ 1 - 1
src/JavaScriptObfuscator.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from './container/ServiceIdentifiers';
 import { ServiceIdentifiers } from './container/ServiceIdentifiers';
 
 
 import * as esprima from 'esprima';
 import * as esprima from 'esprima';

+ 1 - 1
src/analyzers/stack-trace-analyzer/StackTraceAnalyzer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';

+ 2 - 1
src/analyzers/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts

@@ -49,9 +49,10 @@ export class FunctionExpressionCalleeDataExtractor extends AbstractCalleeDataExt
         let calleeBlockStatement: ESTree.BlockStatement | null = null;
         let calleeBlockStatement: ESTree.BlockStatement | null = null;
 
 
         estraverse.traverse(targetNode, {
         estraverse.traverse(targetNode, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
                 if (
                 if (
                     NodeGuards.isFunctionExpressionNode(node) &&
                     NodeGuards.isFunctionExpressionNode(node) &&
+                    parentNode &&
                     NodeGuards.isVariableDeclaratorNode(parentNode) &&
                     NodeGuards.isVariableDeclaratorNode(parentNode) &&
                     NodeGuards.isIdentifierNode(parentNode.id) &&
                     NodeGuards.isIdentifierNode(parentNode.id) &&
                     parentNode.id.name === name
                     parentNode.id.name === name

+ 1 - 1
src/analyzers/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts

@@ -101,7 +101,7 @@ export class ObjectExpressionCalleeDataExtractor extends AbstractCalleeDataExtra
         let calleeBlockStatement: ESTree.BlockStatement | null = null;
         let calleeBlockStatement: ESTree.BlockStatement | null = null;
 
 
         estraverse.traverse(targetNode, {
         estraverse.traverse(targetNode, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
+            enter: (node: ESTree.Node): any => {
                 if (
                 if (
                     NodeGuards.isVariableDeclaratorNode(node) &&
                     NodeGuards.isVariableDeclaratorNode(node) &&
                     NodeGuards.isIdentifierNode(node.id) &&
                     NodeGuards.isIdentifierNode(node.id) &&

+ 2 - 2
src/cli/JavaScriptObfuscatorCLI.ts

@@ -234,7 +234,7 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 BooleanSanitizer
                 BooleanSanitizer
             )
             )
             .option(
             .option(
-                '--domainLock \'<list>\' (comma separated)',
+                '--domainLock <list> (comma separated, without whitespaces)',
                 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)',
                 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)',
                 ArraySanitizer
                 ArraySanitizer
             )
             )
@@ -247,7 +247,7 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 BooleanSanitizer
                 BooleanSanitizer
             )
             )
             .option(
             .option(
-                '--reservedNames \'<list>\' (comma separated)',
+                '--reservedNames <list> (comma separated, without whitespaces)',
                 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)',
                 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)',
                 ArraySanitizer
                 ArraySanitizer
             )
             )

+ 4 - 0
src/cli/sanitizers/ArraySanitizer.ts

@@ -5,5 +5,9 @@ import { TCLISanitizer } from '../../types/cli/TCLISanitizer';
  * @returns {string[]}
  * @returns {string[]}
  */
  */
 export const ArraySanitizer: TCLISanitizer = (value: string): string[] => {
 export const ArraySanitizer: TCLISanitizer = (value: string): string[] => {
+    if (/,$/.test(value)) {
+        throw new SyntaxError(`Multiple <list> values should be wrapped inside quotes: --optionName 'value1, value2'`);
+    }
+
     return value.split(',').map((string: string) => string.trim());
     return value.split(',').map((string: string) => string.trim());
 };
 };

+ 1 - 1
src/custom-nodes/AbstractCustomNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import { TStatement } from '../types/node/TStatement';
 import { TStatement } from '../types/node/TStatement';

+ 1 - 1
src/custom-nodes/AbstractCustomNodeGroup.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement';
 import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement';

+ 1 - 1
src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';

+ 1 - 10
src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts

@@ -1,11 +1,10 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
-import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
@@ -36,27 +35,19 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
      */
      */
     private readonly customNodeFactory: TCustomNodeFactory;
     private readonly customNodeFactory: TCustomNodeFactory;
 
 
-    /**
-     * @type {IObfuscationEventEmitter}
-     */
-    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
-
     /**
     /**
      * @param {TCustomNodeFactory} customNodeFactory
      * @param {TCustomNodeFactory} customNodeFactory
-     * @param {IObfuscationEventEmitter} obfuscationEventEmitter
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
      * @param {IOptions} options
      * @param {IOptions} options
      */
      */
     constructor (
     constructor (
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
-        @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
     ) {
         super(randomGenerator, options);
         super(randomGenerator, options);
 
 
         this.customNodeFactory = customNodeFactory;
         this.customNodeFactory = customNodeFactory;
-        this.obfuscationEventEmitter = obfuscationEventEmitter;
     }
     }
 
 
     /**
     /**

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import { BinaryOperator } from 'estree';
 import { BinaryOperator } from 'estree';

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import { LogicalOperator } from 'estree';
 import { LogicalOperator } from 'estree';

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/StringLiteralNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import { TStatement } from '../../types/node/TStatement';
 import { TStatement } from '../../types/node/TStatement';

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 2 - 2
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -51,7 +51,7 @@ export class ControlFlowStorageNode extends AbstractCustomNode {
                 Nodes.getIdentifierNode(this.controlFlowStorage.getStorageId()),
                 Nodes.getIdentifierNode(this.controlFlowStorage.getStorageId()),
                 Nodes.getObjectExpressionNode(
                 Nodes.getObjectExpressionNode(
                     Array
                     Array
-                        .from(this.controlFlowStorage.getStorage())
+                        .from<[string, ICustomNode]>(this.controlFlowStorage.getStorage())
                         .map(([key, value]: [string, ICustomNode]) => {
                         .map(([key, value]: [string, ICustomNode]) => {
                             return Nodes.getPropertyNode(
                             return Nodes.getPropertyNode(
                                 Nodes.getIdentifierNode(key),
                                 Nodes.getIdentifierNode(key),

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { Expression } from 'estree';
 import { Expression } from 'estree';

+ 1 - 1
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TStatement } from '../../../types/node/TStatement';
 import { TStatement } from '../../../types/node/TStatement';

+ 1 - 1
src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';

+ 1 - 1
src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';

+ 1 - 1
src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';

+ 1 - 10
src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts

@@ -1,11 +1,10 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
-import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
@@ -36,27 +35,19 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
      */
      */
     private readonly customNodeFactory: TCustomNodeFactory;
     private readonly customNodeFactory: TCustomNodeFactory;
 
 
-    /**
-     * @type {IObfuscationEventEmitter}
-     */
-    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
-
     /**
     /**
      * @param {TCustomNodeFactory} customNodeFactory
      * @param {TCustomNodeFactory} customNodeFactory
-     * @param {IObfuscationEventEmitter} obfuscationEventEmitter
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
      * @param {IOptions} options
      * @param {IOptions} options
      */
      */
     constructor (
     constructor (
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
-        @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
     ) {
         super(randomGenerator, options);
         super(randomGenerator, options);
 
 
         this.customNodeFactory = customNodeFactory;
         this.customNodeFactory = customNodeFactory;
-        this.obfuscationEventEmitter = obfuscationEventEmitter;
     }
     }
 
 
     /**
     /**

+ 1 - 1
src/custom-nodes/domain-lock-nodes/DomainLockNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';

+ 1 - 10
src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts

@@ -1,11 +1,10 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
-import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
@@ -36,27 +35,19 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
      */
      */
     private readonly customNodeFactory: TCustomNodeFactory;
     private readonly customNodeFactory: TCustomNodeFactory;
 
 
-    /**
-     * @type {IObfuscationEventEmitter}
-     */
-    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
-
     /**
     /**
      * @param {TCustomNodeFactory} customNodeFactory
      * @param {TCustomNodeFactory} customNodeFactory
-     * @param {IObfuscationEventEmitter} obfuscationEventEmitter
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
      * @param {IOptions} options
      * @param {IOptions} options
      */
      */
     constructor (
     constructor (
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
-        @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
     ) {
         super(randomGenerator, options);
         super(randomGenerator, options);
 
 
         this.customNodeFactory = customNodeFactory;
         this.customNodeFactory = customNodeFactory;
-        this.obfuscationEventEmitter = obfuscationEventEmitter;
     }
     }
 
 
     /**
     /**

+ 1 - 1
src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';

+ 1 - 1
src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';

+ 1 - 10
src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts

@@ -1,11 +1,10 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
-import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
@@ -36,27 +35,19 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
      */
      */
     private readonly customNodeFactory: TCustomNodeFactory;
     private readonly customNodeFactory: TCustomNodeFactory;
 
 
-    /**
-     * @type {IObfuscationEventEmitter}
-     */
-    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
-
     /**
     /**
      * @param {TCustomNodeFactory} customNodeFactory
      * @param {TCustomNodeFactory} customNodeFactory
-     * @param {IObfuscationEventEmitter} obfuscationEventEmitter
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
      * @param {IOptions} options
      * @param {IOptions} options
      */
      */
     constructor (
     constructor (
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
-        @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
     ) {
         super(randomGenerator, options);
         super(randomGenerator, options);
 
 
         this.customNodeFactory = customNodeFactory;
         this.customNodeFactory = customNodeFactory;
-        this.obfuscationEventEmitter = obfuscationEventEmitter;
     }
     }
 
 
     /**
     /**

+ 1 - 11
src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';
@@ -8,7 +8,6 @@ import { TStatement } from '../../types/node/TStatement';
 import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
 import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
-import { IStorage } from '../../interfaces/storages/IStorage';
 
 
 import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
 import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
 import { StringArrayEncoding } from '../../enums/StringArrayEncoding';
 import { StringArrayEncoding } from '../../enums/StringArrayEncoding';
@@ -36,12 +35,6 @@ export class StringArrayCallsWrapper extends AbstractCustomNode {
      */
      */
     private readonly escapeSequenceEncoder: IEscapeSequenceEncoder;
     private readonly escapeSequenceEncoder: IEscapeSequenceEncoder;
 
 
-    /**
-     * @type {IStorage <string>}
-     */
-    @initializable()
-    private stringArrayStorage: IStorage <string>;
-
     /**
     /**
      * @type {string}
      * @type {string}
      */
      */
@@ -70,16 +63,13 @@ export class StringArrayCallsWrapper extends AbstractCustomNode {
     }
     }
 
 
     /**
     /**
-     * @param {IStorage<string>} stringArrayStorage
      * @param {string} stringArrayName
      * @param {string} stringArrayName
      * @param {string} stringArrayCallsWrapperName
      * @param {string} stringArrayCallsWrapperName
      */
      */
     public initialize (
     public initialize (
-        stringArrayStorage: IStorage <string>,
         stringArrayName: string,
         stringArrayName: string,
         stringArrayCallsWrapperName: string
         stringArrayCallsWrapperName: string
     ): void {
     ): void {
-        this.stringArrayStorage = stringArrayStorage;
         this.stringArrayName = stringArrayName;
         this.stringArrayName = stringArrayName;
         this.stringArrayCallsWrapperName = stringArrayCallsWrapperName;
         this.stringArrayCallsWrapperName = stringArrayCallsWrapperName;
     }
     }

+ 1 - 1
src/custom-nodes/string-array-nodes/StringArrayNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';

+ 1 - 11
src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as format from 'string-template';
 import * as format from 'string-template';
@@ -8,7 +8,6 @@ import { TStatement } from '../../types/node/TStatement';
 import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
 import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
-import { IStorage } from '../../interfaces/storages/IStorage';
 
 
 import { initializable } from '../../decorators/Initializable';
 import { initializable } from '../../decorators/Initializable';
 
 
@@ -29,12 +28,6 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode {
      */
      */
     private readonly escapeSequenceEncoder: IEscapeSequenceEncoder;
     private readonly escapeSequenceEncoder: IEscapeSequenceEncoder;
 
 
-    /**
-     * @type {IStorage <string>}
-     */
-    @initializable()
-    private stringArrayStorage: IStorage <string>;
-
     /**
     /**
      * @type {string}
      * @type {string}
      */
      */
@@ -63,16 +56,13 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode {
     }
     }
 
 
     /**
     /**
-     * @param {IStorage<string>} stringArrayStorage
      * @param {string} stringArrayName
      * @param {string} stringArrayName
      * @param {number} stringArrayRotateValue
      * @param {number} stringArrayRotateValue
      */
      */
     public initialize (
     public initialize (
-        stringArrayStorage: IStorage <string>,
         stringArrayName: string,
         stringArrayName: string,
         stringArrayRotateValue: number
         stringArrayRotateValue: number
     ): void {
     ): void {
-        this.stringArrayStorage = stringArrayStorage;
         this.stringArrayName = stringArrayName;
         this.stringArrayName = stringArrayName;
         this.stringArrayRotateValue = stringArrayRotateValue;
         this.stringArrayRotateValue = stringArrayRotateValue;
     }
     }

+ 3 - 12
src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts

@@ -1,11 +1,10 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
 
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
-import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
 import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
@@ -38,11 +37,6 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
      */
      */
     private readonly customNodeFactory: TCustomNodeFactory;
     private readonly customNodeFactory: TCustomNodeFactory;
 
 
-    /**
-     * @type {IObfuscationEventEmitter}
-     */
-    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
-
     /**
     /**
      * @type {IStorage <string>}
      * @type {IStorage <string>}
      */
      */
@@ -51,14 +45,12 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
     /**
     /**
      * @param {TCustomNodeFactory} customNodeFactory
      * @param {TCustomNodeFactory} customNodeFactory
-     * @param {IObfuscationEventEmitter} obfuscationEventEmitter
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
      * @param {IStorage<string>} stringArrayStorage
      * @param {IStorage<string>} stringArrayStorage
      * @param {IOptions} options
      * @param {IOptions} options
      */
      */
     constructor (
     constructor (
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
         @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
-        @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.TStringArrayStorage) stringArrayStorage: IStorage<string>,
         @inject(ServiceIdentifiers.TStringArrayStorage) stringArrayStorage: IStorage<string>,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
         @inject(ServiceIdentifiers.IOptions) options: IOptions
@@ -66,7 +58,6 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
         super(randomGenerator, options);
         super(randomGenerator, options);
 
 
         this.customNodeFactory = customNodeFactory;
         this.customNodeFactory = customNodeFactory;
-        this.obfuscationEventEmitter = obfuscationEventEmitter;
         this.stringArrayStorage = stringArrayStorage;
         this.stringArrayStorage = stringArrayStorage;
     }
     }
 
 
@@ -120,8 +111,8 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
         }
         }
 
 
         stringArrayNode.initialize(this.stringArrayStorage, stringArrayName, stringArrayRotateValue);
         stringArrayNode.initialize(this.stringArrayStorage, stringArrayName, stringArrayRotateValue);
-        stringArrayCallsWrapper.initialize(this.stringArrayStorage, stringArrayName, stringArrayCallsWrapperName);
-        stringArrayRotateFunctionNode.initialize(this.stringArrayStorage, stringArrayName, stringArrayRotateValue);
+        stringArrayCallsWrapper.initialize(stringArrayName, stringArrayCallsWrapperName);
+        stringArrayRotateFunctionNode.initialize(stringArrayName, stringArrayRotateValue);
 
 
         this.customNodes.set(CustomNode.StringArrayNode, stringArrayNode);
         this.customNodes.set(CustomNode.StringArrayNode, stringArrayNode);
         this.customNodes.set(CustomNode.StringArrayCallsWrapper, stringArrayCallsWrapper);
         this.customNodes.set(CustomNode.StringArrayCallsWrapper, stringArrayCallsWrapper);

+ 2 - 1
src/decorators/Initializable.ts

@@ -19,7 +19,8 @@ export function initializable (
         const initializeMethod: Function = target[initializeMethodKey];
         const initializeMethod: Function = target[initializeMethodKey];
 
 
         if (!initializeMethod || typeof initializeMethod !== 'function') {
         if (!initializeMethod || typeof initializeMethod !== 'function') {
-            throw new Error(`\`${initializeMethodKey}\` method with initialization logic not found. \`@${decoratorName}\` decorator requires \`${initializeMethodKey}\` method`);
+            throw new Error(`\`${initializeMethodKey}\` method with initialization logic not ` +
+                `found. \`@${decoratorName}\` decorator requires \`${initializeMethodKey}\` method`);
         }
         }
 
 
         const metadataPropertyKey: string = `_${propertyKey}`;
         const metadataPropertyKey: string = `_${propertyKey}`;

+ 4 - 4
src/interfaces/node-transformers/INodeTransformer.d.ts

@@ -11,14 +11,14 @@ export interface INodeTransformer {
 
 
     /**
     /**
      * @param {Node} node
      * @param {Node} node
-     * @param {Node} parentNode
+     * @param {Node | null} parentNode
      */
      */
-    analyzeNode ? (node: ESTree.Node, parentNode: ESTree.Node): void;
+    analyzeNode ? (node: ESTree.Node, parentNode: ESTree.Node | null): void;
 
 
     /**
     /**
      * @param {Node} node
      * @param {Node} node
-     * @param {Node} parentNode
+     * @param {Node | null} parentNode
      * @returns {Node | VisitorOption}
      * @returns {Node | VisitorOption}
      */
      */
-    transformNode (node: ESTree.Node, parentNode: ESTree.Node): ESTree.Node | estraverse.VisitorOption;
+    transformNode (node: ESTree.Node, parentNode: ESTree.Node | null): ESTree.Node | estraverse.VisitorOption;
 }
 }

+ 3 - 3
src/interfaces/node-transformers/IVisitor.d.ts

@@ -1,7 +1,7 @@
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-export interface IVisitor {
-    enter?: (node: ESTree.Node, parentNode: ESTree.Node | null) => ESTree.Node | estraverse.VisitorOption | void;
-    leave?: (node: ESTree.Node, parentNode: ESTree.Node | null) => ESTree.Node | estraverse.VisitorOption | void;
+export interface IVisitor <T extends ESTree.Node = ESTree.Node> {
+    enter?: (node: T, parentNode: ESTree.Node | null) => ESTree.Node | estraverse.VisitorOption | void;
+    leave?: (node: T, parentNode: ESTree.Node | null) => ESTree.Node | estraverse.VisitorOption | void;
 }
 }

+ 1 - 1
src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer.d.ts

@@ -5,7 +5,7 @@ import { IObfuscatingReplacer } from './IObfuscatingReplacer';
 export interface IIdentifierObfuscatingReplacer extends IObfuscatingReplacer <ESTree.Identifier> {
 export interface IIdentifierObfuscatingReplacer extends IObfuscatingReplacer <ESTree.Identifier> {
     /**
     /**
      * @param nodeValue
      * @param nodeValue
-     * @param nodeIdentifier
+     * @param {number} nodeIdentifier
      */
      */
     storeNames (nodeValue: any, nodeIdentifier: number): void;
     storeNames (nodeValue: any, nodeIdentifier: number): void;
 }
 }

+ 2 - 1
src/interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IObfuscatingReplacer.d.ts

@@ -3,7 +3,8 @@ import * as ESTree from 'estree';
 export interface IObfuscatingReplacer <T = ESTree.Node> {
 export interface IObfuscatingReplacer <T = ESTree.Node> {
     /**
     /**
      * @param nodeValue
      * @param nodeValue
-     * @param nodeIdentifier
+     * @param {number} nodeIdentifier
+     * @returns {T}
      */
      */
     replace (nodeValue: any, nodeIdentifier?: number): T;
     replace (nodeValue: any, nodeIdentifier?: number): T;
 }
 }

+ 1 - 1
src/logger/Logger.ts

@@ -1,4 +1,4 @@
-import { injectable, inject, postConstruct } from 'inversify';
+import { inject, injectable, postConstruct } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import chalk, { Chalk } from 'chalk';
 import chalk, { Chalk } from 'chalk';

+ 1 - 1
src/node-transformers/AbstractNodeTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject, postConstruct } from 'inversify';
+import { inject, injectable, postConstruct } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';

+ 3 - 3
src/node-transformers/TransformersRunner.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -81,10 +81,10 @@ export class TransformersRunner implements ITransformersRunner {
         const visitorsLength: number = visitors.length;
         const visitorsLength: number = visitors.length;
 
 
         if (!visitorsLength) {
         if (!visitorsLength) {
-            return (node: ESTree.Node, parentNode: ESTree.Node) => node;
+            return (node: ESTree.Node, parentNode: ESTree.Node | null) => node;
         }
         }
 
 
-        return (node: ESTree.Node, parentNode: ESTree.Node) => {
+        return (node: ESTree.Node, parentNode: ESTree.Node | null) => {
             if (node.ignoredNode) {
             if (node.ignoredNode) {
                 return estraverse.VisitorOption.Skip;
                 return estraverse.VisitorOption.Skip;
             }
             }

+ 3 - 3
src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -96,8 +96,8 @@ export class BlockStatementControlFlowTransformer extends AbstractNodeTransforme
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            leave: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isBlockStatementNode(node)) {
+            leave: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isBlockStatementNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }

+ 9 - 7
src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -105,11 +105,13 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            leave: (node: ESTree.Node, parentNode: ESTree.Node) => {
+            leave: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
                 if (
                 if (
-                    NodeGuards.isFunctionDeclarationNode(node) ||
-                    NodeGuards.isFunctionExpressionNode(node) ||
-                    NodeGuards.isArrowFunctionExpressionNode(node)
+                    parentNode && (
+                        NodeGuards.isFunctionDeclarationNode(node) ||
+                        NodeGuards.isFunctionExpressionNode(node) ||
+                        NodeGuards.isArrowFunctionExpressionNode(node)
+                    )
                 ) {
                 ) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
@@ -212,8 +214,8 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer {
      */
      */
     private transformFunctionBody (functionNodeBody: ESTree.BlockStatement, controlFlowStorage: IStorage<ICustomNode>): void {
     private transformFunctionBody (functionNodeBody: ESTree.BlockStatement, controlFlowStorage: IStorage<ICustomNode>): void {
         estraverse.replace(functionNodeBody, {
         estraverse.replace(functionNodeBody, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (this.isVisitedFunctionNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
+                if (this.isVisitedFunctionNode(node) || !parentNode) {
                     return estraverse.VisitorOption.Skip;
                     return estraverse.VisitorOption.Skip;
                 }
                 }
 
 

+ 1 - 1
src/node-transformers/control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 1
src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 1
src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 1
src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 1
src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 1
src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 3 - 3
src/node-transformers/converting-transformers/MemberExpressionTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -30,8 +30,8 @@ export class MemberExpressionTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isMemberExpressionNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isMemberExpressionNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }

+ 3 - 3
src/node-transformers/converting-transformers/MethodDefinitionTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -44,8 +44,8 @@ export class MethodDefinitionTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isMethodDefinitionNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isMethodDefinitionNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }

+ 3 - 3
src/node-transformers/converting-transformers/TemplateLiteralTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -41,8 +41,8 @@ export class TemplateLiteralTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isTemplateLiteralNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isTemplateLiteralNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }

+ 12 - 11
src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -55,15 +55,15 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isProgramNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isProgramNode(node)) {
                     this.analyzeNode(node, parentNode);
                     this.analyzeNode(node, parentNode);
 
 
                     return node;
                     return node;
                 }
                 }
             },
             },
-            leave: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isBlockStatementNode(node)) {
+            leave: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isBlockStatementNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }
@@ -91,10 +91,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
      * @param {NodeGuards} parentNode
      * @param {NodeGuards} parentNode
      * @returns {NodeGuards | VisitorOption}
      * @returns {NodeGuards | VisitorOption}
      */
      */
-    public transformNode (
-        blockStatementNode: ESTree.BlockStatement,
-        parentNode: ESTree.Node
-    ): ESTree.Node | estraverse.VisitorOption {
+    public transformNode (blockStatementNode: ESTree.BlockStatement, parentNode: ESTree.Node): ESTree.Node | estraverse.VisitorOption {
         if (this.collectedBlockStatementsLength < DeadCodeInjectionTransformer.minCollectedBlockStatementsCount) {
         if (this.collectedBlockStatementsLength < DeadCodeInjectionTransformer.minCollectedBlockStatementsCount) {
             return estraverse.VisitorOption.Break;
             return estraverse.VisitorOption.Break;
         }
         }
@@ -140,7 +137,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
             isValidBlockStatementNode: boolean = true;
             isValidBlockStatementNode: boolean = true;
 
 
         estraverse.replace(clonedBlockStatementNode, {
         estraverse.replace(clonedBlockStatementNode, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
                 /**
                 /**
                  * First step: count nested block statements in current block statement
                  * First step: count nested block statements in current block statement
                  */
                  */
@@ -166,7 +163,11 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
                  * Second step: rename all identifiers (except identifiers in member expressions)
                  * Second step: rename all identifiers (except identifiers in member expressions)
                  * in current block statement
                  * in current block statement
                  */
                  */
-                if (NodeGuards.isIdentifierNode(node) && !NodeGuards.isMemberExpressionNode(parentNode)) {
+                if (
+                    NodeGuards.isIdentifierNode(node) &&
+                    parentNode &&
+                    !NodeGuards.isMemberExpressionNode(parentNode)
+                ) {
                     node.name = this.randomGenerator.getRandomVariableName(6);
                     node.name = this.randomGenerator.getRandomVariableName(6);
                 }
                 }
 
 

+ 7 - 6
src/node-transformers/obfuscating-transformers/CatchClauseTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -54,8 +54,8 @@ export class CatchClauseTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isCatchClauseNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isCatchClauseNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }
@@ -92,9 +92,10 @@ export class CatchClauseTransformer extends AbstractNodeTransformer {
      */
      */
     private replaceCatchClauseParam (catchClauseNode: ESTree.CatchClause, nodeIdentifier: number): void {
     private replaceCatchClauseParam (catchClauseNode: ESTree.CatchClause, nodeIdentifier: number): void {
         estraverse.replace(catchClauseNode, {
         estraverse.replace(catchClauseNode, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
-                    const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
+                if (parentNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
+                    const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
+                        .replace(node.name, nodeIdentifier);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {

+ 21 - 19
src/node-transformers/obfuscating-transformers/ClassDeclarationTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -63,8 +63,8 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isClassDeclarationNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isClassDeclarationNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }
@@ -78,20 +78,20 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
      */
      */
     public transformNode (classDeclarationNode: ESTree.ClassDeclaration, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (classDeclarationNode: ESTree.ClassDeclaration, parentNode: ESTree.Node): ESTree.Node {
         const nodeIdentifier: number = this.nodeIdentifier++;
         const nodeIdentifier: number = this.nodeIdentifier++;
-        const blockScopeOfClassDeclarationNode: TNodeWithBlockStatement = NodeUtils
+        const blockScopeNode: TNodeWithBlockStatement = NodeUtils
             .getBlockScopesOfNode(classDeclarationNode)[0];
             .getBlockScopesOfNode(classDeclarationNode)[0];
 
 
-        if (!this.options.renameGlobals && blockScopeOfClassDeclarationNode.type === NodeType.Program) {
+        if (!this.options.renameGlobals && blockScopeNode.type === NodeType.Program) {
             return classDeclarationNode;
             return classDeclarationNode;
         }
         }
 
 
         this.storeClassName(classDeclarationNode, nodeIdentifier);
         this.storeClassName(classDeclarationNode, nodeIdentifier);
 
 
         // check for cached identifiers for current scope node. If exist - loop through them.
         // check for cached identifiers for current scope node. If exist - loop through them.
-        if (this.replaceableIdentifiers.has(blockScopeOfClassDeclarationNode)) {
-            this.replaceScopeCachedIdentifiers(blockScopeOfClassDeclarationNode, nodeIdentifier);
+        if (this.replaceableIdentifiers.has(blockScopeNode)) {
+            this.replaceScopeCachedIdentifiers(blockScopeNode, nodeIdentifier);
         } else {
         } else {
-            this.replaceScopeIdentifiers(blockScopeOfClassDeclarationNode, nodeIdentifier);
+            this.replaceScopeIdentifiers(blockScopeNode, nodeIdentifier);
         }
         }
 
 
         return classDeclarationNode;
         return classDeclarationNode;
@@ -106,30 +106,32 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
     }
     }
 
 
     /**
     /**
-     * @param {NodeGuards} scopeNode
+     * @param {TNodeWithBlockStatement} blockScopeNode
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      */
      */
-    private replaceScopeCachedIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
-        const cachedReplaceableIdentifiers: ESTree.Identifier[] = <ESTree.Identifier[]>this.replaceableIdentifiers.get(scopeNode);
+    private replaceScopeCachedIdentifiers (blockScopeNode: TNodeWithBlockStatement, nodeIdentifier: number): void {
+        const cachedReplaceableIdentifiers: ESTree.Identifier[] = <ESTree.Identifier[]>this.replaceableIdentifiers.get(blockScopeNode);
 
 
         cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
         cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
-            const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
+            const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
+                .replace(replaceableIdentifier.name, nodeIdentifier);
 
 
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             replaceableIdentifier.name = newReplaceableIdentifier.name;
         });
         });
     }
     }
 
 
     /**
     /**
-     * @param {NodeGuards} scopeNode
+     * @param {TNodeWithBlockStatement} blockScopeNode
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      */
      */
-    private replaceScopeIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
+    private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockStatement, nodeIdentifier: number): void {
         const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
         const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
 
 
-        estraverse.replace(scopeNode, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
-                    const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
+        estraverse.replace(blockScopeNode, {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
+                if (parentNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
+                    const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
+                        .replace(node.name, nodeIdentifier);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {
@@ -141,6 +143,6 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer {
             }
             }
         });
         });
 
 
-        this.replaceableIdentifiers.set(scopeNode, storedReplaceableIdentifiers);
+        this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiers);
     }
     }
 }
 }

+ 21 - 19
src/node-transformers/obfuscating-transformers/FunctionDeclarationTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -63,8 +63,8 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isFunctionDeclarationNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isFunctionDeclarationNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }
@@ -78,20 +78,20 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
      */
      */
     public transformNode (functionDeclarationNode: ESTree.FunctionDeclaration, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (functionDeclarationNode: ESTree.FunctionDeclaration, parentNode: ESTree.Node): ESTree.Node {
         const nodeIdentifier: number = this.nodeIdentifier++;
         const nodeIdentifier: number = this.nodeIdentifier++;
-        const blockScopeOfFunctionDeclarationNode: TNodeWithBlockStatement = NodeUtils
+        const blockScopeNode: TNodeWithBlockStatement = NodeUtils
             .getBlockScopesOfNode(functionDeclarationNode)[0];
             .getBlockScopesOfNode(functionDeclarationNode)[0];
 
 
-        if (!this.options.renameGlobals && blockScopeOfFunctionDeclarationNode.type === NodeType.Program) {
+        if (!this.options.renameGlobals && blockScopeNode.type === NodeType.Program) {
             return functionDeclarationNode;
             return functionDeclarationNode;
         }
         }
 
 
         this.storeFunctionName(functionDeclarationNode, nodeIdentifier);
         this.storeFunctionName(functionDeclarationNode, nodeIdentifier);
 
 
         // check for cached identifiers for current scope node. If exist - loop through them.
         // check for cached identifiers for current scope node. If exist - loop through them.
-        if (this.replaceableIdentifiers.has(blockScopeOfFunctionDeclarationNode)) {
-            this.replaceScopeCachedIdentifiers(blockScopeOfFunctionDeclarationNode, nodeIdentifier);
+        if (this.replaceableIdentifiers.has(blockScopeNode)) {
+            this.replaceScopeCachedIdentifiers(blockScopeNode, nodeIdentifier);
         } else {
         } else {
-            this.replaceScopeIdentifiers(blockScopeOfFunctionDeclarationNode, nodeIdentifier);
+            this.replaceScopeIdentifiers(blockScopeNode, nodeIdentifier);
         }
         }
 
 
         return functionDeclarationNode;
         return functionDeclarationNode;
@@ -106,30 +106,32 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
     }
     }
 
 
     /**
     /**
-     * @param {NodeGuards} scopeNode
+     * @param {TNodeWithBlockStatement} blockScopeNode
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      */
      */
-    private replaceScopeCachedIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
-        const cachedReplaceableIdentifiers: ESTree.Identifier[] = <ESTree.Identifier[]>this.replaceableIdentifiers.get(scopeNode);
+    private replaceScopeCachedIdentifiers (blockScopeNode: TNodeWithBlockStatement, nodeIdentifier: number): void {
+        const cachedReplaceableIdentifiers: ESTree.Identifier[] = <ESTree.Identifier[]>this.replaceableIdentifiers.get(blockScopeNode);
 
 
         cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
         cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
-            const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
+            const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.
+                replace(replaceableIdentifier.name, nodeIdentifier);
 
 
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             replaceableIdentifier.name = newReplaceableIdentifier.name;
         });
         });
     }
     }
 
 
     /**
     /**
-     * @param {NodeGuards} scopeNode
+     * @param {TNodeWithBlockStatement} blockScopeNode
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      */
      */
-    private replaceScopeIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
+    private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockStatement, nodeIdentifier: number): void {
         const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
         const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
 
 
-        estraverse.replace(scopeNode, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
-                    const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
+        estraverse.replace(blockScopeNode, {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
+                if (parentNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
+                    const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
+                        .replace(node.name, nodeIdentifier);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
                     if (node.name !== newIdentifierName) {
                     if (node.name !== newIdentifierName) {
@@ -141,6 +143,6 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer {
             }
             }
         });
         });
 
 
-        this.replaceableIdentifiers.set(scopeNode, storedReplaceableIdentifiers);
+        this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiers);
     }
     }
 }
 }

+ 9 - 7
src/node-transformers/obfuscating-transformers/FunctionTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -54,11 +54,13 @@ export class FunctionTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
                 if (
                 if (
-                    NodeGuards.isFunctionDeclarationNode(node) ||
-                    NodeGuards.isFunctionExpressionNode(node) ||
-                    NodeGuards.isArrowFunctionExpressionNode(node)
+                    parentNode && (
+                        NodeGuards.isFunctionDeclarationNode(node) ||
+                        NodeGuards.isFunctionExpressionNode(node) ||
+                        NodeGuards.isArrowFunctionExpressionNode(node)
+                    )
                 ) {
                 ) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
@@ -113,8 +115,8 @@ export class FunctionTransformer extends AbstractNodeTransformer {
      */
      */
     private replaceFunctionParams (functionNode: ESTree.Function, nodeIdentifier: number): void {
     private replaceFunctionParams (functionNode: ESTree.Function, nodeIdentifier: number): void {
         const replaceVisitor: estraverse.Visitor = {
         const replaceVisitor: estraverse.Visitor = {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
+                if (parentNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 

+ 9 - 7
src/node-transformers/obfuscating-transformers/LabeledStatementTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -62,8 +62,8 @@ export class LabeledStatementTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isLabeledStatementNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isLabeledStatementNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }
@@ -89,7 +89,8 @@ export class LabeledStatementTransformer extends AbstractNodeTransformer {
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      */
      */
     private storeLabeledStatementName (labeledStatementNode: ESTree.LabeledStatement, nodeIdentifier: number): void {
     private storeLabeledStatementName (labeledStatementNode: ESTree.LabeledStatement, nodeIdentifier: number): void {
-        this.identifierObfuscatingReplacer.storeNames(labeledStatementNode.label.name, nodeIdentifier);
+        this.identifierObfuscatingReplacer
+            .storeNames(labeledStatementNode.label.name, nodeIdentifier);
     }
     }
 
 
     /**
     /**
@@ -98,9 +99,10 @@ export class LabeledStatementTransformer extends AbstractNodeTransformer {
      */
      */
     private replaceLabeledStatementName (labeledStatementNode: ESTree.LabeledStatement, nodeIdentifier: number): void {
     private replaceLabeledStatementName (labeledStatementNode: ESTree.LabeledStatement, nodeIdentifier: number): void {
         estraverse.replace(labeledStatementNode, {
         estraverse.replace(labeledStatementNode, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (NodeGuards.isLabelIdentifierNode(node, parentNode)) {
-                    const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
+                if (parentNode && NodeGuards.isLabelIdentifierNode(node, parentNode)) {
+                    const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
+                        .replace(node.name, nodeIdentifier);
 
 
                     node.name = newIdentifier.name;
                     node.name = newIdentifier.name;
                 }
                 }

+ 4 - 4
src/node-transformers/obfuscating-transformers/LiteralTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -42,8 +42,8 @@ export class LiteralTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isLiteralNode(node) && !node.obfuscatedNode) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isLiteralNode(node) && !node.obfuscatedNode) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }
@@ -56,7 +56,7 @@ export class LiteralTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      * @returns {NodeGuards}
      */
      */
     public transformNode (literalNode: ESTree.Literal, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (literalNode: ESTree.Literal, parentNode: ESTree.Node): ESTree.Node {
-        if (NodeGuards.isPropertyNode(parentNode) && parentNode.key === literalNode) {
+        if (parentNode && NodeGuards.isPropertyNode(parentNode) && parentNode.key === literalNode) {
             return literalNode;
             return literalNode;
         }
         }
 
 

+ 3 - 3
src/node-transformers/obfuscating-transformers/ObjectExpressionTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -49,8 +49,8 @@ export class ObjectExpressionTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isObjectExpressionNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isObjectExpressionNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }

+ 21 - 16
src/node-transformers/obfuscating-transformers/VariableDeclarationTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
@@ -64,8 +64,8 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
-                if (NodeGuards.isVariableDeclarationNode(node)) {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                if (parentNode && NodeGuards.isVariableDeclarationNode(node)) {
                     return this.transformNode(node, parentNode);
                     return this.transformNode(node, parentNode);
                 }
                 }
             }
             }
@@ -78,16 +78,16 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
      * @returns {NodeGuards}
      * @returns {NodeGuards}
      */
      */
     public transformNode (variableDeclarationNode: ESTree.VariableDeclaration, parentNode: ESTree.Node): ESTree.Node {
     public transformNode (variableDeclarationNode: ESTree.VariableDeclaration, parentNode: ESTree.Node): ESTree.Node {
-        const blockScopeOfVariableDeclarationNode: TNodeWithBlockStatement = NodeUtils
+        const blockScopeNode: TNodeWithBlockStatement = NodeUtils
             .getBlockScopesOfNode(variableDeclarationNode)[0];
             .getBlockScopesOfNode(variableDeclarationNode)[0];
 
 
-        if (!this.options.renameGlobals && blockScopeOfVariableDeclarationNode.type === NodeType.Program) {
+        if (!this.options.renameGlobals && blockScopeNode.type === NodeType.Program) {
             return variableDeclarationNode;
             return variableDeclarationNode;
         }
         }
 
 
         const nodeIdentifier: number = this.nodeIdentifier++;
         const nodeIdentifier: number = this.nodeIdentifier++;
         const scopeNode: ESTree.Node = variableDeclarationNode.kind === 'var'
         const scopeNode: ESTree.Node = variableDeclarationNode.kind === 'var'
-            ? blockScopeOfVariableDeclarationNode
+            ? blockScopeNode
             : parentNode;
             : parentNode;
 
 
         this.storeVariableNames(variableDeclarationNode, nodeIdentifier);
         this.storeVariableNames(variableDeclarationNode, nodeIdentifier);
@@ -113,36 +113,41 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
                     return estraverse.VisitorOption.Skip;
                     return estraverse.VisitorOption.Skip;
                 }
                 }
 
 
-                NodeUtils.typedTraverse(declarationNode.id, NodeType.Identifier, {
-                    enter: (node: ESTree.Identifier) => this.identifierObfuscatingReplacer.storeNames(node.name, nodeIdentifier)
+                estraverse.traverse(declarationNode.id, {
+                    enter: (node: ESTree.Node) => {
+                        if (NodeGuards.isIdentifierNode(node)) {
+                            this.identifierObfuscatingReplacer.storeNames(node.name, nodeIdentifier);
+                        }
+                    }
                 });
                 });
             });
             });
     }
     }
 
 
     /**
     /**
-     * @param {NodeGuards} scopeNode
+     * @param {Node} scopeNode
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      */
      */
     private replaceScopeCachedIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
     private replaceScopeCachedIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
         const cachedReplaceableIdentifiers: ESTree.Identifier[] = <ESTree.Identifier[]>this.replaceableIdentifiers.get(scopeNode);
         const cachedReplaceableIdentifiers: ESTree.Identifier[] = <ESTree.Identifier[]>this.replaceableIdentifiers.get(scopeNode);
 
 
         cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
         cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => {
-            const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
+            const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
+                .replace(replaceableIdentifier.name, nodeIdentifier);
 
 
             replaceableIdentifier.name = newReplaceableIdentifier.name;
             replaceableIdentifier.name = newReplaceableIdentifier.name;
         });
         });
     }
     }
 
 
     /**
     /**
-     * @param {NodeGuards} scopeNode
+     * @param {NodeGuards} blockScopeNode
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      */
      */
-    private replaceScopeIdentifiers (scopeNode: ESTree.Node, nodeIdentifier: number): void {
+    private replaceScopeIdentifiers (blockScopeNode: ESTree.Node, nodeIdentifier: number): void {
         const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
         const storedReplaceableIdentifiers: ESTree.Identifier[] = [];
 
 
-        estraverse.replace(scopeNode, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (!node.obfuscatedNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
+        estraverse.replace(blockScopeNode, {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => {
+                if (parentNode && !node.obfuscatedNode && NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
                     const newIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
                     const newIdentifierName: string = newIdentifier.name;
                     const newIdentifierName: string = newIdentifier.name;
 
 
@@ -155,6 +160,6 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer {
             }
             }
         });
         });
 
 
-        this.replaceableIdentifiers.set(scopeNode, storedReplaceableIdentifiers);
+        this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiers);
     }
     }
 }
 }

+ 1 - 1
src/node-transformers/obfuscating-transformers/obfuscating-replacers/AbstractObfuscatingReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 5 - 3
src/node-transformers/obfuscating-transformers/obfuscating-replacers/identifier-obfuscating-replacers/BaseIdentifierObfuscatingReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -58,9 +58,11 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac
      * @param {number} nodeIdentifier
      * @param {number} nodeIdentifier
      */
      */
     public storeNames (nodeName: string, nodeIdentifier: number): void {
     public storeNames (nodeName: string, nodeIdentifier: number): void {
-        if (!this.isReservedName(nodeName)) {
-            this.namesMap.set(`${nodeName}-${String(nodeIdentifier)}`, this.randomGenerator.getRandomVariableName(6));
+        if (this.isReservedName(nodeName)) {
+            return;
         }
         }
+
+        this.namesMap.set(`${nodeName}-${String(nodeIdentifier)}`, this.randomGenerator.getRandomVariableName(6));
     }
     }
 
 
     /**
     /**

+ 1 - 1
src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/BooleanLiteralObfuscatingReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 1
src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/NumberLiteralObfuscatingReplacer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';

+ 1 - 10
src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts

@@ -1,10 +1,9 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
 import { ICryptUtils } from '../../../../interfaces/utils/ICryptUtils';
 import { ICryptUtils } from '../../../../interfaces/utils/ICryptUtils';
-import { ICustomNodeGroup } from '../../../../interfaces/custom-nodes/ICustomNodeGroup';
 import { IEncodedValue } from '../../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IEncodedValue';
 import { IEncodedValue } from '../../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/IEncodedValue';
 import { IEscapeSequenceEncoder } from '../../../../interfaces/utils/IEscapeSequenceEncoder';
 import { IEscapeSequenceEncoder } from '../../../../interfaces/utils/IEscapeSequenceEncoder';
 import { IOptions } from '../../../../interfaces/options/IOptions';
 import { IOptions } from '../../../../interfaces/options/IOptions';
@@ -40,11 +39,6 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace
      */
      */
     private readonly cryptUtils: ICryptUtils;
     private readonly cryptUtils: ICryptUtils;
 
 
-    /**
-     * @type {IStorage<ICustomNodeGroup>}
-     */
-    private readonly customNodeGroupStorage: IStorage<ICustomNodeGroup>;
-
     /**
     /**
      * @type {IEscapeSequenceEncoder}
      * @type {IEscapeSequenceEncoder}
      */
      */
@@ -76,7 +70,6 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace
     private readonly stringArrayStorage: IStorage<string>;
     private readonly stringArrayStorage: IStorage<string>;
 
 
     /**
     /**
-     * @param {IStorage<ICustomNodeGroup>} customNodeGroupStorage
      * @param {IStorage<string>} stringArrayStorage
      * @param {IStorage<string>} stringArrayStorage
      * @param {IEscapeSequenceEncoder} escapeSequenceEncoder
      * @param {IEscapeSequenceEncoder} escapeSequenceEncoder
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
@@ -84,7 +77,6 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace
      * @param {IOptions} options
      * @param {IOptions} options
      */
      */
     constructor (
     constructor (
-        @inject(ServiceIdentifiers.TCustomNodeGroupStorage) customNodeGroupStorage: IStorage<ICustomNodeGroup>,
         @inject(ServiceIdentifiers.TStringArrayStorage) stringArrayStorage: IStorage<string>,
         @inject(ServiceIdentifiers.TStringArrayStorage) stringArrayStorage: IStorage<string>,
         @inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder,
         @inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@@ -95,7 +87,6 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace
             options
             options
         );
         );
 
 
-        this.customNodeGroupStorage = customNodeGroupStorage;
         this.stringArrayStorage = stringArrayStorage;
         this.stringArrayStorage = stringArrayStorage;
         this.escapeSequenceEncoder = escapeSequenceEncoder;
         this.escapeSequenceEncoder = escapeSequenceEncoder;
         this.randomGenerator = randomGenerator;
         this.randomGenerator = randomGenerator;

+ 3 - 3
src/node-transformers/preparing-transformers/ObfuscatingGuardsTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -52,7 +52,7 @@ export class ObfuscatingGuardsTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
                 return this.transformNode(node, parentNode);
                 return this.transformNode(node, parentNode);
             }
             }
         };
         };
@@ -63,7 +63,7 @@ export class ObfuscatingGuardsTransformer extends AbstractNodeTransformer {
      * @param {Node} parentNode
      * @param {Node} parentNode
      * @returns {Node}
      * @returns {Node}
      */
      */
-    public transformNode (node: ESTree.Node, parentNode: ESTree.Node): ESTree.Node {
+    public transformNode (node: ESTree.Node, parentNode: ESTree.Node | null): ESTree.Node {
         const obfuscationAllowed: boolean = this.obfuscatingGuards.every((nodeGuard: IObfuscatingGuard) => nodeGuard.check(node));
         const obfuscationAllowed: boolean = this.obfuscatingGuards.every((nodeGuard: IObfuscatingGuard) => nodeGuard.check(node));
 
 
         node.ignoredNode = !obfuscationAllowed;
         node.ignoredNode = !obfuscationAllowed;

+ 3 - 3
src/node-transformers/preparing-transformers/ParentificationTransformer.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
@@ -31,7 +31,7 @@ export class ParentificationTransformer extends AbstractNodeTransformer {
      */
      */
     public getVisitor (): IVisitor {
     public getVisitor (): IVisitor {
         return {
         return {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node) => {
+            enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
                 return this.transformNode(node, parentNode);
                 return this.transformNode(node, parentNode);
             }
             }
         };
         };
@@ -42,7 +42,7 @@ export class ParentificationTransformer extends AbstractNodeTransformer {
      * @param {Node} parentNode
      * @param {Node} parentNode
      * @returns {Node}
      * @returns {Node}
      */
      */
-    public transformNode (node: ESTree.Node, parentNode: ESTree.Node): ESTree.Node {
+    public transformNode (node: ESTree.Node, parentNode: ESTree.Node | null): ESTree.Node {
         return NodeUtils.parentizeNode(node, parentNode);
         return NodeUtils.parentizeNode(node, parentNode);
     }
     }
 }
 }

+ 10 - 47
src/node/NodeUtils.ts

@@ -26,13 +26,15 @@ export class NodeUtils {
      * @param {T} astTree
      * @param {T} astTree
      * @returns {T}
      * @returns {T}
      */
      */
-    public static addXVerbatimPropertyToLiterals <T extends ESTree.Node> (astTree: T): T {
-        NodeUtils.typedReplace(astTree, NodeType.Literal, {
-            leave: (literalNode: ESTree.Literal) => {
-                literalNode['x-verbatim-property'] = {
-                    content : literalNode.raw,
-                    precedence: escodegen.Precedence.Primary
-                };
+    public static addXVerbatimPropertyToLiterals <T extends ESTree.Node = ESTree.Node> (astTree: T): T {
+        estraverse.replace(astTree, {
+            leave: (node: ESTree.Node) => {
+                if (NodeGuards.isLiteralNode(node)) {
+                    node['x-verbatim-property'] = {
+                        content: node.raw,
+                        precedence: escodegen.Precedence.Primary
+                    };
+                }
             }
             }
         });
         });
 
 
@@ -213,49 +215,10 @@ export class NodeUtils {
      * @param {Node} parentNode
      * @param {Node} parentNode
      * @returns {T}
      * @returns {T}
      */
      */
-    public static parentizeNode <T extends ESTree.Node = ESTree.Node> (node: T, parentNode: ESTree.Node): T {
+    public static parentizeNode <T extends ESTree.Node = ESTree.Node> (node: T, parentNode: ESTree.Node | null): T {
         node.parentNode = parentNode || node;
         node.parentNode = parentNode || node;
         node.obfuscatedNode = false;
         node.obfuscatedNode = false;
 
 
         return node;
         return node;
     }
     }
-
-    /**
-     * @param {NodeGuards} astTree
-     * @param {string} nodeType
-     * @param {visitor} visitor
-     */
-    public static typedReplace (
-        astTree: ESTree.Node,
-        nodeType: string,
-        visitor: {enter?: (node: ESTree.Node) => void, leave?: (node: ESTree.Node) => void},
-    ): void {
-        NodeUtils.typedTraverse(astTree, nodeType, visitor, 'replace');
-    }
-
-    /**
-     * @param {NodeGuards} astTree
-     * @param {string} nodeType
-     * @param {Visitor} visitor
-     * @param {string} traverseType
-     */
-    public static typedTraverse (
-        astTree: ESTree.Node,
-        nodeType: string,
-        visitor: estraverse.Visitor,
-        traverseType: string = 'traverse'
-    ): void {
-        (<any>estraverse)[traverseType](astTree, {
-            enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (node.type === nodeType && visitor.enter) {
-                    return visitor.enter(node, parentNode);
-                }
-            },
-            leave: (node: ESTree.Node, parentNode: ESTree.Node): any => {
-                if (node.type === nodeType && visitor.leave) {
-                    return visitor.leave(node, parentNode);
-                }
-            }
-        });
-    }
 }
 }

+ 1 - 1
src/node/Nodes.ts

@@ -343,7 +343,7 @@ export class Nodes {
     /**
     /**
      * @param {UnaryOperator} operator
      * @param {UnaryOperator} operator
      * @param {Expression} argument
      * @param {Expression} argument
-     * @param {boolean} prefix
+     * @param {true} prefix
      * @returns {UnaryExpression}
      * @returns {UnaryExpression}
      */
      */
     public static getUnaryExpressionNode (
     public static getUnaryExpressionNode (

+ 2 - 2
src/options/Options.ts

@@ -2,14 +2,14 @@ import { injectable } from 'inversify';
 
 
 import {
 import {
     ArrayUnique,
     ArrayUnique,
-    IsBoolean,
     IsArray,
     IsArray,
+    IsBoolean,
     IsIn,
     IsIn,
     IsNumber,
     IsNumber,
     IsString,
     IsString,
     IsUrl,
     IsUrl,
-    Min,
     Max,
     Max,
+    Min,
     ValidateIf,
     ValidateIf,
     validateSync,
     validateSync,
     ValidationError,
     ValidationError,

+ 1 - 1
src/source-map/SourceMapCorrector.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import { TObfuscationResultFactory } from '../types/container/TObfuscationResultFactory';
 import { TObfuscationResultFactory } from '../types/container/TObfuscationResultFactory';

+ 1 - 1
src/storages/ArrayStorage.ts

@@ -1,4 +1,4 @@
-import { injectable, inject, postConstruct } from 'inversify';
+import { inject, injectable, postConstruct } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';

+ 1 - 1
src/storages/MapStorage.ts

@@ -1,4 +1,4 @@
-import { injectable, inject, postConstruct } from 'inversify';
+import { inject, injectable, postConstruct } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';

+ 1 - 1
src/storages/control-flow/ControlFlowStorage.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable, } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode';

+ 1 - 10
src/storages/custom-node-group/CustomNodeGroupStorage.ts

@@ -1,10 +1,9 @@
-import { injectable, inject, postConstruct } from 'inversify';
+import { inject, injectable, postConstruct } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import { TCustomNodeGroupFactory } from '../../types/container/custom-nodes/TCustomNodeGroupFactory';
 import { TCustomNodeGroupFactory } from '../../types/container/custom-nodes/TCustomNodeGroupFactory';
 
 
 import { ICustomNodeGroup } from '../../interfaces/custom-nodes/ICustomNodeGroup';
 import { ICustomNodeGroup } from '../../interfaces/custom-nodes/ICustomNodeGroup';
-import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 
 
 import { CustomNodeGroup } from '../../enums/custom-nodes/CustomNodeGroup';
 import { CustomNodeGroup } from '../../enums/custom-nodes/CustomNodeGroup';
@@ -29,25 +28,17 @@ export class CustomNodeGroupStorage extends MapStorage <ICustomNodeGroup> {
      */
      */
     private readonly customNodeGroupFactory: TCustomNodeGroupFactory;
     private readonly customNodeGroupFactory: TCustomNodeGroupFactory;
 
 
-    /**
-     * @type {IOptions}
-     */
-    private readonly options: IOptions;
-
     /**
     /**
      * @param {TCustomNodeGroupFactory} customNodeGroupFactory
      * @param {TCustomNodeGroupFactory} customNodeGroupFactory
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
-     * @param {IOptions} options
      */
      */
     constructor (
     constructor (
         @inject(ServiceIdentifiers.Factory__ICustomNodeGroup) customNodeGroupFactory: TCustomNodeGroupFactory,
         @inject(ServiceIdentifiers.Factory__ICustomNodeGroup) customNodeGroupFactory: TCustomNodeGroupFactory,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
-        @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
     ) {
         super(randomGenerator);
         super(randomGenerator);
 
 
         this.customNodeGroupFactory = customNodeGroupFactory;
         this.customNodeGroupFactory = customNodeGroupFactory;
-        this.options = options;
     }
     }
 
 
     @postConstruct()
     @postConstruct()

+ 1 - 1
src/storages/string-array/StringArrayStorage.ts

@@ -1,4 +1,4 @@
-import { injectable, inject, postConstruct } from 'inversify';
+import { inject, injectable, postConstruct } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
 
 import { IArrayUtils } from '../../interfaces/utils/IArrayUtils';
 import { IArrayUtils } from '../../interfaces/utils/IArrayUtils';

+ 4 - 4
src/templates/GlobalVariableTemplate1.ts

@@ -5,12 +5,12 @@ export function GlobalVariableTemplate1 (): string {
     return `
     return `
         var that;
         var that;
         
         
-        try { 
+        try {
             var getGlobal = Function('return (function() ' + '{}.constructor("return this")( )' + ');');
             var getGlobal = Function('return (function() ' + '{}.constructor("return this")( )' + ');');
             
             
-            that = getGlobal(); 
-        } catch (e) { 
-            that = window; 
+            that = getGlobal();
+        } catch (e) {
+            that = window;
         }
         }
     `;
     `;
 }
 }

+ 4 - 4
src/templates/GlobalVariableTemplate2.ts

@@ -6,10 +6,10 @@ export function GlobalVariableTemplate2 (): string {
         var getGlobal = function () {
         var getGlobal = function () {
             var globalObject;
             var globalObject;
         
         
-            try {                     
-                globalObject = Function('return (function() ' + '{}.constructor("return this")( )' + ');')(); 
-            } catch (e) { 
-                globalObject = window; 
+            try {
+                globalObject = Function('return (function() ' + '{}.constructor("return this")( )' + ');')();
+            } catch (e) {
+                globalObject = window;
             }
             }
             
             
             return globalObject;
             return globalObject;

+ 1 - 1
src/templates/SingleNodeCallControllerTemplate.ts

@@ -6,7 +6,7 @@ export function SingleNodeCallControllerTemplate (): string {
         var {singleNodeCallControllerFunctionName} = (function(){
         var {singleNodeCallControllerFunctionName} = (function(){
             var firstCall = true;
             var firstCall = true;
             
             
-            return function (context, fn){	
+            return function (context, fn){
                 var rfn = firstCall ? function(){
                 var rfn = firstCall ? function(){
                     if(fn){
                     if(fn){
                         var res = fn.apply(context, arguments);
                         var res = fn.apply(context, arguments);

+ 6 - 6
src/templates/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate.ts

@@ -3,28 +3,28 @@
  */
  */
 export function ConsoleOutputDisableExpressionTemplate (): string {
 export function ConsoleOutputDisableExpressionTemplate (): string {
     return `
     return `
-        var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {            
+        var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {
             var func = function () {};
             var func = function () {};
             
             
             {globalVariableTemplate}
             {globalVariableTemplate}
                         
                         
             if (!that.console) {
             if (!that.console) {
-                that.console = (function (func){ 
-                    var c = {}; 
+                that.console = (function (func){
+                    var c = {};
                     
                     
                     c.log = func;
                     c.log = func;
-                    c.warn = func; 
+                    c.warn = func;
                     c.debug = func;
                     c.debug = func;
                     c.info = func;
                     c.info = func;
                     c.error = func;
                     c.error = func;
                     c.exception = func;
                     c.exception = func;
                     c.trace = func;
                     c.trace = func;
                     
                     
-                    return c; 
+                    return c;
                 })(func);
                 })(func);
             } else {
             } else {
                 that.console.log = func;
                 that.console.log = func;
-                that.console.warn = func; 
+                that.console.warn = func;
                 that.console.debug = func;
                 that.console.debug = func;
                 that.console.info = func;
                 that.console.info = func;
                 that.console.error = func;
                 that.console.error = func;

+ 1 - 1
src/templates/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate.ts

@@ -2,7 +2,7 @@
  * @returns {string}
  * @returns {string}
  */
  */
 export function DebugProtectionFunctionTemplate (): string {
 export function DebugProtectionFunctionTemplate (): string {
-    return `     
+    return `
         function {debugProtectionFunctionName} (ret) {
         function {debugProtectionFunctionName} (ret) {
             function debuggerProtection (counter) {
             function debuggerProtection (counter) {
             
             

+ 1 - 1
src/templates/debug-protection-nodes/debug-protection-function-node/DebuggerTemplate.ts

@@ -2,7 +2,7 @@
  * @returns {string}
  * @returns {string}
  */
  */
 export function DebuggerTemplate (): string {
 export function DebuggerTemplate (): string {
-    return `     
+    return `
         if (typeof counter === 'string') {
         if (typeof counter === 'string') {
             return (function (arg) {}.constructor('while (true) {}').apply('counter'));
             return (function (arg) {}.constructor('while (true) {}').apply('counter'));
         } else {
         } else {

+ 1 - 1
src/templates/debug-protection-nodes/debug-protection-function-node/DebuggerTemplateNoEval.ts

@@ -2,7 +2,7 @@
  * @returns {string}
  * @returns {string}
  */
  */
 export function DebuggerTemplateNoEval (): string {
 export function DebuggerTemplateNoEval (): string {
-    return `     
+    return `
         if (typeof counter === 'string') {
         if (typeof counter === 'string') {
             var func = function () {
             var func = function () {
                 while (true) {}
                 while (true) {}

+ 1 - 1
src/templates/domain-lock-nodes/domain-lock-node/DomainLockNodeTemplate.ts

@@ -7,7 +7,7 @@ export function DomainLockNodeTemplate (): string {
             
             
             {globalVariableTemplate}
             {globalVariableTemplate}
             
             
-            var func = function () { 
+            var func = function () {
                 return {
                 return {
                     key: 'item',
                     key: 'item',
                     value: 'attribute',
                     value: 'attribute',

+ 2 - 2
src/templates/string-array-nodes/string-array-calls-wrapper/StringArrayBase64DecodeNodeTemplate.ts

@@ -2,7 +2,7 @@
  * @returns {string}
  * @returns {string}
  */
  */
 export function StringArrayBase64DecodeNodeTemplate (): string {
 export function StringArrayBase64DecodeNodeTemplate (): string {
-    return `      
+    return `
         if ({stringArrayCallsWrapperName}.initialized === undefined) {
         if ({stringArrayCallsWrapperName}.initialized === undefined) {
             {atobPolyfill}
             {atobPolyfill}
             
             
@@ -31,6 +31,6 @@ export function StringArrayBase64DecodeNodeTemplate (): string {
             {stringArrayCallsWrapperName}.data[index] = value;
             {stringArrayCallsWrapperName}.data[index] = value;
         } else {
         } else {
             value = cachedValue;
             value = cachedValue;
-        }  
+        }
     `;
     `;
 }
 }

+ 4 - 4
src/templates/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate.ts

@@ -8,7 +8,7 @@ import { IEscapeSequenceEncoder } from '../../../interfaces/utils/IEscapeSequenc
  */
  */
 export function SelfDefendingTemplate (escapeSequenceEncoder: IEscapeSequenceEncoder): string {
 export function SelfDefendingTemplate (escapeSequenceEncoder: IEscapeSequenceEncoder): string {
     return `
     return `
-        var selfDefendingFunc = function () {            
+        var selfDefendingFunc = function () {
             var object = {
             var object = {
                 data: {
                 data: {
                     key: 'cookie',
                     key: 'cookie',
@@ -21,7 +21,7 @@ export function SelfDefendingTemplate (escapeSequenceEncoder: IEscapeSequenceEnc
 
 
                     var i = 0;
                     var i = 0;
                                                             
                                                             
-                    for (var i = 0, len = options.length; i < len; i++) {                          
+                    for (var i = 0, len = options.length; i < len; i++) {
                         var propName = options[i];
                         var propName = options[i];
                                      
                                      
                         updatedCookie += "; " + propName;
                         updatedCookie += "; " + propName;
@@ -39,7 +39,7 @@ export function SelfDefendingTemplate (escapeSequenceEncoder: IEscapeSequenceEnc
                     document['cookie'] = updatedCookie;
                     document['cookie'] = updatedCookie;
                 },
                 },
                 removeCookie: function(){return 'dev';},
                 removeCookie: function(){return 'dev';},
-                getCookie: function (document, name) {    
+                getCookie: function (document, name) {
                     document = document || function (value) { return value };
                     document = document || function (value) { return value };
                     var matches = document(new RegExp(
                     var matches = document(new RegExp(
                         "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
                         "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
@@ -71,7 +71,7 @@ export function SelfDefendingTemplate (escapeSequenceEncoder: IEscapeSequenceEnc
             if (!result) {
             if (!result) {
                 object['setCookie'](['*'], 'counter', 1);
                 object['setCookie'](['*'], 'counter', 1);
             } else if (result) {
             } else if (result) {
-                cookie = object['getCookie'](null, 'counter');     
+                cookie = object['getCookie'](null, 'counter');
             } else {
             } else {
                 object['removeCookie']();
                 object['removeCookie']();
             }
             }

+ 1 - 1
src/utils/ArrayUtils.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import { IArrayUtils } from '../interfaces/utils/IArrayUtils';
 import { IArrayUtils } from '../interfaces/utils/IArrayUtils';

+ 1 - 1
src/utils/CryptUtils.ts

@@ -1,4 +1,4 @@
-import { injectable, inject } from 'inversify';
+import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
 
 import { ICryptUtils } from '../interfaces/utils/ICryptUtils';
 import { ICryptUtils } from '../interfaces/utils/ICryptUtils';

+ 2 - 4
test/functional-tests/cli/JavaScriptObfuscatorCLI.spec.ts

@@ -482,8 +482,7 @@ describe('JavaScriptObfuscatorCLI', function (): void {
         describe('`--config` option is set but overridden by CLI option', () => {
         describe('`--config` option is set but overridden by CLI option', () => {
             const outputSourceMapPath: string = `${outputFilePath}.map`;
             const outputSourceMapPath: string = `${outputFilePath}.map`;
 
 
-            let isFileExist: boolean,
-                sourceMapObject: any;
+            let isFileExist: boolean;
 
 
             before(() => {
             before(() => {
                 JavaScriptObfuscator.runCLI([
                 JavaScriptObfuscator.runCLI([
@@ -499,10 +498,9 @@ describe('JavaScriptObfuscatorCLI', function (): void {
                 ]);
                 ]);
 
 
                 try {
                 try {
-                    const content: string = fs.readFileSync(outputSourceMapPath, {encoding: 'utf8'});
+                    fs.readFileSync(outputSourceMapPath, {encoding: 'utf8'});
 
 
                     isFileExist = true;
                     isFileExist = true;
-                    sourceMapObject = JSON.parse(content);
                 } catch (e) {
                 } catch (e) {
                     isFileExist = false;
                     isFileExist = false;
                 }
                 }

+ 12 - 1
test/unit-tests/cli/sanitizers/ArraySanitizer.spec.ts

@@ -2,7 +2,6 @@ import { assert } from 'chai';
 
 
 import { ArraySanitizer } from '../../../../src/cli/sanitizers/ArraySanitizer';
 import { ArraySanitizer } from '../../../../src/cli/sanitizers/ArraySanitizer';
 
 
-
 describe('ArraySanitizer', () => {
 describe('ArraySanitizer', () => {
     describe('ArraySanitizer: TCLISanitizer = (value: string): string[]', () => {
     describe('ArraySanitizer: TCLISanitizer = (value: string): string[]', () => {
         describe('variant #1: input value `foo`', () => {
         describe('variant #1: input value `foo`', () => {
@@ -34,5 +33,17 @@ describe('ArraySanitizer', () => {
                 assert.deepEqual(value, expectedValue);
                 assert.deepEqual(value, expectedValue);
             });
             });
         });
         });
+
+        describe('variant #3: input value `foo,`', () => {
+            const inputValue: string = 'foo,';
+
+            const testFunc: () => void = () => {
+                ArraySanitizer(inputValue);
+            };
+
+            it('should sanitize value', () => {
+                assert.throw(testFunc, SyntaxError);
+            });
+        });
     });
     });
 });
 });

+ 14 - 3
tslint.json

@@ -16,6 +16,7 @@
       [ "$", "each" ],
       [ "$", "each" ],
       [ "angular", "forEach" ]
       [ "angular", "forEach" ]
     ],
     ],
+    "ban-comma-operator": true,
     "block-spacing": [true, "always"],
     "block-spacing": [true, "always"],
     "brace-style": [true, "1tbs"],
     "brace-style": [true, "1tbs"],
     "class-name": true,
     "class-name": true,
@@ -38,8 +39,8 @@
     "import-spacing": true,
     "import-spacing": true,
     "jsdoc-format": true,
     "jsdoc-format": true,
     "label-position": true,
     "label-position": true,
-    "max-line-length": false,
-    "member-access": true,
+    "max-classes-per-file": [true, 1],
+    "member-access": [true],
     "member-ordering": [
     "member-ordering": [
       true,
       true,
       { "order": "fields-first" }
       { "order": "fields-first" }
@@ -65,6 +66,7 @@
     "no-debugger": true,
     "no-debugger": true,
     "no-default-export": true,
     "no-default-export": true,
     "no-duplicate-case": true,
     "no-duplicate-case": true,
+    "no-duplicate-switch-case": true,
     "no-duplicate-variable": true,
     "no-duplicate-variable": true,
     "no-empty": false,
     "no-empty": false,
     "no-empty-character-class": true,
     "no-empty-character-class": true,
@@ -92,8 +94,9 @@
     "no-string-throw": true,
     "no-string-throw": true,
     "no-submodule-imports": true,
     "no-submodule-imports": true,
     "no-switch-case-fall-through": false,
     "no-switch-case-fall-through": false,
-    "no-trailing-whitespace": false,
+    "no-trailing-whitespace": [true, "ignore-blank-lines"],
     "no-unnecessary-callback-wrapper": true,
     "no-unnecessary-callback-wrapper": true,
+    "no-unnecessary-class": [true, "allow-static-only"],
     "no-unexpected-multiline": true,
     "no-unexpected-multiline": true,
     "no-unused-expression": true,
     "no-unused-expression": true,
     "no-use-before-declare": true,
     "no-use-before-declare": true,
@@ -111,6 +114,14 @@
     ],
     ],
     "one-variable-per-declaration": false,
     "one-variable-per-declaration": false,
     "only-arrow-functions": [true, "allow-declarations"],
     "only-arrow-functions": [true, "allow-declarations"],
+    "ordered-imports": [
+      true,
+      {
+        "import-sources-order": "any",
+        "grouped-imports": true,
+        "named-imports-order": "case-insensitive"
+      }
+    ],
     "prefer-const": true,
     "prefer-const": true,
     "prefer-template": true,
     "prefer-template": true,
     "quotemark": false,
     "quotemark": false,

+ 2 - 2
webpack.config.js

@@ -51,7 +51,8 @@ module.exports = {
                 loader: 'awesome-typescript-loader',
                 loader: 'awesome-typescript-loader',
                 query: {
                 query: {
                     useBabel: true,
                     useBabel: true,
-                    useCache: true
+                    useCache: true,
+                    forceIsolatedModules: true
                 }
                 }
             }
             }
         ]
         ]
@@ -70,7 +71,6 @@ module.exports = {
         new CheckerPlugin(),
         new CheckerPlugin(),
         new TSLintPlugin({
         new TSLintPlugin({
             files: ['./src/**/*.ts'],
             files: ['./src/**/*.ts'],
-            typeCheck: true,
             project: './tsconfig.json'
             project: './tsconfig.json'
         })
         })
     ],
     ],

文件差异内容过多而无法显示
+ 263 - 207
yarn.lock


部分文件因为文件数量过多而无法显示