Bläddra i källkod

Custom nodes: moved append logic to custom node groups

sanex3339 8 år sedan
förälder
incheckning
984adae965

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 298 - 209
dist/index.js


+ 18 - 22
src/Obfuscator.ts

@@ -7,14 +7,15 @@ import * as ESTree from 'estree';
 import { TNodeTransformersFactory } from './types/container/TNodeTransformersFactory';
 import { TVisitorDirection } from './types/TVisitorDirection';
 
+import { ICustomNodeGroup } from './interfaces/custom-nodes/ICustomNodeGroup';
 import { IObfuscationEventEmitter } from './interfaces/event-emitters/IObfuscationEventEmitter';
 import { IObfuscator } from './interfaces/IObfuscator';
 import { IOptions } from './interfaces/options/IOptions';
 import { INodeTransformer } from './interfaces/node-transformers/INodeTransformer';
 import { IStackTraceAnalyzer } from './interfaces/stack-trace-analyzer/IStackTraceAnalyzer';
 import { IStackTraceData } from './interfaces/stack-trace-analyzer/IStackTraceData';
+import { IStorage } from './interfaces/storages/IStorage';
 
-import { CustomNodeGroups } from './enums/container/CustomNodeGroups';
 import { NodeTransformers } from './enums/container/NodeTransformers';
 import { NodeType } from './enums/NodeType';
 import { ObfuscationEvents } from './enums/ObfuscationEvents';
@@ -22,21 +23,9 @@ import { VisitorDirection } from './enums/VisitorDirection';
 
 import { Node } from './node/Node';
 import { NodeUtils } from './node/NodeUtils';
-import { TCustomNodeGroupsFactory } from './types/container/TCustomNodesFactoriesFactory';
 
 @injectable()
 export class Obfuscator implements IObfuscator {
-    /**
-     * @type {CustomNodeGroups[]}
-     */
-    private static readonly customNodeGroupsList: CustomNodeGroups[] = [
-        CustomNodeGroups.ConsoleOutputCustomNodeGroup,
-        CustomNodeGroups.DebugProtectionCustomNodeGroup,
-        CustomNodeGroups.DomainLockCustomNodeGroup,
-        CustomNodeGroups.SelfDefendingCustomNodeGroup,
-        CustomNodeGroups.StringArrayCustomNodeGroup
-    ];
-
     /**
      * @type {Map<string, NodeTransformers[]>}
      */
@@ -66,9 +55,9 @@ export class Obfuscator implements IObfuscator {
     ]);
 
     /**
-     * @type {TCustomNodeGroupsFactory}
+     * @type {IStorage<ICustomNodeGroup>}
      */
-    private readonly customNodeGroupsFactory: TCustomNodeGroupsFactory;
+    private readonly customNodeGroupStorage: IStorage<ICustomNodeGroup>;
 
     /**
      * @type {TNodeTransformersFactory}
@@ -93,20 +82,20 @@ export class Obfuscator implements IObfuscator {
     /**
      * @param stackTraceAnalyzer
      * @param obfuscationEventEmitter
-     * @param customNodeGroupsFactory
+     * @param customNodeGroupStorage
      * @param nodeTransformersFactory
      * @param options
      */
     constructor (
         @inject(ServiceIdentifiers.IStackTraceAnalyzer) stackTraceAnalyzer: IStackTraceAnalyzer,
         @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
-        @inject(ServiceIdentifiers['Factory<ICustomNodeGroup>']) customNodeGroupsFactory: TCustomNodeGroupsFactory,
+        @inject(ServiceIdentifiers['IStorage<ICustomNodeGroup>']) customNodeGroupStorage: IStorage<ICustomNodeGroup>,
         @inject(ServiceIdentifiers['Factory<INodeTransformer[]>']) nodeTransformersFactory: TNodeTransformersFactory,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
         this.stackTraceAnalyzer = stackTraceAnalyzer;
         this.obfuscationEventEmitter = obfuscationEventEmitter;
-        this.customNodeGroupsFactory = customNodeGroupsFactory;
+        this.customNodeGroupStorage = customNodeGroupStorage;
         this.nodeTransformersFactory = nodeTransformersFactory;
         this.options = options;
     }
