From 5144b2b76a4a8ac9ce4120ea647737ed66cabe6b Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Wed, 2 Aug 2017 00:48:31 +0300 Subject: [PATCH] Fixed processing of `null` value in NodeUtils.clone() method --- CHANGELOG.md | 4 + dist/index.js | 2 +- package.json | 8 +- src/cli/utils/CLIUtils.ts | 6 +- src/node/NodeUtils.ts | 4 + test/unit-tests/cli/utils/CLIUtils.spec.ts | 62 ++++++--- .../node/node-utils/NodeUtils.spec.ts | 120 ++++++++++++------ yarn.lock | 40 +++--- 8 files changed, 164 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7560d070..1c942fc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ v0.11.0 * **New option:** `log` enables logging of the information to the console. * **New option:** `renameGlobals` allows to enable obfuscation of global variable and function names with declaration. +v0.10.2 +--- +* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/78 + v0.10.1 --- * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/76 diff --git a/dist/index.js b/dist/index.js index fe3633ab..e448a149 100644 --- a/dist/index.js +++ b/dist/index.js @@ -21,5 +21,5 @@ 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(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=40)}([function(e,t){e.exports=require("inversify")},function(e,t,n){"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__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.INodeTransformer="INodeTransformer",e.IObfuscationEventEmitter="IObfuscationEventEmitter",e.IObfuscationResult="IObfuscationResult",e.IObfuscator="IObfuscator",e.IOptions="IOptions",e.IObfuscatingReplacer="IObfuscatingReplacer",e.IRandomGenerator="IRandomGenerator",e.ISourceCode="ISourceCode",e.ISourceMapCorrector="ISourceMapCorrector",e.IStackTraceAnalyzer="IStackTraceAnalyzer",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,n){"use strict";function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initialize",t=Object.keys(this)[0];return function(n,r){var o={configurable:!0,enumerable:!0},a=n[e];if(!a||"function"!=typeof a)throw new Error("`"+e+"` method with initialization logic not found. `@"+t+"` decorator requires `"+e+"` method");var i="_"+r,c=Object.getOwnPropertyDescriptor(n,i)||o,s=Object.getOwnPropertyDescriptor(n,e)||o,u=s.value;return Object.defineProperty(n,r,Object.assign({},c,{get:function(){if(void 0===this[i])throw new Error("Property `"+r+"` is not initialized! Initialize it first!");return this[i]},set:function(e){this[i]=e}})),Object.defineProperty(n,e,Object.assign({},s,{value:function(){u.apply(this,arguments),this[r]}})),c}}Object.defineProperty(t,"__esModule",{value:!0}),t.initializable=r},function(e,t,n){"use strict";function r(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 n=0;n1&&void 0!==arguments[1]?arguments[1]:0;if(l.Node.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 n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=t.parentNode;if(!r)throw new ReferenceError("`parentNode` property of given node is `undefined`");if(l.Node.isBlockStatementNode(r)){if(!r.parentNode)throw new ReferenceError("`parentNode` property of `parentNode` of given node is `undefined`");-1!==e.nodesWithBlockScope.indexOf(r.parentNode.type)&&n.push(r)}return l.Node.isProgramNode(r)?(n.push(r),n):e.getBlockScopesOfNode(r,n)}},{key:"getNodeBlockScopeDepth",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=t.parentNode;if(!r)throw new ReferenceError("`parentNode` property of given node is `undefined`");return l.Node.isProgramNode(r)?n:l.Node.isBlockStatementNode(t)&&-1!==e.nodesWithBlockScope.indexOf(r.type)?e.getNodeBlockScopeDepth(r,++n):e.getNodeBlockScopeDepth(r,n)}},{key:"getUnaryExpressionArgumentNode",value:function(t){return l.Node.isUnaryExpressionNode(t.argument)?e.getUnaryExpressionArgumentNode(t.argument):t.argument}},{key:"parentize",value:function(e){var t=!0;return s.traverse(e,{enter:function(e,n){var r=void 0;t?(e.type===u.NodeType.Program?r=e:(r=f.Nodes.getProgramNode([e]),r.parentNode=r),t=!1):r=n||e,e.parentNode=r,e.obfuscatedNode=!1}}),e}},{key:"typedReplace",value:function(t,n,r){e.typedTraverse(t,n,r,"replace")}},{key:"typedTraverse",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"traverse";s[r](e,{enter:function(e,r){if(e.type===t&&n.enter)return n.enter(e,r)},leave:function(e,r){if(e.type===t&&n.leave)return n.leave(e,r)}})}}]),e}();d.nodesWithBlockScope=[u.NodeType.ArrowFunctionExpression,u.NodeType.FunctionDeclaration,u.NodeType.FunctionExpression,u.NodeType.MethodDefinition,u.NodeType.Program],t.NodeUtils=d},function(e,t,n){"use strict";function r(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 n=0;n0&&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,n){return{type:i.NodeType.AssignmentExpression,operator:e,left:t,right:n,obfuscatedNode:!1}}},{key:"getBinaryExpressionNode",value:function(e,t,n){return{type:i.NodeType.BinaryExpression,operator:e,left:t,right:n,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,n,r){return{type:i.NodeType.FunctionDeclaration,id:e.getIdentifierNode(t),params:n,body:r,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,n){return Object.assign({type:i.NodeType.IfStatement,test:e,consequent:t},n&&{alternate:n},{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,n){return{type:i.NodeType.LogicalExpression,operator:e,left:t,right:n,obfuscatedNode:!1}}},{key:"getMemberExpressionNode",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.MemberExpression,computed:n,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 n=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:n,obfuscatedNode:!1}}},{key:"getUnaryExpressionNode",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return{type:i.NodeType.UnaryExpression,operator:e,argument:t,prefix:n,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){e.exports=require("estraverse")},function(e,t,n){"use strict";function r(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 n=0;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 n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=new i.InversifyContainerFacade;n.load(e,t);var r=n.get(a.ServiceIdentifiers.IJavaScriptObfuscator),o=r.obfuscate(e);return n.unload(),o}},{key:"runCLI",value:function(e){new c.JavaScriptObfuscatorCLI(e).run()}}]),e}();t.JavaScriptObfuscator=s},function(e,t,n){"use strict";function r(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 n=0;n1?t-1:0),r=1;r3&&void 0!==arguments[3]?arguments[3]:0,a=void 0;a=t.length?e.getOptimalBlockScope(t,o):n,e.prependNode(a,r)}},{key:"getOptimalBlockScope",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,o=t[n];if(r<=0)throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");return r>1&&o.stackTrace.length?e.getOptimalBlockScope(o.stackTrace,0,--r):o.callee}},{key:"insertNodeAtIndex",value:function(t,n,o){e.validateBodyStatements(n)||(n=[]),n=e.parentizeBodyStatementsBeforeAppend(t,n),t.body=[].concat(r(t.body.slice(0,o)),r(n),r(t.body.slice(o)))}},{key:"prependNode",value:function(t,n){e.validateBodyStatements(n)||(n=[]),n=e.parentizeBodyStatementsBeforeAppend(t,n),t.body=[].concat(r(n),r(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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BaseIdentifierObfuscatingReplacer=0]="BaseIdentifierObfuscatingReplacer"}(t.IdentifierObfuscatingReplacer||(t.IdentifierObfuscatingReplacer={}))},function(e,t,n){"use strict";function r(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 n=0;n1&&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,n=this.getRandomInteger(1e4,99999999),r=f.Utils.decToHex(n),o=""+t+r.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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(22);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:r.SourceMapMode.Separate,stringArray:!0,stringArrayEncoding:!1,stringArrayThreshold:.75,unicodeEscapeSequence:!1})},function(e,t,n){"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,n){"use strict";function r(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 n=0;n1&&void 0!==arguments[1]&&arguments[1];this.storage=new Map([].concat(r(this.storage),r(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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.EmptySourceCode="Empty source code. Obfuscation canceled...",e.ObfuscationCompleted="Obfuscation completed. Total time: %s sec.",e.ObfuscationStarted="Obfuscation started...",e.RandomGeneratorSeed="Random generator seed: %s...",e.StageControlFlowFlattening="Stage: control flow flattening...",e.StageDeadCodeInjection="Stage: dead code injection...",e.StageObfuscation="Stage: obfuscation..."}(t.LoggingMessage||(t.LoggingMessage={}))},function(e,t){e.exports=require("path")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(15);e.exports=r.JavaScriptObfuscator},function(e,t){e.exports=require("reflect-metadata")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(16),o=n(0),a=n(1),i=n(30),c=n(43),s=n(44),u=n(45),l=n(46);t.controlFlowTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IControlFlowReplacer).to(c.BinaryExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.BinaryExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(s.CallExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.CallExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(u.LogicalExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.LogicalExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(l.StringLiteralControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.StringLiteralControlFlowReplacer),e(a.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(r.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IControlFlowReplacer))})},function(e,t,n){"use strict";function r(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 n=0;n 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=r},function(e,t,n){"use strict";function r(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 n=0;n> 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=r},function(e,t,n){"use strict";function r(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 n=0;n> (-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=r},function(e,t,n){"use strict";function r(){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=r},function(e,t,n){"use strict";function r(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=r},function(e,t,n){"use strict";function r(){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=r},function(e,t,n){"use strict";function r(){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=r},function(e,t,n){"use strict";function r(){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=r},function(e,t,n){"use strict";function r(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 n=0;n=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 n=p.Utils.decToHex(t),r=""+p.Utils.hexadecimalPrefix+n;return this.stringLiteralHexadecimalIndexCache.set(e,r),{fromCache:!1,index:r}}},{key:"getEncodedValue",value:function(e){var t=void 0,n=null;switch(this.options.stringArrayEncoding){case l.StringArrayEncoding.Rc4:n=this.randomGenerator.getRandomGenerator().pickone(this.rc4Keys),t=this.cryptUtils.btoa(this.cryptUtils.rc4(e,n));break;case l.StringArrayEncoding.Base64:t=this.cryptUtils.btoa(e);break;default:t=e}return{encodedValue:t,key:n}}},{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),n=t.encodedValue,r=t.key,o=this.escapeSequenceEncoder.encode(n,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 r&&f.push(m.getRc4KeyLiteralNode(this.escapeSequenceEncoder.encode(r,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.TCustomNodeGroupStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.TStringArrayStorage)),c.__param(2,s.inject(u.ServiceIdentifiers.IEscapeSequenceEncoder)),c.__param(3,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(4,s.inject(u.ServiceIdentifiers.ICryptUtils)),c.__param(5,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object,Object,Object,Object,Object])],y),t.StringLiteralObfuscatingReplacer=y;var m},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(16),o=n(0),a=n(1),i=n(35),c=n(95),s=n(96),u=n(97),l=n(98),f=n(99),d=n(100),p=n(101),y=n(102),m=n(103),b=n(104),g=n(105),v=n(106),h=n(107);t.nodeTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(s.BlockStatementControlFlowTransformer).whenTargetNamed(i.NodeTransformer.BlockStatementControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(u.DeadCodeInjectionTransformer).whenTargetNamed(i.NodeTransformer.DeadCodeInjectionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(c.FunctionControlFlowTransformer).whenTargetNamed(i.NodeTransformer.FunctionControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(m.MemberExpressionTransformer).whenTargetNamed(i.NodeTransformer.MemberExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(b.MethodDefinitionTransformer).whenTargetNamed(i.NodeTransformer.MethodDefinitionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(v.TemplateLiteralTransformer).whenTargetNamed(i.NodeTransformer.TemplateLiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(l.CatchClauseTransformer).whenTargetNamed(i.NodeTransformer.CatchClauseTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(f.FunctionDeclarationTransformer).whenTargetNamed(i.NodeTransformer.FunctionDeclarationTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.FunctionTransformer).whenTargetNamed(i.NodeTransformer.FunctionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(p.LabeledStatementTransformer).whenTargetNamed(i.NodeTransformer.LabeledStatementTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(y.LiteralTransformer).whenTargetNamed(i.NodeTransformer.LiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(g.ObjectExpressionTransformer).whenTargetNamed(i.NodeTransformer.ObjectExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(h.VariableDeclarationTransformer).whenTargetNamed(i.NodeTransformer.VariableDeclarationTransformer),e(a.ServiceIdentifiers.Factory__INodeTransformer).toFactory(r.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.INodeTransformer))})},function(e,t,n){"use strict";function r(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 n=0;nh.hostNodeSearchMinDepth&&t.splice(0,h.hostNodeSearchMinDepth),t.length>h.hostNodeSearchMaxDepth&&(t.length=h.hostNodeSearchMaxDepth),this.randomGenerator.getRandomGenerator().pickone(t))}},{key:"isVisitedFunctionNode",value:function(e){return(y.Node.isFunctionDeclarationNode(e)||y.Node.isFunctionExpressionNode(e)||y.Node.isArrowFunctionExpressionNode(e))&&this.visitedFunctionNodes.has(e)}},{key:"transformFunctionBody",value:function(e,t){var n=this;l.replace(e,{enter:function(e,r){if(n.isVisitedFunctionNode(e))return l.VisitorOption.Skip;if(!h.controlFlowReplacersMap.has(e.type))return e;if(n.randomGenerator.getMathRandom()>n.options.controlFlowFlatteningThreshold)return e;var o=h.controlFlowReplacersMap.get(e.type);return void 0===o?e:Object.assign({},n.controlFlowReplacerFactory(o).replace(e,r,t),{parentNode:r})}})}}]),t}(p.AbstractNodeTransformer);v.controlFlowReplacersMap=new Map([[d.NodeType.BinaryExpression,b.ControlFlowReplacer.BinaryExpressionControlFlowReplacer],[d.NodeType.CallExpression,b.ControlFlowReplacer.CallExpressionControlFlowReplacer],[d.NodeType.LogicalExpression,b.ControlFlowReplacer.LogicalExpressionControlFlowReplacer],[d.NodeType.Literal,b.ControlFlowReplacer.StringLiteralControlFlowReplacer]]),v.hostNodeSearchMinDepth=0,v.hostNodeSearchMaxDepth=2,v=h=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])],v),t.FunctionControlFlowTransformer=v;var h},function(e,t,n){"use strict";function r(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 n=0;nthis.options.controlFlowFlatteningThreshold||!m.canTransformBlockStatementNode(e))return e;var n=e.body,r=this.arrayUtils.arrayRange(n.length),o=this.arrayUtils.arrayShuffle(r),a=r.map(function(e){return o.indexOf(e)}),i=this.controlFlowCustomNodeFactory(f.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);return i.initialize(n,o,a),i.getNode()[0]}}],[{key:"blockStatementHasProhibitedStatements",value:function(e){return e.body.some(function(e){var t=p.Node.isBreakStatementNode(e)||p.Node.isContinueStatementNode(e),n=p.Node.isVariableDeclarationNode(e)&&("const"===e.kind||"let"===e.kind);return p.Node.isFunctionDeclarationNode(e)||t||n})}},{key:"canTransformBlockStatementNode",value:function(e){var t=!0;return l.traverse(e,{enter:function(e){if(p.Node.isWhileStatementNode(e))return l.VisitorOption.Skip;p.Node.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,n){"use strict";function r(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 n=0;nb.maxNestedBlockStatementsCount||d.Node.isBreakStatementNode(e)||d.Node.isContinueStatementNode(e)?(a=!1,l.VisitorOption.Break):(d.Node.isIdentifierNode(e)&&!d.Node.isMemberExpressionNode(t)&&(e.name=n.randomGenerator.getRandomVariableName(6)),e)}}),a&&t.push(r)}},{key:"replaceBlockStatementNode",value:function(e,t){var n=this.randomGenerator.getMathRandom()>.5,r=this.randomGenerator.getMathRandom()>.5,o=n?"===":"!==",a=this.randomGenerator.getRandomString(3),i=r?a:this.randomGenerator.getRandomString(3),c=void 0,s=void 0;n&&r||!n&&!r?(c=e,s=t):(c=t,s=e);var u=p.Nodes.getBlockStatementNode([p.Nodes.getIfStatementNode(p.Nodes.getBinaryExpressionNode(o,p.Nodes.getLiteralNode(a),p.Nodes.getLiteralNode(i)),c,s)]);return u=y.NodeUtils.parentize(u)}},{key:"transformProgramNode",value:function(e){var t=this;l.traverse(e,{enter:function(e,n){d.Node.isBlockStatementNode(e)&&t.collectBlockStatementNodes(e,t.collectedBlockStatements)}}),this.collectedBlockStatements.lengtht.options.deadCodeInjectionThreshold)return e;var r=t.collectedBlockStatements.length-1,o=t.randomGenerator.getRandomInteger(0,r),a=t.collectedBlockStatements.splice(o,1)[0];return a===e?e:t.replaceBlockStatementNode(e,a)}})}}]),t}(f.AbstractNodeTransformer);m.maxNestedBlockStatementsCount=4,m.minCollectedBlockStatementsCount=5,m=b=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])],m),t.DeadCodeInjectionTransformer=m;var b},function(e,t,n){"use strict";function r(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 n=0;n1){var o=d.Nodes.getBinaryExpressionNode("+",r.shift(),r.shift());return r.forEach(function(e){o=d.Nodes.getBinaryExpressionNode("+",o,e)}),o}return r[0]}}],[{key:"isLiteralNodeWithStringValue",value:function(e){return e&&f.Node.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,n){"use strict";function r(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 n=0;nn)return"break";var a=e[o];s.traverse(a,{enter:function(n){if(l.Node.isCallExpressionNode(n))return a.parentNode!==f.NodeUtils.getBlockScopesOfNode(n)[0]?s.VisitorOption.Skip:void t.analyzeCallExpressionNode(r,e,n)}})}(a))break}return r}},{key:"analyzeCallExpressionNode",value:function(e,t,n){var r=this;p.calleeDataExtractorsList.forEach(function(o){var a=r.calleeDataExtractorFactory(o).extract(t,n.callee);a&&e.push(Object.assign({},a,{stackTrace:r.analyzeRecursive(a.callee.body)}))})}}],[{key:"getLimitIndex",value:function(e){var t=e-1,n=p.limitThresholdActivationLength-1,r=t;return t>n&&(r=Math.round(n+t*p.limitThreshold))>t&&(r=t),r}}]),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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(1),a=n(114),i=n(115),c=n(116);t.storagesModule=new r.ContainerModule(function(e){e(o.ServiceIdentifiers.TCustomNodeGroupStorage).to(i.CustomNodeGroupStorage).inSingletonScope(),e(o.ServiceIdentifiers.TStringArrayStorage).to(c.StringArrayStorage).inSingletonScope(),e(o.ServiceIdentifiers.Newable__TControlFlowStorage).toConstructor(a.ControlFlowStorage),e(o.ServiceIdentifiers.Factory__TControlFlowStorage).toFactory(function(e){return function(){var t=e.container.get(o.ServiceIdentifiers.Newable__TControlFlowStorage),n=e.container.get(o.ServiceIdentifiers.IRandomGenerator),r=new t(n);return r.initialize(),r}})})},function(e,t,n){"use strict";function r(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)}Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),c=n(0),s=n(1),u=n(37),l=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return a(t,e),t}(u.MapStorage);l=i.__decorate([c.injectable(),i.__param(0,c.inject(s.ServiceIdentifiers.IRandomGenerator)),i.__metadata("design:paramtypes",[Object])],l),t.ControlFlowStorage=l},function(e,t,n){"use strict";function r(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 n=0;n=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(r(this.storage),r(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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(1),a=n(121),i=n(122),c=n(123),s=n(28);t.utilsModule=new r.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,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t>8-o%1*8)){if((r=e.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|r}return t}},{key:"hideString",value:function(e,t){var n=this,r=this.randomGenerator.getRandomGenerator().string({length:t,pool:s.RandomGenerator.randomGeneratorPool}),o=r.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 r=-1,o=-1,a="";r [options]").option("-o, --output ","Output path for obfuscated code").option("--compact ","Disable one line output code compacting",s.BooleanSanitizer).option("--config ","Name of js / json config file").option("--controlFlowFlattening ","Enables control flow flattening",s.BooleanSanitizer).option("--controlFlowFlatteningThreshold ","The probability that the control flow flattening transformation will be applied to the node",parseFloat).option("--deadCodeInjection ","Enables dead code injection",s.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)",s.BooleanSanitizer).option("--debugProtectionInterval ","Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)",s.BooleanSanitizer).option("--disableConsoleOutput ","Allow console.log, console.info, console.error and console.warn messages output into browser console",s.BooleanSanitizer).option("--domainLock ","Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)",function(e){return e.split(",")}).option("--log ","Enables logging of the information to the console",s.BooleanSanitizer).option("--mangle ","Enables mangling of variable names",s.BooleanSanitizer).option("--reservedNames ","Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)",function(e){return e.split(",")}).option("--renameGlobals ","Allows to enable obfuscation of global variable and function names with declaration.",s.BooleanSanitizer).option("--rotateStringArray ","Disable rotation of unicode array values during obfuscation",s.BooleanSanitizer).option("--seed ","Sets seed for random generator. This is useful for creating repeatable results.",parseFloat).option("--selfDefending ","Disables self-defending for obfuscated code",s.BooleanSanitizer).option("--sourceMap ","Enables source map generation",s.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",u.SourceMapModeSanitizer).option("--stringArray ","Disables gathering of all literal strings into an array and replacing every literal string with an array call",s.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",l.StringArrayEncodingSanitizer).option("--stringArrayThreshold ","The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)",parseFloat).option("--unicodeEscapeSequence ","Allows to enable/disable string conversion to unicode escape sequence",s.BooleanSanitizer).parse(this.rawArguments)}},{key:"configureHelp",value:function(){this.commands.on("--help",function(){console.log(" Examples:\n"),console.log(" %> javascript-obfuscator in.js --compact true --selfDefending false"),console.log(" %> javascript-obfuscator in.js --output out.js --compact true --selfDefending false"),console.log("")})}},{key:"getData",value:function(){this.sourceCode=f.CLIUtils.readFile(this.inputPath)}},{key:"processData",value:function(){var e=this.buildOptions(),t=f.CLIUtils.getOutputCodePath(this.commands.output,this.inputPath);e.sourceMap?this.processDataWithSourceMap(t,e):this.processDataWithoutSourceMap(t,e)}},{key:"processDataWithoutSourceMap",value:function(e,t){var n=d.JavaScriptObfuscator.obfuscate(this.sourceCode,t).getObfuscatedCode();f.CLIUtils.writeFile(e,n)}},{key:"processDataWithSourceMap",value:function(e,t){var n=f.CLIUtils.getOutputSourceMapPath(e,t.sourceMapFileName||"");t=Object.assign({},t,{sourceMapFileName:i.basename(n)});var r=d.JavaScriptObfuscator.obfuscate(this.sourceCode,t);f.CLIUtils.writeFile(e,r.getObfuscatedCode()),"separate"===t.sourceMapMode&&r.getSourceMap()&&f.CLIUtils.writeFile(n,r.getSourceMap())}}],[{key:"sanitizeOptions",value:function(e){var t={},n=Object.keys(c.DEFAULT_PRESET);for(var r in e)e.hasOwnProperty(r)&&-1!==n.indexOf(r)&&(t[r]=e[r]);return t}}]),e}();t.JavaScriptObfuscatorCLI=p},function(e,t){e.exports=require("commander")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizer=function(e){return"true"===e||"1"===e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(22);t.SourceMapModeSanitizer=function(e){if(!Object.keys(r.SourceMapMode).some(function(t){return r.SourceMapMode[t]===e}))throw new ReferenceError("Invalid value of `--sourceMapMode` option");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(26);t.StringArrayEncodingSanitizer=function(e){switch(e){case"true":case"1":case r.StringArrayEncoding.Base64:return!0;case r.StringArrayEncoding.Rc4:return r.StringArrayEncoding.Rc4;default:return!1}}},function(e,t,n){"use strict";function r(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 n=0;n1&&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"),e.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(n){t=require(e)}return t}},{key:"isFilePath",value:function(e){try{return a.statSync(e).isFile()}catch(e){return!1}}},{key:"readFile",value:function(t){return a.readFileSync(t,e.encoding)}},{key:"validateInputPath",value:function(t){if(!e.isFilePath(t))throw new ReferenceError("Given input path must be a valid file path");if(-1===e.availableInputExtensions.indexOf(c.extname(t)))throw new ReferenceError("Input file must have .js extension")}},{key:"writeFile",value:function(t,n){i.sync(c.dirname(t)),a.writeFileSync(t,n,{encoding:e.encoding})}}]),e}();s.availableInputExtensions=[".js"],s.encoding="utf8",t.CLIUtils=s},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("mkdirp")},function(e,t){function n(e){throw new Error("Cannot find module '"+e+"'.")}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id=157}]); +require("source-map-support").install(),module.exports=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=40)}([function(e,t){e.exports=require("inversify")},function(e,t,n){"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__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.INodeTransformer="INodeTransformer",e.IObfuscationEventEmitter="IObfuscationEventEmitter",e.IObfuscationResult="IObfuscationResult",e.IObfuscator="IObfuscator",e.IOptions="IOptions",e.IObfuscatingReplacer="IObfuscatingReplacer",e.IRandomGenerator="IRandomGenerator",e.ISourceCode="ISourceCode",e.ISourceMapCorrector="ISourceMapCorrector",e.IStackTraceAnalyzer="IStackTraceAnalyzer",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,n){"use strict";function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initialize",t=Object.keys(this)[0];return function(n,r){var o={configurable:!0,enumerable:!0},a=n[e];if(!a||"function"!=typeof a)throw new Error("`"+e+"` method with initialization logic not found. `@"+t+"` decorator requires `"+e+"` method");var i="_"+r,c=Object.getOwnPropertyDescriptor(n,i)||o,s=Object.getOwnPropertyDescriptor(n,e)||o,u=s.value;return Object.defineProperty(n,r,Object.assign({},c,{get:function(){if(void 0===this[i])throw new Error("Property `"+r+"` is not initialized! Initialize it first!");return this[i]},set:function(e){this[i]=e}})),Object.defineProperty(n,e,Object.assign({},s,{value:function(){u.apply(this,arguments),this[r]}})),c}}Object.defineProperty(t,"__esModule",{value:!0}),t.initializable=r},function(e,t,n){"use strict";function r(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 n=0;n1&&void 0!==arguments[1]?arguments[1]:0;if(l.Node.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 n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=t.parentNode;if(!r)throw new ReferenceError("`parentNode` property of given node is `undefined`");if(l.Node.isBlockStatementNode(r)){if(!r.parentNode)throw new ReferenceError("`parentNode` property of `parentNode` of given node is `undefined`");-1!==e.nodesWithBlockScope.indexOf(r.parentNode.type)&&n.push(r)}return l.Node.isProgramNode(r)?(n.push(r),n):e.getBlockScopesOfNode(r,n)}},{key:"getNodeBlockScopeDepth",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=t.parentNode;if(!r)throw new ReferenceError("`parentNode` property of given node is `undefined`");return l.Node.isProgramNode(r)?n:l.Node.isBlockStatementNode(t)&&-1!==e.nodesWithBlockScope.indexOf(r.type)?e.getNodeBlockScopeDepth(r,++n):e.getNodeBlockScopeDepth(r,n)}},{key:"getUnaryExpressionArgumentNode",value:function(t){return l.Node.isUnaryExpressionNode(t.argument)?e.getUnaryExpressionArgumentNode(t.argument):t.argument}},{key:"parentize",value:function(e){var t=!0;return s.traverse(e,{enter:function(e,n){var r=void 0;t?(e.type===u.NodeType.Program?r=e:(r=f.Nodes.getProgramNode([e]),r.parentNode=r),t=!1):r=n||e,e.parentNode=r,e.obfuscatedNode=!1}}),e}},{key:"typedReplace",value:function(t,n,r){e.typedTraverse(t,n,r,"replace")}},{key:"typedTraverse",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"traverse";s[r](e,{enter:function(e,r){if(e.type===t&&n.enter)return n.enter(e,r)},leave:function(e,r){if(e.type===t&&n.leave)return n.leave(e,r)}})}}]),e}();d.nodesWithBlockScope=[u.NodeType.ArrowFunctionExpression,u.NodeType.FunctionDeclaration,u.NodeType.FunctionExpression,u.NodeType.MethodDefinition,u.NodeType.Program],t.NodeUtils=d},function(e,t,n){"use strict";function r(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 n=0;n0&&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,n){return{type:i.NodeType.AssignmentExpression,operator:e,left:t,right:n,obfuscatedNode:!1}}},{key:"getBinaryExpressionNode",value:function(e,t,n){return{type:i.NodeType.BinaryExpression,operator:e,left:t,right:n,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,n,r){return{type:i.NodeType.FunctionDeclaration,id:e.getIdentifierNode(t),params:n,body:r,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,n){return Object.assign({type:i.NodeType.IfStatement,test:e,consequent:t},n&&{alternate:n},{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,n){return{type:i.NodeType.LogicalExpression,operator:e,left:t,right:n,obfuscatedNode:!1}}},{key:"getMemberExpressionNode",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.MemberExpression,computed:n,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 n=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:n,obfuscatedNode:!1}}},{key:"getUnaryExpressionNode",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return{type:i.NodeType.UnaryExpression,operator:e,argument:t,prefix:n,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){e.exports=require("estraverse")},function(e,t,n){"use strict";function r(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 n=0;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 n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=new i.InversifyContainerFacade;n.load(e,t);var r=n.get(a.ServiceIdentifiers.IJavaScriptObfuscator),o=r.obfuscate(e);return n.unload(),o}},{key:"runCLI",value:function(e){new c.JavaScriptObfuscatorCLI(e).run()}}]),e}();t.JavaScriptObfuscator=s},function(e,t,n){"use strict";function r(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 n=0;n1?t-1:0),r=1;r3&&void 0!==arguments[3]?arguments[3]:0,a=void 0;a=t.length?e.getOptimalBlockScope(t,o):n,e.prependNode(a,r)}},{key:"getOptimalBlockScope",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,o=t[n];if(r<=0)throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");return r>1&&o.stackTrace.length?e.getOptimalBlockScope(o.stackTrace,0,--r):o.callee}},{key:"insertNodeAtIndex",value:function(t,n,o){e.validateBodyStatements(n)||(n=[]),n=e.parentizeBodyStatementsBeforeAppend(t,n),t.body=[].concat(r(t.body.slice(0,o)),r(n),r(t.body.slice(o)))}},{key:"prependNode",value:function(t,n){e.validateBodyStatements(n)||(n=[]),n=e.parentizeBodyStatementsBeforeAppend(t,n),t.body=[].concat(r(n),r(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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BaseIdentifierObfuscatingReplacer=0]="BaseIdentifierObfuscatingReplacer"}(t.IdentifierObfuscatingReplacer||(t.IdentifierObfuscatingReplacer={}))},function(e,t,n){"use strict";function r(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 n=0;n1&&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,n=this.getRandomInteger(1e4,99999999),r=f.Utils.decToHex(n),o=""+t+r.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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(22);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:r.SourceMapMode.Separate,stringArray:!0,stringArrayEncoding:!1,stringArrayThreshold:.75,unicodeEscapeSequence:!1})},function(e,t,n){"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,n){"use strict";function r(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 n=0;n1&&void 0!==arguments[1]&&arguments[1];this.storage=new Map([].concat(r(this.storage),r(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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.EmptySourceCode="Empty source code. Obfuscation canceled...",e.ObfuscationCompleted="Obfuscation completed. Total time: %s sec.",e.ObfuscationStarted="Obfuscation started...",e.RandomGeneratorSeed="Random generator seed: %s...",e.StageControlFlowFlattening="Stage: control flow flattening...",e.StageDeadCodeInjection="Stage: dead code injection...",e.StageObfuscation="Stage: obfuscation..."}(t.LoggingMessage||(t.LoggingMessage={}))},function(e,t){e.exports=require("path")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(15);e.exports=r.JavaScriptObfuscator},function(e,t){e.exports=require("reflect-metadata")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(16),o=n(0),a=n(1),i=n(30),c=n(43),s=n(44),u=n(45),l=n(46);t.controlFlowTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IControlFlowReplacer).to(c.BinaryExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.BinaryExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(s.CallExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.CallExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(u.LogicalExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.LogicalExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(l.StringLiteralControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.StringLiteralControlFlowReplacer),e(a.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(r.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IControlFlowReplacer))})},function(e,t,n){"use strict";function r(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 n=0;n 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=r},function(e,t,n){"use strict";function r(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 n=0;n> 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=r},function(e,t,n){"use strict";function r(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 n=0;n> (-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=r},function(e,t,n){"use strict";function r(){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=r},function(e,t,n){"use strict";function r(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=r},function(e,t,n){"use strict";function r(){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=r},function(e,t,n){"use strict";function r(){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=r},function(e,t,n){"use strict";function r(){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=r},function(e,t,n){"use strict";function r(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 n=0;n=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 n=p.Utils.decToHex(t),r=""+p.Utils.hexadecimalPrefix+n;return this.stringLiteralHexadecimalIndexCache.set(e,r),{fromCache:!1,index:r}}},{key:"getEncodedValue",value:function(e){var t=void 0,n=null;switch(this.options.stringArrayEncoding){case l.StringArrayEncoding.Rc4:n=this.randomGenerator.getRandomGenerator().pickone(this.rc4Keys),t=this.cryptUtils.btoa(this.cryptUtils.rc4(e,n));break;case l.StringArrayEncoding.Base64:t=this.cryptUtils.btoa(e);break;default:t=e}return{encodedValue:t,key:n}}},{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),n=t.encodedValue,r=t.key,o=this.escapeSequenceEncoder.encode(n,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 r&&f.push(m.getRc4KeyLiteralNode(this.escapeSequenceEncoder.encode(r,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.TCustomNodeGroupStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.TStringArrayStorage)),c.__param(2,s.inject(u.ServiceIdentifiers.IEscapeSequenceEncoder)),c.__param(3,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(4,s.inject(u.ServiceIdentifiers.ICryptUtils)),c.__param(5,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object,Object,Object,Object,Object])],y),t.StringLiteralObfuscatingReplacer=y;var m},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(16),o=n(0),a=n(1),i=n(35),c=n(95),s=n(96),u=n(97),l=n(98),f=n(99),d=n(100),p=n(101),y=n(102),m=n(103),b=n(104),g=n(105),v=n(106),h=n(107);t.nodeTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(s.BlockStatementControlFlowTransformer).whenTargetNamed(i.NodeTransformer.BlockStatementControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(u.DeadCodeInjectionTransformer).whenTargetNamed(i.NodeTransformer.DeadCodeInjectionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(c.FunctionControlFlowTransformer).whenTargetNamed(i.NodeTransformer.FunctionControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(m.MemberExpressionTransformer).whenTargetNamed(i.NodeTransformer.MemberExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(b.MethodDefinitionTransformer).whenTargetNamed(i.NodeTransformer.MethodDefinitionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(v.TemplateLiteralTransformer).whenTargetNamed(i.NodeTransformer.TemplateLiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(l.CatchClauseTransformer).whenTargetNamed(i.NodeTransformer.CatchClauseTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(f.FunctionDeclarationTransformer).whenTargetNamed(i.NodeTransformer.FunctionDeclarationTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.FunctionTransformer).whenTargetNamed(i.NodeTransformer.FunctionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(p.LabeledStatementTransformer).whenTargetNamed(i.NodeTransformer.LabeledStatementTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(y.LiteralTransformer).whenTargetNamed(i.NodeTransformer.LiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(g.ObjectExpressionTransformer).whenTargetNamed(i.NodeTransformer.ObjectExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(h.VariableDeclarationTransformer).whenTargetNamed(i.NodeTransformer.VariableDeclarationTransformer),e(a.ServiceIdentifiers.Factory__INodeTransformer).toFactory(r.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.INodeTransformer))})},function(e,t,n){"use strict";function r(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 n=0;nh.hostNodeSearchMinDepth&&t.splice(0,h.hostNodeSearchMinDepth),t.length>h.hostNodeSearchMaxDepth&&(t.length=h.hostNodeSearchMaxDepth),this.randomGenerator.getRandomGenerator().pickone(t))}},{key:"isVisitedFunctionNode",value:function(e){return(y.Node.isFunctionDeclarationNode(e)||y.Node.isFunctionExpressionNode(e)||y.Node.isArrowFunctionExpressionNode(e))&&this.visitedFunctionNodes.has(e)}},{key:"transformFunctionBody",value:function(e,t){var n=this;l.replace(e,{enter:function(e,r){if(n.isVisitedFunctionNode(e))return l.VisitorOption.Skip;if(!h.controlFlowReplacersMap.has(e.type))return e;if(n.randomGenerator.getMathRandom()>n.options.controlFlowFlatteningThreshold)return e;var o=h.controlFlowReplacersMap.get(e.type);return void 0===o?e:Object.assign({},n.controlFlowReplacerFactory(o).replace(e,r,t),{parentNode:r})}})}}]),t}(p.AbstractNodeTransformer);v.controlFlowReplacersMap=new Map([[d.NodeType.BinaryExpression,b.ControlFlowReplacer.BinaryExpressionControlFlowReplacer],[d.NodeType.CallExpression,b.ControlFlowReplacer.CallExpressionControlFlowReplacer],[d.NodeType.LogicalExpression,b.ControlFlowReplacer.LogicalExpressionControlFlowReplacer],[d.NodeType.Literal,b.ControlFlowReplacer.StringLiteralControlFlowReplacer]]),v.hostNodeSearchMinDepth=0,v.hostNodeSearchMaxDepth=2,v=h=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])],v),t.FunctionControlFlowTransformer=v;var h},function(e,t,n){"use strict";function r(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 n=0;nthis.options.controlFlowFlatteningThreshold||!m.canTransformBlockStatementNode(e))return e;var n=e.body,r=this.arrayUtils.arrayRange(n.length),o=this.arrayUtils.arrayShuffle(r),a=r.map(function(e){return o.indexOf(e)}),i=this.controlFlowCustomNodeFactory(f.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);return i.initialize(n,o,a),i.getNode()[0]}}],[{key:"blockStatementHasProhibitedStatements",value:function(e){return e.body.some(function(e){var t=p.Node.isBreakStatementNode(e)||p.Node.isContinueStatementNode(e),n=p.Node.isVariableDeclarationNode(e)&&("const"===e.kind||"let"===e.kind);return p.Node.isFunctionDeclarationNode(e)||t||n})}},{key:"canTransformBlockStatementNode",value:function(e){var t=!0;return l.traverse(e,{enter:function(e){if(p.Node.isWhileStatementNode(e))return l.VisitorOption.Skip;p.Node.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,n){"use strict";function r(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 n=0;nb.maxNestedBlockStatementsCount||d.Node.isBreakStatementNode(e)||d.Node.isContinueStatementNode(e)?(a=!1,l.VisitorOption.Break):(d.Node.isIdentifierNode(e)&&!d.Node.isMemberExpressionNode(t)&&(e.name=n.randomGenerator.getRandomVariableName(6)),e)}}),a&&t.push(r)}},{key:"replaceBlockStatementNode",value:function(e,t){var n=this.randomGenerator.getMathRandom()>.5,r=this.randomGenerator.getMathRandom()>.5,o=n?"===":"!==",a=this.randomGenerator.getRandomString(3),i=r?a:this.randomGenerator.getRandomString(3),c=void 0,s=void 0;n&&r||!n&&!r?(c=e,s=t):(c=t,s=e);var u=p.Nodes.getBlockStatementNode([p.Nodes.getIfStatementNode(p.Nodes.getBinaryExpressionNode(o,p.Nodes.getLiteralNode(a),p.Nodes.getLiteralNode(i)),c,s)]);return u=y.NodeUtils.parentize(u)}},{key:"transformProgramNode",value:function(e){var t=this;l.traverse(e,{enter:function(e,n){d.Node.isBlockStatementNode(e)&&t.collectBlockStatementNodes(e,t.collectedBlockStatements)}}),this.collectedBlockStatements.lengtht.options.deadCodeInjectionThreshold)return e;var r=t.collectedBlockStatements.length-1,o=t.randomGenerator.getRandomInteger(0,r),a=t.collectedBlockStatements.splice(o,1)[0];return a===e?e:t.replaceBlockStatementNode(e,a)}})}}]),t}(f.AbstractNodeTransformer);m.maxNestedBlockStatementsCount=4,m.minCollectedBlockStatementsCount=5,m=b=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])],m),t.DeadCodeInjectionTransformer=m;var b},function(e,t,n){"use strict";function r(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 n=0;n1){var o=d.Nodes.getBinaryExpressionNode("+",r.shift(),r.shift());return r.forEach(function(e){o=d.Nodes.getBinaryExpressionNode("+",o,e)}),o}return r[0]}}],[{key:"isLiteralNodeWithStringValue",value:function(e){return e&&f.Node.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,n){"use strict";function r(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 n=0;nn)return"break";var a=e[o];s.traverse(a,{enter:function(n){if(l.Node.isCallExpressionNode(n))return a.parentNode!==f.NodeUtils.getBlockScopesOfNode(n)[0]?s.VisitorOption.Skip:void t.analyzeCallExpressionNode(r,e,n)}})}(a))break}return r}},{key:"analyzeCallExpressionNode",value:function(e,t,n){var r=this;p.calleeDataExtractorsList.forEach(function(o){var a=r.calleeDataExtractorFactory(o).extract(t,n.callee);a&&e.push(Object.assign({},a,{stackTrace:r.analyzeRecursive(a.callee.body)}))})}}],[{key:"getLimitIndex",value:function(e){var t=e-1,n=p.limitThresholdActivationLength-1,r=t;return t>n&&(r=Math.round(n+t*p.limitThreshold))>t&&(r=t),r}}]),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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(1),a=n(114),i=n(115),c=n(116);t.storagesModule=new r.ContainerModule(function(e){e(o.ServiceIdentifiers.TCustomNodeGroupStorage).to(i.CustomNodeGroupStorage).inSingletonScope(),e(o.ServiceIdentifiers.TStringArrayStorage).to(c.StringArrayStorage).inSingletonScope(),e(o.ServiceIdentifiers.Newable__TControlFlowStorage).toConstructor(a.ControlFlowStorage),e(o.ServiceIdentifiers.Factory__TControlFlowStorage).toFactory(function(e){return function(){var t=e.container.get(o.ServiceIdentifiers.Newable__TControlFlowStorage),n=e.container.get(o.ServiceIdentifiers.IRandomGenerator),r=new t(n);return r.initialize(),r}})})},function(e,t,n){"use strict";function r(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)}Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),c=n(0),s=n(1),u=n(37),l=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return a(t,e),t}(u.MapStorage);l=i.__decorate([c.injectable(),i.__param(0,c.inject(s.ServiceIdentifiers.IRandomGenerator)),i.__metadata("design:paramtypes",[Object])],l),t.ControlFlowStorage=l},function(e,t,n){"use strict";function r(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 n=0;n=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(r(this.storage),r(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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(1),a=n(121),i=n(122),c=n(123),s=n(28);t.utilsModule=new r.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,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t>8-o%1*8)){if((r=e.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|r}return t}},{key:"hideString",value:function(e,t){var n=this,r=this.randomGenerator.getRandomGenerator().string({length:t,pool:s.RandomGenerator.randomGeneratorPool}),o=r.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 r=-1,o=-1,a="";r [options]").option("-o, --output ","Output path for obfuscated code").option("--compact ","Disable one line output code compacting",s.BooleanSanitizer).option("--config ","Name of js / json config file").option("--controlFlowFlattening ","Enables control flow flattening",s.BooleanSanitizer).option("--controlFlowFlatteningThreshold ","The probability that the control flow flattening transformation will be applied to the node",parseFloat).option("--deadCodeInjection ","Enables dead code injection",s.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)",s.BooleanSanitizer).option("--debugProtectionInterval ","Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)",s.BooleanSanitizer).option("--disableConsoleOutput ","Allow console.log, console.info, console.error and console.warn messages output into browser console",s.BooleanSanitizer).option("--domainLock ","Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)",function(e){return e.split(",")}).option("--log ","Enables logging of the information to the console",s.BooleanSanitizer).option("--mangle ","Enables mangling of variable names",s.BooleanSanitizer).option("--reservedNames ","Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)",function(e){return e.split(",")}).option("--renameGlobals ","Allows to enable obfuscation of global variable and function names with declaration.",s.BooleanSanitizer).option("--rotateStringArray ","Disable rotation of unicode array values during obfuscation",s.BooleanSanitizer).option("--seed ","Sets seed for random generator. This is useful for creating repeatable results.",parseFloat).option("--selfDefending ","Disables self-defending for obfuscated code",s.BooleanSanitizer).option("--sourceMap ","Enables source map generation",s.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",u.SourceMapModeSanitizer).option("--stringArray ","Disables gathering of all literal strings into an array and replacing every literal string with an array call",s.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",l.StringArrayEncodingSanitizer).option("--stringArrayThreshold ","The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)",parseFloat).option("--unicodeEscapeSequence ","Allows to enable/disable string conversion to unicode escape sequence",s.BooleanSanitizer).parse(this.rawArguments)}},{key:"configureHelp",value:function(){this.commands.on("--help",function(){console.log(" Examples:\n"),console.log(" %> javascript-obfuscator in.js --compact true --selfDefending false"),console.log(" %> javascript-obfuscator in.js --output out.js --compact true --selfDefending false"),console.log("")})}},{key:"getData",value:function(){this.sourceCode=f.CLIUtils.readFile(this.inputPath)}},{key:"processData",value:function(){var e=this.buildOptions(),t=f.CLIUtils.getOutputCodePath(this.commands.output,this.inputPath);e.sourceMap?this.processDataWithSourceMap(t,e):this.processDataWithoutSourceMap(t,e)}},{key:"processDataWithoutSourceMap",value:function(e,t){var n=d.JavaScriptObfuscator.obfuscate(this.sourceCode,t).getObfuscatedCode();f.CLIUtils.writeFile(e,n)}},{key:"processDataWithSourceMap",value:function(e,t){var n=f.CLIUtils.getOutputSourceMapPath(e,t.sourceMapFileName||"");t=Object.assign({},t,{sourceMapFileName:i.basename(n)});var r=d.JavaScriptObfuscator.obfuscate(this.sourceCode,t);f.CLIUtils.writeFile(e,r.getObfuscatedCode()),"separate"===t.sourceMapMode&&r.getSourceMap()&&f.CLIUtils.writeFile(n,r.getSourceMap())}}],[{key:"sanitizeOptions",value:function(e){var t={},n=Object.keys(c.DEFAULT_PRESET);for(var r in e)e.hasOwnProperty(r)&&-1!==n.indexOf(r)&&(t[r]=e[r]);return t}}]),e}();t.JavaScriptObfuscatorCLI=p},function(e,t){e.exports=require("commander")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizer=function(e){return"true"===e||"1"===e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(22);t.SourceMapModeSanitizer=function(e){if(!Object.keys(r.SourceMapMode).some(function(t){return r.SourceMapMode[t]===e}))throw new ReferenceError("Invalid value of `--sourceMapMode` option");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(26);t.StringArrayEncodingSanitizer=function(e){switch(e){case"true":case"1":case r.StringArrayEncoding.Base64:return!0;case r.StringArrayEncoding.Rc4:return r.StringArrayEncoding.Rc4;default:return!1}}},function(e,t,n){"use strict";function r(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 n=0;n1&&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"),e.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(n){try{t=require(e)}catch(e){throw new ReferenceError("Given config path must be a valid file path")}}return t}},{key:"isFilePath",value:function(e){try{return a.statSync(e).isFile()}catch(e){return!1}}},{key:"readFile",value:function(t){return a.readFileSync(t,e.encoding)}},{key:"validateInputPath",value:function(t){if(!e.isFilePath(t))throw new ReferenceError("Given input path must be a valid file path");if(-1===e.availableInputExtensions.indexOf(c.extname(t)))throw new ReferenceError("Input file must have .js extension")}},{key:"writeFile",value:function(t,n){i.sync(c.dirname(t)),a.writeFileSync(t,n,{encoding:e.encoding})}}]),e}();s.availableInputExtensions=[".js"],s.encoding="utf8",t.CLIUtils=s},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("mkdirp")},function(e,t){function n(e){throw new Error("Cannot find module '"+e+"'.")}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id=157}]); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/package.json b/package.json index 901b8419..d18d45e2 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,9 @@ "tslib": "1.7.1" }, "devDependencies": { - "@types/chai": "4.0.1", + "@types/chai": "4.0.2", "@types/chalk": "0.4.31", - "@types/chance": "0.7.33", + "@types/chance": "0.7.34", "@types/commander": "2.9.1", "@types/escodegen": "0.0.6", "@types/esprima": "2.1.34", @@ -48,7 +48,7 @@ "@types/md5": "2.1.32", "@types/mkdirp": "0.5.0", "@types/mocha": "2.2.41", - "@types/node": "8.0.17", + "@types/node": "8.0.19", "@types/sinon": "2.3.3", "@types/string-template": "1.0.2", "@types/webpack-env": "1.13.0", @@ -60,7 +60,7 @@ "chai": "4.1.0", "coveralls": "2.13.1", "istanbul": "1.1.0-alpha.1", - "mocha": "3.4.2", + "mocha": "3.5.0", "pre-commit": "1.2.2", "sinon": "2.4.1", "ts-node": "3.3.0", diff --git a/src/cli/utils/CLIUtils.ts b/src/cli/utils/CLIUtils.ts index 7d46e812..909f07eb 100644 --- a/src/cli/utils/CLIUtils.ts +++ b/src/cli/utils/CLIUtils.ts @@ -83,7 +83,11 @@ export class CLIUtils { try { config = require(configPath); } catch (e) { - config = __non_webpack_require__(configPath); + try { + config = __non_webpack_require__(configPath); + } catch (e) { + throw new ReferenceError('Given config path must be a valid file path'); + } } return config; diff --git a/src/node/NodeUtils.ts b/src/node/NodeUtils.ts index ededd2c2..a887c396 100644 --- a/src/node/NodeUtils.ts +++ b/src/node/NodeUtils.ts @@ -46,6 +46,10 @@ export class NodeUtils { */ public static clone (astTree: T): T { const cloneRecursive: (node: T) => T = (node: T) => { + if (node === null) { + return node; + } + const copy: {[key: string]: any} = {}; Object diff --git a/test/unit-tests/cli/utils/CLIUtils.spec.ts b/test/unit-tests/cli/utils/CLIUtils.spec.ts index b1c76587..479ce68a 100644 --- a/test/unit-tests/cli/utils/CLIUtils.spec.ts +++ b/test/unit-tests/cli/utils/CLIUtils.spec.ts @@ -49,23 +49,41 @@ describe('CLIUtils', () => { }); describe('getUserConfig (configPath: string): Object', () => { - const configDirName: string = 'test/fixtures'; - const configFileName: string = 'config.js'; - const configFilePath: string = `../../../${configDirName}/${configFileName}`; - const expectedResult: TInputOptions = { - compact: true, - selfDefending: false, - sourceMap: true - }; + describe('variant #1: valid config file path', () => { + const configDirName: string = 'test/fixtures'; + const configFileName: string = 'config.js'; + const configFilePath: string = `../../../${configDirName}/${configFileName}`; + const expectedResult: TInputOptions = { + compact: true, + selfDefending: false, + sourceMap: true + }; - let result: Object; + let result: Object; - before(() => { - result = CLIUtils.getUserConfig(configFilePath); + before(() => { + result = CLIUtils.getUserConfig(configFilePath); + }); + + it('should return object with user configuration', () => { + assert.deepEqual(result, expectedResult); + }); }); - it('should return object with user configuration', () => { - assert.deepEqual(result, expectedResult); + describe('variant #2: invalid config file path', () => { + const configDirName: string = 'test/fixtures'; + const configFileName: string = 'configs.js'; + const configFilePath: string = `../../../${configDirName}/${configFileName}`; + + let testFunc: () => void; + + before(() => { + testFunc = () => CLIUtils.getUserConfig(configFilePath); + }); + + it('should throw an error if `configFilePath` is not a valid path', () => { + assert.throws(testFunc, ReferenceError); + }); }); }); @@ -74,12 +92,15 @@ describe('CLIUtils', () => { const tmpFileName: string = 'test.js'; const inputPath: string = `${tmpDir}/${tmpFileName}`; + let testFunc: () => void; + before(() => { fs.writeFileSync(inputPath, fileContent); + testFunc = () => CLIUtils.validateInputPath(inputPath); }); it('shouldn\'t throw an error if `inputPath` is a valid path', () => { - assert.doesNotThrow(() => CLIUtils.validateInputPath(inputPath), ReferenceError); + assert.doesNotThrow(testFunc, ReferenceError); }); after(() => { @@ -91,8 +112,14 @@ describe('CLIUtils', () => { const tmpFileName: string = 'test.js'; const inputPath: string = `${tmpDir}/${tmpFileName}`; + let testFunc: () => void; + + before(() => { + testFunc = () => CLIUtils.validateInputPath(inputPath); + }); + it('should throw an error if `inputPath` is not a valid path', () => { - assert.throws(() => CLIUtils.validateInputPath(inputPath), ReferenceError); + assert.throws(testFunc, ReferenceError); }); }); @@ -100,12 +127,15 @@ describe('CLIUtils', () => { const tmpFileName: string = 'test.ts'; const inputPath: string = `${tmpDir}/${tmpFileName}`; + let testFunc: () => void; + before(() => { fs.writeFileSync(inputPath, fileContent); + testFunc = () => CLIUtils.validateInputPath(inputPath); }); it('should throw an error if `inputPath` is a file name has invalid extension', () => { - assert.throws(() => CLIUtils.validateInputPath(inputPath), ReferenceError); + assert.throws(testFunc, ReferenceError); }); after(() => { diff --git a/test/unit-tests/node/node-utils/NodeUtils.spec.ts b/test/unit-tests/node/node-utils/NodeUtils.spec.ts index 847abeee..3f58b51d 100644 --- a/test/unit-tests/node/node-utils/NodeUtils.spec.ts +++ b/test/unit-tests/node/node-utils/NodeUtils.spec.ts @@ -27,52 +27,98 @@ describe('NodeUtils', () => { }); describe('clone (astTree: T): T', () => { - let programNode: ESTree.Program, - expectedProgramNode: ESTree.Program; + describe('variant #1: simple AST-tree', () => { + let programNode: ESTree.Program, + expectedProgramNode: ESTree.Program; - before(() => { - // actual AST tree - const expressionStatementNode1: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); - const expressionStatementNode2: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); + before(() => { + // actual AST tree + const expressionStatementNode1: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); + const expressionStatementNode2: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); - const ifStatementBlockStatementNode1: ESTree.BlockStatement = Nodes.getBlockStatementNode([ - expressionStatementNode1, - expressionStatementNode2 - ]); + const ifStatementBlockStatementNode1: ESTree.BlockStatement = Nodes.getBlockStatementNode([ + expressionStatementNode1, + expressionStatementNode2 + ]); - const ifStatementNode1: ESTree.IfStatement = Nodes.getIfStatementNode( - Nodes.getLiteralNode(true), - ifStatementBlockStatementNode1 - ); + const ifStatementNode1: ESTree.IfStatement = Nodes.getIfStatementNode( + Nodes.getLiteralNode(true), + ifStatementBlockStatementNode1 + ); - // expected AST tree - const expressionStatementNode3: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); - const expressionStatementNode4: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); + // expected AST tree + const expressionStatementNode3: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); + const expressionStatementNode4: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); - const ifStatementBlockStatementNode2: ESTree.BlockStatement = Nodes.getBlockStatementNode([ - expressionStatementNode3, - expressionStatementNode4 - ]); + const ifStatementBlockStatementNode2: ESTree.BlockStatement = Nodes.getBlockStatementNode([ + expressionStatementNode3, + expressionStatementNode4 + ]); - const ifStatementNode2: ESTree.IfStatement = Nodes.getIfStatementNode( - Nodes.getLiteralNode(true), - ifStatementBlockStatementNode2 - ); + const ifStatementNode2: ESTree.IfStatement = Nodes.getIfStatementNode( + Nodes.getLiteralNode(true), + ifStatementBlockStatementNode2 + ); - programNode = NodeUtils.clone( - Nodes.getProgramNode([ - ifStatementNode1 - ]) - ); - expectedProgramNode = NodeUtils.parentize( - Nodes.getProgramNode([ - ifStatementNode2 - ]) - ); + programNode = NodeUtils.clone( + Nodes.getProgramNode([ + ifStatementNode1 + ]) + ); + expectedProgramNode = NodeUtils.parentize( + Nodes.getProgramNode([ + ifStatementNode2 + ]) + ); + }); + + it('should clone given AST-tree', () => { + assert.deepEqual(programNode, expectedProgramNode); + }); }); - it('should clone given AST-tree', () => { - assert.deepEqual(programNode, expectedProgramNode); + describe('variant #2: array expression with `null` element', () => { + let programNode: ESTree.Program, + expectedProgramNode: ESTree.Program; + + before(() => { + // actual AST tree + const arrayExpressionNode: ESTree.ArrayExpression = Nodes.getArrayExpressionNode([ + Nodes.getLiteralNode(1), + Nodes.getLiteralNode(2), + null, + Nodes.getLiteralNode(4) + ]); + const expressionStatementNode: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode( + arrayExpressionNode + ); + + // expected AST tree + const expectedArrayExpressionNode: ESTree.ArrayExpression = Nodes.getArrayExpressionNode([ + Nodes.getLiteralNode(1), + Nodes.getLiteralNode(2), + null, + Nodes.getLiteralNode(4) + ]); + const expectedExpressionStatementNode: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode( + expectedArrayExpressionNode + ); + + programNode = NodeUtils.clone( + Nodes.getProgramNode([ + expressionStatementNode + ]) + ); + expectedProgramNode = NodeUtils.parentize( + Nodes.getProgramNode([ + expectedExpressionStatementNode + ]) + ); + }); + + it('should clone given AST-tree', () => { + assert.deepEqual(programNode, expectedProgramNode); + }); }); }); diff --git a/yarn.lock b/yarn.lock index f6fb2607..2e97cb12 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,17 +2,17 @@ # yarn lockfile v1 -"@types/chai@4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.1.tgz#37fea779617cfec3fd2b19a0247e8bbdd5133bf6" +"@types/chai@4.0.2": + version "4.0.2" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.2.tgz#cce9666f5ee2fa27ffd505d2dfaf53bb02ed2584" "@types/chalk@0.4.31": version "0.4.31" resolved "https://registry.yarnpkg.com/@types/chalk/-/chalk-0.4.31.tgz#a31d74241a6b1edbb973cf36d97a2896834a51f9" -"@types/chance@0.7.33": - version "0.7.33" - resolved "https://registry.yarnpkg.com/@types/chance/-/chance-0.7.33.tgz#9666ae5c8f602a14a67e5b608dabf1a7853a1e28" +"@types/chance@0.7.34": + version "0.7.34" + resolved "https://registry.yarnpkg.com/@types/chance/-/chance-0.7.34.tgz#270ec0e23feafdee471b9d2f053f9a2ff922270e" "@types/commander@2.9.1": version "2.9.1" @@ -56,10 +56,14 @@ version "2.2.41" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.41.tgz#e27cf0817153eb9f2713b2d3f6c68f1e1c3ca608" -"@types/node@*", "@types/node@8.0.17": +"@types/node@*": version "8.0.17" resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.17.tgz#677bc8c118cfb76013febb62ede1f31d2c7222a1" +"@types/node@8.0.19": + version "8.0.19" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.19.tgz#e46e2b0243de7d03f15b26b45c59ebb84f657a4e" + "@types/sinon@2.3.3": version "2.3.3" resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-2.3.3.tgz#1f20b96f954b4997a09c1c0a20264aaba6b00147" @@ -68,7 +72,7 @@ version "1.0.2" resolved "https://registry.yarnpkg.com/@types/string-template/-/string-template-1.0.2.tgz#363b273c9b456705e3111e3571e9248f6474eba4" -"@types/webpack-env@^1.13.0": +"@types/webpack-env@1.13.0": version "1.13.0" resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.13.0.tgz#3044381647e11ee973c5af2e925323930f691d80" @@ -1203,13 +1207,7 @@ date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" -debug@2.6.0, debug@^2.1.1, debug@^2.2.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b" - dependencies: - ms "0.7.2" - -debug@^2.3.3, debug@^2.6.3: +debug@2.6.8, debug@^2.1.1, debug@^2.2.0, debug@^2.3.3, debug@^2.6.3: version "2.6.8" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: @@ -2643,13 +2641,13 @@ mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.1, mkdirp@~0.5.0: dependencies: minimist "0.0.8" -mocha@3.4.2: - version "3.4.2" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.4.2.tgz#d0ef4d332126dbf18d0d640c9b382dd48be97594" +mocha@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.5.0.tgz#1328567d2717f997030f8006234bce9b8cd72465" dependencies: browser-stdout "1.3.0" commander "2.9.0" - debug "2.6.0" + debug "2.6.8" diff "3.2.0" escape-string-regexp "1.0.5" glob "7.1.1" @@ -2659,10 +2657,6 @@ mocha@3.4.2: mkdirp "0.5.1" supports-color "3.1.2" -ms@0.7.2: - version "0.7.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"