Просмотр исходного кода

added tslint-loader and tslint fixes

sanex3339 8 лет назад
Родитель
Сommit
034d3774f8
25 измененных файлов с 156 добавлено и 142 удалено
  1. 43 40
      dist/index.js
  2. 1 0
      package.json
  3. 17 17
      src/JavaScriptObfuscatorInternal.ts
  4. 1 1
      src/container/modules/custom-nodes/CustomNodesModule.ts
  5. 5 5
      src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts
  6. 1 1
      src/custom-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts
  7. 5 5
      src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts
  8. 2 2
      src/custom-nodes/domain-lock-nodes/DomainLockNode.ts
  9. 5 5
      src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts
  10. 4 4
      src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts
  11. 5 5
      src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts
  12. 32 31
      src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts
  13. 4 3
      src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts
  14. 5 5
      src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts
  15. 1 1
      src/node-transformers/node-control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.ts
  16. 2 1
      src/node-transformers/node-control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.ts
  17. 1 1
      src/node-transformers/node-obfuscators/FunctionObfuscator.ts
  18. 4 4
      src/node-transformers/node-obfuscators/MethodDefinitionObfuscator.ts
  19. 1 1
      src/node-transformers/node-obfuscators/replacers/AbstractReplacer.ts
  20. 6 5
      src/node-transformers/node-obfuscators/replacers/StringLiteralReplacer.ts
  21. 1 1
      src/node/Nodes.ts
  22. 1 1
      src/storages/custom-node-group/CustomNodeGroupStorage.ts
  23. 1 1
      src/storages/string-array/StringArrayStorage.ts
  24. 1 1
      tslint.json
  25. 7 1
      webpack.config.js

+ 43 - 40
dist/index.js

@@ -88,7 +88,7 @@ module.exports =
 /******/ 	__webpack_require__.p = "";
 /******/
 /******/ 	// Load entry module and return exports
-/******/ 	return __webpack_require__(__webpack_require__.s = 141);
+/******/ 	return __webpack_require__(__webpack_require__.s = 140);
 /******/ })
 /************************************************************************/
 /******/ ([
@@ -2040,6 +2040,14 @@ var JavaScriptObfuscatorInternal = JavaScriptObfuscatorInternal_1 = function ()
     }
 
     (0, _createClass3.default)(JavaScriptObfuscatorInternal, [{
+        key: "obfuscate",
+        value: function obfuscate(sourceCode) {
+            var astTree = esprima.parse(sourceCode, JavaScriptObfuscatorInternal_1.esprimaParams);
+            var obfuscatedAstTree = this.obfuscator.obfuscateAstTree(astTree);
+            var generatorOutput = this.generateCode(sourceCode, obfuscatedAstTree);
+            return this.getObfuscationResult(generatorOutput);
+        }
+    }, {
         key: "generateCode",
         value: function generateCode(sourceCode, astTree) {
             var escodegenParams = tslib_1.__assign({}, JavaScriptObfuscatorInternal_1.escodegenParams);
@@ -2059,14 +2067,6 @@ var JavaScriptObfuscatorInternal = JavaScriptObfuscatorInternal_1 = function ()
         value: function getObfuscationResult(generatorOutput) {
             return this.sourceMapCorrector.correct(generatorOutput.code, generatorOutput.map);
         }
-    }, {
-        key: "obfuscate",
-        value: function obfuscate(sourceCode) {
-            var astTree = esprima.parse(sourceCode, JavaScriptObfuscatorInternal_1.esprimaParams);
-            var obfuscatedAstTree = this.obfuscator.obfuscateAstTree(astTree);
-            var generatorOutput = this.generateCode(sourceCode, obfuscatedAstTree);
-            return this.getObfuscationResult(generatorOutput);
-        }
     }]);
     return JavaScriptObfuscatorInternal;
 }();
@@ -3620,11 +3620,13 @@ var DomainLockNode = function (_AbstractCustomNode_) {
     }, {
         key: "getTemplate",
         value: function getTemplate() {
-            var domainsString = this.options.domainLock.join(';'),
-                _CryptUtils_1$CryptUt = CryptUtils_1.CryptUtils.hideString(domainsString, domainsString.length * 3),
+            var domainsString = this.options.domainLock.join(';');
+
+            var _CryptUtils_1$CryptUt = CryptUtils_1.CryptUtils.hideString(domainsString, domainsString.length * 3),
                 _CryptUtils_1$CryptUt2 = (0, _slicedToArray3.default)(_CryptUtils_1$CryptUt, 2),
                 hiddenDomainsString = _CryptUtils_1$CryptUt2[0],
                 diff = _CryptUtils_1$CryptUt2[1];
+
             return format(DomainLockNodeTemplate_1.DomainLockNodeTemplate(), {
                 domainLockFunctionName: RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomVariableName(),
                 diff: diff,
@@ -3808,8 +3810,8 @@ var NodeCallsControllerFunctionNode = function (_AbstractCustomNode_) {
     }]);
     return NodeCallsControllerFunctionNode;
 }(AbstractCustomNode_1.AbstractCustomNode);
-tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], NodeCallsControllerFunctionNode.prototype, "appendEvent", void 0);
 tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], NodeCallsControllerFunctionNode.prototype, "callsControllerFunctionName", void 0);
+tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], NodeCallsControllerFunctionNode.prototype, "appendEvent", void 0);
 NodeCallsControllerFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], NodeCallsControllerFunctionNode);
 exports.NodeCallsControllerFunctionNode = NodeCallsControllerFunctionNode;
 
@@ -4041,6 +4043,21 @@ var StringArrayCallsWrapper = function (_AbstractCustomNode_) {
             this.stringArrayName = stringArrayName;
             this.stringArrayCallsWrapperName = stringArrayCallsWrapperName;
         }
+    }, {
+        key: "getNodeStructure",
+        value: function getNodeStructure() {
+            return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
+        }
+    }, {
+        key: "getTemplate",
+        value: function getTemplate() {
+            var decodeNodeTemplate = this.getDecodeStringArrayTemplate();
+            return JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(format(StringArrayCallsWrapperTemplate_1.StringArrayCallsWrapperTemplate(), {
+                decodeNodeTemplate: decodeNodeTemplate,
+                stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
+                stringArrayName: this.stringArrayName
+            }), tslib_1.__assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { seed: this.options.seed })).getObfuscatedCode();
+        }
     }, {
         key: "getDecodeStringArrayTemplate",
         value: function getDecodeStringArrayTemplate() {
@@ -4053,17 +4070,18 @@ var StringArrayCallsWrapper = function (_AbstractCustomNode_) {
                 });
             }
             switch (this.options.stringArrayEncoding) {
-                case StringArrayEncoding_1.StringArrayEncoding.base64:
-                    decodeStringArrayTemplate = format(StringArrayBase64DecodeNodeTemplate_1.StringArrayBase64DecodeNodeTemplate(), {
+                case StringArrayEncoding_1.StringArrayEncoding.rc4:
+                    decodeStringArrayTemplate = format(StringArrayRC4DecodeNodeTemplate_1.StringArrayRc4DecodeNodeTemplate(), {
                         atobPolyfill: AtobTemplate_1.AtobTemplate(),
+                        rc4Polyfill: Rc4Template_1.Rc4Template(),
                         selfDefendingCode: selfDefendingCode,
                         stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
                     });
                     break;
-                case StringArrayEncoding_1.StringArrayEncoding.rc4:
-                    decodeStringArrayTemplate = format(StringArrayRC4DecodeNodeTemplate_1.StringArrayRc4DecodeNodeTemplate(), {
+                case StringArrayEncoding_1.StringArrayEncoding.base64:
+                default:
+                    decodeStringArrayTemplate = format(StringArrayBase64DecodeNodeTemplate_1.StringArrayBase64DecodeNodeTemplate(), {
                         atobPolyfill: AtobTemplate_1.AtobTemplate(),
-                        rc4Polyfill: Rc4Template_1.Rc4Template(),
                         selfDefendingCode: selfDefendingCode,
                         stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
                     });
@@ -4071,21 +4089,6 @@ var StringArrayCallsWrapper = function (_AbstractCustomNode_) {
             }
             return decodeStringArrayTemplate;
         }
-    }, {
-        key: "getNodeStructure",
-        value: function getNodeStructure() {
-            return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
-        }
-    }, {
-        key: "getTemplate",
-        value: function getTemplate() {
-            var decodeNodeTemplate = this.getDecodeStringArrayTemplate();
-            return JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(format(StringArrayCallsWrapperTemplate_1.StringArrayCallsWrapperTemplate(), {
-                decodeNodeTemplate: decodeNodeTemplate,
-                stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
-                stringArrayName: this.stringArrayName
-            }), tslib_1.__assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { seed: this.options.seed })).getObfuscatedCode();
-        }
     }]);
     return StringArrayCallsWrapper;
 }(AbstractCustomNode_1.AbstractCustomNode);