@@ -124,10 +113,17 @@ export class Obfuscator implements IObfuscator {
 
         const stackTraceData: IStackTraceData[] = this.stackTraceAnalyzer.analyze(astTree.body);
 
-        // initialize custom node groups
-        Obfuscator.customNodeGroupsList.forEach((customNodeGroupName: CustomNodeGroups) => {
-            this.customNodeGroupsFactory(customNodeGroupName).initialize(stackTraceData);
-        });
+        // initialize custom node groups and configure custom nodes
+        this.customNodeGroupStorage
+            .getStorage()
+            .forEach((customNodeGroup: ICustomNodeGroup) => {
+                customNodeGroup.initialize();
+
+                this.obfuscationEventEmitter.once(
+                    customNodeGroup.getAppendEvent(),
+                    customNodeGroup.appendCustomNodes.bind(customNodeGroup)
+                );
+            });
 
         this.obfuscationEventEmitter.emit(ObfuscationEvents.BeforeObfuscation, astTree, stackTraceData);
 

+ 8 - 0
src/container/InversifyContainerFacade.ts

@@ -22,6 +22,9 @@ import { ObfuscationResult } from '../ObfuscationResult';
 import { Obfuscator } from '../Obfuscator';
 import { Options } from "../options/Options";
 import { SourceMapCorrector } from '../SourceMapCorrector';
+import { IStorage } from '../interfaces/storages/IStorage';
+import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup';
+import { CustomNodeGroupStorage } from '../storages/custom-node-group/CustomNodeGroupStorage';
 
 export class InversifyContainerFacade implements IInversifyContainerFacade {
     /**
@@ -75,6 +78,11 @@ export class InversifyContainerFacade implements IInversifyContainerFacade {
             .to(SourceMapCorrector)
             .inSingletonScope();
 
+        this.container
+            .bind<IStorage<ICustomNodeGroup>>(ServiceIdentifiers['IStorage<ICustomNodeGroup>'])
+            .to(CustomNodeGroupStorage)
+            .inSingletonScope();
+
         this.container
             .bind<IObfuscationEventEmitter>(ServiceIdentifiers.IObfuscationEventEmitter)
             .to(ObfuscationEventEmitter)

+ 2 - 1
src/container/ServiceIdentifiers.ts

@@ -18,5 +18,6 @@ export const ServiceIdentifiers: any = {
     IOptions: Symbol('IOptions'),
     IReplacer: Symbol('IReplacer'),
     ISourceMapCorrector: Symbol('ISourceMapCorrector'),
-    IStackTraceAnalyzer: Symbol('IStackTraceAnalyzer')
+    IStackTraceAnalyzer: Symbol('IStackTraceAnalyzer'),
+    'IStorage<ICustomNodeGroup>': Symbol('IStorage<ICustomNodeGroup>')
 };

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

@@ -84,27 +84,22 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
     // node groups
     bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
         .to(ConsoleOutputCustomNodeGroup)
-        .inSingletonScope()
         .whenTargetNamed(CustomNodeGroups.ConsoleOutputCustomNodeGroup);
 
     bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
         .to(DebugProtectionCustomNodeGroup)
-        .inSingletonScope()
         .whenTargetNamed(CustomNodeGroups.DebugProtectionCustomNodeGroup);
 
     bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
         .to(DomainLockCustomNodeGroup)
-        .inSingletonScope()
         .whenTargetNamed(CustomNodeGroups.DomainLockCustomNodeGroup);
 
     bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
         .to(SelfDefendingCustomNodeGroup)
-        .inSingletonScope()
         .whenTargetNamed(CustomNodeGroups.SelfDefendingCustomNodeGroup);
 
     bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
         .to(StringArrayCustomNodeGroup)
-        .inSingletonScope()
         .whenTargetNamed(CustomNodeGroups.StringArrayCustomNodeGroup);
 
     // customNode factory
@@ -121,21 +116,11 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
     // CustomNodeGroup factory
     bind<ICustomNodeGroup>(ServiceIdentifiers['Factory<ICustomNodeGroup>'])
         .toFactory<ICustomNodeGroup>((context: interfaces.Context) => {
-            const cache: Map <CustomNodeGroups, ICustomNodeGroup> = new Map <CustomNodeGroups, ICustomNodeGroup> ();
-
             return (customNodeGroupName: CustomNodeGroups) => {
-                if (cache.has(customNodeGroupName)) {
-                    return <ICustomNodeGroup>cache.get(customNodeGroupName);
-                }
-
-                const customNodeGroup: ICustomNodeGroup = context.container.getNamed<ICustomNodeGroup>(
+                return context.container.getNamed<ICustomNodeGroup>(
                     ServiceIdentifiers.ICustomNodeGroup,
                     customNodeGroupName
                 );
-
-                cache.set(customNodeGroupName, customNodeGroup);
-
-                return customNodeGroup;
             };
         });
 });

+ 30 - 17
src/custom-nodes/AbstractCustomNodeGroup.ts

@@ -1,6 +1,7 @@
 import { injectable, inject } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
+import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement';
 import { TObfuscationEvent } from '../types/event-emitters/TObfuscationEvent';
 
 import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode';
@@ -8,24 +9,19 @@ import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup';
 import { IOptions } from '../interfaces/options/IOptions';
 import { IStackTraceData } from '../interfaces/stack-trace-analyzer/IStackTraceData';
 
-import { ObfuscationEvents } from '../enums/ObfuscationEvents';
+import { CustomNodes } from '../enums/container/CustomNodes';
 
 @injectable()
 export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup {
     /**
      * @type {TObfuscationEvent}
      */
-    protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.BeforeObfuscation;
+    protected abstract readonly appendEvent: TObfuscationEvent;
 
     /**
-     * @type {Map<string, ICustomNode>}
+     * @type {Map<CustomNodes, ICustomNode>}
      */
-    protected abstract customNodes: Map <string, ICustomNode>;
-
-    /**
-     * @type {string}
-     */
-    protected abstract readonly groupName: string;
+    protected abstract customNodes: Map <CustomNodes, ICustomNode>;
 
     /**
      * @type {IStackTraceData[]}
@@ -47,21 +43,38 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup {
     }
 
     /**
-     * @returns {Map<string, ICustomNode>}
+     * @param blockScopeNode
+     * @param stackTraceData
      */
-    public getCustomNodes (): Map <string, ICustomNode> {
-        return this.customNodes;
+    public abstract appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void;
+
+    /**
+     * @returns {TObfuscationEvent}
+     */
+    public getAppendEvent (): TObfuscationEvent {
+        return this.appendEvent;
     }
 
     /**
-     * @returns {string}
+     * @returns {Map<CustomNodes, ICustomNode>}
      */
-    public getGroupName (): string {
-        return this.groupName;
+    public getCustomNodes (): Map <CustomNodes, ICustomNode> {
+        return this.customNodes;
     }
 
+    public abstract initialize (): void;
+
     /**
-     * @param stackTraceData
+     * @param customNodeName
+     * @param callback
      */
-    public abstract initialize (stackTraceData: IStackTraceData[]): void;
+    protected appendCustomNodeIfExist (customNodeName: CustomNodes, callback: (customNode: ICustomNode) => void): void {
+        const customNode: ICustomNode | undefined = this.customNodes.get(customNodeName);
+
+        if (!customNode) {
+            return;
+        }
+
+        callback(customNode);
+    }
 }

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

@@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 import { TCustomNodeFactory } from '../../../types/container/TCustomNodeFactory';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
+import { TObfuscationEvent } from '../../../types/event-emitters/TObfuscationEvent';
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter';
@@ -12,6 +13,7 @@ import { IStackTraceData } from '../../../interfaces/stack-trace-analyzer/IStack
 import { initializable } from '../../../decorators/Initializable';
 
 import { CustomNodes } from '../../../enums/container/CustomNodes';
+import { ObfuscationEvents } from '../../../enums/ObfuscationEvents';
 
 import { AbstractCustomNodeGroup } from '../../AbstractCustomNodeGroup';
 import { NodeAppender } from '../../../node/NodeAppender';
@@ -20,20 +22,20 @@ import { Utils } from '../../../Utils';
 @injectable()
 export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
     /**
-     * @type {TCustomNodeFactory}
+     * @type {TObfuscationEvent}
      */
-    private readonly customNodeFactory: TCustomNodeFactory;
+    protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.BeforeObfuscation;
 
     /**
-     * @type {Map<string, ICustomNode>}
+     * @type {TCustomNodeFactory}
      */
-    @initializable()
-    protected customNodes: Map <string, ICustomNode>;
+    private readonly customNodeFactory: TCustomNodeFactory;
 
     /**
-     * @type {string}
+     * @type {Map<CustomNodes, ICustomNode>}
      */
-    protected readonly groupName: string = 'consoleOutputCustomNodeGroup';
+    @initializable()
+    protected customNodes: Map <CustomNodes, ICustomNode>;
 
     /**
      * @type {IObfuscationEventEmitter}
@@ -57,50 +59,52 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
     }
 
     /**
+     * @param blockScopeNode
      * @param stackTraceData
      */
-    public initialize (stackTraceData: IStackTraceData[]): void {
-        const callsControllerFunctionName: string = Utils.getRandomVariableName();
+    public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void {
         const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(stackTraceData.length);
 
-        const consoleOutputDisableExpressionNode: ICustomNode = this.customNodeFactory(CustomNodes.ConsoleOutputDisableExpressionNode);
-        const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNodes.NodeCallsControllerFunctionNode);
+        // consoleOutputDisableExpressionNode append
+        this.appendCustomNodeIfExist(CustomNodes.ConsoleOutputDisableExpressionNode, (customNode: ICustomNode) => {
+            NodeAppender.appendNodeToOptimalBlockScope(
+                stackTraceData,
+                blockScopeNode,
+                customNode.getNode(),
+                randomStackTraceIndex
+            );
+        });
+
+        // nodeCallsControllerFunctionNode append
+        this.appendCustomNodeIfExist(CustomNodes.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
+            let targetBlockScope: TNodeWithBlockStatement;
+
+            if (stackTraceData.length) {
+                targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
+            } else {
+                targetBlockScope = blockScopeNode;
+            }
 
-        consoleOutputDisableExpressionNode.initialize(callsControllerFunctionName);
-        nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
+            NodeAppender.prependNode(targetBlockScope, customNode.getNode());
+        });
+    }
 
-        this.customNodes = new Map <string, ICustomNode> ([
-            ['consoleOutputDisableExpressionNode', consoleOutputDisableExpressionNode],
-            ['nodeCallsControllerFunctionNode', nodeCallsControllerFunctionNode]
-        ]);
+    public initialize (): void {
+        this.customNodes = new Map <CustomNodes, ICustomNode> ();
 
         if (!this.options.disableConsoleOutput) {
             return;
         }
 
-        this.obfuscationEventEmitter.once(
-            this.appendEvent,
-            (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]) => {
-                // consoleOutputDisableExpressionNode append
-                NodeAppender.appendNodeToOptimalBlockScope(
-                    stackTraceData,
-                    blockScopeNode,
-                    consoleOutputDisableExpressionNode.getNode(),
-                    randomStackTraceIndex
-                );
-
-                // nodeCallsControllerFunctionNode append
-                let targetBlockScope: TNodeWithBlockStatement;
-
-                if (stackTraceData.length) {
-                    targetBlockScope = NodeAppender
-                        .getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
-                } else {
-                    targetBlockScope = blockScopeNode;
-                }
-
-                NodeAppender.prependNode(targetBlockScope, nodeCallsControllerFunctionNode.getNode());
-            }
-        );
+        const callsControllerFunctionName: string = Utils.getRandomVariableName();
+
+        const consoleOutputDisableExpressionNode: ICustomNode = this.customNodeFactory(CustomNodes.ConsoleOutputDisableExpressionNode);
+        const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNodes.NodeCallsControllerFunctionNode);
+
+        consoleOutputDisableExpressionNode.initialize(callsControllerFunctionName);
+        nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
+
+        this.customNodes.set(CustomNodes.ConsoleOutputDisableExpressionNode, consoleOutputDisableExpressionNode);
+        this.customNodes.set(CustomNodes.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode);
     }
 }

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

