From 389c49582c47da9f7785126853634f3a9bf241ff Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Thu, 30 Nov 2017 00:55:47 +0300 Subject: [PATCH] Identifier name generators: Hexadecimal and Mangled --- dist/index.js | 9025 ++++++++++++++++- package.json | 1 - src/JavaScriptObfuscator.ts | 5 - src/container/InversifyContainerFacade.ts | 2 + src/container/ServiceIdentifiers.ts | 3 +- .../modules/custom-nodes/CustomNodesModule.ts | 1 + .../modules/generators/GeneratorsModule.ts | 58 + .../modules/storages/StoragesModule.ts | 5 +- src/custom-nodes/AbstractCustomNode.ts | 11 + src/custom-nodes/AbstractCustomNodeGroup.ts | 15 +- .../ConsoleOutputDisableExpressionNode.ts | 8 +- .../group/ConsoleOutputCustomNodeGroup.ts | 8 +- .../BinaryExpressionFunctionNode.ts | 6 +- ...BlockStatementControlFlowFlatteningNode.ts | 6 +- .../CallExpressionFunctionNode.ts | 6 +- .../LogicalExpressionFunctionNode.ts | 6 +- .../StringLiteralNode.ts | 6 +- ...allExpressionControlFlowStorageCallNode.ts | 6 +- .../ControlFlowStorageNode.ts | 6 +- ...nWithOperatorControlFlowStorageCallNode.ts | 6 +- ...StringLiteralControlFlowStorageCallNode.ts | 6 +- .../DebugProtectionFunctionCallNode.ts | 6 +- .../DebugProtectionFunctionIntervalNode.ts | 6 +- .../DebugProtectionFunctionNode.ts | 6 +- .../group/DebugProtectionCustomNodeGroup.ts | 8 +- .../domain-lock-nodes/DomainLockNode.ts | 8 +- .../group/DomainLockCustomNodeGroup.ts | 8 +- .../NodeCallsControllerFunctionNode.ts | 7 +- .../SelfDefendingUnicodeNode.ts | 9 +- .../group/SelfDefendingCustomNodeGroup.ts | 8 +- .../StringArrayCallsWrapper.ts | 7 +- .../string-array-nodes/StringArrayNode.ts | 6 +- .../StringArrayRotateFunctionNode.ts | 11 +- .../group/StringArrayCustomNodeGroup.ts | 14 +- src/declarations/esmangle.d.ts | 5 - .../IdentifierNameGenerator.ts | 4 + .../AbstractIdentifierNameGenerator.ts | 37 + .../HexadecimalIdentifierNameGenerator.ts | 48 + .../MangledIdentifierNameGenerator.ts | 116 + .../IIdentifierNameGenerator.d.ts | 7 + .../IDeadCodeInjectionReplacer.d.ts | 13 - src/interfaces/utils/IRandomGenerator.d.ts | 6 - .../BaseIdentifierObfuscatingReplacer.ts | 23 +- .../StringLiteralObfuscatingReplacer.ts | 3 +- src/storages/ArrayStorage.ts | 11 +- src/storages/MapStorage.ts | 11 +- .../control-flow/ControlFlowStorage.ts | 7 +- .../CustomNodeGroupStorage.ts | 5 +- .../string-array/StringArrayStorage.ts | 25 +- .../DebufProtectionFunctionCallTemplate.ts | 2 +- .../TInversifyContainerModuleFactory.d.ts | 5 + .../TIdentifierNameGeneratorFactory.d.ts | 4 + src/utils/RandomGenerator.ts | 28 - test/dev/dev.ts | 3 +- .../JavaScriptObfuscator.spec.ts | 2 +- test/index.spec.ts | 3 +- ...HexadecimalIdentifierNameGenerator.spec.ts | 52 + .../MangledlIdentifierNameGenerator.spec.ts | 95 + test/unit-tests/storages/ArrayStorage.spec.ts | 6 +- test/unit-tests/storages/MapStorage.spec.ts | 6 +- .../utils/RandomGeneratorUtils.spec.ts | 45 - 61 files changed, 9698 insertions(+), 174 deletions(-) create mode 100644 src/container/modules/generators/GeneratorsModule.ts delete mode 100644 src/declarations/esmangle.d.ts create mode 100644 src/enums/generators/identifier-name-generators/IdentifierNameGenerator.ts create mode 100644 src/generators/identifier-name-generators/AbstractIdentifierNameGenerator.ts create mode 100644 src/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.ts create mode 100644 src/generators/identifier-name-generators/MangledIdentifierNameGenerator.ts create mode 100644 src/interfaces/generators/identifier-name-generators/IIdentifierNameGenerator.d.ts delete mode 100644 src/interfaces/node-transformers/dead-code-injection-transformers/IDeadCodeInjectionReplacer.d.ts create mode 100644 src/types/container/TInversifyContainerModuleFactory.d.ts create mode 100644 src/types/container/generators/TIdentifierNameGeneratorFactory.d.ts create mode 100644 test/unit-tests/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.spec.ts create mode 100644 test/unit-tests/generators/identifier-name-generators/MangledlIdentifierNameGenerator.spec.ts delete mode 100644 test/unit-tests/utils/RandomGeneratorUtils.spec.ts diff --git a/dist/index.js b/dist/index.js index f1384aa9..77705d5f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -21,5 +21,9028 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -require("source-map-support").install(),module.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=44)}([function(e,t){e.exports=require("inversify")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.Factory__ICalleeDataExtractor="Factory",e.Factory__IControlFlowCustomNode="Factory",e.Factory__IControlFlowReplacer="Factory",e.Factory__ICustomNode="Factory",e.Factory__ICustomNodeGroup="Factory",e.Factory__IIdentifierObfuscatingReplacer="Factory",e.Factory__INodeGuard="Factory",e.Factory__INodeTransformer="Factory",e.Factory__IObfuscationResult="Factory",e.Factory__IObfuscatingReplacer="Factory",e.Factory__TControlFlowStorage="Factory",e.IArrayUtils="IArrayUtils",e.ICalleeDataExtractor="ICalleeDataExtractor",e.ICryptUtils="ICryptUtils",e.ICustomNode="ICustomNode",e.ICustomNodeGroup="ICustomNodeGroup",e.IControlFlowReplacer="IControlFlowReplacer",e.IDeadCodeInjectionReplacer="IDeadCodeInjectionReplacer",e.IEscapeSequenceEncoder="IEscapeSequenceEncoder",e.IIdentifierObfuscatingReplacer="IIdentifierObfuscatingReplacer",e.IJavaScriptObfuscator="IJavaScriptObfuscator",e.ILogger="ILogger",e.INodeGuard="INodeGuard",e.INodeTransformer="INodeTransformer",e.IObfuscationEventEmitter="IObfuscationEventEmitter",e.IObfuscationResult="IObfuscationResult",e.IOptions="IOptions",e.IObfuscatingReplacer="IObfuscatingReplacer",e.IRandomGenerator="IRandomGenerator",e.ISourceCode="ISourceCode",e.ISourceMapCorrector="ISourceMapCorrector",e.IStackTraceAnalyzer="IStackTraceAnalyzer",e.ITransformersRunner="ITransformersRunner",e.Newable__ICustomNode="Newable",e.Newable__TControlFlowStorage="Newable",e.TCustomNodeGroupStorage="TCustomNodeGroupStorage",e.TStringArrayStorage="TStringArrayStorage"}(t.ServiceIdentifiers||(t.ServiceIdentifiers={}))},function(e,t){e.exports=require("tslib")},function(e,t,r){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initialize",t=Object.keys(this)[0];return function(r,n){var o={configurable:!0,enumerable:!0},a=r[e];if(!a||"function"!=typeof a)throw new Error("`"+e+"` method with initialization logic not found. `@"+t+"` decorator requires `"+e+"` method");var i="_"+n,c=Object.getOwnPropertyDescriptor(r,i)||o,s=Object.getOwnPropertyDescriptor(r,e)||o,u=s.value;return Object.defineProperty(r,n,Object.assign({},c,{get:function(){if(void 0===this[i])throw new Error("Property `"+n+"` is not initialized! Initialize it first!");return this[i]},set:function(e){this[i]=e}})),Object.defineProperty(r,e,Object.assign({},s,{value:function(){u.apply(this,arguments),this[n]}})),c}}Object.defineProperty(t,"__esModule",{value:!0}),t.initializable=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(l.NodeGuards.isNodeHasBlockStatement(e)){if(void 0===e.body[t])throw new ReferenceError("Wrong index `"+t+"`. Block-statement body length is `"+e.body.length+"`");return e.body[t]}throw new TypeError("The specified node have no a block-statement")}},{key:"getBlockScopesOfNode",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=t.parentNode;if(!n)throw new ReferenceError("`parentNode` property of given node is `undefined`");if(l.NodeGuards.isBlockStatementNode(n)){if(!n.parentNode)throw new ReferenceError("`parentNode` property of `parentNode` of given node is `undefined`");-1!==e.nodesWithBlockScope.indexOf(n.parentNode.type)&&r.push(n)}return t!==n?e.getBlockScopesOfNode(n,r):(l.NodeGuards.isNodeHasBlockStatement(n)&&r.push(n),r)}},{key:"getNodeBlockScopeDepth",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t.parentNode;if(!n)throw new ReferenceError("`parentNode` property of given node is `undefined`");return l.NodeGuards.isProgramNode(n)?r:l.NodeGuards.isBlockStatementNode(t)&&-1!==e.nodesWithBlockScope.indexOf(n.type)?e.getNodeBlockScopeDepth(n,++r):e.getNodeBlockScopeDepth(n,r)}},{key:"getUnaryExpressionArgumentNode",value:function(t){return l.NodeGuards.isUnaryExpressionNode(t.argument)?e.getUnaryExpressionArgumentNode(t.argument):t.argument}},{key:"parentize",value:function(t){return s.traverse(t,{enter:e.parentizeNode}),t}},{key:"parentizeNode",value:function(e,t){return e.parentNode=t||e,e.obfuscatedNode=!1,e}}]),e}();f.nodesWithBlockScope=[u.NodeType.ArrowFunctionExpression,u.NodeType.FunctionDeclaration,u.NodeType.FunctionExpression,u.NodeType.MethodDefinition,u.NodeType.Program],t.NodeUtils=f},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.Program,body:e,sourceType:"script",obfuscatedNode:!1}}},{key:"getArrayExpressionNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.ArrayExpression,elements:e}}},{key:"getAssignmentExpressionNode",value:function(e,t,r){return{type:i.NodeType.AssignmentExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getBinaryExpressionNode",value:function(e,t,r){return{type:i.NodeType.BinaryExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getBlockStatementNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.BlockStatement,body:e,obfuscatedNode:!1}}},{key:"getBreakStatement",value:function(e){var t={type:i.NodeType.BreakStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getCatchClauseNode",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.CatchClause,param:e.getIdentifierNode("err"),body:e.getBlockStatementNode(t),obfuscatedNode:!1}}},{key:"getCallExpressionNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:i.NodeType.CallExpression,callee:e,arguments:t,obfuscatedNode:!1}}},{key:"getContinueStatement",value:function(e){var t={type:i.NodeType.ContinueStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getExpressionStatementNode",value:function(e){return{type:i.NodeType.ExpressionStatement,expression:e,obfuscatedNode:!1}}},{key:"getFunctionDeclarationNode",value:function(t,r,n){return{type:i.NodeType.FunctionDeclaration,id:e.getIdentifierNode(t),params:r,body:n,generator:!1,obfuscatedNode:!1}}},{key:"getFunctionExpressionNode",value:function(e,t){return{type:i.NodeType.FunctionExpression,params:e,body:t,generator:!1,obfuscatedNode:!1}}},{key:"getIfStatementNode",value:function(e,t,r){return Object.assign({type:i.NodeType.IfStatement,test:e,consequent:t},r&&{alternate:r},{obfuscatedNode:!1})}},{key:"getIdentifierNode",value:function(e){return{type:i.NodeType.Identifier,name:e,obfuscatedNode:!1}}},{key:"getLabeledStatement",value:function(e,t){return{type:i.NodeType.LabeledStatement,label:e,body:t,obfuscatedNode:!1}}},{key:"getLiteralNode",value:function(e,t){return t=void 0!==t?t:"'"+e+"'",{type:i.NodeType.Literal,value:e,raw:t,"x-verbatim-property":{content:t,precedence:a.Precedence.Primary},obfuscatedNode:!1}}},{key:"getLogicalExpressionNode",value:function(e,t,r){return{type:i.NodeType.LogicalExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getMemberExpressionNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.MemberExpression,computed:r,object:e,property:t,obfuscatedNode:!1}}},{key:"getObjectExpressionNode",value:function(e){return{type:i.NodeType.ObjectExpression,properties:e,obfuscatedNode:!1}}},{key:"getPropertyNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.Property,key:e,value:t,kind:"init",method:!1,shorthand:!1,computed:r,obfuscatedNode:!1}}},{key:"getUnaryExpressionNode",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return{type:i.NodeType.UnaryExpression,operator:e,argument:t,prefix:r,obfuscatedNode:!1}}},{key:"getReturnStatementNode",value:function(e){return{type:i.NodeType.ReturnStatement,argument:e,obfuscatedNode:!1}}},{key:"getSwitchStatementNode",value:function(e,t){return{type:i.NodeType.SwitchStatement,discriminant:e,cases:t,obfuscatedNode:!1}}},{key:"getSwitchCaseNode",value:function(e,t){return{type:i.NodeType.SwitchCase,test:e,consequent:t,obfuscatedNode:!1}}},{key:"getUpdateExpressionNode",value:function(e,t){return{type:i.NodeType.UpdateExpression,operator:e,argument:t,prefix:!1,obfuscatedNode:!1}}},{key:"getVariableDeclarationNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"var";return{type:i.NodeType.VariableDeclaration,declarations:e,kind:t,obfuscatedNode:!1}}},{key:"getVariableDeclaratorNode",value:function(e,t){return{type:i.NodeType.VariableDeclarator,id:e,init:t,obfuscatedNode:!1}}},{key:"getWhileStatementNode",value:function(e,t){return{type:i.NodeType.WhileStatement,test:e,body:t,obfuscatedNode:!1}}}]),e}();t.Nodes=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.ArrayExpression="ArrayExpression",e.ArrowFunctionExpression="ArrowFunctionExpression",e.AssignmentExpression="AssignmentExpression",e.AssignmentPattern="AssignmentPattern",e.AwaitExpression="AwaitExpression",e.BinaryExpression="BinaryExpression",e.BlockStatement="BlockStatement",e.BreakStatement="BreakStatement",e.CallExpression="CallExpression",e.CatchClause="CatchClause",e.ClassDeclaration="ClassDeclaration",e.ContinueStatement="ContinueStatement",e.ExpressionStatement="ExpressionStatement",e.FunctionDeclaration="FunctionDeclaration",e.FunctionExpression="FunctionExpression",e.Identifier="Identifier",e.IfStatement="IfStatement",e.LabeledStatement="LabeledStatement",e.Literal="Literal",e.LogicalExpression="LogicalExpression",e.MemberExpression="MemberExpression",e.MethodDefinition="MethodDefinition",e.ObjectExpression="ObjectExpression",e.ObjectPattern="ObjectPattern",e.Program="Program",e.Property="Property",e.ReturnStatement="ReturnStatement",e.SwitchCase="SwitchCase",e.SwitchStatement="SwitchStatement",e.TemplateLiteral="TemplateLiteral",e.TryStatement="TryStatement",e.UnaryExpression="UnaryExpression",e.UpdateExpression="UpdateExpression",e.VariableDeclaration="VariableDeclaration",e.VariableDeclarator="VariableDeclarator",e.WhileStatement="WhileStatement"}(t.NodeType||(t.NodeType={}))},function(e,t){e.exports=require("string-template")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BinaryExpressionFunctionNode=0]="BinaryExpressionFunctionNode",e[e.BlockStatementControlFlowFlatteningNode=1]="BlockStatementControlFlowFlatteningNode",e[e.CallExpressionControlFlowStorageCallNode=2]="CallExpressionControlFlowStorageCallNode",e[e.CallExpressionFunctionNode=3]="CallExpressionFunctionNode",e[e.ControlFlowStorageNode=4]="ControlFlowStorageNode",e[e.ExpressionWithOperatorControlFlowStorageCallNode=5]="ExpressionWithOperatorControlFlowStorageCallNode",e[e.LogicalExpressionFunctionNode=6]="LogicalExpressionFunctionNode",e[e.StringLiteralControlFlowStorageCallNode=7]="StringLiteralControlFlowStorageCallNode",e[e.StringLiteralNode=8]="StringLiteralNode"}(t.ControlFlowCustomNode||(t.ControlFlowCustomNode={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.Browser="browser",e.Extension="extension",e.Node="node"}(t.ObfuscationTarget||(t.ObfuscationTarget={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1?t-1:0),n=1;n-1||0===e.indexOf("//")?e.split("/")[2]:e.split("/")[0],t=t.split(":")[0]}},{key:"isCeilNumber",value:function(e){return e%1==0}},{key:"stringRotate",value:function(e,t){if(!e)throw new ReferenceError("Cannot rotate empty string.");for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{},r=new i.InversifyContainerFacade;r.load(e,t);var n=r.get(a.ServiceIdentifiers.IJavaScriptObfuscator),o=n.obfuscate(e);return r.unload(),o}},{key:"runCLI",value:function(e){var t=new c.JavaScriptObfuscatorCLI(e);t.initialize(),t.run()}}]),e}();t.JavaScriptObfuscator=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BlockStatementControlFlowTransformer=0]="BlockStatementControlFlowTransformer",e[e.ClassDeclarationTransformer=1]="ClassDeclarationTransformer",e[e.DeadCodeInjectionTransformer=2]="DeadCodeInjectionTransformer",e[e.FunctionControlFlowTransformer=3]="FunctionControlFlowTransformer",e[e.CatchClauseTransformer=4]="CatchClauseTransformer",e[e.FunctionDeclarationTransformer=5]="FunctionDeclarationTransformer",e[e.FunctionTransformer=6]="FunctionTransformer",e[e.LabeledStatementTransformer=7]="LabeledStatementTransformer",e[e.LiteralTransformer=8]="LiteralTransformer",e[e.MemberExpressionTransformer=9]="MemberExpressionTransformer",e[e.MethodDefinitionTransformer=10]="MethodDefinitionTransformer",e[e.ObfuscatingGuardsTransformer=11]="ObfuscatingGuardsTransformer",e[e.ObjectExpressionTransformer=12]="ObjectExpressionTransformer",e[e.ParentificationTransformer=13]="ParentificationTransformer",e[e.TemplateLiteralTransformer=14]="TemplateLiteralTransformer",e[e.VariableDeclarationTransformer=15]="VariableDeclarationTransformer"}(t.NodeTransformer||(t.NodeTransformer={}))},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t3&&void 0!==arguments[3]?arguments[3]:0,a=void 0;a=t.length?e.getOptimalBlockScope(t,o):r,e.prependNode(a,n)}},{key:"getOptimalBlockScope",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,o=t[r];if(n<=0)throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");return n>1&&o.stackTrace.length?e.getOptimalBlockScope(o.stackTrace,0,--n):o.callee}},{key:"insertNodeAtIndex",value:function(t,r,o){e.validateBodyStatements(r)||(r=[]),r=e.parentizeBodyStatementsBeforeAppend(t,r),t.body=[].concat(n(t.body.slice(0,o)),n(r),n(t.body.slice(o)))}},{key:"prependNode",value:function(t,r){e.validateBodyStatements(r)||(r=[]),r=e.parentizeBodyStatementsBeforeAppend(t,r),t.body=[].concat(n(r),n(t.body))}},{key:"parentizeBodyStatementsBeforeAppend",value:function(e,t){return t.forEach(function(t){t.parentNode=e}),t}},{key:"validateBodyStatements",value:function(e){return e.every(function(e){return!!e&&e.hasOwnProperty("type")})}}]),e}();t.NodeAppender=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.ConsoleOutputDisableExpressionNode=0]="ConsoleOutputDisableExpressionNode",e[e.DebugProtectionFunctionCallNode=1]="DebugProtectionFunctionCallNode",e[e.DebugProtectionFunctionIntervalNode=2]="DebugProtectionFunctionIntervalNode",e[e.DebugProtectionFunctionNode=3]="DebugProtectionFunctionNode",e[e.DomainLockNode=4]="DomainLockNode",e[e.NodeCallsControllerFunctionNode=5]="NodeCallsControllerFunctionNode",e[e.SelfDefendingUnicodeNode=6]="SelfDefendingUnicodeNode",e[e.StringArrayCallsWrapper=7]="StringArrayCallsWrapper",e[e.StringArrayNode=8]="StringArrayNode",e[e.StringArrayRotateFunctionNode=9]="StringArrayRotateFunctionNode"}(t.CustomNode||(t.CustomNode={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:p.randomGeneratorPool;return this.getRandomGenerator().string({length:e,pool:t})}},{key:"getRandomVariableName",value:function(e){var t="_"+f.Utils.hexadecimalPrefix,r=this.getRandomInteger(1e4,99999999),n=f.Utils.decToHex(r),o=""+t+n.substr(0,e);return this.randomVariableNameSet.has(o)?this.getRandomVariableName(e):(this.randomVariableNameSet.add(o),o)}},{key:"getSeed",value:function(){return this.seed}}]),e}();d.randomGeneratorPool="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",d.randomGeneratorPoolNumbers="0123456789",d.randomGeneratorPoolHexadecimal="abcdef"+p.randomGeneratorPoolNumbers,a.__decorate([l.initializable(),a.__metadata("design:type",Object)],d.prototype,"randomGenerator",void 0),a.__decorate([l.initializable(),a.__metadata("design:type",Number)],d.prototype,"seed",void 0),a.__decorate([i.postConstruct(),a.__metadata("design:type",Function),a.__metadata("design:paramtypes",[]),a.__metadata("design:returntype",void 0)],d.prototype,"initialize",null),d=p=a.__decorate([i.injectable(),a.__param(0,i.inject(c.ServiceIdentifiers.ISourceCode)),a.__param(1,i.inject(c.ServiceIdentifiers.IOptions)),a.__metadata("design:paramtypes",[Object,Object])],d),t.RandomGenerator=d;var p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(13),o=r(23);t.DEFAULT_PRESET=Object.freeze({compact:!0,config:"",controlFlowFlattening:!1,controlFlowFlatteningThreshold:.75,deadCodeInjection:!1,deadCodeInjectionThreshold:.4,debugProtection:!1,debugProtectionInterval:!1,disableConsoleOutput:!1,domainLock:[],log:!1,mangle:!1,renameGlobals:!1,reservedNames:[],rotateStringArray:!0,seed:0,selfDefending:!1,sourceMap:!1,sourceMapBaseUrl:"",sourceMapFileName:"",sourceMapMode:o.SourceMapMode.Separate,stringArray:!0,stringArrayEncoding:!1,stringArrayThreshold:.75,target:n.ObfuscationTarget.Browser,unicodeEscapeSequence:!1})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r [options]").version(m.CLIUtils.getPackageConfig().version,"-v, --version").option("-o, --output ","Output path for obfuscated code").option("--compact ","Disable one line output code compacting",f.BooleanSanitizer).option("--config ","Name of js / json config file").option("--controlFlowFlattening ","Enables control flow flattening",f.BooleanSanitizer).option("--controlFlowFlatteningThreshold ","The probability that the control flow flattening transformation will be applied to the node",parseFloat).option("--deadCodeInjection ","Enables dead code injection",f.BooleanSanitizer).option("--deadCodeInjectionThreshold ","The probability that the dead code injection transformation will be applied to the node",parseFloat).option("--debugProtection ","Disable browser Debug panel (can cause DevTools enabled browser freeze)",f.BooleanSanitizer).option("--debugProtectionInterval ","Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)",f.BooleanSanitizer).option("--disableConsoleOutput ","Allow console.log, console.info, console.error and console.warn messages output into browser console",f.BooleanSanitizer).option("--domainLock (comma separated, without whitespaces)","Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)",l.ArraySanitizer).option("--log ","Enables logging of the information to the console",f.BooleanSanitizer).option("--mangle ","Enables mangling of variable names",f.BooleanSanitizer).option("--reservedNames (comma separated, without whitespaces)","Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)",l.ArraySanitizer).option("--renameGlobals ","Allows to enable obfuscation of global variable and function names with declaration.",f.BooleanSanitizer).option("--rotateStringArray ","Disable rotation of unicode array values during obfuscation",f.BooleanSanitizer).option("--seed ","Sets seed for random generator. This is useful for creating repeatable results.",parseFloat).option("--selfDefending ","Disables self-defending for obfuscated code",f.BooleanSanitizer).option("--sourceMap ","Enables source map generation",f.BooleanSanitizer).option("--sourceMapBaseUrl ","Sets base url to the source map import url when `--sourceMapMode=separate`").option("--sourceMapFileName ","Sets file name for output source map when `--sourceMapMode=separate`").option("--sourceMapMode [inline, separate]","Specify source map output mode",p.SourceMapModeSanitizer).option("--stringArray ","Disables gathering of all literal strings into an array and replacing every literal string with an array call",f.BooleanSanitizer).option("--stringArrayEncoding [true, false, base64, rc4]","Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed",y.StringArrayEncodingSanitizer).option("--stringArrayThreshold ","The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)",parseFloat).option("--target ","Allows to set target environment for obfuscated code.",d.ObfuscationTargetSanitizer).option("--unicodeEscapeSequence ","Allows to enable/disable string conversion to unicode escape sequence",f.BooleanSanitizer).parse(this.rawArguments)}},{key:"configureHelp",value:function(){this.commands.on("--help",function(){console.log(" Examples:\n"),console.log(" %> javascript-obfuscator input_file_name.js --compact true --selfDefending false"),console.log(" %> javascript-obfuscator input_file_name.js --output output_file_name.js --compact true --selfDefending false"),console.log(" %> javascript-obfuscator input_directory_name --compact true --selfDefending false"),console.log("")})}},{key:"processSourceCodeData",value:function(e){var t=this;if(Array.isArray(e))e.forEach(function(e){var r=e.filePath,n=e.content,o=m.CLIUtils.getOutputCodePath(r);t.processSourceCode(n,o)});else{var r=this.inputCLIOptions.output||m.CLIUtils.getOutputCodePath(this.inputPath);this.processSourceCode(e,r)}}},{key:"processSourceCode",value:function(t,r){var n=this.buildOptions();n.sourceMap?e.processSourceCodeWithSourceMap(t,r,n):e.processSourceCodeWithoutSourceMap(t,r,n)}}],[{key:"filterOptions",value:function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&void 0!==e[r]&&(t[r]=e[r]);return t}},{key:"processSourceCodeWithoutSourceMap",value:function(e,t,r){var n=b.JavaScriptObfuscator.obfuscate(e,r).getObfuscatedCode();m.CLIUtils.writeFile(t,n)}},{key:"processSourceCodeWithSourceMap",value:function(e,t,r){var n=m.CLIUtils.getOutputSourceMapPath(t,r.sourceMapFileName||"");r=Object.assign({},r,{sourceMapFileName:c.basename(n)});var o=b.JavaScriptObfuscator.obfuscate(e,r);m.CLIUtils.writeFile(t,o.getObfuscatedCode()),"separate"===r.sourceMapMode&&o.getSourceMap()&&m.CLIUtils.writeFile(n,o.getSourceMap())}}]),e}();h.availableInputExtensions=[".js"],h.encoding="utf8",h.obfuscatedFilePrefix="-obfuscated",a.__decorate([s.initializable(),a.__metadata("design:type",Object)],h.prototype,"commands",void 0),a.__decorate([s.initializable(),a.__metadata("design:type",Object)],h.prototype,"inputCLIOptions",void 0),a.__decorate([s.initializable(),a.__metadata("design:type",String)],h.prototype,"inputPath",void 0),t.JavaScriptObfuscatorCLI=h},function(e,t){e.exports=require("path")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.FunctionDeclarationCalleeDataExtractor=0]="FunctionDeclarationCalleeDataExtractor",e[e.FunctionExpressionCalleeDataExtractor=1]="FunctionExpressionCalleeDataExtractor",e[e.ObjectExpressionCalleeDataExtractor=2]="ObjectExpressionCalleeDataExtractor"}(t.CalleeDataExtractor||(t.CalleeDataExtractor={}))},function(e,t){e.exports=require("esprima")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BinaryExpressionControlFlowReplacer=0]="BinaryExpressionControlFlowReplacer",e[e.CallExpressionControlFlowReplacer=1]="CallExpressionControlFlowReplacer",e[e.LogicalExpressionControlFlowReplacer=2]="LogicalExpressionControlFlowReplacer",e[e.StringLiteralControlFlowReplacer=3]="StringLiteralControlFlowReplacer"}(t.ControlFlowReplacer||(t.ControlFlowReplacer={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]&&arguments[1];this.storage=new Map([].concat(n(this.storage),n(e.getStorage()))),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){this.storage.set(e,t)}}]),e}();c.__decorate([l.initializable(),c.__metadata("design:type",String)],f.prototype,"storageId",void 0),c.__decorate([l.initializable(),c.__metadata("design:type",Map)],f.prototype,"storage",void 0),c.__decorate([s.postConstruct(),c.__metadata("design:type",Function),c.__metadata("design:paramtypes",[]),c.__metadata("design:returntype",void 0)],f.prototype,"initialize",null),f=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__metadata("design:paramtypes",[Object])],f),t.MapStorage=f},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(18);e.exports=n.JavaScriptObfuscator},function(e,t){e.exports=require("reflect-metadata")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(35),c=r(47),s=r(48),u=r(49),l=r(50);t.analyzersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IStackTraceAnalyzer).to(l.StackTraceAnalyzer).inSingletonScope(),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(c.FunctionDeclarationCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(s.FunctionExpressionCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(u.ObjectExpressionCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor),e(a.ServiceIdentifiers.Factory__ICalleeDataExtractor).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.ICalleeDataExtractor))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rr)return"break";var a=e[o];s.traverse(a,{enter:function(r){if(l.NodeGuards.isCallExpressionNode(r))return a.parentNode!==f.NodeUtils.getBlockScopesOfNode(r)[0]?s.VisitorOption.Skip:void t.analyzeCallExpressionNode(n,e,r)}})}(a))break}return n}},{key:"analyzeCallExpressionNode",value:function(e,t,r){var n=this;p.calleeDataExtractorsList.forEach(function(o){var a=n.calleeDataExtractorFactory(o).extract(t,r.callee);a&&e.push(Object.assign({},a,{stackTrace:n.analyzeRecursive(a.callee.body)}))})}}],[{key:"getLimitIndex",value:function(e){var t=e-1,r=p.limitThresholdActivationLength-1,n=t;return t>r&&(n=Math.round(r+t*p.limitThreshold))>t&&(n=t),n}}]),e}();d.calleeDataExtractorsList=[u.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor,u.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor,u.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor],d.limitThresholdActivationLength=25,d.limitThreshold=.002,d=p=a.__decorate([i.injectable(),a.__param(0,i.inject(c.ServiceIdentifiers.Factory__ICalleeDataExtractor)),a.__metadata("design:paramtypes",[Function])],d),t.StackTraceAnalyzer=d;var p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(37),c=r(19),s=r(52),u=r(53),l=r(54),f=r(55),d=r(56),p=r(57),y=r(58);t.controlFlowTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(u.BlockStatementControlFlowTransformer).whenTargetNamed(c.NodeTransformer.BlockStatementControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(f.DeadCodeInjectionTransformer).whenTargetNamed(c.NodeTransformer.DeadCodeInjectionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.FunctionControlFlowTransformer).whenTargetNamed(c.NodeTransformer.FunctionControlFlowTransformer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(s.BinaryExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.BinaryExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(l.CallExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.CallExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(p.LogicalExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.LogicalExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(y.StringLiteralControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.StringLiteralControlFlowReplacer),e(a.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IControlFlowReplacer))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rthis.options.controlFlowFlatteningThreshold||!m.canTransformBlockStatementNode(e))return e;var r=e.body,n=this.arrayUtils.arrayRange(r.length),o=this.arrayUtils.arrayShuffle(n),a=n.map(function(e){return o.indexOf(e)}),i=this.controlFlowCustomNodeFactory(f.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);return i.initialize(r,o,a),i.getNode()[0]}}],[{key:"blockStatementHasProhibitedStatements",value:function(e){return e.body.some(function(e){var t=p.NodeGuards.isBreakStatementNode(e)||p.NodeGuards.isContinueStatementNode(e),r=p.NodeGuards.isVariableDeclarationNode(e)&&("const"===e.kind||"let"===e.kind);return p.NodeGuards.isFunctionDeclarationNode(e)||t||r})}},{key:"canTransformBlockStatementNode",value:function(e){var t=!0;return l.traverse(e,{enter:function(e){if(p.NodeGuards.isWhileStatementNode(e))return l.VisitorOption.Skip;p.NodeGuards.isBlockStatementNode(e)&&m.blockStatementHasProhibitedStatements(e)&&(t=!1)}}),e.body.length<=4&&(t=!1),t}}]),t}(d.AbstractNodeTransformer);y=m=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.Factory__IControlFlowCustomNode)),c.__param(1,s.inject(u.ServiceIdentifiers.IArrayUtils)),c.__param(2,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(3,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Function,Object,Object,Object])],y),t.BlockStatementControlFlowTransformer=y;var m},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rthis.options.deadCodeInjectionThreshold)return e;if(g.NodeUtils.getBlockScopesOfNode(e)[0].type===p.NodeType.Program)return e;var r=this.collectedBlockStatements.length-1,n=this.randomGenerator.getRandomInteger(0,r),o=this.collectedBlockStatements.splice(n,1)[0];return o===e?e:this.replaceBlockStatementNode(e,o)}},{key:"collectBlockStatementNodes",value:function(e,t){var r=g.NodeUtils.clone(e),n=0,o=!0;f.replace(r,{enter:function(e,t){return m.NodeGuards.isBlockStatementNode(e)&&n++,n>v.maxNestedBlockStatementsCount||m.NodeGuards.isBreakStatementNode(e)||m.NodeGuards.isContinueStatementNode(e)||m.NodeGuards.isAwaitExpressionNode(e)?(o=!1,f.VisitorOption.Break):e}}),o&&(r=this.transformersRunner.transform(r,v.transformersToRenameBlockScopeIdentifiers),t.push(r))}},{key:"replaceBlockStatementNode",value:function(e,t){var r=this.randomGenerator.getMathRandom()>.5,n=this.randomGenerator.getMathRandom()>.5,o=r?"===":"!==",a=this.randomGenerator.getRandomString(3),c=n?a:this.randomGenerator.getRandomString(3),s=r===n?[e,t]:[t,e],u=i(s,2),l=u[0],f=u[1],d=b.Nodes.getBlockStatementNode([b.Nodes.getIfStatementNode(b.Nodes.getBinaryExpressionNode(o,b.Nodes.getLiteralNode(a),b.Nodes.getLiteralNode(c)),l,f)]);return d=g.NodeUtils.parentize(d)}}]),t}(y.AbstractNodeTransformer);h.maxNestedBlockStatementsCount=4,h.minCollectedBlockStatementsCount=5,h.transformersToRenameBlockScopeIdentifiers=[d.NodeTransformer.CatchClauseTransformer,d.NodeTransformer.ClassDeclarationTransformer,d.NodeTransformer.FunctionDeclarationTransformer,d.NodeTransformer.FunctionTransformer,d.NodeTransformer.LabeledStatementTransformer,d.NodeTransformer.VariableDeclarationTransformer],h=v=s.__decorate([u.injectable(),s.__param(0,u.inject(l.ServiceIdentifiers.ITransformersRunner)),s.__param(1,u.inject(l.ServiceIdentifiers.IRandomGenerator)),s.__param(2,u.inject(l.ServiceIdentifiers.IOptions)),s.__metadata("design:paramtypes",[Object,Object,Object])],h),t.DeadCodeInjectionTransformer=h;var v},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rv.hostNodeSearchMinDepth&&t.splice(0,v.hostNodeSearchMinDepth),t.length>v.hostNodeSearchMaxDepth&&(t.length=v.hostNodeSearchMaxDepth),this.randomGenerator.getRandomGenerator().pickone(t))}},{key:"isVisitedFunctionNode",value:function(e){return(m.NodeGuards.isFunctionDeclarationNode(e)||m.NodeGuards.isFunctionExpressionNode(e)||m.NodeGuards.isArrowFunctionExpressionNode(e))&&this.visitedFunctionNodes.has(e)}},{key:"transformFunctionBody",value:function(e,t){var r=this;l.replace(e,{enter:function(e,n){if(r.isVisitedFunctionNode(e)||!n)return l.VisitorOption.Skip;if(!v.controlFlowReplacersMap.has(e.type))return e;if(r.randomGenerator.getMathRandom()>r.options.controlFlowFlatteningThreshold)return e;var o=v.controlFlowReplacersMap.get(e.type);return void 0===o?e:Object.assign({},r.controlFlowReplacerFactory(o).replace(e,n,t),{parentNode:n})}})}}]),t}(y.AbstractNodeTransformer);h.controlFlowReplacersMap=new Map([[p.NodeType.BinaryExpression,d.ControlFlowReplacer.BinaryExpressionControlFlowReplacer],[p.NodeType.CallExpression,d.ControlFlowReplacer.CallExpressionControlFlowReplacer],[p.NodeType.LogicalExpression,d.ControlFlowReplacer.LogicalExpressionControlFlowReplacer],[p.NodeType.Literal,d.ControlFlowReplacer.StringLiteralControlFlowReplacer]]),h.hostNodeSearchMinDepth=0,h.hostNodeSearchMaxDepth=2,h=v=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.Factory__TControlFlowStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.Factory__IControlFlowReplacer)),c.__param(2,s.inject(u.ServiceIdentifiers.Factory__IControlFlowCustomNode)),c.__param(3,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(4,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Function,Function,Function,Object,Object])],h),t.FunctionControlFlowTransformer=h;var v},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r1){var o=d.Nodes.getBinaryExpressionNode("+",n.shift(),n.shift());return n.forEach(function(e){o=d.Nodes.getBinaryExpressionNode("+",o,e)}),o}return n[0]}}],[{key:"isLiteralNodeWithStringValue",value:function(e){return e&&f.NodeGuards.isLiteralNode(e)&&"string"==typeof e.value}}]),t}(l.AbstractNodeTransformer);p=y=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(1,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object])],p),t.TemplateLiteralTransformer=p;var y},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(12),c=r(21),s=r(39),u=r(64),l=r(65),f=r(66),d=r(67),p=r(68),y=r(70),m=r(73),b=r(74),g=r(75),h=r(76),v=r(77),_=r(79),N=r(81),O=r(83),S=r(87),C=r(89),w=r(90),j=r(91),I=r(93),T=r(95),E=r(102),F=r(104),k=r(107),P=r(108);t.customNodesModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.ICustomNode).to(v.ConsoleOutputDisableExpressionNode).whenTargetNamed(c.CustomNode.ConsoleOutputDisableExpressionNode),e(a.ServiceIdentifiers.ICustomNode).to(_.DebugProtectionFunctionCallNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionCallNode),e(a.ServiceIdentifiers.ICustomNode).to(N.DebugProtectionFunctionIntervalNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionIntervalNode),e(a.ServiceIdentifiers.ICustomNode).to(O.DebugProtectionFunctionNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionNode),e(a.ServiceIdentifiers.ICustomNode).to(S.DomainLockNode).whenTargetNamed(c.CustomNode.DomainLockNode),e(a.ServiceIdentifiers.ICustomNode).to(j.NodeCallsControllerFunctionNode).whenTargetNamed(c.CustomNode.NodeCallsControllerFunctionNode),e(a.ServiceIdentifiers.ICustomNode).to(I.SelfDefendingUnicodeNode).whenTargetNamed(c.CustomNode.SelfDefendingUnicodeNode),e(a.ServiceIdentifiers.ICustomNode).to(T.StringArrayCallsWrapper).whenTargetNamed(c.CustomNode.StringArrayCallsWrapper),e(a.ServiceIdentifiers.ICustomNode).to(E.StringArrayNode).whenTargetNamed(c.CustomNode.StringArrayNode),e(a.ServiceIdentifiers.ICustomNode).to(F.StringArrayRotateFunctionNode).whenTargetNamed(c.CustomNode.StringArrayRotateFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(y.BinaryExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.BinaryExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(m.BlockStatementControlFlowFlatteningNode).whenTargetNamed(i.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(b.CallExpressionControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(g.CallExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.CallExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(h.ControlFlowStorageNode).whenTargetNamed(i.ControlFlowCustomNode.ControlFlowStorageNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(C.ExpressionWithOperatorControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(w.LogicalExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.LogicalExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(P.StringLiteralNode).whenTargetNamed(i.ControlFlowCustomNode.StringLiteralNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(k.StringLiteralControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode),e(a.ServiceIdentifiers.ICustomNodeGroup).to(u.ConsoleOutputCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.ConsoleOutputCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(l.DebugProtectionCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.DebugProtectionCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(f.DomainLockCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.DomainLockCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(d.SelfDefendingCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.SelfDefendingCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(p.StringArrayCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.StringArrayCustomNodeGroup),e(a.ServiceIdentifiers.Factory__ICustomNode).toFactory(n.InversifyContainerFacade.getFactory(a.ServiceIdentifiers.ICustomNode)),e(a.ServiceIdentifiers.Factory__IControlFlowCustomNode).toFactory(n.InversifyContainerFacade.getConstructorFactory(a.ServiceIdentifiers.Newable__ICustomNode,a.ServiceIdentifiers.IRandomGenerator,a.ServiceIdentifiers.IOptions)),e(a.ServiceIdentifiers.Factory__ICustomNodeGroup).toFactory(n.InversifyContainerFacade.getFactory(a.ServiceIdentifiers.ICustomNodeGroup))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r 0;\n \n switch (isPositive) {\n case true:\n return this.item + \'_\' + this.value + \'_\' + i;\n default:\n this.item + \'_\' + this.value;\n }\n }\n }()\n };\n };\n \n var regExp = new RegExp("[{diff}]", "g");\n var domains = "{domains}".replace(regExp, "").split(";");\n var document;\n var domain;\n \n for (var d in that) {\n if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {\n document = d;\n \n break;\n }\n }\n\n for (var d1 in that[document]) {\n if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {\n domain = d1;\n \n break;\n }\n }\n \n if ((!document && !domain) || (!that[document] && !that[document][domain])) {\n return;\n }\n \n var currentDomain = that[document][domain];\n\n var ok = false;\n \n for (var i = 0; i < domains.length; i++) {\n var domain = domains[i];\n var position = currentDomain.length - domain.length;\n var lastIndex = currentDomain.indexOf(domain, position);\n var endsWith = lastIndex !== -1 && lastIndex === position;\n \n if (endsWith) {\n if (currentDomain.length == domain.length || domain.indexOf(".") === 0) {\n ok = true;\n }\n \n break;\n }\n }\n \n if (!ok) {\n data;\n } else {\n return;\n }\n \n func();\n });\n\n {domainLockFunctionName}();\n '}Object.defineProperty(t,"__esModule",{value:!0}),t.DomainLockNodeTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r> 1 + 255 % 0;\n \n if (string.indexOf('i' === i)) {\n recursiveFunc2(string)\n }\n };\n \n var recursiveFunc2 = function (string) {\n var i = ~-4 >> 1 + 255 % 0;\n \n if (string.indexOf((true+\"\")[3]) !== i) {\n recursiveFunc1(string)\n }\n };\n \n if (!test1()) {\n if (!test2()) {\n recursiveFunc1('indеxOf');\n } else {\n recursiveFunc1('indexOf');\n }\n } else {\n recursiveFunc1('indеxOf');\n }\n })\n \n {selfDefendingFunctionName}();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r> (-2 * bc & 6)) : 0\n ) {\n buffer = chars.indexOf(buffer);\n }\n return output;\n });\n })();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.AtobTemplate=n},function(e,t,r){"use strict";function n(){return"\n var rc4 = function (str, key) {\n var s = [], j = 0, x, res = '', newStr = '';\n \n str = atob(str);\n \n for (var k = 0, length = str.length; k < length; k++) {\n newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);\n }\n \n str = decodeURIComponent(newStr);\n \t \n\t for (var i = 0; i < 256; i++) {\n s[i] = i;\n }\n \n for (i = 0; i < 256; i++) {\n j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n }\n \n i = 0;\n j = 0;\n \n for (var y = 0; y < str.length; y++) {\n i = (i + 1) % 256;\n j = (j + s[i]) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);\n }\n \n return res;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.Rc4Template=n},function(e,t,r){"use strict";function n(e){return"\n var StatesClass = function (rc4Bytes) {\n this.rc4Bytes = rc4Bytes;\n this.states = [1, 0, 0];\n this.newState = function(){return 'newState';};\n this.firstState = '"+e.encode("\\w+ *\\(\\) *{\\w+ *",!0)+"';\n this.secondState = '"+e.encode("['|\"].+['|\"];? *}",!0)+"';\n };\n \n StatesClass.prototype.checkState = function () {\n var regExp = new RegExp(this.firstState + this.secondState);\n\n return this.runState(regExp.test(this.newState.toString()) ? --this.states[1] : --this.states[0]);\n };\n \n StatesClass.prototype.runState = function (stateResult) {\n if (!Boolean(~stateResult)) {\n return stateResult;\n }\n \n return this.getState(this.rc4Bytes);\n };\n\n StatesClass.prototype.getState = function (rc4Bytes) {\n for (var i = 0, len = this.states.length; i < len; i++) {\n this.states.push(Math.round(Math.random()));\n len = this.states.length;\n }\n \n return rc4Bytes(this.states[0]);\n };\n\n new StatesClass({stringArrayCallsWrapperName}).checkState();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(){return"\n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}.base64DecodeUnicode = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}.data[index];\n \n if (cachedValue === undefined) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = cachedValue;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayBase64DecodeNodeTemplate=n},function(e,t,r){"use strict";function n(){return"\n var {stringArrayCallsWrapperName} = function (index, key) {\n index = index - 0;\n \n var value = {stringArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayCallsWrapperTemplate=n},function(e,t,r){"use strict";function n(){return"\n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {rc4Polyfill}\n {stringArrayCallsWrapperName}.rc4 = rc4;\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}.data[index];\n\n if (cachedValue === undefined) {\n if ({stringArrayCallsWrapperName}.once === undefined) {\n {selfDefendingCode}\n \n {stringArrayCallsWrapperName}.once = true;\n }\n \n value = {stringArrayCallsWrapperName}.rc4(value, key);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = cachedValue;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayRc4DecodeNodeTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=m.minimumLengthForStringArray&&this.randomGenerator.getMathRandom()<=this.options.stringArrayThreshold}},{key:"getStringArrayHexadecimalIndex",value:function(e,t){if(this.stringLiteralHexadecimalIndexCache.has(e))return{fromCache:!0,index:this.stringLiteralHexadecimalIndexCache.get(e)};var r=p.Utils.decToHex(t),n=""+p.Utils.hexadecimalPrefix+r;return this.stringLiteralHexadecimalIndexCache.set(e,n),{fromCache:!1,index:n}}},{key:"getEncodedValue",value:function(e){var t=void 0,r=null;switch(this.options.stringArrayEncoding){case l.StringArrayEncoding.Rc4:r=this.randomGenerator.getRandomGenerator().pickone(this.rc4Keys),t=this.cryptUtils.btoa(this.cryptUtils.rc4(e,r));break;case l.StringArrayEncoding.Base64:t=this.cryptUtils.btoa(e);break;default:t=e}return{encodedValue:t,key:r}}},{key:"replaceWithLiteralNode",value:function(e){return d.Nodes.getLiteralNode(this.escapeSequenceEncoder.encode(e,this.options.unicodeEscapeSequence))}},{key:"replaceWithStringArrayCallNode",value:function(e){var t=this.getEncodedValue(e),r=t.encodedValue,n=t.key,o=this.escapeSequenceEncoder.encode(r,this.options.unicodeEscapeSequence),a=this.stringArrayStorage.getLength(),i=p.Utils.stringRotate(this.stringArrayStorage.getStorageId(),1),c="_"+p.Utils.hexadecimalPrefix+i,s=this.getStringArrayHexadecimalIndex(o,a),u=s.fromCache,l=s.index;u||this.stringArrayStorage.set(a,o);var f=[m.getHexadecimalLiteralNode(l)];return n&&f.push(m.getRc4KeyLiteralNode(this.escapeSequenceEncoder.encode(n,this.options.unicodeEscapeSequence))),d.Nodes.getCallExpressionNode(d.Nodes.getIdentifierNode(c),f)}}],[{key:"getHexadecimalLiteralNode",value:function(e){var t=d.Nodes.getLiteralNode(e);return t.obfuscatedNode=!0,t}},{key:"getRc4KeyLiteralNode",value:function(e){var t=d.Nodes.getLiteralNode(e);return t.obfuscatedNode=!0,t}}]),t}(f.AbstractObfuscatingReplacer);y.minimumLengthForStringArray=3,y.rc4KeyLength=4,y.rc4KeysCount=50,y=m=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.TStringArrayStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.IEscapeSequenceEncoder)),c.__param(2,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(3,s.inject(u.ServiceIdentifiers.ICryptUtils)),c.__param(4,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object,Object,Object,Object])],y),t.StringLiteralObfuscatingReplacer=y;var m},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=0?t:null}},{key:"getLength",value:function(){return this.storageLength}},{key:"getStorage",value:function(){return this.storage}},{key:"getStorageId",value:function(){return this.storageId}},{key:"mergeWith",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.storage=[].concat(n(this.storage),n(e.getStorage())),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){e===this.storageLength?this.storage.push(t):this.storage.splice(e,0,t),this.storageLength++}}]),e}();i.__decorate([u.initializable(),i.__metadata("design:type",Array)],l.prototype,"storage",void 0),i.__decorate([u.initializable(),i.__metadata("design:type",String)],l.prototype,"storageId",void 0),i.__decorate([c.postConstruct(),i.__metadata("design:type",Function),i.__metadata("design:paramtypes",[]),i.__metadata("design:returntype",void 0)],l.prototype,"initialize",null),l=i.__decorate([c.injectable(),i.__param(0,c.inject(s.ServiceIdentifiers.IRandomGenerator)),i.__metadata("design:paramtypes",[Object])],l),t.ArrayStorage=l},function(e,t){e.exports=require("md5")},function(e,t){e.exports=require("chance")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(1),a=r(136),i=r(137),c=r(138),s=r(31);t.utilsModule=new n.ContainerModule(function(e){e(o.ServiceIdentifiers.IArrayUtils).to(a.ArrayUtils).inSingletonScope(),e(o.ServiceIdentifiers.IRandomGenerator).to(s.RandomGenerator).inSingletonScope(),e(o.ServiceIdentifiers.ICryptUtils).to(i.CryptUtils).inSingletonScope(),e(o.ServiceIdentifiers.IEscapeSequenceEncoder).to(c.EscapeSequenceEncoder).inSingletonScope()})},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t>8-o%1*8)){if((n=e.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|n}return t}},{key:"hideString",value:function(e,t){var r=this,n=this.randomGenerator.getRandomGenerator().string({length:t,pool:s.RandomGenerator.randomGeneratorPool}),o=n.replace(new RegExp("["+function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}(e)+"]","g"),""),a=o.split("");return this.randomGenerator.getRandomGenerator().shuffle(a),o=a.join(""),[function(e,t){for(var n=-1,o=-1,a="";n values should be wrapped inside quotes: --optionName 'value1, value2'");return e.split(",").map(function(e){return e.trim()})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizer=function(e){return"true"===e||"1"===e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(13);t.ObfuscationTargetSanitizer=function(e){if(!Object.keys(n.ObfuscationTarget).some(function(t){return n.ObfuscationTarget[t]===e}))throw new ReferenceError("Invalid value of `--target` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(23);t.SourceMapModeSanitizer=function(e){if(!Object.keys(n.SourceMapMode).some(function(t){return n.SourceMapMode[t]===e}))throw new ReferenceError("Invalid value of `--sourceMapMode` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(24);t.StringArrayEncodingSanitizer=function(e){switch(e){case"true":case"1":case n.StringArrayEncoding.Base64:return!0;case n.StringArrayEncoding.Rc4:return n.StringArrayEncoding.Rc4;default:return!1}}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"";return t&&(e=e.substring(0,e.lastIndexOf("/"))+"/"+t),/\.js\.map$/.test(e)?/\.js$/.test(e)&&(e+=".map"):e=e.split(".")[0]+".js.map",e}},{key:"getPackageConfig",value:function(){return JSON.parse(a.readFileSync(c.join(c.dirname(a.realpathSync(process.argv[1])),"../package.json"),s.JavaScriptObfuscatorCLI.encoding))}},{key:"getUserConfig",value:function(e){var t=void 0;try{t=!function(){var e=new Error('Cannot find module "."');throw e.code="MODULE_NOT_FOUND",e}()}catch(r){try{t=require(e)}catch(e){throw new ReferenceError("Given config path must be a valid file path")}}return t}},{key:"writeFile",value:function(e,t){i.sync(c.dirname(e)),a.writeFileSync(e,t,{encoding:s.JavaScriptObfuscatorCLI.encoding})}}]),e}();t.CLIUtils=u},function(e,t){e.exports=require("mkdirp")},function(e,t){function r(e){throw new Error("Cannot find module '"+e+"'.")}r.keys=function(){return[]},r.resolve=r,e.exports=r,r.id=173},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r 0 && arguments[0] !== undefined ? arguments[0] : 'initialize'; + + var decoratorName = Object.keys(this)[0]; + return function (target, propertyKey) { + var descriptor = { + configurable: true, + enumerable: true + }; + var initializeMethod = target[initializeMethodKey]; + if (!initializeMethod || typeof initializeMethod !== 'function') { + throw new Error("`" + initializeMethodKey + "` method with initialization logic not " + ("found. `@" + decoratorName + "` decorator requires `" + initializeMethodKey + "` method")); + } + var metadataPropertyKey = "_" + propertyKey; + var propertyDescriptor = Object.getOwnPropertyDescriptor(target, metadataPropertyKey) || descriptor; + var methodDescriptor = Object.getOwnPropertyDescriptor(target, initializeMethodKey) || descriptor; + var originalMethod = methodDescriptor.value; + Object.defineProperty(target, propertyKey, Object.assign({}, propertyDescriptor, { get: function get() { + if (this[metadataPropertyKey] === undefined) { + throw new Error("Property `" + propertyKey + "` is not initialized! Initialize it first!"); + } + return this[metadataPropertyKey]; + }, set: function set(newVal) { + this[metadataPropertyKey] = newVal; + } })); + Object.defineProperty(target, initializeMethodKey, Object.assign({}, methodDescriptor, { value: function value() { + originalMethod.apply(this, arguments); + if (this[propertyKey]) {} + } })); + return propertyDescriptor; + }; +} +exports.initializable = initializable; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var escodegen = __webpack_require__(28); +var esprima = __webpack_require__(35); +var estraverse = __webpack_require__(8); +var NodeType_1 = __webpack_require__(10); +var NodeGuards_1 = __webpack_require__(5); + +var NodeUtils = function () { + function NodeUtils() { + _classCallCheck(this, NodeUtils); + } + + _createClass(NodeUtils, null, [{ + key: "addXVerbatimPropertyToLiterals", + value: function addXVerbatimPropertyToLiterals(astTree) { + estraverse.replace(astTree, { + leave: function leave(node) { + if (NodeGuards_1.NodeGuards.isLiteralNode(node)) { + node['x-verbatim-property'] = { + content: node.raw, + precedence: escodegen.Precedence.Primary + }; + } + } + }); + return astTree; + } + }, { + key: "clone", + value: function clone(astTree) { + var cloneRecursive = function cloneRecursive(node) { + if (node === null) { + return node; + } + var copy = {}; + Object.keys(node).filter(function (property) { + return property !== 'parentNode'; + }).forEach(function (property) { + var value = node[property]; + var clonedValue = void 0; + if (value === null || value instanceof RegExp) { + clonedValue = value; + } else if (Array.isArray(value)) { + clonedValue = value.map(cloneRecursive); + } else if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === 'object') { + clonedValue = cloneRecursive(value); + } else { + clonedValue = value; + } + copy[property] = clonedValue; + }); + return copy; + }; + return NodeUtils.parentize(cloneRecursive(astTree)); + } + }, { + key: "convertCodeToStructure", + value: function convertCodeToStructure(code) { + var structure = esprima.parseScript(code); + structure = NodeUtils.addXVerbatimPropertyToLiterals(structure); + structure = NodeUtils.parentize(structure); + return structure.body; + } + }, { + key: "convertStructureToCode", + value: function convertStructureToCode(structure) { + var code = ''; + structure.forEach(function (node) { + code += escodegen.generate(node, { + sourceMapWithCode: true + }).code; + }); + return code; + } + }, { + key: "getBlockStatementNodeByIndex", + value: function getBlockStatementNodeByIndex(node) { + var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + if (NodeGuards_1.NodeGuards.isNodeHasBlockStatement(node)) { + if (node.body[index] === undefined) { + throw new ReferenceError("Wrong index `" + index + "`. Block-statement body length is `" + node.body.length + "`"); + } + return node.body[index]; + } + throw new TypeError('The specified node have no a block-statement'); + } + }, { + key: "getBlockScopesOfNode", + value: function getBlockScopesOfNode(node) { + var blockScopes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + + var parentNode = node.parentNode; + if (!parentNode) { + throw new ReferenceError('`parentNode` property of given node is `undefined`'); + } + if (NodeGuards_1.NodeGuards.isBlockStatementNode(parentNode)) { + if (!parentNode.parentNode) { + throw new ReferenceError('`parentNode` property of `parentNode` of given node is `undefined`'); + } + if (NodeUtils.nodesWithBlockScope.indexOf(parentNode.parentNode.type) !== -1) { + blockScopes.push(parentNode); + } + } + if (node !== parentNode) { + return NodeUtils.getBlockScopesOfNode(parentNode, blockScopes); + } + if (NodeGuards_1.NodeGuards.isNodeHasBlockStatement(parentNode)) { + blockScopes.push(parentNode); + } + return blockScopes; + } + }, { + key: "getNodeBlockScopeDepth", + value: function getNodeBlockScopeDepth(node) { + var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + var parentNode = node.parentNode; + if (!parentNode) { + throw new ReferenceError('`parentNode` property of given node is `undefined`'); + } + if (NodeGuards_1.NodeGuards.isProgramNode(parentNode)) { + return depth; + } + if (NodeGuards_1.NodeGuards.isBlockStatementNode(node) && NodeUtils.nodesWithBlockScope.indexOf(parentNode.type) !== -1) { + return NodeUtils.getNodeBlockScopeDepth(parentNode, ++depth); + } + return NodeUtils.getNodeBlockScopeDepth(parentNode, depth); + } + }, { + key: "getUnaryExpressionArgumentNode", + value: function getUnaryExpressionArgumentNode(unaryExpressionNode) { + if (NodeGuards_1.NodeGuards.isUnaryExpressionNode(unaryExpressionNode.argument)) { + return NodeUtils.getUnaryExpressionArgumentNode(unaryExpressionNode.argument); + } + return unaryExpressionNode.argument; + } + }, { + key: "parentize", + value: function parentize(astTree) { + estraverse.traverse(astTree, { + enter: NodeUtils.parentizeNode + }); + return astTree; + } + }, { + key: "parentizeNode", + value: function parentizeNode(node, parentNode) { + node.parentNode = parentNode || node; + node.obfuscatedNode = false; + return node; + } + }]); + + return NodeUtils; +}(); + +NodeUtils.nodesWithBlockScope = [NodeType_1.NodeType.ArrowFunctionExpression, NodeType_1.NodeType.FunctionDeclaration, NodeType_1.NodeType.FunctionExpression, NodeType_1.NodeType.MethodDefinition, NodeType_1.NodeType.Program]; +exports.NodeUtils = NodeUtils; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var NodeType_1 = __webpack_require__(10); + +var NodeGuards = function () { + function NodeGuards() { + _classCallCheck(this, NodeGuards); + } + + _createClass(NodeGuards, null, [{ + key: "isArrowFunctionExpressionNode", + value: function isArrowFunctionExpressionNode(node) { + return node.type === NodeType_1.NodeType.ArrowFunctionExpression; + } + }, { + key: "isAssignmentPatternNode", + value: function isAssignmentPatternNode(node) { + return node.type === NodeType_1.NodeType.AssignmentPattern; + } + }, { + key: "isAwaitExpressionNode", + value: function isAwaitExpressionNode(node) { + return node.type === NodeType_1.NodeType.AwaitExpression; + } + }, { + key: "isBlockStatementNode", + value: function isBlockStatementNode(node) { + return node.type === NodeType_1.NodeType.BlockStatement; + } + }, { + key: "isBreakStatementNode", + value: function isBreakStatementNode(node) { + return node.type === NodeType_1.NodeType.BreakStatement; + } + }, { + key: "isCallExpressionNode", + value: function isCallExpressionNode(node) { + return node.type === NodeType_1.NodeType.CallExpression; + } + }, { + key: "isCatchClauseNode", + value: function isCatchClauseNode(node) { + return node.type === NodeType_1.NodeType.CatchClause; + } + }, { + key: "isClassDeclarationNode", + value: function isClassDeclarationNode(node) { + return node.type === NodeType_1.NodeType.ClassDeclaration; + } + }, { + key: "isContinueStatementNode", + value: function isContinueStatementNode(node) { + return node.type === NodeType_1.NodeType.ContinueStatement; + } + }, { + key: "isExpressionStatementNode", + value: function isExpressionStatementNode(node) { + return node.type === NodeType_1.NodeType.ExpressionStatement; + } + }, { + key: "isFunctionDeclarationNode", + value: function isFunctionDeclarationNode(node) { + return node.type === NodeType_1.NodeType.FunctionDeclaration; + } + }, { + key: "isFunctionExpressionNode", + value: function isFunctionExpressionNode(node) { + return node.type === NodeType_1.NodeType.FunctionExpression; + } + }, { + key: "isIdentifierNode", + value: function isIdentifierNode(node) { + return node.type === NodeType_1.NodeType.Identifier; + } + }, { + key: "isIfStatementNode", + value: function isIfStatementNode(node) { + return node.type === NodeType_1.NodeType.IfStatement; + } + }, { + key: "isLabelIdentifierNode", + value: function isLabelIdentifierNode(node, parentNode) { + var parentNodeIsLabeledStatementNode = NodeGuards.isLabeledStatementNode(parentNode) && parentNode.label === node; + var parentNodeIsContinueStatementNode = NodeGuards.isContinueStatementNode(parentNode) && parentNode.label === node; + var parentNodeIsBreakStatementNode = NodeGuards.isBreakStatementNode(parentNode) && parentNode.label === node; + return parentNodeIsLabeledStatementNode || parentNodeIsContinueStatementNode || parentNodeIsBreakStatementNode; + } + }, { + key: "isLabeledStatementNode", + value: function isLabeledStatementNode(node) { + return node.type === NodeType_1.NodeType.LabeledStatement; + } + }, { + key: "isLiteralNode", + value: function isLiteralNode(node) { + return node.type === NodeType_1.NodeType.Literal; + } + }, { + key: "isMemberExpressionNode", + value: function isMemberExpressionNode(node) { + return node.type === NodeType_1.NodeType.MemberExpression; + } + }, { + key: "isMethodDefinitionNode", + value: function isMethodDefinitionNode(node) { + return node.type === NodeType_1.NodeType.MethodDefinition; + } + }, { + key: "isNode", + value: function isNode(object) { + return object && !object.type !== undefined; + } + }, { + key: "isNodeHasBlockStatement", + value: function isNodeHasBlockStatement(node) { + return Array.isArray(node.body); + } + }, { + key: "isObjectPatternNode", + value: function isObjectPatternNode(node) { + return node.type === NodeType_1.NodeType.ObjectPattern; + } + }, { + key: "isObjectExpressionNode", + value: function isObjectExpressionNode(node) { + return node.type === NodeType_1.NodeType.ObjectExpression; + } + }, { + key: "isProgramNode", + value: function isProgramNode(node) { + return node.type === NodeType_1.NodeType.Program; + } + }, { + key: "isPropertyNode", + value: function isPropertyNode(node) { + return node.type === NodeType_1.NodeType.Property; + } + }, { + key: "isReplaceableIdentifierNode", + value: function isReplaceableIdentifierNode(node, parentNode) { + if (!NodeGuards.isIdentifierNode(node)) { + return false; + } + var parentNodeIsPropertyNode = NodeGuards.isPropertyNode(parentNode) && !parentNode.computed && parentNode.key === node; + var parentNodeIsMemberExpressionNode = NodeGuards.isMemberExpressionNode(parentNode) && parentNode.computed === false && parentNode.property === node; + return !parentNodeIsPropertyNode && !parentNodeIsMemberExpressionNode && !NodeGuards.isLabelIdentifierNode(node, parentNode); + } + }, { + key: "isReturnStatementNode", + value: function isReturnStatementNode(node) { + return node.type === NodeType_1.NodeType.ReturnStatement; + } + }, { + key: "isTemplateLiteralNode", + value: function isTemplateLiteralNode(node) { + return node.type === NodeType_1.NodeType.TemplateLiteral; + } + }, { + key: "isUnaryExpressionNode", + value: function isUnaryExpressionNode(node) { + return node.type === NodeType_1.NodeType.UnaryExpression; + } + }, { + key: "isUseStrictOperator", + value: function isUseStrictOperator(node) { + return node.type === NodeType_1.NodeType.ExpressionStatement && node.directive === 'use strict'; + } + }, { + key: "isVariableDeclarationNode", + value: function isVariableDeclarationNode(node) { + return node.type === NodeType_1.NodeType.VariableDeclaration; + } + }, { + key: "isVariableDeclaratorNode", + value: function isVariableDeclaratorNode(node) { + return node.type === NodeType_1.NodeType.VariableDeclarator; + } + }, { + key: "isWhileStatementNode", + value: function isWhileStatementNode(node) { + return node.type === NodeType_1.NodeType.WhileStatement; + } + }]); + + return NodeGuards; +}(); + +exports.NodeGuards = NodeGuards; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var GlobalVariableTemplate1_1 = __webpack_require__(71); +var GlobalVariableTemplate2_1 = __webpack_require__(72); +var NodeUtils_1 = __webpack_require__(4); +var AbstractCustomNode = AbstractCustomNode_1 = function () { + function AbstractCustomNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, AbstractCustomNode); + + this.identifierNameGenerator = identifierNameGeneratorFactory(options); + this.randomGenerator = randomGenerator; + this.options = options; + } + + _createClass(AbstractCustomNode, [{ + key: "getCode", + value: function getCode() { + if (!this.cachedCode) { + this.cachedCode = NodeUtils_1.NodeUtils.convertStructureToCode(this.getNode()); + } + return this.cachedCode; + } + }, { + key: "getNode", + value: function getNode() { + if (!this.cachedNode) { + this.cachedNode = this.getNodeStructure(); + } + return this.cachedNode; + } + }, { + key: "getGlobalVariableTemplate", + value: function getGlobalVariableTemplate() { + return this.randomGenerator.getRandomGenerator().pickone(AbstractCustomNode_1.globalVariableTemplateFunctions); + } + }]); + + return AbstractCustomNode; +}(); +AbstractCustomNode.globalVariableTemplateFunctions = [GlobalVariableTemplate1_1.GlobalVariableTemplate1(), GlobalVariableTemplate2_1.GlobalVariableTemplate2()]; +AbstractCustomNode = AbstractCustomNode_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], AbstractCustomNode); +exports.AbstractCustomNode = AbstractCustomNode; +var AbstractCustomNode_1; + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractNodeTransformer = function () { + function AbstractNodeTransformer(randomGenerator, options) { + _classCallCheck(this, AbstractNodeTransformer); + + this.randomGenerator = randomGenerator; + this.options = options; + } + + _createClass(AbstractNodeTransformer, [{ + key: "initialize", + value: function initialize() { + this.nodeIdentifier = this.randomGenerator.getRandomInteger(0, 10000); + } + }]); + + return AbstractNodeTransformer; +}(); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Number)], AbstractNodeTransformer.prototype, "nodeIdentifier", void 0); +tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], AbstractNodeTransformer.prototype, "initialize", null); +AbstractNodeTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], AbstractNodeTransformer); +exports.AbstractNodeTransformer = AbstractNodeTransformer; + +/***/ }), +/* 8 */ +/***/ (function(module, exports) { + +module.exports = require("estraverse"); + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var escodegen = __webpack_require__(28); +var NodeType_1 = __webpack_require__(10); + +var Nodes = function () { + function Nodes() { + _classCallCheck(this, Nodes); + } + + _createClass(Nodes, null, [{ + key: "getProgramNode", + value: function getProgramNode() { + var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + return { + type: NodeType_1.NodeType.Program, + body: body, + sourceType: 'script', + obfuscatedNode: false + }; + } + }, { + key: "getArrayExpressionNode", + value: function getArrayExpressionNode() { + var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + return { + type: NodeType_1.NodeType.ArrayExpression, + elements: elements + }; + } + }, { + key: "getAssignmentExpressionNode", + value: function getAssignmentExpressionNode(operator, left, right) { + return { + type: NodeType_1.NodeType.AssignmentExpression, + operator: operator, + left: left, + right: right, + obfuscatedNode: false + }; + } + }, { + key: "getBinaryExpressionNode", + value: function getBinaryExpressionNode(operator, left, right) { + return { + type: NodeType_1.NodeType.BinaryExpression, + operator: operator, + left: left, + right: right, + obfuscatedNode: false + }; + } + }, { + key: "getBlockStatementNode", + value: function getBlockStatementNode() { + var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + return { + type: NodeType_1.NodeType.BlockStatement, + body: body, + obfuscatedNode: false + }; + } + }, { + key: "getBreakStatement", + value: function getBreakStatement(label) { + var breakStatementNode = { + type: NodeType_1.NodeType.BreakStatement, + obfuscatedNode: false + }; + if (label) { + breakStatementNode.label = label; + } + return breakStatementNode; + } + }, { + key: "getCatchClauseNode", + value: function getCatchClauseNode() { + var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + return { + type: NodeType_1.NodeType.CatchClause, + param: Nodes.getIdentifierNode('err'), + body: Nodes.getBlockStatementNode(body), + obfuscatedNode: false + }; + } + }, { + key: "getCallExpressionNode", + value: function getCallExpressionNode(callee) { + var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + + return { + type: NodeType_1.NodeType.CallExpression, + callee: callee, + arguments: args, + obfuscatedNode: false + }; + } + }, { + key: "getContinueStatement", + value: function getContinueStatement(label) { + var continueStatementNode = { + type: NodeType_1.NodeType.ContinueStatement, + obfuscatedNode: false + }; + if (label) { + continueStatementNode.label = label; + } + return continueStatementNode; + } + }, { + key: "getExpressionStatementNode", + value: function getExpressionStatementNode(expression) { + return { + type: NodeType_1.NodeType.ExpressionStatement, + expression: expression, + obfuscatedNode: false + }; + } + }, { + key: "getFunctionDeclarationNode", + value: function getFunctionDeclarationNode(functionName, params, body) { + return { + type: NodeType_1.NodeType.FunctionDeclaration, + id: Nodes.getIdentifierNode(functionName), + params: params, + body: body, + generator: false, + obfuscatedNode: false + }; + } + }, { + key: "getFunctionExpressionNode", + value: function getFunctionExpressionNode(params, body) { + return { + type: NodeType_1.NodeType.FunctionExpression, + params: params, + body: body, + generator: false, + obfuscatedNode: false + }; + } + }, { + key: "getIfStatementNode", + value: function getIfStatementNode(test, consequent, alternate) { + return Object.assign({ type: NodeType_1.NodeType.IfStatement, test: test, + consequent: consequent }, alternate && { alternate: alternate }, { obfuscatedNode: false }); + } + }, { + key: "getIdentifierNode", + value: function getIdentifierNode(name) { + return { + type: NodeType_1.NodeType.Identifier, + name: name, + obfuscatedNode: false + }; + } + }, { + key: "getLabeledStatement", + value: function getLabeledStatement(label, body) { + return { + type: NodeType_1.NodeType.LabeledStatement, + label: label, + body: body, + obfuscatedNode: false + }; + } + }, { + key: "getLiteralNode", + value: function getLiteralNode(value, raw) { + raw = raw !== undefined ? raw : "'" + value + "'"; + return { + type: NodeType_1.NodeType.Literal, + value: value, + raw: raw, + 'x-verbatim-property': { + content: raw, + precedence: escodegen.Precedence.Primary + }, + obfuscatedNode: false + }; + } + }, { + key: "getLogicalExpressionNode", + value: function getLogicalExpressionNode(operator, left, right) { + return { + type: NodeType_1.NodeType.LogicalExpression, + operator: operator, + left: left, + right: right, + obfuscatedNode: false + }; + } + }, { + key: "getMemberExpressionNode", + value: function getMemberExpressionNode(object, property) { + var computed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + return { + type: NodeType_1.NodeType.MemberExpression, + computed: computed, + object: object, + property: property, + obfuscatedNode: false + }; + } + }, { + key: "getObjectExpressionNode", + value: function getObjectExpressionNode(properties) { + return { + type: NodeType_1.NodeType.ObjectExpression, + properties: properties, + obfuscatedNode: false + }; + } + }, { + key: "getPropertyNode", + value: function getPropertyNode(key, value) { + var computed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + return { + type: NodeType_1.NodeType.Property, + key: key, + value: value, + kind: 'init', + method: false, + shorthand: false, + computed: computed, + obfuscatedNode: false + }; + } + }, { + key: "getUnaryExpressionNode", + value: function getUnaryExpressionNode(operator, argument) { + var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + + return { + type: NodeType_1.NodeType.UnaryExpression, + operator: operator, + argument: argument, + prefix: prefix, + obfuscatedNode: false + }; + } + }, { + key: "getReturnStatementNode", + value: function getReturnStatementNode(argument) { + return { + type: NodeType_1.NodeType.ReturnStatement, + argument: argument, + obfuscatedNode: false + }; + } + }, { + key: "getSwitchStatementNode", + value: function getSwitchStatementNode(discriminant, cases) { + return { + type: NodeType_1.NodeType.SwitchStatement, + discriminant: discriminant, + cases: cases, + obfuscatedNode: false + }; + } + }, { + key: "getSwitchCaseNode", + value: function getSwitchCaseNode(test, consequent) { + return { + type: NodeType_1.NodeType.SwitchCase, + test: test, + consequent: consequent, + obfuscatedNode: false + }; + } + }, { + key: "getUpdateExpressionNode", + value: function getUpdateExpressionNode(operator, argumentExpr) { + return { + type: NodeType_1.NodeType.UpdateExpression, + operator: operator, + argument: argumentExpr, + prefix: false, + obfuscatedNode: false + }; + } + }, { + key: "getVariableDeclarationNode", + value: function getVariableDeclarationNode() { + var declarations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'var'; + + return { + type: NodeType_1.NodeType.VariableDeclaration, + declarations: declarations, + kind: kind, + obfuscatedNode: false + }; + } + }, { + key: "getVariableDeclaratorNode", + value: function getVariableDeclaratorNode(id, init) { + return { + type: NodeType_1.NodeType.VariableDeclarator, + id: id, + init: init, + obfuscatedNode: false + }; + } + }, { + key: "getWhileStatementNode", + value: function getWhileStatementNode(test, body) { + return { + type: NodeType_1.NodeType.WhileStatement, + test: test, + body: body, + obfuscatedNode: false + }; + } + }]); + + return Nodes; +}(); + +exports.Nodes = Nodes; + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var NodeType; +(function (NodeType) { + NodeType["ArrayExpression"] = "ArrayExpression"; + NodeType["ArrowFunctionExpression"] = "ArrowFunctionExpression"; + NodeType["AssignmentExpression"] = "AssignmentExpression"; + NodeType["AssignmentPattern"] = "AssignmentPattern"; + NodeType["AwaitExpression"] = "AwaitExpression"; + NodeType["BinaryExpression"] = "BinaryExpression"; + NodeType["BlockStatement"] = "BlockStatement"; + NodeType["BreakStatement"] = "BreakStatement"; + NodeType["CallExpression"] = "CallExpression"; + NodeType["CatchClause"] = "CatchClause"; + NodeType["ClassDeclaration"] = "ClassDeclaration"; + NodeType["ContinueStatement"] = "ContinueStatement"; + NodeType["ExpressionStatement"] = "ExpressionStatement"; + NodeType["FunctionDeclaration"] = "FunctionDeclaration"; + NodeType["FunctionExpression"] = "FunctionExpression"; + NodeType["Identifier"] = "Identifier"; + NodeType["IfStatement"] = "IfStatement"; + NodeType["LabeledStatement"] = "LabeledStatement"; + NodeType["Literal"] = "Literal"; + NodeType["LogicalExpression"] = "LogicalExpression"; + NodeType["MemberExpression"] = "MemberExpression"; + NodeType["MethodDefinition"] = "MethodDefinition"; + NodeType["ObjectExpression"] = "ObjectExpression"; + NodeType["ObjectPattern"] = "ObjectPattern"; + NodeType["Program"] = "Program"; + NodeType["Property"] = "Property"; + NodeType["ReturnStatement"] = "ReturnStatement"; + NodeType["SwitchCase"] = "SwitchCase"; + NodeType["SwitchStatement"] = "SwitchStatement"; + NodeType["TemplateLiteral"] = "TemplateLiteral"; + NodeType["TryStatement"] = "TryStatement"; + NodeType["UnaryExpression"] = "UnaryExpression"; + NodeType["UpdateExpression"] = "UpdateExpression"; + NodeType["VariableDeclaration"] = "VariableDeclaration"; + NodeType["VariableDeclarator"] = "VariableDeclarator"; + NodeType["WhileStatement"] = "WhileStatement"; +})(NodeType = exports.NodeType || (exports.NodeType = {})); + +/***/ }), +/* 11 */ +/***/ (function(module, exports) { + +module.exports = require("string-template"); + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var ControlFlowCustomNode; +(function (ControlFlowCustomNode) { + ControlFlowCustomNode[ControlFlowCustomNode["BinaryExpressionFunctionNode"] = 0] = "BinaryExpressionFunctionNode"; + ControlFlowCustomNode[ControlFlowCustomNode["BlockStatementControlFlowFlatteningNode"] = 1] = "BlockStatementControlFlowFlatteningNode"; + ControlFlowCustomNode[ControlFlowCustomNode["CallExpressionControlFlowStorageCallNode"] = 2] = "CallExpressionControlFlowStorageCallNode"; + ControlFlowCustomNode[ControlFlowCustomNode["CallExpressionFunctionNode"] = 3] = "CallExpressionFunctionNode"; + ControlFlowCustomNode[ControlFlowCustomNode["ControlFlowStorageNode"] = 4] = "ControlFlowStorageNode"; + ControlFlowCustomNode[ControlFlowCustomNode["ExpressionWithOperatorControlFlowStorageCallNode"] = 5] = "ExpressionWithOperatorControlFlowStorageCallNode"; + ControlFlowCustomNode[ControlFlowCustomNode["LogicalExpressionFunctionNode"] = 6] = "LogicalExpressionFunctionNode"; + ControlFlowCustomNode[ControlFlowCustomNode["StringLiteralControlFlowStorageCallNode"] = 7] = "StringLiteralControlFlowStorageCallNode"; + ControlFlowCustomNode[ControlFlowCustomNode["StringLiteralNode"] = 8] = "StringLiteralNode"; +})(ControlFlowCustomNode = exports.ControlFlowCustomNode || (exports.ControlFlowCustomNode = {})); + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var ObfuscationTarget; +(function (ObfuscationTarget) { + ObfuscationTarget["Browser"] = "browser"; + ObfuscationTarget["Extension"] = "extension"; + ObfuscationTarget["Node"] = "node"; +})(ObfuscationTarget = exports.ObfuscationTarget || (exports.ObfuscationTarget = {})); + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AnalyzersModule_1 = __webpack_require__(47); +var ControlFlowTransformersModule_1 = __webpack_require__(52); +var ConvertingTransformersModule_1 = __webpack_require__(60); +var CustomNodesModule_1 = __webpack_require__(64); +var GeneratorsModule_1 = __webpack_require__(110); +var NodeTransformersModule_1 = __webpack_require__(114); +var ObfuscatingTransformersModule_1 = __webpack_require__(115); +var PreparingTransformersModule_1 = __webpack_require__(128); +var StoragesModule_1 = __webpack_require__(133); +var UtilsModule_1 = __webpack_require__(138); +var JavaScriptObfuscator_1 = __webpack_require__(144); +var Logger_1 = __webpack_require__(146); +var ObfuscationEventEmitter_1 = __webpack_require__(148); +var ObfuscationResult_1 = __webpack_require__(150); +var Options_1 = __webpack_require__(151); +var SourceCode_1 = __webpack_require__(165); +var SourceMapCorrector_1 = __webpack_require__(166); +var TransformersRunner_1 = __webpack_require__(167); + +var InversifyContainerFacade = function () { + function InversifyContainerFacade() { + _classCallCheck(this, InversifyContainerFacade); + + this.container = new inversify_1.Container(); + } + + _createClass(InversifyContainerFacade, [{ + key: "get", + value: function get(serviceIdentifier) { + return this.container.get(serviceIdentifier); + } + }, { + key: "getNamed", + value: function getNamed(serviceIdentifier, named) { + return this.container.getNamed(serviceIdentifier, named); + } + }, { + key: "load", + value: function load(sourceCode, options) { + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.ISourceCode).toDynamicValue(function () { + return new SourceCode_1.SourceCode(sourceCode); + }).inSingletonScope(); + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.IOptions).toDynamicValue(function () { + return new Options_1.Options(options); + }).inSingletonScope(); + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.ILogger).to(Logger_1.Logger).inSingletonScope(); + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.IJavaScriptObfuscator).to(JavaScriptObfuscator_1.JavaScriptObfuscator).inSingletonScope(); + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.ITransformersRunner).to(TransformersRunner_1.TransformersRunner).inSingletonScope(); + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationResult).to(ObfuscationResult_1.ObfuscationResult).inSingletonScope(); + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationResult).toFactory(function (context) { + return function (obfuscatedCode, sourceMap) { + var obfuscationResult = context.container.get(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationResult); + obfuscationResult.initialize(obfuscatedCode, sourceMap); + return obfuscationResult; + }; + }); + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.ISourceMapCorrector).to(SourceMapCorrector_1.SourceMapCorrector).inSingletonScope(); + this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationEventEmitter).to(ObfuscationEventEmitter_1.ObfuscationEventEmitter).inSingletonScope(); + this.container.load(AnalyzersModule_1.analyzersModule); + this.container.load(ControlFlowTransformersModule_1.controlFlowTransformersModule); + this.container.load(ConvertingTransformersModule_1.convertingTransformersModule); + this.container.load(CustomNodesModule_1.customNodesModule); + this.container.load(GeneratorsModule_1.generatorsModule); + this.container.load(NodeTransformersModule_1.nodeTransformersModule); + this.container.load(ObfuscatingTransformersModule_1.obfuscatingTransformersModule); + this.container.load(PreparingTransformersModule_1.preparingTransformersModule); + this.container.load(StoragesModule_1.storagesModule); + this.container.load(UtilsModule_1.utilsModule); + } + }, { + key: "unload", + value: function unload() { + this.container.unbindAll(); + } + }], [{ + key: "getFactory", + value: function getFactory(serviceIdentifier) { + return function (context) { + return function (bindingName) { + return context.container.getNamed(serviceIdentifier, bindingName); + }; + }; + } + }, { + key: "getCacheFactory", + value: function getCacheFactory(serviceIdentifier) { + return function (context) { + var cache = new Map(); + return function (bindingName) { + if (cache.has(bindingName)) { + return cache.get(bindingName); + } + var object = context.container.getNamed(serviceIdentifier, bindingName); + cache.set(bindingName, object); + return object; + }; + }; + } + }, { + key: "getConstructorFactory", + value: function getConstructorFactory(serviceIdentifier) { + for (var _len = arguments.length, dependencies = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + dependencies[_key - 1] = arguments[_key]; + } + + return function (context) { + var cache = new Map(); + var cachedDependencies = []; + return function (bindingName) { + dependencies.forEach(function (dependency, index) { + if (!cachedDependencies[index]) { + cachedDependencies[index] = context.container.get(dependency); + } + }); + if (cache.has(bindingName)) { + return new (Function.prototype.bind.apply(cache.get(bindingName), [null].concat(cachedDependencies)))(); + } + var constructor = context.container.getNamed(serviceIdentifier, bindingName); + cache.set(bindingName, constructor); + return new (Function.prototype.bind.apply(constructor, [null].concat(cachedDependencies)))(); + }; + }; + } + }]); + + return InversifyContainerFacade; +}(); + +exports.InversifyContainerFacade = InversifyContainerFacade; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var ObfuscationEvent; +(function (ObfuscationEvent) { + ObfuscationEvent["AfterObfuscation"] = "afterObfuscation"; + ObfuscationEvent["BeforeObfuscation"] = "beforeObfuscation"; +})(ObfuscationEvent = exports.ObfuscationEvent || (exports.ObfuscationEvent = {})); + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var IdentifierObfuscatingReplacer; +(function (IdentifierObfuscatingReplacer) { + IdentifierObfuscatingReplacer[IdentifierObfuscatingReplacer["BaseIdentifierObfuscatingReplacer"] = 0] = "BaseIdentifierObfuscatingReplacer"; +})(IdentifierObfuscatingReplacer = exports.IdentifierObfuscatingReplacer || (exports.IdentifierObfuscatingReplacer = {})); + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +__webpack_require__(46); +var ServiceIdentifiers_1 = __webpack_require__(1); +var InversifyContainerFacade_1 = __webpack_require__(14); +var JavaScriptObfuscatorCLI_1 = __webpack_require__(32); + +var JavaScriptObfuscatorFacade = function () { + function JavaScriptObfuscatorFacade() { + _classCallCheck(this, JavaScriptObfuscatorFacade); + } + + _createClass(JavaScriptObfuscatorFacade, null, [{ + key: "obfuscate", + value: function obfuscate(sourceCode) { + var inputOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + var inversifyContainerFacade = new InversifyContainerFacade_1.InversifyContainerFacade(); + inversifyContainerFacade.load(sourceCode, inputOptions); + var javaScriptObfuscator = inversifyContainerFacade.get(ServiceIdentifiers_1.ServiceIdentifiers.IJavaScriptObfuscator); + var obfuscationResult = javaScriptObfuscator.obfuscate(sourceCode); + inversifyContainerFacade.unload(); + return obfuscationResult; + } + }, { + key: "runCLI", + value: function runCLI(argv) { + var javaScriptObfuscatorCLI = new JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI(argv); + javaScriptObfuscatorCLI.initialize(); + javaScriptObfuscatorCLI.run(); + } + }]); + + return JavaScriptObfuscatorFacade; +}(); + +exports.JavaScriptObfuscator = JavaScriptObfuscatorFacade; + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var NodeTransformer; +(function (NodeTransformer) { + NodeTransformer[NodeTransformer["BlockStatementControlFlowTransformer"] = 0] = "BlockStatementControlFlowTransformer"; + NodeTransformer[NodeTransformer["ClassDeclarationTransformer"] = 1] = "ClassDeclarationTransformer"; + NodeTransformer[NodeTransformer["DeadCodeInjectionTransformer"] = 2] = "DeadCodeInjectionTransformer"; + NodeTransformer[NodeTransformer["FunctionControlFlowTransformer"] = 3] = "FunctionControlFlowTransformer"; + NodeTransformer[NodeTransformer["CatchClauseTransformer"] = 4] = "CatchClauseTransformer"; + NodeTransformer[NodeTransformer["FunctionDeclarationTransformer"] = 5] = "FunctionDeclarationTransformer"; + NodeTransformer[NodeTransformer["FunctionTransformer"] = 6] = "FunctionTransformer"; + NodeTransformer[NodeTransformer["LabeledStatementTransformer"] = 7] = "LabeledStatementTransformer"; + NodeTransformer[NodeTransformer["LiteralTransformer"] = 8] = "LiteralTransformer"; + NodeTransformer[NodeTransformer["MemberExpressionTransformer"] = 9] = "MemberExpressionTransformer"; + NodeTransformer[NodeTransformer["MethodDefinitionTransformer"] = 10] = "MethodDefinitionTransformer"; + NodeTransformer[NodeTransformer["ObfuscatingGuardsTransformer"] = 11] = "ObfuscatingGuardsTransformer"; + NodeTransformer[NodeTransformer["ObjectExpressionTransformer"] = 12] = "ObjectExpressionTransformer"; + NodeTransformer[NodeTransformer["ParentificationTransformer"] = 13] = "ParentificationTransformer"; + NodeTransformer[NodeTransformer["TemplateLiteralTransformer"] = 14] = "TemplateLiteralTransformer"; + NodeTransformer[NodeTransformer["VariableDeclarationTransformer"] = 15] = "VariableDeclarationTransformer"; +})(NodeTransformer = exports.NodeTransformer || (exports.NodeTransformer = {})); + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); + +var NodeAppender = function () { + function NodeAppender() { + _classCallCheck(this, NodeAppender); + } + + _createClass(NodeAppender, null, [{ + key: "appendNode", + value: function appendNode(blockScopeNode, nodeBodyStatements) { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + blockScopeNode.body = [].concat(_toConsumableArray(blockScopeNode.body), _toConsumableArray(nodeBodyStatements)); + } + }, { + key: "appendNodeToOptimalBlockScope", + value: function appendNodeToOptimalBlockScope(blockScopeStackTraceData, blockScopeNode, nodeBodyStatements) { + var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; + + var targetBlockScope = void 0; + if (!blockScopeStackTraceData.length) { + targetBlockScope = blockScopeNode; + } else { + targetBlockScope = NodeAppender.getOptimalBlockScope(blockScopeStackTraceData, index); + } + NodeAppender.prependNode(targetBlockScope, nodeBodyStatements); + } + }, { + key: "getOptimalBlockScope", + value: function getOptimalBlockScope(blockScopeTraceData, index) { + var deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity; + + var firstCall = blockScopeTraceData[index]; + if (deep <= 0) { + throw new Error("Invalid `deep` argument value. Value should be bigger then 0."); + } + if (deep > 1 && firstCall.stackTrace.length) { + return NodeAppender.getOptimalBlockScope(firstCall.stackTrace, 0, --deep); + } else { + return firstCall.callee; + } + } + }, { + key: "insertNodeAtIndex", + value: function insertNodeAtIndex(blockScopeNode, nodeBodyStatements, index) { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + blockScopeNode.body = [].concat(_toConsumableArray(blockScopeNode.body.slice(0, index)), _toConsumableArray(nodeBodyStatements), _toConsumableArray(blockScopeNode.body.slice(index))); + } + }, { + key: "prependNode", + value: function prependNode(blockScopeNode, nodeBodyStatements) { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + blockScopeNode.body = [].concat(_toConsumableArray(nodeBodyStatements), _toConsumableArray(blockScopeNode.body)); + } + }, { + key: "parentizeBodyStatementsBeforeAppend", + value: function parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements) { + nodeBodyStatements.forEach(function (statement) { + statement.parentNode = blockScopeNode; + }); + return nodeBodyStatements; + } + }, { + key: "validateBodyStatements", + value: function validateBodyStatements(nodeBodyStatements) { + return nodeBodyStatements.every(function (statementNode) { + return !!statementNode && statementNode.hasOwnProperty('type'); + }); + } + }]); + + return NodeAppender; +}(); + +exports.NodeAppender = NodeAppender; + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var CustomNode; +(function (CustomNode) { + CustomNode[CustomNode["ConsoleOutputDisableExpressionNode"] = 0] = "ConsoleOutputDisableExpressionNode"; + CustomNode[CustomNode["DebugProtectionFunctionCallNode"] = 1] = "DebugProtectionFunctionCallNode"; + CustomNode[CustomNode["DebugProtectionFunctionIntervalNode"] = 2] = "DebugProtectionFunctionIntervalNode"; + CustomNode[CustomNode["DebugProtectionFunctionNode"] = 3] = "DebugProtectionFunctionNode"; + CustomNode[CustomNode["DomainLockNode"] = 4] = "DomainLockNode"; + CustomNode[CustomNode["NodeCallsControllerFunctionNode"] = 5] = "NodeCallsControllerFunctionNode"; + CustomNode[CustomNode["SelfDefendingUnicodeNode"] = 6] = "SelfDefendingUnicodeNode"; + CustomNode[CustomNode["StringArrayCallsWrapper"] = 7] = "StringArrayCallsWrapper"; + CustomNode[CustomNode["StringArrayNode"] = 8] = "StringArrayNode"; + CustomNode[CustomNode["StringArrayRotateFunctionNode"] = 9] = "StringArrayRotateFunctionNode"; +})(CustomNode = exports.CustomNode || (exports.CustomNode = {})); + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var JSFuck_1 = __webpack_require__(107); + +var Utils = function () { + function Utils() { + _classCallCheck(this, Utils); + } + + _createClass(Utils, null, [{ + key: "decToHex", + value: function decToHex(dec) { + var radix = 16; + return dec.toString(radix); + } + }, { + key: "extractDomainFromUrl", + value: function extractDomainFromUrl(url) { + var domain = void 0; + if (url.indexOf('://') > -1 || url.indexOf('//') === 0) { + domain = url.split('/')[2]; + } else { + domain = url.split('/')[0]; + } + domain = domain.split(':')[0]; + return domain; + } + }, { + key: "isCeilNumber", + value: function isCeilNumber(number) { + return number % 1 === 0; + } + }, { + key: "stringRotate", + value: function stringRotate(string, times) { + if (!string) { + throw new ReferenceError("Cannot rotate empty string."); + } + for (var i = 0; i < times; i++) { + string = string[string.length - 1] + string.substring(0, string.length - 1); + } + return string; + } + }, { + key: "stringToJSFuck", + value: function stringToJSFuck(string) { + return Array.from(string).map(function (character) { + return JSFuck_1.JSFuck[character] || character; + }).join(' + '); + } + }]); + + return Utils; +}(); + +Utils.hexadecimalPrefix = '0x'; +exports.Utils = Utils; + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractCustomNodeGroup = function () { + function AbstractCustomNodeGroup(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, AbstractCustomNodeGroup); + + this.identifierNameGenerator = identifierNameGeneratorFactory(options); + this.randomGenerator = randomGenerator; + this.options = options; + } + + _createClass(AbstractCustomNodeGroup, [{ + key: "getAppendEvent", + value: function getAppendEvent() { + return this.appendEvent; + } + }, { + key: "getCustomNodes", + value: function getCustomNodes() { + return this.customNodes; + } + }, { + key: "appendCustomNodeIfExist", + value: function appendCustomNodeIfExist(customNodeName, callback) { + var customNode = this.customNodes.get(customNodeName); + if (!customNode) { + return; + } + callback(customNode); + } + }, { + key: "getRandomStackTraceIndex", + value: function getRandomStackTraceIndex(stackTraceLength) { + return this.randomGenerator.getRandomInteger(0, Math.max(0, Math.round(stackTraceLength - 1))); + } + }]); + + return AbstractCustomNodeGroup; +}(); +AbstractCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], AbstractCustomNodeGroup); +exports.AbstractCustomNodeGroup = AbstractCustomNodeGroup; + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var SourceMapMode; +(function (SourceMapMode) { + SourceMapMode["Inline"] = "inline"; + SourceMapMode["Separate"] = "separate"; +})(SourceMapMode = exports.SourceMapMode || (exports.SourceMapMode = {})); + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var StringArrayEncoding; +(function (StringArrayEncoding) { + StringArrayEncoding["Base64"] = "base64"; + StringArrayEncoding["Rc4"] = "rc4"; +})(StringArrayEncoding = exports.StringArrayEncoding || (exports.StringArrayEncoding = {})); + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var ObfuscationTarget_1 = __webpack_require__(13); +var SourceMapMode_1 = __webpack_require__(23); +exports.NO_CUSTOM_NODES_PRESET = Object.freeze({ + compact: true, + controlFlowFlattening: false, + controlFlowFlatteningThreshold: 0, + deadCodeInjection: false, + deadCodeInjectionThreshold: 0, + debugProtection: false, + debugProtectionInterval: false, + disableConsoleOutput: false, + domainLock: [], + log: false, + mangle: false, + renameGlobals: false, + reservedNames: [], + rotateStringArray: false, + seed: 0, + selfDefending: false, + sourceMap: false, + sourceMapBaseUrl: '', + sourceMapFileName: '', + sourceMapMode: SourceMapMode_1.SourceMapMode.Separate, + stringArray: false, + stringArrayEncoding: false, + stringArrayThreshold: 0, + target: ObfuscationTarget_1.ObfuscationTarget.Browser, + unicodeEscapeSequence: false +}); + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractObfuscatingReplacer = function AbstractObfuscatingReplacer(options) { + _classCallCheck(this, AbstractObfuscatingReplacer); + + this.options = options; +}; +AbstractObfuscatingReplacer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], AbstractObfuscatingReplacer); +exports.AbstractObfuscatingReplacer = AbstractObfuscatingReplacer; + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var AbstractCalleeDataExtractor = function AbstractCalleeDataExtractor() { + _classCallCheck(this, AbstractCalleeDataExtractor); +}; +AbstractCalleeDataExtractor = tslib_1.__decorate([inversify_1.injectable()], AbstractCalleeDataExtractor); +exports.AbstractCalleeDataExtractor = AbstractCalleeDataExtractor; + +/***/ }), +/* 28 */ +/***/ (function(module, exports) { + +module.exports = require("escodegen-wallaby"); + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractControlFlowReplacer = AbstractControlFlowReplacer_1 = function () { + function AbstractControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) { + _classCallCheck(this, AbstractControlFlowReplacer); + + this.replacerDataByControlFlowStorageId = new Map(); + this.controlFlowCustomNodeFactory = controlFlowCustomNodeFactory; + this.randomGenerator = randomGenerator; + this.options = options; + } + + _createClass(AbstractControlFlowReplacer, [{ + key: "insertCustomNodeToControlFlowStorage", + value: function insertCustomNodeToControlFlowStorage(customNode, controlFlowStorage, replacerId, usingExistingIdentifierChance) { + var _this = this; + + var controlFlowStorageId = controlFlowStorage.getStorageId(); + var storageKeysById = AbstractControlFlowReplacer_1.getStorageKeysByIdForCurrentStorage(this.replacerDataByControlFlowStorageId, controlFlowStorageId); + var storageKeysForCurrentId = storageKeysById.get(replacerId); + if (this.randomGenerator.getMathRandom() < usingExistingIdentifierChance && storageKeysForCurrentId && storageKeysForCurrentId.length) { + return this.randomGenerator.getRandomGenerator().pickone(storageKeysForCurrentId); + } + var generateStorageKey = function generateStorageKey(length) { + var key = _this.randomGenerator.getRandomString(length); + if (controlFlowStorage.getStorage().has(key)) { + return generateStorageKey(length); + } + return key; + }; + var storageKey = generateStorageKey(5); + storageKeysById.set(replacerId, [storageKey]); + this.replacerDataByControlFlowStorageId.set(controlFlowStorageId, storageKeysById); + controlFlowStorage.set(storageKey, customNode); + return storageKey; + } + }], [{ + key: "getStorageKeysByIdForCurrentStorage", + value: function getStorageKeysByIdForCurrentStorage(identifierDataByControlFlowStorageId, controlFlowStorageId) { + var storageKeysById = void 0; + if (identifierDataByControlFlowStorageId.has(controlFlowStorageId)) { + storageKeysById = identifierDataByControlFlowStorageId.get(controlFlowStorageId); + } else { + storageKeysById = new Map(); + } + return storageKeysById; + } + }]); + + return AbstractControlFlowReplacer; +}(); +AbstractControlFlowReplacer = AbstractControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], AbstractControlFlowReplacer); +exports.AbstractControlFlowReplacer = AbstractControlFlowReplacer; +var AbstractControlFlowReplacer_1; + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function GlobalVariableNoEvalTemplate() { + return "\n var that = (typeof window !== 'undefined'\n ? window\n : (typeof process === 'object' &&\n typeof require === 'function' &&\n typeof global === 'object')\n ? global\n : this);\n "; +} +exports.GlobalVariableNoEvalTemplate = GlobalVariableNoEvalTemplate; + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var ObfuscationTarget_1 = __webpack_require__(13); +var SourceMapMode_1 = __webpack_require__(23); +exports.DEFAULT_PRESET = Object.freeze({ + compact: true, + config: '', + controlFlowFlattening: false, + controlFlowFlatteningThreshold: 0.75, + deadCodeInjection: false, + deadCodeInjectionThreshold: 0.4, + debugProtection: false, + debugProtectionInterval: false, + disableConsoleOutput: false, + domainLock: [], + log: false, + mangle: false, + renameGlobals: false, + reservedNames: [], + rotateStringArray: true, + seed: 0, + selfDefending: false, + sourceMap: false, + sourceMapBaseUrl: '', + sourceMapFileName: '', + sourceMapMode: SourceMapMode_1.SourceMapMode.Separate, + stringArray: true, + stringArrayEncoding: false, + stringArrayThreshold: 0.75, + target: ObfuscationTarget_1.ObfuscationTarget.Browser, + unicodeEscapeSequence: false +}); + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var commander = __webpack_require__(169); +var path = __webpack_require__(33); +var Initializable_1 = __webpack_require__(3); +var Default_1 = __webpack_require__(31); +var ArraySanitizer_1 = __webpack_require__(170); +var BooleanSanitizer_1 = __webpack_require__(171); +var ObfuscatingTargetSanitizer_1 = __webpack_require__(172); +var SourceMapModeSanitizer_1 = __webpack_require__(173); +var StringArrayEncodingSanitizer_1 = __webpack_require__(174); +var CLIUtils_1 = __webpack_require__(175); +var JavaScriptObfuscatorFacade_1 = __webpack_require__(17); +var SourceCodeReader_1 = __webpack_require__(178); + +var JavaScriptObfuscatorCLI = function () { + function JavaScriptObfuscatorCLI(argv) { + _classCallCheck(this, JavaScriptObfuscatorCLI); + + this.rawArguments = argv; + this.arguments = argv.slice(2); + } + + _createClass(JavaScriptObfuscatorCLI, [{ + key: "initialize", + value: function initialize() { + this.inputPath = this.arguments[0] || ''; + this.commands = new commander.Command(); + this.configureCommands(); + this.configureHelp(); + this.inputCLIOptions = this.commands.opts(); + } + }, { + key: "run", + value: function run() { + var canShowHelp = !this.arguments.length || this.arguments.indexOf('--help') !== -1; + if (canShowHelp) { + return this.commands.outputHelp(); + } + var sourceCodeData = SourceCodeReader_1.SourceCodeReader.readSourceCode(this.inputPath); + this.processSourceCodeData(sourceCodeData); + } + }, { + key: "buildOptions", + value: function buildOptions() { + var inputCLIOptions = JavaScriptObfuscatorCLI.filterOptions(this.inputCLIOptions); + var configFilePath = this.inputCLIOptions.config; + var configFileLocation = configFilePath ? path.resolve(configFilePath, '.') : ''; + var configFileOptions = configFileLocation ? CLIUtils_1.CLIUtils.getUserConfig(configFileLocation) : {}; + return Object.assign({}, Default_1.DEFAULT_PRESET, configFileOptions, inputCLIOptions); + } + }, { + key: "configureCommands", + value: function configureCommands() { + this.commands.usage(' [options]').version(CLIUtils_1.CLIUtils.getPackageConfig().version, '-v, --version').option('-o, --output ', 'Output path for obfuscated code').option('--compact ', 'Disable one line output code compacting', BooleanSanitizer_1.BooleanSanitizer).option('--config ', 'Name of js / json config file').option('--controlFlowFlattening ', 'Enables control flow flattening', BooleanSanitizer_1.BooleanSanitizer).option('--controlFlowFlatteningThreshold ', 'The probability that the control flow flattening transformation will be applied to the node', parseFloat).option('--deadCodeInjection ', 'Enables dead code injection', BooleanSanitizer_1.BooleanSanitizer).option('--deadCodeInjectionThreshold ', 'The probability that the dead code injection transformation will be applied to the node', parseFloat).option('--debugProtection ', 'Disable browser Debug panel (can cause DevTools enabled browser freeze)', BooleanSanitizer_1.BooleanSanitizer).option('--debugProtectionInterval ', 'Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)', BooleanSanitizer_1.BooleanSanitizer).option('--disableConsoleOutput ', 'Allow console.log, console.info, console.error and console.warn messages output into browser console', BooleanSanitizer_1.BooleanSanitizer).option('--domainLock (comma separated, without whitespaces)', 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)', ArraySanitizer_1.ArraySanitizer).option('--log ', 'Enables logging of the information to the console', BooleanSanitizer_1.BooleanSanitizer).option('--mangle ', 'Enables mangling of variable names', BooleanSanitizer_1.BooleanSanitizer).option('--reservedNames (comma separated, without whitespaces)', 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)', ArraySanitizer_1.ArraySanitizer).option('--renameGlobals ', 'Allows to enable obfuscation of global variable and function names with declaration.', BooleanSanitizer_1.BooleanSanitizer).option('--rotateStringArray ', 'Disable rotation of unicode array values during obfuscation', BooleanSanitizer_1.BooleanSanitizer).option('--seed ', 'Sets seed for random generator. This is useful for creating repeatable results.', parseFloat).option('--selfDefending ', 'Disables self-defending for obfuscated code', BooleanSanitizer_1.BooleanSanitizer).option('--sourceMap ', 'Enables source map generation', BooleanSanitizer_1.BooleanSanitizer).option('--sourceMapBaseUrl ', 'Sets base url to the source map import url when `--sourceMapMode=separate`').option('--sourceMapFileName ', 'Sets file name for output source map when `--sourceMapMode=separate`').option('--sourceMapMode [inline, separate]', 'Specify source map output mode', SourceMapModeSanitizer_1.SourceMapModeSanitizer).option('--stringArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', BooleanSanitizer_1.BooleanSanitizer).option('--stringArrayEncoding [true, false, base64, rc4]', 'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed', StringArrayEncodingSanitizer_1.StringArrayEncodingSanitizer).option('--stringArrayThreshold ', 'The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).option('--target ', 'Allows to set target environment for obfuscated code.', ObfuscatingTargetSanitizer_1.ObfuscationTargetSanitizer).option('--unicodeEscapeSequence ', 'Allows to enable/disable string conversion to unicode escape sequence', BooleanSanitizer_1.BooleanSanitizer).parse(this.rawArguments); + } + }, { + key: "configureHelp", + value: function configureHelp() { + this.commands.on('--help', function () { + console.log(' Examples:\n'); + console.log(' %> javascript-obfuscator input_file_name.js --compact true --selfDefending false'); + console.log(' %> javascript-obfuscator input_file_name.js --output output_file_name.js --compact true --selfDefending false'); + console.log(' %> javascript-obfuscator input_directory_name --compact true --selfDefending false'); + console.log(''); + }); + } + }, { + key: "processSourceCodeData", + value: function processSourceCodeData(sourceCodeData) { + var _this = this; + + if (!Array.isArray(sourceCodeData)) { + var outputCodePath = this.inputCLIOptions.output || CLIUtils_1.CLIUtils.getOutputCodePath(this.inputPath); + this.processSourceCode(sourceCodeData, outputCodePath); + } else { + sourceCodeData.forEach(function (_ref) { + var filePath = _ref.filePath, + content = _ref.content; + + var outputCodePath = CLIUtils_1.CLIUtils.getOutputCodePath(filePath); + _this.processSourceCode(content, outputCodePath); + }); + } + } + }, { + key: "processSourceCode", + value: function processSourceCode(sourceCode, outputCodePath) { + var options = this.buildOptions(); + if (options.sourceMap) { + JavaScriptObfuscatorCLI.processSourceCodeWithSourceMap(sourceCode, outputCodePath, options); + } else { + JavaScriptObfuscatorCLI.processSourceCodeWithoutSourceMap(sourceCode, outputCodePath, options); + } + } + }], [{ + key: "filterOptions", + value: function filterOptions(options) { + var filteredOptions = {}; + for (var option in options) { + if (!options.hasOwnProperty(option) || options[option] === undefined) { + continue; + } + filteredOptions[option] = options[option]; + } + return filteredOptions; + } + }, { + key: "processSourceCodeWithoutSourceMap", + value: function processSourceCodeWithoutSourceMap(sourceCode, outputCodePath, options) { + var obfuscatedCode = JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(sourceCode, options).getObfuscatedCode(); + CLIUtils_1.CLIUtils.writeFile(outputCodePath, obfuscatedCode); + } + }, { + key: "processSourceCodeWithSourceMap", + value: function processSourceCodeWithSourceMap(sourceCode, outputCodePath, options) { + var outputSourceMapPath = CLIUtils_1.CLIUtils.getOutputSourceMapPath(outputCodePath, options.sourceMapFileName || ''); + options = Object.assign({}, options, { sourceMapFileName: path.basename(outputSourceMapPath) }); + var obfuscationResult = JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(sourceCode, options); + CLIUtils_1.CLIUtils.writeFile(outputCodePath, obfuscationResult.getObfuscatedCode()); + if (options.sourceMapMode === 'separate' && obfuscationResult.getSourceMap()) { + CLIUtils_1.CLIUtils.writeFile(outputSourceMapPath, obfuscationResult.getSourceMap()); + } + } + }]); + + return JavaScriptObfuscatorCLI; +}(); + +JavaScriptObfuscatorCLI.availableInputExtensions = ['.js']; +JavaScriptObfuscatorCLI.encoding = 'utf8'; +JavaScriptObfuscatorCLI.obfuscatedFilePrefix = '-obfuscated'; +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], JavaScriptObfuscatorCLI.prototype, "commands", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], JavaScriptObfuscatorCLI.prototype, "inputCLIOptions", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], JavaScriptObfuscatorCLI.prototype, "inputPath", void 0); +exports.JavaScriptObfuscatorCLI = JavaScriptObfuscatorCLI; + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +module.exports = require("path"); + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var CalleeDataExtractor; +(function (CalleeDataExtractor) { + CalleeDataExtractor[CalleeDataExtractor["FunctionDeclarationCalleeDataExtractor"] = 0] = "FunctionDeclarationCalleeDataExtractor"; + CalleeDataExtractor[CalleeDataExtractor["FunctionExpressionCalleeDataExtractor"] = 1] = "FunctionExpressionCalleeDataExtractor"; + CalleeDataExtractor[CalleeDataExtractor["ObjectExpressionCalleeDataExtractor"] = 2] = "ObjectExpressionCalleeDataExtractor"; +})(CalleeDataExtractor = exports.CalleeDataExtractor || (exports.CalleeDataExtractor = {})); + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +module.exports = require("esprima"); + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var ControlFlowReplacer; +(function (ControlFlowReplacer) { + ControlFlowReplacer[ControlFlowReplacer["BinaryExpressionControlFlowReplacer"] = 0] = "BinaryExpressionControlFlowReplacer"; + ControlFlowReplacer[ControlFlowReplacer["CallExpressionControlFlowReplacer"] = 1] = "CallExpressionControlFlowReplacer"; + ControlFlowReplacer[ControlFlowReplacer["LogicalExpressionControlFlowReplacer"] = 2] = "LogicalExpressionControlFlowReplacer"; + ControlFlowReplacer[ControlFlowReplacer["StringLiteralControlFlowReplacer"] = 3] = "StringLiteralControlFlowReplacer"; +})(ControlFlowReplacer = exports.ControlFlowReplacer || (exports.ControlFlowReplacer = {})); + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ControlFlowCustomNode_1 = __webpack_require__(12); +var AbstractControlFlowReplacer_1 = __webpack_require__(29); +var NodeGuards_1 = __webpack_require__(5); +var ExpressionWithOperatorControlFlowReplacer = function (_AbstractControlFlowR) { + _inherits(ExpressionWithOperatorControlFlowReplacer, _AbstractControlFlowR); + + function ExpressionWithOperatorControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) { + _classCallCheck(this, ExpressionWithOperatorControlFlowReplacer); + + var _this = _possibleConstructorReturn(this, (ExpressionWithOperatorControlFlowReplacer.__proto__ || Object.getPrototypeOf(ExpressionWithOperatorControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options)); + + _this.replacerDataByControlFlowStorageId = new Map(); + return _this; + } + + _createClass(ExpressionWithOperatorControlFlowReplacer, [{ + key: "getControlFlowStorageCallNode", + value: function getControlFlowStorageCallNode(controlFlowStorageId, storageKey, leftExpression, rightExpression) { + var controlFlowStorageCallCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode); + controlFlowStorageCallCustomNode.initialize(controlFlowStorageId, storageKey, leftExpression, rightExpression); + var statementNode = controlFlowStorageCallCustomNode.getNode()[0]; + if (!statementNode || !NodeGuards_1.NodeGuards.isExpressionStatementNode(statementNode)) { + throw new Error("`controlFlowStorageCallCustomNode.getNode()[0]` should returns array with `ExpressionStatement` node"); + } + return statementNode.expression; + } + }]); + + return ExpressionWithOperatorControlFlowReplacer; +}(AbstractControlFlowReplacer_1.AbstractControlFlowReplacer); +ExpressionWithOperatorControlFlowReplacer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ExpressionWithOperatorControlFlowReplacer); +exports.ExpressionWithOperatorControlFlowReplacer = ExpressionWithOperatorControlFlowReplacer; + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var CustomNodeGroup; +(function (CustomNodeGroup) { + CustomNodeGroup[CustomNodeGroup["ConsoleOutputCustomNodeGroup"] = 0] = "ConsoleOutputCustomNodeGroup"; + CustomNodeGroup[CustomNodeGroup["DebugProtectionCustomNodeGroup"] = 1] = "DebugProtectionCustomNodeGroup"; + CustomNodeGroup[CustomNodeGroup["DomainLockCustomNodeGroup"] = 2] = "DomainLockCustomNodeGroup"; + CustomNodeGroup[CustomNodeGroup["SelfDefendingCustomNodeGroup"] = 3] = "SelfDefendingCustomNodeGroup"; + CustomNodeGroup[CustomNodeGroup["StringArrayCustomNodeGroup"] = 4] = "StringArrayCustomNodeGroup"; +})(CustomNodeGroup = exports.CustomNodeGroup || (exports.CustomNodeGroup = {})); + +/***/ }), +/* 39 */, +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var LiteralObfuscatingReplacer; +(function (LiteralObfuscatingReplacer) { + LiteralObfuscatingReplacer[LiteralObfuscatingReplacer["BooleanLiteralObfuscatingReplacer"] = 0] = "BooleanLiteralObfuscatingReplacer"; + LiteralObfuscatingReplacer[LiteralObfuscatingReplacer["NumberLiteralObfuscatingReplacer"] = 1] = "NumberLiteralObfuscatingReplacer"; + LiteralObfuscatingReplacer[LiteralObfuscatingReplacer["StringLiteralObfuscatingReplacer"] = 2] = "StringLiteralObfuscatingReplacer"; +})(LiteralObfuscatingReplacer = exports.LiteralObfuscatingReplacer || (exports.LiteralObfuscatingReplacer = {})); + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var ObfuscatingGuard; +(function (ObfuscatingGuard) { + ObfuscatingGuard[ObfuscatingGuard["BlackListNodeGuard"] = 0] = "BlackListNodeGuard"; + ObfuscatingGuard[ObfuscatingGuard["ConditionalCommentNodeGuard"] = 1] = "ConditionalCommentNodeGuard"; +})(ObfuscatingGuard = exports.ObfuscatingGuard || (exports.ObfuscatingGuard = {})); + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var MapStorage = function () { + function MapStorage(randomGenerator, options) { + _classCallCheck(this, MapStorage); + + this.randomGenerator = randomGenerator; + this.options = options; + } + + _createClass(MapStorage, [{ + key: "initialize", + value: function initialize() { + this.storage = new Map(); + this.storageId = this.randomGenerator.getRandomString(6); + } + }, { + key: "get", + value: function get(key) { + var value = this.storage.get(key); + if (!value) { + throw new Error("No value found in map storage with key `" + key + "`"); + } + return value; + } + }, { + key: "getKeyOf", + value: function getKeyOf(value) { + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = this.storage[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var _step$value = _slicedToArray(_step.value, 2), + key = _step$value[0], + storageValue = _step$value[1]; + + if (value === storageValue) { + return key; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return null; + } + }, { + key: "getLength", + value: function getLength() { + return this.storage.size; + } + }, { + key: "getStorage", + value: function getStorage() { + return this.storage; + } + }, { + key: "getStorageId", + value: function getStorageId() { + return this.storageId; + } + }, { + key: "mergeWith", + value: function mergeWith(storage) { + var mergeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + this.storage = new Map([].concat(_toConsumableArray(this.storage), _toConsumableArray(storage.getStorage()))); + if (mergeId) { + this.storageId = storage.getStorageId(); + } + } + }, { + key: "set", + value: function set(key, value) { + this.storage.set(key, value); + } + }]); + + return MapStorage; +}(); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], MapStorage.prototype, "storageId", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], MapStorage.prototype, "storage", void 0); +tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], MapStorage.prototype, "initialize", null); +MapStorage = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], MapStorage); +exports.MapStorage = MapStorage; + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var md5 = __webpack_require__(141); +var chance_1 = __webpack_require__(142); +var Initializable_1 = __webpack_require__(3); +var RandomGenerator = RandomGenerator_1 = function () { + function RandomGenerator(sourceCode, options) { + _classCallCheck(this, RandomGenerator); + + this.sourceCode = sourceCode; + this.options = options; + } + + _createClass(RandomGenerator, [{ + key: "initialize", + value: function initialize() { + var _this = this; + + var getRandomInteger = function getRandomInteger(min, max) { + return Math.floor(Math.random() * (max - min + 1) + min); + }; + var getSeed = function getSeed() { + var md5Hash = md5(_this.sourceCode.getSourceCode()); + return _this.seed + Number(md5Hash.replace(/\D/g, '')); + }; + this.seed = this.options.seed !== 0 ? this.options.seed : getRandomInteger(0, 999999999); + this.randomGenerator = new chance_1.Chance(getSeed()); + } + }, { + key: "getMathRandom", + value: function getMathRandom() { + return this.getRandomInteger(0, 99999) / 100000; + } + }, { + key: "getRandomFloat", + value: function getRandomFloat(min, max) { + return this.getRandomGenerator().floating({ + min: min, + max: max, + fixed: 7 + }); + } + }, { + key: "getRandomGenerator", + value: function getRandomGenerator() { + return this.randomGenerator; + } + }, { + key: "getRandomInteger", + value: function getRandomInteger(min, max) { + return this.getRandomGenerator().integer({ + min: min, + max: max + }); + } + }, { + key: "getRandomString", + value: function getRandomString(length) { + var pool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : RandomGenerator_1.randomGeneratorPool; + + return this.getRandomGenerator().string({ length: length, pool: pool }); + } + }, { + key: "getSeed", + value: function getSeed() { + return this.seed; + } + }]); + + return RandomGenerator; +}(); +RandomGenerator.randomGeneratorPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; +RandomGenerator.randomGeneratorPoolNumbers = '0123456789'; +RandomGenerator.randomGeneratorPoolHexadecimal = "abcdef" + RandomGenerator_1.randomGeneratorPoolNumbers; +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], RandomGenerator.prototype, "randomGenerator", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Number)], RandomGenerator.prototype, "seed", void 0); +tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], RandomGenerator.prototype, "initialize", null); +RandomGenerator = RandomGenerator_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ISourceCode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], RandomGenerator); +exports.RandomGenerator = RandomGenerator; +var RandomGenerator_1; + +/***/ }), +/* 44 */ +/***/ (function(module, exports) { + +module.exports = require("fs"); + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var JavaScriptObfuscatorFacade_1 = __webpack_require__(17); +module.exports = JavaScriptObfuscatorFacade_1.JavaScriptObfuscator; + +/***/ }), +/* 46 */ +/***/ (function(module, exports) { + +module.exports = require("reflect-metadata"); + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var InversifyContainerFacade_1 = __webpack_require__(14); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var CalleeDataExtractor_1 = __webpack_require__(34); +var FunctionDeclarationCalleeDataExtractor_1 = __webpack_require__(48); +var FunctionExpressionCalleeDataExtractor_1 = __webpack_require__(49); +var ObjectExpressionCalleeDataExtractor_1 = __webpack_require__(50); +var StackTraceAnalyzer_1 = __webpack_require__(51); +exports.analyzersModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.IStackTraceAnalyzer).to(StackTraceAnalyzer_1.StackTraceAnalyzer).inSingletonScope(); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICalleeDataExtractor).to(FunctionDeclarationCalleeDataExtractor_1.FunctionDeclarationCalleeDataExtractor).whenTargetNamed(CalleeDataExtractor_1.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICalleeDataExtractor).to(FunctionExpressionCalleeDataExtractor_1.FunctionExpressionCalleeDataExtractor).whenTargetNamed(CalleeDataExtractor_1.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICalleeDataExtractor).to(ObjectExpressionCalleeDataExtractor_1.ObjectExpressionCalleeDataExtractor).whenTargetNamed(CalleeDataExtractor_1.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICalleeDataExtractor).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.ICalleeDataExtractor)); +}); + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var estraverse = __webpack_require__(8); +var AbstractCalleeDataExtractor_1 = __webpack_require__(27); +var NodeGuards_1 = __webpack_require__(5); +var NodeUtils_1 = __webpack_require__(4); +var FunctionDeclarationCalleeDataExtractor = function (_AbstractCalleeDataEx) { + _inherits(FunctionDeclarationCalleeDataExtractor, _AbstractCalleeDataEx); + + function FunctionDeclarationCalleeDataExtractor() { + _classCallCheck(this, FunctionDeclarationCalleeDataExtractor); + + return _possibleConstructorReturn(this, (FunctionDeclarationCalleeDataExtractor.__proto__ || Object.getPrototypeOf(FunctionDeclarationCalleeDataExtractor)).apply(this, arguments)); + } + + _createClass(FunctionDeclarationCalleeDataExtractor, [{ + key: "extract", + value: function extract(blockScopeBody, callee) { + if (!NodeGuards_1.NodeGuards.isIdentifierNode(callee)) { + return null; + } + var calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopesOfNode(blockScopeBody[0])[0], callee.name); + if (!calleeBlockStatement) { + return null; + } + return { + callee: calleeBlockStatement, + name: callee.name + }; + } + }, { + key: "getCalleeBlockStatement", + value: function getCalleeBlockStatement(targetNode, name) { + var calleeBlockStatement = null; + estraverse.traverse(targetNode, { + enter: function enter(node) { + if (NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node) && node.id.name === name) { + calleeBlockStatement = node.body; + return estraverse.VisitorOption.Break; + } + } + }); + return calleeBlockStatement; + } + }]); + + return FunctionDeclarationCalleeDataExtractor; +}(AbstractCalleeDataExtractor_1.AbstractCalleeDataExtractor); +FunctionDeclarationCalleeDataExtractor = tslib_1.__decorate([inversify_1.injectable()], FunctionDeclarationCalleeDataExtractor); +exports.FunctionDeclarationCalleeDataExtractor = FunctionDeclarationCalleeDataExtractor; + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var estraverse = __webpack_require__(8); +var AbstractCalleeDataExtractor_1 = __webpack_require__(27); +var NodeGuards_1 = __webpack_require__(5); +var NodeUtils_1 = __webpack_require__(4); +var FunctionExpressionCalleeDataExtractor = function (_AbstractCalleeDataEx) { + _inherits(FunctionExpressionCalleeDataExtractor, _AbstractCalleeDataEx); + + function FunctionExpressionCalleeDataExtractor() { + _classCallCheck(this, FunctionExpressionCalleeDataExtractor); + + return _possibleConstructorReturn(this, (FunctionExpressionCalleeDataExtractor.__proto__ || Object.getPrototypeOf(FunctionExpressionCalleeDataExtractor)).apply(this, arguments)); + } + + _createClass(FunctionExpressionCalleeDataExtractor, [{ + key: "extract", + value: function extract(blockScopeBody, callee) { + var calleeBlockStatement = null; + if (NodeGuards_1.NodeGuards.isIdentifierNode(callee)) { + calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopesOfNode(blockScopeBody[0])[0], callee.name); + } + if (NodeGuards_1.NodeGuards.isFunctionExpressionNode(callee)) { + calleeBlockStatement = callee.body; + } + if (!calleeBlockStatement) { + return null; + } + return { + callee: calleeBlockStatement, + name: callee.name || null + }; + } + }, { + key: "getCalleeBlockStatement", + value: function getCalleeBlockStatement(targetNode, name) { + var calleeBlockStatement = null; + estraverse.traverse(targetNode, { + enter: function enter(node, parentNode) { + if (NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) && parentNode && NodeGuards_1.NodeGuards.isVariableDeclaratorNode(parentNode) && NodeGuards_1.NodeGuards.isIdentifierNode(parentNode.id) && parentNode.id.name === name) { + calleeBlockStatement = node.body; + return estraverse.VisitorOption.Break; + } + } + }); + return calleeBlockStatement; + } + }]); + + return FunctionExpressionCalleeDataExtractor; +}(AbstractCalleeDataExtractor_1.AbstractCalleeDataExtractor); +FunctionExpressionCalleeDataExtractor = tslib_1.__decorate([inversify_1.injectable()], FunctionExpressionCalleeDataExtractor); +exports.FunctionExpressionCalleeDataExtractor = FunctionExpressionCalleeDataExtractor; + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var estraverse = __webpack_require__(8); +var AbstractCalleeDataExtractor_1 = __webpack_require__(27); +var NodeGuards_1 = __webpack_require__(5); +var NodeUtils_1 = __webpack_require__(4); +var ObjectExpressionCalleeDataExtractor = function (_AbstractCalleeDataEx) { + _inherits(ObjectExpressionCalleeDataExtractor, _AbstractCalleeDataEx); + + function ObjectExpressionCalleeDataExtractor() { + _classCallCheck(this, ObjectExpressionCalleeDataExtractor); + + return _possibleConstructorReturn(this, (ObjectExpressionCalleeDataExtractor.__proto__ || Object.getPrototypeOf(ObjectExpressionCalleeDataExtractor)).apply(this, arguments)); + } + + _createClass(ObjectExpressionCalleeDataExtractor, [{ + key: "extract", + value: function extract(blockScopeBody, callee) { + if (!NodeGuards_1.NodeGuards.isMemberExpressionNode(callee)) { + return null; + } + var objectMembersCallsChain = this.createObjectMembersCallsChain([], callee); + if (!objectMembersCallsChain.length) { + return null; + } + var functionExpressionName = objectMembersCallsChain[objectMembersCallsChain.length - 1]; + var calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopesOfNode(blockScopeBody[0])[0], objectMembersCallsChain); + if (!calleeBlockStatement) { + return null; + } + return { + callee: calleeBlockStatement, + name: functionExpressionName + }; + } + }, { + key: "createObjectMembersCallsChain", + value: function createObjectMembersCallsChain(currentChain, memberExpression) { + if (NodeGuards_1.NodeGuards.isIdentifierNode(memberExpression.property) && memberExpression.computed === false) { + currentChain.unshift(memberExpression.property.name); + } else if (NodeGuards_1.NodeGuards.isLiteralNode(memberExpression.property) && (typeof memberExpression.property.value === 'string' || typeof memberExpression.property.value === 'number')) { + currentChain.unshift(memberExpression.property.value); + } else { + return currentChain; + } + if (NodeGuards_1.NodeGuards.isMemberExpressionNode(memberExpression.object)) { + return this.createObjectMembersCallsChain(currentChain, memberExpression.object); + } else if (NodeGuards_1.NodeGuards.isIdentifierNode(memberExpression.object)) { + currentChain.unshift(memberExpression.object.name); + } + return currentChain; + } + }, { + key: "getCalleeBlockStatement", + value: function getCalleeBlockStatement(targetNode, objectMembersCallsChain) { + var _this2 = this; + + var objectName = objectMembersCallsChain.shift(); + if (!objectName) { + return null; + } + var calleeBlockStatement = null; + estraverse.traverse(targetNode, { + enter: function enter(node) { + if (NodeGuards_1.NodeGuards.isVariableDeclaratorNode(node) && NodeGuards_1.NodeGuards.isIdentifierNode(node.id) && node.init && NodeGuards_1.NodeGuards.isObjectExpressionNode(node.init) && node.id.name === objectName) { + calleeBlockStatement = _this2.findCalleeBlockStatement(node.init.properties, objectMembersCallsChain); + return estraverse.VisitorOption.Break; + } + } + }); + return calleeBlockStatement; + } + }, { + key: "findCalleeBlockStatement", + value: function findCalleeBlockStatement(objectExpressionProperties, objectMembersCallsChain) { + var nextItemInCallsChain = objectMembersCallsChain.shift(); + if (!nextItemInCallsChain) { + return null; + } + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = objectExpressionProperties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var propertyNode = _step.value; + + var isTargetPropertyNodeWithIdentifierKey = NodeGuards_1.NodeGuards.isIdentifierNode(propertyNode.key) && propertyNode.key.name === nextItemInCallsChain; + var isTargetPropertyNodeWithLiteralKey = NodeGuards_1.NodeGuards.isLiteralNode(propertyNode.key) && Boolean(propertyNode.key.value) && propertyNode.key.value === nextItemInCallsChain; + if (!isTargetPropertyNodeWithIdentifierKey && !isTargetPropertyNodeWithLiteralKey) { + continue; + } + if (NodeGuards_1.NodeGuards.isObjectExpressionNode(propertyNode.value)) { + return this.findCalleeBlockStatement(propertyNode.value.properties, objectMembersCallsChain); + } + if (NodeGuards_1.NodeGuards.isFunctionExpressionNode(propertyNode.value)) { + return propertyNode.value.body; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return null; + } + }]); + + return ObjectExpressionCalleeDataExtractor; +}(AbstractCalleeDataExtractor_1.AbstractCalleeDataExtractor); +ObjectExpressionCalleeDataExtractor = tslib_1.__decorate([inversify_1.injectable()], ObjectExpressionCalleeDataExtractor); +exports.ObjectExpressionCalleeDataExtractor = ObjectExpressionCalleeDataExtractor; + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var CalleeDataExtractor_1 = __webpack_require__(34); +var NodeGuards_1 = __webpack_require__(5); +var NodeUtils_1 = __webpack_require__(4); +var StackTraceAnalyzer = StackTraceAnalyzer_1 = function () { + function StackTraceAnalyzer(calleeDataExtractorFactory) { + _classCallCheck(this, StackTraceAnalyzer); + + this.calleeDataExtractorFactory = calleeDataExtractorFactory; + } + + _createClass(StackTraceAnalyzer, [{ + key: "analyze", + value: function analyze(astTree) { + return this.analyzeRecursive(astTree.body); + } + }, { + key: "analyzeRecursive", + value: function analyzeRecursive(blockScopeBody) { + var _this = this; + + var limitIndex = StackTraceAnalyzer_1.getLimitIndex(blockScopeBody.length); + var stackTraceData = []; + var blockScopeBodyLength = blockScopeBody.length; + + var _loop = function _loop(index) { + if (index > limitIndex) { + return "break"; + } + var blockScopeBodyNode = blockScopeBody[index]; + estraverse.traverse(blockScopeBodyNode, { + enter: function enter(node) { + if (!NodeGuards_1.NodeGuards.isCallExpressionNode(node)) { + return; + } + if (blockScopeBodyNode.parentNode !== NodeUtils_1.NodeUtils.getBlockScopesOfNode(node)[0]) { + return estraverse.VisitorOption.Skip; + } + _this.analyzeCallExpressionNode(stackTraceData, blockScopeBody, node); + } + }); + }; + + for (var index = 0; index < blockScopeBodyLength; index++) { + var _ret = _loop(index); + + if (_ret === "break") break; + } + return stackTraceData; + } + }, { + key: "analyzeCallExpressionNode", + value: function analyzeCallExpressionNode(stackTraceData, blockScopeBody, callExpressionNode) { + var _this2 = this; + + StackTraceAnalyzer_1.calleeDataExtractorsList.forEach(function (calleeDataExtractorName) { + var calleeData = _this2.calleeDataExtractorFactory(calleeDataExtractorName).extract(blockScopeBody, callExpressionNode.callee); + if (!calleeData) { + return; + } + stackTraceData.push(Object.assign({}, calleeData, { stackTrace: _this2.analyzeRecursive(calleeData.callee.body) })); + }); + } + }], [{ + key: "getLimitIndex", + value: function getLimitIndex(blockScopeBodyLength) { + var lastIndex = blockScopeBodyLength - 1; + var limitThresholdActivationIndex = StackTraceAnalyzer_1.limitThresholdActivationLength - 1; + var limitIndex = lastIndex; + if (lastIndex > limitThresholdActivationIndex) { + limitIndex = Math.round(limitThresholdActivationIndex + lastIndex * StackTraceAnalyzer_1.limitThreshold); + if (limitIndex > lastIndex) { + limitIndex = lastIndex; + } + } + return limitIndex; + } + }]); + + return StackTraceAnalyzer; +}(); +StackTraceAnalyzer.calleeDataExtractorsList = [CalleeDataExtractor_1.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor, CalleeDataExtractor_1.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor, CalleeDataExtractor_1.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor]; +StackTraceAnalyzer.limitThresholdActivationLength = 25; +StackTraceAnalyzer.limitThreshold = 0.002; +StackTraceAnalyzer = StackTraceAnalyzer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICalleeDataExtractor)), tslib_1.__metadata("design:paramtypes", [Function])], StackTraceAnalyzer); +exports.StackTraceAnalyzer = StackTraceAnalyzer; +var StackTraceAnalyzer_1; + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var InversifyContainerFacade_1 = __webpack_require__(14); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ControlFlowReplacer_1 = __webpack_require__(36); +var NodeTransformer_1 = __webpack_require__(18); +var BinaryExpressionControlFlowReplacer_1 = __webpack_require__(53); +var BlockStatementControlFlowTransformer_1 = __webpack_require__(54); +var CallExpressionControlFlowReplacer_1 = __webpack_require__(55); +var DeadCodeInjectionTransformer_1 = __webpack_require__(56); +var FunctionControlFlowTransformer_1 = __webpack_require__(57); +var LogicalExpressionControlFlowReplacer_1 = __webpack_require__(58); +var StringLiteralControlFlowReplacer_1 = __webpack_require__(59); +exports.controlFlowTransformersModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(BlockStatementControlFlowTransformer_1.BlockStatementControlFlowTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.BlockStatementControlFlowTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(DeadCodeInjectionTransformer_1.DeadCodeInjectionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.DeadCodeInjectionTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(FunctionControlFlowTransformer_1.FunctionControlFlowTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.FunctionControlFlowTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(BinaryExpressionControlFlowReplacer_1.BinaryExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacer_1.ControlFlowReplacer.BinaryExpressionControlFlowReplacer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(CallExpressionControlFlowReplacer_1.CallExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacer_1.ControlFlowReplacer.CallExpressionControlFlowReplacer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(LogicalExpressionControlFlowReplacer_1.LogicalExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacer_1.ControlFlowReplacer.LogicalExpressionControlFlowReplacer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(StringLiteralControlFlowReplacer_1.StringLiteralControlFlowReplacer).whenTargetNamed(ControlFlowReplacer_1.ControlFlowReplacer.StringLiteralControlFlowReplacer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer)); +}); + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ControlFlowCustomNode_1 = __webpack_require__(12); +var ExpressionWithOperatorControlFlowReplacer_1 = __webpack_require__(37); +var BinaryExpressionControlFlowReplacer = BinaryExpressionControlFlowReplacer_1 = function (_ExpressionWithOperat) { + _inherits(BinaryExpressionControlFlowReplacer, _ExpressionWithOperat); + + function BinaryExpressionControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) { + _classCallCheck(this, BinaryExpressionControlFlowReplacer); + + return _possibleConstructorReturn(this, (BinaryExpressionControlFlowReplacer.__proto__ || Object.getPrototypeOf(BinaryExpressionControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options)); + } + + _createClass(BinaryExpressionControlFlowReplacer, [{ + key: "replace", + value: function replace(binaryExpressionNode, parentNode, controlFlowStorage) { + var replacerId = binaryExpressionNode.operator; + var binaryExpressionFunctionCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.BinaryExpressionFunctionNode); + binaryExpressionFunctionCustomNode.initialize(replacerId); + var storageKey = this.insertCustomNodeToControlFlowStorage(binaryExpressionFunctionCustomNode, controlFlowStorage, replacerId, BinaryExpressionControlFlowReplacer_1.usingExistingIdentifierChance); + return this.getControlFlowStorageCallNode(controlFlowStorage.getStorageId(), storageKey, binaryExpressionNode.left, binaryExpressionNode.right); + } + }]); + + return BinaryExpressionControlFlowReplacer; +}(ExpressionWithOperatorControlFlowReplacer_1.ExpressionWithOperatorControlFlowReplacer); +BinaryExpressionControlFlowReplacer.usingExistingIdentifierChance = 0.5; +BinaryExpressionControlFlowReplacer = BinaryExpressionControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], BinaryExpressionControlFlowReplacer); +exports.BinaryExpressionControlFlowReplacer = BinaryExpressionControlFlowReplacer; +var BinaryExpressionControlFlowReplacer_1; + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var ControlFlowCustomNode_1 = __webpack_require__(12); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var BlockStatementControlFlowTransformer = BlockStatementControlFlowTransformer_1 = function (_AbstractNodeTransfor) { + _inherits(BlockStatementControlFlowTransformer, _AbstractNodeTransfor); + + function BlockStatementControlFlowTransformer(controlFlowCustomNodeFactory, arrayUtils, randomGenerator, options) { + _classCallCheck(this, BlockStatementControlFlowTransformer); + + var _this = _possibleConstructorReturn(this, (BlockStatementControlFlowTransformer.__proto__ || Object.getPrototypeOf(BlockStatementControlFlowTransformer)).call(this, randomGenerator, options)); + + _this.controlFlowCustomNodeFactory = controlFlowCustomNodeFactory; + _this.arrayUtils = arrayUtils; + return _this; + } + + _createClass(BlockStatementControlFlowTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + leave: function leave(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isBlockStatementNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(blockStatementNode, parentNode) { + if (this.randomGenerator.getMathRandom() > this.options.controlFlowFlatteningThreshold || !BlockStatementControlFlowTransformer_1.canTransformBlockStatementNode(blockStatementNode)) { + return blockStatementNode; + } + var blockStatementBody = blockStatementNode.body; + var originalKeys = this.arrayUtils.arrayRange(blockStatementBody.length); + var shuffledKeys = this.arrayUtils.arrayShuffle(originalKeys); + var originalKeysIndexesInShuffledArray = originalKeys.map(function (key) { + return shuffledKeys.indexOf(key); + }); + var blockStatementControlFlowFlatteningCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode); + blockStatementControlFlowFlatteningCustomNode.initialize(blockStatementBody, shuffledKeys, originalKeysIndexesInShuffledArray); + return blockStatementControlFlowFlatteningCustomNode.getNode()[0]; + } + }], [{ + key: "blockStatementHasProhibitedStatements", + value: function blockStatementHasProhibitedStatements(blockStatementNode) { + return blockStatementNode.body.some(function (statement) { + var isBreakOrContinueStatement = NodeGuards_1.NodeGuards.isBreakStatementNode(statement) || NodeGuards_1.NodeGuards.isContinueStatementNode(statement); + var isVariableDeclarationWithLetOrConstKind = NodeGuards_1.NodeGuards.isVariableDeclarationNode(statement) && (statement.kind === 'const' || statement.kind === 'let'); + return NodeGuards_1.NodeGuards.isFunctionDeclarationNode(statement) || isBreakOrContinueStatement || isVariableDeclarationWithLetOrConstKind; + }); + } + }, { + key: "canTransformBlockStatementNode", + value: function canTransformBlockStatementNode(blockStatementNode) { + var canTransform = true; + estraverse.traverse(blockStatementNode, { + enter: function enter(node) { + if (NodeGuards_1.NodeGuards.isWhileStatementNode(node)) { + return estraverse.VisitorOption.Skip; + } + if (NodeGuards_1.NodeGuards.isBlockStatementNode(node) && BlockStatementControlFlowTransformer_1.blockStatementHasProhibitedStatements(node)) { + canTransform = false; + } + } + }); + if (blockStatementNode.body.length <= 4) { + canTransform = false; + } + return canTransform; + } + }]); + + return BlockStatementControlFlowTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +BlockStatementControlFlowTransformer = BlockStatementControlFlowTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IArrayUtils)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], BlockStatementControlFlowTransformer); +exports.BlockStatementControlFlowTransformer = BlockStatementControlFlowTransformer; +var BlockStatementControlFlowTransformer_1; + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ControlFlowCustomNode_1 = __webpack_require__(12); +var AbstractControlFlowReplacer_1 = __webpack_require__(29); +var NodeGuards_1 = __webpack_require__(5); +var CallExpressionControlFlowReplacer = CallExpressionControlFlowReplacer_1 = function (_AbstractControlFlowR) { + _inherits(CallExpressionControlFlowReplacer, _AbstractControlFlowR); + + function CallExpressionControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) { + _classCallCheck(this, CallExpressionControlFlowReplacer); + + return _possibleConstructorReturn(this, (CallExpressionControlFlowReplacer.__proto__ || Object.getPrototypeOf(CallExpressionControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options)); + } + + _createClass(CallExpressionControlFlowReplacer, [{ + key: "replace", + value: function replace(callExpressionNode, parentNode, controlFlowStorage) { + var callee = callExpressionNode.callee; + if (!NodeGuards_1.NodeGuards.isIdentifierNode(callee)) { + return callExpressionNode; + } + var replacerId = String(callExpressionNode.arguments.length); + var callExpressionFunctionCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.CallExpressionFunctionNode); + var expressionArguments = callExpressionNode.arguments; + callExpressionFunctionCustomNode.initialize(expressionArguments); + var storageKey = this.insertCustomNodeToControlFlowStorage(callExpressionFunctionCustomNode, controlFlowStorage, replacerId, CallExpressionControlFlowReplacer_1.usingExistingIdentifierChance); + return this.getControlFlowStorageCallNode(controlFlowStorage.getStorageId(), storageKey, callee, expressionArguments); + } + }, { + key: "getControlFlowStorageCallNode", + value: function getControlFlowStorageCallNode(controlFlowStorageId, storageKey, callee, expressionArguments) { + var controlFlowStorageCallCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode); + controlFlowStorageCallCustomNode.initialize(controlFlowStorageId, storageKey, callee, expressionArguments); + var statementNode = controlFlowStorageCallCustomNode.getNode()[0]; + if (!statementNode || !NodeGuards_1.NodeGuards.isExpressionStatementNode(statementNode)) { + throw new Error("`controlFlowStorageCallCustomNode.getNode()[0]` should returns array with `ExpressionStatement` node"); + } + return statementNode.expression; + } + }]); + + return CallExpressionControlFlowReplacer; +}(AbstractControlFlowReplacer_1.AbstractControlFlowReplacer); +CallExpressionControlFlowReplacer.usingExistingIdentifierChance = 0.5; +CallExpressionControlFlowReplacer = CallExpressionControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CallExpressionControlFlowReplacer); +exports.CallExpressionControlFlowReplacer = CallExpressionControlFlowReplacer; +var CallExpressionControlFlowReplacer_1; + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var NodeTransformer_1 = __webpack_require__(18); +var NodeType_1 = __webpack_require__(10); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var DeadCodeInjectionTransformer = DeadCodeInjectionTransformer_1 = function (_AbstractNodeTransfor) { + _inherits(DeadCodeInjectionTransformer, _AbstractNodeTransfor); + + function DeadCodeInjectionTransformer(transformersRunner, randomGenerator, options) { + _classCallCheck(this, DeadCodeInjectionTransformer); + + var _this = _possibleConstructorReturn(this, (DeadCodeInjectionTransformer.__proto__ || Object.getPrototypeOf(DeadCodeInjectionTransformer)).call(this, randomGenerator, options)); + + _this.collectedBlockStatements = []; + _this.transformersRunner = transformersRunner; + return _this; + } + + _createClass(DeadCodeInjectionTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isProgramNode(node)) { + _this2.analyzeNode(node, parentNode); + return node; + } + }, + leave: function leave(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isBlockStatementNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "analyzeNode", + value: function analyzeNode(programNode, parentNode) { + var _this3 = this; + + estraverse.traverse(programNode, { + enter: function enter(node) { + if (NodeGuards_1.NodeGuards.isBlockStatementNode(node)) { + _this3.collectBlockStatementNodes(node, _this3.collectedBlockStatements); + } + } + }); + this.collectedBlockStatementsLength = this.collectedBlockStatements.length; + } + }, { + key: "transformNode", + value: function transformNode(blockStatementNode, parentNode) { + if (this.collectedBlockStatementsLength < DeadCodeInjectionTransformer_1.minCollectedBlockStatementsCount) { + return estraverse.VisitorOption.Break; + } + if (!this.collectedBlockStatements.length) { + return estraverse.VisitorOption.Break; + } + if (this.randomGenerator.getMathRandom() > this.options.deadCodeInjectionThreshold) { + return blockStatementNode; + } + var blockScopeOfBlockStatementNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(blockStatementNode)[0]; + if (blockScopeOfBlockStatementNode.type === NodeType_1.NodeType.Program) { + return blockStatementNode; + } + var minInteger = 0; + var maxInteger = this.collectedBlockStatements.length - 1; + var randomIndex = this.randomGenerator.getRandomInteger(minInteger, maxInteger); + var randomBlockStatementNode = this.collectedBlockStatements.splice(randomIndex, 1)[0]; + if (randomBlockStatementNode === blockStatementNode) { + return blockStatementNode; + } + return this.replaceBlockStatementNode(blockStatementNode, randomBlockStatementNode); + } + }, { + key: "collectBlockStatementNodes", + value: function collectBlockStatementNodes(blockStatementNode, collectedBlockStatements) { + var clonedBlockStatementNode = NodeUtils_1.NodeUtils.clone(blockStatementNode), + nestedBlockStatementsCount = 0, + isValidBlockStatementNode = true; + estraverse.replace(clonedBlockStatementNode, { + enter: function enter(node, parentNode) { + if (NodeGuards_1.NodeGuards.isBlockStatementNode(node)) { + nestedBlockStatementsCount++; + } + if (nestedBlockStatementsCount > DeadCodeInjectionTransformer_1.maxNestedBlockStatementsCount || NodeGuards_1.NodeGuards.isBreakStatementNode(node) || NodeGuards_1.NodeGuards.isContinueStatementNode(node) || NodeGuards_1.NodeGuards.isAwaitExpressionNode(node)) { + isValidBlockStatementNode = false; + return estraverse.VisitorOption.Break; + } + return node; + } + }); + if (!isValidBlockStatementNode) { + return; + } + clonedBlockStatementNode = this.transformersRunner.transform(clonedBlockStatementNode, DeadCodeInjectionTransformer_1.transformersToRenameBlockScopeIdentifiers); + collectedBlockStatements.push(clonedBlockStatementNode); + } + }, { + key: "replaceBlockStatementNode", + value: function replaceBlockStatementNode(blockStatementNode, randomBlockStatementNode) { + var random1 = this.randomGenerator.getMathRandom() > 0.5; + var random2 = this.randomGenerator.getMathRandom() > 0.5; + var operator = random1 ? '===' : '!=='; + var leftString = this.randomGenerator.getRandomString(3); + var rightString = random2 ? leftString : this.randomGenerator.getRandomString(3); + + var _ref = random1 === random2 ? [blockStatementNode, randomBlockStatementNode] : [randomBlockStatementNode, blockStatementNode], + _ref2 = _slicedToArray(_ref, 2), + consequent = _ref2[0], + alternate = _ref2[1]; + + var newBlockStatementNode = Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getIfStatementNode(Nodes_1.Nodes.getBinaryExpressionNode(operator, Nodes_1.Nodes.getLiteralNode(leftString), Nodes_1.Nodes.getLiteralNode(rightString)), consequent, alternate)]); + newBlockStatementNode = NodeUtils_1.NodeUtils.parentize(newBlockStatementNode); + return newBlockStatementNode; + } + }]); + + return DeadCodeInjectionTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +DeadCodeInjectionTransformer.maxNestedBlockStatementsCount = 4; +DeadCodeInjectionTransformer.minCollectedBlockStatementsCount = 5; +DeadCodeInjectionTransformer.transformersToRenameBlockScopeIdentifiers = [NodeTransformer_1.NodeTransformer.CatchClauseTransformer, NodeTransformer_1.NodeTransformer.ClassDeclarationTransformer, NodeTransformer_1.NodeTransformer.FunctionDeclarationTransformer, NodeTransformer_1.NodeTransformer.FunctionTransformer, NodeTransformer_1.NodeTransformer.LabeledStatementTransformer, NodeTransformer_1.NodeTransformer.VariableDeclarationTransformer]; +DeadCodeInjectionTransformer = DeadCodeInjectionTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ITransformersRunner)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object, Object])], DeadCodeInjectionTransformer); +exports.DeadCodeInjectionTransformer = DeadCodeInjectionTransformer; +var DeadCodeInjectionTransformer_1; + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var ControlFlowCustomNode_1 = __webpack_require__(12); +var ControlFlowReplacer_1 = __webpack_require__(36); +var NodeType_1 = __webpack_require__(10); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var NodeAppender_1 = __webpack_require__(19); +var NodeUtils_1 = __webpack_require__(4); +var FunctionControlFlowTransformer = FunctionControlFlowTransformer_1 = function (_AbstractNodeTransfor) { + _inherits(FunctionControlFlowTransformer, _AbstractNodeTransfor); + + function FunctionControlFlowTransformer(controlFlowStorageFactory, controlFlowReplacerFactory, controlFlowCustomNodeFactory, randomGenerator, options) { + _classCallCheck(this, FunctionControlFlowTransformer); + + var _this = _possibleConstructorReturn(this, (FunctionControlFlowTransformer.__proto__ || Object.getPrototypeOf(FunctionControlFlowTransformer)).call(this, randomGenerator, options)); + + _this.controlFlowData = new Map(); + _this.visitedFunctionNodes = new Set(); + _this.hostNodesWithControlFlowNode = new Set(); + _this.controlFlowStorageFactory = controlFlowStorageFactory; + _this.controlFlowReplacerFactory = controlFlowReplacerFactory; + _this.controlFlowCustomNodeFactory = controlFlowCustomNodeFactory; + return _this; + } + + _createClass(FunctionControlFlowTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + leave: function leave(node, parentNode) { + if (parentNode && (NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node) || NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) || NodeGuards_1.NodeGuards.isArrowFunctionExpressionNode(node))) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(functionNode, parentNode) { + this.visitedFunctionNodes.add(functionNode); + if (!NodeGuards_1.NodeGuards.isBlockStatementNode(functionNode.body)) { + return functionNode; + } + var hostNode = this.getHostNode(functionNode.body); + var controlFlowStorage = this.getControlFlowStorage(hostNode); + this.controlFlowData.set(hostNode, controlFlowStorage); + this.transformFunctionBody(functionNode.body, controlFlowStorage); + if (!controlFlowStorage.getLength()) { + return functionNode; + } + var controlFlowStorageCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.ControlFlowStorageNode); + controlFlowStorageCustomNode.initialize(controlFlowStorage); + NodeAppender_1.NodeAppender.prependNode(hostNode, controlFlowStorageCustomNode.getNode()); + this.hostNodesWithControlFlowNode.add(hostNode); + return functionNode; + } + }, { + key: "getControlFlowStorage", + value: function getControlFlowStorage(hostNode) { + var controlFlowStorage = this.controlFlowStorageFactory(); + if (this.controlFlowData.has(hostNode)) { + if (this.hostNodesWithControlFlowNode.has(hostNode)) { + hostNode.body.shift(); + } + var hostControlFlowStorage = this.controlFlowData.get(hostNode); + controlFlowStorage.mergeWith(hostControlFlowStorage, true); + } + return controlFlowStorage; + } + }, { + key: "getHostNode", + value: function getHostNode(functionNodeBody) { + var blockScopesOfNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(functionNodeBody); + if (blockScopesOfNode.length === 1) { + return functionNodeBody; + } else { + blockScopesOfNode.pop(); + } + if (blockScopesOfNode.length > FunctionControlFlowTransformer_1.hostNodeSearchMinDepth) { + blockScopesOfNode.splice(0, FunctionControlFlowTransformer_1.hostNodeSearchMinDepth); + } + if (blockScopesOfNode.length > FunctionControlFlowTransformer_1.hostNodeSearchMaxDepth) { + blockScopesOfNode.length = FunctionControlFlowTransformer_1.hostNodeSearchMaxDepth; + } + return this.randomGenerator.getRandomGenerator().pickone(blockScopesOfNode); + } + }, { + key: "isVisitedFunctionNode", + value: function isVisitedFunctionNode(node) { + return (NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node) || NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) || NodeGuards_1.NodeGuards.isArrowFunctionExpressionNode(node)) && this.visitedFunctionNodes.has(node); + } + }, { + key: "transformFunctionBody", + value: function transformFunctionBody(functionNodeBody, controlFlowStorage) { + var _this3 = this; + + estraverse.replace(functionNodeBody, { + enter: function enter(node, parentNode) { + if (_this3.isVisitedFunctionNode(node) || !parentNode) { + return estraverse.VisitorOption.Skip; + } + if (!FunctionControlFlowTransformer_1.controlFlowReplacersMap.has(node.type)) { + return node; + } + if (_this3.randomGenerator.getMathRandom() > _this3.options.controlFlowFlatteningThreshold) { + return node; + } + var controlFlowReplacerName = FunctionControlFlowTransformer_1.controlFlowReplacersMap.get(node.type); + if (controlFlowReplacerName === undefined) { + return node; + } + return Object.assign({}, _this3.controlFlowReplacerFactory(controlFlowReplacerName).replace(node, parentNode, controlFlowStorage), { parentNode: parentNode }); + } + }); + } + }]); + + return FunctionControlFlowTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +FunctionControlFlowTransformer.controlFlowReplacersMap = new Map([[NodeType_1.NodeType.BinaryExpression, ControlFlowReplacer_1.ControlFlowReplacer.BinaryExpressionControlFlowReplacer], [NodeType_1.NodeType.CallExpression, ControlFlowReplacer_1.ControlFlowReplacer.CallExpressionControlFlowReplacer], [NodeType_1.NodeType.LogicalExpression, ControlFlowReplacer_1.ControlFlowReplacer.LogicalExpressionControlFlowReplacer], [NodeType_1.NodeType.Literal, ControlFlowReplacer_1.ControlFlowReplacer.StringLiteralControlFlowReplacer]]); +FunctionControlFlowTransformer.hostNodeSearchMinDepth = 0; +FunctionControlFlowTransformer.hostNodeSearchMaxDepth = 2; +FunctionControlFlowTransformer = FunctionControlFlowTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__TControlFlowStorage)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowReplacer)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Function, Object, Object])], FunctionControlFlowTransformer); +exports.FunctionControlFlowTransformer = FunctionControlFlowTransformer; +var FunctionControlFlowTransformer_1; + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ControlFlowCustomNode_1 = __webpack_require__(12); +var ExpressionWithOperatorControlFlowReplacer_1 = __webpack_require__(37); +var NodeGuards_1 = __webpack_require__(5); +var NodeUtils_1 = __webpack_require__(4); +var LogicalExpressionControlFlowReplacer = LogicalExpressionControlFlowReplacer_1 = function (_ExpressionWithOperat) { + _inherits(LogicalExpressionControlFlowReplacer, _ExpressionWithOperat); + + function LogicalExpressionControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) { + _classCallCheck(this, LogicalExpressionControlFlowReplacer); + + return _possibleConstructorReturn(this, (LogicalExpressionControlFlowReplacer.__proto__ || Object.getPrototypeOf(LogicalExpressionControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options)); + } + + _createClass(LogicalExpressionControlFlowReplacer, [{ + key: "replace", + value: function replace(logicalExpressionNode, parentNode, controlFlowStorage) { + if (this.checkForProhibitedExpressions(logicalExpressionNode.left, logicalExpressionNode.right)) { + return logicalExpressionNode; + } + var replacerId = logicalExpressionNode.operator; + var logicalExpressionFunctionCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.LogicalExpressionFunctionNode); + logicalExpressionFunctionCustomNode.initialize(replacerId); + var storageKey = this.insertCustomNodeToControlFlowStorage(logicalExpressionFunctionCustomNode, controlFlowStorage, replacerId, LogicalExpressionControlFlowReplacer_1.usingExistingIdentifierChance); + return this.getControlFlowStorageCallNode(controlFlowStorage.getStorageId(), storageKey, logicalExpressionNode.left, logicalExpressionNode.right); + } + }, { + key: "checkForProhibitedExpressions", + value: function checkForProhibitedExpressions(leftExpression, rightExpression) { + return [leftExpression, rightExpression].some(function (expressionNode) { + var nodeForCheck = void 0; + if (!NodeGuards_1.NodeGuards.isUnaryExpressionNode(expressionNode)) { + nodeForCheck = expressionNode; + } else { + nodeForCheck = NodeUtils_1.NodeUtils.getUnaryExpressionArgumentNode(expressionNode); + } + return !NodeGuards_1.NodeGuards.isLiteralNode(nodeForCheck) && !NodeGuards_1.NodeGuards.isIdentifierNode(nodeForCheck) && !NodeGuards_1.NodeGuards.isObjectExpressionNode(nodeForCheck) && !NodeGuards_1.NodeGuards.isExpressionStatementNode(nodeForCheck); + }); + } + }]); + + return LogicalExpressionControlFlowReplacer; +}(ExpressionWithOperatorControlFlowReplacer_1.ExpressionWithOperatorControlFlowReplacer); +LogicalExpressionControlFlowReplacer.usingExistingIdentifierChance = 0.5; +LogicalExpressionControlFlowReplacer = LogicalExpressionControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], LogicalExpressionControlFlowReplacer); +exports.LogicalExpressionControlFlowReplacer = LogicalExpressionControlFlowReplacer; +var LogicalExpressionControlFlowReplacer_1; + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ControlFlowCustomNode_1 = __webpack_require__(12); +var AbstractControlFlowReplacer_1 = __webpack_require__(29); +var NodeGuards_1 = __webpack_require__(5); +var StringLiteralControlFlowReplacer = StringLiteralControlFlowReplacer_1 = function (_AbstractControlFlowR) { + _inherits(StringLiteralControlFlowReplacer, _AbstractControlFlowR); + + function StringLiteralControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) { + _classCallCheck(this, StringLiteralControlFlowReplacer); + + return _possibleConstructorReturn(this, (StringLiteralControlFlowReplacer.__proto__ || Object.getPrototypeOf(StringLiteralControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options)); + } + + _createClass(StringLiteralControlFlowReplacer, [{ + key: "replace", + value: function replace(literalNode, parentNode, controlFlowStorage) { + if (NodeGuards_1.NodeGuards.isPropertyNode(parentNode) && parentNode.key === literalNode) { + return literalNode; + } + if (typeof literalNode.value !== 'string' || literalNode.value.length < 3) { + return literalNode; + } + var replacerId = String(literalNode.value); + var literalFunctionCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.StringLiteralNode); + literalFunctionCustomNode.initialize(literalNode.value); + var storageKey = this.insertCustomNodeToControlFlowStorage(literalFunctionCustomNode, controlFlowStorage, replacerId, StringLiteralControlFlowReplacer_1.usingExistingIdentifierChance); + return this.getControlFlowStorageCallNode(controlFlowStorage.getStorageId(), storageKey); + } + }, { + key: "getControlFlowStorageCallNode", + value: function getControlFlowStorageCallNode(controlFlowStorageId, storageKey) { + var controlFlowStorageCallCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode); + controlFlowStorageCallCustomNode.initialize(controlFlowStorageId, storageKey); + var statementNode = controlFlowStorageCallCustomNode.getNode()[0]; + if (!statementNode || !NodeGuards_1.NodeGuards.isExpressionStatementNode(statementNode)) { + throw new Error("`controlFlowStorageCallCustomNode.getNode()[0]` should returns array with `ExpressionStatement` node"); + } + return statementNode.expression; + } + }]); + + return StringLiteralControlFlowReplacer; +}(AbstractControlFlowReplacer_1.AbstractControlFlowReplacer); +StringLiteralControlFlowReplacer.usingExistingIdentifierChance = 1; +StringLiteralControlFlowReplacer = StringLiteralControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], StringLiteralControlFlowReplacer); +exports.StringLiteralControlFlowReplacer = StringLiteralControlFlowReplacer; +var StringLiteralControlFlowReplacer_1; + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var NodeTransformer_1 = __webpack_require__(18); +var MemberExpressionTransformer_1 = __webpack_require__(61); +var MethodDefinitionTransformer_1 = __webpack_require__(62); +var TemplateLiteralTransformer_1 = __webpack_require__(63); +exports.convertingTransformersModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(MemberExpressionTransformer_1.MemberExpressionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.MemberExpressionTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(MethodDefinitionTransformer_1.MethodDefinitionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.MethodDefinitionTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(TemplateLiteralTransformer_1.TemplateLiteralTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.TemplateLiteralTransformer); +}); + +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var NodeType_1 = __webpack_require__(10); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var MemberExpressionTransformer = function (_AbstractNodeTransfor) { + _inherits(MemberExpressionTransformer, _AbstractNodeTransfor); + + function MemberExpressionTransformer(randomGenerator, options) { + _classCallCheck(this, MemberExpressionTransformer); + + return _possibleConstructorReturn(this, (MemberExpressionTransformer.__proto__ || Object.getPrototypeOf(MemberExpressionTransformer)).call(this, randomGenerator, options)); + } + + _createClass(MemberExpressionTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isMemberExpressionNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(memberExpressionNode, parentNode) { + if (NodeGuards_1.NodeGuards.isIdentifierNode(memberExpressionNode.property)) { + if (memberExpressionNode.computed) { + return memberExpressionNode; + } + memberExpressionNode.computed = true; + memberExpressionNode.property = { + type: NodeType_1.NodeType.Literal, + value: memberExpressionNode.property.name, + raw: "'" + memberExpressionNode.property.name + "'" + }; + } + return memberExpressionNode; + } + }]); + + return MemberExpressionTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +MemberExpressionTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], MemberExpressionTransformer); +exports.MemberExpressionTransformer = MemberExpressionTransformer; + +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var NodeType_1 = __webpack_require__(10); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var MethodDefinitionTransformer = MethodDefinitionTransformer_1 = function (_AbstractNodeTransfor) { + _inherits(MethodDefinitionTransformer, _AbstractNodeTransfor); + + function MethodDefinitionTransformer(randomGenerator, options) { + _classCallCheck(this, MethodDefinitionTransformer); + + return _possibleConstructorReturn(this, (MethodDefinitionTransformer.__proto__ || Object.getPrototypeOf(MethodDefinitionTransformer)).call(this, randomGenerator, options)); + } + + _createClass(MethodDefinitionTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isMethodDefinitionNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(methodDefinitionNode, parentNode) { + if (NodeGuards_1.NodeGuards.isIdentifierNode(methodDefinitionNode.key) && !(MethodDefinitionTransformer_1.ignoredNames.indexOf(methodDefinitionNode.key.name) !== -1) && methodDefinitionNode.computed === false) { + methodDefinitionNode.computed = true; + methodDefinitionNode.key = { + type: NodeType_1.NodeType.Literal, + value: methodDefinitionNode.key.name, + raw: "'" + methodDefinitionNode.key.name + "'" + }; + } + return methodDefinitionNode; + } + }]); + + return MethodDefinitionTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +MethodDefinitionTransformer.ignoredNames = ['constructor']; +MethodDefinitionTransformer = MethodDefinitionTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], MethodDefinitionTransformer); +exports.MethodDefinitionTransformer = MethodDefinitionTransformer; +var MethodDefinitionTransformer_1; + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var Nodes_1 = __webpack_require__(9); +var TemplateLiteralTransformer = TemplateLiteralTransformer_1 = function (_AbstractNodeTransfor) { + _inherits(TemplateLiteralTransformer, _AbstractNodeTransfor); + + function TemplateLiteralTransformer(randomGenerator, options) { + _classCallCheck(this, TemplateLiteralTransformer); + + return _possibleConstructorReturn(this, (TemplateLiteralTransformer.__proto__ || Object.getPrototypeOf(TemplateLiteralTransformer)).call(this, randomGenerator, options)); + } + + _createClass(TemplateLiteralTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isTemplateLiteralNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(templateLiteralNode, parentNode) { + var templateLiteralExpressions = templateLiteralNode.expressions; + var nodes = []; + templateLiteralNode.quasis.forEach(function (templateElement) { + nodes.push(Nodes_1.Nodes.getLiteralNode(templateElement.value.cooked)); + var expression = templateLiteralExpressions.shift(); + if (!expression) { + return; + } + nodes.push(expression); + }); + nodes = nodes.filter(function (node) { + return !(NodeGuards_1.NodeGuards.isLiteralNode(node) && node.value === ''); + }); + if (!TemplateLiteralTransformer_1.isLiteralNodeWithStringValue(nodes[0]) && !TemplateLiteralTransformer_1.isLiteralNodeWithStringValue(nodes[1])) { + nodes.unshift(Nodes_1.Nodes.getLiteralNode('')); + } + if (nodes.length > 1) { + var root = Nodes_1.Nodes.getBinaryExpressionNode('+', nodes.shift(), nodes.shift()); + nodes.forEach(function (node) { + root = Nodes_1.Nodes.getBinaryExpressionNode('+', root, node); + }); + return root; + } + return nodes[0]; + } + }], [{ + key: "isLiteralNodeWithStringValue", + value: function isLiteralNodeWithStringValue(node) { + return node && NodeGuards_1.NodeGuards.isLiteralNode(node) && typeof node.value === 'string'; + } + }]); + + return TemplateLiteralTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +TemplateLiteralTransformer = TemplateLiteralTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], TemplateLiteralTransformer); +exports.TemplateLiteralTransformer = TemplateLiteralTransformer; +var TemplateLiteralTransformer_1; + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var InversifyContainerFacade_1 = __webpack_require__(14); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ControlFlowCustomNode_1 = __webpack_require__(12); +var CustomNode_1 = __webpack_require__(20); +var CustomNodeGroup_1 = __webpack_require__(38); +var ConsoleOutputCustomNodeGroup_1 = __webpack_require__(65); +var DebugProtectionCustomNodeGroup_1 = __webpack_require__(66); +var DomainLockCustomNodeGroup_1 = __webpack_require__(67); +var SelfDefendingCustomNodeGroup_1 = __webpack_require__(68); +var StringArrayCustomNodeGroup_1 = __webpack_require__(69); +var BinaryExpressionFunctionNode_1 = __webpack_require__(70); +var BlockStatementControlFlowFlatteningNode_1 = __webpack_require__(73); +var CallExpressionControlFlowStorageCallNode_1 = __webpack_require__(74); +var CallExpressionFunctionNode_1 = __webpack_require__(75); +var ControlFlowStorageNode_1 = __webpack_require__(76); +var ConsoleOutputDisableExpressionNode_1 = __webpack_require__(77); +var DebugProtectionFunctionCallNode_1 = __webpack_require__(79); +var DebugProtectionFunctionIntervalNode_1 = __webpack_require__(81); +var DebugProtectionFunctionNode_1 = __webpack_require__(83); +var DomainLockNode_1 = __webpack_require__(87); +var ExpressionWithOperatorControlFlowStorageCallNode_1 = __webpack_require__(89); +var LogicalExpressionFunctionNode_1 = __webpack_require__(90); +var NodeCallsControllerFunctionNode_1 = __webpack_require__(91); +var SelfDefendingUnicodeNode_1 = __webpack_require__(93); +var StringArrayCallsWrapper_1 = __webpack_require__(95); +var StringArrayNode_1 = __webpack_require__(102); +var StringArrayRotateFunctionNode_1 = __webpack_require__(104); +var StringLiteralControlFlowStorageCallNode_1 = __webpack_require__(108); +var StringLiteralNode_1 = __webpack_require__(109); +exports.customNodesModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(ConsoleOutputDisableExpressionNode_1.ConsoleOutputDisableExpressionNode).whenTargetNamed(CustomNode_1.CustomNode.ConsoleOutputDisableExpressionNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(DebugProtectionFunctionCallNode_1.DebugProtectionFunctionCallNode).whenTargetNamed(CustomNode_1.CustomNode.DebugProtectionFunctionCallNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode).whenTargetNamed(CustomNode_1.CustomNode.DebugProtectionFunctionIntervalNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(DebugProtectionFunctionNode_1.DebugProtectionFunctionNode).whenTargetNamed(CustomNode_1.CustomNode.DebugProtectionFunctionNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(DomainLockNode_1.DomainLockNode).whenTargetNamed(CustomNode_1.CustomNode.DomainLockNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode).whenTargetNamed(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(SelfDefendingUnicodeNode_1.SelfDefendingUnicodeNode).whenTargetNamed(CustomNode_1.CustomNode.SelfDefendingUnicodeNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(StringArrayCallsWrapper_1.StringArrayCallsWrapper).whenTargetNamed(CustomNode_1.CustomNode.StringArrayCallsWrapper); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(StringArrayNode_1.StringArrayNode).whenTargetNamed(CustomNode_1.CustomNode.StringArrayNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(StringArrayRotateFunctionNode_1.StringArrayRotateFunctionNode).whenTargetNamed(CustomNode_1.CustomNode.StringArrayRotateFunctionNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(BinaryExpressionFunctionNode_1.BinaryExpressionFunctionNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.BinaryExpressionFunctionNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(BlockStatementControlFlowFlatteningNode_1.BlockStatementControlFlowFlatteningNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(CallExpressionControlFlowStorageCallNode_1.CallExpressionControlFlowStorageCallNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(CallExpressionFunctionNode_1.CallExpressionFunctionNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.CallExpressionFunctionNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(ControlFlowStorageNode_1.ControlFlowStorageNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.ControlFlowStorageNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(ExpressionWithOperatorControlFlowStorageCallNode_1.ExpressionWithOperatorControlFlowStorageCallNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(LogicalExpressionFunctionNode_1.LogicalExpressionFunctionNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.LogicalExpressionFunctionNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(StringLiteralNode_1.StringLiteralNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.StringLiteralNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(StringLiteralControlFlowStorageCallNode_1.StringLiteralControlFlowStorageCallNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(ConsoleOutputCustomNodeGroup_1.ConsoleOutputCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.ConsoleOutputCustomNodeGroup); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(DebugProtectionCustomNodeGroup_1.DebugProtectionCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.DebugProtectionCustomNodeGroup); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(DomainLockCustomNodeGroup_1.DomainLockCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.DomainLockCustomNodeGroup); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(SelfDefendingCustomNodeGroup_1.SelfDefendingCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.SelfDefendingCustomNodeGroup); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(StringArrayCustomNodeGroup_1.StringArrayCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.StringArrayCustomNodeGroup); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getFactory(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode)); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getConstructorFactory(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode, ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator, ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator, ServiceIdentifiers_1.ServiceIdentifiers.IOptions)); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNodeGroup).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getFactory(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup)); +}); + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var CustomNode_1 = __webpack_require__(20); +var ObfuscationEvent_1 = __webpack_require__(15); +var AbstractCustomNodeGroup_1 = __webpack_require__(22); +var NodeAppender_1 = __webpack_require__(19); +var ConsoleOutputCustomNodeGroup = function (_AbstractCustomNodeGr) { + _inherits(ConsoleOutputCustomNodeGroup, _AbstractCustomNodeGr); + + function ConsoleOutputCustomNodeGroup(customNodeFactory, identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, ConsoleOutputCustomNodeGroup); + + var _this = _possibleConstructorReturn(this, (ConsoleOutputCustomNodeGroup.__proto__ || Object.getPrototypeOf(ConsoleOutputCustomNodeGroup)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.BeforeObfuscation; + _this.customNodeFactory = customNodeFactory; + return _this; + } + + _createClass(ConsoleOutputCustomNodeGroup, [{ + key: "appendCustomNodes", + value: function appendCustomNodes(blockScopeNode, stackTraceData) { + var randomStackTraceIndex = this.getRandomStackTraceIndex(stackTraceData.length); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.ConsoleOutputDisableExpressionNode, function (customNode) { + NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, blockScopeNode, customNode.getNode(), randomStackTraceIndex); + }); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, function (customNode) { + var targetBlockScope = void 0; + if (stackTraceData.length) { + targetBlockScope = NodeAppender_1.NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1); + } else { + targetBlockScope = blockScopeNode; + } + NodeAppender_1.NodeAppender.prependNode(targetBlockScope, customNode.getNode()); + }); + } + }, { + key: "initialize", + value: function initialize() { + this.customNodes = new Map(); + if (!this.options.disableConsoleOutput) { + return; + } + var callsControllerFunctionName = this.identifierNameGenerator.generate(6); + var consoleOutputDisableExpressionNode = this.customNodeFactory(CustomNode_1.CustomNode.ConsoleOutputDisableExpressionNode); + var nodeCallsControllerFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode); + consoleOutputDisableExpressionNode.initialize(callsControllerFunctionName); + nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName); + this.customNodes.set(CustomNode_1.CustomNode.ConsoleOutputDisableExpressionNode, consoleOutputDisableExpressionNode); + this.customNodes.set(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode); + } + }]); + + return ConsoleOutputCustomNodeGroup; +}(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], ConsoleOutputCustomNodeGroup.prototype, "customNodes", void 0); +ConsoleOutputCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Object, Object])], ConsoleOutputCustomNodeGroup); +exports.ConsoleOutputCustomNodeGroup = ConsoleOutputCustomNodeGroup; + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var CustomNode_1 = __webpack_require__(20); +var ObfuscationEvent_1 = __webpack_require__(15); +var AbstractCustomNodeGroup_1 = __webpack_require__(22); +var NodeAppender_1 = __webpack_require__(19); +var DebugProtectionCustomNodeGroup = function (_AbstractCustomNodeGr) { + _inherits(DebugProtectionCustomNodeGroup, _AbstractCustomNodeGr); + + function DebugProtectionCustomNodeGroup(customNodeFactory, identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, DebugProtectionCustomNodeGroup); + + var _this = _possibleConstructorReturn(this, (DebugProtectionCustomNodeGroup.__proto__ || Object.getPrototypeOf(DebugProtectionCustomNodeGroup)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.BeforeObfuscation; + _this.customNodeFactory = customNodeFactory; + return _this; + } + + _createClass(DebugProtectionCustomNodeGroup, [{ + key: "appendCustomNodes", + value: function appendCustomNodes(blockScopeNode, stackTraceData) { + var _this2 = this; + + var randomStackTraceIndex = this.getRandomStackTraceIndex(stackTraceData.length); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.DebugProtectionFunctionCallNode, function (customNode) { + NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, blockScopeNode, customNode.getNode(), randomStackTraceIndex); + }); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.DebugProtectionFunctionNode, function (customNode) { + NodeAppender_1.NodeAppender.appendNode(blockScopeNode, customNode.getNode()); + }); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.DebugProtectionFunctionIntervalNode, function (customNode) { + var programBodyLength = blockScopeNode.body.length; + var randomIndex = _this2.randomGenerator.getRandomInteger(0, programBodyLength); + NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), randomIndex); + }); + } + }, { + key: "initialize", + value: function initialize() { + this.customNodes = new Map(); + if (!this.options.debugProtection) { + return; + } + var debugProtectionFunctionName = this.identifierNameGenerator.generate(6); + var debugProtectionFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.DebugProtectionFunctionNode); + var debugProtectionFunctionCallNode = this.customNodeFactory(CustomNode_1.CustomNode.DebugProtectionFunctionCallNode); + var debugProtectionFunctionIntervalNode = this.customNodeFactory(CustomNode_1.CustomNode.DebugProtectionFunctionIntervalNode); + debugProtectionFunctionNode.initialize(debugProtectionFunctionName); + debugProtectionFunctionCallNode.initialize(debugProtectionFunctionName); + debugProtectionFunctionIntervalNode.initialize(debugProtectionFunctionName); + this.customNodes.set(CustomNode_1.CustomNode.DebugProtectionFunctionNode, debugProtectionFunctionNode); + this.customNodes.set(CustomNode_1.CustomNode.DebugProtectionFunctionCallNode, debugProtectionFunctionCallNode); + if (this.options.debugProtectionInterval) { + this.customNodes.set(CustomNode_1.CustomNode.DebugProtectionFunctionIntervalNode, debugProtectionFunctionIntervalNode); + } + } + }]); + + return DebugProtectionCustomNodeGroup; +}(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], DebugProtectionCustomNodeGroup.prototype, "customNodes", void 0); +DebugProtectionCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Object, Object])], DebugProtectionCustomNodeGroup); +exports.DebugProtectionCustomNodeGroup = DebugProtectionCustomNodeGroup; + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var CustomNode_1 = __webpack_require__(20); +var ObfuscationEvent_1 = __webpack_require__(15); +var AbstractCustomNodeGroup_1 = __webpack_require__(22); +var NodeAppender_1 = __webpack_require__(19); +var DomainLockCustomNodeGroup = function (_AbstractCustomNodeGr) { + _inherits(DomainLockCustomNodeGroup, _AbstractCustomNodeGr); + + function DomainLockCustomNodeGroup(customNodeFactory, identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, DomainLockCustomNodeGroup); + + var _this = _possibleConstructorReturn(this, (DomainLockCustomNodeGroup.__proto__ || Object.getPrototypeOf(DomainLockCustomNodeGroup)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.BeforeObfuscation; + _this.customNodeFactory = customNodeFactory; + return _this; + } + + _createClass(DomainLockCustomNodeGroup, [{ + key: "appendCustomNodes", + value: function appendCustomNodes(blockScopeNode, stackTraceData) { + var randomStackTraceIndex = this.getRandomStackTraceIndex(stackTraceData.length); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.DomainLockNode, function (customNode) { + NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, blockScopeNode, customNode.getNode(), randomStackTraceIndex); + }); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, function (customNode) { + var targetBlockScope = void 0; + if (stackTraceData.length) { + targetBlockScope = NodeAppender_1.NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1); + } else { + targetBlockScope = blockScopeNode; + } + NodeAppender_1.NodeAppender.prependNode(targetBlockScope, customNode.getNode()); + }); + } + }, { + key: "initialize", + value: function initialize() { + this.customNodes = new Map(); + if (!this.options.domainLock.length) { + return; + } + var callsControllerFunctionName = this.identifierNameGenerator.generate(6); + var domainLockNode = this.customNodeFactory(CustomNode_1.CustomNode.DomainLockNode); + var nodeCallsControllerFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode); + domainLockNode.initialize(callsControllerFunctionName); + nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName); + this.customNodes.set(CustomNode_1.CustomNode.DomainLockNode, domainLockNode); + this.customNodes.set(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode); + } + }]); + + return DomainLockCustomNodeGroup; +}(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], DomainLockCustomNodeGroup.prototype, "customNodes", void 0); +DomainLockCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Object, Object])], DomainLockCustomNodeGroup); +exports.DomainLockCustomNodeGroup = DomainLockCustomNodeGroup; + +/***/ }), +/* 68 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var CustomNode_1 = __webpack_require__(20); +var ObfuscationEvent_1 = __webpack_require__(15); +var AbstractCustomNodeGroup_1 = __webpack_require__(22); +var NodeAppender_1 = __webpack_require__(19); +var SelfDefendingCustomNodeGroup = function (_AbstractCustomNodeGr) { + _inherits(SelfDefendingCustomNodeGroup, _AbstractCustomNodeGr); + + function SelfDefendingCustomNodeGroup(customNodeFactory, identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, SelfDefendingCustomNodeGroup); + + var _this = _possibleConstructorReturn(this, (SelfDefendingCustomNodeGroup.__proto__ || Object.getPrototypeOf(SelfDefendingCustomNodeGroup)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.AfterObfuscation; + _this.customNodeFactory = customNodeFactory; + return _this; + } + + _createClass(SelfDefendingCustomNodeGroup, [{ + key: "appendCustomNodes", + value: function appendCustomNodes(blockScopeNode, stackTraceData) { + var randomStackTraceIndex = this.getRandomStackTraceIndex(stackTraceData.length); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.SelfDefendingUnicodeNode, function (customNode) { + NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, blockScopeNode, customNode.getNode(), randomStackTraceIndex); + }); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, function (customNode) { + var targetBlockScope = void 0; + if (stackTraceData.length) { + targetBlockScope = NodeAppender_1.NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1); + } else { + targetBlockScope = blockScopeNode; + } + NodeAppender_1.NodeAppender.prependNode(targetBlockScope, customNode.getNode()); + }); + } + }, { + key: "initialize", + value: function initialize() { + this.customNodes = new Map(); + if (!this.options.selfDefending) { + return; + } + var callsControllerFunctionName = this.identifierNameGenerator.generate(6); + var selfDefendingUnicodeNode = this.customNodeFactory(CustomNode_1.CustomNode.SelfDefendingUnicodeNode); + var nodeCallsControllerFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode); + selfDefendingUnicodeNode.initialize(callsControllerFunctionName); + nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName); + this.customNodes.set(CustomNode_1.CustomNode.SelfDefendingUnicodeNode, selfDefendingUnicodeNode); + this.customNodes.set(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode); + } + }]); + + return SelfDefendingCustomNodeGroup; +}(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], SelfDefendingCustomNodeGroup.prototype, "customNodes", void 0); +SelfDefendingCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Object, Object])], SelfDefendingCustomNodeGroup); +exports.SelfDefendingCustomNodeGroup = SelfDefendingCustomNodeGroup; + +/***/ }), +/* 69 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var CustomNode_1 = __webpack_require__(20); +var ObfuscationEvent_1 = __webpack_require__(15); +var AbstractCustomNodeGroup_1 = __webpack_require__(22); +var NodeAppender_1 = __webpack_require__(19); +var StringArrayCustomNodeGroup = function (_AbstractCustomNodeGr) { + _inherits(StringArrayCustomNodeGroup, _AbstractCustomNodeGr); + + function StringArrayCustomNodeGroup(customNodeFactory, stringArrayStorage, identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, StringArrayCustomNodeGroup); + + var _this = _possibleConstructorReturn(this, (StringArrayCustomNodeGroup.__proto__ || Object.getPrototypeOf(StringArrayCustomNodeGroup)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.AfterObfuscation; + _this.customNodeFactory = customNodeFactory; + _this.stringArrayStorage = stringArrayStorage; + return _this; + } + + _createClass(StringArrayCustomNodeGroup, [{ + key: "appendCustomNodes", + value: function appendCustomNodes(blockScopeNode, stackTraceData) { + if (!this.stringArrayStorage.getLength()) { + return; + } + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.StringArrayNode, function (customNode) { + NodeAppender_1.NodeAppender.prependNode(blockScopeNode, customNode.getNode()); + }); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.StringArrayCallsWrapper, function (customNode) { + NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), 1); + }); + this.appendCustomNodeIfExist(CustomNode_1.CustomNode.StringArrayRotateFunctionNode, function (customNode) { + NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), 1); + }); + } + }, { + key: "initialize", + value: function initialize() { + this.customNodes = new Map(); + if (!this.options.stringArray) { + return; + } + var stringArrayNode = this.customNodeFactory(CustomNode_1.CustomNode.StringArrayNode); + var stringArrayCallsWrapper = this.customNodeFactory(CustomNode_1.CustomNode.StringArrayCallsWrapper); + var stringArrayRotateFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.StringArrayRotateFunctionNode); + var stringArrayStorageId = this.stringArrayStorage.getStorageId(); + + var _stringArrayStorageId = stringArrayStorageId.split('|'), + _stringArrayStorageId2 = _slicedToArray(_stringArrayStorageId, 2), + stringArrayName = _stringArrayStorageId2[0], + stringArrayCallsWrapperName = _stringArrayStorageId2[1]; + + var stringArrayRotateValue = void 0; + if (this.options.rotateStringArray) { + stringArrayRotateValue = this.randomGenerator.getRandomInteger(100, 500); + } else { + stringArrayRotateValue = 0; + } + stringArrayNode.initialize(this.stringArrayStorage, stringArrayName, stringArrayRotateValue); + stringArrayCallsWrapper.initialize(stringArrayName, stringArrayCallsWrapperName); + stringArrayRotateFunctionNode.initialize(stringArrayName, stringArrayRotateValue); + this.customNodes.set(CustomNode_1.CustomNode.StringArrayNode, stringArrayNode); + this.customNodes.set(CustomNode_1.CustomNode.StringArrayCallsWrapper, stringArrayCallsWrapper); + if (this.options.rotateStringArray) { + this.customNodes.set(CustomNode_1.CustomNode.StringArrayRotateFunctionNode, stringArrayRotateFunctionNode); + } + } + }]); + + return StringArrayCustomNodeGroup; +}(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], StringArrayCustomNodeGroup.prototype, "customNodes", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], StringArrayCustomNodeGroup.prototype, "stringArrayStorage", void 0); +StringArrayCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.TStringArrayStorage)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Function, Object, Object])], StringArrayCustomNodeGroup); +exports.StringArrayCustomNodeGroup = StringArrayCustomNodeGroup; + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var BinaryExpressionFunctionNode = function (_AbstractCustomNode_) { + _inherits(BinaryExpressionFunctionNode, _AbstractCustomNode_); + + function BinaryExpressionFunctionNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, BinaryExpressionFunctionNode); + + return _possibleConstructorReturn(this, (BinaryExpressionFunctionNode.__proto__ || Object.getPrototypeOf(BinaryExpressionFunctionNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(BinaryExpressionFunctionNode, [{ + key: "initialize", + value: function initialize(operator) { + this.operator = operator; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var structure = Nodes_1.Nodes.getFunctionDeclarationNode(this.randomGenerator.getRandomString(3), [Nodes_1.Nodes.getIdentifierNode('x'), Nodes_1.Nodes.getIdentifierNode('y')], Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getReturnStatementNode(Nodes_1.Nodes.getBinaryExpressionNode(this.operator, Nodes_1.Nodes.getIdentifierNode('x'), Nodes_1.Nodes.getIdentifierNode('y')))])); + NodeUtils_1.NodeUtils.parentize(structure); + return [structure]; + } + }]); + + return BinaryExpressionFunctionNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], BinaryExpressionFunctionNode.prototype, "operator", void 0); +BinaryExpressionFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], BinaryExpressionFunctionNode); +exports.BinaryExpressionFunctionNode = BinaryExpressionFunctionNode; + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function GlobalVariableTemplate1() { + return "\n var that;\n \n try {\n var getGlobal = Function('return (function() ' + '{}.constructor(\"return this\")( )' + ');');\n \n that = getGlobal();\n } catch (e) {\n that = window;\n }\n "; +} +exports.GlobalVariableTemplate1 = GlobalVariableTemplate1; + +/***/ }), +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function GlobalVariableTemplate2() { + return "\n var getGlobal = function () {\n var globalObject;\n \n try {\n globalObject = Function('return (function() ' + '{}.constructor(\"return this\")( )' + ');')();\n } catch (e) {\n globalObject = window;\n }\n \n return globalObject;\n };\n var that = getGlobal();\n "; +} +exports.GlobalVariableTemplate2 = GlobalVariableTemplate2; + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeGuards_1 = __webpack_require__(5); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var BlockStatementControlFlowFlatteningNode = function (_AbstractCustomNode_) { + _inherits(BlockStatementControlFlowFlatteningNode, _AbstractCustomNode_); + + function BlockStatementControlFlowFlatteningNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, BlockStatementControlFlowFlatteningNode); + + return _possibleConstructorReturn(this, (BlockStatementControlFlowFlatteningNode.__proto__ || Object.getPrototypeOf(BlockStatementControlFlowFlatteningNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(BlockStatementControlFlowFlatteningNode, [{ + key: "initialize", + value: function initialize(blockStatementBody, shuffledKeys, originalKeysIndexesInShuffledArray) { + this.blockStatementBody = blockStatementBody; + this.shuffledKeys = shuffledKeys; + this.originalKeysIndexesInShuffledArray = originalKeysIndexesInShuffledArray; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var _this2 = this; + + var controllerIdentifierName = this.randomGenerator.getRandomString(6); + var indexIdentifierName = this.randomGenerator.getRandomString(6); + var structure = Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getVariableDeclarationNode([Nodes_1.Nodes.getVariableDeclaratorNode(Nodes_1.Nodes.getIdentifierNode(controllerIdentifierName), Nodes_1.Nodes.getCallExpressionNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getLiteralNode(this.originalKeysIndexesInShuffledArray.join('|')), Nodes_1.Nodes.getIdentifierNode('split')), [Nodes_1.Nodes.getLiteralNode('|')])), Nodes_1.Nodes.getVariableDeclaratorNode(Nodes_1.Nodes.getIdentifierNode(indexIdentifierName), Nodes_1.Nodes.getLiteralNode(0))]), Nodes_1.Nodes.getWhileStatementNode(Nodes_1.Nodes.getLiteralNode(true), Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getSwitchStatementNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getIdentifierNode(controllerIdentifierName), Nodes_1.Nodes.getUpdateExpressionNode('++', Nodes_1.Nodes.getIdentifierNode(indexIdentifierName)), true), this.shuffledKeys.map(function (key, index) { + var statement = _this2.blockStatementBody[key]; + var consequent = [statement]; + if (!NodeGuards_1.NodeGuards.isReturnStatementNode(statement)) { + consequent.push(Nodes_1.Nodes.getContinueStatement()); + } + return Nodes_1.Nodes.getSwitchCaseNode(Nodes_1.Nodes.getLiteralNode(String(index)), consequent); + })), Nodes_1.Nodes.getBreakStatement()]))]); + NodeUtils_1.NodeUtils.parentize(structure); + return [structure]; + } + }]); + + return BlockStatementControlFlowFlatteningNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], BlockStatementControlFlowFlatteningNode.prototype, "blockStatementBody", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], BlockStatementControlFlowFlatteningNode.prototype, "originalKeysIndexesInShuffledArray", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], BlockStatementControlFlowFlatteningNode.prototype, "shuffledKeys", void 0); +BlockStatementControlFlowFlatteningNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], BlockStatementControlFlowFlatteningNode); +exports.BlockStatementControlFlowFlatteningNode = BlockStatementControlFlowFlatteningNode; + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var CallExpressionControlFlowStorageCallNode = function (_AbstractCustomNode_) { + _inherits(CallExpressionControlFlowStorageCallNode, _AbstractCustomNode_); + + function CallExpressionControlFlowStorageCallNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, CallExpressionControlFlowStorageCallNode); + + return _possibleConstructorReturn(this, (CallExpressionControlFlowStorageCallNode.__proto__ || Object.getPrototypeOf(CallExpressionControlFlowStorageCallNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(CallExpressionControlFlowStorageCallNode, [{ + key: "initialize", + value: function initialize(controlFlowStorageName, controlFlowStorageKey, callee, expressionArguments) { + this.controlFlowStorageName = controlFlowStorageName; + this.controlFlowStorageKey = controlFlowStorageKey; + this.callee = callee; + this.expressionArguments = expressionArguments; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getCallExpressionNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageName), Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageKey)), [this.callee].concat(_toConsumableArray(this.expressionArguments)))); + NodeUtils_1.NodeUtils.parentize(structure); + return [structure]; + } + }]); + + return CallExpressionControlFlowStorageCallNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], CallExpressionControlFlowStorageCallNode.prototype, "callee", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], CallExpressionControlFlowStorageCallNode.prototype, "controlFlowStorageKey", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], CallExpressionControlFlowStorageCallNode.prototype, "controlFlowStorageName", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], CallExpressionControlFlowStorageCallNode.prototype, "expressionArguments", void 0); +CallExpressionControlFlowStorageCallNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CallExpressionControlFlowStorageCallNode); +exports.CallExpressionControlFlowStorageCallNode = CallExpressionControlFlowStorageCallNode; + +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var CallExpressionFunctionNode = function (_AbstractCustomNode_) { + _inherits(CallExpressionFunctionNode, _AbstractCustomNode_); + + function CallExpressionFunctionNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, CallExpressionFunctionNode); + + return _possibleConstructorReturn(this, (CallExpressionFunctionNode.__proto__ || Object.getPrototypeOf(CallExpressionFunctionNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(CallExpressionFunctionNode, [{ + key: "initialize", + value: function initialize(expressionArguments) { + this.expressionArguments = expressionArguments; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var calleeIdentifier = Nodes_1.Nodes.getIdentifierNode('callee'); + var params = []; + var argumentsLength = this.expressionArguments.length; + for (var i = 0; i < argumentsLength; i++) { + params.push(Nodes_1.Nodes.getIdentifierNode("param" + (i + 1))); + } + var structure = Nodes_1.Nodes.getFunctionDeclarationNode(this.randomGenerator.getRandomString(3), [calleeIdentifier].concat(params), Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getReturnStatementNode(Nodes_1.Nodes.getCallExpressionNode(calleeIdentifier, params))])); + NodeUtils_1.NodeUtils.parentize(structure); + return [structure]; + } + }]); + + return CallExpressionFunctionNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], CallExpressionFunctionNode.prototype, "expressionArguments", void 0); +CallExpressionFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CallExpressionFunctionNode); +exports.CallExpressionFunctionNode = CallExpressionFunctionNode; + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var ControlFlowStorageNode = function (_AbstractCustomNode_) { + _inherits(ControlFlowStorageNode, _AbstractCustomNode_); + + function ControlFlowStorageNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, ControlFlowStorageNode); + + return _possibleConstructorReturn(this, (ControlFlowStorageNode.__proto__ || Object.getPrototypeOf(ControlFlowStorageNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(ControlFlowStorageNode, [{ + key: "initialize", + value: function initialize(controlFlowStorage) { + this.controlFlowStorage = controlFlowStorage; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var structure = Nodes_1.Nodes.getVariableDeclarationNode([Nodes_1.Nodes.getVariableDeclaratorNode(Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorage.getStorageId()), Nodes_1.Nodes.getObjectExpressionNode(Array.from(this.controlFlowStorage.getStorage()).map(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + key = _ref2[0], + value = _ref2[1]; + + return Nodes_1.Nodes.getPropertyNode(Nodes_1.Nodes.getIdentifierNode(key), value.getNode()[0]); + })))]); + structure = NodeUtils_1.NodeUtils.parentize(structure); + return [structure]; + } + }]); + + return ControlFlowStorageNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], ControlFlowStorageNode.prototype, "controlFlowStorage", void 0); +ControlFlowStorageNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ControlFlowStorageNode); +exports.ControlFlowStorageNode = ControlFlowStorageNode; + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var ObfuscationTarget_1 = __webpack_require__(13); +var ConsoleOutputDisableExpressionTemplate_1 = __webpack_require__(78); +var GlobalVariableNoEvalTemplate_1 = __webpack_require__(30); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeUtils_1 = __webpack_require__(4); +var ConsoleOutputDisableExpressionNode = function (_AbstractCustomNode_) { + _inherits(ConsoleOutputDisableExpressionNode, _AbstractCustomNode_); + + function ConsoleOutputDisableExpressionNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, ConsoleOutputDisableExpressionNode); + + return _possibleConstructorReturn(this, (ConsoleOutputDisableExpressionNode.__proto__ || Object.getPrototypeOf(ConsoleOutputDisableExpressionNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(ConsoleOutputDisableExpressionNode, [{ + key: "initialize", + value: function initialize(callsControllerFunctionName) { + this.callsControllerFunctionName = callsControllerFunctionName; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + var globalVariableTemplate = this.options.target !== ObfuscationTarget_1.ObfuscationTarget.Extension ? this.getGlobalVariableTemplate() : GlobalVariableNoEvalTemplate_1.GlobalVariableNoEvalTemplate(); + return format(ConsoleOutputDisableExpressionTemplate_1.ConsoleOutputDisableExpressionTemplate(), { + consoleLogDisableFunctionName: this.identifierNameGenerator.generate(6), + globalVariableTemplate: globalVariableTemplate, + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }); + } + }]); + + return ConsoleOutputDisableExpressionNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ConsoleOutputDisableExpressionNode.prototype, "callsControllerFunctionName", void 0); +ConsoleOutputDisableExpressionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ConsoleOutputDisableExpressionNode); +exports.ConsoleOutputDisableExpressionNode = ConsoleOutputDisableExpressionNode; + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function ConsoleOutputDisableExpressionTemplate() { + return "\n var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var func = function () {};\n \n {globalVariableTemplate}\n \n if (!that.console) {\n that.console = (function (func){\n var c = {};\n \n c.log = func;\n c.warn = func;\n c.debug = func;\n c.info = func;\n c.error = func;\n c.exception = func;\n c.trace = func;\n \n return c;\n })(func);\n } else {\n that.console.log = func;\n that.console.warn = func;\n that.console.debug = func;\n that.console.info = func;\n that.console.error = func;\n that.console.exception = func;\n that.console.trace = func;\n }\n });\n \n {consoleLogDisableFunctionName}();\n "; +} +exports.ConsoleOutputDisableExpressionTemplate = ConsoleOutputDisableExpressionTemplate; + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var Initializable_1 = __webpack_require__(3); +var DebufProtectionFunctionCallTemplate_1 = __webpack_require__(80); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeUtils_1 = __webpack_require__(4); +var DebugProtectionFunctionCallNode = function (_AbstractCustomNode_) { + _inherits(DebugProtectionFunctionCallNode, _AbstractCustomNode_); + + function DebugProtectionFunctionCallNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, DebugProtectionFunctionCallNode); + + return _possibleConstructorReturn(this, (DebugProtectionFunctionCallNode.__proto__ || Object.getPrototypeOf(DebugProtectionFunctionCallNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(DebugProtectionFunctionCallNode, [{ + key: "initialize", + value: function initialize(debugProtectionFunctionName) { + this.debugProtectionFunctionName = debugProtectionFunctionName; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + return format(DebufProtectionFunctionCallTemplate_1.DebugProtectionFunctionCallTemplate(), { + debugProtectionFunctionName: this.debugProtectionFunctionName + }); + } + }]); + + return DebugProtectionFunctionCallNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DebugProtectionFunctionCallNode.prototype, "debugProtectionFunctionName", void 0); +DebugProtectionFunctionCallNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], DebugProtectionFunctionCallNode); +exports.DebugProtectionFunctionCallNode = DebugProtectionFunctionCallNode; + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function DebugProtectionFunctionCallTemplate() { + return "\n (function () {\n var regExp1 = new RegExp('function *\\\\( *\\\\)');\n var regExp2 = new RegExp('\\\\+\\\\+ *\\(?:_0x([a-f0-9]){4,6}|\\\\b[0-9a-zA-Z_$]{1,4}\\\\b\\)');\n var result = {debugProtectionFunctionName}('init');\n \n if (!regExp1.test(result + 'chain') || !regExp2.test(result + 'input')) {\n result('0');\n } else {\n {debugProtectionFunctionName}();\n }\n })();\n "; +} +exports.DebugProtectionFunctionCallTemplate = DebugProtectionFunctionCallTemplate; + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var Initializable_1 = __webpack_require__(3); +var DebugProtectionFunctionIntervalTemplate_1 = __webpack_require__(82); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeUtils_1 = __webpack_require__(4); +var DebugProtectionFunctionIntervalNode = function (_AbstractCustomNode_) { + _inherits(DebugProtectionFunctionIntervalNode, _AbstractCustomNode_); + + function DebugProtectionFunctionIntervalNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, DebugProtectionFunctionIntervalNode); + + return _possibleConstructorReturn(this, (DebugProtectionFunctionIntervalNode.__proto__ || Object.getPrototypeOf(DebugProtectionFunctionIntervalNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(DebugProtectionFunctionIntervalNode, [{ + key: "initialize", + value: function initialize(debugProtectionFunctionName) { + this.debugProtectionFunctionName = debugProtectionFunctionName; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + return format(DebugProtectionFunctionIntervalTemplate_1.DebugProtectionFunctionIntervalTemplate(), { + debugProtectionFunctionName: this.debugProtectionFunctionName + }); + } + }]); + + return DebugProtectionFunctionIntervalNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DebugProtectionFunctionIntervalNode.prototype, "debugProtectionFunctionName", void 0); +DebugProtectionFunctionIntervalNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], DebugProtectionFunctionIntervalNode); +exports.DebugProtectionFunctionIntervalNode = DebugProtectionFunctionIntervalNode; + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function DebugProtectionFunctionIntervalTemplate() { + return "\n setInterval(function () {\n {debugProtectionFunctionName}();\n }, 4000);\n "; +} +exports.DebugProtectionFunctionIntervalTemplate = DebugProtectionFunctionIntervalTemplate; + +/***/ }), +/* 83 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var ObfuscationTarget_1 = __webpack_require__(13); +var Initializable_1 = __webpack_require__(3); +var DebuggerTemplate_1 = __webpack_require__(84); +var DebuggerTemplateNoEval_1 = __webpack_require__(85); +var DebugProtectionFunctionTemplate_1 = __webpack_require__(86); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeUtils_1 = __webpack_require__(4); +var DebugProtectionFunctionNode = function (_AbstractCustomNode_) { + _inherits(DebugProtectionFunctionNode, _AbstractCustomNode_); + + function DebugProtectionFunctionNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, DebugProtectionFunctionNode); + + return _possibleConstructorReturn(this, (DebugProtectionFunctionNode.__proto__ || Object.getPrototypeOf(DebugProtectionFunctionNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(DebugProtectionFunctionNode, [{ + key: "initialize", + value: function initialize(debugProtectionFunctionName) { + this.debugProtectionFunctionName = debugProtectionFunctionName; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + var debuggerTemplate = this.options.target !== ObfuscationTarget_1.ObfuscationTarget.Extension ? DebuggerTemplate_1.DebuggerTemplate() : DebuggerTemplateNoEval_1.DebuggerTemplateNoEval(); + return format(DebugProtectionFunctionTemplate_1.DebugProtectionFunctionTemplate(), { + debuggerTemplate: debuggerTemplate, + debugProtectionFunctionName: this.debugProtectionFunctionName + }); + } + }]); + + return DebugProtectionFunctionNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DebugProtectionFunctionNode.prototype, "debugProtectionFunctionName", void 0); +DebugProtectionFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], DebugProtectionFunctionNode); +exports.DebugProtectionFunctionNode = DebugProtectionFunctionNode; + +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function DebuggerTemplate() { + return "\n if (typeof counter === 'string') {\n return (function (arg) {}.constructor('while (true) {}').apply('counter'));\n } else {\n if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {\n (function () {return true;}.constructor('debu' + 'gger').call('action'));\n } else {\n (function () {return false;}.constructor('debu' + 'gger').apply('stateObject'));\n }\n \n }\n "; +} +exports.DebuggerTemplate = DebuggerTemplate; + +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function DebuggerTemplateNoEval() { + return "\n if (typeof counter === 'string') {\n var func = function () {\n while (true) {}\n };\n \n return func();\n } else {\n if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {\n debugger;\n } else {\n debugger;\n }\n \n }\n "; +} +exports.DebuggerTemplateNoEval = DebuggerTemplateNoEval; + +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function DebugProtectionFunctionTemplate() { + return "\n function {debugProtectionFunctionName} (ret) {\n function debuggerProtection (counter) {\n \n {debuggerTemplate}\n \n debuggerProtection(++counter);\n }\n \n try {\n if (ret) {\n return debuggerProtection;\n } else {\n debuggerProtection(0);\n }\n } catch (y) {}\n }\n "; +} +exports.DebugProtectionFunctionTemplate = DebugProtectionFunctionTemplate; + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var ObfuscationTarget_1 = __webpack_require__(13); +var Initializable_1 = __webpack_require__(3); +var DomainLockNodeTemplate_1 = __webpack_require__(88); +var GlobalVariableNoEvalTemplate_1 = __webpack_require__(30); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeUtils_1 = __webpack_require__(4); +var DomainLockNode = function (_AbstractCustomNode_) { + _inherits(DomainLockNode, _AbstractCustomNode_); + + function DomainLockNode(identifierNameGeneratorFactory, randomGenerator, cryptUtils, options) { + _classCallCheck(this, DomainLockNode); + + var _this = _possibleConstructorReturn(this, (DomainLockNode.__proto__ || Object.getPrototypeOf(DomainLockNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.cryptUtils = cryptUtils; + return _this; + } + + _createClass(DomainLockNode, [{ + key: "initialize", + value: function initialize(callsControllerFunctionName) { + this.callsControllerFunctionName = callsControllerFunctionName; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + var domainsString = this.options.domainLock.join(';'); + + var _cryptUtils$hideStrin = this.cryptUtils.hideString(domainsString, domainsString.length * 3), + _cryptUtils$hideStrin2 = _slicedToArray(_cryptUtils$hideStrin, 2), + hiddenDomainsString = _cryptUtils$hideStrin2[0], + diff = _cryptUtils$hideStrin2[1]; + + var globalVariableTemplate = this.options.target !== ObfuscationTarget_1.ObfuscationTarget.Extension ? this.getGlobalVariableTemplate() : GlobalVariableNoEvalTemplate_1.GlobalVariableNoEvalTemplate(); + return format(DomainLockNodeTemplate_1.DomainLockNodeTemplate(), { + domainLockFunctionName: this.identifierNameGenerator.generate(6), + diff: diff, + domains: hiddenDomainsString, + globalVariableTemplate: globalVariableTemplate, + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }); + } + }]); + + return DomainLockNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DomainLockNode.prototype, "callsControllerFunctionName", void 0); +DomainLockNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ICryptUtils)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], DomainLockNode); +exports.DomainLockNode = DomainLockNode; + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function DomainLockNodeTemplate() { + return "\n var {domainLockFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n \n {globalVariableTemplate}\n \n var func = function () {\n return {\n key: 'item',\n value: 'attribute',\n getAttribute: function () {\n for (var i = 0; i < 1000; i--) {\n var isPositive = i > 0;\n \n switch (isPositive) {\n case true:\n return this.item + '_' + this.value + '_' + i;\n default:\n this.item + '_' + this.value;\n }\n }\n }()\n };\n };\n \n var regExp = new RegExp(\"[{diff}]\", \"g\");\n var domains = \"{domains}\".replace(regExp, \"\").split(\";\");\n var document;\n var domain;\n \n for (var d in that) {\n if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {\n document = d;\n \n break;\n }\n }\n\n for (var d1 in that[document]) {\n if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {\n domain = d1;\n \n break;\n }\n }\n \n if ((!document && !domain) || (!that[document] && !that[document][domain])) {\n return;\n }\n \n var currentDomain = that[document][domain];\n\n var ok = false;\n \n for (var i = 0; i < domains.length; i++) {\n var domain = domains[i];\n var position = currentDomain.length - domain.length;\n var lastIndex = currentDomain.indexOf(domain, position);\n var endsWith = lastIndex !== -1 && lastIndex === position;\n \n if (endsWith) {\n if (currentDomain.length == domain.length || domain.indexOf(\".\") === 0) {\n ok = true;\n }\n \n break;\n }\n }\n \n if (!ok) {\n data;\n } else {\n return;\n }\n \n func();\n });\n\n {domainLockFunctionName}();\n "; +} +exports.DomainLockNodeTemplate = DomainLockNodeTemplate; + +/***/ }), +/* 89 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var ExpressionWithOperatorControlFlowStorageCallNode = function (_AbstractCustomNode_) { + _inherits(ExpressionWithOperatorControlFlowStorageCallNode, _AbstractCustomNode_); + + function ExpressionWithOperatorControlFlowStorageCallNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, ExpressionWithOperatorControlFlowStorageCallNode); + + return _possibleConstructorReturn(this, (ExpressionWithOperatorControlFlowStorageCallNode.__proto__ || Object.getPrototypeOf(ExpressionWithOperatorControlFlowStorageCallNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(ExpressionWithOperatorControlFlowStorageCallNode, [{ + key: "initialize", + value: function initialize(controlFlowStorageName, controlFlowStorageKey, leftValue, rightValue) { + this.controlFlowStorageName = controlFlowStorageName; + this.controlFlowStorageKey = controlFlowStorageKey; + this.leftValue = leftValue; + this.rightValue = rightValue; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getCallExpressionNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageName), Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageKey)), [this.leftValue, this.rightValue])); + NodeUtils_1.NodeUtils.parentize(structure); + return [structure]; + } + }]); + + return ExpressionWithOperatorControlFlowStorageCallNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ExpressionWithOperatorControlFlowStorageCallNode.prototype, "controlFlowStorageKey", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ExpressionWithOperatorControlFlowStorageCallNode.prototype, "controlFlowStorageName", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], ExpressionWithOperatorControlFlowStorageCallNode.prototype, "leftValue", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], ExpressionWithOperatorControlFlowStorageCallNode.prototype, "rightValue", void 0); +ExpressionWithOperatorControlFlowStorageCallNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ExpressionWithOperatorControlFlowStorageCallNode); +exports.ExpressionWithOperatorControlFlowStorageCallNode = ExpressionWithOperatorControlFlowStorageCallNode; + +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var LogicalExpressionFunctionNode = function (_AbstractCustomNode_) { + _inherits(LogicalExpressionFunctionNode, _AbstractCustomNode_); + + function LogicalExpressionFunctionNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, LogicalExpressionFunctionNode); + + return _possibleConstructorReturn(this, (LogicalExpressionFunctionNode.__proto__ || Object.getPrototypeOf(LogicalExpressionFunctionNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(LogicalExpressionFunctionNode, [{ + key: "initialize", + value: function initialize(operator) { + this.operator = operator; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var structure = Nodes_1.Nodes.getFunctionDeclarationNode(this.randomGenerator.getRandomString(3), [Nodes_1.Nodes.getIdentifierNode('x'), Nodes_1.Nodes.getIdentifierNode('y')], Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getReturnStatementNode(Nodes_1.Nodes.getLogicalExpressionNode(this.operator, Nodes_1.Nodes.getIdentifierNode('x'), Nodes_1.Nodes.getIdentifierNode('y')))])); + NodeUtils_1.NodeUtils.parentize(structure); + return [structure]; + } + }]); + + return LogicalExpressionFunctionNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], LogicalExpressionFunctionNode.prototype, "operator", void 0); +LogicalExpressionFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], LogicalExpressionFunctionNode); +exports.LogicalExpressionFunctionNode = LogicalExpressionFunctionNode; + +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var ObfuscationEvent_1 = __webpack_require__(15); +var Initializable_1 = __webpack_require__(3); +var SingleNodeCallControllerTemplate_1 = __webpack_require__(92); +var NoCustomNodes_1 = __webpack_require__(25); +var AbstractCustomNode_1 = __webpack_require__(6); +var JavaScriptObfuscatorFacade_1 = __webpack_require__(17); +var NodeUtils_1 = __webpack_require__(4); +var NodeCallsControllerFunctionNode = function (_AbstractCustomNode_) { + _inherits(NodeCallsControllerFunctionNode, _AbstractCustomNode_); + + function NodeCallsControllerFunctionNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, NodeCallsControllerFunctionNode); + + return _possibleConstructorReturn(this, (NodeCallsControllerFunctionNode.__proto__ || Object.getPrototypeOf(NodeCallsControllerFunctionNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(NodeCallsControllerFunctionNode, [{ + key: "initialize", + value: function initialize(appendEvent, callsControllerFunctionName) { + this.appendEvent = appendEvent; + this.callsControllerFunctionName = callsControllerFunctionName; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + if (this.appendEvent === ObfuscationEvent_1.ObfuscationEvent.AfterObfuscation) { + return JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(format(SingleNodeCallControllerTemplate_1.SingleNodeCallControllerTemplate(), { + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }), Object.assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { mangle: this.options.mangle, seed: this.options.seed })).getObfuscatedCode(); + } + return format(SingleNodeCallControllerTemplate_1.SingleNodeCallControllerTemplate(), { + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }); + } + }]); + + return NodeCallsControllerFunctionNode; +}(AbstractCustomNode_1.AbstractCustomNode); +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.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], NodeCallsControllerFunctionNode); +exports.NodeCallsControllerFunctionNode = NodeCallsControllerFunctionNode; + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function SingleNodeCallControllerTemplate() { + return "\n var {singleNodeCallControllerFunctionName} = (function(){\n var firstCall = true;\n \n return function (context, fn){\n var rfn = firstCall ? function(){\n if(fn){\n var res = fn.apply(context, arguments);\n fn = null;\n return res;\n }\n } : function(){}\n \n firstCall = false;\n \n return rfn;\n }\n })();\n "; +} +exports.SingleNodeCallControllerTemplate = SingleNodeCallControllerTemplate; + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var Initializable_1 = __webpack_require__(3); +var NoCustomNodes_1 = __webpack_require__(25); +var SelfDefendingTemplate_1 = __webpack_require__(94); +var AbstractCustomNode_1 = __webpack_require__(6); +var JavaScriptObfuscatorFacade_1 = __webpack_require__(17); +var NodeUtils_1 = __webpack_require__(4); +var SelfDefendingUnicodeNode = function (_AbstractCustomNode_) { + _inherits(SelfDefendingUnicodeNode, _AbstractCustomNode_); + + function SelfDefendingUnicodeNode(identifierNameGeneratorFactory, randomGenerator, escapeSequenceEncoder, options) { + _classCallCheck(this, SelfDefendingUnicodeNode); + + var _this = _possibleConstructorReturn(this, (SelfDefendingUnicodeNode.__proto__ || Object.getPrototypeOf(SelfDefendingUnicodeNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.escapeSequenceEncoder = escapeSequenceEncoder; + return _this; + } + + _createClass(SelfDefendingUnicodeNode, [{ + key: "initialize", + value: function initialize(callsControllerFunctionName) { + this.callsControllerFunctionName = callsControllerFunctionName; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + return JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(format(SelfDefendingTemplate_1.SelfDefendingTemplate(this.escapeSequenceEncoder), { + selfDefendingFunctionName: this.identifierNameGenerator.generate(6), + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }), Object.assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { mangle: this.options.mangle, seed: this.options.seed, unicodeEscapeSequence: true })).getObfuscatedCode(); + } + }]); + + return SelfDefendingUnicodeNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], SelfDefendingUnicodeNode.prototype, "callsControllerFunctionName", void 0); +SelfDefendingUnicodeNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], SelfDefendingUnicodeNode); +exports.SelfDefendingUnicodeNode = SelfDefendingUnicodeNode; + +/***/ }), +/* 94 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function SelfDefendingTemplate(escapeSequenceEncoder) { + return "\n var {selfDefendingFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var func1 = function(){return 'dev';},\n func2 = function () {\n return 'window';\n };\n \n var test1 = function () {\n var regExp = new RegExp('" + escapeSequenceEncoder.encode("\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}", true) + "');\n \n return !regExp.test(func1.toString());\n };\n \n var test2 = function () {\n var regExp = new RegExp('" + escapeSequenceEncoder.encode("(\\\\[x|u](\\w){2,4})+", true) + "');\n \n return regExp.test(func2.toString());\n };\n \n var recursiveFunc1 = function (string) {\n var i = ~-1 >> 1 + 255 % 0;\n \n if (string.indexOf('i' === i)) {\n recursiveFunc2(string)\n }\n };\n \n var recursiveFunc2 = function (string) {\n var i = ~-4 >> 1 + 255 % 0;\n \n if (string.indexOf((true+\"\")[3]) !== i) {\n recursiveFunc1(string)\n }\n };\n \n if (!test1()) {\n if (!test2()) {\n recursiveFunc1('ind\u0435xOf');\n } else {\n recursiveFunc1('indexOf');\n }\n } else {\n recursiveFunc1('ind\u0435xOf');\n }\n })\n \n {selfDefendingFunctionName}();\n "; +} +exports.SelfDefendingTemplate = SelfDefendingTemplate; + +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var ObfuscationTarget_1 = __webpack_require__(13); +var StringArrayEncoding_1 = __webpack_require__(24); +var Initializable_1 = __webpack_require__(3); +var NoCustomNodes_1 = __webpack_require__(25); +var AtobTemplate_1 = __webpack_require__(96); +var GlobalVariableNoEvalTemplate_1 = __webpack_require__(30); +var Rc4Template_1 = __webpack_require__(97); +var SelfDefendingTemplate_1 = __webpack_require__(98); +var StringArrayBase64DecodeNodeTemplate_1 = __webpack_require__(99); +var StringArrayCallsWrapperTemplate_1 = __webpack_require__(100); +var StringArrayRC4DecodeNodeTemplate_1 = __webpack_require__(101); +var AbstractCustomNode_1 = __webpack_require__(6); +var JavaScriptObfuscatorFacade_1 = __webpack_require__(17); +var NodeUtils_1 = __webpack_require__(4); +var StringArrayCallsWrapper = function (_AbstractCustomNode_) { + _inherits(StringArrayCallsWrapper, _AbstractCustomNode_); + + function StringArrayCallsWrapper(identifierNameGeneratorFactory, randomGenerator, escapeSequenceEncoder, options) { + _classCallCheck(this, StringArrayCallsWrapper); + + var _this = _possibleConstructorReturn(this, (StringArrayCallsWrapper.__proto__ || Object.getPrototypeOf(StringArrayCallsWrapper)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.escapeSequenceEncoder = escapeSequenceEncoder; + return _this; + } + + _createClass(StringArrayCallsWrapper, [{ + key: "initialize", + value: function initialize(stringArrayName, stringArrayCallsWrapperName) { + 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 JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(format(StringArrayCallsWrapperTemplate_1.StringArrayCallsWrapperTemplate(), { + decodeNodeTemplate: decodeNodeTemplate, + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName, + stringArrayName: this.stringArrayName + }), Object.assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { mangle: this.options.mangle, seed: this.options.seed })).getObfuscatedCode(); + } + }, { + key: "getDecodeStringArrayTemplate", + value: function getDecodeStringArrayTemplate() { + var globalVariableTemplate = this.options.target !== ObfuscationTarget_1.ObfuscationTarget.Extension ? this.getGlobalVariableTemplate() : GlobalVariableNoEvalTemplate_1.GlobalVariableNoEvalTemplate(); + var atobPolyfill = format(AtobTemplate_1.AtobTemplate(), { globalVariableTemplate: globalVariableTemplate }); + var decodeStringArrayTemplate = '', + selfDefendingCode = ''; + if (this.options.selfDefending) { + selfDefendingCode = format(SelfDefendingTemplate_1.SelfDefendingTemplate(this.escapeSequenceEncoder), { + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName, + stringArrayName: this.stringArrayName + }); + } + switch (this.options.stringArrayEncoding) { + case StringArrayEncoding_1.StringArrayEncoding.Rc4: + decodeStringArrayTemplate = format(StringArrayRC4DecodeNodeTemplate_1.StringArrayRc4DecodeNodeTemplate(), { + atobPolyfill: atobPolyfill, + rc4Polyfill: Rc4Template_1.Rc4Template(), + selfDefendingCode: selfDefendingCode, + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName + }); + break; + case StringArrayEncoding_1.StringArrayEncoding.Base64: + decodeStringArrayTemplate = format(StringArrayBase64DecodeNodeTemplate_1.StringArrayBase64DecodeNodeTemplate(), { + atobPolyfill: atobPolyfill, + selfDefendingCode: selfDefendingCode, + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName + }); + break; + } + return decodeStringArrayTemplate; + } + }]); + + return StringArrayCallsWrapper; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringArrayCallsWrapper.prototype, "stringArrayName", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringArrayCallsWrapper.prototype, "stringArrayCallsWrapperName", void 0); +StringArrayCallsWrapper = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], StringArrayCallsWrapper); +exports.StringArrayCallsWrapper = StringArrayCallsWrapper; + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function AtobTemplate() { + return "\n (function () {\n {globalVariableTemplate}\n \n var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\n that.atob || (\n that.atob = function(input) {\n var str = String(input).replace(/=+$/, '');\n for (\n var bc = 0, bs, buffer, idx = 0, output = '';\n buffer = str.charAt(idx++);\n ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,\n bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0\n ) {\n buffer = chars.indexOf(buffer);\n }\n return output;\n });\n })();\n "; +} +exports.AtobTemplate = AtobTemplate; + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function Rc4Template() { + return "\n var rc4 = function (str, key) {\n var s = [], j = 0, x, res = '', newStr = '';\n \n str = atob(str);\n \n for (var k = 0, length = str.length; k < length; k++) {\n newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);\n }\n \n str = decodeURIComponent(newStr);\n \t \n\t for (var i = 0; i < 256; i++) {\n s[i] = i;\n }\n \n for (i = 0; i < 256; i++) {\n j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n }\n \n i = 0;\n j = 0;\n \n for (var y = 0; y < str.length; y++) {\n i = (i + 1) % 256;\n j = (j + s[i]) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);\n }\n \n return res;\n }\n "; +} +exports.Rc4Template = Rc4Template; + +/***/ }), +/* 98 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function SelfDefendingTemplate(escapeSequenceEncoder) { + return "\n var StatesClass = function (rc4Bytes) {\n this.rc4Bytes = rc4Bytes;\n this.states = [1, 0, 0];\n this.newState = function(){return 'newState';};\n this.firstState = '" + escapeSequenceEncoder.encode("\\w+ *\\(\\) *{\\w+ *", true) + "';\n this.secondState = '" + escapeSequenceEncoder.encode("['|\"].+['|\"];? *}", true) + "';\n };\n \n StatesClass.prototype.checkState = function () {\n var regExp = new RegExp(this.firstState + this.secondState);\n\n return this.runState(regExp.test(this.newState.toString()) ? --this.states[1] : --this.states[0]);\n };\n \n StatesClass.prototype.runState = function (stateResult) {\n if (!Boolean(~stateResult)) {\n return stateResult;\n }\n \n return this.getState(this.rc4Bytes);\n };\n\n StatesClass.prototype.getState = function (rc4Bytes) {\n for (var i = 0, len = this.states.length; i < len; i++) {\n this.states.push(Math.round(Math.random()));\n len = this.states.length;\n }\n \n return rc4Bytes(this.states[0]);\n };\n\n new StatesClass({stringArrayCallsWrapperName}).checkState();\n "; +} +exports.SelfDefendingTemplate = SelfDefendingTemplate; + +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function StringArrayBase64DecodeNodeTemplate() { + return "\n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}.base64DecodeUnicode = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}.data[index];\n \n if (cachedValue === undefined) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = cachedValue;\n }\n "; +} +exports.StringArrayBase64DecodeNodeTemplate = StringArrayBase64DecodeNodeTemplate; + +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function StringArrayCallsWrapperTemplate() { + return "\n var {stringArrayCallsWrapperName} = function (index, key) {\n index = index - 0;\n \n var value = {stringArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "; +} +exports.StringArrayCallsWrapperTemplate = StringArrayCallsWrapperTemplate; + +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function StringArrayRc4DecodeNodeTemplate() { + return "\n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {rc4Polyfill}\n {stringArrayCallsWrapperName}.rc4 = rc4;\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}.data[index];\n\n if (cachedValue === undefined) {\n if ({stringArrayCallsWrapperName}.once === undefined) {\n {selfDefendingCode}\n \n {stringArrayCallsWrapperName}.once = true;\n }\n \n value = {stringArrayCallsWrapperName}.rc4(value, key);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = cachedValue;\n }\n "; +} +exports.StringArrayRc4DecodeNodeTemplate = StringArrayRc4DecodeNodeTemplate; + +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = (function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var Initializable_1 = __webpack_require__(3); +var StringArrayTemplate_1 = __webpack_require__(103); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeUtils_1 = __webpack_require__(4); +var StringArrayNode = function (_AbstractCustomNode_) { + _inherits(StringArrayNode, _AbstractCustomNode_); + + function StringArrayNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, StringArrayNode); + + return _possibleConstructorReturn(this, (StringArrayNode.__proto__ || Object.getPrototypeOf(StringArrayNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(StringArrayNode, [{ + key: "initialize", + value: function initialize(stringArrayStorage, stringArrayName, stringArrayRotateValue) { + this.stringArrayStorage = stringArrayStorage; + this.stringArrayName = stringArrayName; + this.stringArrayRotateValue = stringArrayRotateValue; + } + }, { + key: "getNode", + value: function getNode() { + this.stringArrayStorage.rotateArray(this.stringArrayRotateValue); + return _get(StringArrayNode.prototype.__proto__ || Object.getPrototypeOf(StringArrayNode.prototype), "getNode", this).call(this); + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + return format(StringArrayTemplate_1.StringArrayTemplate(), { + stringArrayName: this.stringArrayName, + stringArray: this.stringArrayStorage.toString() + }); + } + }]); + + return StringArrayNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], StringArrayNode.prototype, "stringArrayStorage", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringArrayNode.prototype, "stringArrayName", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Number)], StringArrayNode.prototype, "stringArrayRotateValue", void 0); +StringArrayNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], StringArrayNode); +exports.StringArrayNode = StringArrayNode; + +/***/ }), +/* 103 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function StringArrayTemplate() { + return "\n var {stringArrayName} = [{stringArray}];\n "; +} +exports.StringArrayTemplate = StringArrayTemplate; + +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var format = __webpack_require__(11); +var Initializable_1 = __webpack_require__(3); +var NoCustomNodes_1 = __webpack_require__(25); +var SelfDefendingTemplate_1 = __webpack_require__(105); +var StringArrayRotateFunctionTemplate_1 = __webpack_require__(106); +var AbstractCustomNode_1 = __webpack_require__(6); +var JavaScriptObfuscatorFacade_1 = __webpack_require__(17); +var NodeUtils_1 = __webpack_require__(4); +var Utils_1 = __webpack_require__(21); +var StringArrayRotateFunctionNode = function (_AbstractCustomNode_) { + _inherits(StringArrayRotateFunctionNode, _AbstractCustomNode_); + + function StringArrayRotateFunctionNode(identifierNameGeneratorFactory, randomGenerator, escapeSequenceEncoder, options) { + _classCallCheck(this, StringArrayRotateFunctionNode); + + var _this = _possibleConstructorReturn(this, (StringArrayRotateFunctionNode.__proto__ || Object.getPrototypeOf(StringArrayRotateFunctionNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + + _this.escapeSequenceEncoder = escapeSequenceEncoder; + return _this; + } + + _createClass(StringArrayRotateFunctionNode, [{ + key: "initialize", + value: function initialize(stringArrayName, stringArrayRotateValue) { + this.stringArrayName = stringArrayName; + this.stringArrayRotateValue = stringArrayRotateValue; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate()); + } + }, { + key: "getTemplate", + value: function getTemplate() { + var timesName = this.identifierNameGenerator.generate(6); + var whileFunctionName = this.identifierNameGenerator.generate(6); + var code = ''; + if (this.options.selfDefending) { + code = format(SelfDefendingTemplate_1.SelfDefendingTemplate(this.escapeSequenceEncoder), { + timesName: timesName, + whileFunctionName: whileFunctionName + }); + } else { + code = whileFunctionName + "(++" + timesName + ")"; + } + return JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(format(StringArrayRotateFunctionTemplate_1.StringArrayRotateFunctionTemplate(), { + code: code, + timesName: timesName, + stringArrayName: this.stringArrayName, + stringArrayRotateValue: Utils_1.Utils.decToHex(this.stringArrayRotateValue), + whileFunctionName: whileFunctionName + }), Object.assign({}, NoCustomNodes_1.NO_CUSTOM_NODES_PRESET, { mangle: this.options.mangle, seed: this.options.seed })).getObfuscatedCode(); + } + }]); + + return StringArrayRotateFunctionNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringArrayRotateFunctionNode.prototype, "stringArrayName", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Number)], StringArrayRotateFunctionNode.prototype, "stringArrayRotateValue", void 0); +StringArrayRotateFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], StringArrayRotateFunctionNode); +exports.StringArrayRotateFunctionNode = StringArrayRotateFunctionNode; + +/***/ }), +/* 105 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function SelfDefendingTemplate(escapeSequenceEncoder) { + return "\n var selfDefendingFunc = function () {\n var object = {\n data: {\n key: 'cookie',\n value: 'timeout'\n },\n setCookie: function (options, name, value, document) {\n document = document || {};\n \n var updatedCookie = name + \"=\" + value;\n\n var i = 0;\n \n for (var i = 0, len = options.length; i < len; i++) {\n var propName = options[i];\n \n updatedCookie += \"; \" + propName;\n \n var propValue = options[propName];\n \n options.push(propValue);\n len = options.length;\n \n if (propValue !== true) {\n updatedCookie += \"=\" + propValue;\n }\n }\n\n document['cookie'] = updatedCookie;\n },\n removeCookie: function(){return 'dev';},\n getCookie: function (document, name) {\n document = document || function (value) { return value };\n var matches = document(new RegExp(\n \"(?:^|; )\" + name.replace(/([.$?*|{}()[]\\/+^])/g, '\\$1') + \"=([^;]*)\"\n ));\n \n var func = function (param1, param2) {\n param1(++param2);\n };\n \n func({whileFunctionName}, {timesName});\n \n return matches ? decodeURIComponent(matches[1]) : undefined;\n }\n };\n \n var test1 = function () {\n var regExp = new RegExp('" + escapeSequenceEncoder.encode("\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}", true) + "');\n \n return regExp.test(object.removeCookie.toString());\n };\n \n object['updateCookie'] = test1;\n \n var cookie = '';\n var result = object['updateCookie']();\n \n if (!result) {\n object['setCookie'](['*'], 'counter', 1);\n } else if (result) {\n cookie = object['getCookie'](null, 'counter');\n } else {\n object['removeCookie']();\n }\n };\n \n selfDefendingFunc();\n "; +} +exports.SelfDefendingTemplate = SelfDefendingTemplate; + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +function StringArrayRotateFunctionTemplate() { + return "\n (function (array, {timesName}) {\n var {whileFunctionName} = function (times) {\n while (--times) {\n array['push'](array['shift']());\n }\n };\n \n {code}\n })({stringArrayName}, 0x{stringArrayRotateValue});\n "; +} +exports.StringArrayRotateFunctionTemplate = StringArrayRotateFunctionTemplate; + +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var JSFuck; +(function (JSFuck) { + JSFuck["False"] = "![]"; + JSFuck["True"] = "!![]"; + JSFuck["a"] = "(false+\"\")[1]"; + JSFuck["b"] = "([][\"entries\"]()+\"\")[2]"; + JSFuck["c"] = "([][\"fill\"]+\"\")[3]"; + JSFuck["d"] = "(undefined+\"\")[2]"; + JSFuck["e"] = "(true+\"\")[3]"; + JSFuck["f"] = "(false+\"\")[0]"; + JSFuck["g"] = "(false+[0]+String)[20]"; + JSFuck["h"] = "(+(101))[\"toString\"](21)[1]"; + JSFuck["i"] = "([false]+undefined)[10]"; + JSFuck["j"] = "([][\"entries\"]()+\"\")[3]"; + JSFuck["k"] = "(+(20))[\"toString\"](21)"; + JSFuck["l"] = "(false+\"\")[2]"; + JSFuck["m"] = "(Number+\"\")[11]"; + JSFuck["n"] = "(undefined+\"\")[1]"; + JSFuck["o"] = "(true+[][\"fill\"])[10]"; + JSFuck["p"] = "(+(211))[\"toString\"](31)[1]"; + JSFuck["q"] = "(+(212))[\"toString\"](31)[1]"; + JSFuck["r"] = "(true+\"\")[1]"; + JSFuck["s"] = "(false+\"\")[3]"; + JSFuck["t"] = "(true+\"\")[0]"; + JSFuck["u"] = "(undefined+\"\")[0]"; + JSFuck["v"] = "(+(31))[\"toString\"](32)"; + JSFuck["w"] = "(+(32))[\"toString\"](33)"; + JSFuck["x"] = "(+(101))[\"toString\"](34)[1]"; + JSFuck["y"] = "(NaN+[Infinity])[10]"; + JSFuck["z"] = "(+(35))[\"toString\"](36)"; + JSFuck["A"] = "(+[]+Array)[10]"; + JSFuck["B"] = "(+[]+Boolean)[10]"; + JSFuck["C"] = "Function(\"return escape\")()((\"\")[\"italics\"]())[2]"; + JSFuck["D"] = "Function(\"return escape\")()([][\"fill\"])[\"slice\"](\"-1\")"; + JSFuck["E"] = "(RegExp+\"\")[12]"; + JSFuck["F"] = "(+[]+Function)[10]"; + JSFuck["G"] = "(false+Function(\"return Date\")()())[30]"; + JSFuck["H"] = "'H'"; + JSFuck["I"] = "(Infinity+\"\")[0]"; + JSFuck["J"] = "'J'"; + JSFuck["K"] = "'K'"; + JSFuck["L"] = "'L'"; + JSFuck["M"] = "(true+Function(\"return Date\")()())[30]"; + JSFuck["N"] = "(NaN+\"\")[0]"; + JSFuck["O"] = "(NaN+Function(\"return{}\")())[11]"; + JSFuck["P"] = "'P'"; + JSFuck["Q"] = "'Q'"; + JSFuck["R"] = "(+[]+RegExp)[10]"; + JSFuck["S"] = "(+[]+String)[10]"; + JSFuck["T"] = "(NaN+Function(\"return Date\")()())[30]"; + JSFuck["U"] = "(NaN+Function(\"return{}\")()[\"toString\"][\"call\"]())[11]"; + JSFuck["V"] = "'V'"; + JSFuck["W"] = "'W'"; + JSFuck["X"] = "'X'"; + JSFuck["Y"] = "'Y'"; + JSFuck["Z"] = "'Z'"; +})(JSFuck = exports.JSFuck || (exports.JSFuck = {})); + +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var Nodes_1 = __webpack_require__(9); +var NodeUtils_1 = __webpack_require__(4); +var StringLiteralControlFlowStorageCallNode = function (_AbstractCustomNode_) { + _inherits(StringLiteralControlFlowStorageCallNode, _AbstractCustomNode_); + + function StringLiteralControlFlowStorageCallNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, StringLiteralControlFlowStorageCallNode); + + return _possibleConstructorReturn(this, (StringLiteralControlFlowStorageCallNode.__proto__ || Object.getPrototypeOf(StringLiteralControlFlowStorageCallNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(StringLiteralControlFlowStorageCallNode, [{ + key: "initialize", + value: function initialize(controlFlowStorageName, controlFlowStorageKey) { + this.controlFlowStorageName = controlFlowStorageName; + this.controlFlowStorageKey = controlFlowStorageKey; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageName), Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageKey))); + NodeUtils_1.NodeUtils.parentize(structure); + return [structure]; + } + }]); + + return StringLiteralControlFlowStorageCallNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringLiteralControlFlowStorageCallNode.prototype, "controlFlowStorageKey", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringLiteralControlFlowStorageCallNode.prototype, "controlFlowStorageName", void 0); +StringLiteralControlFlowStorageCallNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], StringLiteralControlFlowStorageCallNode); +exports.StringLiteralControlFlowStorageCallNode = StringLiteralControlFlowStorageCallNode; + +/***/ }), +/* 109 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var AbstractCustomNode_1 = __webpack_require__(6); +var Nodes_1 = __webpack_require__(9); +var StringLiteralNode = function (_AbstractCustomNode_) { + _inherits(StringLiteralNode, _AbstractCustomNode_); + + function StringLiteralNode(identifierNameGeneratorFactory, randomGenerator, options) { + _classCallCheck(this, StringLiteralNode); + + return _possibleConstructorReturn(this, (StringLiteralNode.__proto__ || Object.getPrototypeOf(StringLiteralNode)).call(this, identifierNameGeneratorFactory, randomGenerator, options)); + } + + _createClass(StringLiteralNode, [{ + key: "initialize", + value: function initialize(literalValue) { + this.literalValue = literalValue; + } + }, { + key: "getNodeStructure", + value: function getNodeStructure() { + var structure = Nodes_1.Nodes.getLiteralNode(this.literalValue); + return [structure]; + } + }]); + + return StringLiteralNode; +}(AbstractCustomNode_1.AbstractCustomNode); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringLiteralNode.prototype, "literalValue", void 0); +StringLiteralNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], StringLiteralNode); +exports.StringLiteralNode = StringLiteralNode; + +/***/ }), +/* 110 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var IdentifierNameGenerator_1 = __webpack_require__(111); +var HexadecimalIdentifierNameGenerator_1 = __webpack_require__(180); +var MangledIdentifierNameGenerator_1 = __webpack_require__(181); +exports.generatorsModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierNameGenerator).to(HexadecimalIdentifierNameGenerator_1.HexadecimalIdentifierNameGenerator).inSingletonScope().whenTargetNamed(IdentifierNameGenerator_1.IdentifierNameGenerator.HexadecimalIdentifierNameGenerator); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierNameGenerator).to(MangledIdentifierNameGenerator_1.MangledIdentifierNameGenerator).inSingletonScope().whenTargetNamed(IdentifierNameGenerator_1.IdentifierNameGenerator.MangledIdentifierNameGenerator); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator).toFactory(function (context) { + var cache = new Map(); + return function (options) { + if (cache.has(options.mangle)) { + return cache.get(options.mangle); + } + var identifierNameGenerator = void 0; + switch (options.mangle) { + case true: + identifierNameGenerator = context.container.getNamed(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierNameGenerator, IdentifierNameGenerator_1.IdentifierNameGenerator.MangledIdentifierNameGenerator); + break; + case false: + default: + identifierNameGenerator = context.container.getNamed(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierNameGenerator, IdentifierNameGenerator_1.IdentifierNameGenerator.HexadecimalIdentifierNameGenerator); + } + cache.set(options.mangle, identifierNameGenerator); + return identifierNameGenerator; + }; + }); +}); + +/***/ }), +/* 111 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var IdentifierNameGenerator; +(function (IdentifierNameGenerator) { + IdentifierNameGenerator[IdentifierNameGenerator["HexadecimalIdentifierNameGenerator"] = 0] = "HexadecimalIdentifierNameGenerator"; + IdentifierNameGenerator[IdentifierNameGenerator["MangledIdentifierNameGenerator"] = 1] = "MangledIdentifierNameGenerator"; +})(IdentifierNameGenerator = exports.IdentifierNameGenerator || (exports.IdentifierNameGenerator = {})); + +/***/ }), +/* 112 */, +/* 113 */, +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var InversifyContainerFacade_1 = __webpack_require__(14); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +exports.nodeTransformersModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__INodeTransformer).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer)); +}); + +/***/ }), +/* 115 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var InversifyContainerFacade_1 = __webpack_require__(14); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var IdentifierObfuscatingReplacer_1 = __webpack_require__(16); +var LiteralObfuscatingReplacer_1 = __webpack_require__(40); +var NodeTransformer_1 = __webpack_require__(18); +var BaseIdentifierObfuscatingReplacer_1 = __webpack_require__(116); +var BooleanLiteralObfuscatingReplacer_1 = __webpack_require__(117); +var CatchClauseTransformer_1 = __webpack_require__(118); +var ClassDeclarationTransformer_1 = __webpack_require__(119); +var FunctionDeclarationTransformer_1 = __webpack_require__(120); +var FunctionTransformer_1 = __webpack_require__(121); +var LabeledStatementTransformer_1 = __webpack_require__(122); +var LiteralTransformer_1 = __webpack_require__(123); +var NumberLiteralObfuscatingReplacer_1 = __webpack_require__(124); +var ObjectExpressionTransformer_1 = __webpack_require__(125); +var StringLiteralObfuscatingReplacer_1 = __webpack_require__(126); +var VariableDeclarationTransformer_1 = __webpack_require__(127); +exports.obfuscatingTransformersModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(CatchClauseTransformer_1.CatchClauseTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.CatchClauseTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ClassDeclarationTransformer_1.ClassDeclarationTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ClassDeclarationTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(FunctionDeclarationTransformer_1.FunctionDeclarationTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.FunctionDeclarationTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(FunctionTransformer_1.FunctionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.FunctionTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(LabeledStatementTransformer_1.LabeledStatementTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.LabeledStatementTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(LiteralTransformer_1.LiteralTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.LiteralTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ObjectExpressionTransformer_1.ObjectExpressionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ObjectExpressionTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(VariableDeclarationTransformer_1.VariableDeclarationTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.VariableDeclarationTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatingReplacer).to(BooleanLiteralObfuscatingReplacer_1.BooleanLiteralObfuscatingReplacer).whenTargetNamed(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.BooleanLiteralObfuscatingReplacer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatingReplacer).to(NumberLiteralObfuscatingReplacer_1.NumberLiteralObfuscatingReplacer).whenTargetNamed(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.NumberLiteralObfuscatingReplacer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatingReplacer).to(StringLiteralObfuscatingReplacer_1.StringLiteralObfuscatingReplacer).whenTargetNamed(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.StringLiteralObfuscatingReplacer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierObfuscatingReplacer).to(BaseIdentifierObfuscatingReplacer_1.BaseIdentifierObfuscatingReplacer).whenTargetNamed(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatingReplacer).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatingReplacer)); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierObfuscatingReplacer)); +}); + +/***/ }), +/* 116 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractObfuscatingReplacer_1 = __webpack_require__(26); +var Nodes_1 = __webpack_require__(9); +var BaseIdentifierObfuscatingReplacer = function (_AbstractObfuscatingR) { + _inherits(BaseIdentifierObfuscatingReplacer, _AbstractObfuscatingR); + + function BaseIdentifierObfuscatingReplacer(identifierNameGeneratorFactory, options) { + _classCallCheck(this, BaseIdentifierObfuscatingReplacer); + + var _this = _possibleConstructorReturn(this, (BaseIdentifierObfuscatingReplacer.__proto__ || Object.getPrototypeOf(BaseIdentifierObfuscatingReplacer)).call(this, options)); + + _this.namesMap = new Map(); + _this.identifierNameGenerator = identifierNameGeneratorFactory(options); + return _this; + } + + _createClass(BaseIdentifierObfuscatingReplacer, [{ + key: "replace", + value: function replace(nodeValue, nodeIdentifier) { + var mapKey = nodeValue + "-" + String(nodeIdentifier); + if (this.namesMap.has(mapKey)) { + nodeValue = this.namesMap.get(mapKey); + } + return Nodes_1.Nodes.getIdentifierNode(nodeValue); + } + }, { + key: "storeNames", + value: function storeNames(nodeName, nodeIdentifier) { + if (this.isReservedName(nodeName)) { + return; + } + this.namesMap.set(nodeName + "-" + String(nodeIdentifier), this.identifierNameGenerator.generate(6)); + } + }, { + key: "isReservedName", + value: function isReservedName(name) { + return this.options.reservedNames.some(function (reservedName) { + return new RegExp(reservedName, 'g').exec(name) !== null; + }); + } + }]); + + return BaseIdentifierObfuscatingReplacer; +}(AbstractObfuscatingReplacer_1.AbstractObfuscatingReplacer); +BaseIdentifierObfuscatingReplacer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], BaseIdentifierObfuscatingReplacer); +exports.BaseIdentifierObfuscatingReplacer = BaseIdentifierObfuscatingReplacer; + +/***/ }), +/* 117 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractObfuscatingReplacer_1 = __webpack_require__(26); +var Nodes_1 = __webpack_require__(9); +var BooleanLiteralObfuscatingReplacer = BooleanLiteralObfuscatingReplacer_1 = function (_AbstractObfuscatingR) { + _inherits(BooleanLiteralObfuscatingReplacer, _AbstractObfuscatingR); + + function BooleanLiteralObfuscatingReplacer(options) { + _classCallCheck(this, BooleanLiteralObfuscatingReplacer); + + return _possibleConstructorReturn(this, (BooleanLiteralObfuscatingReplacer.__proto__ || Object.getPrototypeOf(BooleanLiteralObfuscatingReplacer)).call(this, options)); + } + + _createClass(BooleanLiteralObfuscatingReplacer, [{ + key: "replace", + value: function replace(nodeValue) { + return nodeValue ? BooleanLiteralObfuscatingReplacer_1.getTrueUnaryExpressionNode() : BooleanLiteralObfuscatingReplacer_1.getFalseUnaryExpressionNode(); + } + }], [{ + key: "getTrueUnaryExpressionNode", + value: function getTrueUnaryExpressionNode() { + return Nodes_1.Nodes.getUnaryExpressionNode('!', BooleanLiteralObfuscatingReplacer_1.getFalseUnaryExpressionNode()); + } + }, { + key: "getFalseUnaryExpressionNode", + value: function getFalseUnaryExpressionNode() { + return Nodes_1.Nodes.getUnaryExpressionNode('!', Nodes_1.Nodes.getArrayExpressionNode()); + } + }]); + + return BooleanLiteralObfuscatingReplacer; +}(AbstractObfuscatingReplacer_1.AbstractObfuscatingReplacer); +BooleanLiteralObfuscatingReplacer = BooleanLiteralObfuscatingReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], BooleanLiteralObfuscatingReplacer); +exports.BooleanLiteralObfuscatingReplacer = BooleanLiteralObfuscatingReplacer; +var BooleanLiteralObfuscatingReplacer_1; + +/***/ }), +/* 118 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var IdentifierObfuscatingReplacer_1 = __webpack_require__(16); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var CatchClauseTransformer = function (_AbstractNodeTransfor) { + _inherits(CatchClauseTransformer, _AbstractNodeTransfor); + + function CatchClauseTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) { + _classCallCheck(this, CatchClauseTransformer); + + var _this = _possibleConstructorReturn(this, (CatchClauseTransformer.__proto__ || Object.getPrototypeOf(CatchClauseTransformer)).call(this, randomGenerator, options)); + + _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer); + return _this; + } + + _createClass(CatchClauseTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isCatchClauseNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(catchClauseNode, parentNode) { + var nodeIdentifier = this.nodeIdentifier++; + this.storeCatchClauseParam(catchClauseNode, nodeIdentifier); + this.replaceCatchClauseParam(catchClauseNode, nodeIdentifier); + return catchClauseNode; + } + }, { + key: "storeCatchClauseParam", + value: function storeCatchClauseParam(catchClauseNode, nodeIdentifier) { + if (NodeGuards_1.NodeGuards.isIdentifierNode(catchClauseNode.param)) { + this.identifierObfuscatingReplacer.storeNames(catchClauseNode.param.name, nodeIdentifier); + } + } + }, { + key: "replaceCatchClauseParam", + value: function replaceCatchClauseParam(catchClauseNode, nodeIdentifier) { + var _this3 = this; + + estraverse.replace(catchClauseNode, { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode)) { + var newIdentifier = _this3.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier); + var newIdentifierName = newIdentifier.name; + if (node.name !== newIdentifierName) { + node.name = newIdentifierName; + node.obfuscatedNode = true; + } + } + } + }); + } + }]); + + return CatchClauseTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +CatchClauseTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CatchClauseTransformer); +exports.CatchClauseTransformer = CatchClauseTransformer; + +/***/ }), +/* 119 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var IdentifierObfuscatingReplacer_1 = __webpack_require__(16); +var NodeType_1 = __webpack_require__(10); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var NodeUtils_1 = __webpack_require__(4); +var ClassDeclarationTransformer = function (_AbstractNodeTransfor) { + _inherits(ClassDeclarationTransformer, _AbstractNodeTransfor); + + function ClassDeclarationTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) { + _classCallCheck(this, ClassDeclarationTransformer); + + var _this = _possibleConstructorReturn(this, (ClassDeclarationTransformer.__proto__ || Object.getPrototypeOf(ClassDeclarationTransformer)).call(this, randomGenerator, options)); + + _this.replaceableIdentifiers = new Map(); + _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer); + return _this; + } + + _createClass(ClassDeclarationTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isClassDeclarationNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(classDeclarationNode, parentNode) { + var nodeIdentifier = this.nodeIdentifier++; + var blockScopeNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(classDeclarationNode)[0]; + if (!this.options.renameGlobals && blockScopeNode.type === NodeType_1.NodeType.Program) { + return classDeclarationNode; + } + this.storeClassName(classDeclarationNode, nodeIdentifier); + if (this.replaceableIdentifiers.has(blockScopeNode)) { + this.replaceScopeCachedIdentifiers(blockScopeNode, nodeIdentifier); + } else { + this.replaceScopeIdentifiers(blockScopeNode, nodeIdentifier); + } + return classDeclarationNode; + } + }, { + key: "storeClassName", + value: function storeClassName(classDeclarationNode, nodeIdentifier) { + this.identifierObfuscatingReplacer.storeNames(classDeclarationNode.id.name, nodeIdentifier); + } + }, { + key: "replaceScopeCachedIdentifiers", + value: function replaceScopeCachedIdentifiers(blockScopeNode, nodeIdentifier) { + var _this3 = this; + + var cachedReplaceableIdentifiers = this.replaceableIdentifiers.get(blockScopeNode); + cachedReplaceableIdentifiers.forEach(function (replaceableIdentifier) { + var newReplaceableIdentifier = _this3.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier); + replaceableIdentifier.name = newReplaceableIdentifier.name; + }); + } + }, { + key: "replaceScopeIdentifiers", + value: function replaceScopeIdentifiers(blockScopeNode, nodeIdentifier) { + var _this4 = this; + + var storedReplaceableIdentifiers = []; + estraverse.replace(blockScopeNode, { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode)) { + var newIdentifier = _this4.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier); + var newIdentifierName = newIdentifier.name; + if (node.name !== newIdentifierName) { + node.name = newIdentifierName; + } else { + storedReplaceableIdentifiers.push(node); + } + } + } + }); + this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiers); + } + }]); + + return ClassDeclarationTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +ClassDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ClassDeclarationTransformer); +exports.ClassDeclarationTransformer = ClassDeclarationTransformer; + +/***/ }), +/* 120 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var IdentifierObfuscatingReplacer_1 = __webpack_require__(16); +var NodeType_1 = __webpack_require__(10); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var NodeUtils_1 = __webpack_require__(4); +var FunctionDeclarationTransformer = function (_AbstractNodeTransfor) { + _inherits(FunctionDeclarationTransformer, _AbstractNodeTransfor); + + function FunctionDeclarationTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) { + _classCallCheck(this, FunctionDeclarationTransformer); + + var _this = _possibleConstructorReturn(this, (FunctionDeclarationTransformer.__proto__ || Object.getPrototypeOf(FunctionDeclarationTransformer)).call(this, randomGenerator, options)); + + _this.replaceableIdentifiers = new Map(); + _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer); + return _this; + } + + _createClass(FunctionDeclarationTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(functionDeclarationNode, parentNode) { + var nodeIdentifier = this.nodeIdentifier++; + var blockScopeNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(functionDeclarationNode)[0]; + if (!this.options.renameGlobals && blockScopeNode.type === NodeType_1.NodeType.Program) { + return functionDeclarationNode; + } + this.storeFunctionName(functionDeclarationNode, nodeIdentifier); + if (this.replaceableIdentifiers.has(blockScopeNode)) { + this.replaceScopeCachedIdentifiers(blockScopeNode, nodeIdentifier); + } else { + this.replaceScopeIdentifiers(blockScopeNode, nodeIdentifier); + } + return functionDeclarationNode; + } + }, { + key: "storeFunctionName", + value: function storeFunctionName(functionDeclarationNode, nodeIdentifier) { + this.identifierObfuscatingReplacer.storeNames(functionDeclarationNode.id.name, nodeIdentifier); + } + }, { + key: "replaceScopeCachedIdentifiers", + value: function replaceScopeCachedIdentifiers(blockScopeNode, nodeIdentifier) { + var _this3 = this; + + var cachedReplaceableIdentifiers = this.replaceableIdentifiers.get(blockScopeNode); + cachedReplaceableIdentifiers.forEach(function (replaceableIdentifier) { + var newReplaceableIdentifier = _this3.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier); + replaceableIdentifier.name = newReplaceableIdentifier.name; + }); + } + }, { + key: "replaceScopeIdentifiers", + value: function replaceScopeIdentifiers(blockScopeNode, nodeIdentifier) { + var _this4 = this; + + var storedReplaceableIdentifiers = []; + estraverse.replace(blockScopeNode, { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode)) { + var newIdentifier = _this4.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier); + var newIdentifierName = newIdentifier.name; + if (node.name !== newIdentifierName) { + node.name = newIdentifierName; + } else { + storedReplaceableIdentifiers.push(node); + } + } + } + }); + this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiers); + } + }]); + + return FunctionDeclarationTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +FunctionDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], FunctionDeclarationTransformer); +exports.FunctionDeclarationTransformer = FunctionDeclarationTransformer; + +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var IdentifierObfuscatingReplacer_1 = __webpack_require__(16); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var FunctionTransformer = function (_AbstractNodeTransfor) { + _inherits(FunctionTransformer, _AbstractNodeTransfor); + + function FunctionTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) { + _classCallCheck(this, FunctionTransformer); + + var _this = _possibleConstructorReturn(this, (FunctionTransformer.__proto__ || Object.getPrototypeOf(FunctionTransformer)).call(this, randomGenerator, options)); + + _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer); + return _this; + } + + _createClass(FunctionTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && (NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node) || NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) || NodeGuards_1.NodeGuards.isArrowFunctionExpressionNode(node))) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(functionNode, parentNode) { + var nodeIdentifier = this.nodeIdentifier++; + this.storeFunctionParams(functionNode, nodeIdentifier); + this.replaceFunctionParams(functionNode, nodeIdentifier); + return functionNode; + } + }, { + key: "storeFunctionParams", + value: function storeFunctionParams(functionNode, nodeIdentifier) { + var _this3 = this; + + functionNode.params.forEach(function (paramsNode) { + if (NodeGuards_1.NodeGuards.isObjectPatternNode(paramsNode)) { + return estraverse.VisitorOption.Skip; + } + estraverse.traverse(paramsNode, { + enter: function enter(node) { + if (NodeGuards_1.NodeGuards.isAssignmentPatternNode(node) && NodeGuards_1.NodeGuards.isIdentifierNode(node.left)) { + _this3.identifierObfuscatingReplacer.storeNames(node.left.name, nodeIdentifier); + return estraverse.VisitorOption.Skip; + } + if (NodeGuards_1.NodeGuards.isIdentifierNode(node)) { + _this3.identifierObfuscatingReplacer.storeNames(node.name, nodeIdentifier); + } + } + }); + }); + } + }, { + key: "addIdentifiersToIgnoredIdentifierNamesSet", + value: function addIdentifiersToIgnoredIdentifierNamesSet(properties, ignoredIdentifierNamesSet) { + properties.forEach(function (property) { + if (!NodeGuards_1.NodeGuards.isIdentifierNode(property.key)) { + return; + } + ignoredIdentifierNamesSet.add(property.key.name); + }); + } + }, { + key: "replaceFunctionParams", + value: function replaceFunctionParams(functionNode, nodeIdentifier) { + var _this4 = this; + + var ignoredIdentifierNamesSet = new Set(); + var replaceVisitor = { + enter: function enter(node, parentNode) { + if (NodeGuards_1.NodeGuards.isObjectPatternNode(node)) { + _this4.addIdentifiersToIgnoredIdentifierNamesSet(node.properties, ignoredIdentifierNamesSet); + } + if (parentNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode) && !ignoredIdentifierNamesSet.has(node.name)) { + var newIdentifier = _this4.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier); + var newIdentifierName = newIdentifier.name; + if (node.name !== newIdentifierName) { + node.name = newIdentifierName; + node.obfuscatedNode = true; + } + } + } + }; + functionNode.params.forEach(function (paramsNode) { + return estraverse.replace(paramsNode, replaceVisitor); + }); + estraverse.replace(functionNode.body, replaceVisitor); + } + }]); + + return FunctionTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +FunctionTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], FunctionTransformer); +exports.FunctionTransformer = FunctionTransformer; + +/***/ }), +/* 122 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var IdentifierObfuscatingReplacer_1 = __webpack_require__(16); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var LabeledStatementTransformer = function (_AbstractNodeTransfor) { + _inherits(LabeledStatementTransformer, _AbstractNodeTransfor); + + function LabeledStatementTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) { + _classCallCheck(this, LabeledStatementTransformer); + + var _this = _possibleConstructorReturn(this, (LabeledStatementTransformer.__proto__ || Object.getPrototypeOf(LabeledStatementTransformer)).call(this, randomGenerator, options)); + + _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer); + return _this; + } + + _createClass(LabeledStatementTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isLabeledStatementNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(labeledStatementNode, parentNode) { + var nodeIdentifier = this.nodeIdentifier++; + this.storeLabeledStatementName(labeledStatementNode, nodeIdentifier); + this.replaceLabeledStatementName(labeledStatementNode, nodeIdentifier); + return labeledStatementNode; + } + }, { + key: "storeLabeledStatementName", + value: function storeLabeledStatementName(labeledStatementNode, nodeIdentifier) { + this.identifierObfuscatingReplacer.storeNames(labeledStatementNode.label.name, nodeIdentifier); + } + }, { + key: "replaceLabeledStatementName", + value: function replaceLabeledStatementName(labeledStatementNode, nodeIdentifier) { + var _this3 = this; + + estraverse.replace(labeledStatementNode, { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isLabelIdentifierNode(node, parentNode)) { + var newIdentifier = _this3.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier); + node.name = newIdentifier.name; + } + } + }); + } + }]); + + return LabeledStatementTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +LabeledStatementTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], LabeledStatementTransformer); +exports.LabeledStatementTransformer = LabeledStatementTransformer; + +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var LiteralObfuscatingReplacer_1 = __webpack_require__(40); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var LiteralTransformer = function (_AbstractNodeTransfor) { + _inherits(LiteralTransformer, _AbstractNodeTransfor); + + function LiteralTransformer(literalObfuscatingReplacerFactory, randomGenerator, options) { + _classCallCheck(this, LiteralTransformer); + + var _this = _possibleConstructorReturn(this, (LiteralTransformer.__proto__ || Object.getPrototypeOf(LiteralTransformer)).call(this, randomGenerator, options)); + + _this.literalObfuscatingReplacerFactory = literalObfuscatingReplacerFactory; + return _this; + } + + _createClass(LiteralTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isLiteralNode(node) && !node.obfuscatedNode) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(literalNode, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isPropertyNode(parentNode) && parentNode.key === literalNode) { + return literalNode; + } + switch (_typeof(literalNode.value)) { + case 'boolean': + return this.literalObfuscatingReplacerFactory(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.BooleanLiteralObfuscatingReplacer).replace(literalNode.value); + case 'number': + return this.literalObfuscatingReplacerFactory(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.NumberLiteralObfuscatingReplacer).replace(literalNode.value); + case 'string': + return this.literalObfuscatingReplacerFactory(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.StringLiteralObfuscatingReplacer).replace(literalNode.value); + default: + return literalNode; + } + } + }]); + + return LiteralTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +LiteralTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], LiteralTransformer); +exports.LiteralTransformer = LiteralTransformer; + +/***/ }), +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractObfuscatingReplacer_1 = __webpack_require__(26); +var Nodes_1 = __webpack_require__(9); +var Utils_1 = __webpack_require__(21); +var NumberLiteralObfuscatingReplacer = function (_AbstractObfuscatingR) { + _inherits(NumberLiteralObfuscatingReplacer, _AbstractObfuscatingR); + + function NumberLiteralObfuscatingReplacer(options) { + _classCallCheck(this, NumberLiteralObfuscatingReplacer); + + var _this = _possibleConstructorReturn(this, (NumberLiteralObfuscatingReplacer.__proto__ || Object.getPrototypeOf(NumberLiteralObfuscatingReplacer)).call(this, options)); + + _this.numberLiteralCache = new Map(); + return _this; + } + + _createClass(NumberLiteralObfuscatingReplacer, [{ + key: "replace", + value: function replace(nodeValue) { + var rawValue = void 0; + if (this.numberLiteralCache.has(nodeValue)) { + rawValue = this.numberLiteralCache.get(nodeValue); + } else { + if (!Utils_1.Utils.isCeilNumber(nodeValue)) { + rawValue = String(nodeValue); + } else { + rawValue = "" + Utils_1.Utils.hexadecimalPrefix + Utils_1.Utils.decToHex(nodeValue); + } + this.numberLiteralCache.set(nodeValue, rawValue); + } + return Nodes_1.Nodes.getLiteralNode(nodeValue, rawValue); + } + }]); + + return NumberLiteralObfuscatingReplacer; +}(AbstractObfuscatingReplacer_1.AbstractObfuscatingReplacer); +NumberLiteralObfuscatingReplacer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], NumberLiteralObfuscatingReplacer); +exports.NumberLiteralObfuscatingReplacer = NumberLiteralObfuscatingReplacer; + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var NodeType_1 = __webpack_require__(10); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var ObjectExpressionTransformer = ObjectExpressionTransformer_1 = function (_AbstractNodeTransfor) { + _inherits(ObjectExpressionTransformer, _AbstractNodeTransfor); + + function ObjectExpressionTransformer(randomGenerator, options) { + _classCallCheck(this, ObjectExpressionTransformer); + + return _possibleConstructorReturn(this, (ObjectExpressionTransformer.__proto__ || Object.getPrototypeOf(ObjectExpressionTransformer)).call(this, randomGenerator, options)); + } + + _createClass(ObjectExpressionTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isObjectExpressionNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(objectExpressionNode, parentNode) { + objectExpressionNode.properties.forEach(function (property) { + if (property.computed) { + return; + } + if (property.shorthand) { + property.shorthand = false; + } + if (NodeGuards_1.NodeGuards.isIdentifierNode(property.key)) { + property.key = ObjectExpressionTransformer_1.transformIdentifierPropertyKey(property.key); + } + }); + return objectExpressionNode; + } + }], [{ + key: "transformIdentifierPropertyKey", + value: function transformIdentifierPropertyKey(node) { + return { + type: NodeType_1.NodeType.Literal, + value: node.name, + raw: "'" + node.name + "'" + }; + } + }]); + + return ObjectExpressionTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +ObjectExpressionTransformer = ObjectExpressionTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ObjectExpressionTransformer); +exports.ObjectExpressionTransformer = ObjectExpressionTransformer; +var ObjectExpressionTransformer_1; + +/***/ }), +/* 126 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var StringArrayEncoding_1 = __webpack_require__(24); +var AbstractObfuscatingReplacer_1 = __webpack_require__(26); +var Nodes_1 = __webpack_require__(9); +var Utils_1 = __webpack_require__(21); +var StringLiteralObfuscatingReplacer = StringLiteralObfuscatingReplacer_1 = function (_AbstractObfuscatingR) { + _inherits(StringLiteralObfuscatingReplacer, _AbstractObfuscatingR); + + function StringLiteralObfuscatingReplacer(stringArrayStorage, escapeSequenceEncoder, randomGenerator, cryptUtils, options) { + _classCallCheck(this, StringLiteralObfuscatingReplacer); + + var _this = _possibleConstructorReturn(this, (StringLiteralObfuscatingReplacer.__proto__ || Object.getPrototypeOf(StringLiteralObfuscatingReplacer)).call(this, options)); + + _this.nodesCache = new Map(); + _this.stringLiteralHexadecimalIndexCache = new Map(); + _this.stringArrayStorage = stringArrayStorage; + _this.escapeSequenceEncoder = escapeSequenceEncoder; + _this.randomGenerator = randomGenerator; + _this.cryptUtils = cryptUtils; + _this.rc4Keys = _this.randomGenerator.getRandomGenerator().n(function () { + return _this.randomGenerator.getRandomGenerator().string({ + length: StringLiteralObfuscatingReplacer_1.rc4KeyLength + }); + }, StringLiteralObfuscatingReplacer_1.rc4KeysCount); + return _this; + } + + _createClass(StringLiteralObfuscatingReplacer, [{ + key: "replace", + value: function replace(nodeValue) { + var useStringArray = this.canUseStringArray(nodeValue); + var cacheKey = nodeValue + "-" + String(useStringArray); + var useCacheValue = this.nodesCache.has(cacheKey) && this.options.stringArrayEncoding !== StringArrayEncoding_1.StringArrayEncoding.Rc4; + if (useCacheValue) { + return this.nodesCache.get(cacheKey); + } + var resultNode = useStringArray ? this.replaceWithStringArrayCallNode(nodeValue) : this.replaceWithLiteralNode(nodeValue); + this.nodesCache.set(cacheKey, resultNode); + return resultNode; + } + }, { + key: "canUseStringArray", + value: function canUseStringArray(nodeValue) { + return this.options.stringArray && nodeValue.length >= StringLiteralObfuscatingReplacer_1.minimumLengthForStringArray && this.randomGenerator.getMathRandom() <= this.options.stringArrayThreshold; + } + }, { + key: "getStringArrayHexadecimalIndex", + value: function getStringArrayHexadecimalIndex(value, stringArrayStorageLength) { + if (this.stringLiteralHexadecimalIndexCache.has(value)) { + return { + fromCache: true, + index: this.stringLiteralHexadecimalIndexCache.get(value) + }; + } + var hexadecimalRawIndex = Utils_1.Utils.decToHex(stringArrayStorageLength); + var hexadecimalIndex = "" + Utils_1.Utils.hexadecimalPrefix + hexadecimalRawIndex; + this.stringLiteralHexadecimalIndexCache.set(value, hexadecimalIndex); + return { + fromCache: false, + index: hexadecimalIndex + }; + } + }, { + key: "getEncodedValue", + value: function getEncodedValue(value) { + var encodedValue = void 0, + key = null; + switch (this.options.stringArrayEncoding) { + case StringArrayEncoding_1.StringArrayEncoding.Rc4: + key = this.randomGenerator.getRandomGenerator().pickone(this.rc4Keys); + encodedValue = this.cryptUtils.btoa(this.cryptUtils.rc4(value, key)); + break; + case StringArrayEncoding_1.StringArrayEncoding.Base64: + encodedValue = this.cryptUtils.btoa(value); + break; + default: + encodedValue = value; + } + return { encodedValue: encodedValue, key: key }; + } + }, { + key: "replaceWithLiteralNode", + value: function replaceWithLiteralNode(value) { + return Nodes_1.Nodes.getLiteralNode(this.escapeSequenceEncoder.encode(value, this.options.unicodeEscapeSequence)); + } + }, { + key: "replaceWithStringArrayCallNode", + value: function replaceWithStringArrayCallNode(value) { + var _getEncodedValue = this.getEncodedValue(value), + encodedValue = _getEncodedValue.encodedValue, + key = _getEncodedValue.key; + + var escapedValue = this.escapeSequenceEncoder.encode(encodedValue, this.options.unicodeEscapeSequence); + var stringArrayStorageLength = this.stringArrayStorage.getLength(); + var stringArrayStorageCallsWrapperName = this.stringArrayStorage.getStorageId().split('|')[1]; + + var _getStringArrayHexade = this.getStringArrayHexadecimalIndex(escapedValue, stringArrayStorageLength), + fromCache = _getStringArrayHexade.fromCache, + index = _getStringArrayHexade.index; + + if (!fromCache) { + this.stringArrayStorage.set(stringArrayStorageLength, escapedValue); + } + var callExpressionArgs = [StringLiteralObfuscatingReplacer_1.getHexadecimalLiteralNode(index)]; + if (key) { + callExpressionArgs.push(StringLiteralObfuscatingReplacer_1.getRc4KeyLiteralNode(this.escapeSequenceEncoder.encode(key, this.options.unicodeEscapeSequence))); + } + return Nodes_1.Nodes.getCallExpressionNode(Nodes_1.Nodes.getIdentifierNode(stringArrayStorageCallsWrapperName), callExpressionArgs); + } + }], [{ + key: "getHexadecimalLiteralNode", + value: function getHexadecimalLiteralNode(hexadecimalIndex) { + var hexadecimalLiteralNode = Nodes_1.Nodes.getLiteralNode(hexadecimalIndex); + hexadecimalLiteralNode.obfuscatedNode = true; + return hexadecimalLiteralNode; + } + }, { + key: "getRc4KeyLiteralNode", + value: function getRc4KeyLiteralNode(literalValue) { + var rc4KeyLiteralNode = Nodes_1.Nodes.getLiteralNode(literalValue); + rc4KeyLiteralNode.obfuscatedNode = true; + return rc4KeyLiteralNode; + } + }]); + + return StringLiteralObfuscatingReplacer; +}(AbstractObfuscatingReplacer_1.AbstractObfuscatingReplacer); +StringLiteralObfuscatingReplacer.minimumLengthForStringArray = 3; +StringLiteralObfuscatingReplacer.rc4KeyLength = 4; +StringLiteralObfuscatingReplacer.rc4KeysCount = 50; +StringLiteralObfuscatingReplacer = StringLiteralObfuscatingReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.TStringArrayStorage)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ICryptUtils)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object, Object])], StringLiteralObfuscatingReplacer); +exports.StringLiteralObfuscatingReplacer = StringLiteralObfuscatingReplacer; +var StringLiteralObfuscatingReplacer_1; + +/***/ }), +/* 127 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var IdentifierObfuscatingReplacer_1 = __webpack_require__(16); +var NodeType_1 = __webpack_require__(10); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeGuards_1 = __webpack_require__(5); +var NodeUtils_1 = __webpack_require__(4); +var VariableDeclarationTransformer = function (_AbstractNodeTransfor) { + _inherits(VariableDeclarationTransformer, _AbstractNodeTransfor); + + function VariableDeclarationTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) { + _classCallCheck(this, VariableDeclarationTransformer); + + var _this = _possibleConstructorReturn(this, (VariableDeclarationTransformer.__proto__ || Object.getPrototypeOf(VariableDeclarationTransformer)).call(this, randomGenerator, options)); + + _this.replaceableIdentifiers = new Map(); + _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer); + return _this; + } + + _createClass(VariableDeclarationTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + if (parentNode && NodeGuards_1.NodeGuards.isVariableDeclarationNode(node)) { + return _this2.transformNode(node, parentNode); + } + } + }; + } + }, { + key: "transformNode", + value: function transformNode(variableDeclarationNode, parentNode) { + var blockScopeNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(variableDeclarationNode)[0]; + if (!this.options.renameGlobals && blockScopeNode.type === NodeType_1.NodeType.Program) { + return variableDeclarationNode; + } + var nodeIdentifier = this.nodeIdentifier++; + var scopeNode = variableDeclarationNode.kind === 'var' ? blockScopeNode : parentNode; + this.storeVariableNames(variableDeclarationNode, nodeIdentifier); + if (this.replaceableIdentifiers.has(scopeNode)) { + this.replaceScopeCachedIdentifiers(scopeNode, nodeIdentifier); + } else { + this.replaceScopeIdentifiers(scopeNode, nodeIdentifier); + } + return variableDeclarationNode; + } + }, { + key: "storeVariableNames", + value: function storeVariableNames(variableDeclarationNode, nodeIdentifier) { + var _this3 = this; + + variableDeclarationNode.declarations.forEach(function (declarationNode) { + if (NodeGuards_1.NodeGuards.isObjectPatternNode(declarationNode.id)) { + return estraverse.VisitorOption.Skip; + } + estraverse.traverse(declarationNode.id, { + enter: function enter(node) { + if (NodeGuards_1.NodeGuards.isIdentifierNode(node)) { + _this3.identifierObfuscatingReplacer.storeNames(node.name, nodeIdentifier); + } + } + }); + }); + } + }, { + key: "replaceScopeCachedIdentifiers", + value: function replaceScopeCachedIdentifiers(scopeNode, nodeIdentifier) { + var _this4 = this; + + var cachedReplaceableIdentifiers = this.replaceableIdentifiers.get(scopeNode); + cachedReplaceableIdentifiers.forEach(function (replaceableIdentifier) { + var newReplaceableIdentifier = _this4.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier); + replaceableIdentifier.name = newReplaceableIdentifier.name; + }); + } + }, { + key: "replaceScopeIdentifiers", + value: function replaceScopeIdentifiers(blockScopeNode, nodeIdentifier) { + var _this5 = this; + + var storedReplaceableIdentifiers = []; + estraverse.replace(blockScopeNode, { + enter: function enter(node, parentNode) { + if (parentNode && !node.obfuscatedNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode)) { + var newIdentifier = _this5.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier); + var newIdentifierName = newIdentifier.name; + if (node.name !== newIdentifierName) { + node.name = newIdentifierName; + } else { + storedReplaceableIdentifiers.push(node); + } + } + } + }); + this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiers); + } + }]); + + return VariableDeclarationTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +VariableDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], VariableDeclarationTransformer); +exports.VariableDeclarationTransformer = VariableDeclarationTransformer; + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var InversifyContainerFacade_1 = __webpack_require__(14); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var NodeTransformer_1 = __webpack_require__(18); +var ObfuscatingGuard_1 = __webpack_require__(41); +var BlackListObfuscatingGuard_1 = __webpack_require__(129); +var ConditionalCommentObfuscatingGuard_1 = __webpack_require__(130); +var ObfuscatingGuardsTransformer_1 = __webpack_require__(131); +var ParentificationTransformer_1 = __webpack_require__(132); +exports.preparingTransformersModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ObfuscatingGuardsTransformer_1.ObfuscatingGuardsTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ObfuscatingGuardsTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ParentificationTransformer_1.ParentificationTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ParentificationTransformer); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeGuard).to(BlackListObfuscatingGuard_1.BlackListObfuscatingGuard).inSingletonScope().whenTargetNamed(ObfuscatingGuard_1.ObfuscatingGuard.BlackListNodeGuard); + bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeGuard).to(ConditionalCommentObfuscatingGuard_1.ConditionalCommentObfuscatingGuard).inSingletonScope().whenTargetNamed(ObfuscatingGuard_1.ObfuscatingGuard.ConditionalCommentNodeGuard); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__INodeGuard).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.INodeGuard)); +}); + +/***/ }), +/* 129 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var NodeGuards_1 = __webpack_require__(5); +var BlackListObfuscatingGuard = BlackListObfuscatingGuard_1 = function () { + function BlackListObfuscatingGuard() { + _classCallCheck(this, BlackListObfuscatingGuard); + + this.blackListGuardsLength = BlackListObfuscatingGuard_1.blackListGuards.length; + } + + _createClass(BlackListObfuscatingGuard, [{ + key: "check", + value: function check(node) { + for (var i = 0; i < this.blackListGuardsLength; i++) { + if (BlackListObfuscatingGuard_1.blackListGuards[i](node)) { + return false; + } + } + return true; + } + }]); + + return BlackListObfuscatingGuard; +}(); +BlackListObfuscatingGuard.blackListGuards = [NodeGuards_1.NodeGuards.isUseStrictOperator]; +BlackListObfuscatingGuard = BlackListObfuscatingGuard_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__metadata("design:paramtypes", [])], BlackListObfuscatingGuard); +exports.BlackListObfuscatingGuard = BlackListObfuscatingGuard; +var BlackListObfuscatingGuard_1; + +/***/ }), +/* 130 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ConditionalCommentObfuscatingGuard = ConditionalCommentObfuscatingGuard_1 = function () { + function ConditionalCommentObfuscatingGuard() { + _classCallCheck(this, ConditionalCommentObfuscatingGuard); + + this.obfuscationAllowedForCurrentNode = true; + this.obfuscationAllowedForNextNode = null; + } + + _createClass(ConditionalCommentObfuscatingGuard, [{ + key: "check", + value: function check(node) { + if (this.obfuscationAllowedForNextNode) { + this.obfuscationAllowedForCurrentNode = this.obfuscationAllowedForNextNode; + this.obfuscationAllowedForNextNode = null; + } + if (!node.leadingComments && !node.trailingComments) { + return this.obfuscationAllowedForCurrentNode; + } + var leadingComments = node.leadingComments; + var trailingComments = node.trailingComments; + if (leadingComments) { + this.obfuscationAllowedForCurrentNode = this.checkComments(leadingComments); + } + if (trailingComments) { + this.obfuscationAllowedForNextNode = this.checkComments(trailingComments); + } + return this.obfuscationAllowedForCurrentNode; + } + }, { + key: "checkComments", + value: function checkComments(comments) { + var commentsLength = comments.length; + var obfuscationAllowed = this.obfuscationAllowedForCurrentNode; + for (var i = 0; i < commentsLength; i++) { + var comment = comments[i]; + if (ConditionalCommentObfuscatingGuard_1.obfuscationEnableCommentRegExp.test(comment.value)) { + obfuscationAllowed = true; + continue; + } + if (ConditionalCommentObfuscatingGuard_1.obfuscationDisableCommentRegExp.test(comment.value)) { + obfuscationAllowed = false; + } + } + return obfuscationAllowed; + } + }]); + + return ConditionalCommentObfuscatingGuard; +}(); +ConditionalCommentObfuscatingGuard.obfuscationEnableCommentRegExp = new RegExp('javascript-obfuscator *: *enable'); +ConditionalCommentObfuscatingGuard.obfuscationDisableCommentRegExp = new RegExp('javascript-obfuscator *: *disable'); +ConditionalCommentObfuscatingGuard = ConditionalCommentObfuscatingGuard_1 = tslib_1.__decorate([inversify_1.injectable()], ConditionalCommentObfuscatingGuard); +exports.ConditionalCommentObfuscatingGuard = ConditionalCommentObfuscatingGuard; +var ConditionalCommentObfuscatingGuard_1; + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ObfuscatingGuard_1 = __webpack_require__(41); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var ObfuscatingGuardsTransformer = ObfuscatingGuardsTransformer_1 = function (_AbstractNodeTransfor) { + _inherits(ObfuscatingGuardsTransformer, _AbstractNodeTransfor); + + function ObfuscatingGuardsTransformer(obfuscatingGuardFactory, randomGenerator, options) { + _classCallCheck(this, ObfuscatingGuardsTransformer); + + var _this = _possibleConstructorReturn(this, (ObfuscatingGuardsTransformer.__proto__ || Object.getPrototypeOf(ObfuscatingGuardsTransformer)).call(this, randomGenerator, options)); + + _this.obfuscatingGuards = ObfuscatingGuardsTransformer_1.obfuscatingGuardsList.map(obfuscatingGuardFactory); + return _this; + } + + _createClass(ObfuscatingGuardsTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + return _this2.transformNode(node, parentNode); + } + }; + } + }, { + key: "transformNode", + value: function transformNode(node, parentNode) { + var obfuscationAllowed = this.obfuscatingGuards.every(function (nodeGuard) { + return nodeGuard.check(node); + }); + node.ignoredNode = !obfuscationAllowed; + return node; + } + }]); + + return ObfuscatingGuardsTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +ObfuscatingGuardsTransformer.obfuscatingGuardsList = [ObfuscatingGuard_1.ObfuscatingGuard.BlackListNodeGuard, ObfuscatingGuard_1.ObfuscatingGuard.ConditionalCommentNodeGuard]; +ObfuscatingGuardsTransformer = ObfuscatingGuardsTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__INodeGuard)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ObfuscatingGuardsTransformer); +exports.ObfuscatingGuardsTransformer = ObfuscatingGuardsTransformer; +var ObfuscatingGuardsTransformer_1; + +/***/ }), +/* 132 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractNodeTransformer_1 = __webpack_require__(7); +var NodeUtils_1 = __webpack_require__(4); +var ParentificationTransformer = function (_AbstractNodeTransfor) { + _inherits(ParentificationTransformer, _AbstractNodeTransfor); + + function ParentificationTransformer(randomGenerator, options) { + _classCallCheck(this, ParentificationTransformer); + + return _possibleConstructorReturn(this, (ParentificationTransformer.__proto__ || Object.getPrototypeOf(ParentificationTransformer)).call(this, randomGenerator, options)); + } + + _createClass(ParentificationTransformer, [{ + key: "getVisitor", + value: function getVisitor() { + var _this2 = this; + + return { + enter: function enter(node, parentNode) { + return _this2.transformNode(node, parentNode); + } + }; + } + }, { + key: "transformNode", + value: function transformNode(node, parentNode) { + return NodeUtils_1.NodeUtils.parentizeNode(node, parentNode); + } + }]); + + return ParentificationTransformer; +}(AbstractNodeTransformer_1.AbstractNodeTransformer); +ParentificationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ParentificationTransformer); +exports.ParentificationTransformer = ParentificationTransformer; + +/***/ }), +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ControlFlowStorage_1 = __webpack_require__(134); +var CustomNodeGroupStorage_1 = __webpack_require__(135); +var StringArrayStorage_1 = __webpack_require__(136); +exports.storagesModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.TCustomNodeGroupStorage).to(CustomNodeGroupStorage_1.CustomNodeGroupStorage).inSingletonScope(); + bind(ServiceIdentifiers_1.ServiceIdentifiers.TStringArrayStorage).to(StringArrayStorage_1.StringArrayStorage).inSingletonScope(); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__TControlFlowStorage).toConstructor(ControlFlowStorage_1.ControlFlowStorage); + bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__TControlFlowStorage).toFactory(function (context) { + return function () { + var constructor = context.container.get(ServiceIdentifiers_1.ServiceIdentifiers.Newable__TControlFlowStorage); + var randomGenerator = context.container.get(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator); + var options = context.container.get(ServiceIdentifiers_1.ServiceIdentifiers.IOptions); + var storage = new constructor(randomGenerator, options); + storage.initialize(); + return storage; + }; + }); +}); + +/***/ }), +/* 134 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var MapStorage_1 = __webpack_require__(42); +var ControlFlowStorage = function (_MapStorage_1$MapStor) { + _inherits(ControlFlowStorage, _MapStorage_1$MapStor); + + function ControlFlowStorage(randomGenerator, options) { + _classCallCheck(this, ControlFlowStorage); + + return _possibleConstructorReturn(this, (ControlFlowStorage.__proto__ || Object.getPrototypeOf(ControlFlowStorage)).call(this, randomGenerator, options)); + } + + return ControlFlowStorage; +}(MapStorage_1.MapStorage); +ControlFlowStorage = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ControlFlowStorage); +exports.ControlFlowStorage = ControlFlowStorage; + +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var CustomNodeGroup_1 = __webpack_require__(38); +var MapStorage_1 = __webpack_require__(42); +var CustomNodeGroupStorage = CustomNodeGroupStorage_1 = function (_MapStorage_1$MapStor) { + _inherits(CustomNodeGroupStorage, _MapStorage_1$MapStor); + + function CustomNodeGroupStorage(customNodeGroupFactory, randomGenerator, options) { + _classCallCheck(this, CustomNodeGroupStorage); + + var _this = _possibleConstructorReturn(this, (CustomNodeGroupStorage.__proto__ || Object.getPrototypeOf(CustomNodeGroupStorage)).call(this, randomGenerator, options)); + + _this.customNodeGroupFactory = customNodeGroupFactory; + return _this; + } + + _createClass(CustomNodeGroupStorage, [{ + key: "initialize", + value: function initialize() { + var _this2 = this; + + this.storage = new Map(); + this.storageId = this.randomGenerator.getRandomString(6); + CustomNodeGroupStorage_1.customNodeGroupsList.forEach(function (customNodeGroupName) { + var customNodeGroup = _this2.customNodeGroupFactory(customNodeGroupName); + if (!customNodeGroup) { + return; + } + _this2.storage.set(customNodeGroupName, customNodeGroup); + }); + } + }]); + + return CustomNodeGroupStorage; +}(MapStorage_1.MapStorage); +CustomNodeGroupStorage.customNodeGroupsList = [CustomNodeGroup_1.CustomNodeGroup.ConsoleOutputCustomNodeGroup, CustomNodeGroup_1.CustomNodeGroup.DebugProtectionCustomNodeGroup, CustomNodeGroup_1.CustomNodeGroup.DomainLockCustomNodeGroup, CustomNodeGroup_1.CustomNodeGroup.SelfDefendingCustomNodeGroup, CustomNodeGroup_1.CustomNodeGroup.StringArrayCustomNodeGroup]; +tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], CustomNodeGroupStorage.prototype, "initialize", null); +CustomNodeGroupStorage = CustomNodeGroupStorage_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNodeGroup)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CustomNodeGroupStorage); +exports.CustomNodeGroupStorage = CustomNodeGroupStorage; +var CustomNodeGroupStorage_1; + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = (function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ArrayStorage_1 = __webpack_require__(137); +var StringArrayStorage = function (_ArrayStorage_1$Array) { + _inherits(StringArrayStorage, _ArrayStorage_1$Array); + + function StringArrayStorage(identifierNameGeneratorFactory, arrayUtils, randomGenerator, options) { + _classCallCheck(this, StringArrayStorage); + + var _this = _possibleConstructorReturn(this, (StringArrayStorage.__proto__ || Object.getPrototypeOf(StringArrayStorage)).call(this, randomGenerator, options)); + + _this.identifierNameGenerator = identifierNameGeneratorFactory(options); + _this.arrayUtils = arrayUtils; + return _this; + } + + _createClass(StringArrayStorage, [{ + key: "initialize", + value: function initialize() { + _get(StringArrayStorage.prototype.__proto__ || Object.getPrototypeOf(StringArrayStorage.prototype), "initialize", this).call(this); + var stringArrayName = this.identifierNameGenerator.generate(4); + var stringArrayCallsWrapperName = this.identifierNameGenerator.generate(4); + this.storageId = stringArrayName + "|" + stringArrayCallsWrapperName; + } + }, { + key: "rotateArray", + value: function rotateArray(rotationValue) { + this.storage = this.arrayUtils.arrayRotate(this.storage, rotationValue); + } + }, { + key: "toString", + value: function toString() { + return this.storage.map(function (value) { + return "'" + value + "'"; + }).toString(); + } + }]); + + return StringArrayStorage; +}(ArrayStorage_1.ArrayStorage); +tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], StringArrayStorage.prototype, "initialize", null); +StringArrayStorage = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNameGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IArrayUtils)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], StringArrayStorage); +exports.StringArrayStorage = StringArrayStorage; + +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var Initializable_1 = __webpack_require__(3); +var ArrayStorage = function () { + function ArrayStorage(randomGenerator, options) { + _classCallCheck(this, ArrayStorage); + + this.storageLength = 0; + this.randomGenerator = randomGenerator; + this.options = options; + } + + _createClass(ArrayStorage, [{ + key: "initialize", + value: function initialize() { + this.storage = []; + this.storageId = this.randomGenerator.getRandomString(6); + } + }, { + key: "get", + value: function get(key) { + var value = this.storage[key]; + if (!value) { + throw new Error("No value found in array storage with key `" + key + "`"); + } + return value; + } + }, { + key: "getKeyOf", + value: function getKeyOf(value) { + var key = this.storage.indexOf(value); + return key >= 0 ? key : null; + } + }, { + key: "getLength", + value: function getLength() { + return this.storageLength; + } + }, { + key: "getStorage", + value: function getStorage() { + return this.storage; + } + }, { + key: "getStorageId", + value: function getStorageId() { + return this.storageId; + } + }, { + key: "mergeWith", + value: function mergeWith(storage) { + var mergeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + this.storage = [].concat(_toConsumableArray(this.storage), _toConsumableArray(storage.getStorage())); + if (mergeId) { + this.storageId = storage.getStorageId(); + } + } + }, { + key: "set", + value: function set(key, value) { + if (key === this.storageLength) { + this.storage.push(value); + } else { + this.storage.splice(key, 0, value); + } + this.storageLength++; + } + }]); + + return ArrayStorage; +}(); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], ArrayStorage.prototype, "storage", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ArrayStorage.prototype, "storageId", void 0); +tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], ArrayStorage.prototype, "initialize", null); +ArrayStorage = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ArrayStorage); +exports.ArrayStorage = ArrayStorage; + +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ArrayUtils_1 = __webpack_require__(139); +var CryptUtils_1 = __webpack_require__(140); +var EscapeSequenceEncoder_1 = __webpack_require__(143); +var RandomGenerator_1 = __webpack_require__(43); +exports.utilsModule = new inversify_1.ContainerModule(function (bind) { + bind(ServiceIdentifiers_1.ServiceIdentifiers.IArrayUtils).to(ArrayUtils_1.ArrayUtils).inSingletonScope(); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator).to(RandomGenerator_1.RandomGenerator).inSingletonScope(); + bind(ServiceIdentifiers_1.ServiceIdentifiers.ICryptUtils).to(CryptUtils_1.CryptUtils).inSingletonScope(); + bind(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder).to(EscapeSequenceEncoder_1.EscapeSequenceEncoder).inSingletonScope(); +}); + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var ArrayUtils = function () { + function ArrayUtils(randomGenerator) { + _classCallCheck(this, ArrayUtils); + + this.randomGenerator = randomGenerator; + } + + _createClass(ArrayUtils, [{ + key: "arrayRange", + value: function arrayRange(length) { + var range = []; + for (var i = 0; i < length; i++) { + range.push(i); + } + return range; + } + }, { + key: "arrayRotate", + value: function arrayRotate(array, times) { + if (!array.length) { + throw new ReferenceError("Cannot rotate empty array."); + } + if (times <= 0) { + return array; + } + var newArray = array; + var temp = void 0; + while (times--) { + temp = newArray.pop(); + newArray.unshift(temp); + } + return newArray; + } + }, { + key: "arrayShuffle", + value: function arrayShuffle(array) { + var shuffledArray = [].concat(_toConsumableArray(array)); + for (var i = shuffledArray.length; i; i--) { + var j = Math.floor(this.randomGenerator.getMathRandom() * i); + var _ref = [shuffledArray[j], shuffledArray[i - 1]]; + shuffledArray[i - 1] = _ref[0]; + shuffledArray[j] = _ref[1]; + } + return shuffledArray; + } + }]); + + return ArrayUtils; +}(); +ArrayUtils = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__metadata("design:paramtypes", [Object])], ArrayUtils); +exports.ArrayUtils = ArrayUtils; + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var RandomGenerator_1 = __webpack_require__(43); +var Utils_1 = __webpack_require__(21); +var CryptUtils = function () { + function CryptUtils(randomGenerator) { + _classCallCheck(this, CryptUtils); + + this.randomGenerator = randomGenerator; + } + + _createClass(CryptUtils, [{ + key: "btoa", + value: function btoa(string) { + var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + var output = ''; + string = encodeURIComponent(string).replace(/%([0-9A-F]{2})/g, function (match, p1) { + return String.fromCharCode(parseInt("" + Utils_1.Utils.hexadecimalPrefix + p1)); + }); + for (var block, charCode, idx = 0, map = chars; string.charAt(idx | 0) || (map = '=', idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) { + charCode = string.charCodeAt(idx += 3 / 4); + if (charCode > 0xFF) { + throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); + } + block = block << 8 | charCode; + } + return output; + } + }, { + key: "hideString", + value: function hideString(str, length) { + var _this = this; + + var escapeRegExp = function escapeRegExp(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + }; + var randomMerge = function randomMerge(s1, s2) { + var i1 = -1, + i2 = -1, + result = ''; + while (i1 < s1.length || i2 < s2.length) { + if (_this.randomGenerator.getMathRandom() < 0.5 && i2 < s2.length) { + result += s2.charAt(++i2); + } else { + result += s1.charAt(++i1); + } + } + return result; + }; + var randomString = this.randomGenerator.getRandomGenerator().string({ + length: length, + pool: RandomGenerator_1.RandomGenerator.randomGeneratorPool + }); + var randomStringDiff = randomString.replace(new RegExp("[" + escapeRegExp(str) + "]", 'g'), ''); + var randomStringDiffArray = randomStringDiff.split(''); + this.randomGenerator.getRandomGenerator().shuffle(randomStringDiffArray); + randomStringDiff = randomStringDiffArray.join(''); + return [randomMerge(str, randomStringDiff), randomStringDiff]; + } + }, { + key: "rc4", + value: function rc4(string, key) { + var s = [], + j = 0, + x = void 0, + result = ''; + for (var i = 0; i < 256; i++) { + s[i] = i; + } + for (i = 0; i < 256; i++) { + j = (j + s[i] + key.charCodeAt(i % key.length)) % 256; + x = s[i]; + s[i] = s[j]; + s[j] = x; + } + i = 0; + j = 0; + for (var y = 0; y < string.length; y++) { + i = (i + 1) % 256; + j = (j + s[i]) % 256; + x = s[i]; + s[i] = s[j]; + s[j] = x; + result += String.fromCharCode(string.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]); + } + return result; + } + }]); + + return CryptUtils; +}(); +CryptUtils = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__metadata("design:paramtypes", [Object])], CryptUtils); +exports.CryptUtils = CryptUtils; + +/***/ }), +/* 141 */ +/***/ (function(module, exports) { + +module.exports = require("md5"); + +/***/ }), +/* 142 */ +/***/ (function(module, exports) { + +module.exports = require("chance"); + +/***/ }), +/* 143 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var EscapeSequenceEncoder = function () { + function EscapeSequenceEncoder() { + _classCallCheck(this, EscapeSequenceEncoder); + + this.stringsCache = new Map(); + } + + _createClass(EscapeSequenceEncoder, [{ + key: "encode", + value: function encode(string, encodeAllSymbols) { + var cacheKey = string + "-" + String(encodeAllSymbols); + if (this.stringsCache.has(cacheKey)) { + return this.stringsCache.get(cacheKey); + } + var radix = 16; + var replaceRegExp = new RegExp('[\\s\\S]', 'g'); + var escapeSequenceRegExp = new RegExp('[\'\"\\\\\\s]'); + var regExp = new RegExp('[\\x00-\\x7F]'); + var prefix = void 0, + template = void 0; + var result = string.replace(replaceRegExp, function (character) { + if (!encodeAllSymbols && !escapeSequenceRegExp.exec(character)) { + return character; + } + if (regExp.exec(character)) { + prefix = '\\x'; + template = '00'; + } else { + prefix = "\\u"; + template = '0000'; + } + return "" + prefix + (template + character.charCodeAt(0).toString(radix)).slice(-template.length); + }); + this.stringsCache.set(cacheKey, result); + return result; + } + }]); + + return EscapeSequenceEncoder; +}(); +EscapeSequenceEncoder = tslib_1.__decorate([inversify_1.injectable()], EscapeSequenceEncoder); +exports.EscapeSequenceEncoder = EscapeSequenceEncoder; + +/***/ }), +/* 144 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var esprima = __webpack_require__(35); +var escodegen = __webpack_require__(28); +var LoggingMessage_1 = __webpack_require__(145); +var NodeTransformer_1 = __webpack_require__(18); +var ObfuscationEvent_1 = __webpack_require__(15); +var NodeGuards_1 = __webpack_require__(5); +var JavaScriptObfuscator = JavaScriptObfuscator_1 = function () { + function JavaScriptObfuscator(stackTraceAnalyzer, obfuscationEventEmitter, customNodeGroupStorage, transformersRunner, sourceMapCorrector, randomGenerator, logger, options) { + _classCallCheck(this, JavaScriptObfuscator); + + this.stackTraceAnalyzer = stackTraceAnalyzer; + this.obfuscationEventEmitter = obfuscationEventEmitter; + this.customNodeGroupStorage = customNodeGroupStorage; + this.transformersRunner = transformersRunner; + this.sourceMapCorrector = sourceMapCorrector; + this.randomGenerator = randomGenerator; + this.logger = logger; + this.options = options; + } + + _createClass(JavaScriptObfuscator, [{ + key: "obfuscate", + value: function obfuscate(sourceCode) { + var timeStart = Date.now(); + this.logger.info(LoggingMessage_1.LoggingMessage.ObfuscationStarted); + this.logger.info(LoggingMessage_1.LoggingMessage.RandomGeneratorSeed, this.randomGenerator.getSeed()); + var astTree = this.parseCode(sourceCode); + var obfuscatedAstTree = this.transformAstTree(astTree); + var generatorOutput = this.generateCode(sourceCode, obfuscatedAstTree); + var obfuscationTime = (Date.now() - timeStart) / 1000; + this.logger.success(LoggingMessage_1.LoggingMessage.ObfuscationCompleted, obfuscationTime); + return this.getObfuscationResult(generatorOutput); + } + }, { + key: "parseCode", + value: function parseCode(sourceCode) { + return esprima.parseScript(sourceCode, { + attachComment: true, + loc: this.options.sourceMap + }); + } + }, { + key: "transformAstTree", + value: function transformAstTree(astTree) { + var _this = this; + + if (NodeGuards_1.NodeGuards.isProgramNode(astTree) && !astTree.body.length) { + this.logger.warn(LoggingMessage_1.LoggingMessage.EmptySourceCode); + return astTree; + } + this.logger.info(LoggingMessage_1.LoggingMessage.StagePreparingASTTree); + astTree = this.transformersRunner.transform(astTree, JavaScriptObfuscator_1.preparingTransformersList); + this.logger.info(LoggingMessage_1.LoggingMessage.StageAnalyzingASTTree); + var stackTraceData = this.stackTraceAnalyzer.analyze(astTree); + this.customNodeGroupStorage.getStorage().forEach(function (customNodeGroup) { + customNodeGroup.initialize(); + _this.obfuscationEventEmitter.once(customNodeGroup.getAppendEvent(), customNodeGroup.appendCustomNodes.bind(customNodeGroup)); + }); + this.obfuscationEventEmitter.emit(ObfuscationEvent_1.ObfuscationEvent.BeforeObfuscation, astTree, stackTraceData); + if (this.options.deadCodeInjection) { + this.logger.info(LoggingMessage_1.LoggingMessage.StageDeadCodeInjection); + astTree = this.transformersRunner.transform(astTree, JavaScriptObfuscator_1.deadCodeInjectionTransformersList); + } + if (this.options.controlFlowFlattening) { + this.logger.info(LoggingMessage_1.LoggingMessage.StageControlFlowFlattening); + astTree = this.transformersRunner.transform(astTree, JavaScriptObfuscator_1.controlFlowTransformersList); + } + this.logger.info(LoggingMessage_1.LoggingMessage.StageObfuscation); + astTree = this.transformersRunner.transform(astTree, [].concat(_toConsumableArray(JavaScriptObfuscator_1.convertingTransformersList), _toConsumableArray(JavaScriptObfuscator_1.obfuscatingTransformersList))); + this.obfuscationEventEmitter.emit(ObfuscationEvent_1.ObfuscationEvent.AfterObfuscation, astTree, stackTraceData); + return astTree; + } + }, { + key: "generateCode", + value: function generateCode(sourceCode, astTree) { + var escodegenParams = Object.assign({}, JavaScriptObfuscator_1.escodegenParams); + if (this.options.sourceMap) { + escodegenParams.sourceMap = 'sourceMap'; + escodegenParams.sourceContent = sourceCode; + } + var generatorOutput = escodegen.generate(astTree, Object.assign({}, escodegenParams, { format: { + compact: this.options.compact + } })); + generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : ''; + return generatorOutput; + } + }, { + key: "getObfuscationResult", + value: function getObfuscationResult(generatorOutput) { + return this.sourceMapCorrector.correct(generatorOutput.code, generatorOutput.map); + } + }]); + + return JavaScriptObfuscator; +}(); +JavaScriptObfuscator.escodegenParams = { + verbatim: 'x-verbatim-property', + sourceMapWithCode: true +}; +JavaScriptObfuscator.controlFlowTransformersList = [NodeTransformer_1.NodeTransformer.BlockStatementControlFlowTransformer, NodeTransformer_1.NodeTransformer.FunctionControlFlowTransformer]; +JavaScriptObfuscator.convertingTransformersList = [NodeTransformer_1.NodeTransformer.MemberExpressionTransformer, NodeTransformer_1.NodeTransformer.MethodDefinitionTransformer, NodeTransformer_1.NodeTransformer.TemplateLiteralTransformer]; +JavaScriptObfuscator.deadCodeInjectionTransformersList = [NodeTransformer_1.NodeTransformer.DeadCodeInjectionTransformer]; +JavaScriptObfuscator.obfuscatingTransformersList = [NodeTransformer_1.NodeTransformer.CatchClauseTransformer, NodeTransformer_1.NodeTransformer.ClassDeclarationTransformer, NodeTransformer_1.NodeTransformer.FunctionDeclarationTransformer, NodeTransformer_1.NodeTransformer.FunctionTransformer, NodeTransformer_1.NodeTransformer.LabeledStatementTransformer, NodeTransformer_1.NodeTransformer.LiteralTransformer, NodeTransformer_1.NodeTransformer.ObjectExpressionTransformer, NodeTransformer_1.NodeTransformer.VariableDeclarationTransformer]; +JavaScriptObfuscator.preparingTransformersList = [NodeTransformer_1.NodeTransformer.ObfuscatingGuardsTransformer, NodeTransformer_1.NodeTransformer.ParentificationTransformer]; +JavaScriptObfuscator = JavaScriptObfuscator_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IStackTraceAnalyzer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationEventEmitter)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.TCustomNodeGroupStorage)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ITransformersRunner)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ISourceMapCorrector)), tslib_1.__param(5, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(6, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ILogger)), tslib_1.__param(7, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object, Object, Object])], JavaScriptObfuscator); +exports.JavaScriptObfuscator = JavaScriptObfuscator; +var JavaScriptObfuscator_1; + +/***/ }), +/* 145 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var LoggingMessage; +(function (LoggingMessage) { + LoggingMessage["EmptySourceCode"] = "Empty source code. Obfuscation canceled..."; + LoggingMessage["ObfuscationCompleted"] = "Obfuscation completed. Total time: %s sec."; + LoggingMessage["ObfuscationStarted"] = "Obfuscation started..."; + LoggingMessage["RandomGeneratorSeed"] = "Random generator seed: %s..."; + LoggingMessage["StagePreparingASTTree"] = "Stage: preparing AST-tree..."; + LoggingMessage["StageAnalyzingASTTree"] = "Stage: analyzing AST-tree..."; + LoggingMessage["StageControlFlowFlattening"] = "Stage: control flow flattening..."; + LoggingMessage["StageDeadCodeInjection"] = "Stage: dead code injection..."; + LoggingMessage["StageObfuscation"] = "Stage: obfuscation..."; +})(LoggingMessage = exports.LoggingMessage || (exports.LoggingMessage = {})); + +/***/ }), +/* 146 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var chalk_1 = __webpack_require__(147); +var Initializable_1 = __webpack_require__(3); +var Logger = Logger_1 = function () { + function Logger(options) { + _classCallCheck(this, Logger); + + this.options = options; + } + + _createClass(Logger, [{ + key: "initialize", + value: function initialize() { + this.colorInfo = chalk_1.default.cyan; + this.colorSuccess = chalk_1.default.green; + this.colorWarn = chalk_1.default.yellow; + } + }, { + key: "info", + value: function info(loggingMessage, value) { + this.log(this.colorInfo, loggingMessage, value); + } + }, { + key: "success", + value: function success(loggingMessage, value) { + this.log(this.colorSuccess, loggingMessage, value); + } + }, { + key: "warn", + value: function warn(loggingMessage, value) { + this.log(this.colorWarn, loggingMessage, value); + } + }, { + key: "log", + value: function log(loggingLevelColor, loggingMessage, value) { + if (!this.options.log) { + return; + } + var processedMessage = loggingLevelColor("\n" + Logger_1.loggingPrefix + " " + loggingMessage); + !value ? console.log(processedMessage) : console.log(processedMessage, value); + } + }]); + + return Logger; +}(); +Logger.loggingPrefix = '[javascript-obfuscator]'; +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Function)], Logger.prototype, "colorInfo", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Function)], Logger.prototype, "colorSuccess", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Function)], Logger.prototype, "colorWarn", void 0); +tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], Logger.prototype, "initialize", null); +Logger = Logger_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], Logger); +exports.Logger = Logger; +var Logger_1; + +/***/ }), +/* 147 */ +/***/ (function(module, exports) { + +module.exports = require("chalk"); + +/***/ }), +/* 148 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var events_1 = __webpack_require__(149); +inversify_1.decorate(inversify_1.injectable(), events_1.EventEmitter); +var ObfuscationEventEmitter = function (_events_1$EventEmitte) { + _inherits(ObfuscationEventEmitter, _events_1$EventEmitte); + + function ObfuscationEventEmitter() { + _classCallCheck(this, ObfuscationEventEmitter); + + return _possibleConstructorReturn(this, (ObfuscationEventEmitter.__proto__ || Object.getPrototypeOf(ObfuscationEventEmitter)).apply(this, arguments)); + } + + return ObfuscationEventEmitter; +}(events_1.EventEmitter); +ObfuscationEventEmitter = tslib_1.__decorate([inversify_1.injectable()], ObfuscationEventEmitter); +exports.ObfuscationEventEmitter = ObfuscationEventEmitter; + +/***/ }), +/* 149 */ +/***/ (function(module, exports) { + +module.exports = require("events"); + +/***/ }), +/* 150 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var Initializable_1 = __webpack_require__(3); +var ObfuscationResult = function () { + function ObfuscationResult() { + _classCallCheck(this, ObfuscationResult); + } + + _createClass(ObfuscationResult, [{ + key: "initialize", + value: function initialize(obfuscatedCode, sourceMap) { + this.obfuscatedCode = obfuscatedCode; + this.sourceMap = sourceMap; + } + }, { + key: "getObfuscatedCode", + value: function getObfuscatedCode() { + return this.obfuscatedCode; + } + }, { + key: "getSourceMap", + value: function getSourceMap() { + return this.sourceMap; + } + }, { + key: "toString", + value: function toString() { + return this.obfuscatedCode; + } + }]); + + return ObfuscationResult; +}(); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ObfuscationResult.prototype, "obfuscatedCode", void 0); +tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ObfuscationResult.prototype, "sourceMap", void 0); +ObfuscationResult = tslib_1.__decorate([inversify_1.injectable()], ObfuscationResult); +exports.ObfuscationResult = ObfuscationResult; + +/***/ }), +/* 151 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var class_validator_1 = __webpack_require__(152); +var ObfuscationTarget_1 = __webpack_require__(13); +var SourceMapMode_1 = __webpack_require__(23); +var StringArrayEncoding_1 = __webpack_require__(24); +var Default_1 = __webpack_require__(31); +var OptionsNormalizer_1 = __webpack_require__(153); +var ValidationErrorsFormatter_1 = __webpack_require__(164); +var Options = Options_1 = function Options(inputOptions) { + _classCallCheck(this, Options); + + Object.assign(this, Default_1.DEFAULT_PRESET, inputOptions); + var errors = class_validator_1.validateSync(this, Options_1.validatorOptions); + if (errors.length) { + throw new ReferenceError("Validation failed. errors:\n" + ValidationErrorsFormatter_1.ValidationErrorsFormatter.format(errors)); + } + Object.assign(this, OptionsNormalizer_1.OptionsNormalizer.normalizeOptions(this)); +}; +Options.validatorOptions = { + validationError: { + target: false + } +}; +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "compact", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "controlFlowFlattening", void 0); +tslib_1.__decorate([class_validator_1.IsNumber(), class_validator_1.Min(0), class_validator_1.Max(1), tslib_1.__metadata("design:type", Number)], Options.prototype, "controlFlowFlatteningThreshold", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "deadCodeInjection", void 0); +tslib_1.__decorate([class_validator_1.IsNumber(), tslib_1.__metadata("design:type", Number)], Options.prototype, "deadCodeInjectionThreshold", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "debugProtection", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "debugProtectionInterval", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "disableConsoleOutput", void 0); +tslib_1.__decorate([class_validator_1.IsArray(), class_validator_1.ArrayUnique(), class_validator_1.IsString({ + each: true +}), tslib_1.__metadata("design:type", Array)], Options.prototype, "domainLock", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "log", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "mangle", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "renameGlobals", void 0); +tslib_1.__decorate([class_validator_1.IsArray(), class_validator_1.ArrayUnique(), class_validator_1.IsString({ + each: true +}), tslib_1.__metadata("design:type", Array)], Options.prototype, "reservedNames", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "rotateStringArray", void 0); +tslib_1.__decorate([class_validator_1.IsNumber(), tslib_1.__metadata("design:type", Number)], Options.prototype, "seed", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "selfDefending", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "sourceMap", void 0); +tslib_1.__decorate([class_validator_1.IsString(), class_validator_1.ValidateIf(function (options) { + return Boolean(options.sourceMapBaseUrl); +}), class_validator_1.IsUrl({ + require_protocol: true, + require_valid_protocol: true +}), tslib_1.__metadata("design:type", String)], Options.prototype, "sourceMapBaseUrl", void 0); +tslib_1.__decorate([class_validator_1.IsString(), tslib_1.__metadata("design:type", String)], Options.prototype, "sourceMapFileName", void 0); +tslib_1.__decorate([class_validator_1.IsIn([SourceMapMode_1.SourceMapMode.Inline, SourceMapMode_1.SourceMapMode.Separate]), tslib_1.__metadata("design:type", String)], Options.prototype, "sourceMapMode", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "stringArray", void 0); +tslib_1.__decorate([class_validator_1.IsIn([true, false, StringArrayEncoding_1.StringArrayEncoding.Base64, StringArrayEncoding_1.StringArrayEncoding.Rc4]), tslib_1.__metadata("design:type", Object)], Options.prototype, "stringArrayEncoding", void 0); +tslib_1.__decorate([class_validator_1.IsNumber(), class_validator_1.Min(0), class_validator_1.Max(1), tslib_1.__metadata("design:type", Number)], Options.prototype, "stringArrayThreshold", void 0); +tslib_1.__decorate([class_validator_1.IsIn([ObfuscationTarget_1.ObfuscationTarget.Browser, ObfuscationTarget_1.ObfuscationTarget.Extension, ObfuscationTarget_1.ObfuscationTarget.Node]), tslib_1.__metadata("design:type", String)], Options.prototype, "target", void 0); +tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "unicodeEscapeSequence", void 0); +Options = Options_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__metadata("design:paramtypes", [Object])], Options); +exports.Options = Options; +var Options_1; + +/***/ }), +/* 152 */ +/***/ (function(module, exports) { + +module.exports = require("class-validator"); + +/***/ }), +/* 153 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var ControlFlowFlatteningThresholdRule_1 = __webpack_require__(154); +var DeadCodeInjectionRule_1 = __webpack_require__(155); +var DeadCodeInjectionThresholdRule_1 = __webpack_require__(156); +var DomainLockRule_1 = __webpack_require__(157); +var SelfDefendingRule_1 = __webpack_require__(158); +var SourceMapBaseUrlRule_1 = __webpack_require__(159); +var SourceMapFileNameRule_1 = __webpack_require__(160); +var StringArrayRule_1 = __webpack_require__(161); +var StringArrayEncodingRule_1 = __webpack_require__(162); +var StringArrayThresholdRule_1 = __webpack_require__(163); + +var OptionsNormalizer = function () { + function OptionsNormalizer() { + _classCallCheck(this, OptionsNormalizer); + } + + _createClass(OptionsNormalizer, null, [{ + key: "normalizeOptions", + value: function normalizeOptions(options) { + var normalizedOptions = Object.assign({}, options); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = OptionsNormalizer.normalizerRules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var normalizerRule = _step.value; + + normalizedOptions = normalizerRule(normalizedOptions); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return normalizedOptions; + } + }]); + + return OptionsNormalizer; +}(); + +OptionsNormalizer.normalizerRules = [ControlFlowFlatteningThresholdRule_1.ControlFlowFlatteningThresholdRule, DeadCodeInjectionRule_1.DeadCodeInjectionRule, DeadCodeInjectionThresholdRule_1.DeadCodeInjectionThresholdRule, DomainLockRule_1.DomainLockRule, SelfDefendingRule_1.SelfDefendingRule, SourceMapBaseUrlRule_1.SourceMapBaseUrlRule, SourceMapFileNameRule_1.SourceMapFileNameRule, StringArrayRule_1.StringArrayRule, StringArrayEncodingRule_1.StringArrayEncodingRule, StringArrayThresholdRule_1.StringArrayThresholdRule]; +exports.OptionsNormalizer = OptionsNormalizer; + +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ControlFlowFlatteningThresholdRule = function (options) { + if (options.controlFlowFlatteningThreshold === 0) { + options = Object.assign({}, options, { controlFlowFlattening: false, controlFlowFlatteningThreshold: 0 }); + } + return options; +}; + +/***/ }), +/* 155 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var Default_1 = __webpack_require__(31); +exports.DeadCodeInjectionRule = function (options) { + if (options.deadCodeInjection) { + options = Object.assign({}, options, { deadCodeInjection: true, stringArray: true }); + if (!options.stringArrayThreshold) { + options = Object.assign({}, options, { stringArray: true, stringArrayThreshold: Default_1.DEFAULT_PRESET.stringArrayThreshold }); + } + } + return options; +}; + +/***/ }), +/* 156 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DeadCodeInjectionThresholdRule = function (options) { + if (options.deadCodeInjectionThreshold === 0) { + options = Object.assign({}, options, { deadCodeInjection: false, deadCodeInjectionThreshold: 0 }); + } + return options; +}; + +/***/ }), +/* 157 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var Utils_1 = __webpack_require__(21); +exports.DomainLockRule = function (options) { + if (options.domainLock.length) { + var normalizedDomains = []; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = options.domainLock[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var domain = _step.value; + + normalizedDomains.push(Utils_1.Utils.extractDomainFromUrl(domain)); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + options = Object.assign({}, options, { domainLock: normalizedDomains }); + } + return options; +}; + +/***/ }), +/* 158 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SelfDefendingRule = function (options) { + if (options.selfDefending) { + options = Object.assign({}, options, { compact: true, selfDefending: true }); + } + return options; +}; + +/***/ }), +/* 159 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SourceMapBaseUrlRule = function (options) { + var _options = options, + sourceMapBaseUrl = _options.sourceMapBaseUrl; + + if (!options.sourceMapFileName) { + options = Object.assign({}, options, { sourceMapBaseUrl: '' }); + return options; + } + if (sourceMapBaseUrl && !sourceMapBaseUrl.endsWith('/')) { + options = Object.assign({}, options, { sourceMapBaseUrl: sourceMapBaseUrl + "/" }); + } + return options; +}; + +/***/ }), +/* 160 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SourceMapFileNameRule = function (options) { + var _options = options, + sourceMapFileName = _options.sourceMapFileName; + + if (sourceMapFileName) { + sourceMapFileName = sourceMapFileName.replace(/^\/+/, '').split('.')[0]; + options = Object.assign({}, options, { sourceMapFileName: sourceMapFileName + ".js.map" }); + } + return options; +}; + +/***/ }), +/* 161 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StringArrayRule = function (options) { + if (!options.stringArray) { + options = Object.assign({}, options, { rotateStringArray: false, stringArray: false, stringArrayEncoding: false, stringArrayThreshold: 0 }); + } + return options; +}; + +/***/ }), +/* 162 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var StringArrayEncoding_1 = __webpack_require__(24); +exports.StringArrayEncodingRule = function (options) { + if (options.stringArrayEncoding === true) { + options = Object.assign({}, options, { stringArrayEncoding: StringArrayEncoding_1.StringArrayEncoding.Base64 }); + } + return options; +}; + +/***/ }), +/* 163 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StringArrayThresholdRule = function (options) { + if (options.stringArrayThreshold === 0) { + options = Object.assign({}, options, { rotateStringArray: false, stringArray: false, stringArrayEncoding: false, stringArrayThreshold: 0 }); + } + return options; +}; + +/***/ }), +/* 164 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); + +var ValidationErrorsFormatter = function () { + function ValidationErrorsFormatter() { + _classCallCheck(this, ValidationErrorsFormatter); + } + + _createClass(ValidationErrorsFormatter, null, [{ + key: "format", + value: function format(validationErrors) { + var errorsArray = []; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = validationErrors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var error = _step.value; + + errorsArray.push(ValidationErrorsFormatter.formatError(error)); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return errorsArray.join('\n'); + } + }, { + key: "formatError", + value: function formatError(validationError) { + var constraints = validationError.constraints; + var errorString = "`" + validationError.property + "` errors:\n"; + for (var constraint in constraints) { + if (!constraints.hasOwnProperty(constraint)) { + continue; + } + errorString += " - " + constraints[constraint] + "\n"; + } + return errorString; + } + }]); + + return ValidationErrorsFormatter; +}(); + +exports.ValidationErrorsFormatter = ValidationErrorsFormatter; + +/***/ }), +/* 165 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); + +var SourceCode = function () { + function SourceCode(sourceCode) { + _classCallCheck(this, SourceCode); + + this.sourceCode = sourceCode; + } + + _createClass(SourceCode, [{ + key: "getSourceCode", + value: function getSourceCode() { + return this.sourceCode; + } + }]); + + return SourceCode; +}(); + +exports.SourceCode = SourceCode; + +/***/ }), +/* 166 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var SourceMapMode_1 = __webpack_require__(23); +var SourceMapCorrector = function () { + function SourceMapCorrector(obfuscationResultFactory, cryptUtils, options) { + _classCallCheck(this, SourceMapCorrector); + + this.obfuscationResultFactory = obfuscationResultFactory; + this.cryptUtils = cryptUtils; + this.options = options; + } + + _createClass(SourceMapCorrector, [{ + key: "correct", + value: function correct(obfuscatedCode, sourceMap) { + return this.obfuscationResultFactory(this.correctObfuscatedCode(obfuscatedCode, sourceMap), sourceMap); + } + }, { + key: "correctObfuscatedCode", + value: function correctObfuscatedCode(obfuscatedCode, sourceMap) { + if (!sourceMap) { + return obfuscatedCode; + } + var sourceMapUrl = this.options.sourceMapBaseUrl + this.options.sourceMapFileName; + var sourceMappingUrl = '//# sourceMappingURL='; + switch (this.options.sourceMapMode) { + case SourceMapMode_1.SourceMapMode.Inline: + sourceMappingUrl += "data:application/json;base64," + this.cryptUtils.btoa(sourceMap); + break; + case SourceMapMode_1.SourceMapMode.Separate: + default: + if (!sourceMapUrl) { + return obfuscatedCode; + } + sourceMappingUrl += sourceMapUrl; + break; + } + return obfuscatedCode + "\n" + sourceMappingUrl; + } + }]); + + return SourceMapCorrector; +}(); +SourceMapCorrector = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationResult)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ICryptUtils)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], SourceMapCorrector); +exports.SourceMapCorrector = SourceMapCorrector; + +/***/ }), +/* 167 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var estraverse = __webpack_require__(8); +var VisitorDirection_1 = __webpack_require__(168); +var NodeGuards_1 = __webpack_require__(5); +var TransformersRunner = function () { + function TransformersRunner(nodeTransformerFactory) { + _classCallCheck(this, TransformersRunner); + + this.nodeTransformerFactory = nodeTransformerFactory; + } + + _createClass(TransformersRunner, [{ + key: "transform", + value: function transform(astTree, nodeTransformers) { + if (!nodeTransformers.length) { + return astTree; + } + var enterVisitors = []; + var leaveVisitors = []; + var nodeTransformersLength = nodeTransformers.length; + var visitor = void 0; + for (var i = 0; i < nodeTransformersLength; i++) { + visitor = this.nodeTransformerFactory(nodeTransformers[i]).getVisitor(); + if (visitor.enter) { + enterVisitors.push(visitor); + } + if (visitor.leave) { + leaveVisitors.push(visitor); + } + } + estraverse.replace(astTree, { + enter: this.mergeVisitorsForDirection(enterVisitors, VisitorDirection_1.VisitorDirection.Enter), + leave: this.mergeVisitorsForDirection(leaveVisitors, VisitorDirection_1.VisitorDirection.Leave) + }); + return astTree; + } + }, { + key: "mergeVisitorsForDirection", + value: function mergeVisitorsForDirection(visitors, direction) { + var visitorsLength = visitors.length; + if (!visitorsLength) { + return function (node, parentNode) { + return node; + }; + } + return function (node, parentNode) { + if (node.ignoredNode) { + return estraverse.VisitorOption.Skip; + } + for (var i = 0; i < visitorsLength; i++) { + var visitorFunction = visitors[i][direction]; + if (!visitorFunction) { + continue; + } + var visitorResult = visitorFunction(node, parentNode); + if (!visitorResult || !NodeGuards_1.NodeGuards.isNode(visitorResult)) { + continue; + } + node = visitorResult; + } + return node; + }; + } + }]); + + return TransformersRunner; +}(); +TransformersRunner = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__INodeTransformer)), tslib_1.__metadata("design:paramtypes", [Function])], TransformersRunner); +exports.TransformersRunner = TransformersRunner; + +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var VisitorDirection; +(function (VisitorDirection) { + VisitorDirection["Enter"] = "enter"; + VisitorDirection["Leave"] = "leave"; +})(VisitorDirection = exports.VisitorDirection || (exports.VisitorDirection = {})); + +/***/ }), +/* 169 */ +/***/ (function(module, exports) { + +module.exports = require("commander"); + +/***/ }), +/* 170 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ArraySanitizer = function (value) { + if (/,$/.test(value)) { + throw new SyntaxError("Multiple values should be wrapped inside quotes: --optionName 'value1, value2'"); + } + return value.split(',').map(function (string) { + return string.trim(); + }); +}; + +/***/ }), +/* 171 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BooleanSanitizer = function (value) { + return value === 'true' || value === '1'; +}; + +/***/ }), +/* 172 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var ObfuscationTarget_1 = __webpack_require__(13); +exports.ObfuscationTargetSanitizer = function (value) { + var isCorrectTarget = Object.keys(ObfuscationTarget_1.ObfuscationTarget).some(function (key) { + return ObfuscationTarget_1.ObfuscationTarget[key] === value; + }); + if (!isCorrectTarget) { + throw new ReferenceError('Invalid value of `--target` option'); + } + return value; +}; + +/***/ }), +/* 173 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var SourceMapMode_1 = __webpack_require__(23); +exports.SourceMapModeSanitizer = function (value) { + var isCorrectSourceMapMode = Object.keys(SourceMapMode_1.SourceMapMode).some(function (key) { + return SourceMapMode_1.SourceMapMode[key] === value; + }); + if (!isCorrectSourceMapMode) { + throw new ReferenceError('Invalid value of `--sourceMapMode` option'); + } + return value; +}; + +/***/ }), +/* 174 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { value: true }); +var StringArrayEncoding_1 = __webpack_require__(24); +exports.StringArrayEncodingSanitizer = function (value) { + switch (value) { + case 'true': + case '1': + case StringArrayEncoding_1.StringArrayEncoding.Base64: + return true; + case StringArrayEncoding_1.StringArrayEncoding.Rc4: + return StringArrayEncoding_1.StringArrayEncoding.Rc4; + default: + return false; + } +}; + +/***/ }), +/* 175 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var fs = __webpack_require__(44); +var mkdirp = __webpack_require__(176); +var path = __webpack_require__(33); +var JavaScriptObfuscatorCLI_1 = __webpack_require__(32); + +var CLIUtils = function () { + function CLIUtils() { + _classCallCheck(this, CLIUtils); + } + + _createClass(CLIUtils, null, [{ + key: "getOutputCodePath", + value: function getOutputCodePath(inputPath) { + return inputPath.split('.').map(function (value, index) { + return index === 0 ? "" + value + JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.obfuscatedFilePrefix : value; + }).join('.'); + } + }, { + key: "getOutputSourceMapPath", + value: function getOutputSourceMapPath(outputCodePath) { + var sourceMapFileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; + + if (sourceMapFileName) { + outputCodePath = outputCodePath.substring(0, outputCodePath.lastIndexOf('/')) + "/" + sourceMapFileName; + } + if (!/\.js\.map$/.test(outputCodePath)) { + outputCodePath = outputCodePath.split('.')[0] + ".js.map"; + } else if (/\.js$/.test(outputCodePath)) { + outputCodePath += '.map'; + } + return outputCodePath; + } + }, { + key: "getPackageConfig", + value: function getPackageConfig() { + return JSON.parse(fs.readFileSync(path.join(path.dirname(fs.realpathSync(process.argv[1])), '../package.json'), JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding)); + } + }, { + key: "getUserConfig", + value: function getUserConfig(configPath) { + var config = void 0; + try { + config = !(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()); + } catch (e) { + try { + config = require(configPath); + } catch (e) { + throw new ReferenceError('Given config path must be a valid file path'); + } + } + return config; + } + }, { + key: "writeFile", + value: function writeFile(outputPath, data) { + mkdirp.sync(path.dirname(outputPath)); + fs.writeFileSync(outputPath, data, { + encoding: JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding + }); + } + }]); + + return CLIUtils; +}(); + +exports.CLIUtils = CLIUtils; + +/***/ }), +/* 176 */ +/***/ (function(module, exports) { + +module.exports = require("mkdirp"); + +/***/ }), +/* 177 */ +/***/ (function(module, exports) { + +function webpackEmptyContext(req) { + throw new Error("Cannot find module '" + req + "'."); +} +webpackEmptyContext.keys = function() { return []; }; +webpackEmptyContext.resolve = webpackEmptyContext; +module.exports = webpackEmptyContext; +webpackEmptyContext.id = 177; + +/***/ }), +/* 178 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var fs = __webpack_require__(44); +var path = __webpack_require__(33); +var JavaScriptObfuscatorCLI_1 = __webpack_require__(32); + +var SourceCodeReader = function () { + function SourceCodeReader() { + _classCallCheck(this, SourceCodeReader); + } + + _createClass(SourceCodeReader, null, [{ + key: "readSourceCode", + value: function readSourceCode(inputPath) { + if (SourceCodeReader.isFilePath(inputPath)) { + return SourceCodeReader.readFile(inputPath); + } + if (SourceCodeReader.isDirectoryPath(inputPath)) { + return SourceCodeReader.readDirectory(inputPath); + } + throw new ReferenceError("Given input path must be a valid source code file or directory path"); + } + }, { + key: "isDirectoryPath", + value: function isDirectoryPath(filePath) { + try { + return fs.statSync(filePath).isDirectory(); + } catch (e) { + return false; + } + } + }, { + key: "isFilePath", + value: function isFilePath(filePath) { + try { + return fs.statSync(filePath).isFile(); + } catch (e) { + return false; + } + } + }, { + key: "readDirectory", + value: function readDirectory(directoryPath) { + return fs.readdirSync(directoryPath, JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding).filter(SourceCodeReader.isValidFile).map(function (fileName) { + var filePath = directoryPath + "/" + fileName; + var content = fs.readFileSync(filePath, JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding); + return { filePath: filePath, content: content }; + }); + } + }, { + key: "readFile", + value: function readFile(filePath) { + if (!SourceCodeReader.isValidFile(filePath)) { + throw new ReferenceError("Input file must have .js extension"); + } + return fs.readFileSync(filePath, JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding); + } + }, { + key: "isValidFile", + value: function isValidFile(filePath) { + return JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.availableInputExtensions.indexOf(path.extname(filePath)) !== -1 && !(filePath.indexOf(JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.obfuscatedFilePrefix) !== -1); + } + }]); + + return SourceCodeReader; +}(); + +exports.SourceCodeReader = SourceCodeReader; + +/***/ }), +/* 179 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractIdentifierNameGenerator = function AbstractIdentifierNameGenerator(randomGenerator, options) { + _classCallCheck(this, AbstractIdentifierNameGenerator); + + this.randomGenerator = randomGenerator; + this.options = options; +}; +AbstractIdentifierNameGenerator = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], AbstractIdentifierNameGenerator); +exports.AbstractIdentifierNameGenerator = AbstractIdentifierNameGenerator; + +/***/ }), +/* 180 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractIdentifierNameGenerator_1 = __webpack_require__(179); +var Utils_1 = __webpack_require__(21); +var HexadecimalIdentifierNameGenerator = function (_AbstractIdentifierNa) { + _inherits(HexadecimalIdentifierNameGenerator, _AbstractIdentifierNa); + + function HexadecimalIdentifierNameGenerator(randomGenerator, options) { + _classCallCheck(this, HexadecimalIdentifierNameGenerator); + + var _this = _possibleConstructorReturn(this, (HexadecimalIdentifierNameGenerator.__proto__ || Object.getPrototypeOf(HexadecimalIdentifierNameGenerator)).call(this, randomGenerator, options)); + + _this.randomVariableNameSet = new Set(); + return _this; + } + + _createClass(HexadecimalIdentifierNameGenerator, [{ + key: "generate", + value: function generate(length) { + var prefix = "_" + Utils_1.Utils.hexadecimalPrefix; + var rangeMinInteger = 10000; + var rangeMaxInteger = 99999999; + var randomInteger = this.randomGenerator.getRandomInteger(rangeMinInteger, rangeMaxInteger); + var hexadecimalNumber = Utils_1.Utils.decToHex(randomInteger); + var randomVariableName = "" + prefix + hexadecimalNumber.substr(0, length); + if (this.randomVariableNameSet.has(randomVariableName)) { + return this.generate(length); + } + this.randomVariableNameSet.add(randomVariableName); + return randomVariableName; + } + }]); + + return HexadecimalIdentifierNameGenerator; +}(AbstractIdentifierNameGenerator_1.AbstractIdentifierNameGenerator); +HexadecimalIdentifierNameGenerator = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], HexadecimalIdentifierNameGenerator); +exports.HexadecimalIdentifierNameGenerator = HexadecimalIdentifierNameGenerator; + +/***/ }), +/* 181 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = __webpack_require__(2); +var inversify_1 = __webpack_require__(0); +var ServiceIdentifiers_1 = __webpack_require__(1); +var AbstractIdentifierNameGenerator_1 = __webpack_require__(179); +var MangledIdentifierNameGenerator = MangledIdentifierNameGenerator_1 = function (_AbstractIdentifierNa) { + _inherits(MangledIdentifierNameGenerator, _AbstractIdentifierNa); + + function MangledIdentifierNameGenerator(randomGenerator, options) { + _classCallCheck(this, MangledIdentifierNameGenerator); + + var _this = _possibleConstructorReturn(this, (MangledIdentifierNameGenerator.__proto__ || Object.getPrototypeOf(MangledIdentifierNameGenerator)).call(this, randomGenerator, options)); + + _this.previousMangledName = MangledIdentifierNameGenerator_1.initMangledNameCharacter; + return _this; + } + + _createClass(MangledIdentifierNameGenerator, [{ + key: "generate", + value: function generate(length) { + var newName = MangledIdentifierNameGenerator_1.generateNewMangledName(this.previousMangledName); + this.previousMangledName = newName; + return newName; + } + }], [{ + key: "generateNewMangledName", + value: function generateNewMangledName(previousMangledName) { + var generateNewMangledName = function generateNewMangledName(name) { + var nameSequence = MangledIdentifierNameGenerator_1.nameSequence; + var zeroSequenceCache = []; + var zeroSequence = function zeroSequence(num) { + var result = zeroSequenceCache[num]; + if (result !== undefined) { + return result; + } + result = '0'.repeat(num); + zeroSequenceCache[num] = result; + return result; + }; + var cur = name.length - 1; + do { + var character = void 0, + index = void 0; + character = name.charAt(cur); + index = nameSequence.indexOf(character); + if (index !== nameSequence.length - 1) { + return name.substring(0, cur) + nameSequence[index + 1] + zeroSequence(name.length - (cur + 1)); + } + --cur; + } while (cur >= 0); + return "a" + zeroSequence(name.length); + }; + var newMangledName = generateNewMangledName(previousMangledName); + if (!MangledIdentifierNameGenerator_1.validateMangledName(newMangledName)) { + newMangledName = MangledIdentifierNameGenerator_1.generateNewMangledName(newMangledName); + } + return newMangledName; + } + }, { + key: "validateMangledName", + value: function validateMangledName(mangledName) { + return !(MangledIdentifierNameGenerator_1.reservedNames.indexOf(mangledName) !== -1); + } + }]); + + return MangledIdentifierNameGenerator; +}(AbstractIdentifierNameGenerator_1.AbstractIdentifierNameGenerator); +MangledIdentifierNameGenerator.initMangledNameCharacter = '9'; +MangledIdentifierNameGenerator.nameSequence = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'.split(''); +MangledIdentifierNameGenerator.reservedNames = ['byte', 'case', 'char', 'do', 'else', 'enum', 'eval', 'for', 'goto', 'if', 'in', 'int', 'let', 'long', 'new', 'null', 'this', 'true', 'try', 'var', 'void', 'with']; +MangledIdentifierNameGenerator = MangledIdentifierNameGenerator_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], MangledIdentifierNameGenerator); +exports.MangledIdentifierNameGenerator = MangledIdentifierNameGenerator; +var MangledIdentifierNameGenerator_1; + +/***/ }) +/******/ ]); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/package.json b/package.json index 5ddd9162..1670a163 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "class-validator": "0.7.3", "commander": "2.11.0", "escodegen-wallaby": "1.6.14", - "esmangle": "1.0.1", "esprima": "4.0.0", "estraverse": "4.2.0", "inversify": "4.5.2", diff --git a/src/JavaScriptObfuscator.ts b/src/JavaScriptObfuscator.ts index f488c07b..f92f906b 100644 --- a/src/JavaScriptObfuscator.ts +++ b/src/JavaScriptObfuscator.ts @@ -3,7 +3,6 @@ import { ServiceIdentifiers } from './container/ServiceIdentifiers'; import * as esprima from 'esprima'; import * as escodegen from 'escodegen-wallaby'; -import * as esmangle from 'esmangle'; import * as ESTree from 'estree'; import { ICustomNodeGroup } from './interfaces/custom-nodes/ICustomNodeGroup'; @@ -270,10 +269,6 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator { escodegenParams.sourceContent = sourceCode; } - if (this.options.mangle) { - astTree = esmangle.mangle(astTree); - } - const generatorOutput: IGeneratorOutput = escodegen.generate(astTree, { ...escodegenParams, format: { diff --git a/src/container/InversifyContainerFacade.ts b/src/container/InversifyContainerFacade.ts index 6cb04c9e..b40478c8 100644 --- a/src/container/InversifyContainerFacade.ts +++ b/src/container/InversifyContainerFacade.ts @@ -5,6 +5,7 @@ import { analyzersModule } from './modules/analyzers/AnalyzersModule'; import { controlFlowTransformersModule } from './modules/node-transformers/ControlFlowTransformersModule'; import { convertingTransformersModule } from './modules/node-transformers/ConvertingTransformersModule'; import { customNodesModule } from './modules/custom-nodes/CustomNodesModule'; +import { generatorsModule } from './modules/generators/GeneratorsModule'; import { nodeTransformersModule } from './modules/node-transformers/NodeTransformersModule'; import { obfuscatingTransformersModule } from './modules/node-transformers/ObfuscatingTransformersModule'; import { preparingTransformersModule } from './modules/node-transformers/PreparingTransformersModule'; @@ -197,6 +198,7 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { this.container.load(controlFlowTransformersModule); this.container.load(convertingTransformersModule); this.container.load(customNodesModule); + this.container.load(generatorsModule); this.container.load(nodeTransformersModule); this.container.load(obfuscatingTransformersModule); this.container.load(preparingTransformersModule); diff --git a/src/container/ServiceIdentifiers.ts b/src/container/ServiceIdentifiers.ts index cca98bf7..fe38d6a5 100644 --- a/src/container/ServiceIdentifiers.ts +++ b/src/container/ServiceIdentifiers.ts @@ -4,6 +4,7 @@ export enum ServiceIdentifiers { Factory__IControlFlowReplacer = 'Factory', Factory__ICustomNode = 'Factory', Factory__ICustomNodeGroup = 'Factory', + Factory__IIdentifierNameGenerator = 'Factory', Factory__IIdentifierObfuscatingReplacer = 'Factory', Factory__INodeGuard = 'Factory', Factory__INodeTransformer = 'Factory', @@ -16,8 +17,8 @@ export enum ServiceIdentifiers { ICustomNode = 'ICustomNode', ICustomNodeGroup = 'ICustomNodeGroup', IControlFlowReplacer = 'IControlFlowReplacer', - IDeadCodeInjectionReplacer = 'IDeadCodeInjectionReplacer', IEscapeSequenceEncoder = 'IEscapeSequenceEncoder', + IIdentifierNameGenerator = 'IIdentifierNameGenerator', IIdentifierObfuscatingReplacer = 'IIdentifierObfuscatingReplacer', IJavaScriptObfuscator = 'IJavaScriptObfuscator', ILogger = 'ILogger', diff --git a/src/container/modules/custom-nodes/CustomNodesModule.ts b/src/container/modules/custom-nodes/CustomNodesModule.ts index 5ff2e2e5..168005de 100644 --- a/src/container/modules/custom-nodes/CustomNodesModule.ts +++ b/src/container/modules/custom-nodes/CustomNodesModule.ts @@ -145,6 +145,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule .toFactory(InversifyContainerFacade .getConstructorFactory( ServiceIdentifiers.Newable__ICustomNode, + ServiceIdentifiers.Factory__IIdentifierNameGenerator, ServiceIdentifiers.IRandomGenerator, ServiceIdentifiers.IOptions )); diff --git a/src/container/modules/generators/GeneratorsModule.ts b/src/container/modules/generators/GeneratorsModule.ts new file mode 100644 index 00000000..019b07ee --- /dev/null +++ b/src/container/modules/generators/GeneratorsModule.ts @@ -0,0 +1,58 @@ +import { ContainerModule, interfaces } from 'inversify'; +import { ServiceIdentifiers } from '../../ServiceIdentifiers'; + +import { IIdentifierNameGenerator } from '../../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; +import { IOptions } from '../../../interfaces/options/IOptions'; + +import { IdentifierNameGenerator } from '../../../enums/generators/identifier-name-generators/IdentifierNameGenerator'; + +import { HexadecimalIdentifierNameGenerator } from '../../../generators/identifier-name-generators/HexadecimalIdentifierNameGenerator'; +import { MangledIdentifierNameGenerator } from '../../../generators/identifier-name-generators/MangledIdentifierNameGenerator'; + +export const generatorsModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { + // identifier name generators + bind(ServiceIdentifiers.IIdentifierNameGenerator) + .to(HexadecimalIdentifierNameGenerator) + .inSingletonScope() + .whenTargetNamed(IdentifierNameGenerator.HexadecimalIdentifierNameGenerator); + + bind(ServiceIdentifiers.IIdentifierNameGenerator) + .to(MangledIdentifierNameGenerator) + .inSingletonScope() + .whenTargetNamed(IdentifierNameGenerator.MangledIdentifierNameGenerator); + + // identifier name generator factory + bind(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + .toFactory((context: interfaces.Context): (options: IOptions) => IIdentifierNameGenerator => { + const cache: Map = new Map(); + + return (options: IOptions) => { + if (cache.has(options.mangle)) { + return cache.get(options.mangle); + } + + let identifierNameGenerator: IIdentifierNameGenerator; + + switch (options.mangle) { + case true: + identifierNameGenerator = context.container.getNamed( + ServiceIdentifiers.IIdentifierNameGenerator, + IdentifierNameGenerator.MangledIdentifierNameGenerator + ); + + break; + + case false: + default: + identifierNameGenerator = context.container.getNamed( + ServiceIdentifiers.IIdentifierNameGenerator, + IdentifierNameGenerator.HexadecimalIdentifierNameGenerator + ); + } + + cache.set(options.mangle, identifierNameGenerator); + + return identifierNameGenerator; + }; + }); +}); diff --git a/src/container/modules/storages/StoragesModule.ts b/src/container/modules/storages/StoragesModule.ts index 773991e7..a8c94e02 100644 --- a/src/container/modules/storages/StoragesModule.ts +++ b/src/container/modules/storages/StoragesModule.ts @@ -5,6 +5,7 @@ import { TControlFlowStorage } from '../../../types/storages/TControlFlowStorage import { TCustomNodeGroupStorage } from '../../../types/storages/TCustomNodeGroupStorage'; import { TStringArrayStorage } from '../../../types/storages/TStringArrayStorage'; +import { IOptions } from '../../../interfaces/options/IOptions'; import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator'; import { ControlFlowStorage } from '../../../storages/control-flow/ControlFlowStorage'; @@ -32,8 +33,10 @@ export const storagesModule: interfaces.ContainerModule = new ContainerModule((b .get>(ServiceIdentifiers.Newable__TControlFlowStorage); const randomGenerator: IRandomGenerator = context.container .get(ServiceIdentifiers.IRandomGenerator); + const options: IOptions = context.container + .get(ServiceIdentifiers.IOptions); - const storage: TControlFlowStorage = new constructor(randomGenerator); + const storage: TControlFlowStorage = new constructor(randomGenerator, options); storage.initialize(); diff --git a/src/custom-nodes/AbstractCustomNode.ts b/src/custom-nodes/AbstractCustomNode.ts index fe2def25..72440208 100644 --- a/src/custom-nodes/AbstractCustomNode.ts +++ b/src/custom-nodes/AbstractCustomNode.ts @@ -1,9 +1,11 @@ import { inject, injectable } from 'inversify'; import { ServiceIdentifiers } from '../container/ServiceIdentifiers'; +import { TIdentifierNameGeneratorFactory } from '../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../types/node/TStatement'; import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; +import { IIdentifierNameGenerator } from '../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; import { IOptions } from '../interfaces/options/IOptions'; import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator'; @@ -32,6 +34,11 @@ export abstract class AbstractCustomNode implements ICustomNode { */ protected cachedNode: TStatement[]; + /** + * @type {IIdentifierNameGenerator} + */ + protected readonly identifierNameGenerator: IIdentifierNameGenerator; + /** * @type {IOptions} */ @@ -43,13 +50,17 @@ export abstract class AbstractCustomNode implements ICustomNode { protected readonly randomGenerator: IRandomGenerator; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { + this.identifierNameGenerator = identifierNameGeneratorFactory(options); this.randomGenerator = randomGenerator; this.options = options; } diff --git a/src/custom-nodes/AbstractCustomNodeGroup.ts b/src/custom-nodes/AbstractCustomNodeGroup.ts index 75fafab9..b3f72995 100644 --- a/src/custom-nodes/AbstractCustomNodeGroup.ts +++ b/src/custom-nodes/AbstractCustomNodeGroup.ts @@ -1,10 +1,12 @@ import { inject, injectable } from 'inversify'; import { ServiceIdentifiers } from '../container/ServiceIdentifiers'; +import { TIdentifierNameGeneratorFactory } from '../types/container/generators/TIdentifierNameGeneratorFactory'; import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement'; import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup'; +import { IIdentifierNameGenerator } from '../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; import { IOptions } from '../interfaces/options/IOptions'; import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator'; import { IStackTraceData } from '../interfaces/analyzers/stack-trace-analyzer/IStackTraceData'; @@ -25,9 +27,9 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup { protected abstract customNodes: Map ; /** - * @type {IStackTraceData[]} + * @type {IIdentifierNameGenerator} */ - protected readonly stackTraceData: IStackTraceData[]; + protected readonly identifierNameGenerator: IIdentifierNameGenerator; /** * @type {IOptions} @@ -40,13 +42,22 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup { protected readonly randomGenerator: IRandomGenerator; /** + * @type {IStackTraceData[]} + */ + protected readonly stackTraceData: IStackTraceData[]; + + /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { + this.identifierNameGenerator = identifierNameGeneratorFactory(options); this.randomGenerator = randomGenerator; this.options = options; } diff --git a/src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts b/src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts index 54ae72a9..494c169f 100644 --- a/src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts +++ b/src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts @@ -17,6 +17,7 @@ import { initializable } from '../../decorators/Initializable'; import { AbstractCustomNode } from '../AbstractCustomNode'; import { NodeUtils } from '../../node/NodeUtils'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; @injectable() export class ConsoleOutputDisableExpressionNode extends AbstractCustomNode { @@ -27,14 +28,17 @@ export class ConsoleOutputDisableExpressionNode extends AbstractCustomNode { private callsControllerFunctionName: string; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** @@ -60,7 +64,7 @@ export class ConsoleOutputDisableExpressionNode extends AbstractCustomNode { : GlobalVariableNoEvalTemplate(); return format(ConsoleOutputDisableExpressionTemplate(), { - consoleLogDisableFunctionName: this.randomGenerator.getRandomVariableName(6), + consoleLogDisableFunctionName: this.identifierNameGenerator.generate(6), globalVariableTemplate, singleNodeCallControllerFunctionName: this.callsControllerFunctionName }); diff --git a/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts b/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts index 044d03d2..008b72ff 100644 --- a/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts +++ b/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts @@ -2,6 +2,7 @@ import { inject, injectable, } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; @@ -37,15 +38,18 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup { /** * @param {TCustomNodeFactory} customNodeFactory + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory, + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.customNodeFactory = customNodeFactory; } @@ -88,7 +92,7 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup { return; } - const callsControllerFunctionName: string = this.randomGenerator.getRandomVariableName(6); + const callsControllerFunctionName: string = this.identifierNameGenerator.generate(6); const consoleOutputDisableExpressionNode: ICustomNode = this.customNodeFactory(CustomNode.ConsoleOutputDisableExpressionNode); const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNode.NodeCallsControllerFunctionNode); diff --git a/src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts b/src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts index cc298c76..c7130f96 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { BinaryOperator } from 'estree'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -23,14 +24,17 @@ export class BinaryExpressionFunctionNode extends AbstractCustomNode { private operator: BinaryOperator; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts b/src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts index f3fc8099..08a026ad 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -36,14 +37,17 @@ export class BlockStatementControlFlowFlatteningNode extends AbstractCustomNode private shuffledKeys: number[]; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts b/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts index 3f92681e..148b602a 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -23,14 +24,17 @@ export class CallExpressionFunctionNode extends AbstractCustomNode { private expressionArguments: (ESTree.Expression | ESTree.SpreadElement)[]; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts b/src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts index 6e378025..6b3d13b7 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { LogicalOperator } from 'estree'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -23,14 +24,17 @@ export class LogicalExpressionFunctionNode extends AbstractCustomNode { private operator: LogicalOperator; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/StringLiteralNode.ts b/src/custom-nodes/control-flow-flattening-nodes/StringLiteralNode.ts index 9ca5352b..24f1cb22 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/StringLiteralNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/StringLiteralNode.ts @@ -1,6 +1,7 @@ import { inject, injectable, } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -20,14 +21,17 @@ export class StringLiteralNode extends AbstractCustomNode { private literalValue: string; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts index dc389479..d9bb68b1 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode.ts @@ -4,6 +4,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; import { Expression } from 'estree'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../../types/node/TStatement'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -42,14 +43,17 @@ export class CallExpressionControlFlowStorageCallNode extends AbstractCustomNode private expressionArguments: (ESTree.Expression | ESTree.SpreadElement)[]; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts index f39e9fb8..8d8555f6 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../../types/node/TStatement'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; @@ -25,14 +26,17 @@ export class ControlFlowStorageNode extends AbstractCustomNode { private controlFlowStorage: IStorage ; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts index 0a550d90..2b7e5d94 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { Expression } from 'estree'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../../types/node/TStatement'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -41,14 +42,17 @@ export class ExpressionWithOperatorControlFlowStorageCallNode extends AbstractCu private rightValue: Expression; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts index e725837e..7240134b 100644 --- a/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts +++ b/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode.ts @@ -1,6 +1,7 @@ import { inject, injectable, } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../../types/node/TStatement'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -27,14 +28,17 @@ export class StringLiteralControlFlowStorageCallNode extends AbstractCustomNode private controlFlowStorageName: string; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts index 85bd1d3f..a1e4835b 100644 --- a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts +++ b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -24,14 +25,17 @@ export class DebugProtectionFunctionCallNode extends AbstractCustomNode { private debugProtectionFunctionName: string; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts index def0117b..575b8fd5 100644 --- a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts +++ b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -24,14 +25,17 @@ export class DebugProtectionFunctionIntervalNode extends AbstractCustomNode { private debugProtectionFunctionName: string; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts index 3e22828d..52c04b5e 100644 --- a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts +++ b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -28,14 +29,17 @@ export class DebugProtectionFunctionNode extends AbstractCustomNode { private debugProtectionFunctionName: string; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts b/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts index 72a8a145..b0736cb0 100644 --- a/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts +++ b/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts @@ -2,6 +2,7 @@ import { inject, injectable, } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; @@ -37,15 +38,18 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup { /** * @param {TCustomNodeFactory} customNodeFactory + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory, + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.customNodeFactory = customNodeFactory; } @@ -88,7 +92,7 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup { return; } - const debugProtectionFunctionName: string = this.randomGenerator.getRandomVariableName(6); + const debugProtectionFunctionName: string = this.identifierNameGenerator.generate(6); const debugProtectionFunctionNode: ICustomNode = this.customNodeFactory(CustomNode.DebugProtectionFunctionNode); const debugProtectionFunctionCallNode: ICustomNode = this.customNodeFactory(CustomNode.DebugProtectionFunctionCallNode); diff --git a/src/custom-nodes/domain-lock-nodes/DomainLockNode.ts b/src/custom-nodes/domain-lock-nodes/DomainLockNode.ts index 188525eb..1614dcd7 100644 --- a/src/custom-nodes/domain-lock-nodes/DomainLockNode.ts +++ b/src/custom-nodes/domain-lock-nodes/DomainLockNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { ICryptUtils } from '../../interfaces/utils/ICryptUtils'; @@ -33,16 +34,19 @@ export class DomainLockNode extends AbstractCustomNode { private readonly cryptUtils: ICryptUtils; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {ICryptUtils} cryptUtils * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.ICryptUtils) cryptUtils: ICryptUtils, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.cryptUtils = cryptUtils; } @@ -75,7 +79,7 @@ export class DomainLockNode extends AbstractCustomNode { : GlobalVariableNoEvalTemplate(); return format(DomainLockNodeTemplate(), { - domainLockFunctionName: this.randomGenerator.getRandomVariableName(6), + domainLockFunctionName: this.identifierNameGenerator.generate(6), diff: diff, domains: hiddenDomainsString, globalVariableTemplate, diff --git a/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts b/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts index acf35942..ba57b7fb 100644 --- a/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts +++ b/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts @@ -2,6 +2,7 @@ import { inject, injectable, } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; @@ -37,15 +38,18 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup { /** * @param {TCustomNodeFactory} customNodeFactory + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory, + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.customNodeFactory = customNodeFactory; } @@ -88,7 +92,7 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup { return; } - const callsControllerFunctionName: string = this.randomGenerator.getRandomVariableName(6); + const callsControllerFunctionName: string = this.identifierNameGenerator.generate(6); const domainLockNode: ICustomNode = this.customNodeFactory(CustomNode.DomainLockNode); const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNode.NodeCallsControllerFunctionNode); diff --git a/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts b/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts index a096cc56..2c8a17a4 100644 --- a/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts +++ b/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -35,14 +36,17 @@ export class NodeCallsControllerFunctionNode extends AbstractCustomNode { private appendEvent: ObfuscationEvent; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** @@ -72,6 +76,7 @@ export class NodeCallsControllerFunctionNode extends AbstractCustomNode { }), { ...NO_CUSTOM_NODES_PRESET, + mangle: this.options.mangle, seed: this.options.seed } ).getObfuscatedCode(); diff --git a/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts b/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts index ef346810..05414d84 100644 --- a/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts +++ b/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder'; @@ -33,16 +34,19 @@ export class SelfDefendingUnicodeNode extends AbstractCustomNode { private callsControllerFunctionName: string; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IEscapeSequenceEncoder} escapeSequenceEncoder * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.escapeSequenceEncoder = escapeSequenceEncoder; } @@ -67,11 +71,12 @@ export class SelfDefendingUnicodeNode extends AbstractCustomNode { protected getTemplate (): string { return JavaScriptObfuscator.obfuscate( format(SelfDefendingTemplate(this.escapeSequenceEncoder), { - selfDefendingFunctionName: this.randomGenerator.getRandomVariableName(6), + selfDefendingFunctionName: this.identifierNameGenerator.generate(6), singleNodeCallControllerFunctionName: this.callsControllerFunctionName }), { ...NO_CUSTOM_NODES_PRESET, + mangle: this.options.mangle, seed: this.options.seed, unicodeEscapeSequence: true } diff --git a/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts b/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts index e1dbeed7..90e8e642 100644 --- a/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts +++ b/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts @@ -2,6 +2,7 @@ import { inject, injectable, } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; @@ -37,15 +38,18 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup { /** * @param {TCustomNodeFactory} customNodeFactory + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory, + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.customNodeFactory = customNodeFactory; } @@ -88,7 +92,7 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup { return; } - const callsControllerFunctionName: string = this.randomGenerator.getRandomVariableName(6); + const callsControllerFunctionName: string = this.identifierNameGenerator.generate(6); const selfDefendingUnicodeNode: ICustomNode = this.customNodeFactory(CustomNode.SelfDefendingUnicodeNode); const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNode.NodeCallsControllerFunctionNode); diff --git a/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts b/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts index bbe3c551..cb15116b 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder'; @@ -48,16 +49,19 @@ export class StringArrayCallsWrapper extends AbstractCustomNode { private stringArrayCallsWrapperName: string; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IEscapeSequenceEncoder} escapeSequenceEncoder * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.escapeSequenceEncoder = escapeSequenceEncoder; } @@ -95,6 +99,7 @@ export class StringArrayCallsWrapper extends AbstractCustomNode { }), { ...NO_CUSTOM_NODES_PRESET, + mangle: this.options.mangle, seed: this.options.seed } ).getObfuscatedCode(); diff --git a/src/custom-nodes/string-array-nodes/StringArrayNode.ts b/src/custom-nodes/string-array-nodes/StringArrayNode.ts index 1d071463..4d7983b0 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayNode.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -38,14 +39,17 @@ export class StringArrayNode extends AbstractCustomNode { private stringArrayRotateValue: number; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); } /** diff --git a/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts b/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts index 111603fa..1def3eff 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts @@ -3,6 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as format from 'string-template'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TStatement } from '../../types/node/TStatement'; import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder'; @@ -41,16 +42,19 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode { private stringArrayRotateValue: number; /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IRandomGenerator} randomGenerator * @param {IEscapeSequenceEncoder} escapeSequenceEncoder * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.escapeSequenceEncoder = escapeSequenceEncoder; } @@ -78,8 +82,8 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode { * @returns {string} */ protected getTemplate (): string { - const timesName: string = this.randomGenerator.getRandomVariableName(6); - const whileFunctionName: string = this.randomGenerator.getRandomVariableName(6); + const timesName: string = this.identifierNameGenerator.generate(6); + const whileFunctionName: string = this.identifierNameGenerator.generate(6); let code: string = ''; @@ -102,6 +106,7 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode { }), { ...NO_CUSTOM_NODES_PRESET, + mangle: this.options.mangle, seed: this.options.seed } ).getObfuscatedCode(); diff --git a/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts b/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts index 3cadb8d9..a70b0bfb 100644 --- a/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts +++ b/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts @@ -2,6 +2,7 @@ import { inject, injectable, } from 'inversify'; import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; +import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory'; import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; @@ -17,7 +18,6 @@ import { ObfuscationEvent } from '../../../enums/event-emitters/ObfuscationEvent import { AbstractCustomNodeGroup } from '../../AbstractCustomNodeGroup'; import { NodeAppender } from '../../../node/NodeAppender'; -import { Utils } from '../../../utils/Utils'; @injectable() export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup { @@ -45,17 +45,20 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup { /** * @param {TCustomNodeFactory} customNodeFactory - * @param {IRandomGenerator} randomGenerator * @param {IStorage} stringArrayStorage + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory + * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( @inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory, - @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.TStringArrayStorage) stringArrayStorage: IStorage, + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator, options); + super(identifierNameGeneratorFactory, randomGenerator, options); this.customNodeFactory = customNodeFactory; this.stringArrayStorage = stringArrayStorage; @@ -99,8 +102,7 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup { const stringArrayStorageId: string = this.stringArrayStorage.getStorageId(); - const stringArrayName: string = `_${Utils.hexadecimalPrefix}${stringArrayStorageId}`; - const stringArrayCallsWrapperName: string = `_${Utils.hexadecimalPrefix}${Utils.stringRotate(stringArrayStorageId, 1)}`; + const [stringArrayName, stringArrayCallsWrapperName]: string[] = stringArrayStorageId.split('|'); let stringArrayRotateValue: number; diff --git a/src/declarations/esmangle.d.ts b/src/declarations/esmangle.d.ts deleted file mode 100644 index 7795f89c..00000000 --- a/src/declarations/esmangle.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare module "esmangle" { - import * as ESTree from 'estree'; - - function mangle (ast: ESTree.Program): ESTree.Program; -} diff --git a/src/enums/generators/identifier-name-generators/IdentifierNameGenerator.ts b/src/enums/generators/identifier-name-generators/IdentifierNameGenerator.ts new file mode 100644 index 00000000..d5ec2db4 --- /dev/null +++ b/src/enums/generators/identifier-name-generators/IdentifierNameGenerator.ts @@ -0,0 +1,4 @@ +export enum IdentifierNameGenerator { + HexadecimalIdentifierNameGenerator, + MangledIdentifierNameGenerator +} diff --git a/src/generators/identifier-name-generators/AbstractIdentifierNameGenerator.ts b/src/generators/identifier-name-generators/AbstractIdentifierNameGenerator.ts new file mode 100644 index 00000000..00fb1e34 --- /dev/null +++ b/src/generators/identifier-name-generators/AbstractIdentifierNameGenerator.ts @@ -0,0 +1,37 @@ +import { inject, injectable } from 'inversify'; +import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; + +import { IIdentifierNameGenerator } from '../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; +import { IOptions } from '../../interfaces/options/IOptions'; +import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; + +@injectable() +export abstract class AbstractIdentifierNameGenerator implements IIdentifierNameGenerator { + /** + * @type {IOptions} + */ + protected readonly options: IOptions; + + /** + * @type {IRandomGenerator} + */ + protected readonly randomGenerator: IRandomGenerator; + + /** + * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options + */ + constructor ( + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions + ) { + this.randomGenerator = randomGenerator; + this.options = options; + } + + /** + * @param {number} length + * @returns {string} + */ + public abstract generate (length: number): string; +} diff --git a/src/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.ts b/src/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.ts new file mode 100644 index 00000000..c63c75ca --- /dev/null +++ b/src/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.ts @@ -0,0 +1,48 @@ +import { inject, injectable } from 'inversify'; +import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; + +import { IOptions } from '../../interfaces/options/IOptions'; +import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; + +import { AbstractIdentifierNameGenerator } from './AbstractIdentifierNameGenerator'; +import { Utils } from '../../utils/Utils'; + +@injectable() +export class HexadecimalIdentifierNameGenerator extends AbstractIdentifierNameGenerator { + /** + * @type {Set} + */ + private readonly randomVariableNameSet: Set = new Set(); + + /** + * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options + */ + constructor ( + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions + ) { + super(randomGenerator, options); + } + + /** + * @param {number} length + * @returns {string} + */ + public generate (length: number): string { + const prefix: string = `_${Utils.hexadecimalPrefix}`; + const rangeMinInteger: number = 10000; + const rangeMaxInteger: number = 99999999; + const randomInteger: number = this.randomGenerator.getRandomInteger(rangeMinInteger, rangeMaxInteger); + const hexadecimalNumber: string = Utils.decToHex(randomInteger); + const randomVariableName: string = `${prefix}${hexadecimalNumber.substr(0, length)}`; + + if (this.randomVariableNameSet.has(randomVariableName)) { + return this.generate(length); + } + + this.randomVariableNameSet.add(randomVariableName); + + return randomVariableName; + } +} diff --git a/src/generators/identifier-name-generators/MangledIdentifierNameGenerator.ts b/src/generators/identifier-name-generators/MangledIdentifierNameGenerator.ts new file mode 100644 index 00000000..19de1a03 --- /dev/null +++ b/src/generators/identifier-name-generators/MangledIdentifierNameGenerator.ts @@ -0,0 +1,116 @@ +import { inject, injectable } from 'inversify'; +import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; + +import { IOptions } from '../../interfaces/options/IOptions'; +import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; + +import { AbstractIdentifierNameGenerator } from './AbstractIdentifierNameGenerator'; + +@injectable() +export class MangledIdentifierNameGenerator extends AbstractIdentifierNameGenerator { + /** + * @type {string} + */ + private static initMangledNameCharacter: string = '9'; + + /** + * @type {string[]} + */ + private static nameSequence: string[] = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'.split(''); + + /** + * Reserved JS words with length of 2-4 symbols that can be possible generated with this replacer + * + * @type {string[]} + */ + private static reservedNames: string[] = [ + 'byte', 'case', 'char', 'do', 'else', 'enum', 'eval', 'for', 'goto', + 'if', 'in', 'int', 'let', 'long', 'new', 'null', 'this', 'true', 'try', + 'var', 'void', 'with' + ]; + + /** + * @type {string} + */ + private previousMangledName: string = MangledIdentifierNameGenerator.initMangledNameCharacter; + + /** + * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options + */ + constructor ( + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions + ) { + super(randomGenerator, options); + } + + /** + * @param {string} previousMangledName + * @returns {string} + */ + private static generateNewMangledName (previousMangledName: string): string { + const generateNewMangledName: (name: string) => string = (name: string): string => { + const nameSequence: string[] = MangledIdentifierNameGenerator.nameSequence; + const zeroSequenceCache: string[] = []; + + const zeroSequence: (num: number) => string = (num: number): string => { + let result: string = zeroSequenceCache[num]; + + if (result !== undefined) { + return result; + } + + result = '0'.repeat(num); + zeroSequenceCache[num] = result; + + return result; + }; + + let cur: number = name.length - 1; + + do { + let character: string, index: number; + + character = name.charAt(cur); + index = nameSequence.indexOf(character); + + if (index !== (nameSequence.length - 1)) { + return name.substring(0, cur) + nameSequence[index + 1] + zeroSequence(name.length - (cur + 1)); + } + + --cur; + } while (cur >= 0); + + return `a${zeroSequence(name.length)}`; + }; + + let newMangledName: string = generateNewMangledName(previousMangledName); + + if (!MangledIdentifierNameGenerator.validateMangledName(newMangledName)) { + newMangledName = MangledIdentifierNameGenerator.generateNewMangledName(newMangledName); + } + + return newMangledName; + } + + /** + * @param {string} mangledName + * @returns {boolean} + */ + private static validateMangledName (mangledName: string): boolean { + return !MangledIdentifierNameGenerator.reservedNames.includes(mangledName); + } + + /** + * @param {number} length + * @returns {string} + */ + public generate (length: number): string { + const newName: string = MangledIdentifierNameGenerator.generateNewMangledName(this.previousMangledName); + + this.previousMangledName = newName; + + return newName; + } +} diff --git a/src/interfaces/generators/identifier-name-generators/IIdentifierNameGenerator.d.ts b/src/interfaces/generators/identifier-name-generators/IIdentifierNameGenerator.d.ts new file mode 100644 index 00000000..88c63497 --- /dev/null +++ b/src/interfaces/generators/identifier-name-generators/IIdentifierNameGenerator.d.ts @@ -0,0 +1,7 @@ +export interface IIdentifierNameGenerator { + /** + * @param {number} length + * @returns {string} + */ + generate (length: number): string; +} diff --git a/src/interfaces/node-transformers/dead-code-injection-transformers/IDeadCodeInjectionReplacer.d.ts b/src/interfaces/node-transformers/dead-code-injection-transformers/IDeadCodeInjectionReplacer.d.ts deleted file mode 100644 index 79b05e9a..00000000 --- a/src/interfaces/node-transformers/dead-code-injection-transformers/IDeadCodeInjectionReplacer.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import * as ESTree from 'estree'; - -export interface IDeadCodeInjectionReplacer { - /** - * @param node - * @param parentNode - * @returns ESTree.Node - */ - replace ( - node: ESTree.Node, - parentNode: ESTree.Node - ): ESTree.Node; -} diff --git a/src/interfaces/utils/IRandomGenerator.d.ts b/src/interfaces/utils/IRandomGenerator.d.ts index d290e0ce..686d36d4 100644 --- a/src/interfaces/utils/IRandomGenerator.d.ts +++ b/src/interfaces/utils/IRandomGenerator.d.ts @@ -32,12 +32,6 @@ export interface IRandomGenerator { */ getRandomString (length: number, pool?: string): string; - /** - * @param length - * @returns {string} - */ - getRandomVariableName (length: number): string; - /** * @returns {number} */ diff --git a/src/node-transformers/obfuscating-transformers/obfuscating-replacers/identifier-obfuscating-replacers/BaseIdentifierObfuscatingReplacer.ts b/src/node-transformers/obfuscating-transformers/obfuscating-replacers/identifier-obfuscating-replacers/BaseIdentifierObfuscatingReplacer.ts index dfbedf82..8aaed075 100644 --- a/src/node-transformers/obfuscating-transformers/obfuscating-replacers/identifier-obfuscating-replacers/BaseIdentifierObfuscatingReplacer.ts +++ b/src/node-transformers/obfuscating-transformers/obfuscating-replacers/identifier-obfuscating-replacers/BaseIdentifierObfuscatingReplacer.ts @@ -3,36 +3,39 @@ import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers'; import * as ESTree from 'estree'; +import { TIdentifierNameGeneratorFactory } from '../../../../types/container/generators/TIdentifierNameGeneratorFactory'; + +import { IIdentifierNameGenerator } from '../../../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; import { IIdentifierObfuscatingReplacer } from '../../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer'; import { IOptions } from '../../../../interfaces/options/IOptions'; -import { IRandomGenerator } from '../../../../interfaces/utils/IRandomGenerator'; import { AbstractObfuscatingReplacer } from '../AbstractObfuscatingReplacer'; import { Nodes } from '../../../../node/Nodes'; @injectable() export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplacer implements IIdentifierObfuscatingReplacer { + /** + * @type {IIdentifierNameGenerator} + */ + private readonly identifierNameGenerator: IIdentifierNameGenerator; + /** * @type {Map} */ private readonly namesMap: Map = new Map(); /** - * @type {IRandomGenerator} - */ - private readonly randomGenerator: IRandomGenerator; - - /** - * @param {IRandomGenerator} randomGenerator + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IOptions} options */ constructor ( - @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { super(options); - this.randomGenerator = randomGenerator; + this.identifierNameGenerator = identifierNameGeneratorFactory(options); } /** @@ -62,7 +65,7 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac return; } - this.namesMap.set(`${nodeName}-${String(nodeIdentifier)}`, this.randomGenerator.getRandomVariableName(6)); + this.namesMap.set(`${nodeName}-${String(nodeIdentifier)}`, this.identifierNameGenerator.generate(6)); } /** diff --git a/src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts b/src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts index b10c0e26..6898c67c 100644 --- a/src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts +++ b/src/node-transformers/obfuscating-transformers/obfuscating-replacers/literal-obfuscating-replacers/StringLiteralObfuscatingReplacer.ts @@ -229,8 +229,7 @@ export class StringLiteralObfuscatingReplacer extends AbstractObfuscatingReplace const escapedValue: string = this.escapeSequenceEncoder.encode(encodedValue, this.options.unicodeEscapeSequence); const stringArrayStorageLength: number = this.stringArrayStorage.getLength(); - const rotatedStringArrayStorageId: string = Utils.stringRotate(this.stringArrayStorage.getStorageId(), 1); - const stringArrayStorageCallsWrapperName: string = `_${Utils.hexadecimalPrefix}${rotatedStringArrayStorageId}`; + const stringArrayStorageCallsWrapperName: string = this.stringArrayStorage.getStorageId().split('|')[1]; const { fromCache, index }: IStringArrayIndexData = this.getStringArrayHexadecimalIndex( escapedValue, diff --git a/src/storages/ArrayStorage.ts b/src/storages/ArrayStorage.ts index ff65a7dc..a009c1a9 100644 --- a/src/storages/ArrayStorage.ts +++ b/src/storages/ArrayStorage.ts @@ -1,6 +1,7 @@ import { inject, injectable, postConstruct } from 'inversify'; import { ServiceIdentifiers } from '../container/ServiceIdentifiers'; +import { IOptions } from '../interfaces/options/IOptions'; import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator'; import { IStorage } from '../interfaces/storages/IStorage'; @@ -13,6 +14,11 @@ export abstract class ArrayStorage implements IStorage { */ protected readonly randomGenerator: IRandomGenerator; + /** + * @type {IOptions} + */ + protected readonly options: IOptions; + /** * @type {T[]} */ @@ -32,11 +38,14 @@ export abstract class ArrayStorage implements IStorage { /** * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options */ constructor ( - @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions ) { this.randomGenerator = randomGenerator; + this.options = options; } @postConstruct() diff --git a/src/storages/MapStorage.ts b/src/storages/MapStorage.ts index 506a26ee..45cb44a0 100644 --- a/src/storages/MapStorage.ts +++ b/src/storages/MapStorage.ts @@ -1,6 +1,7 @@ import { inject, injectable, postConstruct } from 'inversify'; import { ServiceIdentifiers } from '../container/ServiceIdentifiers'; +import { IOptions } from '../interfaces/options/IOptions'; import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator'; import { IStorage } from '../interfaces/storages/IStorage'; @@ -8,6 +9,11 @@ import { initializable } from '../decorators/Initializable'; @injectable() export abstract class MapStorage implements IStorage { + /** + * @type {IOptions} + */ + protected readonly options: IOptions; + /** * @type {IRandomGenerator} */ @@ -27,11 +33,14 @@ export abstract class MapStorage implements IStorage { /** * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options */ constructor ( - @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions ) { this.randomGenerator = randomGenerator; + this.options = options; } @postConstruct() diff --git a/src/storages/control-flow/ControlFlowStorage.ts b/src/storages/control-flow/ControlFlowStorage.ts index 207856d0..20d8ee65 100644 --- a/src/storages/control-flow/ControlFlowStorage.ts +++ b/src/storages/control-flow/ControlFlowStorage.ts @@ -2,6 +2,7 @@ import { inject, injectable, } from 'inversify'; import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode'; +import { IOptions } from '../../interfaces/options/IOptions'; import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { MapStorage } from '../MapStorage'; @@ -10,10 +11,12 @@ import { MapStorage } from '../MapStorage'; export class ControlFlowStorage extends MapStorage { /** * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options */ constructor ( - @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator); + super(randomGenerator, options); } } diff --git a/src/storages/custom-node-group/CustomNodeGroupStorage.ts b/src/storages/custom-node-group/CustomNodeGroupStorage.ts index 62268db0..351ba86d 100644 --- a/src/storages/custom-node-group/CustomNodeGroupStorage.ts +++ b/src/storages/custom-node-group/CustomNodeGroupStorage.ts @@ -4,6 +4,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { TCustomNodeGroupFactory } from '../../types/container/custom-nodes/TCustomNodeGroupFactory'; import { ICustomNodeGroup } from '../../interfaces/custom-nodes/ICustomNodeGroup'; +import { IOptions } from '../../interfaces/options/IOptions'; import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { CustomNodeGroup } from '../../enums/custom-nodes/CustomNodeGroup'; @@ -31,12 +32,14 @@ export class CustomNodeGroupStorage extends MapStorage { /** * @param {TCustomNodeGroupFactory} customNodeGroupFactory * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options */ constructor ( @inject(ServiceIdentifiers.Factory__ICustomNodeGroup) customNodeGroupFactory: TCustomNodeGroupFactory, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator); + super(randomGenerator, options); this.customNodeGroupFactory = customNodeGroupFactory; } diff --git a/src/storages/string-array/StringArrayStorage.ts b/src/storages/string-array/StringArrayStorage.ts index eb4e2ae4..58cbe8c4 100644 --- a/src/storages/string-array/StringArrayStorage.ts +++ b/src/storages/string-array/StringArrayStorage.ts @@ -4,8 +4,11 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import { IArrayUtils } from '../../interfaces/utils/IArrayUtils'; import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; +import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory'; +import { IIdentifierNameGenerator } from '../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; +import { IOptions } from '../../interfaces/options/IOptions'; + import { ArrayStorage } from '../ArrayStorage'; -import { RandomGenerator } from '../../utils/RandomGenerator'; @injectable() export class StringArrayStorage extends ArrayStorage { @@ -15,15 +18,26 @@ export class StringArrayStorage extends ArrayStorage { private readonly arrayUtils: IArrayUtils; /** + * @type {IIdentifierNameGenerator} + */ + private readonly identifierNameGenerator: IIdentifierNameGenerator; + + /** + * @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory * @param {IArrayUtils} arrayUtils * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator) + identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory, @inject(ServiceIdentifiers.IArrayUtils) arrayUtils: IArrayUtils, - @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions ) { - super(randomGenerator); + super(randomGenerator, options); + this.identifierNameGenerator = identifierNameGeneratorFactory(options); this.arrayUtils = arrayUtils; } @@ -31,7 +45,10 @@ export class StringArrayStorage extends ArrayStorage { public initialize (): void { super.initialize(); - this.storageId = this.randomGenerator.getRandomString(4, RandomGenerator.randomGeneratorPoolHexadecimal); + const stringArrayName: string = this.identifierNameGenerator.generate(4); + const stringArrayCallsWrapperName: string = this.identifierNameGenerator.generate(4); + + this.storageId = `${stringArrayName}|${stringArrayCallsWrapperName}`; } /** diff --git a/src/templates/debug-protection-nodes/debug-protection-function-call-node/DebufProtectionFunctionCallTemplate.ts b/src/templates/debug-protection-nodes/debug-protection-function-call-node/DebufProtectionFunctionCallTemplate.ts index c5672ab5..54800108 100644 --- a/src/templates/debug-protection-nodes/debug-protection-function-call-node/DebufProtectionFunctionCallTemplate.ts +++ b/src/templates/debug-protection-nodes/debug-protection-function-call-node/DebufProtectionFunctionCallTemplate.ts @@ -5,7 +5,7 @@ export function DebugProtectionFunctionCallTemplate (): string { return ` (function () { var regExp1 = new RegExp('function *\\\\( *\\\\)'); - var regExp2 = new RegExp('\\\\+\\\\+ *\\(?:_0x([a-f0-9]){4,6}|\\\\b[a-zA-Z]{1,2}\\\\b\\)'); + var regExp2 = new RegExp('\\\\+\\\\+ *\\(?:_0x([a-f0-9]){4,6}|\\\\b[0-9a-zA-Z_$]{1,4}\\\\b\\)'); var result = {debugProtectionFunctionName}('init'); if (!regExp1.test(result + 'chain') || !regExp2.test(result + 'input')) { diff --git a/src/types/container/TInversifyContainerModuleFactory.d.ts b/src/types/container/TInversifyContainerModuleFactory.d.ts new file mode 100644 index 00000000..46effdc4 --- /dev/null +++ b/src/types/container/TInversifyContainerModuleFactory.d.ts @@ -0,0 +1,5 @@ +import { interfaces } from 'inversify'; + +import { TInputOptions } from '../options/TInputOptions'; + +export type TInversifyContainerModuleFactory = (options: TInputOptions) => interfaces.ContainerModule; diff --git a/src/types/container/generators/TIdentifierNameGeneratorFactory.d.ts b/src/types/container/generators/TIdentifierNameGeneratorFactory.d.ts new file mode 100644 index 00000000..f92d023d --- /dev/null +++ b/src/types/container/generators/TIdentifierNameGeneratorFactory.d.ts @@ -0,0 +1,4 @@ +import { IIdentifierNameGenerator } from '../../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; +import { IOptions } from '../../../interfaces/options/IOptions'; + +export type TIdentifierNameGeneratorFactory = (options: IOptions) => IIdentifierNameGenerator; diff --git a/src/utils/RandomGenerator.ts b/src/utils/RandomGenerator.ts index a2413f79..0d642d3a 100644 --- a/src/utils/RandomGenerator.ts +++ b/src/utils/RandomGenerator.ts @@ -11,8 +11,6 @@ import { ISourceCode } from '../interfaces/ISourceCode'; import { initializable } from '../decorators/Initializable'; -import { Utils } from './Utils'; - @injectable() export class RandomGenerator implements IRandomGenerator, IInitializable { /** @@ -35,11 +33,6 @@ export class RandomGenerator implements IRandomGenerator, IInitializable { */ private readonly options: IOptions; - /** - * @type {Set} - */ - private readonly randomVariableNameSet: Set = new Set(); - /** * @type {Chance.Chance | Chance.SeededChance} */ @@ -139,27 +132,6 @@ export class RandomGenerator implements IRandomGenerator, IInitializable { return this.getRandomGenerator().string({ length, pool }); } - /** - * @param {number} length - * @returns {string} - */ - public getRandomVariableName (length: number): string { - const prefix: string = `_${Utils.hexadecimalPrefix}`; - const rangeMinInteger: number = 10000; - const rangeMaxInteger: number = 99999999; - const randomInteger: number = this.getRandomInteger(rangeMinInteger, rangeMaxInteger); - const hexadecimalNumber: string = Utils.decToHex(randomInteger); - const randomVariableName: string = `${prefix}${hexadecimalNumber.substr(0, length)}`; - - if (this.randomVariableNameSet.has(randomVariableName)) { - return this.getRandomVariableName(length); - } - - this.randomVariableNameSet.add(randomVariableName); - - return randomVariableName; - } - /** * @returns {number} */ diff --git a/test/dev/dev.ts b/test/dev/dev.ts index 9f3332b7..c61bf8af 100644 --- a/test/dev/dev.ts +++ b/test/dev/dev.ts @@ -35,8 +35,7 @@ import { NO_CUSTOM_NODES_PRESET } from '../../src/options/presets/NoCustomNodes' { ...NO_CUSTOM_NODES_PRESET, compact: false, - deadCodeInjection: true, - deadCodeInjectionThreshold: 1 + mangle: true } ).getObfuscatedCode(); diff --git a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts index 6bde6aac..3a54700e 100644 --- a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts +++ b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts @@ -445,7 +445,7 @@ describe('JavaScriptObfuscator', () => { }); describe('mangle', () => { - const regExp: RegExp = /var *a *= *0x1/; + const regExp: RegExp = /var *c *= *0x1/; let obfuscatedCode: string; diff --git a/test/index.spec.ts b/test/index.spec.ts index 6f79a5da..09672fdc 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -14,6 +14,8 @@ import './unit-tests/cli/sanitizers/StringArrayEncodingSanitizer.spec'; import './unit-tests/cli/utils/CLIUtils.spec'; import './unit-tests/cli/utils/SourceCodeReader.spec'; import './unit-tests/decorators/initializable/Initializable.spec'; +import './unit-tests/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.spec'; +import './unit-tests/generators/identifier-name-generators/MangledlIdentifierNameGenerator.spec'; import './unit-tests/javascript-obfuscator/JavaScriptObfuscator.spec'; import './unit-tests/logger/Logger.spec'; import './unit-tests/node/node-appender/NodeAppender.spec'; @@ -27,7 +29,6 @@ import './unit-tests/storages/ArrayStorage.spec'; import './unit-tests/storages/MapStorage.spec'; import './unit-tests/utils/ArrayUtils.spec'; import './unit-tests/utils/CryptUtils.spec'; -import './unit-tests/utils/RandomGeneratorUtils.spec'; import './unit-tests/utils/EscapeSequenceEncoder.spec'; import './unit-tests/utils/Utils.spec'; diff --git a/test/unit-tests/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.spec.ts b/test/unit-tests/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.spec.ts new file mode 100644 index 00000000..8308177e --- /dev/null +++ b/test/unit-tests/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.spec.ts @@ -0,0 +1,52 @@ +import 'reflect-metadata'; + +import { assert } from 'chai'; + +import { ServiceIdentifiers } from '../../../../src/container/ServiceIdentifiers'; + +import { IIdentifierNameGenerator } from '../../../../src/interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; +import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade'; + +import { IdentifierNameGenerator } from '../../../../src/enums/generators/identifier-name-generators/IdentifierNameGenerator'; + +import { InversifyContainerFacade } from '../../../../src/container/InversifyContainerFacade'; + +describe('HexadecimalIdentifierNameGenerator', () => { + describe('generate (length: number): string', () => { + let identifierNameGenerator: IIdentifierNameGenerator, + hexadecimalIdentifierName: string, + regExp: RegExp; + + before(() => { + const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade(); + + inversifyContainerFacade.load('', {}); + identifierNameGenerator = inversifyContainerFacade.getNamed( + ServiceIdentifiers.IIdentifierNameGenerator, + IdentifierNameGenerator.HexadecimalIdentifierNameGenerator + ) + }); + + describe('variant #1: hexadecimal name with length `4`', () => { + before(() => { + hexadecimalIdentifierName = identifierNameGenerator.generate(4); + regExp = /^_0x(\w){4}$/; + }); + + it('should return hexadecimal name', () => { + assert.match(hexadecimalIdentifierName, regExp); + }) + }); + + describe('variant #2: hexadecimal name with length `6`', () => { + before(() => { + hexadecimalIdentifierName = identifierNameGenerator.generate(6); + regExp = /^_0x(\w){4,6}$/; + }); + + it('should return hexadecimal name', () => { + assert.match(hexadecimalIdentifierName, regExp); + }) + }); + }); +}); diff --git a/test/unit-tests/generators/identifier-name-generators/MangledlIdentifierNameGenerator.spec.ts b/test/unit-tests/generators/identifier-name-generators/MangledlIdentifierNameGenerator.spec.ts new file mode 100644 index 00000000..abe8e29f --- /dev/null +++ b/test/unit-tests/generators/identifier-name-generators/MangledlIdentifierNameGenerator.spec.ts @@ -0,0 +1,95 @@ +import 'reflect-metadata'; + +import { assert } from 'chai'; + +import { ServiceIdentifiers } from '../../../../src/container/ServiceIdentifiers'; + +import { IIdentifierNameGenerator } from '../../../../src/interfaces/generators/identifier-name-generators/IIdentifierNameGenerator'; +import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade'; + +import { IdentifierNameGenerator } from '../../../../src/enums/generators/identifier-name-generators/IdentifierNameGenerator'; + +import { InversifyContainerFacade } from '../../../../src/container/InversifyContainerFacade'; + +describe('MangledIdentifierNameGenerator', () => { + describe('generate (length: number): string', () => { + let identifierNameGenerator: IIdentifierNameGenerator, + mangledIdentifierName: string; + + before(() => { + const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade(); + + inversifyContainerFacade.load('', {}); + identifierNameGenerator = inversifyContainerFacade.getNamed( + ServiceIdentifiers.IIdentifierNameGenerator, + IdentifierNameGenerator.MangledIdentifierNameGenerator + ) + }); + + describe('variant #1: initial mangled name', () => { + const expectedMangledIdentifierName: string = 'a'; + + before(() => { + mangledIdentifierName = identifierNameGenerator.generate(4); + }); + + it('should return hexadecimal name', () => { + assert.equal(mangledIdentifierName, expectedMangledIdentifierName); + }) + }); + + describe('variant #2: second mangled name', () => { + const expectedMangledIdentifierName: string = 'b'; + + before(() => { + mangledIdentifierName = identifierNameGenerator.generate(6); + }); + + it('should return hexadecimal name', () => { + assert.equal(mangledIdentifierName, expectedMangledIdentifierName); + }) + }); + + describe('variant #3: special character as mangled name', () => { + const expectedMangledIdentifierName: string = '_'; + + before(() => { + for (let i: number = 0; i <= 50; i++) { + mangledIdentifierName = identifierNameGenerator.generate(6); + } + }); + + it('should return hexadecimal name', () => { + assert.equal(mangledIdentifierName, expectedMangledIdentifierName); + }) + }); + + describe('variant #4: correct increase of mangled name length', () => { + const expectedMangledIdentifierName: string = 'a0'; + + before(() => { + for (let i: number = 0; i < 2; i++) { + mangledIdentifierName = identifierNameGenerator.generate(6); + } + }); + + it('should return hexadecimal name', () => { + assert.equal(mangledIdentifierName, expectedMangledIdentifierName); + }) + }); + + describe('variant #4: correct increase of mangled name length #2', () => { + const expectedMangledIdentifierName: string = 'aa'; + + before(() => { + for (let i: number = 0; i < 10; i++) { + mangledIdentifierName = identifierNameGenerator.generate(6); + } + }); + + it('should return hexadecimal name', () => { + assert.equal(mangledIdentifierName, expectedMangledIdentifierName); + }) + }); + }); +}); diff --git a/test/unit-tests/storages/ArrayStorage.spec.ts b/test/unit-tests/storages/ArrayStorage.spec.ts index 4ecf3c21..31d12b08 100644 --- a/test/unit-tests/storages/ArrayStorage.spec.ts +++ b/test/unit-tests/storages/ArrayStorage.spec.ts @@ -3,6 +3,7 @@ import { assert } from 'chai'; import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers'; import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade'; +import { IOptions } from '../../../src/interfaces/options/IOptions'; import { IRandomGenerator } from '../../../src/interfaces/utils/IRandomGenerator'; import { IStorage } from '../../../src/interfaces/storages/IStorage'; @@ -15,7 +16,10 @@ class ConcreteStorage extends ArrayStorage { inversifyContainerFacade.load('', {}); - super(inversifyContainerFacade.get(ServiceIdentifiers.IRandomGenerator)); + super( + inversifyContainerFacade.get(ServiceIdentifiers.IRandomGenerator), + inversifyContainerFacade.get(ServiceIdentifiers.IOptions) + ); } } diff --git a/test/unit-tests/storages/MapStorage.spec.ts b/test/unit-tests/storages/MapStorage.spec.ts index 1b3b677b..eb0ff531 100644 --- a/test/unit-tests/storages/MapStorage.spec.ts +++ b/test/unit-tests/storages/MapStorage.spec.ts @@ -3,6 +3,7 @@ import { assert } from 'chai'; import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers'; import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade'; +import { IOptions } from '../../../src/interfaces/options/IOptions'; import { IRandomGenerator } from '../../../src/interfaces/utils/IRandomGenerator'; import { IStorage } from '../../../src/interfaces/storages/IStorage'; @@ -15,7 +16,10 @@ class ConcreteStorage extends MapStorage { inversifyContainerFacade.load('', {}); - super(inversifyContainerFacade.get(ServiceIdentifiers.IRandomGenerator)); + super( + inversifyContainerFacade.get(ServiceIdentifiers.IRandomGenerator), + inversifyContainerFacade.get(ServiceIdentifiers.IOptions) + ); } } diff --git a/test/unit-tests/utils/RandomGeneratorUtils.spec.ts b/test/unit-tests/utils/RandomGeneratorUtils.spec.ts deleted file mode 100644 index 1862b8dd..00000000 --- a/test/unit-tests/utils/RandomGeneratorUtils.spec.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { assert } from 'chai'; - -import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers'; - -import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade'; -import { IRandomGenerator } from '../../../src/interfaces/utils/IRandomGenerator'; - -import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade'; - -describe('RandomGeneratorUtils', () => { - describe('getRandomVariableName (length: number = 6): string', () => { - let randomGenerator: IRandomGenerator, - randomVariableName: string, - regExp: RegExp; - - before(() => { - const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade(); - - inversifyContainerFacade.load('', {}); - randomGenerator = inversifyContainerFacade.get(ServiceIdentifiers.IRandomGenerator) - }); - - describe('variant #1: string with random variable of length `4`', () => { - before(() => { - randomVariableName = randomGenerator.getRandomVariableName(4); - regExp = /^_0x(\w){4}$/; - }); - - it('should return random variable name', () => { - assert.match(randomVariableName, regExp); - }) - }); - - describe('variant #2: string with random variable of length `6`', () => { - before(() => { - randomVariableName = randomGenerator.getRandomVariableName(6); - regExp = /^_0x(\w){4,6}$/; - }); - - it('should return random variable name', () => { - assert.match(randomVariableName, regExp); - }) - }); - }); -});