@@ -4244,9 +4247,9 @@ var StringArrayRotateFunctionNode = function (_AbstractCustomNode_) {
     }, {
         key: "getTemplate",
         value: function getTemplate() {
-            var code = '',
-                timesName = RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomVariableName(),
-                whileFunctionName = RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomVariableName();
+            var timesName = RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomVariableName();
+            var whileFunctionName = RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomVariableName();
+            var code = '';
             if (this.options.selfDefending) {
                 code = format(SelfDefendingTemplate_1.SelfDefendingTemplate(), {
                     timesName: timesName,
@@ -5760,13 +5763,14 @@ var StringLiteralReplacer = StringLiteralReplacer_1 = function (_AbstractReplace
         value: function replaceStringLiteralWithStringArrayCall(value) {
             var rc4Key = '';
             switch (this.options.stringArrayEncoding) {
-                case StringArrayEncoding_1.StringArrayEncoding.base64:
-                    value = CryptUtils_1.CryptUtils.btoa(value);
-                    break;
                 case StringArrayEncoding_1.StringArrayEncoding.rc4:
                     rc4Key = RandomGeneratorUtils_1.RandomGeneratorUtils.getRandomGenerator().pickone(StringLiteralReplacer_1.rc4Keys);
                     value = CryptUtils_1.CryptUtils.btoa(CryptUtils_1.CryptUtils.rc4(value, rc4Key));
                     break;
+                case StringArrayEncoding_1.StringArrayEncoding.base64:
+                default:
+                    value = CryptUtils_1.CryptUtils.btoa(value);
+                    break;
             }
             if (this.options.unicodeEscapeSequence) {
                 value = Utils_1.Utils.stringToUnicodeEscapeSequence(value);
@@ -7107,8 +7111,7 @@ module.exports = require("mkdirp");
 module.exports = require("reflect-metadata");
 
 /***/ },
-/* 140 */,
-/* 141 */
+/* 140 */
 /***/ function(module, exports, __webpack_require__) {
 
 "use strict";

+ 1 - 0
package.json

@@ -62,6 +62,7 @@
     "sinon": "2.0.0-pre.3",
     "ts-node": "1.7.2",
     "tslint": "4.1.1",
+    "tslint-loader": "^3.3.0",
     "typescript": "2.1.4",
     "webpack": "2.1.0-beta.27",
     "webpack-node-externals": "1.5.4"

+ 17 - 17
src/JavaScriptObfuscatorInternal.ts

@@ -59,6 +59,23 @@ export class JavaScriptObfuscatorInternal implements IJavaScriptObfuscator {
         this.options = options;
     }
 
+    /**
+     * @param sourceCode
+     * @returns {IObfuscationResult}
+     */
+    public obfuscate (sourceCode: string): IObfuscationResult {
+        // parse AST tree
+        const astTree: ESTree.Program = esprima.parse(sourceCode, JavaScriptObfuscatorInternal.esprimaParams);
+
+        // obfuscate AST tree
+        const obfuscatedAstTree: ESTree.Program = this.obfuscator.obfuscateAstTree(astTree);
+
+        // generate code
+        const generatorOutput: IGeneratorOutput = this.generateCode(sourceCode, obfuscatedAstTree);
+
+        return this.getObfuscationResult(generatorOutput);
+    }
+
     /**
      * @param sourceCode
      * @param astTree
@@ -94,21 +111,4 @@ export class JavaScriptObfuscatorInternal implements IJavaScriptObfuscator {
             generatorOutput.map
         );
     }
-
-    /**
-     * @param sourceCode
-     * @returns {IObfuscationResult}
-     */
-    public obfuscate (sourceCode: string): IObfuscationResult {
-        // parse AST tree
-        const astTree: ESTree.Program = esprima.parse(sourceCode, JavaScriptObfuscatorInternal.esprimaParams);
-
-        // obfuscate AST tree
-        const obfuscatedAstTree: ESTree.Program = this.obfuscator.obfuscateAstTree(astTree);
-
-        // generate code
-        const generatorOutput: IGeneratorOutput = this.generateCode(sourceCode, obfuscatedAstTree);
-
-        return this.getObfuscationResult(generatorOutput);
-    }
 }

+ 1 - 1
src/container/modules/custom-nodes/CustomNodesModule.ts

@@ -131,7 +131,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
             };
         });
 
-    // CustomNodeGroup factory
+    // customNodeGroup factory
     bind<ICustomNodeGroup>(ServiceIdentifiers.Factory__ICustomNodeGroup)
         .toFactory<ICustomNodeGroup>((context: interfaces.Context) => {
             return (customNodeGroupName: CustomNodeGroups) => {

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

@@ -26,17 +26,17 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
      */
     protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.BeforeObfuscation;
 
-    /**
-     * @type {TCustomNodeFactory}
-     */
-    private readonly customNodeFactory: TCustomNodeFactory;
-
     /**
      * @type {Map<CustomNodes, ICustomNode>}
      */
     @initializable()
     protected customNodes: Map <CustomNodes, ICustomNode>;
 
+    /**
+     * @type {TCustomNodeFactory}
+     */
+    private readonly customNodeFactory: TCustomNodeFactory;
+
     /**
      * @type {IObfuscationEventEmitter}
      */

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

@@ -53,7 +53,7 @@ export class ControlFlowStorageNode extends AbstractCustomNode {
                             return Nodes.getPropertyNode(
                                 Nodes.getIdentifierNode(key),
                                 <any>value.getNode()[0]
-                            )
+                            );
                         })
                 )
             )

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

@@ -26,17 +26,17 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
      */
     protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.BeforeObfuscation;
 
-    /**
-     * @type {TCustomNodeFactory}
-     */
-    private readonly customNodeFactory: TCustomNodeFactory;
-
     /**
      * @type {Map<CustomNodes, ICustomNode>}
      */
     @initializable()
     protected customNodes: Map <CustomNodes, ICustomNode>;
 
+    /**
+     * @type {TCustomNodeFactory}
+     */
+    private readonly customNodeFactory: TCustomNodeFactory;
+
     /**
      * @type {IObfuscationEventEmitter}
      */

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

@@ -51,8 +51,8 @@ export class DomainLockNode extends AbstractCustomNode {
      * @returns {string}
      */
     protected getTemplate (): string {
-        let domainsString: string = this.options.domainLock.join(';'),
-            [hiddenDomainsString, diff]: string[] = CryptUtils.hideString(domainsString, domainsString.length * 3);
+        const domainsString: string = this.options.domainLock.join(';');
+        const [hiddenDomainsString, diff]: string[] = CryptUtils.hideString(domainsString, domainsString.length * 3);
 
         return format(DomainLockNodeTemplate(), {
             domainLockFunctionName: RandomGeneratorUtils.getRandomVariableName(),

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

@@ -26,17 +26,17 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
      */
     protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.BeforeObfuscation;
 
-    /**
-     * @type {TCustomNodeFactory}
-     */
-    private readonly customNodeFactory: TCustomNodeFactory;
-
     /**
      * @type {Map<CustomNodes, ICustomNode>}
      */
     @initializable()
     protected customNodes: Map <CustomNodes, ICustomNode>;
 
+    /**
+     * @type {TCustomNodeFactory}
+     */
+    private readonly customNodeFactory: TCustomNodeFactory;
+
     /**
      * @type {IObfuscationEventEmitter}
      */

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

@@ -23,16 +23,16 @@ import { NodeUtils } from '../../node/NodeUtils';
 @injectable()
 export class NodeCallsControllerFunctionNode extends AbstractCustomNode {
     /**
-     * @type {TObfuscationEvent}
+     * @type {string}
      */
     @initializable()
-    private appendEvent: TObfuscationEvent;
+    protected callsControllerFunctionName: string;
 
     /**
-     * @type {string}
+     * @type {TObfuscationEvent}
      */
     @initializable()
-    protected callsControllerFunctionName: string;
+    private appendEvent: TObfuscationEvent;
 
     /**
      * @param options

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

@@ -26,17 +26,17 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
      */
     protected appendEvent: TObfuscationEvent = ObfuscationEvents.AfterObfuscation;
 
-    /**
-     * @type {TCustomNodeFactory}
-     */
-    private readonly customNodeFactory: TCustomNodeFactory;
-
     /**
      * @type {Map<CustomNodes, ICustomNode>}
      */
     @initializable()
     protected customNodes: Map <CustomNodes, ICustomNode>;
 
+    /**
+     * @type {TCustomNodeFactory}
+     */
+    private readonly customNodeFactory: TCustomNodeFactory;
+
     /**
      * @type {IObfuscationEventEmitter}
      */

+ 32 - 31
src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts

@@ -69,6 +69,32 @@ export class StringArrayCallsWrapper extends AbstractCustomNode {
         this.stringArrayCallsWrapperName = stringArrayCallsWrapperName;
     }
 
+    /**
+     * @returns {TStatement[]}
+     */
+    protected getNodeStructure (): TStatement[] {
+        return NodeUtils.convertCodeToStructure(this.getTemplate());
+    }
+
+    /**
+     * @returns {string}
+     */
+    protected getTemplate (): string {
+        const decodeNodeTemplate: string = this.getDecodeStringArrayTemplate();
+
+        return JavaScriptObfuscator.obfuscate(
+            format(StringArrayCallsWrapperTemplate(), {
+                decodeNodeTemplate,
+                stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
+                stringArrayName: this.stringArrayName
+            }),
+            {
+                ...NO_CUSTOM_NODES_PRESET,
+                seed: this.options.seed
+            }
+        ).getObfuscatedCode();
+    }
+
     /**
      * @returns {string}
      */
@@ -84,19 +110,20 @@ export class StringArrayCallsWrapper extends AbstractCustomNode {
         }
 
         switch (this.options.stringArrayEncoding) {
-            case StringArrayEncoding.base64:
-                decodeStringArrayTemplate = format(StringArrayBase64DecodeNodeTemplate(), {
+            case StringArrayEncoding.rc4:
+                decodeStringArrayTemplate = format(StringArrayRc4DecodeNodeTemplate(), {
                     atobPolyfill: AtobTemplate(),
+                    rc4Polyfill: Rc4Template(),
                     selfDefendingCode,
                     stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
                 });
 
                 break;
 
-            case StringArrayEncoding.rc4:
-                decodeStringArrayTemplate = format(StringArrayRc4DecodeNodeTemplate(), {
+            case StringArrayEncoding.base64:
+            default:
+                decodeStringArrayTemplate = format(StringArrayBase64DecodeNodeTemplate(), {
                     atobPolyfill: AtobTemplate(),
-                    rc4Polyfill: Rc4Template(),
                     selfDefendingCode,
                     stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
                 });
@@ -106,30 +133,4 @@ export class StringArrayCallsWrapper extends AbstractCustomNode {
 
         return decodeStringArrayTemplate;
     }
-
-    /**
-     * @returns {TStatement[]}
-     */
-    protected getNodeStructure (): TStatement[] {
-        return NodeUtils.convertCodeToStructure(this.getTemplate());
-    }
-
-    /**
-     * @returns {string}
-     */
-    protected getTemplate (): string {
-        const decodeNodeTemplate: string = this.getDecodeStringArrayTemplate();
-
-        return JavaScriptObfuscator.obfuscate(
-            format(StringArrayCallsWrapperTemplate(), {
-                decodeNodeTemplate,
-                stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
-                stringArrayName: this.stringArrayName
-            }),
-            {
-                ...NO_CUSTOM_NODES_PRESET,
-                seed: this.options.seed
-            }
-        ).getObfuscatedCode();
-    }
 }

+ 4 - 3
src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts

@@ -76,9 +76,10 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode {
      * @returns {string}
      */
     protected getTemplate (): string {
-        let code: string = '',
-            timesName: string = RandomGeneratorUtils.getRandomVariableName(),
-            whileFunctionName: string = RandomGeneratorUtils.getRandomVariableName();
+        const timesName: string = RandomGeneratorUtils.getRandomVariableName();
+        const whileFunctionName: string = RandomGeneratorUtils.getRandomVariableName();
+
+        let code: string = '';
 
         if (this.options.selfDefending) {
             code = format(SelfDefendingTemplate(), {

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

@@ -28,17 +28,17 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
      */
     protected appendEvent: TObfuscationEvent = ObfuscationEvents.AfterObfuscation;
 
-    /**
-     * @type {TCustomNodeFactory}
-     */
-    private readonly customNodeFactory: TCustomNodeFactory;
-
     /**
      * @type {Map<CustomNodes, ICustomNode>}
      */
     @initializable()
     protected customNodes: Map <CustomNodes, ICustomNode>;
 
+    /**
+     * @type {TCustomNodeFactory}
+     */
+    private readonly customNodeFactory: TCustomNodeFactory;
+
     /**
      * @type {IObfuscationEventEmitter}
      */

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

@@ -13,7 +13,7 @@ export abstract class AbstractControlFlowReplacer implements IControlFlowReplace
     /**
      * @type {IOptions}
      */
-    protected readonly options : IOptions;
+    protected readonly options: IOptions;
 
     /**
      * @param options

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

@@ -86,7 +86,8 @@ export class BinaryExpressionControlFlowReplacer extends AbstractControlFlowRepl
                 controlFlowStorageId
             );
 
-        let storageKeysForCurrentOperator: string[] | undefined = storageKeysByBinaryOperator.get(binaryExpressionNode.operator);
+        const storageKeysForCurrentOperator: string[] | undefined = storageKeysByBinaryOperator.get(binaryExpressionNode.operator);
+
         let storageKey: string;
 
         if (

+ 1 - 1
src/node-transformers/node-obfuscators/FunctionObfuscator.ts

@@ -72,7 +72,7 @@ export class FunctionObfuscator extends AbstractNodeTransformer {
      * @param nodeIdentifier
      */
     private replaceFunctionParams (functionNode: ESTree.Function, nodeIdentifier: string): void {
-        let traverseVisitor: estraverse.Visitor = {
+        const traverseVisitor: estraverse.Visitor = {
             enter: (node: ESTree.Node, parentNode: ESTree.Node): any => {
                 if (Node.isReplaceableIdentifierNode(node, parentNode)) {
                     const newNodeName: string = this.identifierReplacer.replace(node.name, nodeIdentifier);

+ 4 - 4
src/node-transformers/node-obfuscators/MethodDefinitionObfuscator.ts

@@ -22,14 +22,14 @@ import { Node } from '../../node/Node';
 @injectable()
 export class MethodDefinitionObfuscator extends AbstractNodeTransformer {
     /**
-     * @type {IObfuscatorReplacer}
+     * @type {string[]}
      */
-    private readonly stringLiteralReplacer: IObfuscatorReplacer;
+    private static readonly ignoredNames: string[] = ['constructor'];
 
     /**
-     * @type {string[]}
+     * @type {IObfuscatorReplacer}
      */
-    private static readonly ignoredNames: string[] = ['constructor'];
+    private readonly stringLiteralReplacer: IObfuscatorReplacer;
 
     /**
      * @param replacersFactory

+ 1 - 1
src/node-transformers/node-obfuscators/replacers/AbstractReplacer.ts

@@ -9,7 +9,7 @@ export abstract class AbstractReplacer implements IObfuscatorReplacer {
     /**
      * @type {IOptions}
      */
-    protected readonly options : IOptions;
+    protected readonly options: IOptions;
 
     /**
      * @param options

+ 6 - 5
src/node-transformers/node-obfuscators/replacers/StringLiteralReplacer.ts

@@ -76,15 +76,16 @@ export class StringLiteralReplacer extends AbstractReplacer {
         let rc4Key: string = '';
 
         switch (this.options.stringArrayEncoding) {
-            case StringArrayEncoding.base64:
-                value = CryptUtils.btoa(value);
-
-                break;
-
             case StringArrayEncoding.rc4:
                 rc4Key = RandomGeneratorUtils.getRandomGenerator().pickone(StringLiteralReplacer.rc4Keys);
                 value = CryptUtils.btoa(CryptUtils.rc4(value, rc4Key));
 
+                break;
+
+            case StringArrayEncoding.base64:
+            default:
+                value = CryptUtils.btoa(value);
+
                 break;
         }
 

+ 1 - 1
src/node/Nodes.ts

@@ -137,7 +137,7 @@ export class Nodes {
      * @param consequent
      * @returns {ESTree.IfStatement}
      */
-    public static getIfStatementNode (test: ESTree.Expression, consequent: ESTree.BlockStatement,): ESTree.IfStatement {
+    public static getIfStatementNode (test: ESTree.Expression, consequent: ESTree.BlockStatement): ESTree.IfStatement {
         return {
             type: NodeType.IfStatement,
             test,

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

@@ -66,4 +66,4 @@ export class CustomNodeGroupStorage extends MapStorage <ICustomNodeGroup> {
             this.storage.set(customNodeGroupName, customNodeGroup);
         });
     }
-}
+}

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

@@ -36,4 +36,4 @@ export class StringArrayStorage extends ArrayStorage <string> {
             return `'${value}'`;
         }).toString();
     }
-}
+}

+ 1 - 1
tslint.json

@@ -37,7 +37,7 @@
       true,
       { "order": "fields-first" }
     ],
-    "new-parens": true,
+    "new-parens": false,
     "no-angle-bracket-type-assertion": false,
     "no-any": false,
     "no-arg": true,

+ 7 - 1
webpack.config.js

@@ -18,7 +18,13 @@ module.exports = {
     target: 'node',
     externals: [nodeExternals()],
     module: {
-        loaders: [
+        rules: [
+            {
+                enforce: 'pre',
+                test: /\.ts$/,
+                loader: 'tslint-loader',
+                exclude: /(node_modules)/,
+            },
             {
                 test: /\.ts(x?)$/,
                 loader: 'awesome-typescript-loader',