@@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 import { TCustomNodeFactory } from '../../../types/container/TCustomNodeFactory';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
+import { TObfuscationEvent } from '../../../types/event-emitters/TObfuscationEvent';
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter';
@@ -12,6 +13,7 @@ import { IStackTraceData } from '../../../interfaces/stack-trace-analyzer/IStack
 import { initializable } from '../../../decorators/Initializable';
 
 import { CustomNodes } from '../../../enums/container/CustomNodes';
+import { ObfuscationEvents } from '../../../enums/ObfuscationEvents';
 
 import { AbstractCustomNodeGroup } from '../../AbstractCustomNodeGroup';
 import { NodeAppender } from '../../../node/NodeAppender';
@@ -20,20 +22,20 @@ import { Utils } from '../../../Utils';
 @injectable()
 export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
     /**
-     * @type {TCustomNodeFactory}
+     * @type {TObfuscationEvent}
      */
-    private readonly customNodeFactory: TCustomNodeFactory;
+    protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.BeforeObfuscation;
 
     /**
-     * @type {Map<string, ICustomNode>}
+     * @type {TCustomNodeFactory}
      */
-    @initializable()
-    protected customNodes: Map <string, ICustomNode>;
+    private readonly customNodeFactory: TCustomNodeFactory;
 
     /**
-     * @type {string}
+     * @type {Map<CustomNodes, ICustomNode>}
      */
-    protected readonly groupName: string = 'debugProtectionCustomNodeGroup';
+    @initializable()
+    protected customNodes: Map <CustomNodes, ICustomNode>;
 
     /**
      * @type {IObfuscationEventEmitter}
@@ -57,9 +59,36 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
     }
 
     /**
+     * @param blockScopeNode
      * @param stackTraceData
      */
-    public initialize (stackTraceData: IStackTraceData[]): void {
+    public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void {
+        // debugProtectionFunctionNode append
+        this.appendCustomNodeIfExist(CustomNodes.DebugProtectionFunctionNode, (customNode: ICustomNode) => {
+            NodeAppender.appendNode(blockScopeNode, customNode.getNode());
+        });
+
+        // debugProtectionFunctionCallNode append
+        this.appendCustomNodeIfExist(CustomNodes.DebugProtectionFunctionCallNode, (customNode: ICustomNode) => {
+            NodeAppender.appendNode(blockScopeNode, customNode.getNode());
+        });
+
+        // debugProtectionFunctionIntervalNode append
+        this.appendCustomNodeIfExist(CustomNodes.DebugProtectionFunctionIntervalNode, (customNode: ICustomNode) => {
+            let programBodyLength: number = blockScopeNode.body.length,
+                randomIndex: number = Utils.getRandomInteger(0, programBodyLength);
+
+            NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), randomIndex);
+        });
+    }
+
+    public initialize (): void {
+        this.customNodes = new Map <CustomNodes, ICustomNode> ();
+
+        if (!this.options.debugProtection) {
+            return;
+        }
+
         const debugProtectionFunctionName: string = Utils.getRandomVariableName();
 
         const debugProtectionFunctionNode: ICustomNode = this.customNodeFactory(CustomNodes.DebugProtectionFunctionNode);
@@ -70,45 +99,11 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
         debugProtectionFunctionCallNode.initialize(debugProtectionFunctionName);
         debugProtectionFunctionIntervalNode.initialize(debugProtectionFunctionName);
 
-        const customNodes: Map <string, ICustomNode> = new Map <string, ICustomNode> ([
-            ['debugProtectionFunctionNode', debugProtectionFunctionNode],
-            ['debugProtectionFunctionCallNode', debugProtectionFunctionCallNode]
-        ]);
-
-        this.obfuscationEventEmitter.once(
-            this.appendEvent,
-            (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]) => {
-                if (!this.options.debugProtection) {
-                    return;
-                }
-
-                // debugProtectionFunctionNode append
-                NodeAppender.appendNode(blockScopeNode, debugProtectionFunctionNode.getNode());
-
-                // debugProtectionFunctionCallNode append
-                NodeAppender.appendNode(blockScopeNode, debugProtectionFunctionCallNode.getNode());
-            }
-        );
+        this.customNodes.set(CustomNodes.DebugProtectionFunctionNode, debugProtectionFunctionNode);
+        this.customNodes.set(CustomNodes.DebugProtectionFunctionCallNode, debugProtectionFunctionCallNode);
 
         if (this.options.debugProtectionInterval) {
-            customNodes.set('debugProtectionFunctionIntervalNode', debugProtectionFunctionIntervalNode);
-
-            this.obfuscationEventEmitter.once(
-                this.appendEvent,
-                (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]) => {
-                    if (!this.options.debugProtection) {
-                        return;
-                    }
-
-                    // debugProtectionFunctionIntervalNode append
-                    let programBodyLength: number = blockScopeNode.body.length,
-                        randomIndex: number = Utils.getRandomInteger(0, programBodyLength);
-
-                    NodeAppender.insertNodeAtIndex(blockScopeNode, debugProtectionFunctionIntervalNode.getNode(), randomIndex);
-                }
-            );
+            this.customNodes.set(CustomNodes.DebugProtectionFunctionIntervalNode, debugProtectionFunctionIntervalNode);
         }
-
-        this.customNodes = customNodes;
     }
 }

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

@@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
 import { TCustomNodeFactory } from '../../../types/container/TCustomNodeFactory';
 import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
+import { TObfuscationEvent } from '../../../types/event-emitters/TObfuscationEvent';
 
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IObfuscationEventEmitter } from '../../../interfaces/event-emitters/IObfuscationEventEmitter';
@@ -12,6 +13,7 @@ import { IStackTraceData } from '../../../interfaces/stack-trace-analyzer/IStack
 import { initializable } from '../../../decorators/Initializable';
 
 import { CustomNodes } from '../../../enums/container/CustomNodes';
+import { ObfuscationEvents } from '../../../enums/ObfuscationEvents';
 
 import { AbstractCustomNodeGroup } from '../../AbstractCustomNodeGroup';
 import { NodeAppender } from '../../../node/NodeAppender';
@@ -20,20 +22,20 @@ import { Utils } from '../../../Utils';
 @injectable()
 export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
     /**
-     * @type {TCustomNodeFactory}
+     * @type {TObfuscationEvent}
      */
-    private readonly customNodeFactory: TCustomNodeFactory;
+    protected readonly appendEvent: TObfuscationEvent = ObfuscationEvents.BeforeObfuscation;
 
     /**
-     * @type {Map<string, ICustomNode>}
+     * @type {TCustomNodeFactory}
      */
-    @initializable()
-    protected customNodes: Map <string, ICustomNode>;
+    private readonly customNodeFactory: TCustomNodeFactory;
 
     /**
-     * @type {string}
+     * @type {Map<CustomNodes, ICustomNode>}
      */
-    protected readonly groupName: string = 'domainLockCustomNodeGroup';
+    @initializable()
+    protected customNodes: Map <CustomNodes, ICustomNode>;
 
     /**
      * @type {IObfuscationEventEmitter}
@@ -57,50 +59,52 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
     }
 
     /**
+     * @param blockScopeNode
      * @param stackTraceData
      */
-    public initialize (stackTraceData: IStackTraceData[]): void {
-        const callsControllerFunctionName: string = Utils.getRandomVariableName();
+    public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void {
         const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(stackTraceData.length);
 
-        const domainLockNode: ICustomNode = this.customNodeFactory(CustomNodes.DomainLockNode);
-        const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNodes.NodeCallsControllerFunctionNode);
+        // domainLockNode append
+        this.appendCustomNodeIfExist(CustomNodes.DomainLockNode, (customNode: ICustomNode) => {
+            NodeAppender.appendNodeToOptimalBlockScope(
+                stackTraceData,
+                blockScopeNode,
+                customNode.getNode(),
+                randomStackTraceIndex
+            );
+        });
+
+        // nodeCallsControllerFunctionNode append
+        this.appendCustomNodeIfExist(CustomNodes.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
+            let targetBlockScope: TNodeWithBlockStatement;
+
+            if (stackTraceData.length) {
+                targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
+            } else {
+                targetBlockScope = blockScopeNode;
+            }
 
-        domainLockNode.initialize(callsControllerFunctionName);
-        nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
+            NodeAppender.prependNode(targetBlockScope, customNode.getNode());
+        });
+    }
 
-        this.customNodes = new Map <string, ICustomNode> ([
-            ['domainLockNode', domainLockNode],
-            ['nodeCallsControllerFunctionNode', nodeCallsControllerFunctionNode]
-        ]);
+    public initialize (): void {
+        this.customNodes = new Map <CustomNodes, ICustomNode> ();
 
         if (!this.options.domainLock.length) {
             return;
         }
 
-        this.obfuscationEventEmitter.once(
-            this.appendEvent,
-            (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]) => {
-                // domainLockNode append
-                NodeAppender.appendNodeToOptimalBlockScope(
-                    stackTraceData,
-                    blockScopeNode,
-                    domainLockNode.getNode(),
-                    randomStackTraceIndex
-                );
-
-                // nodeCallsControllerFunctionNode append
-                let targetBlockScope: TNodeWithBlockStatement;
-
-                if (stackTraceData.length) {
-                    targetBlockScope = NodeAppender
-                        .getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
-                } else {
-                    targetBlockScope = blockScopeNode;
-                }
-
-                NodeAppender.prependNode(targetBlockScope, nodeCallsControllerFunctionNode.getNode());
-            }
-        );
+        const callsControllerFunctionName: string = Utils.getRandomVariableName();
+
+        const domainLockNode: ICustomNode = this.customNodeFactory(CustomNodes.DomainLockNode);
+        const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNodes.NodeCallsControllerFunctionNode);
+
+        domainLockNode.initialize(callsControllerFunctionName);
+        nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
+
+        this.customNodes.set(CustomNodes.DomainLockNode, domainLockNode);
+        this.customNodes.set(CustomNodes.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode);
     }
 }

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

@@ -32,15 +32,10 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
     private readonly customNodeFactory: TCustomNodeFactory;
 
     /**
-     * @type {Map<string, ICustomNode>}
+     * @type {Map<CustomNodes, ICustomNode>}
      */
     @initializable()
-    protected customNodes: Map <string, ICustomNode>;
-
-    /**
-     * @type {string}
-     */
-    protected readonly groupName: string = 'selfDefendingCustomNodeGroup';
+    protected customNodes: Map <CustomNodes, ICustomNode>;
 
     /**
      * @type {IObfuscationEventEmitter}
@@ -64,50 +59,52 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
     }
 
     /**
+     * @param blockScopeNode
      * @param stackTraceData
      */
-    public initialize (stackTraceData: IStackTraceData[]): void {
-        const callsControllerFunctionName: string = Utils.getRandomVariableName();
+    public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void {
         const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(stackTraceData.length);
 
-        const selfDefendingUnicodeNode: ICustomNode = this.customNodeFactory(CustomNodes.SelfDefendingUnicodeNode);
-        const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNodes.NodeCallsControllerFunctionNode);
+        // selfDefendingUnicodeNode append
+        this.appendCustomNodeIfExist(CustomNodes.SelfDefendingUnicodeNode, (customNode: ICustomNode) => {
+            NodeAppender.appendNodeToOptimalBlockScope(
+                stackTraceData,
+                blockScopeNode,
+                customNode.getNode(),
+                randomStackTraceIndex
+            );
+        });
+
+        // nodeCallsControllerFunctionNode append
+        this.appendCustomNodeIfExist(CustomNodes.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
+            let targetBlockScope: TNodeWithBlockStatement;
+
+            if (stackTraceData.length) {
+                targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
+            } else {
+                targetBlockScope = blockScopeNode;
+            }
 
-        selfDefendingUnicodeNode.initialize(callsControllerFunctionName);
-        nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
+            NodeAppender.prependNode(targetBlockScope, customNode.getNode());
+        });
+    }
 
-        this.customNodes = new Map <string, ICustomNode> ([
-            ['selfDefendingUnicodeNode', selfDefendingUnicodeNode],
-            ['nodeCallsControllerFunctionNode', nodeCallsControllerFunctionNode]
-        ]);
+    public initialize (): void {
+        this.customNodes = new Map <CustomNodes, ICustomNode> ();
 
         if (!this.options.selfDefending) {
             return;
         }
 
-        this.obfuscationEventEmitter.once(
-            this.appendEvent,
-            (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]) => {
-                // selfDefendingUnicodeNode append
-                NodeAppender.appendNodeToOptimalBlockScope(
-                    stackTraceData,
-                    blockScopeNode,
-                    selfDefendingUnicodeNode.getNode(),
-                    randomStackTraceIndex
-                );
-
-                // nodeCallsControllerFunctionNode append
-                let targetBlockScope: TNodeWithBlockStatement;
-
-                if (stackTraceData.length) {
-                    targetBlockScope = NodeAppender
-                        .getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
-                } else {
-                    targetBlockScope = blockScopeNode;
-                }
-
-                NodeAppender.prependNode(targetBlockScope, nodeCallsControllerFunctionNode.getNode());
-            }
-        );
+        const callsControllerFunctionName: string = Utils.getRandomVariableName();
+
+        const selfDefendingUnicodeNode: ICustomNode = this.customNodeFactory(CustomNodes.SelfDefendingUnicodeNode);
+        const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNodes.NodeCallsControllerFunctionNode);
+
+        selfDefendingUnicodeNode.initialize(callsControllerFunctionName);
+        nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
+
+        this.customNodes.set(CustomNodes.SelfDefendingUnicodeNode, selfDefendingUnicodeNode);
+        this.customNodes.set(CustomNodes.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode);
     }
 }

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

@@ -36,20 +36,21 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
     private readonly customNodeFactory: TCustomNodeFactory;
 
     /**
-     * @type {Map<string, ICustomNode>}
+     * @type {Map<CustomNodes, ICustomNode>}
      */
     @initializable()
-    protected customNodes: Map <string, ICustomNode>;
+    protected customNodes: Map <CustomNodes, ICustomNode>;
 
     /**
-     * @type {string}
+     * @type {IObfuscationEventEmitter}
      */
-    protected readonly groupName: string = 'stringArrayCustomNodeGroup';
+    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
 
     /**
-     * @type {IObfuscationEventEmitter}
+     * @type {IStorage <string>}
      */
-    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
+    @initializable()
+    private stringArray: IStorage <string>;
 
     /**
      * @param customNodeFactory
@@ -68,10 +69,37 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
     }
 
     /**
+     * @param blockScopeNode
      * @param stackTraceData
      */
-    public initialize (stackTraceData: IStackTraceData[]): void {
-        const stringArray: IStorage <string> = new StringArrayStorage();
+    public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void {
+        if (!this.stringArray.getLength()) {
+            return;
+        }
+
+        // stringArrayNode append
+        this.appendCustomNodeIfExist(CustomNodes.StringArrayNode, (customNode: ICustomNode) => {
+            NodeAppender.prependNode(blockScopeNode, customNode.getNode());
+        });
+
+        // stringArrayCallsWrapper append
+        this.appendCustomNodeIfExist(CustomNodes.StringArrayCallsWrapper, (customNode: ICustomNode) => {
+            NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), 1);
+        });
+
+        // stringArrayRotateFunctionNode append
+        this.appendCustomNodeIfExist(CustomNodes.StringArrayRotateFunctionNode, (customNode: ICustomNode) => {
+            NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), 1);
+        });
+    }
+
+    public initialize (): void {
+        this.customNodes = new Map <CustomNodes, ICustomNode> ();
+        this.stringArray = new StringArrayStorage();
+
+        if (!this.options.stringArray) {
+            return;
+        }
 
         const stringArrayNode: ICustomNode = this.customNodeFactory(CustomNodes.StringArrayNode);
         const stringArrayCallsWrapper: ICustomNode = this.customNodeFactory(CustomNodes.StringArrayCallsWrapper);
@@ -88,44 +116,15 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
             stringArrayRotateValue = 0;
         }
 
-        stringArrayNode.initialize(stringArray, stringArrayName, stringArrayRotateValue);
-        stringArrayCallsWrapper.initialize(stringArray, stringArrayName, stringArrayCallsWrapperName);
-        stringArrayRotateFunctionNode.initialize(stringArray, stringArrayName, stringArrayRotateValue);
-
-        this.customNodes = new Map <string, ICustomNode> ([
-            ['stringArrayNode', stringArrayNode],
-            ['stringArrayCallsWrapper', stringArrayCallsWrapper]
-        ]);
-
-        this.obfuscationEventEmitter.once(
-            this.appendEvent,
-            (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]) => {
-                if (!this.options.stringArray || !stringArray.getLength()) {
-                    return;
-                }
-
-                // stringArrayNode append
-                NodeAppender.prependNode(blockScopeNode, stringArrayNode.getNode());
+        stringArrayNode.initialize(this.stringArray, stringArrayName, stringArrayRotateValue);
+        stringArrayCallsWrapper.initialize(this.stringArray, stringArrayName, stringArrayCallsWrapperName);
+        stringArrayRotateFunctionNode.initialize(this.stringArray, stringArrayName, stringArrayRotateValue);
 
-                // stringArrayCallsWrapper append
-                NodeAppender.insertNodeAtIndex(blockScopeNode, stringArrayCallsWrapper.getNode(), 1);
-            }
-        );
+        this.customNodes.set(CustomNodes.StringArrayNode, stringArrayNode);
+        this.customNodes.set(CustomNodes.StringArrayCallsWrapper, stringArrayCallsWrapper);
 
         if (this.options.rotateStringArray) {
-            this.customNodes.set('stringArrayRotateFunctionNode', stringArrayRotateFunctionNode);
-
-            this.obfuscationEventEmitter.once(
-                this.appendEvent,
-                (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]) => {
-                    if (!this.options.stringArray || !stringArray.getLength()) {
-                        return;
-                    }
-
-                    // stringArrayRotateFunctionNode append
-                    NodeAppender.insertNodeAtIndex(blockScopeNode, stringArrayRotateFunctionNode.getNode(), 1);
-                }
-            );
+            this.customNodes.set(CustomNodes.StringArrayRotateFunctionNode, stringArrayRotateFunctionNode);
         }
     }
 }

+ 15 - 6
src/interfaces/custom-nodes/ICustomNodeGroup.d.ts

@@ -1,20 +1,29 @@
+import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement';
+import { TObfuscationEvent } from '../../types/event-emitters/TObfuscationEvent';
+
 import { ICustomNode } from './ICustomNode';
 import { IInitializable } from '../IInitializable';
 import { IStackTraceData } from '../stack-trace-analyzer/IStackTraceData';
 
+import { CustomNodes } from '../../enums/container/CustomNodes';
+
 export interface ICustomNodeGroup extends IInitializable {
     /**
-     * @type {Map <string, ICustomNode>}
+     * @param blockScopeNode
+     * @param stackTraceData
      */
-    getCustomNodes (): Map <string, ICustomNode>;
+    appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void;
 
     /**
-     * @type {string}
+     * @returns {TObfuscationEvent}
      */
-    getGroupName (): string;
+    getAppendEvent (): TObfuscationEvent;
 
     /**
-     * @returns {Map <string, ICustomNode> | undefined}
+     * @type {Map <CustomNodes, ICustomNode>}
      */
-    initialize (stackTraceData: IStackTraceData[]): void;
+    getCustomNodes (): Map <CustomNodes, ICustomNode>;
+
+
+    initialize (): void;
 }

+ 13 - 13
src/node-transformers/node-obfuscators/replacers/StringLiteralReplacer.ts

@@ -1,9 +1,8 @@
 import { injectable, inject } from 'inversify';
 import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
 
-import { TCustomNodeGroupsFactory } from '../../../types/container/TCustomNodesFactoriesFactory';
-
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
+import { ICustomNodeGroup } from '../../../interfaces/custom-nodes/ICustomNodeGroup';
 import { ICustomNodeWithData } from '../../../interfaces/custom-nodes/ICustomNodeWithData';
 import { ICustomNodeWithIdentifier } from '../../../interfaces/custom-nodes/ICustomNodeWithIdentifier';
 import { IOptions } from '../../../interfaces/options/IOptions';
@@ -14,6 +13,7 @@ import { StringArrayEncoding } from '../../../enums/StringArrayEncoding';
 import { AbstractReplacer } from './AbstractReplacer';
 import { CustomNodeGroups } from '../../../enums/container/CustomNodeGroups';
 import { Utils } from '../../../Utils';
+import { CustomNodes } from '../../../enums/container/CustomNodes';
 
 @injectable()
 export class StringLiteralReplacer extends AbstractReplacer {
@@ -29,21 +29,21 @@ export class StringLiteralReplacer extends AbstractReplacer {
         .n(() => Utils.getRandomGenerator().string({length: 4}), 50);
 
     /**
-     * @type {TCustomNodeGroupsFactory}
+     * @type {IStorage<ICustomNodeGroup>}
      */
-    private readonly customNodeGroupsFactory: TCustomNodeGroupsFactory;
+    private readonly customNodeGroupStorage: IStorage<ICustomNodeGroup>;
 
     /**
-     * @param customNodeGroupsFactory
+     * @param customNodeGroupStorage
      * @param options
      */
     constructor (
-        @inject(ServiceIdentifiers['Factory<ICustomNodeGroup>']) customNodeGroupsFactory: TCustomNodeGroupsFactory,
+        @inject(ServiceIdentifiers['IStorage<ICustomNodeGroup>']) customNodeGroupStorage: IStorage<ICustomNodeGroup>,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
         super(options);
 
-        this.customNodeGroupsFactory = customNodeGroupsFactory;
+        this.customNodeGroupStorage = customNodeGroupStorage;
     }
 
     /**
@@ -68,11 +68,11 @@ export class StringLiteralReplacer extends AbstractReplacer {
      * @returns {string}
      */
     private replaceStringLiteralWithStringArrayCall (value: string): string {
-        const stringArrayCustomNodeGroupNodes: Map <string, ICustomNode> = this.customNodeGroupsFactory(
-            CustomNodeGroups.StringArrayCustomNodeGroup
-        ).getCustomNodes();
-
-        const stringArrayNode: ICustomNodeWithData = <ICustomNodeWithData>stringArrayCustomNodeGroupNodes.get('stringArrayNode');
+        const stringArrayCustomNodeGroupNodes: Map <CustomNodes, ICustomNode> = this.customNodeGroupStorage
+            .get(CustomNodeGroups.StringArrayCustomNodeGroup)
+            .getCustomNodes();
+        const stringArrayNode: ICustomNodeWithData = <ICustomNodeWithData>stringArrayCustomNodeGroupNodes
+            .get(CustomNodes.StringArrayNode);
 
         let rc4Key: string = '';
 
@@ -106,7 +106,7 @@ export class StringLiteralReplacer extends AbstractReplacer {
         }
 
         const stringArrayCallsWrapper: ICustomNodeWithIdentifier = <ICustomNodeWithIdentifier>stringArrayCustomNodeGroupNodes
-            .get('stringArrayCallsWrapper');
+            .get(CustomNodes.StringArrayCallsWrapper);
         const hexadecimalIndex: string = `${Utils.hexadecimalPrefix}${Utils.decToHex(indexOfValue)}`;
 
         if (this.options.stringArrayEncoding === StringArrayEncoding.rc4) {

+ 67 - 0
src/storages/custom-node-group/CustomNodeGroupStorage.ts

@@ -0,0 +1,67 @@
+import { injectable, inject } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import { TCustomNodeGroupFactory } from '../../types/container/TCustomNodeGroupFactory';
+
+import { ICustomNodeGroup } from '../../interfaces/custom-nodes/ICustomNodeGroup';
+import { IOptions } from '../../interfaces/options/IOptions';
+
+import { CustomNodeGroups } from '../../enums/container/CustomNodeGroups';
+
+import { MapStorage } from '../MapStorage';
+
+@injectable()
+export class CustomNodeGroupStorage extends MapStorage <ICustomNodeGroup> {
+    /**
+     * @type {CustomNodeGroups[]}
+     */
+    private static readonly customNodeGroupsList: CustomNodeGroups[] = [
+        CustomNodeGroups.ConsoleOutputCustomNodeGroup,
+        CustomNodeGroups.DebugProtectionCustomNodeGroup,
+        CustomNodeGroups.DomainLockCustomNodeGroup,
+        CustomNodeGroups.SelfDefendingCustomNodeGroup,
+        CustomNodeGroups.StringArrayCustomNodeGroup
+    ];
+
+    /**
+     * @type {TCustomNodesFactoriesFactory}
+     */
+    private readonly customNodeGroupFactory: TCustomNodeGroupFactory;
+
+    /**
+     * @type {IOptions}
+     */
+    private readonly options: IOptions;
+
+    /**
+     * @param customNodeGroupFactory
+     * @param options
+     */
+    constructor (
+        @inject(ServiceIdentifiers['Factory<ICustomNodeGroup>']) customNodeGroupFactory: TCustomNodeGroupFactory,
+        @inject(ServiceIdentifiers.IOptions) options: IOptions
+    ) {
+        super();
+
+        this.customNodeGroupFactory = customNodeGroupFactory;
+        this.options = options;
+
+        this.initialize();
+    }
+
+    public initialize (): void {
+        this.storage = new Map <string, ICustomNodeGroup> ();
+
+        CustomNodeGroupStorage.customNodeGroupsList.forEach((customNodeGroupName: CustomNodeGroups) => {
+            const customNodeGroup: ICustomNodeGroup = this.customNodeGroupFactory(
+                customNodeGroupName
+            );
+
+            if (!customNodeGroup) {
+                return;
+            }
+
+            this.storage.set(customNodeGroupName, customNodeGroup);
+        });
+    }
+}

+ 1 - 1
src/types/container/TCustomNodesFactoriesFactory.d.ts → src/types/container/TCustomNodeGroupFactory.d.ts

@@ -2,4 +2,4 @@ import { ICustomNodeGroup } from '../../interfaces/custom-nodes/ICustomNodeGroup
 
 import { CustomNodeGroups } from '../../enums/container/CustomNodeGroups';
 
-export type TCustomNodeGroupsFactory = (customNodeGroupsName: CustomNodeGroups) => ICustomNodeGroup;
+export type TCustomNodeGroupFactory = (customNodeGroupName: CustomNodeGroups) => ICustomNodeGroup;

Vissa filer visades inte eftersom för många filer har ändrats