diff --git a/README.md b/README.md index d1283848..c92692c7 100644 --- a/README.md +++ b/README.md @@ -290,6 +290,7 @@ Following options are available for the JS Obfuscator: stringArrayEncoding: false, stringArrayThreshold: 0.75, target: 'browser', + transformObjectKeys: false, unicodeEscapeSequence: false } ``` @@ -326,6 +327,7 @@ Following options are available for the JS Obfuscator: --string-array-encoding [true, false, base64, rc4] --string-array-threshold --target [browser, extension, node] + --transform-object-keys --unicode-escape-sequence ``` @@ -706,6 +708,44 @@ Available values: Currently output code for `browser` and `node` targets is identical. Output code for `extension` target is not using `eval`. +### `transformObjectKeys` +Type: `boolean` Default: `false` + +Enables transformation of object keys. + +Example: +```ts +// input +(function(){ + var object = { + foo: 'test1', + bar: { + baz: 'test2' + } + }; +})(); + +// output +var _0x5a21 = [ + 'foo', + 'test1', + 'bar', + 'baz', + 'test2' +]; +var _0x223f = function (_0x474dc0, _0x10db96) { + _0x474dc0 = _0x474dc0 - 0x0; + var _0x4c8bf7 = _0x5a21[_0x474dc0]; + return _0x4c8bf7; +}; +(function () { + var _0x2e1a8e = {}; + _0x2e1a8e[_0x223f('0x0')] = _0x223f('0x1'); + _0x2e1a8e[_0x223f('0x2')] = {}; + _0x2e1a8e[_0x223f('0x2')][_0x223f('0x3')] = _0x223f('0x4'); +}()); +``` + ### `unicodeEscapeSequence` Type: `boolean` Default: `false` @@ -736,6 +776,7 @@ Performance will 50-100% slower than without obfuscation stringArray: true, stringArrayEncoding: 'rc4', stringArrayThreshold: 1, + transformObjectKeys: true, unicodeEscapeSequence: false } ``` @@ -762,6 +803,7 @@ Performance will 30-35% slower than without obfuscation stringArray: true, stringArrayEncoding: 'base64', stringArrayThreshold: 0.75, + transformObjectKeys: true, unicodeEscapeSequence: false } ``` diff --git a/dist/index.js b/dist/index.js index f2f9eac7..46926b18 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(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=47)}([function(e,t){e.exports=require("inversify")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.Factory__ICalleeDataExtractor="Factory",e.Factory__IControlFlowCustomNode="Factory",e.Factory__IControlFlowReplacer="Factory",e.Factory__ICustomNode="Factory",e.Factory__ICustomNodeGroup="Factory",e.Factory__IIdentifierNamesGenerator="Factory",e.Factory__IIdentifierObfuscatingReplacer="Factory",e.Factory__INodeGuard="Factory",e.Factory__INodeTransformer="Factory",e.Factory__IObfuscationResult="Factory",e.Factory__IObfuscatingReplacer="Factory",e.Factory__TControlFlowStorage="Factory",e.IArrayUtils="IArrayUtils",e.ICalleeDataExtractor="ICalleeDataExtractor",e.ICryptUtils="ICryptUtils",e.ICustomNode="ICustomNode",e.ICustomNodeGroup="ICustomNodeGroup",e.IControlFlowReplacer="IControlFlowReplacer",e.IEscapeSequenceEncoder="IEscapeSequenceEncoder",e.IIdentifierNamesGenerator="IIdentifierNamesGenerator",e.IIdentifierObfuscatingReplacer="IIdentifierObfuscatingReplacer",e.IJavaScriptObfuscator="IJavaScriptObfuscator",e.ILogger="ILogger",e.INodeGuard="INodeGuard",e.INodeTransformer="INodeTransformer",e.IObfuscationEventEmitter="IObfuscationEventEmitter",e.IObfuscationResult="IObfuscationResult",e.IOptions="IOptions",e.IObfuscatingReplacer="IObfuscatingReplacer",e.IRandomGenerator="IRandomGenerator",e.ISourceCode="ISourceCode",e.ISourceMapCorrector="ISourceMapCorrector",e.IStackTraceAnalyzer="IStackTraceAnalyzer",e.ITransformersRunner="ITransformersRunner",e.Newable__ICustomNode="Newable",e.Newable__TControlFlowStorage="Newable",e.TCustomNodeGroupStorage="TCustomNodeGroupStorage",e.TStringArrayStorage="TStringArrayStorage"}(t.ServiceIdentifiers||(t.ServiceIdentifiers={}))},function(e,t){e.exports=require("tslib")},function(e,t,r){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initialize",t=Object.keys(this)[0];return function(r,n){var o={configurable:!0,enumerable:!0},a=r[e];if(!a||"function"!=typeof a)throw new Error("`"+e+"` method with initialization logic not found. `@"+t+"` decorator requires `"+e+"` method");var i="_"+n,c=Object.getOwnPropertyDescriptor(r,i)||o,s=Object.getOwnPropertyDescriptor(r,e)||o,u=s.value;return Object.defineProperty(r,n,Object.assign({},c,{get:function(){if(void 0===this[i])throw new Error("Property `"+n+"` is not initialized! Initialize it first!");return this[i]},set:function(e){this[i]=e}})),Object.defineProperty(r,e,Object.assign({},s,{value:function(){u.apply(this,arguments),this[n]}})),c}}Object.defineProperty(t,"__esModule",{value:!0}),t.initializable=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(!l.NodeGuards.isNodeHasBlockStatement(e))throw new TypeError("The specified node have no a block-statement");if(void 0===e.body[t])throw new ReferenceError("Wrong index `"+t+"`. Block-statement body length is `"+e.body.length+"`");return e.body[t]}},{key:"getBlockScopesOfNode",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=t.parentNode;if(!n)throw new ReferenceError("`parentNode` property of given node is `undefined`");if(l.NodeGuards.isBlockStatementNode(n)){if(!n.parentNode)throw new ReferenceError("`parentNode` property of `parentNode` of given node is `undefined`");-1!==e.nodesWithBlockScope.indexOf(n.parentNode.type)&&r.push(n)}return t!==n?e.getBlockScopesOfNode(n,r):(l.NodeGuards.isNodeHasBlockStatement(n)&&r.push(n),r)}},{key:"getNodeBlockScopeDepth",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t.parentNode;if(!n)throw new ReferenceError("`parentNode` property of given node is `undefined`");return l.NodeGuards.isProgramNode(n)?r:l.NodeGuards.isBlockStatementNode(t)&&-1!==e.nodesWithBlockScope.indexOf(n.type)?e.getNodeBlockScopeDepth(n,++r):e.getNodeBlockScopeDepth(n,r)}},{key:"getUnaryExpressionArgumentNode",value:function(t){return l.NodeGuards.isUnaryExpressionNode(t.argument)?e.getUnaryExpressionArgumentNode(t.argument):t.argument}},{key:"parentize",value:function(t){return s.traverse(t,{enter:e.parentizeNode}),t}},{key:"parentizeNode",value:function(e,t){return e.parentNode=t||e,e.obfuscatedNode=!1,e}}]),e}();f.nodesWithBlockScope=[u.NodeType.ArrowFunctionExpression,u.NodeType.FunctionDeclaration,u.NodeType.FunctionExpression,u.NodeType.MethodDefinition,u.NodeType.Program],t.NodeUtils=f},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.Program,body:e,sourceType:"script",obfuscatedNode:!1}}},{key:"getArrayExpressionNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.ArrayExpression,elements:e}}},{key:"getAssignmentExpressionNode",value:function(e,t,r){return{type:i.NodeType.AssignmentExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getBinaryExpressionNode",value:function(e,t,r){return{type:i.NodeType.BinaryExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getBlockStatementNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.BlockStatement,body:e,obfuscatedNode:!1}}},{key:"getBreakStatement",value:function(e){var t={type:i.NodeType.BreakStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getCatchClauseNode",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.CatchClause,param:e.getIdentifierNode("err"),body:e.getBlockStatementNode(t),obfuscatedNode:!1}}},{key:"getCallExpressionNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:i.NodeType.CallExpression,callee:e,arguments:t,obfuscatedNode:!1}}},{key:"getContinueStatement",value:function(e){var t={type:i.NodeType.ContinueStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getExpressionStatementNode",value:function(e){return{type:i.NodeType.ExpressionStatement,expression:e,obfuscatedNode:!1}}},{key:"getFunctionDeclarationNode",value:function(t,r,n){return{type:i.NodeType.FunctionDeclaration,id:e.getIdentifierNode(t),params:r,body:n,generator:!1,obfuscatedNode:!1}}},{key:"getFunctionExpressionNode",value:function(e,t){return{type:i.NodeType.FunctionExpression,params:e,body:t,generator:!1,obfuscatedNode:!1}}},{key:"getIfStatementNode",value:function(e,t,r){return Object.assign({type:i.NodeType.IfStatement,test:e,consequent:t},r&&{alternate:r},{obfuscatedNode:!1})}},{key:"getIdentifierNode",value:function(e){return{type:i.NodeType.Identifier,name:e,obfuscatedNode:!1}}},{key:"getLabeledStatement",value:function(e,t){return{type:i.NodeType.LabeledStatement,label:e,body:t,obfuscatedNode:!1}}},{key:"getLiteralNode",value:function(e,t){return t=void 0!==t?t:"'"+e+"'",{type:i.NodeType.Literal,value:e,raw:t,"x-verbatim-property":{content:t,precedence:a.Precedence.Primary},obfuscatedNode:!1}}},{key:"getLogicalExpressionNode",value:function(e,t,r){return{type:i.NodeType.LogicalExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getMemberExpressionNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.MemberExpression,computed:r,object:e,property:t,obfuscatedNode:!1}}},{key:"getObjectExpressionNode",value:function(e){return{type:i.NodeType.ObjectExpression,properties:e,obfuscatedNode:!1}}},{key:"getPropertyNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.Property,key:e,value:t,kind:"init",method:!1,shorthand:!1,computed:r,obfuscatedNode:!1}}},{key:"getUnaryExpressionNode",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return{type:i.NodeType.UnaryExpression,operator:e,argument:t,prefix:r,obfuscatedNode:!1}}},{key:"getReturnStatementNode",value:function(e){return{type:i.NodeType.ReturnStatement,argument:e,obfuscatedNode:!1}}},{key:"getSwitchStatementNode",value:function(e,t){return{type:i.NodeType.SwitchStatement,discriminant:e,cases:t,obfuscatedNode:!1}}},{key:"getSwitchCaseNode",value:function(e,t){return{type:i.NodeType.SwitchCase,test:e,consequent:t,obfuscatedNode:!1}}},{key:"getUpdateExpressionNode",value:function(e,t){return{type:i.NodeType.UpdateExpression,operator:e,argument:t,prefix:!1,obfuscatedNode:!1}}},{key:"getVariableDeclarationNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"var";return{type:i.NodeType.VariableDeclaration,declarations:e,kind:t,obfuscatedNode:!1}}},{key:"getVariableDeclaratorNode",value:function(e,t){return{type:i.NodeType.VariableDeclarator,id:e,init:t,obfuscatedNode:!1}}},{key:"getWhileStatementNode",value:function(e,t){return{type:i.NodeType.WhileStatement,test:e,body:t,obfuscatedNode:!1}}}]),e}();t.Nodes=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.ArrayExpression="ArrayExpression",e.ArrowFunctionExpression="ArrowFunctionExpression",e.AssignmentExpression="AssignmentExpression",e.AssignmentPattern="AssignmentPattern",e.AwaitExpression="AwaitExpression",e.BinaryExpression="BinaryExpression",e.BlockStatement="BlockStatement",e.BreakStatement="BreakStatement",e.CallExpression="CallExpression",e.CatchClause="CatchClause",e.ClassDeclaration="ClassDeclaration",e.ContinueStatement="ContinueStatement",e.ExpressionStatement="ExpressionStatement",e.FunctionDeclaration="FunctionDeclaration",e.FunctionExpression="FunctionExpression",e.Identifier="Identifier",e.IfStatement="IfStatement",e.LabeledStatement="LabeledStatement",e.Literal="Literal",e.LogicalExpression="LogicalExpression",e.MemberExpression="MemberExpression",e.MethodDefinition="MethodDefinition",e.ObjectExpression="ObjectExpression",e.ObjectPattern="ObjectPattern",e.Program="Program",e.Property="Property",e.ReturnStatement="ReturnStatement",e.Super="Super",e.SwitchCase="SwitchCase",e.SwitchStatement="SwitchStatement",e.TemplateLiteral="TemplateLiteral",e.TryStatement="TryStatement",e.UnaryExpression="UnaryExpression",e.UpdateExpression="UpdateExpression",e.VariableDeclaration="VariableDeclaration",e.VariableDeclarator="VariableDeclarator",e.WhileStatement="WhileStatement"}(t.NodeType||(t.NodeType={}))},function(e,t){e.exports=require("string-template")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BinaryExpressionFunctionNode=0]="BinaryExpressionFunctionNode",e[e.BlockStatementControlFlowFlatteningNode=1]="BlockStatementControlFlowFlatteningNode",e[e.CallExpressionControlFlowStorageCallNode=2]="CallExpressionControlFlowStorageCallNode",e[e.CallExpressionFunctionNode=3]="CallExpressionFunctionNode",e[e.ControlFlowStorageNode=4]="ControlFlowStorageNode",e[e.ExpressionWithOperatorControlFlowStorageCallNode=5]="ExpressionWithOperatorControlFlowStorageCallNode",e[e.LogicalExpressionFunctionNode=6]="LogicalExpressionFunctionNode",e[e.StringLiteralControlFlowStorageCallNode=7]="StringLiteralControlFlowStorageCallNode",e[e.StringLiteralNode=8]="StringLiteralNode"}(t.ControlFlowCustomNode||(t.ControlFlowCustomNode={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.Browser="browser",e.Extension="extension",e.Node="node"}(t.ObfuscationTarget||(t.ObfuscationTarget={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1?t-1:0),n=1;n1&&void 0!==arguments[1]?arguments[1]:{},r=new i.InversifyContainerFacade;r.load(e,t);var n=r.get(a.ServiceIdentifiers.IJavaScriptObfuscator),o=n.obfuscate(e);return r.unload(),o}},{key:"runCLI",value:function(e){var t=new c.JavaScriptObfuscatorCLI(e);t.initialize(),t.run()}}]),e}();t.JavaScriptObfuscator=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BlockStatementControlFlowTransformer=0]="BlockStatementControlFlowTransformer",e[e.ClassDeclarationTransformer=1]="ClassDeclarationTransformer",e[e.CommentsTransformer=2]="CommentsTransformer",e[e.DeadCodeInjectionTransformer=3]="DeadCodeInjectionTransformer",e[e.FunctionControlFlowTransformer=4]="FunctionControlFlowTransformer",e[e.CatchClauseTransformer=5]="CatchClauseTransformer",e[e.FunctionDeclarationTransformer=6]="FunctionDeclarationTransformer",e[e.FunctionTransformer=7]="FunctionTransformer",e[e.LabeledStatementTransformer=8]="LabeledStatementTransformer",e[e.LiteralTransformer=9]="LiteralTransformer",e[e.MemberExpressionTransformer=10]="MemberExpressionTransformer",e[e.MethodDefinitionTransformer=11]="MethodDefinitionTransformer",e[e.ObfuscatingGuardsTransformer=12]="ObfuscatingGuardsTransformer",e[e.ObjectExpressionTransformer=13]="ObjectExpressionTransformer",e[e.ParentificationTransformer=14]="ParentificationTransformer",e[e.TemplateLiteralTransformer=15]="TemplateLiteralTransformer",e[e.VariableDeclarationTransformer=16]="VariableDeclarationTransformer"}(t.NodeTransformer||(t.NodeTransformer={}))},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t3&&void 0!==arguments[3]?arguments[3]:0,a=void 0;a=t.length?e.getOptimalBlockScope(t,o):r,e.prependNode(a,n)}},{key:"getOptimalBlockScope",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,o=t[r];if(n<=0)throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");return n>1&&o.stackTrace.length?e.getOptimalBlockScope(o.stackTrace,0,--n):o.callee}},{key:"insertNodeAtIndex",value:function(t,r,o){e.validateBodyStatements(r)||(r=[]),r=e.parentizeBodyStatementsBeforeAppend(t,r),t.body=[].concat(n(t.body.slice(0,o)),n(r),n(t.body.slice(o)))}},{key:"prependNode",value:function(t,r){e.validateBodyStatements(r)||(r=[]),r=e.parentizeBodyStatementsBeforeAppend(t,r),t.body=[].concat(n(r),n(t.body))}},{key:"parentizeBodyStatementsBeforeAppend",value:function(e,t){return t.forEach(function(t){t.parentNode=e}),t}},{key:"validateBodyStatements",value:function(e){return e.every(function(e){return!!e&&e.hasOwnProperty("type")})}}]),e}();t.NodeAppender=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.ConsoleOutputDisableExpressionNode=0]="ConsoleOutputDisableExpressionNode",e[e.DebugProtectionFunctionCallNode=1]="DebugProtectionFunctionCallNode",e[e.DebugProtectionFunctionIntervalNode=2]="DebugProtectionFunctionIntervalNode",e[e.DebugProtectionFunctionNode=3]="DebugProtectionFunctionNode",e[e.DomainLockNode=4]="DomainLockNode",e[e.NodeCallsControllerFunctionNode=5]="NodeCallsControllerFunctionNode",e[e.SelfDefendingUnicodeNode=6]="SelfDefendingUnicodeNode",e[e.StringArrayCallsWrapper=7]="StringArrayCallsWrapper",e[e.StringArrayNode=8]="StringArrayNode",e[e.StringArrayRotateFunctionNode=9]="StringArrayRotateFunctionNode"}(t.CustomNode||(t.CustomNode={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r-1||0===e.indexOf("//")?e.split("/")[2]:e.split("/")[0],t=t.split(":")[0]}},{key:"isCeilNumber",value:function(e){return e%1==0}},{key:"stringRotate",value:function(e,t){if(!e)throw new ReferenceError("Cannot rotate empty string.");for(var r=0;r [options]").version(c.version,"-v, --version").option("-o, --output ","Output path for obfuscated code").option("--compact ","Disable one line output code compacting",d.BooleanSanitizer).option("--config ","Name of js / json config file").option("--control-flow-flattening ","Enables control flow flattening",d.BooleanSanitizer).option("--control-flow-flattening-threshold ","The probability that the control flow flattening transformation will be applied to the node",parseFloat).option("--dead-code-injection ","Enables dead code injection",d.BooleanSanitizer).option("--dead-code-injection-threshold ","The probability that the dead code injection transformation will be applied to the node",parseFloat).option("--debug-protection ","Disable browser Debug panel (can cause DevTools enabled browser freeze)",d.BooleanSanitizer).option("--debug-protection-interval ","Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)",d.BooleanSanitizer).option("--disable-console-output ","Allow console.log, console.info, console.error and console.warn messages output into browser console",d.BooleanSanitizer).option("--domain-lock (comma separated, without whitespaces)","Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)",f.ArraySanitizer).option("--identifier-names-generator [hexadecimal, mangled]","Sets identifier names generator (Default: hexadecimal)",p.IdentifierNamesGeneratorSanitizer).option("--log ","Enables logging of the information to the console",d.BooleanSanitizer).option("--reserved-names (comma separated, without whitespaces)","Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)",f.ArraySanitizer).option("--rename-globals ","Allows to enable obfuscation of global variable and function names with declaration.",d.BooleanSanitizer).option("--rotate-string-array ","Disable rotation of unicode array values during obfuscation",d.BooleanSanitizer).option("--seed ","Sets seed for random generator. This is useful for creating repeatable results.",parseFloat).option("--self-defending ","Disables self-defending for obfuscated code",d.BooleanSanitizer).option("--source-map ","Enables source map generation",d.BooleanSanitizer).option("--source-map-base-url ","Sets base url to the source map import url when `--source-map-mode=separate`").option("--source-map-file-name ","Sets file name for output source map when `--source-map-mode=separate`").option("--source-map-mode [inline, separate]","Specify source map output mode",y.SourceMapModeSanitizer).option("--string-array ","Disables gathering of all literal strings into an array and replacing every literal string with an array call",d.BooleanSanitizer).option("--string-array-encoding [true, false, base64, rc4]","Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed",b.StringArrayEncodingSanitizer).option("--string-array-threshold ","The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)",parseFloat).option("--target ","Allows to set target environment for obfuscated code.",m.ObfuscationTargetSanitizer).option("--unicode-escape-sequence ","Allows to enable/disable string conversion to unicode escape sequence",d.BooleanSanitizer).parse(this.rawArguments)}},{key:"configureHelp",value:function(){this.commands.on("--help",function(){console.log(" Examples:\n"),console.log(" %> javascript-obfuscator input_file_name.js --compact true --self-defending false"),console.log(" %> javascript-obfuscator input_file_name.js --output output_file_name.js --compact true --self-defending false"),console.log(" %> javascript-obfuscator input_directory_name --compact true --self-defending false"),console.log("")})}},{key:"processSourceCodeData",value:function(e){var t=this,r=this.inputCLIOptions.output?s.normalize(this.inputCLIOptions.output):"";if(Array.isArray(e))e.forEach(function(e){var n=e.filePath,o=e.content,a=r?s.join(r,n):g.CLIUtils.getOutputCodePath(n);t.processSourceCode(o,a)});else{var n=r||g.CLIUtils.getOutputCodePath(this.inputPath);this.processSourceCode(e,n)}}},{key:"processSourceCode",value:function(t,r){var n=this.buildOptions();n.sourceMap?e.processSourceCodeWithSourceMap(t,r,n):e.processSourceCodeWithoutSourceMap(t,r,n)}}],[{key:"filterOptions",value:function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&void 0!==e[r]&&(t[r]=e[r]);return t}},{key:"processSourceCodeWithoutSourceMap",value:function(e,t,r){var n=v.JavaScriptObfuscator.obfuscate(e,r).getObfuscatedCode();g.CLIUtils.writeFile(t,n)}},{key:"processSourceCodeWithSourceMap",value:function(e,t,r){var n=g.CLIUtils.getOutputSourceMapPath(t,r.sourceMapFileName||"");r=Object.assign({},r,{sourceMapFileName:s.basename(n)});var o=v.JavaScriptObfuscator.obfuscate(e,r);g.CLIUtils.writeFile(t,o.getObfuscatedCode()),"separate"===r.sourceMapMode&&o.getSourceMap()&&g.CLIUtils.writeFile(n,o.getSourceMap())}}]),e}();_.availableInputExtensions=[".js"],_.encoding="utf8",_.obfuscatedFilePrefix="-obfuscated",a.__decorate([u.initializable(),a.__metadata("design:type",Object)],_.prototype,"commands",void 0),a.__decorate([u.initializable(),a.__metadata("design:type",Object)],_.prototype,"inputCLIOptions",void 0),a.__decorate([u.initializable(),a.__metadata("design:type",String)],_.prototype,"inputPath",void 0),t.JavaScriptObfuscatorCLI=_},function(e,t){e.exports=require("path")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.FunctionDeclarationCalleeDataExtractor=0]="FunctionDeclarationCalleeDataExtractor",e[e.FunctionExpressionCalleeDataExtractor=1]="FunctionExpressionCalleeDataExtractor",e[e.ObjectExpressionCalleeDataExtractor=2]="ObjectExpressionCalleeDataExtractor"}(t.CalleeDataExtractor||(t.CalleeDataExtractor={}))},function(e,t){e.exports=require("esprima")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.BinaryExpressionControlFlowReplacer=0]="BinaryExpressionControlFlowReplacer",e[e.CallExpressionControlFlowReplacer=1]="CallExpressionControlFlowReplacer",e[e.LogicalExpressionControlFlowReplacer=2]="LogicalExpressionControlFlowReplacer",e[e.StringLiteralControlFlowReplacer=3]="StringLiteralControlFlowReplacer"}(t.ControlFlowReplacer||(t.ControlFlowReplacer={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]&&arguments[1];this.storage=new Map([].concat(n(this.storage),n(e.getStorage()))),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){this.storage.set(e,t)}}]),e}();c.__decorate([l.initializable(),c.__metadata("design:type",String)],f.prototype,"storageId",void 0),c.__decorate([l.initializable(),c.__metadata("design:type",Map)],f.prototype,"storage",void 0),c.__decorate([s.postConstruct(),c.__metadata("design:type",Function),c.__metadata("design:paramtypes",[]),c.__metadata("design:returntype",void 0)],f.prototype,"initialize",null),f=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(1,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object])],f),t.MapStorage=f},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:d.randomGeneratorPool;return this.getRandomGenerator().string({length:e,pool:t})}},{key:"getSeed",value:function(){return this.seed}}]),e}();f.randomGeneratorPool="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",f.randomGeneratorPoolNumbers="0123456789",f.randomGeneratorPoolHexadecimal="abcdef"+d.randomGeneratorPoolNumbers,a.__decorate([l.initializable(),a.__metadata("design:type",Object)],f.prototype,"randomGenerator",void 0),a.__decorate([l.initializable(),a.__metadata("design:type",Number)],f.prototype,"seed",void 0),a.__decorate([i.postConstruct(),a.__metadata("design:type",Function),a.__metadata("design:paramtypes",[]),a.__metadata("design:returntype",void 0)],f.prototype,"initialize",null),f=d=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])],f),t.RandomGenerator=f;var d},function(e,t){e.exports=require("pjson")},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(17);e.exports=n.JavaScriptObfuscator},function(e,t){e.exports=require("reflect-metadata")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(35),c=r(50),s=r(51),u=r(52),l=r(53);t.analyzersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IStackTraceAnalyzer).to(l.StackTraceAnalyzer).inSingletonScope(),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(c.FunctionDeclarationCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(s.FunctionExpressionCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(u.ObjectExpressionCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor),e(a.ServiceIdentifiers.Factory__ICalleeDataExtractor).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.ICalleeDataExtractor))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rr)return"break";var a=e[o];s.traverse(a,{enter:function(r){if(l.NodeGuards.isCallExpressionNode(r))return a.parentNode!==f.NodeUtils.getBlockScopesOfNode(r)[0]?s.VisitorOption.Skip:void t.analyzeCallExpressionNode(n,e,r)}})}(a))break}return n}},{key:"analyzeCallExpressionNode",value:function(e,t,r){var n=this;p.calleeDataExtractorsList.forEach(function(o){var a=n.calleeDataExtractorFactory(o).extract(t,r.callee);a&&e.push(Object.assign({},a,{stackTrace:n.analyzeRecursive(a.callee.body)}))})}}],[{key:"getLimitIndex",value:function(e){var t=e-1,r=p.limitThresholdActivationLength-1,n=t;return t>r&&(n=Math.round(r+t*p.limitThreshold))>t&&(n=t),n}}]),e}();d.calleeDataExtractorsList=[u.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor,u.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor,u.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor],d.limitThresholdActivationLength=25,d.limitThreshold=.002,d=p=a.__decorate([i.injectable(),a.__param(0,i.inject(c.ServiceIdentifiers.Factory__ICalleeDataExtractor)),a.__metadata("design:paramtypes",[Function])],d),t.StackTraceAnalyzer=d;var p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(37),c=r(18),s=r(55),u=r(56),l=r(57),f=r(58),d=r(59),p=r(60),m=r(61);t.controlFlowTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(u.BlockStatementControlFlowTransformer).whenTargetNamed(c.NodeTransformer.BlockStatementControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(f.DeadCodeInjectionTransformer).whenTargetNamed(c.NodeTransformer.DeadCodeInjectionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.FunctionControlFlowTransformer).whenTargetNamed(c.NodeTransformer.FunctionControlFlowTransformer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(s.BinaryExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.BinaryExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(l.CallExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.CallExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(p.LogicalExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.LogicalExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(m.StringLiteralControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.StringLiteralControlFlowReplacer),e(a.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IControlFlowReplacer))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rthis.options.controlFlowFlatteningThreshold||!y.canTransformBlockStatementNode(e))return e;var r=e.body,n=this.arrayUtils.arrayRange(r.length),o=this.arrayUtils.arrayShuffle(n),a=n.map(function(e){return o.indexOf(e)}),i=this.controlFlowCustomNodeFactory(f.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);return i.initialize(r,o,a),i.getNode()[0]}}],[{key:"blockStatementHasProhibitedStatements",value:function(e){return e.body.some(function(e){var t=p.NodeGuards.isBreakStatementNode(e)||p.NodeGuards.isContinueStatementNode(e),r=p.NodeGuards.isVariableDeclarationNode(e)&&("const"===e.kind||"let"===e.kind);return p.NodeGuards.isFunctionDeclarationNode(e)||t||r})}},{key:"canTransformBlockStatementNode",value:function(e){var t=!0;return l.traverse(e,{enter:function(e){if(p.NodeGuards.isWhileStatementNode(e))return l.VisitorOption.Skip;p.NodeGuards.isBlockStatementNode(e)&&y.blockStatementHasProhibitedStatements(e)&&(t=!1)}}),e.body.length<=4&&(t=!1),t}}]),t}(d.AbstractNodeTransformer);m=y=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])],m),t.BlockStatementControlFlowTransformer=m;var y},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rthis.options.deadCodeInjectionThreshold)return e;if(g.NodeUtils.getBlockScopesOfNode(e)[0].type===p.NodeType.Program)return e;var r=this.collectedBlockStatements.length-1,n=this.randomGenerator.getRandomInteger(0,r),o=this.collectedBlockStatements.splice(n,1)[0];return o===e?e:this.replaceBlockStatementNode(e,o)}},{key:"collectBlockStatementNodes",value:function(e,t){var r=g.NodeUtils.clone(e),n=0,o=!0;f.replace(r,{enter:function(e,t){return y.NodeGuards.isBlockStatementNode(e)&&n++,n>h.maxNestedBlockStatementsCount||!h.isValidBlockStatementNode(e)?(o=!1,f.VisitorOption.Break):e}}),o&&(r=this.transformersRunner.transform(r,h.transformersToRenameBlockScopeIdentifiers),t.push(r))}},{key:"replaceBlockStatementNode",value:function(e,t){var r=this.randomGenerator.getMathRandom()>.5,n=this.randomGenerator.getMathRandom()>.5,o=r?"===":"!==",a=this.randomGenerator.getRandomString(3),c=n?a:this.randomGenerator.getRandomString(3),s=r===n?[e,t]:[t,e],u=i(s,2),l=u[0],f=u[1],d=b.Nodes.getBlockStatementNode([b.Nodes.getIfStatementNode(b.Nodes.getBinaryExpressionNode(o,b.Nodes.getLiteralNode(a),b.Nodes.getLiteralNode(c)),l,f)]);return d=g.NodeUtils.parentize(d)}}],[{key:"isValidBlockStatementNode",value:function(e){return!(y.NodeGuards.isBreakStatementNode(e)||y.NodeGuards.isContinueStatementNode(e)||y.NodeGuards.isAwaitExpressionNode(e)||y.NodeGuards.isSuperNode(e))}}]),t}(m.AbstractNodeTransformer);v.maxNestedBlockStatementsCount=4,v.minCollectedBlockStatementsCount=5,v.transformersToRenameBlockScopeIdentifiers=[d.NodeTransformer.CatchClauseTransformer,d.NodeTransformer.ClassDeclarationTransformer,d.NodeTransformer.FunctionDeclarationTransformer,d.NodeTransformer.FunctionTransformer,d.NodeTransformer.LabeledStatementTransformer,d.NodeTransformer.VariableDeclarationTransformer],v=h=s.__decorate([u.injectable(),s.__param(0,u.inject(l.ServiceIdentifiers.ITransformersRunner)),s.__param(1,u.inject(l.ServiceIdentifiers.IRandomGenerator)),s.__param(2,u.inject(l.ServiceIdentifiers.IOptions)),s.__metadata("design:paramtypes",[Object,Object,Object])],v),t.DeadCodeInjectionTransformer=v;var h},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rh.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.NodeGuards.isFunctionDeclarationNode(e)||y.NodeGuards.isFunctionExpressionNode(e)||y.NodeGuards.isArrowFunctionExpressionNode(e))&&this.visitedFunctionNodes.has(e)}},{key:"transformFunctionBody",value:function(e,t){var r=this;l.replace(e,{enter:function(e,n){if(e.ignoredNode)return l.VisitorOption.Skip;if(r.isVisitedFunctionNode(e)||!n)return l.VisitorOption.Skip;if(!h.controlFlowReplacersMap.has(e.type))return e;if(r.randomGenerator.getMathRandom()>r.options.controlFlowFlatteningThreshold)return e;var o=h.controlFlowReplacersMap.get(e.type);return void 0===o?e:Object.assign({},r.controlFlowReplacerFactory(o).replace(e,n,t),{parentNode:n})}})}}]),t}(m.AbstractNodeTransformer);v.controlFlowReplacersMap=new Map([[p.NodeType.BinaryExpression,d.ControlFlowReplacer.BinaryExpressionControlFlowReplacer],[p.NodeType.CallExpression,d.ControlFlowReplacer.CallExpressionControlFlowReplacer],[p.NodeType.LogicalExpression,d.ControlFlowReplacer.LogicalExpressionControlFlowReplacer],[p.NodeType.Literal,d.ControlFlowReplacer.StringLiteralControlFlowReplacer]]),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,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r1){var o=d.Nodes.getBinaryExpressionNode("+",n.shift(),n.shift());return n.forEach(function(e){o=d.Nodes.getBinaryExpressionNode("+",o,e)}),o}return n[0]}}],[{key:"isLiteralNodeWithStringValue",value:function(e){return e&&f.NodeGuards.isLiteralNode(e)&&"string"==typeof e.value}}]),t}(l.AbstractNodeTransformer);p=m=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 m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(12),c=r(20),s=r(39),u=r(67),l=r(68),f=r(69),d=r(70),p=r(71),m=r(72),y=r(75),b=r(76),g=r(77),v=r(78),h=r(79),_=r(81),N=r(83),O=r(85),S=r(89),C=r(91),j=r(92),w=r(93),I=r(95),F=r(97),T=r(104),E=r(106),k=r(110),P=r(111);t.customNodesModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.ICustomNode).to(h.ConsoleOutputDisableExpressionNode).whenTargetNamed(c.CustomNode.ConsoleOutputDisableExpressionNode),e(a.ServiceIdentifiers.ICustomNode).to(_.DebugProtectionFunctionCallNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionCallNode),e(a.ServiceIdentifiers.ICustomNode).to(N.DebugProtectionFunctionIntervalNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionIntervalNode),e(a.ServiceIdentifiers.ICustomNode).to(O.DebugProtectionFunctionNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionNode),e(a.ServiceIdentifiers.ICustomNode).to(S.DomainLockNode).whenTargetNamed(c.CustomNode.DomainLockNode),e(a.ServiceIdentifiers.ICustomNode).to(w.NodeCallsControllerFunctionNode).whenTargetNamed(c.CustomNode.NodeCallsControllerFunctionNode),e(a.ServiceIdentifiers.ICustomNode).to(I.SelfDefendingUnicodeNode).whenTargetNamed(c.CustomNode.SelfDefendingUnicodeNode),e(a.ServiceIdentifiers.ICustomNode).to(F.StringArrayCallsWrapper).whenTargetNamed(c.CustomNode.StringArrayCallsWrapper),e(a.ServiceIdentifiers.ICustomNode).to(T.StringArrayNode).whenTargetNamed(c.CustomNode.StringArrayNode),e(a.ServiceIdentifiers.ICustomNode).to(E.StringArrayRotateFunctionNode).whenTargetNamed(c.CustomNode.StringArrayRotateFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(m.BinaryExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.BinaryExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(y.BlockStatementControlFlowFlatteningNode).whenTargetNamed(i.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(b.CallExpressionControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(g.CallExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.CallExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(v.ControlFlowStorageNode).whenTargetNamed(i.ControlFlowCustomNode.ControlFlowStorageNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(C.ExpressionWithOperatorControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(j.LogicalExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.LogicalExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(P.StringLiteralNode).whenTargetNamed(i.ControlFlowCustomNode.StringLiteralNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(k.StringLiteralControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode),e(a.ServiceIdentifiers.ICustomNodeGroup).to(u.ConsoleOutputCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.ConsoleOutputCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(l.DebugProtectionCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.DebugProtectionCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(f.DomainLockCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.DomainLockCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(d.SelfDefendingCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.SelfDefendingCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(p.StringArrayCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.StringArrayCustomNodeGroup),e(a.ServiceIdentifiers.Factory__ICustomNode).toFactory(n.InversifyContainerFacade.getFactory(a.ServiceIdentifiers.ICustomNode)),e(a.ServiceIdentifiers.Factory__IControlFlowCustomNode).toFactory(n.InversifyContainerFacade.getConstructorFactory(a.ServiceIdentifiers.Newable__ICustomNode,a.ServiceIdentifiers.Factory__IIdentifierNamesGenerator,a.ServiceIdentifiers.IRandomGenerator,a.ServiceIdentifiers.IOptions)),e(a.ServiceIdentifiers.Factory__ICustomNodeGroup).toFactory(n.InversifyContainerFacade.getFactory(a.ServiceIdentifiers.ICustomNodeGroup))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r 0;\n \n switch (isPositive) {\n case true:\n return this.item + \'_\' + this.value + \'_\' + i;\n default:\n this.item + \'_\' + this.value;\n }\n }\n }()\n };\n };\n \n var regExp = new RegExp("[{diff}]", "g");\n var domains = "{domains}".replace(regExp, "").split(";");\n var document;\n var domain;\n \n for (var d in that) {\n if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {\n document = d;\n \n break;\n }\n }\n\n for (var d1 in that[document]) {\n if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {\n domain = d1;\n \n break;\n }\n }\n \n if ((!document && !domain) || (!that[document] && !that[document][domain])) {\n return;\n }\n \n var currentDomain = that[document][domain];\n\n var ok = false;\n \n for (var i = 0; i < domains.length; i++) {\n var domain = domains[i];\n var position = currentDomain.length - domain.length;\n var lastIndex = currentDomain.indexOf(domain, position);\n var endsWith = lastIndex !== -1 && lastIndex === position;\n \n if (endsWith) {\n if (currentDomain.length == domain.length || domain.indexOf(".") === 0) {\n ok = true;\n }\n \n break;\n }\n }\n \n if (!ok) {\n data;\n } else {\n return;\n }\n \n func();\n });\n\n {domainLockFunctionName}();\n '}Object.defineProperty(t,"__esModule",{value:!0}),t.DomainLockNodeTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r> 1 + 255 % 0;\n \n if (string.indexOf('i' === i)) {\n recursiveFunc2(string)\n }\n };\n \n var recursiveFunc2 = function (string) {\n var i = ~-4 >> 1 + 255 % 0;\n \n if (string.indexOf((true+\"\")[3]) !== i) {\n recursiveFunc1(string)\n }\n };\n \n if (!test1()) {\n if (!test2()) {\n recursiveFunc1('indеxOf');\n } else {\n recursiveFunc1('indexOf');\n }\n } else {\n recursiveFunc1('indеxOf');\n }\n })\n \n {selfDefendingFunctionName}();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r> (-2 * bc & 6)) : 0\n ) {\n buffer = chars.indexOf(buffer);\n }\n return output;\n });\n })();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.AtobTemplate=n},function(e,t,r){"use strict";function n(){return"\n var rc4 = function (str, key) {\n var s = [], j = 0, x, res = '', newStr = '';\n \n str = atob(str);\n \n for (var k = 0, length = str.length; k < length; k++) {\n newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);\n }\n \n str = decodeURIComponent(newStr);\n \t \n\t for (var i = 0; i < 256; i++) {\n s[i] = i;\n }\n \n for (i = 0; i < 256; i++) {\n j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n }\n \n i = 0;\n j = 0;\n \n for (var y = 0; y < str.length; y++) {\n i = (i + 1) % 256;\n j = (j + s[i]) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);\n }\n \n return res;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.Rc4Template=n},function(e,t,r){"use strict";function n(e,t){var r=e.getRandomString(6),n=e.getRandomString(6),o=e.getRandomString(6),a=e.getRandomString(6),i=e.getRandomString(6),c=e.getRandomString(6),s=e.getRandomString(6),u=e.getRandomString(6),l=e.getRandomString(6);return"\n var StatesClass = function ("+r+") {\n this."+r+" = "+r+";\n this."+n+" = [1, 0, 0];\n this."+o+" = function(){return 'newState';};\n this."+a+" = '"+t.encode("\\w+ *\\(\\) *{\\w+ *",!0)+"';\n this."+i+" = '"+t.encode("['|\"].+['|\"];? *}",!0)+"';\n };\n \n StatesClass.prototype."+c+" = function () {\n var regExp = new RegExp(this."+a+" + this."+i+");\n var expression = regExp.test(this."+o+".toString())\n ? --this."+n+"[1]\n : --this."+n+"[0];\n \n return this."+s+"(expression);\n };\n \n StatesClass.prototype."+s+" = function ("+l+") {\n if (!Boolean(~"+l+")) {\n return "+l+";\n }\n \n return this."+u+"(this."+r+");\n };\n\n StatesClass.prototype."+u+" = function ("+r+") {\n for (var i = 0, len = this."+n+".length; i < len; i++) {\n this."+n+".push(Math.round(Math.random()));\n len = this."+n+".length;\n }\n \n return "+r+"(this."+n+"[0]);\n };\n\n new StatesClass({stringArrayCallsWrapperName})."+c+"();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(e){var t=e.getRandomString(6),r=e.getRandomString(6),n=e.getRandomString(6);return"\n if ({stringArrayCallsWrapperName}."+t+" === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}."+r+" = 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}."+n+" = {};\n \n {stringArrayCallsWrapperName}."+t+" = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}."+n+"[index];\n \n if (cachedValue === undefined) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}."+r+"(value);\n {stringArrayCallsWrapperName}."+n+"[index] = value;\n } else {\n value = cachedValue;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayBase64DecodeNodeTemplate=n},function(e,t,r){"use strict";function n(){return"\n var {stringArrayCallsWrapperName} = function (index, key) {\n index = index - 0;\n \n var value = {stringArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayCallsWrapperTemplate=n},function(e,t,r){"use strict";function n(e){var t=e.getRandomString(6),r=e.getRandomString(6),n=e.getRandomString(6),o=e.getRandomString(6);return"\n if ({stringArrayCallsWrapperName}."+t+" === undefined) {\n {atobPolyfill}\n \n {rc4Polyfill}\n {stringArrayCallsWrapperName}."+r+" = rc4;\n \n {stringArrayCallsWrapperName}."+n+" = {};\n \n {stringArrayCallsWrapperName}."+t+" = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}."+n+"[index];\n\n if (cachedValue === undefined) {\n if ({stringArrayCallsWrapperName}."+o+" === undefined) {\n {selfDefendingCode}\n \n {stringArrayCallsWrapperName}."+o+" = true;\n }\n \n value = {stringArrayCallsWrapperName}."+r+"(value, key);\n {stringArrayCallsWrapperName}."+n+"[index] = value;\n } else {\n value = cachedValue;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayRc4DecodeNodeTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=0);return"a"+o(n)}(e);return d.validateMangledName(t)||(t=d.generateNewMangledName(t)),t}},{key:"validateMangledName",value:function(e){return!(-1!==d.reservedNames.indexOf(e))}}]),t}(l.AbstractIdentifierNamesGenerator);f.initMangledNameCharacter="9",f.nameSequence="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),f.reservedNames=["byte","case","char","do","else","enum","eval","for","goto","if","in","int","let","long","new","null","this","true","try","var","void","with"],f=d=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])],f),t.MangledIdentifierNamesGenerator=f;var d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1);t.nodeTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.Factory__INodeTransformer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.INodeTransformer))})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(16),c=r(41),s=r(18),u=r(117),l=r(118),f=r(119),d=r(120),p=r(121),m=r(122),y=r(123),b=r(124),g=r(125),v=r(126),h=r(127),_=r(128);t.obfuscatingTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(f.CatchClauseTransformer).whenTargetNamed(s.NodeTransformer.CatchClauseTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.ClassDeclarationTransformer).whenTargetNamed(s.NodeTransformer.ClassDeclarationTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(p.FunctionDeclarationTransformer).whenTargetNamed(s.NodeTransformer.FunctionDeclarationTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(m.FunctionTransformer).whenTargetNamed(s.NodeTransformer.FunctionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(y.LabeledStatementTransformer).whenTargetNamed(s.NodeTransformer.LabeledStatementTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(b.LiteralTransformer).whenTargetNamed(s.NodeTransformer.LiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(v.ObjectExpressionTransformer).whenTargetNamed(s.NodeTransformer.ObjectExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(_.VariableDeclarationTransformer).whenTargetNamed(s.NodeTransformer.VariableDeclarationTransformer),e(a.ServiceIdentifiers.IObfuscatingReplacer).to(l.BooleanLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.BooleanLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IObfuscatingReplacer).to(g.NumberLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.NumberLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IObfuscatingReplacer).to(h.StringLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.StringLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IIdentifierObfuscatingReplacer).to(u.BaseIdentifierObfuscatingReplacer).whenTargetNamed(i.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer),e(a.ServiceIdentifiers.Factory__IObfuscatingReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IObfuscatingReplacer)),e(a.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IIdentifierObfuscatingReplacer))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=y.minimumLengthForStringArray&&this.randomGenerator.getMathRandom()<=this.options.stringArrayThreshold}},{key:"getStringArrayHexadecimalIndex",value:function(e,t){if(this.stringLiteralHexadecimalIndexCache.has(e))return{fromCache:!0,index:this.stringLiteralHexadecimalIndexCache.get(e)};var r=p.Utils.decToHex(t),n=""+p.Utils.hexadecimalPrefix+r;return this.stringLiteralHexadecimalIndexCache.set(e,n),{fromCache:!1,index:n}}},{key:"getEncodedValue",value:function(e){var t=void 0,r=null;switch(this.options.stringArrayEncoding){case l.StringArrayEncoding.Rc4:r=this.randomGenerator.getRandomGenerator().pickone(this.rc4Keys),t=this.cryptUtils.btoa(this.cryptUtils.rc4(e,r));break;case l.StringArrayEncoding.Base64:t=this.cryptUtils.btoa(e);break;default:t=e}return{encodedValue:t,key:r}}},{key:"replaceWithLiteralNode",value:function(e){return d.Nodes.getLiteralNode(this.escapeSequenceEncoder.encode(e,this.options.unicodeEscapeSequence))}},{key:"replaceWithStringArrayCallNode",value:function(e){var t=this.getEncodedValue(e),r=t.encodedValue,n=t.key,o=this.escapeSequenceEncoder.encode(r,this.options.unicodeEscapeSequence),a=this.stringArrayStorage.getLength(),i=this.stringArrayStorage.getStorageId().split("|")[1],c=this.getStringArrayHexadecimalIndex(o,a),s=c.fromCache,u=c.index;s||this.stringArrayStorage.set(a,o);var l=[y.getHexadecimalLiteralNode(u)];return n&&l.push(y.getRc4KeyLiteralNode(this.escapeSequenceEncoder.encode(n,this.options.unicodeEscapeSequence))),d.Nodes.getCallExpressionNode(d.Nodes.getIdentifierNode(i),l)}}],[{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);m.minimumLengthForStringArray=3,m.rc4KeyLength=4,m.rc4KeysCount=50,m=y=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.TStringArrayStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.IEscapeSequenceEncoder)),c.__param(2,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(3,s.inject(u.ServiceIdentifiers.ICryptUtils)),c.__param(4,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object,Object,Object,Object])],m),t.StringLiteralObfuscatingReplacer=m;var y},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=0?t:null}},{key:"getLength",value:function(){return this.storageLength}},{key:"getStorage",value:function(){return this.storage}},{key:"getStorageId",value:function(){return this.storageId}},{key:"mergeWith",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.storage=[].concat(n(this.storage),n(e.getStorage())),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){e===this.storageLength?this.storage.push(t):this.storage.splice(e,0,t),this.storageLength++}}]),e}();i.__decorate([u.initializable(),i.__metadata("design:type",Array)],l.prototype,"storage",void 0),i.__decorate([u.initializable(),i.__metadata("design:type",String)],l.prototype,"storageId",void 0),i.__decorate([c.postConstruct(),i.__metadata("design:type",Function),i.__metadata("design:paramtypes",[]),i.__metadata("design:returntype",void 0)],l.prototype,"initialize",null),l=i.__decorate([c.injectable(),i.__param(0,c.inject(s.ServiceIdentifiers.IRandomGenerator)),i.__param(1,c.inject(s.ServiceIdentifiers.IOptions)),i.__metadata("design:paramtypes",[Object,Object])],l),t.ArrayStorage=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(1),a=r(141),i=r(142),c=r(145),s=r(44);t.utilsModule=new n.ContainerModule(function(e){e(o.ServiceIdentifiers.IArrayUtils).to(a.ArrayUtils).inSingletonScope(),e(o.ServiceIdentifiers.IRandomGenerator).to(s.RandomGenerator).inSingletonScope(),e(o.ServiceIdentifiers.ICryptUtils).to(i.CryptUtils).inSingletonScope(),e(o.ServiceIdentifiers.IEscapeSequenceEncoder).to(c.EscapeSequenceEncoder).inSingletonScope()})},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t>8-o%1*8)){if((n=e.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|n}return t}},{key:"hideString",value:function(e,t){var r=this,n=this.randomGenerator.getRandomGenerator().string({length:t,pool:s.RandomGenerator.randomGeneratorPool}),o=n.replace(new RegExp("["+function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}(e)+"]","g"),""),a=o.split("");return this.randomGenerator.getRandomGenerator().shuffle(a),o=a.join(""),[function(e,t){for(var n=-1,o=-1,a="";n values should be wrapped inside quotes: --option-name 'value1, value2'");return e.split(",").map(function(e){return e.trim()})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizer=function(e){return"true"===e||"1"===e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(23);t.IdentifierNamesGeneratorSanitizer=function(e){if(!Object.keys(n.IdentifierNamesGenerator).some(function(t){return n.IdentifierNamesGenerator[t]===e}))throw new ReferenceError("Invalid value of `--identifier-names-generator` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(13);t.ObfuscationTargetSanitizer=function(e){if(!Object.keys(n.ObfuscationTarget).some(function(t){return n.ObfuscationTarget[t]===e}))throw new ReferenceError("Invalid value of `--target` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(24);t.SourceMapModeSanitizer=function(e){if(!Object.keys(n.SourceMapMode).some(function(t){return n.SourceMapMode[t]===e}))throw new ReferenceError("Invalid value of `--source-map-mode` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(25);t.StringArrayEncodingSanitizer=function(e){switch(e){case"true":case"1":case n.StringArrayEncoding.Base64:return!0;case n.StringArrayEncoding.Rc4:return n.StringArrayEncoding.Rc4;default:return!1}}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"";return t&&(e=e.substring(0,e.lastIndexOf("/"))+"/"+t),/\.js\.map$/.test(e)?/\.js$/.test(e)&&(e+=".map"):e=e.split(".")[0]+".js.map",e}},{key:"getUserConfig",value:function(e){var t=void 0;try{t=!function(){var e=new Error('Cannot find module "."');throw e.code="MODULE_NOT_FOUND",e}()}catch(r){try{t=require(e)}catch(e){throw new ReferenceError("Given config path must be a valid file path")}}return t}},{key:"writeFile",value:function(e,t){i.sync(c.dirname(e)),a.writeFileSync(e,t,{encoding:s.JavaScriptObfuscatorCLI.encoding})}}]),e}();t.CLIUtils=u},function(e,t){e.exports=require("mkdirp")},function(e,t){function r(e){throw new Error("Cannot find module '"+e+"'.")}r.keys=function(){return[]},r.resolve=r,e.exports=r,r.id=180},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t1&&void 0!==arguments[1]?arguments[1]:[];return i.readdirSync(t,s.JavaScriptObfuscatorCLI.encoding).forEach(function(o){var a=t+"/"+o;if(e.isDirectoryPath(a))r.push.apply(r,n(e.readDirectoryRecursive(a)));else if(e.isFilePath(a)&&e.isValidFile(o)){var c=i.readFileSync(a,s.JavaScriptObfuscatorCLI.encoding);r.push({filePath:a,content:c})}}),r}},{key:"readFile",value:function(t){if(!e.isValidFile(t))throw new ReferenceError("Input file must have .js extension");return i.readFileSync(t,s.JavaScriptObfuscatorCLI.encoding)}},{key:"isValidFile",value:function(e){return-1!==s.JavaScriptObfuscatorCLI.availableInputExtensions.indexOf(c.extname(e))&&!(-1!==e.indexOf(s.JavaScriptObfuscatorCLI.obfuscatedFilePrefix))}}]),e}();t.SourceCodeReader=u}]); +require("source-map-support").install(),module.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=48)}([function(e,t){e.exports=require("inversify")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.Factory__ICalleeDataExtractor="Factory",e.Factory__IControlFlowCustomNode="Factory",e.Factory__IControlFlowReplacer="Factory",e.Factory__ICustomNode="Factory",e.Factory__ICustomNodeGroup="Factory",e.Factory__IDeadCodeInjectionCustomNode="Factory",e.Factory__IIdentifierNamesGenerator="Factory",e.Factory__IIdentifierObfuscatingReplacer="Factory",e.Factory__INodeGuard="Factory",e.Factory__INodeTransformer="Factory",e.Factory__IObfuscationResult="Factory",e.Factory__IObfuscatingReplacer="Factory",e.Factory__TControlFlowStorage="Factory",e.IArrayUtils="IArrayUtils",e.ICalleeDataExtractor="ICalleeDataExtractor",e.ICryptUtils="ICryptUtils",e.ICustomNode="ICustomNode",e.ICustomNodeGroup="ICustomNodeGroup",e.IControlFlowReplacer="IControlFlowReplacer",e.IEscapeSequenceEncoder="IEscapeSequenceEncoder",e.IIdentifierNamesGenerator="IIdentifierNamesGenerator",e.IIdentifierObfuscatingReplacer="IIdentifierObfuscatingReplacer",e.IJavaScriptObfuscator="IJavaScriptObfuscator",e.ILogger="ILogger",e.INodeGuard="INodeGuard",e.INodeTransformer="INodeTransformer",e.IObfuscationEventEmitter="IObfuscationEventEmitter",e.IObfuscationResult="IObfuscationResult",e.IOptions="IOptions",e.IObfuscatingReplacer="IObfuscatingReplacer",e.IRandomGenerator="IRandomGenerator",e.ISourceCode="ISourceCode",e.ISourceMapCorrector="ISourceMapCorrector",e.IStackTraceAnalyzer="IStackTraceAnalyzer",e.ITransformersRunner="ITransformersRunner",e.Newable__ICustomNode="Newable",e.Newable__TControlFlowStorage="Newable",e.TCustomNodeGroupStorage="TCustomNodeGroupStorage",e.TStringArrayStorage="TStringArrayStorage"}(t.ServiceIdentifiers||(t.ServiceIdentifiers={}))},function(e,t){e.exports=require("tslib")},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:[],n=t.parentNode;if(!n)throw new ReferenceError("`parentNode` property of given node is `undefined`");return u.NodeGuards.isBlockStatementNode(n)&&u.NodeGuards.isNodeHasBlockScope(n)&&r.push(n),t!==n?e.getBlockScopesOfNode(n,r):(u.NodeGuards.isNodeHasBlockScope(n)&&r.push(n),r)}},{key:"getScopeOfNode",value:function(t){var r=t.parentNode;if(!r)throw new ReferenceError("`parentNode` property of given node is `undefined`");return u.NodeGuards.isNodeHasScope(r)?r:e.getScopeOfNode(r)}},{key:"getUnaryExpressionArgumentNode",value:function(t){return u.NodeGuards.isUnaryExpressionNode(t.argument)?e.getUnaryExpressionArgumentNode(t.argument):t.argument}},{key:"parentize",value:function(t){return s.replace(t,{enter:e.parentizeNode}),t}},{key:"parentizeNode",value:function(e,t){return e.parentNode=t||e,e.obfuscatedNode=!1,e}}]),e}();t.NodeUtils=l},function(e,t,r){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initialize",t=Object.keys(this)[0];return function(r,n){var o={configurable:!0,enumerable:!0},a=r[e];if(!a||"function"!=typeof a)throw new Error("`"+e+"` method with initialization logic not found. `@"+t+"` decorator requires `"+e+"` method");var i="_"+n,c=Object.getOwnPropertyDescriptor(r,i)||o,s=Object.getOwnPropertyDescriptor(r,e)||o,u=s.value;return Object.defineProperty(r,n,Object.assign({},c,{get:function(){if(void 0===this[i])throw new Error("Property `"+n+"` is not initialized! Initialize it first!");return this[i]},set:function(e){this[i]=e}})),Object.defineProperty(r,e,Object.assign({},s,{value:function(){u.apply(this,arguments),this[n]}})),c}}Object.defineProperty(t,"__esModule",{value:!0}),t.initializable=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.Program,body:e,sourceType:"script",obfuscatedNode:!1}}},{key:"getArrayExpressionNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.ArrayExpression,elements:e}}},{key:"getAssignmentExpressionNode",value:function(e,t,r){return{type:i.NodeType.AssignmentExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getBinaryExpressionNode",value:function(e,t,r){return{type:i.NodeType.BinaryExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getBlockStatementNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.BlockStatement,body:e,obfuscatedNode:!1}}},{key:"getBreakStatement",value:function(e){var t={type:i.NodeType.BreakStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getCatchClauseNode",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:i.NodeType.CatchClause,param:e.getIdentifierNode("err"),body:e.getBlockStatementNode(t),obfuscatedNode:!1}}},{key:"getCallExpressionNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:i.NodeType.CallExpression,callee:e,arguments:t,obfuscatedNode:!1}}},{key:"getContinueStatement",value:function(e){var t={type:i.NodeType.ContinueStatement,obfuscatedNode:!1};return e&&(t.label=e),t}},{key:"getExpressionStatementNode",value:function(e){return{type:i.NodeType.ExpressionStatement,expression:e,obfuscatedNode:!1}}},{key:"getFunctionDeclarationNode",value:function(t,r,n){return{type:i.NodeType.FunctionDeclaration,id:e.getIdentifierNode(t),params:r,body:n,generator:!1,obfuscatedNode:!1}}},{key:"getFunctionExpressionNode",value:function(e,t){return{type:i.NodeType.FunctionExpression,params:e,body:t,generator:!1,obfuscatedNode:!1}}},{key:"getIfStatementNode",value:function(e,t,r){return Object.assign({type:i.NodeType.IfStatement,test:e,consequent:t},r&&{alternate:r},{obfuscatedNode:!1})}},{key:"getIdentifierNode",value:function(e){return{type:i.NodeType.Identifier,name:e,obfuscatedNode:!1}}},{key:"getLabeledStatement",value:function(e,t){return{type:i.NodeType.LabeledStatement,label:e,body:t,obfuscatedNode:!1}}},{key:"getLiteralNode",value:function(e,t){return t=void 0!==t?t:"'"+e+"'",{type:i.NodeType.Literal,value:e,raw:t,"x-verbatim-property":{content:t,precedence:a.Precedence.Primary},obfuscatedNode:!1}}},{key:"getLogicalExpressionNode",value:function(e,t,r){return{type:i.NodeType.LogicalExpression,operator:e,left:t,right:r,obfuscatedNode:!1}}},{key:"getMemberExpressionNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.MemberExpression,computed:r,object:e,property:t,obfuscatedNode:!1}}},{key:"getObjectExpressionNode",value:function(e){return{type:i.NodeType.ObjectExpression,properties:e,obfuscatedNode:!1}}},{key:"getPropertyNode",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.NodeType.Property,key:e,value:t,kind:"init",method:!1,shorthand:!1,computed:r,obfuscatedNode:!1}}},{key:"getUnaryExpressionNode",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return{type:i.NodeType.UnaryExpression,operator:e,argument:t,prefix:r,obfuscatedNode:!1}}},{key:"getReturnStatementNode",value:function(e){return{type:i.NodeType.ReturnStatement,argument:e,obfuscatedNode:!1}}},{key:"getSwitchStatementNode",value:function(e,t){return{type:i.NodeType.SwitchStatement,discriminant:e,cases:t,obfuscatedNode:!1}}},{key:"getSwitchCaseNode",value:function(e,t){return{type:i.NodeType.SwitchCase,test:e,consequent:t,obfuscatedNode:!1}}},{key:"getUpdateExpressionNode",value:function(e,t){return{type:i.NodeType.UpdateExpression,operator:e,argument:t,prefix:!1,obfuscatedNode:!1}}},{key:"getVariableDeclarationNode",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"var";return{type:i.NodeType.VariableDeclaration,declarations:e,kind:t,obfuscatedNode:!1}}},{key:"getVariableDeclaratorNode",value:function(e,t){return{type:i.NodeType.VariableDeclarator,id:e,init:t,obfuscatedNode:!1}}},{key:"getWhileStatementNode",value:function(e,t){return{type:i.NodeType.WhileStatement,test:e,body:t,obfuscatedNode:!1}}}]),e}();t.Nodes=c},function(e,t){e.exports=require("estraverse")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.ArrayExpression="ArrayExpression",e.ArrayPattern="ArrayPattern",e.ArrowFunctionExpression="ArrowFunctionExpression",e.AssignmentExpression="AssignmentExpression",e.AssignmentPattern="AssignmentPattern",e.AwaitExpression="AwaitExpression",e.BinaryExpression="BinaryExpression",e.BlockStatement="BlockStatement",e.BreakStatement="BreakStatement",e.CallExpression="CallExpression",e.CatchClause="CatchClause",e.ClassDeclaration="ClassDeclaration",e.ContinueStatement="ContinueStatement",e.ExpressionStatement="ExpressionStatement",e.FunctionDeclaration="FunctionDeclaration",e.FunctionExpression="FunctionExpression",e.Identifier="Identifier",e.IfStatement="IfStatement",e.LabeledStatement="LabeledStatement",e.Literal="Literal",e.LogicalExpression="LogicalExpression",e.MemberExpression="MemberExpression",e.MethodDefinition="MethodDefinition",e.ObjectExpression="ObjectExpression",e.ObjectPattern="ObjectPattern",e.Program="Program",e.Property="Property",e.RestElement="RestElement",e.ReturnStatement="ReturnStatement",e.Super="Super",e.SwitchCase="SwitchCase",e.SwitchStatement="SwitchStatement",e.TemplateLiteral="TemplateLiteral",e.TryStatement="TryStatement",e.UnaryExpression="UnaryExpression",e.UpdateExpression="UpdateExpression",e.VariableDeclaration="VariableDeclaration",e.VariableDeclarator="VariableDeclarator",e.WhileStatement="WhileStatement"}(t.NodeType||(t.NodeType={}))},function(e,t){e.exports=require("string-template")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.BinaryExpressionFunctionNode="BinaryExpressionFunctionNode",e.BlockStatementControlFlowFlatteningNode="BlockStatementControlFlowFlatteningNode",e.CallExpressionControlFlowStorageCallNode="CallExpressionControlFlowStorageCallNode",e.CallExpressionFunctionNode="CallExpressionFunctionNode",e.ControlFlowStorageNode="ControlFlowStorageNode",e.ExpressionWithOperatorControlFlowStorageCallNode="ExpressionWithOperatorControlFlowStorageCallNode",e.LogicalExpressionFunctionNode="LogicalExpressionFunctionNode",e.StringLiteralControlFlowStorageCallNode="StringLiteralControlFlowStorageCallNode",e.StringLiteralNode="StringLiteralNode"}(t.ControlFlowCustomNode||(t.ControlFlowCustomNode={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.Browser="browser",e.Extension="extension",e.Node="node"}(t.ObfuscationTarget||(t.ObfuscationTarget={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1?t-1:0),n=1;n3&&void 0!==arguments[3]?arguments[3]:0,a=void 0;a=t.length?e.getOptimalBlockScope(t,o):r,e.prependNode(a,n)}},{key:"getOptimalBlockScope",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,o=t[r];if(n<=0)throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");return n>1&&o.stackTrace.length?e.getOptimalBlockScope(o.stackTrace,0,--n):o.callee}},{key:"insertNodeAtIndex",value:function(t,r,o){e.validateBodyStatements(r)||(r=[]),r=e.parentizeBodyStatementsBeforeAppend(t,r),t.body=[].concat(n(t.body.slice(0,o)),n(r),n(t.body.slice(o)))}},{key:"prependNode",value:function(t,r){e.validateBodyStatements(r)||(r=[]),r=e.parentizeBodyStatementsBeforeAppend(t,r),t.body=[].concat(n(r),n(t.body))}},{key:"parentizeBodyStatementsBeforeAppend",value:function(e,t){return t.forEach(function(t){t.parentNode=e}),t}},{key:"validateBodyStatements",value:function(e){return e.every(function(e){return!!e&&e.hasOwnProperty("type")})}}]),e}();t.NodeAppender=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.AfterObfuscation="afterObfuscation",e.BeforeObfuscation="beforeObfuscation"}(t.ObfuscationEvent||(t.ObfuscationEvent={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.BaseIdentifierObfuscatingReplacer="BaseIdentifierObfuscatingReplacer"}(t.IdentifierObfuscatingReplacer||(t.IdentifierObfuscatingReplacer={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{},r=new i.InversifyContainerFacade;r.load(e,t);var n=r.get(a.ServiceIdentifiers.IJavaScriptObfuscator),o=n.obfuscate(e);return r.unload(),o}},{key:"runCLI",value:function(e){var t=new c.JavaScriptObfuscatorCLI(e);t.initialize(),t.run()}}]),e}();t.JavaScriptObfuscator=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.BlockStatementControlFlowTransformer="BlockStatementControlFlowTransformer",e.ClassDeclarationTransformer="ClassDeclarationTransformer",e.CommentsTransformer="CommentsTransformer",e.DeadCodeInjectionTransformer="DeadCodeInjectionTransformer",e.FunctionControlFlowTransformer="FunctionControlFlowTransformer",e.CatchClauseTransformer="CatchClauseTransformer",e.FunctionDeclarationTransformer="FunctionDeclarationTransformer",e.FunctionTransformer="FunctionTransformer",e.LabeledStatementTransformer="LabeledStatementTransformer",e.LiteralTransformer="LiteralTransformer",e.MemberExpressionTransformer="MemberExpressionTransformer",e.MethodDefinitionTransformer="MethodDefinitionTransformer",e.ObfuscatingGuardsTransformer="ObfuscatingGuardsTransformer",e.ObjectExpressionKeysTransformer="ObjectExpressionKeysTransformer",e.ObjectExpressionTransformer="ObjectExpressionTransformer",e.ParentificationTransformer="ParentificationTransformer",e.TemplateLiteralTransformer="TemplateLiteralTransformer",e.VariableDeclarationTransformer="VariableDeclarationTransformer"}(t.NodeTransformer||(t.NodeTransformer={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.ConsoleOutputDisableExpressionNode="ConsoleOutputDisableExpressionNode",e.DebugProtectionFunctionCallNode="DebugProtectionFunctionCallNode",e.DebugProtectionFunctionIntervalNode="DebugProtectionFunctionIntervalNode",e.DebugProtectionFunctionNode="DebugProtectionFunctionNode",e.DomainLockNode="DomainLockNode",e.NodeCallsControllerFunctionNode="NodeCallsControllerFunctionNode",e.SelfDefendingUnicodeNode="SelfDefendingUnicodeNode",e.StringArrayCallsWrapper="StringArrayCallsWrapper",e.StringArrayNode="StringArrayNode",e.StringArrayRotateFunctionNode="StringArrayRotateFunctionNode"}(t.CustomNode||(t.CustomNode={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r-1||0===e.indexOf("//")?e.split("/")[2]:e.split("/")[0],t=t.split(":")[0]}},{key:"isCeilNumber",value:function(e){return e%1==0}},{key:"stringRotate",value:function(e,t){if(!e)throw new ReferenceError("Cannot rotate empty string.");for(var r=0;r [options]").version(c.version,"-v, --version").option("-o, --output ","Output path for obfuscated code").option("--compact ","Disable one line output code compacting",d.BooleanSanitizer).option("--config ","Name of js / json config file").option("--control-flow-flattening ","Enables control flow flattening",d.BooleanSanitizer).option("--control-flow-flattening-threshold ","The probability that the control flow flattening transformation will be applied to the node",parseFloat).option("--dead-code-injection ","Enables dead code injection",d.BooleanSanitizer).option("--dead-code-injection-threshold ","The probability that the dead code injection transformation will be applied to the node",parseFloat).option("--debug-protection ","Disable browser Debug panel (can cause DevTools enabled browser freeze)",d.BooleanSanitizer).option("--debug-protection-interval ","Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)",d.BooleanSanitizer).option("--disable-console-output ","Allow console.log, console.info, console.error and console.warn messages output into browser console",d.BooleanSanitizer).option("--domain-lock (comma separated, without whitespaces)","Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)",f.ArraySanitizer).option("--identifier-names-generator [hexadecimal, mangled]","Sets identifier names generator (Default: hexadecimal)",p.IdentifierNamesGeneratorSanitizer).option("--log ","Enables logging of the information to the console",d.BooleanSanitizer).option("--reserved-names (comma separated, without whitespaces)","Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)",f.ArraySanitizer).option("--rename-globals ","Allows to enable obfuscation of global variable and function names with declaration.",d.BooleanSanitizer).option("--rotate-string-array ","Disable rotation of unicode array values during obfuscation",d.BooleanSanitizer).option("--seed ","Sets seed for random generator. This is useful for creating repeatable results.",parseFloat).option("--self-defending ","Disables self-defending for obfuscated code",d.BooleanSanitizer).option("--source-map ","Enables source map generation",d.BooleanSanitizer).option("--source-map-base-url ","Sets base url to the source map import url when `--source-map-mode=separate`").option("--source-map-file-name ","Sets file name for output source map when `--source-map-mode=separate`").option("--source-map-mode [inline, separate]","Specify source map output mode",y.SourceMapModeSanitizer).option("--string-array ","Disables gathering of all literal strings into an array and replacing every literal string with an array call",d.BooleanSanitizer).option("--string-array-encoding [true, false, base64, rc4]","Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed",b.StringArrayEncodingSanitizer).option("--string-array-threshold ","The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)",parseFloat).option("--target ","Allows to set target environment for obfuscated code.",m.ObfuscationTargetSanitizer).option("--transform-object-keys ","Enables transformation of object keys",d.BooleanSanitizer).option("--unicode-escape-sequence ","Allows to enable/disable string conversion to unicode escape sequence",d.BooleanSanitizer).parse(this.rawArguments)}},{key:"configureHelp",value:function(){this.commands.on("--help",function(){console.log(" Examples:\n"),console.log(" %> javascript-obfuscator input_file_name.js --compact true --self-defending false"),console.log(" %> javascript-obfuscator input_file_name.js --output output_file_name.js --compact true --self-defending false"),console.log(" %> javascript-obfuscator input_directory_name --compact true --self-defending false"),console.log("")})}},{key:"processSourceCodeData",value:function(e){var t=this,r=this.inputCLIOptions.output?s.normalize(this.inputCLIOptions.output):"";if(Array.isArray(e))e.forEach(function(e){var n=e.filePath,o=e.content,a=r?s.join(r,n):g.CLIUtils.getOutputCodePath(n);t.processSourceCode(o,a)});else{var n=r||g.CLIUtils.getOutputCodePath(this.inputPath);this.processSourceCode(e,n)}}},{key:"processSourceCode",value:function(t,r){var n=this.buildOptions();n.sourceMap?e.processSourceCodeWithSourceMap(t,r,n):e.processSourceCodeWithoutSourceMap(t,r,n)}}],[{key:"filterOptions",value:function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&void 0!==e[r]&&(t[r]=e[r]);return t}},{key:"processSourceCodeWithoutSourceMap",value:function(e,t,r){var n=v.JavaScriptObfuscator.obfuscate(e,r).getObfuscatedCode();g.CLIUtils.writeFile(t,n)}},{key:"processSourceCodeWithSourceMap",value:function(e,t,r){var n=g.CLIUtils.getOutputSourceMapPath(t,r.sourceMapFileName||"");r=Object.assign({},r,{sourceMapFileName:s.basename(n)});var o=v.JavaScriptObfuscator.obfuscate(e,r);g.CLIUtils.writeFile(t,o.getObfuscatedCode()),"separate"===r.sourceMapMode&&o.getSourceMap()&&g.CLIUtils.writeFile(n,o.getSourceMap())}}]),e}();_.availableInputExtensions=[".js"],_.encoding="utf8",_.obfuscatedFilePrefix="-obfuscated",a.__decorate([u.initializable(),a.__metadata("design:type",Object)],_.prototype,"commands",void 0),a.__decorate([u.initializable(),a.__metadata("design:type",Object)],_.prototype,"inputCLIOptions",void 0),a.__decorate([u.initializable(),a.__metadata("design:type",String)],_.prototype,"inputPath",void 0),t.JavaScriptObfuscatorCLI=_},function(e,t){e.exports=require("path")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.FunctionDeclarationCalleeDataExtractor="FunctionDeclarationCalleeDataExtractor",e.FunctionExpressionCalleeDataExtractor="FunctionExpressionCalleeDataExtractor",e.ObjectExpressionCalleeDataExtractor="ObjectExpressionCalleeDataExtractor"}(t.CalleeDataExtractor||(t.CalleeDataExtractor={}))},function(e,t){e.exports=require("esprima")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.BinaryExpressionControlFlowReplacer="BinaryExpressionControlFlowReplacer",e.CallExpressionControlFlowReplacer="CallExpressionControlFlowReplacer",e.LogicalExpressionControlFlowReplacer="LogicalExpressionControlFlowReplacer",e.StringLiteralControlFlowReplacer="StringLiteralControlFlowReplacer"}(t.ControlFlowReplacer||(t.ControlFlowReplacer={}))},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]&&arguments[1];this.storage=new Map([].concat(n(this.storage),n(e.getStorage()))),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){this.storage.set(e,t)}}]),e}();c.__decorate([l.initializable(),c.__metadata("design:type",String)],f.prototype,"storageId",void 0),c.__decorate([l.initializable(),c.__metadata("design:type",Map)],f.prototype,"storage",void 0),c.__decorate([s.postConstruct(),c.__metadata("design:type",Function),c.__metadata("design:paramtypes",[]),c.__metadata("design:returntype",void 0)],f.prototype,"initialize",null),f=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(1,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object])],f),t.MapStorage=f},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:d.randomGeneratorPool;return this.getRandomGenerator().string({length:e,pool:t})}},{key:"getSeed",value:function(){return this.seed}}]),e}();f.randomGeneratorPool="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",f.randomGeneratorPoolNumbers="0123456789",f.randomGeneratorPoolHexadecimal="abcdef"+d.randomGeneratorPoolNumbers,a.__decorate([l.initializable(),a.__metadata("design:type",Object)],f.prototype,"randomGenerator",void 0),a.__decorate([l.initializable(),a.__metadata("design:type",Number)],f.prototype,"seed",void 0),a.__decorate([i.postConstruct(),a.__metadata("design:type",Function),a.__metadata("design:paramtypes",[]),a.__metadata("design:returntype",void 0)],f.prototype,"initialize",null),f=d=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])],f),t.RandomGenerator=f;var d},function(e,t){e.exports=require("pjson")},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(18);e.exports=n.JavaScriptObfuscator},function(e,t){e.exports=require("reflect-metadata")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(35),c=r(51),s=r(52),u=r(53),l=r(54);t.analyzersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.IStackTraceAnalyzer).to(l.StackTraceAnalyzer).inSingletonScope(),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(c.FunctionDeclarationCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(s.FunctionExpressionCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor),e(a.ServiceIdentifiers.ICalleeDataExtractor).to(u.ObjectExpressionCalleeDataExtractor).whenTargetNamed(i.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor),e(a.ServiceIdentifiers.Factory__ICalleeDataExtractor).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.ICalleeDataExtractor))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rr)return"break";var a=e[o];s.traverse(a,{enter:function(r){if(l.NodeGuards.isCallExpressionNode(r))return a.parentNode!==f.NodeUtils.getBlockScopesOfNode(r)[0]?s.VisitorOption.Skip:void t.analyzeCallExpressionNode(n,e,r)}})}(a))break}return n}},{key:"analyzeCallExpressionNode",value:function(e,t,r){var n=this;p.calleeDataExtractorsList.forEach(function(o){var a=n.calleeDataExtractorFactory(o).extract(t,r.callee);a&&e.push(Object.assign({},a,{stackTrace:n.analyzeRecursive(a.callee.body)}))})}}],[{key:"getLimitIndex",value:function(e){var t=e-1,r=p.limitThresholdActivationLength-1,n=t;return t>r&&(n=Math.round(r+t*p.limitThreshold))>t&&(n=t),n}}]),e}();d.calleeDataExtractorsList=[u.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor,u.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor,u.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor],d.limitThresholdActivationLength=25,d.limitThreshold=.002,d=p=a.__decorate([i.injectable(),a.__param(0,i.inject(c.ServiceIdentifiers.Factory__ICalleeDataExtractor)),a.__metadata("design:paramtypes",[Function])],d),t.StackTraceAnalyzer=d;var p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(37),c=r(19),s=r(56),u=r(57),l=r(58),f=r(59),d=r(60),p=r(61),m=r(62);t.controlFlowTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(u.BlockStatementControlFlowTransformer).whenTargetNamed(c.NodeTransformer.BlockStatementControlFlowTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(f.DeadCodeInjectionTransformer).whenTargetNamed(c.NodeTransformer.DeadCodeInjectionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.FunctionControlFlowTransformer).whenTargetNamed(c.NodeTransformer.FunctionControlFlowTransformer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(s.BinaryExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.BinaryExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(l.CallExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.CallExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(p.LogicalExpressionControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.LogicalExpressionControlFlowReplacer),e(a.ServiceIdentifiers.IControlFlowReplacer).to(m.StringLiteralControlFlowReplacer).whenTargetNamed(i.ControlFlowReplacer.StringLiteralControlFlowReplacer),e(a.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IControlFlowReplacer))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rthis.options.controlFlowFlatteningThreshold||!b.canTransformBlockStatementNode(e))return e;var r=e.body,n=this.arrayUtils.arrayRange(r.length),o=this.arrayUtils.arrayShuffle(n),a=n.map(function(e){return o.indexOf(e)}),i=this.controlFlowCustomNodeFactory(f.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);i.initialize(r,o,a);var c=i.getNode()[0];return m.NodeUtils.parentizeNode(c,t),c}}],[{key:"blockStatementHasProhibitedStatements",value:function(e){return e.body.some(function(e){var t=p.NodeGuards.isBreakStatementNode(e)||p.NodeGuards.isContinueStatementNode(e),r=p.NodeGuards.isVariableDeclarationNode(e)&&("const"===e.kind||"let"===e.kind);return p.NodeGuards.isFunctionDeclarationNode(e)||t||r})}},{key:"canTransformBlockStatementNode",value:function(e){var t=!0;return l.traverse(e,{enter:function(e){if(p.NodeGuards.isWhileStatementNode(e))return l.VisitorOption.Skip;p.NodeGuards.isBlockStatementNode(e)&&b.blockStatementHasProhibitedStatements(e)&&(t=!1)}}),e.body.length<=4&&(t=!1),t}}]),t}(d.AbstractNodeTransformer);y=b=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 b},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rthis.options.deadCodeInjectionThreshold)return e;if(b.NodeUtils.getBlockScopesOfNode(e)[0].type===p.NodeType.Program)return e;var r=this.collectedBlockStatements.length-1,n=this.randomGenerator.getRandomInteger(0,r),o=this.collectedBlockStatements.splice(n,1)[0];return o===e?e:this.replaceBlockStatementNode(e,o,t)}},{key:"collectBlockStatementNodes",value:function(e,t,r){var n=b.NodeUtils.clone(e),o=0,a=!0;l.replace(n,{enter:function(e){return y.NodeGuards.isBlockStatementNode(e)&&o++,o>v.maxNestedBlockStatementsCount||!v.isValidBlockStatementNode(e)?(a=!1,l.VisitorOption.Break):e}}),a&&(b.NodeUtils.parentizeNode(n,r),n=this.transformersRunner.transform(n,v.transformersToRenameBlockScopeIdentifiers),t.push(n))}},{key:"replaceBlockStatementNode",value:function(e,t,r){var n=this.deadCodeInjectionCustomNodeFactory(f.DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode);n.initialize(e,t);var o=n.getNode()[0];return b.NodeUtils.parentizeNode(o,r),o}}],[{key:"isValidBlockStatementNode",value:function(e){return!(y.NodeGuards.isBreakStatementNode(e)||y.NodeGuards.isContinueStatementNode(e)||y.NodeGuards.isAwaitExpressionNode(e)||y.NodeGuards.isSuperNode(e))}}]),t}(m.AbstractNodeTransformer);g.maxNestedBlockStatementsCount=4,g.minCollectedBlockStatementsCount=5,g.transformersToRenameBlockScopeIdentifiers=[d.NodeTransformer.CatchClauseTransformer,d.NodeTransformer.ClassDeclarationTransformer,d.NodeTransformer.FunctionDeclarationTransformer,d.NodeTransformer.FunctionTransformer,d.NodeTransformer.LabeledStatementTransformer,d.NodeTransformer.VariableDeclarationTransformer],g=v=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode)),c.__param(1,s.inject(u.ServiceIdentifiers.ITransformersRunner)),c.__param(2,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(3,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Function,Object,Object,Object])],g),t.DeadCodeInjectionTransformer=g;var v},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;rh.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.NodeGuards.isFunctionDeclarationNode(e)||y.NodeGuards.isFunctionExpressionNode(e)||y.NodeGuards.isArrowFunctionExpressionNode(e))&&this.visitedFunctionNodes.has(e)}},{key:"transformFunctionBody",value:function(e,t){var r=this;l.replace(e,{enter:function(e,n){if(e.ignoredNode)return l.VisitorOption.Skip;if(r.isVisitedFunctionNode(e)||!n)return l.VisitorOption.Skip;if(!h.controlFlowReplacersMap.has(e.type))return e;if(r.randomGenerator.getMathRandom()>r.options.controlFlowFlatteningThreshold)return e;var o=h.controlFlowReplacersMap.get(e.type);return void 0===o?e:Object.assign({},r.controlFlowReplacerFactory(o).replace(e,n,t),{parentNode:n})}})}}]),t}(m.AbstractNodeTransformer);v.controlFlowReplacersMap=new Map([[p.NodeType.BinaryExpression,d.ControlFlowReplacer.BinaryExpressionControlFlowReplacer],[p.NodeType.CallExpression,d.ControlFlowReplacer.CallExpressionControlFlowReplacer],[p.NodeType.LogicalExpression,d.ControlFlowReplacer.LogicalExpressionControlFlowReplacer],[p.NodeType.Literal,d.ControlFlowReplacer.StringLiteralControlFlowReplacer]]),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,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r1){var o=d.Nodes.getBinaryExpressionNode("+",n.shift(),n.shift());return n.forEach(function(e){o=d.Nodes.getBinaryExpressionNode("+",o,e)}),o}return n[0]}}],[{key:"isLiteralNodeWithStringValue",value:function(e){return e&&f.NodeGuards.isLiteralNode(e)&&"string"==typeof e.value}}]),t}(l.AbstractNodeTransformer);p=m=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 m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(12),c=r(20),s=r(40),u=r(39),l=r(69),f=r(70),d=r(71),p=r(72),m=r(73),y=r(74),b=r(77),g=r(78),v=r(79),h=r(80),_=r(81),N=r(82),O=r(84),S=r(86),j=r(88),C=r(92),I=r(94),w=r(95),F=r(96),T=r(98),E=r(100),k=r(107),P=r(109),x=r(113),R=r(114);t.customNodesModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.ICustomNode).to(N.ConsoleOutputDisableExpressionNode).whenTargetNamed(c.CustomNode.ConsoleOutputDisableExpressionNode),e(a.ServiceIdentifiers.ICustomNode).to(O.DebugProtectionFunctionCallNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionCallNode),e(a.ServiceIdentifiers.ICustomNode).to(S.DebugProtectionFunctionIntervalNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionIntervalNode),e(a.ServiceIdentifiers.ICustomNode).to(j.DebugProtectionFunctionNode).whenTargetNamed(c.CustomNode.DebugProtectionFunctionNode),e(a.ServiceIdentifiers.ICustomNode).to(C.DomainLockNode).whenTargetNamed(c.CustomNode.DomainLockNode),e(a.ServiceIdentifiers.ICustomNode).to(F.NodeCallsControllerFunctionNode).whenTargetNamed(c.CustomNode.NodeCallsControllerFunctionNode),e(a.ServiceIdentifiers.ICustomNode).to(T.SelfDefendingUnicodeNode).whenTargetNamed(c.CustomNode.SelfDefendingUnicodeNode),e(a.ServiceIdentifiers.ICustomNode).to(E.StringArrayCallsWrapper).whenTargetNamed(c.CustomNode.StringArrayCallsWrapper),e(a.ServiceIdentifiers.ICustomNode).to(k.StringArrayNode).whenTargetNamed(c.CustomNode.StringArrayNode),e(a.ServiceIdentifiers.ICustomNode).to(P.StringArrayRotateFunctionNode).whenTargetNamed(c.CustomNode.StringArrayRotateFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(y.BinaryExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.BinaryExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(b.BlockStatementControlFlowFlatteningNode).whenTargetNamed(i.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(v.CallExpressionControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(h.CallExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.CallExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(_.ControlFlowStorageNode).whenTargetNamed(i.ControlFlowCustomNode.ControlFlowStorageNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(I.ExpressionWithOperatorControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(w.LogicalExpressionFunctionNode).whenTargetNamed(i.ControlFlowCustomNode.LogicalExpressionFunctionNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(R.StringLiteralNode).whenTargetNamed(i.ControlFlowCustomNode.StringLiteralNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(x.StringLiteralControlFlowStorageCallNode).whenTargetNamed(i.ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode),e(a.ServiceIdentifiers.Newable__ICustomNode).toConstructor(g.BlockStatementDeadCodeInjectionNode).whenTargetNamed(u.DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode),e(a.ServiceIdentifiers.ICustomNodeGroup).to(l.ConsoleOutputCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.ConsoleOutputCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(f.DebugProtectionCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.DebugProtectionCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(d.DomainLockCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.DomainLockCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(p.SelfDefendingCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.SelfDefendingCustomNodeGroup),e(a.ServiceIdentifiers.ICustomNodeGroup).to(m.StringArrayCustomNodeGroup).whenTargetNamed(s.CustomNodeGroup.StringArrayCustomNodeGroup),e(a.ServiceIdentifiers.Factory__ICustomNode).toFactory(n.InversifyContainerFacade.getFactory(a.ServiceIdentifiers.ICustomNode)),e(a.ServiceIdentifiers.Factory__IControlFlowCustomNode).toFactory(n.InversifyContainerFacade.getConstructorFactory(a.ServiceIdentifiers.Newable__ICustomNode,a.ServiceIdentifiers.Factory__IIdentifierNamesGenerator,a.ServiceIdentifiers.IRandomGenerator,a.ServiceIdentifiers.IOptions)),e(a.ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode).toFactory(n.InversifyContainerFacade.getConstructorFactory(a.ServiceIdentifiers.Newable__ICustomNode,a.ServiceIdentifiers.Factory__IIdentifierNamesGenerator,a.ServiceIdentifiers.IRandomGenerator,a.ServiceIdentifiers.IOptions)),e(a.ServiceIdentifiers.Factory__ICustomNodeGroup).toFactory(n.InversifyContainerFacade.getFactory(a.ServiceIdentifiers.ICustomNodeGroup))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r.5,t=this.randomGenerator.getMathRandom()>.5,r=e?"===":"!==",n=this.randomGenerator.getRandomString(3),o=t?n:this.randomGenerator.getRandomString(3),a=e===t?[this.blockStatementNode,this.randomBlockStatementNode]:[this.randomBlockStatementNode,this.blockStatementNode],c=i(a,2),s=c[0],u=c[1],l=p.Nodes.getBlockStatementNode([p.Nodes.getIfStatementNode(p.Nodes.getBinaryExpressionNode(r,p.Nodes.getLiteralNode(n),p.Nodes.getLiteralNode(o)),s,u)]);return m.NodeUtils.parentize(l),[l]}}]),t}(d.AbstractCustomNode);s.__decorate([f.initializable(),s.__metadata("design:type",Object)],y.prototype,"blockStatementNode",void 0),s.__decorate([f.initializable(),s.__metadata("design:type",Object)],y.prototype,"randomBlockStatementNode",void 0),y=s.__decorate([u.injectable(),s.__param(0,u.inject(l.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)),s.__param(1,u.inject(l.ServiceIdentifiers.IRandomGenerator)),s.__param(2,u.inject(l.ServiceIdentifiers.IOptions)),s.__metadata("design:paramtypes",[Function,Object,Object])],y),t.BlockStatementDeadCodeInjectionNode=y},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t 0;\n \n switch (isPositive) {\n case true:\n return this.item + \'_\' + this.value + \'_\' + i;\n default:\n this.item + \'_\' + this.value;\n }\n }\n }()\n };\n };\n \n var regExp = new RegExp("[{diff}]", "g");\n var domains = "{domains}".replace(regExp, "").split(";");\n var document;\n var domain;\n \n for (var d in that) {\n if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {\n document = d;\n \n break;\n }\n }\n\n for (var d1 in that[document]) {\n if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {\n domain = d1;\n \n break;\n }\n }\n \n if ((!document && !domain) || (!that[document] && !that[document][domain])) {\n return;\n }\n \n var currentDomain = that[document][domain];\n\n var ok = false;\n \n for (var i = 0; i < domains.length; i++) {\n var domain = domains[i];\n var position = currentDomain.length - domain.length;\n var lastIndex = currentDomain.indexOf(domain, position);\n var endsWith = lastIndex !== -1 && lastIndex === position;\n \n if (endsWith) {\n if (currentDomain.length == domain.length || domain.indexOf(".") === 0) {\n ok = true;\n }\n \n break;\n }\n }\n \n if (!ok) {\n data;\n } else {\n return;\n }\n \n func();\n });\n\n {domainLockFunctionName}();\n '}Object.defineProperty(t,"__esModule",{value:!0}),t.DomainLockNodeTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r> 1 + 255 % 0;\n \n if (string.indexOf('i' === i)) {\n recursiveFunc2(string)\n }\n };\n \n var recursiveFunc2 = function (string) {\n var i = ~-4 >> 1 + 255 % 0;\n \n if (string.indexOf((true+\"\")[3]) !== i) {\n recursiveFunc1(string)\n }\n };\n \n if (!test1()) {\n if (!test2()) {\n recursiveFunc1('indеxOf');\n } else {\n recursiveFunc1('indexOf');\n }\n } else {\n recursiveFunc1('indеxOf');\n }\n })\n \n {selfDefendingFunctionName}();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r> (-2 * bc & 6)) : 0\n ) {\n buffer = chars.indexOf(buffer);\n }\n return output;\n });\n })();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.AtobTemplate=n},function(e,t,r){"use strict";function n(){return"\n var rc4 = function (str, key) {\n var s = [], j = 0, x, res = '', newStr = '';\n \n str = atob(str);\n \n for (var k = 0, length = str.length; k < length; k++) {\n newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);\n }\n \n str = decodeURIComponent(newStr);\n \t \n\t for (var i = 0; i < 256; i++) {\n s[i] = i;\n }\n \n for (i = 0; i < 256; i++) {\n j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n }\n \n i = 0;\n j = 0;\n \n for (var y = 0; y < str.length; y++) {\n i = (i + 1) % 256;\n j = (j + s[i]) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);\n }\n \n return res;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.Rc4Template=n},function(e,t,r){"use strict";function n(e,t){var r=e.getRandomString(6),n=e.getRandomString(6),o=e.getRandomString(6),a=e.getRandomString(6),i=e.getRandomString(6),c=e.getRandomString(6),s=e.getRandomString(6),u=e.getRandomString(6),l=e.getRandomString(6);return"\n var StatesClass = function ("+r+") {\n this."+r+" = "+r+";\n this."+n+" = [1, 0, 0];\n this."+o+" = function(){return 'newState';};\n this."+a+" = '"+t.encode("\\w+ *\\(\\) *{\\w+ *",!0)+"';\n this."+i+" = '"+t.encode("['|\"].+['|\"];? *}",!0)+"';\n };\n \n StatesClass.prototype."+c+" = function () {\n var regExp = new RegExp(this."+a+" + this."+i+");\n var expression = regExp.test(this."+o+".toString())\n ? --this."+n+"[1]\n : --this."+n+"[0];\n \n return this."+s+"(expression);\n };\n \n StatesClass.prototype."+s+" = function ("+l+") {\n if (!Boolean(~"+l+")) {\n return "+l+";\n }\n \n return this."+u+"(this."+r+");\n };\n\n StatesClass.prototype."+u+" = function ("+r+") {\n for (var i = 0, len = this."+n+".length; i < len; i++) {\n this."+n+".push(Math.round(Math.random()));\n len = this."+n+".length;\n }\n \n return "+r+"(this."+n+"[0]);\n };\n\n new StatesClass({stringArrayCallsWrapperName})."+c+"();\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.SelfDefendingTemplate=n},function(e,t,r){"use strict";function n(e){var t=e.getRandomString(6),r=e.getRandomString(6),n=e.getRandomString(6);return"\n if ({stringArrayCallsWrapperName}."+t+" === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}."+r+" = 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}."+n+" = {};\n \n {stringArrayCallsWrapperName}."+t+" = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}."+n+"[index];\n \n if (cachedValue === undefined) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}."+r+"(value);\n {stringArrayCallsWrapperName}."+n+"[index] = value;\n } else {\n value = cachedValue;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayBase64DecodeNodeTemplate=n},function(e,t,r){"use strict";function n(){return"\n var {stringArrayCallsWrapperName} = function (index, key) {\n index = index - 0;\n \n var value = {stringArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayCallsWrapperTemplate=n},function(e,t,r){"use strict";function n(e){var t=e.getRandomString(6),r=e.getRandomString(6),n=e.getRandomString(6),o=e.getRandomString(6);return"\n if ({stringArrayCallsWrapperName}."+t+" === undefined) {\n {atobPolyfill}\n \n {rc4Polyfill}\n {stringArrayCallsWrapperName}."+r+" = rc4;\n \n {stringArrayCallsWrapperName}."+n+" = {};\n \n {stringArrayCallsWrapperName}."+t+" = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}."+n+"[index];\n\n if (cachedValue === undefined) {\n if ({stringArrayCallsWrapperName}."+o+" === undefined) {\n {selfDefendingCode}\n \n {stringArrayCallsWrapperName}."+o+" = true;\n }\n \n value = {stringArrayCallsWrapperName}."+r+"(value, key);\n {stringArrayCallsWrapperName}."+n+"[index] = value;\n } else {\n value = cachedValue;\n }\n "}Object.defineProperty(t,"__esModule",{value:!0}),t.StringArrayRc4DecodeNodeTemplate=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=0);return"a"+o(n)}(e);return d.validateMangledName(t)||(t=d.generateNewMangledName(t)),t}},{key:"validateMangledName",value:function(e){return!(-1!==d.reservedNames.indexOf(e))}}]),t}(l.AbstractIdentifierNamesGenerator);f.initMangledNameCharacter="9",f.nameSequence="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),f.reservedNames=["byte","case","char","do","else","enum","eval","for","goto","if","in","int","let","long","new","null","this","true","try","var","void","with"],f=d=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])],f),t.MangledIdentifierNamesGenerator=f;var d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1);t.nodeTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.Factory__INodeTransformer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.INodeTransformer))})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(14),o=r(0),a=r(1),i=r(17),c=r(42),s=r(19),u=r(120),l=r(121),f=r(122),d=r(123),p=r(124),m=r(125),y=r(126),b=r(127),g=r(128),v=r(129),h=r(130),_=r(131);t.obfuscatingTransformersModule=new o.ContainerModule(function(e){e(a.ServiceIdentifiers.INodeTransformer).to(f.CatchClauseTransformer).whenTargetNamed(s.NodeTransformer.CatchClauseTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(d.ClassDeclarationTransformer).whenTargetNamed(s.NodeTransformer.ClassDeclarationTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(p.FunctionDeclarationTransformer).whenTargetNamed(s.NodeTransformer.FunctionDeclarationTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(m.FunctionTransformer).whenTargetNamed(s.NodeTransformer.FunctionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(y.LabeledStatementTransformer).whenTargetNamed(s.NodeTransformer.LabeledStatementTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(b.LiteralTransformer).whenTargetNamed(s.NodeTransformer.LiteralTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(v.ObjectExpressionTransformer).whenTargetNamed(s.NodeTransformer.ObjectExpressionTransformer),e(a.ServiceIdentifiers.INodeTransformer).to(_.VariableDeclarationTransformer).whenTargetNamed(s.NodeTransformer.VariableDeclarationTransformer),e(a.ServiceIdentifiers.IObfuscatingReplacer).to(l.BooleanLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.BooleanLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IObfuscatingReplacer).to(g.NumberLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.NumberLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IObfuscatingReplacer).to(h.StringLiteralObfuscatingReplacer).whenTargetNamed(c.LiteralObfuscatingReplacer.StringLiteralObfuscatingReplacer),e(a.ServiceIdentifiers.IIdentifierObfuscatingReplacer).to(u.BaseIdentifierObfuscatingReplacer).whenTargetNamed(i.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer),e(a.ServiceIdentifiers.Factory__IObfuscatingReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IObfuscatingReplacer)),e(a.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer).toFactory(n.InversifyContainerFacade.getCacheFactory(a.ServiceIdentifiers.IIdentifierObfuscatingReplacer))})},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=y.minimumLengthForStringArray&&this.randomGenerator.getMathRandom()<=this.options.stringArrayThreshold}},{key:"getStringArrayHexadecimalIndex",value:function(e,t){if(this.stringLiteralHexadecimalIndexCache.has(e))return{fromCache:!0,index:this.stringLiteralHexadecimalIndexCache.get(e)};var r=p.Utils.decToHex(t),n=""+p.Utils.hexadecimalPrefix+r;return this.stringLiteralHexadecimalIndexCache.set(e,n),{fromCache:!1,index:n}}},{key:"getEncodedValue",value:function(e){var t=void 0,r=null;switch(this.options.stringArrayEncoding){case l.StringArrayEncoding.Rc4:r=this.randomGenerator.getRandomGenerator().pickone(this.rc4Keys),t=this.cryptUtils.btoa(this.cryptUtils.rc4(e,r));break;case l.StringArrayEncoding.Base64:t=this.cryptUtils.btoa(e);break;default:t=e}return{encodedValue:t,key:r}}},{key:"replaceWithLiteralNode",value:function(e){return d.Nodes.getLiteralNode(this.escapeSequenceEncoder.encode(e,this.options.unicodeEscapeSequence))}},{key:"replaceWithStringArrayCallNode",value:function(e){var t=this.getEncodedValue(e),r=t.encodedValue,n=t.key,o=this.escapeSequenceEncoder.encode(r,this.options.unicodeEscapeSequence),a=this.stringArrayStorage.getLength(),i=this.stringArrayStorage.getStorageId().split("|")[1],c=this.getStringArrayHexadecimalIndex(o,a),s=c.fromCache,u=c.index;s||this.stringArrayStorage.set(a,o);var l=[y.getHexadecimalLiteralNode(u)];return n&&l.push(y.getRc4KeyLiteralNode(this.escapeSequenceEncoder.encode(n,this.options.unicodeEscapeSequence))),d.Nodes.getCallExpressionNode(d.Nodes.getIdentifierNode(i),l)}}],[{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);m.minimumLengthForStringArray=3,m.rc4KeyLength=4,m.rc4KeysCount=50,m=y=c.__decorate([s.injectable(),c.__param(0,s.inject(u.ServiceIdentifiers.TStringArrayStorage)),c.__param(1,s.inject(u.ServiceIdentifiers.IEscapeSequenceEncoder)),c.__param(2,s.inject(u.ServiceIdentifiers.IRandomGenerator)),c.__param(3,s.inject(u.ServiceIdentifiers.ICryptUtils)),c.__param(4,s.inject(u.ServiceIdentifiers.IOptions)),c.__metadata("design:paramtypes",[Object,Object,Object,Object,Object])],m),t.StringLiteralObfuscatingReplacer=m;var y},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var r=0;r=0?t:null}},{key:"getLength",value:function(){return this.storageLength}},{key:"getStorage",value:function(){return this.storage}},{key:"getStorageId",value:function(){return this.storageId}},{key:"mergeWith",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.storage=[].concat(n(this.storage),n(e.getStorage())),t&&(this.storageId=e.getStorageId())}},{key:"set",value:function(e,t){e===this.storageLength?this.storage.push(t):this.storage.splice(e,0,t),this.storageLength++}}]),e}();i.__decorate([u.initializable(),i.__metadata("design:type",Array)],l.prototype,"storage",void 0),i.__decorate([u.initializable(),i.__metadata("design:type",String)],l.prototype,"storageId",void 0),i.__decorate([c.postConstruct(),i.__metadata("design:type",Function),i.__metadata("design:paramtypes",[]),i.__metadata("design:returntype",void 0)],l.prototype,"initialize",null),l=i.__decorate([c.injectable(),i.__param(0,c.inject(s.ServiceIdentifiers.IRandomGenerator)),i.__param(1,c.inject(s.ServiceIdentifiers.IOptions)),i.__metadata("design:paramtypes",[Object,Object])],l),t.ArrayStorage=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(1),a=r(144),i=r(145),c=r(148),s=r(45);t.utilsModule=new n.ContainerModule(function(e){e(o.ServiceIdentifiers.IArrayUtils).to(a.ArrayUtils).inSingletonScope(),e(o.ServiceIdentifiers.IRandomGenerator).to(s.RandomGenerator).inSingletonScope(),e(o.ServiceIdentifiers.ICryptUtils).to(i.CryptUtils).inSingletonScope(),e(o.ServiceIdentifiers.IEscapeSequenceEncoder).to(c.EscapeSequenceEncoder).inSingletonScope()})},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t>8-o%1*8)){if((n=e.charCodeAt(o+=.75))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|n}return t}},{key:"hideString",value:function(e,t){var r=this,n=this.randomGenerator.getRandomGenerator().string({length:t,pool:s.RandomGenerator.randomGeneratorPool}),o=n.replace(new RegExp("["+function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}(e)+"]","g"),""),a=o.split("");return this.randomGenerator.getRandomGenerator().shuffle(a),o=a.join(""),[function(e,t){for(var n=-1,o=-1,a="";n values should be wrapped inside quotes: --option-name 'value1, value2'");return e.split(",").map(function(e){return e.trim()})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizer=function(e){return"true"===e||"1"===e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(23);t.IdentifierNamesGeneratorSanitizer=function(e){if(!Object.keys(n.IdentifierNamesGenerator).some(function(t){return n.IdentifierNamesGenerator[t]===e}))throw new ReferenceError("Invalid value of `--identifier-names-generator` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(13);t.ObfuscationTargetSanitizer=function(e){if(!Object.keys(n.ObfuscationTarget).some(function(t){return n.ObfuscationTarget[t]===e}))throw new ReferenceError("Invalid value of `--target` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(24);t.SourceMapModeSanitizer=function(e){if(!Object.keys(n.SourceMapMode).some(function(t){return n.SourceMapMode[t]===e}))throw new ReferenceError("Invalid value of `--source-map-mode` option");return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(25);t.StringArrayEncodingSanitizer=function(e){switch(e){case"true":case"1":case n.StringArrayEncoding.Base64:return!0;case n.StringArrayEncoding.Rc4:return n.StringArrayEncoding.Rc4;default:return!1}}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"";return t&&(e=e.substring(0,e.lastIndexOf("/"))+"/"+t),/\.js\.map$/.test(e)?/\.js$/.test(e)&&(e+=".map"):e=e.split(".")[0]+".js.map",e}},{key:"getUserConfig",value:function(e){var t=void 0;try{t=!function(){var e=new Error('Cannot find module "."');throw e.code="MODULE_NOT_FOUND",e}()}catch(r){try{t=require(e)}catch(e){throw new ReferenceError("Given config path must be a valid file path")}}return t}},{key:"writeFile",value:function(e,t){i.sync(c.dirname(e)),a.writeFileSync(e,t,{encoding:s.JavaScriptObfuscatorCLI.encoding})}}]),e}();t.CLIUtils=u},function(e,t){e.exports=require("mkdirp")},function(e,t){function r(e){throw new Error("Cannot find module '"+e+"'.")}r.keys=function(){return[]},r.resolve=r,e.exports=r,r.id=183},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t1&&void 0!==arguments[1]?arguments[1]:[];return i.readdirSync(t,s.JavaScriptObfuscatorCLI.encoding).forEach(function(o){var a=t+"/"+o;if(e.isDirectoryPath(a))r.push.apply(r,n(e.readDirectoryRecursive(a)));else if(e.isFilePath(a)&&e.isValidFile(o)){var c=i.readFileSync(a,s.JavaScriptObfuscatorCLI.encoding);r.push({filePath:a,content:c})}}),r}},{key:"readFile",value:function(t){if(!e.isValidFile(t))throw new ReferenceError("Input file must have .js extension");return i.readFileSync(t,s.JavaScriptObfuscatorCLI.encoding)}},{key:"isValidFile",value:function(e){return-1!==s.JavaScriptObfuscatorCLI.availableInputExtensions.indexOf(c.extname(e))&&!(-1!==e.indexOf(s.JavaScriptObfuscatorCLI.obfuscatedFilePrefix))}}]),e}();t.SourceCodeReader=u}]); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/package.json b/package.json index de5cc077..aef0796f 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "chance": "1.0.13", "class-validator": "0.7.3", "commander": "2.12.2", - "escodegen-wallaby": "1.6.15", + "escodegen-wallaby": "1.6.16", "esprima": "4.0.0", "estraverse": "4.2.0", "inversify": "4.9.0", @@ -38,7 +38,7 @@ }, "devDependencies": { "@types/chai": "4.0.10", - "@types/chance": "0.7.35", + "@types/chance": "0.7.36", "@types/commander": "2.12.2", "@types/escodegen": "0.0.6", "@types/esprima": "4.0.1", @@ -47,7 +47,7 @@ "@types/md5": "2.1.32", "@types/mkdirp": "0.5.2", "@types/mocha": "2.2.45", - "@types/node": "8.5.2", + "@types/node": "8.5.5", "@types/rimraf": "^2.0.2", "@types/sinon": "4.1.2", "@types/string-template": "1.0.2", diff --git a/src/JavaScriptObfuscator.ts b/src/JavaScriptObfuscator.ts index 19d24c62..301c3fc9 100644 --- a/src/JavaScriptObfuscator.ts +++ b/src/JavaScriptObfuscator.ts @@ -51,6 +51,7 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator { private static readonly convertingTransformersList: NodeTransformer[] = [ NodeTransformer.MemberExpressionTransformer, NodeTransformer.MethodDefinitionTransformer, + NodeTransformer.ObjectExpressionKeysTransformer, NodeTransformer.TemplateLiteralTransformer ]; @@ -250,12 +251,19 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator { ); } - // fifth pass: converting and obfuscating transformers + // fifth pass: converting transformers + this.logger.info(LoggingMessage.StagePreObfuscation); + astTree = this.transformersRunner.transform( + astTree, + JavaScriptObfuscator.convertingTransformersList + ); + + // sixth pass: obfuscating transformers this.logger.info(LoggingMessage.StageObfuscation); - astTree = this.transformersRunner.transform(astTree, [ - ...JavaScriptObfuscator.convertingTransformersList, - ...JavaScriptObfuscator.obfuscatingTransformersList - ]); + astTree = this.transformersRunner.transform( + astTree, + JavaScriptObfuscator.obfuscatingTransformersList + ); this.obfuscationEventEmitter.emit(ObfuscationEvent.AfterObfuscation, astTree, stackTraceData); diff --git a/src/cli/JavaScriptObfuscatorCLI.ts b/src/cli/JavaScriptObfuscatorCLI.ts index 2e4e9d5b..1b910115 100644 --- a/src/cli/JavaScriptObfuscatorCLI.ts +++ b/src/cli/JavaScriptObfuscatorCLI.ts @@ -309,6 +309,11 @@ export class JavaScriptObfuscatorCLI implements IInitializable { 'Allows to set target environment for obfuscated code.', ObfuscationTargetSanitizer ) + .option( + '--transform-object-keys ', + 'Enables transformation of object keys', + BooleanSanitizer + ) .option( '--unicode-escape-sequence ', 'Allows to enable/disable string conversion to unicode escape sequence', diff --git a/src/container/InversifyContainerFacade.ts b/src/container/InversifyContainerFacade.ts index b40478c8..842a3754 100644 --- a/src/container/InversifyContainerFacade.ts +++ b/src/container/InversifyContainerFacade.ts @@ -47,7 +47,7 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { * @param {interfaces.ServiceIdentifier} serviceIdentifier * @returns {U} */ - public static getFactory ( + public static getFactory ( serviceIdentifier: interfaces.ServiceIdentifier ): (context: interfaces.Context) => (bindingName: T) => U { return (context: interfaces.Context): (bindingName: T) => U => { @@ -61,7 +61,7 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { * @param {interfaces.ServiceIdentifier} serviceIdentifier * @returns {U} */ - public static getCacheFactory ( + public static getCacheFactory ( serviceIdentifier: interfaces.ServiceIdentifier ): (context: interfaces.Context) => (bindingName: T) => U { return (context: interfaces.Context): (bindingName: T) => U => { @@ -86,7 +86,7 @@ export class InversifyContainerFacade implements IInversifyContainerFacade { * @param {any[]} dependencies * @returns {U} */ - public static getConstructorFactory ( + public static getConstructorFactory ( serviceIdentifier: interfaces.ServiceIdentifier>, ...dependencies: any[] ): (context: interfaces.Context) => (bindingName: T) => U { diff --git a/src/container/ServiceIdentifiers.ts b/src/container/ServiceIdentifiers.ts index 1a6c1bdb..1f9473c6 100644 --- a/src/container/ServiceIdentifiers.ts +++ b/src/container/ServiceIdentifiers.ts @@ -4,6 +4,7 @@ export enum ServiceIdentifiers { Factory__IControlFlowReplacer = 'Factory', Factory__ICustomNode = 'Factory', Factory__ICustomNodeGroup = 'Factory', + Factory__IDeadCodeInjectionCustomNode = 'Factory', Factory__IIdentifierNamesGenerator = 'Factory', Factory__IIdentifierObfuscatingReplacer = 'Factory', Factory__INodeGuard = 'Factory', diff --git a/src/container/modules/custom-nodes/CustomNodesModule.ts b/src/container/modules/custom-nodes/CustomNodesModule.ts index ad8d8d27..e78ba981 100644 --- a/src/container/modules/custom-nodes/CustomNodesModule.ts +++ b/src/container/modules/custom-nodes/CustomNodesModule.ts @@ -8,6 +8,7 @@ import { ICustomNodeGroup } from '../../../interfaces/custom-nodes/ICustomNodeGr import { ControlFlowCustomNode } from "../../../enums/custom-nodes/ControlFlowCustomNode"; import { CustomNode } from '../../../enums/custom-nodes/CustomNode'; import { CustomNodeGroup } from '../../../enums/custom-nodes/CustomNodeGroup'; +import { DeadCodeInjectionCustomNode } from '../../../enums/custom-nodes/DeadCodeInjectionCustomNode'; import { ConsoleOutputCustomNodeGroup } from '../../../custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup'; import { DebugProtectionCustomNodeGroup } from '../../../custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup'; @@ -17,6 +18,7 @@ import { StringArrayCustomNodeGroup } from '../../../custom-nodes/string-array-n import { BinaryExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode'; import { BlockStatementControlFlowFlatteningNode } from '../../../custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode'; +import { BlockStatementDeadCodeInjectionNode } from '../../../custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode'; import { CallExpressionControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode'; import { CallExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode'; import { ControlFlowStorageNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode'; @@ -114,6 +116,11 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule .toConstructor(StringLiteralControlFlowStorageCallNode) .whenTargetNamed(ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode); + // dead code injection custom nodes + bind>(ServiceIdentifiers.Newable__ICustomNode) + .toConstructor(BlockStatementDeadCodeInjectionNode) + .whenTargetNamed(DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode); + // node groups bind(ServiceIdentifiers.ICustomNodeGroup) .to(ConsoleOutputCustomNodeGroup) @@ -140,7 +147,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule .toFactory(InversifyContainerFacade .getFactory(ServiceIdentifiers.ICustomNode)); - // control flow storage customNode constructor factory + // control flow customNode constructor factory bind(ServiceIdentifiers.Factory__IControlFlowCustomNode) .toFactory(InversifyContainerFacade .getConstructorFactory( @@ -150,6 +157,16 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule ServiceIdentifiers.IOptions )); + // dead code injection customNode constructor factory + bind(ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode) + .toFactory(InversifyContainerFacade + .getConstructorFactory( + ServiceIdentifiers.Newable__ICustomNode, + ServiceIdentifiers.Factory__IIdentifierNamesGenerator, + ServiceIdentifiers.IRandomGenerator, + ServiceIdentifiers.IOptions + )); + // customNodeGroup factory bind(ServiceIdentifiers.Factory__ICustomNodeGroup) .toFactory(InversifyContainerFacade diff --git a/src/container/modules/node-transformers/ConvertingTransformersModule.ts b/src/container/modules/node-transformers/ConvertingTransformersModule.ts index eed77312..f625df1b 100644 --- a/src/container/modules/node-transformers/ConvertingTransformersModule.ts +++ b/src/container/modules/node-transformers/ConvertingTransformersModule.ts @@ -7,6 +7,7 @@ import { NodeTransformer } from '../../../enums/node-transformers/NodeTransforme import { MemberExpressionTransformer } from '../../../node-transformers/converting-transformers/MemberExpressionTransformer'; import { MethodDefinitionTransformer } from '../../../node-transformers/converting-transformers/MethodDefinitionTransformer'; +import { ObjectExpressionKeysTransformer } from '../../../node-transformers/converting-transformers/ObjectExpressionKeysTransformer'; import { TemplateLiteralTransformer } from '../../../node-transformers/converting-transformers/TemplateLiteralTransformer'; export const convertingTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { @@ -19,6 +20,10 @@ export const convertingTransformersModule: interfaces.ContainerModule = new Cont .to(MethodDefinitionTransformer) .whenTargetNamed(NodeTransformer.MethodDefinitionTransformer); + bind(ServiceIdentifiers.INodeTransformer) + .to(ObjectExpressionKeysTransformer) + .whenTargetNamed(NodeTransformer.ObjectExpressionKeysTransformer); + bind(ServiceIdentifiers.INodeTransformer) .to(TemplateLiteralTransformer) .whenTargetNamed(NodeTransformer.TemplateLiteralTransformer); diff --git a/src/custom-nodes/AbstractCustomNodeGroup.ts b/src/custom-nodes/AbstractCustomNodeGroup.ts index cca506ae..b4ff0589 100644 --- a/src/custom-nodes/AbstractCustomNodeGroup.ts +++ b/src/custom-nodes/AbstractCustomNodeGroup.ts @@ -2,7 +2,7 @@ import { inject, injectable } from 'inversify'; import { ServiceIdentifiers } from '../container/ServiceIdentifiers'; import { TIdentifierNamesGeneratorFactory } from '../types/container/generators/TIdentifierNamesGeneratorFactory'; -import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../types/node/TNodeWithBlockScope'; import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup'; @@ -63,10 +63,10 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {IStackTraceData[]} stackTraceData */ - public abstract appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void; + public abstract appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void; /** * @returns {ObfuscationEvent} diff --git a/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts b/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts index 4fb495ec..cfca8820 100644 --- a/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts +++ b/src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts @@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory'; -import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -55,10 +55,10 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {IStackTraceData[]} stackTraceData */ - public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void { + public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void { const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length); // consoleOutputDisableExpressionNode append @@ -73,7 +73,7 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup { // nodeCallsControllerFunctionNode append this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => { - let targetBlockScope: TNodeWithBlockStatement; + let targetBlockScope: TNodeWithBlockScope; if (stackTraceData.length) { targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1); diff --git a/src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts b/src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts new file mode 100644 index 00000000..0f094170 --- /dev/null +++ b/src/custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode.ts @@ -0,0 +1,89 @@ +import { inject, injectable, } from 'inversify'; +import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; + +import { BinaryOperator, BlockStatement } from 'estree'; + +import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory'; +import { TStatement } from '../../types/node/TStatement'; + +import { IOptions } from '../../interfaces/options/IOptions'; +import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; + +import { initializable } from '../../decorators/Initializable'; + +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { Nodes } from '../../node/Nodes'; +import { NodeUtils } from '../../node/NodeUtils'; + +@injectable() +export class BlockStatementDeadCodeInjectionNode extends AbstractCustomNode { + /** + * @type {BlockStatement} + */ + @initializable() + private blockStatementNode: BlockStatement; + + /** + * @type {BlockStatement} + */ + @initializable() + private randomBlockStatementNode: BlockStatement; + + /** + * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory + * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options + */ + constructor ( + @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator) + identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions + ) { + super(identifierNamesGeneratorFactory, randomGenerator, options); + } + + /** + * @param {BlockStatement} blockStatementNode + * @param {BlockStatement} randomBlockStatementNode + */ + public initialize ( + blockStatementNode: BlockStatement, + randomBlockStatementNode: BlockStatement + ): void { + this.blockStatementNode = blockStatementNode; + this.randomBlockStatementNode = randomBlockStatementNode; + } + + /** + * @returns {TStatement[]} + */ + protected getNodeStructure (): TStatement[] { + const random1: boolean = this.randomGenerator.getMathRandom() > 0.5; + const random2: boolean = this.randomGenerator.getMathRandom() > 0.5; + + const operator: BinaryOperator = random1 ? '===' : '!=='; + const leftString: string = this.randomGenerator.getRandomString(3); + const rightString: string = random2 ? leftString : this.randomGenerator.getRandomString(3); + + const [consequent, alternate]: [BlockStatement, BlockStatement] = random1 === random2 + ? [this.blockStatementNode, this.randomBlockStatementNode] + : [this.randomBlockStatementNode, this.blockStatementNode]; + + const structure: BlockStatement = Nodes.getBlockStatementNode([ + Nodes.getIfStatementNode( + Nodes.getBinaryExpressionNode( + operator, + Nodes.getLiteralNode(leftString), + Nodes.getLiteralNode(rightString) + ), + consequent, + alternate + ) + ]); + + NodeUtils.parentize(structure); + + return [structure]; + } +} diff --git a/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts b/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts index fb7d3d64..f523d853 100644 --- a/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts +++ b/src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts @@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory'; -import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -55,10 +55,10 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {IStackTraceData[]} stackTraceData */ - public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void { + public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void { const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length); // debugProtectionFunctionCallNode append @@ -86,7 +86,7 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup { // nodeCallsControllerFunctionNode append this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => { - let targetBlockScope: TNodeWithBlockStatement; + let targetBlockScope: TNodeWithBlockScope; if (stackTraceData.length) { targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1); diff --git a/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts b/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts index e3874138..bb7c7ec4 100644 --- a/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts +++ b/src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts @@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory'; -import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -55,10 +55,10 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {IStackTraceData[]} stackTraceData */ - public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void { + public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void { const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length); // domainLockNode append @@ -73,7 +73,7 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup { // nodeCallsControllerFunctionNode append this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => { - let targetBlockScope: TNodeWithBlockStatement; + let targetBlockScope: TNodeWithBlockScope; if (stackTraceData.length) { targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1); diff --git a/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts b/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts index 31c4dab9..981a344e 100644 --- a/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts +++ b/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts @@ -15,7 +15,7 @@ import { initializable } from '../../decorators/Initializable'; import { SingleNodeCallControllerTemplate } from '../../templates/SingleNodeCallControllerTemplate'; -import { NO_CUSTOM_NODES_PRESET } from '../../options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../options/presets/NoCustomNodes'; import { AbstractCustomNode } from '../AbstractCustomNode'; import { JavaScriptObfuscator } from '../../JavaScriptObfuscatorFacade'; @@ -75,7 +75,7 @@ export class NodeCallsControllerFunctionNode extends AbstractCustomNode { singleNodeCallControllerFunctionName: this.callsControllerFunctionName }), { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, identifierNamesGenerator: this.options.identifierNamesGenerator, seed: this.options.seed } diff --git a/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts b/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts index f11df688..d381562b 100644 --- a/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts +++ b/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts @@ -12,7 +12,7 @@ import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { initializable } from '../../decorators/Initializable'; -import { NO_CUSTOM_NODES_PRESET } from '../../options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../options/presets/NoCustomNodes'; import { SelfDefendingTemplate } from '../../templates/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate'; @@ -75,7 +75,7 @@ export class SelfDefendingUnicodeNode extends AbstractCustomNode { singleNodeCallControllerFunctionName: this.callsControllerFunctionName }), { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, identifierNamesGenerator: this.options.identifierNamesGenerator, seed: this.options.seed, unicodeEscapeSequence: true diff --git a/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts b/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts index 07290a0e..6c2c55d1 100644 --- a/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts +++ b/src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts @@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory'; -import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -55,10 +55,10 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {IStackTraceData[]} stackTraceData */ - public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void { + public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void { const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length); // selfDefendingUnicodeNode append @@ -73,7 +73,7 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup { // nodeCallsControllerFunctionNode append this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => { - let targetBlockScope: TNodeWithBlockStatement; + let targetBlockScope: TNodeWithBlockScope; if (stackTraceData.length) { targetBlockScope = NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1); diff --git a/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts b/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts index bceec77b..452ed55b 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts @@ -15,7 +15,7 @@ import { StringArrayEncoding } from '../../enums/StringArrayEncoding'; import { initializable } from '../../decorators/Initializable'; -import { NO_CUSTOM_NODES_PRESET } from '../../options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../options/presets/NoCustomNodes'; import { AtobTemplate } from '../../templates/AtobTemplate'; import { GlobalVariableNoEvalTemplate } from '../../templates/GlobalVariableNoEvalTemplate'; @@ -98,7 +98,7 @@ export class StringArrayCallsWrapper extends AbstractCustomNode { stringArrayName: this.stringArrayName }), { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, identifierNamesGenerator: this.options.identifierNamesGenerator, seed: this.options.seed } diff --git a/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts b/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts index 4bf087c1..0c32dbf4 100644 --- a/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts @@ -12,7 +12,7 @@ import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { initializable } from '../../decorators/Initializable'; -import { NO_CUSTOM_NODES_PRESET } from '../../options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../options/presets/NoCustomNodes'; import { SelfDefendingTemplate } from '../../templates/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate'; import { StringArrayRotateFunctionTemplate } from '../../templates/string-array-nodes/string-array-rotate-function-node/StringArrayRotateFunctionTemplate'; @@ -105,7 +105,7 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode { whileFunctionName }), { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, identifierNamesGenerator: this.options.identifierNamesGenerator, seed: this.options.seed } diff --git a/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts b/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts index 8ecf900d..8c7237c2 100644 --- a/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts +++ b/src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts @@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers'; import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory'; import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory'; -import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../../types/node/TNodeWithBlockScope'; import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; import { IOptions } from '../../../interfaces/options/IOptions'; @@ -65,10 +65,10 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {IStackTraceData[]} stackTraceData */ - public appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void { + public appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void { if (!this.stringArrayStorage.getLength()) { return; } diff --git a/src/enums/analyzers/stack-trace-analyzer/CalleeDataExtractor.ts b/src/enums/analyzers/stack-trace-analyzer/CalleeDataExtractor.ts index b8ba708f..2652e419 100644 --- a/src/enums/analyzers/stack-trace-analyzer/CalleeDataExtractor.ts +++ b/src/enums/analyzers/stack-trace-analyzer/CalleeDataExtractor.ts @@ -1,5 +1,5 @@ export enum CalleeDataExtractor { - FunctionDeclarationCalleeDataExtractor, - FunctionExpressionCalleeDataExtractor, - ObjectExpressionCalleeDataExtractor, + FunctionDeclarationCalleeDataExtractor = 'FunctionDeclarationCalleeDataExtractor', + FunctionExpressionCalleeDataExtractor = 'FunctionExpressionCalleeDataExtractor', + ObjectExpressionCalleeDataExtractor = 'ObjectExpressionCalleeDataExtractor', } diff --git a/src/enums/custom-nodes/ControlFlowCustomNode.ts b/src/enums/custom-nodes/ControlFlowCustomNode.ts index b2918756..ae4310b9 100644 --- a/src/enums/custom-nodes/ControlFlowCustomNode.ts +++ b/src/enums/custom-nodes/ControlFlowCustomNode.ts @@ -1,11 +1,11 @@ export enum ControlFlowCustomNode { - BinaryExpressionFunctionNode, - BlockStatementControlFlowFlatteningNode, - CallExpressionControlFlowStorageCallNode, - CallExpressionFunctionNode, - ControlFlowStorageNode, - ExpressionWithOperatorControlFlowStorageCallNode, - LogicalExpressionFunctionNode, - StringLiteralControlFlowStorageCallNode, - StringLiteralNode, + BinaryExpressionFunctionNode = 'BinaryExpressionFunctionNode', + BlockStatementControlFlowFlatteningNode = 'BlockStatementControlFlowFlatteningNode', + CallExpressionControlFlowStorageCallNode = 'CallExpressionControlFlowStorageCallNode', + CallExpressionFunctionNode = 'CallExpressionFunctionNode', + ControlFlowStorageNode = 'ControlFlowStorageNode', + ExpressionWithOperatorControlFlowStorageCallNode = 'ExpressionWithOperatorControlFlowStorageCallNode', + LogicalExpressionFunctionNode = 'LogicalExpressionFunctionNode', + StringLiteralControlFlowStorageCallNode = 'StringLiteralControlFlowStorageCallNode', + StringLiteralNode = 'StringLiteralNode' } diff --git a/src/enums/custom-nodes/CustomNode.ts b/src/enums/custom-nodes/CustomNode.ts index 340cd8f1..f79c3a76 100644 --- a/src/enums/custom-nodes/CustomNode.ts +++ b/src/enums/custom-nodes/CustomNode.ts @@ -1,12 +1,12 @@ export enum CustomNode { - ConsoleOutputDisableExpressionNode, - DebugProtectionFunctionCallNode, - DebugProtectionFunctionIntervalNode, - DebugProtectionFunctionNode, - DomainLockNode, - NodeCallsControllerFunctionNode, - SelfDefendingUnicodeNode, - StringArrayCallsWrapper, - StringArrayNode, - StringArrayRotateFunctionNode + ConsoleOutputDisableExpressionNode = 'ConsoleOutputDisableExpressionNode', + DebugProtectionFunctionCallNode = 'DebugProtectionFunctionCallNode', + DebugProtectionFunctionIntervalNode = 'DebugProtectionFunctionIntervalNode', + DebugProtectionFunctionNode = 'DebugProtectionFunctionNode', + DomainLockNode = 'DomainLockNode', + NodeCallsControllerFunctionNode = 'NodeCallsControllerFunctionNode', + SelfDefendingUnicodeNode = 'SelfDefendingUnicodeNode', + StringArrayCallsWrapper = 'StringArrayCallsWrapper', + StringArrayNode = 'StringArrayNode', + StringArrayRotateFunctionNode = 'StringArrayRotateFunctionNode' } diff --git a/src/enums/custom-nodes/CustomNodeGroup.ts b/src/enums/custom-nodes/CustomNodeGroup.ts index e1368d61..a3f0d9bf 100644 --- a/src/enums/custom-nodes/CustomNodeGroup.ts +++ b/src/enums/custom-nodes/CustomNodeGroup.ts @@ -1,7 +1,7 @@ export enum CustomNodeGroup { - ConsoleOutputCustomNodeGroup, - DebugProtectionCustomNodeGroup, - DomainLockCustomNodeGroup, - SelfDefendingCustomNodeGroup, - StringArrayCustomNodeGroup + ConsoleOutputCustomNodeGroup = 'ConsoleOutputCustomNodeGroup', + DebugProtectionCustomNodeGroup = 'DebugProtectionCustomNodeGroup', + DomainLockCustomNodeGroup = 'DomainLockCustomNodeGroup', + SelfDefendingCustomNodeGroup = 'SelfDefendingCustomNodeGroup', + StringArrayCustomNodeGroup = 'StringArrayCustomNodeGroup' } diff --git a/src/enums/custom-nodes/DeadCodeInjectionCustomNode.ts b/src/enums/custom-nodes/DeadCodeInjectionCustomNode.ts new file mode 100644 index 00000000..dea3aacd --- /dev/null +++ b/src/enums/custom-nodes/DeadCodeInjectionCustomNode.ts @@ -0,0 +1,3 @@ +export enum DeadCodeInjectionCustomNode { + BlockStatementDeadCodeInjectionNode = 'BlockStatementDeadCodeInjectionNode' +} diff --git a/src/enums/logger/LoggingMessage.ts b/src/enums/logger/LoggingMessage.ts index bd793657..9b397fa3 100644 --- a/src/enums/logger/LoggingMessage.ts +++ b/src/enums/logger/LoggingMessage.ts @@ -7,6 +7,7 @@ export enum LoggingMessage { StageAnalyzingASTTree = 'Stage: analyzing AST-tree...', StageControlFlowFlattening = 'Stage: control flow flattening...', StageDeadCodeInjection = 'Stage: dead code injection...', + StagePreObfuscation = 'Stage: pre-obfuscation...', StageObfuscation = 'Stage: obfuscation...', Version = 'Version: %s' } diff --git a/src/enums/node-transformers/NodeTransformer.ts b/src/enums/node-transformers/NodeTransformer.ts index 3d783412..1102c84c 100644 --- a/src/enums/node-transformers/NodeTransformer.ts +++ b/src/enums/node-transformers/NodeTransformer.ts @@ -1,19 +1,20 @@ export enum NodeTransformer { - BlockStatementControlFlowTransformer, - ClassDeclarationTransformer, - CommentsTransformer, - DeadCodeInjectionTransformer, - FunctionControlFlowTransformer, - CatchClauseTransformer, - FunctionDeclarationTransformer, - FunctionTransformer, - LabeledStatementTransformer, - LiteralTransformer, - MemberExpressionTransformer, - MethodDefinitionTransformer, - ObfuscatingGuardsTransformer, - ObjectExpressionTransformer, - ParentificationTransformer, - TemplateLiteralTransformer, - VariableDeclarationTransformer + BlockStatementControlFlowTransformer = 'BlockStatementControlFlowTransformer', + ClassDeclarationTransformer = 'ClassDeclarationTransformer', + CommentsTransformer = 'CommentsTransformer', + DeadCodeInjectionTransformer = 'DeadCodeInjectionTransformer', + FunctionControlFlowTransformer = 'FunctionControlFlowTransformer', + CatchClauseTransformer = 'CatchClauseTransformer', + FunctionDeclarationTransformer = 'FunctionDeclarationTransformer', + FunctionTransformer = 'FunctionTransformer', + LabeledStatementTransformer = 'LabeledStatementTransformer', + LiteralTransformer = 'LiteralTransformer', + MemberExpressionTransformer = 'MemberExpressionTransformer', + MethodDefinitionTransformer = 'MethodDefinitionTransformer', + ObfuscatingGuardsTransformer = 'ObfuscatingGuardsTransformer', + ObjectExpressionKeysTransformer = 'ObjectExpressionKeysTransformer', + ObjectExpressionTransformer = 'ObjectExpressionTransformer', + ParentificationTransformer = 'ParentificationTransformer', + TemplateLiteralTransformer = 'TemplateLiteralTransformer', + VariableDeclarationTransformer = 'VariableDeclarationTransformer' } diff --git a/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/ControlFlowReplacer.ts b/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/ControlFlowReplacer.ts index 513d53f2..079ec1d2 100644 --- a/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/ControlFlowReplacer.ts +++ b/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/ControlFlowReplacer.ts @@ -1,6 +1,6 @@ export enum ControlFlowReplacer { - BinaryExpressionControlFlowReplacer, - CallExpressionControlFlowReplacer, - LogicalExpressionControlFlowReplacer, - StringLiteralControlFlowReplacer, + BinaryExpressionControlFlowReplacer = 'BinaryExpressionControlFlowReplacer', + CallExpressionControlFlowReplacer = 'CallExpressionControlFlowReplacer', + LogicalExpressionControlFlowReplacer = 'LogicalExpressionControlFlowReplacer', + StringLiteralControlFlowReplacer = 'StringLiteralControlFlowReplacer' } diff --git a/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/IdentifierObfuscatingReplacer.ts b/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/IdentifierObfuscatingReplacer.ts index 0bca9ce1..b37453fb 100644 --- a/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/IdentifierObfuscatingReplacer.ts +++ b/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/IdentifierObfuscatingReplacer.ts @@ -1,3 +1,3 @@ export enum IdentifierObfuscatingReplacer { - BaseIdentifierObfuscatingReplacer + BaseIdentifierObfuscatingReplacer = 'BaseIdentifierObfuscatingReplacer' } diff --git a/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/LiteralObfuscatingReplacer.ts b/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/LiteralObfuscatingReplacer.ts index 52f4f4d4..61c9a83f 100644 --- a/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/LiteralObfuscatingReplacer.ts +++ b/src/enums/node-transformers/obfuscating-transformers/obfuscating-replacers/LiteralObfuscatingReplacer.ts @@ -1,5 +1,5 @@ export enum LiteralObfuscatingReplacer { - BooleanLiteralObfuscatingReplacer, - NumberLiteralObfuscatingReplacer, - StringLiteralObfuscatingReplacer + BooleanLiteralObfuscatingReplacer = 'BooleanLiteralObfuscatingReplacer', + NumberLiteralObfuscatingReplacer = 'NumberLiteralObfuscatingReplacer', + StringLiteralObfuscatingReplacer = 'StringLiteralObfuscatingReplacer' } diff --git a/src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.ts b/src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.ts index ecbbe697..0f131254 100644 --- a/src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.ts +++ b/src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.ts @@ -1,4 +1,4 @@ export enum ObfuscatingGuard { - BlackListNodeGuard, - ConditionalCommentNodeGuard + BlackListNodeGuard = 'BlackListNodeGuard', + ConditionalCommentNodeGuard = 'ConditionalCommentNodeGuard' } diff --git a/src/enums/node/NodeType.ts b/src/enums/node/NodeType.ts index fb40f9f9..792879fa 100644 --- a/src/enums/node/NodeType.ts +++ b/src/enums/node/NodeType.ts @@ -1,5 +1,6 @@ export enum NodeType { ArrayExpression = 'ArrayExpression', + ArrayPattern = 'ArrayPattern', ArrowFunctionExpression = 'ArrowFunctionExpression', AssignmentExpression = 'AssignmentExpression', AssignmentPattern = 'AssignmentPattern', @@ -25,6 +26,7 @@ export enum NodeType { ObjectPattern = 'ObjectPattern', Program = 'Program', Property = 'Property', + RestElement = 'RestElement', ReturnStatement = 'ReturnStatement', Super = 'Super', SwitchCase = 'SwitchCase', diff --git a/src/interfaces/custom-nodes/ICustomNodeGroup.d.ts b/src/interfaces/custom-nodes/ICustomNodeGroup.d.ts index 836a4d0a..cf9b2b1d 100644 --- a/src/interfaces/custom-nodes/ICustomNodeGroup.d.ts +++ b/src/interfaces/custom-nodes/ICustomNodeGroup.d.ts @@ -1,4 +1,4 @@ -import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope'; import { ICustomNode } from './ICustomNode'; import { IInitializable } from '../IInitializable'; @@ -12,7 +12,7 @@ export interface ICustomNodeGroup extends IInitializable { * @param blockScopeNode * @param stackTraceData */ - appendCustomNodes (blockScopeNode: TNodeWithBlockStatement, stackTraceData: IStackTraceData[]): void; + appendCustomNodes (blockScopeNode: TNodeWithBlockScope, stackTraceData: IStackTraceData[]): void; /** * @returns {ObfuscationEvent} diff --git a/src/interfaces/options/IOptions.d.ts b/src/interfaces/options/IOptions.d.ts index b2cc2635..5e176e20 100644 --- a/src/interfaces/options/IOptions.d.ts +++ b/src/interfaces/options/IOptions.d.ts @@ -29,5 +29,6 @@ export interface IOptions { readonly stringArrayEncoding: TStringArrayEncoding; readonly stringArrayThreshold: number; readonly target: ObfuscationTarget; + readonly transformObjectKeys: boolean; readonly unicodeEscapeSequence: boolean; } diff --git a/src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts b/src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts index 6b4c9a33..b04883e5 100644 --- a/src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts +++ b/src/node-transformers/control-flow-transformers/BlockStatementControlFlowTransformer.ts @@ -5,6 +5,7 @@ import * as estraverse from 'estraverse'; import * as ESTree from 'estree'; import { TControlFlowCustomNodeFactory } from '../../types/container/custom-nodes/TControlFlowCustomNodeFactory'; +import { TStatement } from '../../types/node/TStatement'; import { IArrayUtils } from '../../interfaces/utils/IArrayUtils'; import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode'; @@ -16,6 +17,7 @@ import { ControlFlowCustomNode } from '../../enums/custom-nodes/ControlFlowCusto import { AbstractNodeTransformer } from '../AbstractNodeTransformer'; import { NodeGuards } from '../../node/NodeGuards'; +import { NodeUtils } from '../../node/NodeUtils'; @injectable() export class BlockStatementControlFlowTransformer extends AbstractNodeTransformer { @@ -134,6 +136,10 @@ export class BlockStatementControlFlowTransformer extends AbstractNodeTransforme originalKeysIndexesInShuffledArray ); - return blockStatementControlFlowFlatteningCustomNode.getNode()[0]; + const newBlockStatementNode: TStatement = blockStatementControlFlowFlatteningCustomNode.getNode()[0]; + + NodeUtils.parentizeNode(newBlockStatementNode, parentNode); + + return newBlockStatementNode; } } diff --git a/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts b/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts index 098b4ffd..377cf566 100644 --- a/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts +++ b/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.ts @@ -7,7 +7,7 @@ import * as ESTree from 'estree'; import { TControlFlowCustomNodeFactory } from '../../types/container/custom-nodes/TControlFlowCustomNodeFactory'; import { TControlFlowReplacerFactory } from '../../types/container/node-transformers/TControlFlowReplacerFactory'; import { TControlFlowStorageFactory } from '../../types/container/node-transformers/TControlFlowStorageFactory'; -import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope'; import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -57,9 +57,9 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer { private readonly visitedFunctionNodes: Set = new Set(); /** - * @type {Set} + * @type {Set} */ - private readonly hostNodesWithControlFlowNode: Set = new Set(); + private readonly hostNodesWithControlFlowNode: Set = new Set(); /** * @type {TControlFlowReplacerFactory} @@ -131,7 +131,7 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer { return functionNode; } - const hostNode: TNodeWithBlockStatement = this.getHostNode(functionNode.body); + const hostNode: TNodeWithBlockScope = this.getHostNode(functionNode.body); const controlFlowStorage: IStorage = this.getControlFlowStorage(hostNode); this.controlFlowData.set(hostNode, controlFlowStorage); @@ -153,10 +153,10 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer { } /** - * @param {TNodeWithBlockStatement} hostNode + * @param {TNodeWithBlockScope} hostNode * @returns {IStorage} */ - private getControlFlowStorage (hostNode: TNodeWithBlockStatement): IStorage { + private getControlFlowStorage (hostNode: TNodeWithBlockScope): IStorage { const controlFlowStorage: IStorage = this.controlFlowStorageFactory(); if (this.controlFlowData.has(hostNode)) { @@ -174,10 +174,10 @@ export class FunctionControlFlowTransformer extends AbstractNodeTransformer { /** * @param {BlockStatement} functionNodeBody - * @returns {TNodeWithBlockStatement} + * @returns {TNodeWithBlockScope} */ - private getHostNode (functionNodeBody: ESTree.BlockStatement): TNodeWithBlockStatement { - const blockScopesOfNode: TNodeWithBlockStatement[] = NodeUtils.getBlockScopesOfNode(functionNodeBody); + private getHostNode (functionNodeBody: ESTree.BlockStatement): TNodeWithBlockScope { + const blockScopesOfNode: TNodeWithBlockScope[] = NodeUtils.getBlockScopesOfNode(functionNodeBody); if (blockScopesOfNode.length === 1) { return functionNodeBody; diff --git a/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts b/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts new file mode 100644 index 00000000..1aefb075 --- /dev/null +++ b/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.ts @@ -0,0 +1,235 @@ +import { inject, injectable } from 'inversify'; +import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; + +import * as ESTree from 'estree'; + +import { TNodeWithScope } from '../../types/node/TNodeWithScope'; + +import { IOptions } from '../../interfaces/options/IOptions'; +import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; +import { IVisitor } from '../../interfaces/node-transformers/IVisitor'; + +import { AbstractNodeTransformer } from '../AbstractNodeTransformer'; +import { NodeAppender } from '../../node/NodeAppender'; +import { NodeGuards } from '../../node/NodeGuards'; +import { Nodes } from '../../node/Nodes'; +import { NodeUtils } from '../../node/NodeUtils'; + +@injectable() +export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer { + /** + * @type {Map} + */ + private cachedScopeNodesMap: Map = new Map(); + + /** + * @param {IRandomGenerator} randomGenerator + * @param {IOptions} options + */ + constructor ( + @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, + @inject(ServiceIdentifiers.IOptions) options: IOptions + ) { + super(randomGenerator, options); + } + + /** + * @param {BlockStatement} scopeNode + * @param {ExpressionStatement[]} expressionStatements + * @param {Node} variableDeclarator + */ + private static appendExpressionStatements ( + scopeNode: ESTree.BlockStatement, + expressionStatements: ESTree.ExpressionStatement[], + variableDeclarator: ESTree.Node + ): void { + const variableDeclaration: ESTree.Node | undefined = variableDeclarator.parentNode; + + if ( + !variableDeclaration + || !NodeGuards.isVariableDeclarationNode(variableDeclaration) + ) { + throw new Error('Cannot find variable declaration for variable declarator'); + } + + const indexInBlockStatement: number = scopeNode.body.indexOf(variableDeclaration); + + NodeAppender.insertNodeAtIndex(scopeNode, expressionStatements, indexInBlockStatement + 1); + } + + /** + * @param {Property[]} properties + * @param {number[]} removablePropertyIds + * @returns {Property[]} + */ + private static filterObjectExpressionProperties (properties: ESTree.Property[], removablePropertyIds: number[]): ESTree.Property[] { + return properties.filter((property: ESTree.Property, index: number) => !removablePropertyIds.includes(index)); + } + + /** + * @return {IVisitor} + */ + public getVisitor (): IVisitor { + return { + enter: (node: ESTree.Node, parentNode: ESTree.Node | null) => { + if ( + this.options.transformObjectKeys + && parentNode + && NodeGuards.isObjectExpressionNode(node) + && NodeGuards.isVariableDeclaratorNode(parentNode) + ) { + return this.transformNode(node, parentNode); + } + } + }; + } + + /** + * replaces: + * var object = { + * foo: 1, + * bar: 2 + * }; + * + * on: + * var object = {}; + * object['foo'] = 1; + * object['bar'] = 2; + * + * @param {MemberExpression} objectExpressionNode + * @param {NodeGuards} variableDeclarator + * @returns {NodeGuards} + */ + public transformNode (objectExpressionNode: ESTree.ObjectExpression, variableDeclarator: ESTree.VariableDeclarator): ESTree.Node { + // should pass only Expression nodes as MemberExpression.object value + if (!NodeGuards.isIdentifierNode(variableDeclarator.id)) { + return objectExpressionNode; + } + + const scopeNode: TNodeWithScope | null = NodeUtils.getScopeOfNode(variableDeclarator); + + if (!scopeNode || !NodeGuards.isBlockStatementNode(scopeNode)) { + return objectExpressionNode; + } + + this.cachedScopeNodesMap.set(variableDeclarator, scopeNode); + + return this.transformObjectExpressionNode( + objectExpressionNode, + variableDeclarator.id, + variableDeclarator + ); + } + + /** + * @param {Property[]} properties + * @param {Expression} memberExpressionObject + * @param {VariableDeclarator} variableDeclarator + * @returns {[ExpressionStatement[] , number[]]} + */ + private extractPropertiesToExpressionStatements ( + properties: ESTree.Property[], + memberExpressionObject: ESTree.Expression, + variableDeclarator: ESTree.VariableDeclarator + ): [ESTree.ExpressionStatement[], number[]] { + const propertiesLength: number = properties.length; + const expressionStatements: ESTree.ExpressionStatement[] = []; + const removablePropertyIds: number[] = []; + + for (let i: number = 0; i < propertiesLength; i++) { + const property: ESTree.Property = properties[i]; + const propertyKey: ESTree.Expression = property.key; + + // invalid property nodes + if ( + NodeGuards.isObjectPatternNode(property.value) + || NodeGuards.isArrayPatternNode(property.value) + || NodeGuards.isAssignmentPatternNode(property.value) + || NodeGuards.isRestElementNode(property.value) + ) { + continue; + } + + /** + * Stage 1: collecting property node key names + */ + let propertyKeyName: string; + + if (NodeGuards.isLiteralNode(propertyKey) && typeof propertyKey.value === 'string') { + propertyKeyName = propertyKey.value; + } else if (NodeGuards.isIdentifierNode(propertyKey)) { + propertyKeyName = propertyKey.name; + } else { + continue; + } + + /** + * Stage 2: creating new expression statement node with member expression based on removed property + */ + const shouldCreateLiteralNode: boolean = !property.computed + || (property.computed && NodeGuards.isLiteralNode(property.key)); + const memberExpressionProperty: ESTree.Expression = shouldCreateLiteralNode + ? Nodes.getLiteralNode(propertyKeyName) + : Nodes.getIdentifierNode(propertyKeyName); + const memberExpressionNode: ESTree.MemberExpression = Nodes + .getMemberExpressionNode(memberExpressionObject, memberExpressionProperty, true); + const rightExpression: ESTree.Expression = property.value; + const expressionStatementNode: ESTree.ExpressionStatement = Nodes.getExpressionStatementNode( + Nodes.getAssignmentExpressionNode('=', memberExpressionNode, rightExpression) + ); + + /** + * Stage 3: recursively processing nested object expressions + */ + if (NodeGuards.isObjectExpressionNode(property.value)) { + this.transformObjectExpressionNode( + property.value, + memberExpressionNode, + variableDeclarator + ); + } + + /** + * Stage 4: filling arrays + */ + expressionStatements.push(expressionStatementNode); + removablePropertyIds.push(i); + } + + return [expressionStatements, removablePropertyIds]; + } + + /** + * @param {ObjectExpression} objectExpressionNode + * @param {Expression} memberExpressionObjectNode + * @param {VariableDeclarator} variableDeclarator + * @returns {Node} + */ + private transformObjectExpressionNode ( + objectExpressionNode: ESTree.ObjectExpression, + memberExpressionObjectNode: ESTree.Expression, + variableDeclarator: ESTree.VariableDeclarator + ): ESTree.Node { + const properties: ESTree.Property[] = objectExpressionNode.properties; + + if (!properties.length) { + return objectExpressionNode; + } + + const scopeNode: ESTree.BlockStatement | undefined = this.cachedScopeNodesMap.get(variableDeclarator); + + if (!scopeNode) { + return objectExpressionNode; + } + + const [expressionStatements, removablePropertyIds]: [ESTree.ExpressionStatement[], number[]] = this + .extractPropertiesToExpressionStatements(properties, memberExpressionObjectNode, variableDeclarator); + + objectExpressionNode.properties = ObjectExpressionKeysTransformer + .filterObjectExpressionProperties(properties, removablePropertyIds); + ObjectExpressionKeysTransformer + .appendExpressionStatements(scopeNode, expressionStatements, variableDeclarator); + + return objectExpressionNode; + } +} diff --git a/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts b/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts index 5daa5391..1a672b5e 100644 --- a/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts +++ b/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts @@ -4,19 +4,21 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers'; import * as estraverse from 'estraverse'; import * as ESTree from 'estree'; -import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement'; +import { TDeadNodeInjectionCustomNodeFactory } from '../../types/container/custom-nodes/TDeadNodeInjectionCustomNodeFactory'; +import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope'; +import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode'; import { IOptions } from '../../interfaces/options/IOptions'; import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator'; import { ITransformersRunner } from '../../interfaces/node-transformers/ITransformersRunner'; import { IVisitor } from '../../interfaces/node-transformers/IVisitor'; +import { DeadCodeInjectionCustomNode } from '../../enums/custom-nodes/DeadCodeInjectionCustomNode'; import { NodeTransformer } from '../../enums/node-transformers/NodeTransformer'; import { NodeType } from '../../enums/node/NodeType'; import { AbstractNodeTransformer } from '../AbstractNodeTransformer'; import { NodeGuards } from '../../node/NodeGuards'; -import { Nodes } from '../../node/Nodes'; import { NodeUtils } from '../../node/NodeUtils'; @injectable() @@ -53,23 +55,32 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer { */ private collectedBlockStatementsLength: number; + /** + * @type {TDeadNodeInjectionCustomNodeFactory} + */ + private readonly deadCodeInjectionCustomNodeFactory: TDeadNodeInjectionCustomNodeFactory; + /** * @type {ITransformersRunner} */ private readonly transformersRunner: ITransformersRunner; /** + * @param {TControlFlowCustomNodeFactory} deadCodeInjectionCustomNodeFactory * @param {ITransformersRunner} transformersRunner * @param {IRandomGenerator} randomGenerator * @param {IOptions} options */ constructor ( + @inject(ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode) + deadCodeInjectionCustomNodeFactory: TDeadNodeInjectionCustomNodeFactory, @inject(ServiceIdentifiers.ITransformersRunner) transformersRunner: ITransformersRunner, @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator, @inject(ServiceIdentifiers.IOptions) options: IOptions ) { super(randomGenerator, options); + this.deadCodeInjectionCustomNodeFactory = deadCodeInjectionCustomNodeFactory; this.transformersRunner = transformersRunner; } @@ -112,7 +123,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer { estraverse.traverse(programNode, { enter: (node: ESTree.Node): any => { if (NodeGuards.isBlockStatementNode(node)) { - this.collectBlockStatementNodes(node, this.collectedBlockStatements); + this.collectBlockStatementNodes(node, this.collectedBlockStatements, parentNode); } } }); @@ -138,7 +149,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer { return blockStatementNode; } - const blockScopeOfBlockStatementNode: TNodeWithBlockStatement = NodeUtils + const blockScopeOfBlockStatementNode: TNodeWithBlockScope = NodeUtils .getBlockScopesOfNode(blockStatementNode)[0]; if (blockScopeOfBlockStatementNode.type === NodeType.Program) { @@ -154,23 +165,25 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer { return blockStatementNode; } - return this.replaceBlockStatementNode(blockStatementNode, randomBlockStatementNode); + return this.replaceBlockStatementNode(blockStatementNode, randomBlockStatementNode, parentNode); } /** * @param {BlockStatement} blockStatementNode * @param {BlockStatement[]} collectedBlockStatements + * @param {Node} parentNode */ private collectBlockStatementNodes ( blockStatementNode: ESTree.BlockStatement, - collectedBlockStatements: ESTree.BlockStatement[] + collectedBlockStatements: ESTree.BlockStatement[], + parentNode: ESTree.Node ): void { let clonedBlockStatementNode: ESTree.BlockStatement = NodeUtils.clone(blockStatementNode), nestedBlockStatementsCount: number = 0, isValidBlockStatementNode: boolean = true; estraverse.replace(clonedBlockStatementNode, { - enter: (node: ESTree.Node, parentNode: ESTree.Node | null): any => { + enter: (node: ESTree.Node): any => { /** * Count nested block statements in current block statement */ @@ -202,6 +215,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer { /** * We should transform identifiers in the dead code block statement to avoid conflicts with original code */ + NodeUtils.parentizeNode(clonedBlockStatementNode, parentNode); clonedBlockStatementNode = this.transformersRunner.transform( clonedBlockStatementNode, DeadCodeInjectionTransformer.transformersToRenameBlockScopeIdentifiers @@ -213,36 +227,26 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer { /** * @param {BlockStatement} blockStatementNode * @param {BlockStatement} randomBlockStatementNode + * @param {Node} parentNode * @returns {BlockStatement} */ private replaceBlockStatementNode ( blockStatementNode: ESTree.BlockStatement, - randomBlockStatementNode: ESTree.BlockStatement + randomBlockStatementNode: ESTree.BlockStatement, + parentNode: ESTree.Node ): ESTree.BlockStatement { - const random1: boolean = this.randomGenerator.getMathRandom() > 0.5; - const random2: boolean = this.randomGenerator.getMathRandom() > 0.5; + const blockStatementDeadCodeInjectionCustomNode: ICustomNode = this.deadCodeInjectionCustomNodeFactory( + DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode + ); - const operator: ESTree.BinaryOperator = random1 ? '===' : '!=='; - const leftString: string = this.randomGenerator.getRandomString(3); - const rightString: string = random2 ? leftString : this.randomGenerator.getRandomString(3); + blockStatementDeadCodeInjectionCustomNode.initialize( + blockStatementNode, + randomBlockStatementNode + ); - const [consequent, alternate]: [ESTree.BlockStatement, ESTree.BlockStatement] = random1 === random2 - ? [blockStatementNode, randomBlockStatementNode] - : [randomBlockStatementNode, blockStatementNode]; + const newBlockStatementNode: ESTree.BlockStatement = blockStatementDeadCodeInjectionCustomNode.getNode()[0]; - let newBlockStatementNode: ESTree.BlockStatement = Nodes.getBlockStatementNode([ - Nodes.getIfStatementNode( - Nodes.getBinaryExpressionNode( - operator, - Nodes.getLiteralNode(leftString), - Nodes.getLiteralNode(rightString) - ), - consequent, - alternate - ) - ]); - - newBlockStatementNode = NodeUtils.parentize(newBlockStatementNode); + NodeUtils.parentizeNode(newBlockStatementNode, parentNode); return newBlockStatementNode; } diff --git a/src/node-transformers/obfuscating-transformers/ClassDeclarationTransformer.ts b/src/node-transformers/obfuscating-transformers/ClassDeclarationTransformer.ts index 1be4ce2d..3930eb0f 100644 --- a/src/node-transformers/obfuscating-transformers/ClassDeclarationTransformer.ts +++ b/src/node-transformers/obfuscating-transformers/ClassDeclarationTransformer.ts @@ -5,7 +5,7 @@ import * as estraverse from 'estraverse'; import * as ESTree from 'estree'; import { TIdentifierObfuscatingReplacerFactory } from "../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory"; -import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope'; import { IIdentifierObfuscatingReplacer } from '../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer'; import { IOptions } from '../../interfaces/options/IOptions'; @@ -78,7 +78,7 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer { */ public transformNode (classDeclarationNode: ESTree.ClassDeclaration, parentNode: ESTree.Node): ESTree.Node { const nodeIdentifier: number = this.nodeIdentifier++; - const blockScopeNode: TNodeWithBlockStatement = NodeUtils + const blockScopeNode: TNodeWithBlockScope = NodeUtils .getBlockScopesOfNode(classDeclarationNode)[0]; if (!this.options.renameGlobals && blockScopeNode.type === NodeType.Program) { @@ -106,10 +106,10 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {number} nodeIdentifier */ - private replaceScopeCachedIdentifiers (blockScopeNode: TNodeWithBlockStatement, nodeIdentifier: number): void { + private replaceScopeCachedIdentifiers (blockScopeNode: TNodeWithBlockScope, nodeIdentifier: number): void { const cachedReplaceableIdentifiers: ESTree.Identifier[] = this.replaceableIdentifiers.get(blockScopeNode); cachedReplaceableIdentifiers.forEach((replaceableIdentifier: ESTree.Identifier) => { @@ -121,10 +121,10 @@ export class ClassDeclarationTransformer extends AbstractNodeTransformer { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {number} nodeIdentifier */ - private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockStatement, nodeIdentifier: number): void { + private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockScope, nodeIdentifier: number): void { const storedReplaceableIdentifiers: ESTree.Identifier[] = []; estraverse.replace(blockScopeNode, { diff --git a/src/node-transformers/obfuscating-transformers/FunctionDeclarationTransformer.ts b/src/node-transformers/obfuscating-transformers/FunctionDeclarationTransformer.ts index d923bd4c..bfc52b42 100644 --- a/src/node-transformers/obfuscating-transformers/FunctionDeclarationTransformer.ts +++ b/src/node-transformers/obfuscating-transformers/FunctionDeclarationTransformer.ts @@ -5,7 +5,7 @@ import * as estraverse from 'estraverse'; import * as ESTree from 'estree'; import { TIdentifierObfuscatingReplacerFactory } from "../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory"; -import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope'; import { TReplaceableIdentifiers } from '../../types/node-transformers/TReplaceableIdentifiers'; import { TReplaceableIdentifiersNames } from '../../types/node-transformers/TReplaceableIdentifiersNames'; @@ -80,7 +80,7 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer { */ public transformNode (functionDeclarationNode: ESTree.FunctionDeclaration, parentNode: ESTree.Node): ESTree.Node { const nodeIdentifier: number = this.nodeIdentifier++; - const blockScopeNode: TNodeWithBlockStatement = NodeUtils + const blockScopeNode: TNodeWithBlockScope = NodeUtils .getBlockScopesOfNode(functionDeclarationNode)[0]; if (!this.options.renameGlobals && blockScopeNode.type === NodeType.Program) { @@ -109,12 +109,12 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer { /** * @param {FunctionDeclaration} functionDeclarationNode - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {number} nodeIdentifier */ private replaceScopeCachedIdentifiers ( functionDeclarationNode: ESTree.FunctionDeclaration, - blockScopeNode: TNodeWithBlockStatement, + blockScopeNode: TNodeWithBlockScope, nodeIdentifier: number ): void { const cachedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames | undefined = this.replaceableIdentifiers.get(blockScopeNode); @@ -142,10 +142,10 @@ export class FunctionDeclarationTransformer extends AbstractNodeTransformer { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {number} nodeIdentifier */ - private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockStatement, nodeIdentifier: number): void { + private replaceScopeIdentifiers (blockScopeNode: TNodeWithBlockScope, nodeIdentifier: number): void { const storedReplaceableIdentifiersNamesMap: TReplaceableIdentifiersNames = new Map(); estraverse.replace(blockScopeNode, { diff --git a/src/node-transformers/obfuscating-transformers/VariableDeclarationTransformer.ts b/src/node-transformers/obfuscating-transformers/VariableDeclarationTransformer.ts index 134fa9b2..7af3d3d1 100644 --- a/src/node-transformers/obfuscating-transformers/VariableDeclarationTransformer.ts +++ b/src/node-transformers/obfuscating-transformers/VariableDeclarationTransformer.ts @@ -5,7 +5,7 @@ import * as estraverse from 'estraverse'; import * as ESTree from 'estree'; import { TIdentifierObfuscatingReplacerFactory } from '../../types/container/node-transformers/TIdentifierObfuscatingReplacerFactory'; -import { TNodeWithBlockStatement } from '../../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../types/node/TNodeWithBlockScope'; import { TReplaceableIdentifiers } from '../../types/node-transformers/TReplaceableIdentifiers'; import { TReplaceableIdentifiersNames } from '../../types/node-transformers/TReplaceableIdentifiersNames'; @@ -80,7 +80,7 @@ export class VariableDeclarationTransformer extends AbstractNodeTransformer { * @returns {NodeGuards} */ public transformNode (variableDeclarationNode: ESTree.VariableDeclaration, parentNode: ESTree.Node): ESTree.Node { - const blockScopeNode: TNodeWithBlockStatement = NodeUtils + const blockScopeNode: TNodeWithBlockScope = NodeUtils .getBlockScopesOfNode(variableDeclarationNode)[0]; if (!this.options.renameGlobals && blockScopeNode.type === NodeType.Program) { diff --git a/src/node/NodeAppender.ts b/src/node/NodeAppender.ts index 8af0edaf..6a681230 100644 --- a/src/node/NodeAppender.ts +++ b/src/node/NodeAppender.ts @@ -1,6 +1,6 @@ import * as ESTree from 'estree'; -import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../types/node/TNodeWithBlockScope'; import { TStatement } from '../types/node/TStatement'; import { IStackTraceData } from '../interfaces/analyzers/stack-trace-analyzer/IStackTraceData'; @@ -24,38 +24,38 @@ import { IStackTraceData } from '../interfaces/analyzers/stack-trace-analyzer/IS */ export class NodeAppender { /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} scopeNode * @param {TStatement[]} nodeBodyStatements */ public static appendNode ( - blockScopeNode: TNodeWithBlockStatement, + scopeNode: TNodeWithBlockScope, nodeBodyStatements: TStatement[] ): void { if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { nodeBodyStatements = []; } - nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(scopeNode, nodeBodyStatements); - blockScopeNode.body = [ - ...blockScopeNode.body, + scopeNode.body = [ + ...scopeNode.body, ...nodeBodyStatements ]; } /** * @param {IStackTraceData[]} blockScopeStackTraceData - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {TStatement[]} nodeBodyStatements * @param {number} index */ public static appendNodeToOptimalBlockScope ( blockScopeStackTraceData: IStackTraceData[], - blockScopeNode: TNodeWithBlockStatement, + blockScopeNode: TNodeWithBlockScope, nodeBodyStatements: TStatement[], index: number = 0 ): void { - let targetBlockScope: TNodeWithBlockStatement; + let targetBlockScope: TNodeWithBlockScope; if (!blockScopeStackTraceData.length) { targetBlockScope = blockScopeNode; @@ -96,12 +96,12 @@ export class NodeAppender { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {TStatement[]} nodeBodyStatements * @param {number} index */ public static insertNodeAtIndex ( - blockScopeNode: TNodeWithBlockStatement, + blockScopeNode: TNodeWithBlockScope, nodeBodyStatements: TStatement[], index: number ): void { @@ -119,11 +119,11 @@ export class NodeAppender { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {TStatement[]} nodeBodyStatements */ public static prependNode ( - blockScopeNode: TNodeWithBlockStatement, + blockScopeNode: TNodeWithBlockScope, nodeBodyStatements: TStatement[] ): void { if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { @@ -139,12 +139,12 @@ export class NodeAppender { } /** - * @param {TNodeWithBlockStatement} blockScopeNode + * @param {TNodeWithBlockScope} blockScopeNode * @param {TStatement[]} nodeBodyStatements * @returns {TStatement[]} */ private static parentizeBodyStatementsBeforeAppend ( - blockScopeNode: TNodeWithBlockStatement, + blockScopeNode: TNodeWithBlockScope, nodeBodyStatements: TStatement[] ): TStatement[] { nodeBodyStatements.forEach((statement: TStatement) => { diff --git a/src/node/NodeGuards.ts b/src/node/NodeGuards.ts index bc166684..3dfafc67 100644 --- a/src/node/NodeGuards.ts +++ b/src/node/NodeGuards.ts @@ -1,10 +1,29 @@ import * as ESTree from 'estree'; -import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../types/node/TNodeWithBlockScope'; +import { TNodeWithScope } from '../types/node/TNodeWithScope'; import { NodeType } from '../enums/node/NodeType'; export class NodeGuards { + /** + * @type {string[]} + */ + private static readonly nodesWithBlockScope: string[] = [ + NodeType.ArrowFunctionExpression, + NodeType.FunctionDeclaration, + NodeType.FunctionExpression, + NodeType.MethodDefinition, + ]; + + /** + * @param {Node} node + * @returns {boolean} + */ + public static isArrayPatternNode (node: ESTree.Node): node is ESTree.ArrayPattern { + return node.type === NodeType.ArrayPattern; + } + /** * @param {Node} node * @returns {boolean} @@ -174,8 +193,27 @@ export class NodeGuards { * @param {Node} node * @returns {boolean} */ - public static isNodeHasBlockStatement (node: ESTree.Node): node is TNodeWithBlockStatement { - return Array.isArray((node).body); + public static isNodeHasBlockScope (node: ESTree.Node): node is TNodeWithBlockScope { + const parentNode: ESTree.Node | undefined = node.parentNode; + + if (!parentNode) { + return false; + } + + return NodeGuards.isProgramNode(node) || ( + NodeGuards.isBlockStatementNode(node) + && NodeGuards.nodesWithBlockScope.includes(parentNode.type) + ); + } + + /** + * @param {Node} node + * @returns {boolean} + */ + public static isNodeHasScope (node: ESTree.Node): node is TNodeWithScope { + return NodeGuards.isProgramNode(node) + || NodeGuards.isBlockStatementNode(node) + || NodeGuards.isSwitchCaseNode(node); } /** @@ -245,6 +283,14 @@ export class NodeGuards { !NodeGuards.isLabelIdentifierNode(node, parentNode); } + /** + * @param {Node} node + * @returns {boolean} + */ + public static isRestElementNode (node: ESTree.Node): node is ESTree.RestElement { + return node.type === NodeType.RestElement; + } + /** * @param {Node} node * @returns {boolean} @@ -261,6 +307,14 @@ export class NodeGuards { return node.type === NodeType.Super; } + /** + * @param {Node} node + * @returns {boolean} + */ + public static isSwitchCaseNode (node: ESTree.Node): node is ESTree.SwitchCase { + return node.type === NodeType.SwitchCase; + } + /** * @param {Node} node * @returns {boolean} diff --git a/src/node/NodeUtils.ts b/src/node/NodeUtils.ts index 76b88743..dc328fce 100644 --- a/src/node/NodeUtils.ts +++ b/src/node/NodeUtils.ts @@ -3,26 +3,14 @@ import * as esprima from 'esprima'; import * as estraverse from 'estraverse'; import * as ESTree from 'estree'; -import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../types/node/TNodeWithBlockScope'; +import { TNodeWithScope } from '../types/node/TNodeWithScope'; import { TObject } from '../types/TObject'; import { TStatement } from '../types/node/TStatement'; -import { NodeType } from '../enums/node/NodeType'; - import { NodeGuards } from './NodeGuards'; export class NodeUtils { - /** - * @type {string[]} - */ - private static readonly nodesWithBlockScope: string[] = [ - NodeType.ArrowFunctionExpression, - NodeType.FunctionDeclaration, - NodeType.FunctionExpression, - NodeType.MethodDefinition, - NodeType.Program - ]; - /** * @param {T} astTree * @returns {T} @@ -115,48 +103,25 @@ export class NodeUtils { /** * @param {NodeGuards} node - * @param {number} index - * @returns {NodeGuards} + * @param {TNodeWithBlockScope[]} blockScopes + * @returns {TNodeWithBlockScope[]} */ - public static getBlockStatementNodeByIndex (node: ESTree.Node, index: number = 0): ESTree.Node { - if (!NodeGuards.isNodeHasBlockStatement(node)) { - throw new TypeError('The specified node have no a block-statement'); - } - - if (node.body[index] === undefined) { - throw new ReferenceError(`Wrong index \`${index}\`. Block-statement body length is \`${node.body.length}\``); - } - - return node.body[index]; - } - - /** - * @param {NodeGuards} node - * @param {TNodeWithBlockStatement[]} blockScopes - * @returns {TNodeWithBlockStatement[]} - */ - public static getBlockScopesOfNode (node: ESTree.Node, blockScopes: TNodeWithBlockStatement[] = []): TNodeWithBlockStatement[] { + public static getBlockScopesOfNode (node: ESTree.Node, blockScopes: TNodeWithBlockScope[] = []): TNodeWithBlockScope[] { const parentNode: ESTree.Node | undefined = node.parentNode; if (!parentNode) { throw new ReferenceError('`parentNode` property of given node is `undefined`'); } - if (NodeGuards.isBlockStatementNode(parentNode)) { - if (!parentNode.parentNode) { - throw new ReferenceError('`parentNode` property of `parentNode` of given node is `undefined`'); - } - - if (NodeUtils.nodesWithBlockScope.includes(parentNode.parentNode.type)) { - blockScopes.push(parentNode); - } + if (NodeGuards.isBlockStatementNode(parentNode) && NodeGuards.isNodeHasBlockScope(parentNode)) { + blockScopes.push(parentNode); } if (node !== parentNode) { return NodeUtils.getBlockScopesOfNode(parentNode, blockScopes); } - if (NodeGuards.isNodeHasBlockStatement(parentNode)) { + if (NodeGuards.isNodeHasBlockScope(parentNode)) { blockScopes.push(parentNode); } @@ -165,25 +130,20 @@ export class NodeUtils { /** * @param {NodeGuards} node - * @param {number} depth - * @returns {number} + * @returns {TNodeWithScope} */ - public static getNodeBlockScopeDepth (node: ESTree.Node, depth: number = 0): number { + public static getScopeOfNode (node: ESTree.Node): TNodeWithScope { const parentNode: ESTree.Node | undefined = node.parentNode; if (!parentNode) { throw new ReferenceError('`parentNode` property of given node is `undefined`'); } - if (NodeGuards.isProgramNode(parentNode)) { - return depth; + if (!NodeGuards.isNodeHasScope(parentNode)) { + return NodeUtils.getScopeOfNode(parentNode); } - if (NodeGuards.isBlockStatementNode(node) && NodeUtils.nodesWithBlockScope.includes(parentNode.type)) { - return NodeUtils.getNodeBlockScopeDepth(parentNode, ++depth); - } - - return NodeUtils.getNodeBlockScopeDepth(parentNode, depth); + return parentNode; } /** @@ -203,7 +163,7 @@ export class NodeUtils { * @returns {T} */ public static parentize (astTree: T): T { - estraverse.traverse(astTree, { + estraverse.replace(astTree, { enter: NodeUtils.parentizeNode }); diff --git a/src/options/Options.ts b/src/options/Options.ts index 963c2569..0a9cc3e7 100644 --- a/src/options/Options.ts +++ b/src/options/Options.ts @@ -206,6 +206,12 @@ export class Options implements IOptions { @IsIn([ObfuscationTarget.Browser, ObfuscationTarget.Extension, ObfuscationTarget.Node]) public readonly target: ObfuscationTarget; + /** + * @type {boolean} + */ + @IsBoolean() + public readonly transformObjectKeys: boolean; + /** * @type {boolean} */ diff --git a/src/options/presets/Default.ts b/src/options/presets/Default.ts index 6b2990f0..d9312848 100644 --- a/src/options/presets/Default.ts +++ b/src/options/presets/Default.ts @@ -30,5 +30,6 @@ export const DEFAULT_PRESET: TInputOptions = Object.freeze({ stringArrayEncoding: false, stringArrayThreshold: 0.75, target: ObfuscationTarget.Browser, + transformObjectKeys: false, unicodeEscapeSequence: false }); diff --git a/src/options/presets/NoCustomNodes.ts b/src/options/presets/NoCustomNodes.ts index d5d6c8b4..182fc7d9 100644 --- a/src/options/presets/NoCustomNodes.ts +++ b/src/options/presets/NoCustomNodes.ts @@ -4,7 +4,7 @@ import { IdentifierNamesGenerator } from '../../enums/generators/identifier-name import { ObfuscationTarget } from '../../enums/ObfuscationTarget'; import { SourceMapMode } from '../../enums/source-map/SourceMapMode'; -export const NO_CUSTOM_NODES_PRESET: TInputOptions = Object.freeze({ +export const NO_ADDITIONAL_NODES_PRESET: TInputOptions = Object.freeze({ compact: true, controlFlowFlattening: false, controlFlowFlatteningThreshold: 0, @@ -29,5 +29,6 @@ export const NO_CUSTOM_NODES_PRESET: TInputOptions = Object.freeze({ stringArrayEncoding: false, stringArrayThreshold: 0, target: ObfuscationTarget.Browser, + transformObjectKeys: false, unicodeEscapeSequence: false }); diff --git a/src/types/container/custom-nodes/TDeadNodeInjectionCustomNodeFactory.d.ts b/src/types/container/custom-nodes/TDeadNodeInjectionCustomNodeFactory.d.ts new file mode 100644 index 00000000..b2b06cf9 --- /dev/null +++ b/src/types/container/custom-nodes/TDeadNodeInjectionCustomNodeFactory.d.ts @@ -0,0 +1,5 @@ +import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode'; + +import { DeadCodeInjectionCustomNode } from '../../../enums/custom-nodes/DeadCodeInjectionCustomNode'; + +export type TDeadNodeInjectionCustomNodeFactory = (deadCodeInjectionCustomNodeName: DeadCodeInjectionCustomNode) => ICustomNode; diff --git a/src/types/node/TNodeWithBlockScope.d.ts b/src/types/node/TNodeWithBlockScope.d.ts new file mode 100644 index 00000000..273b2796 --- /dev/null +++ b/src/types/node/TNodeWithBlockScope.d.ts @@ -0,0 +1,3 @@ +import * as ESTree from 'estree'; + +export type TNodeWithBlockScope = ESTree.Program | ESTree.BlockStatement; diff --git a/src/types/node/TNodeWithBlockStatement.d.ts b/src/types/node/TNodeWithBlockStatement.d.ts deleted file mode 100644 index 82266bac..00000000 --- a/src/types/node/TNodeWithBlockStatement.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as ESTree from 'estree'; - -export type TNodeWithBlockStatement = ESTree.BlockStatement | ESTree.Program; diff --git a/src/types/node/TNodeWithScope.d.ts b/src/types/node/TNodeWithScope.d.ts new file mode 100644 index 00000000..491b4c94 --- /dev/null +++ b/src/types/node/TNodeWithScope.d.ts @@ -0,0 +1,3 @@ +import * as ESTree from 'estree'; + +export type TNodeWithScope = ESTree.Program | ESTree.BlockStatement | ESTree.SwitchCase; diff --git a/test/dev/dev.ts b/test/dev/dev.ts index dceef670..b250f545 100644 --- a/test/dev/dev.ts +++ b/test/dev/dev.ts @@ -1,5 +1,5 @@ 'use strict'; -import { NO_CUSTOM_NODES_PRESET } from '../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNodes'; (function () { const JavaScriptObfuscator: any = require('../../index'); @@ -7,34 +7,20 @@ import { NO_CUSTOM_NODES_PRESET } from '../../src/options/presets/NoCustomNodes' let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( ` (function(){ - if (true) { - var foo = function () { - console.log('abc'); - }; - var bar = function () { - console.log('def'); - }; - var baz = function () { - console.log('ghi'); - }; - var bark = function () { - console.log('jkl'); - }; - var hawk = function () { - console.log('mno'); - }; - - foo(); - bar(); - baz(); - bark(); - hawk(); - } + var object = { + foo: 'test1', + bar: { + baz: 'test2' + } + }; })(); `, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, compact: false, + transformObjectKeys: true, + stringArray: true, + stringArrayThreshold: 1 } ).getObfuscatedCode(); diff --git a/test/functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts b/test/functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts index 714df8b3..5ebdd5ad 100644 --- a/test/functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts +++ b/test/functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts @@ -7,7 +7,7 @@ import * as ESTree from 'estree'; import { assert } from 'chai'; -import { TNodeWithBlockStatement } from '../../../../src/types/node/TNodeWithBlockStatement'; +import { TNodeWithBlockScope } from '../../../../src/types/node/TNodeWithBlockScope'; import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade'; import { IStackTraceAnalyzer } from '../../../../src/interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer'; @@ -165,7 +165,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #1: basic-1', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/basic-1.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -215,7 +215,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #2: basic-2', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/basic-2.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -254,7 +254,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #3: deep conditions nesting', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/deep-conditions-nesting.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -293,7 +293,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #4: call before declaration', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/call-before-declaration.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -316,7 +316,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #5: call expression of object member #1', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/call-expression-of-object-member-1.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -375,7 +375,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #5: call expression of object member #2', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/call-expression-of-object-member-2.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -403,7 +403,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #6: no call expressions', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/no-call-expressions.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -420,7 +420,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #7: only call expression', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/only-call-expression.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -437,7 +437,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #8: self-invoking functions', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/self-invoking-functions.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); @@ -472,7 +472,7 @@ describe('StackTraceAnalyzer', () => { describe('variant #9: no recursion', () => { before(() => { const code: string = readFileAsString(__dirname + '/fixtures/no-recursion.js'); - const astTree: TNodeWithBlockStatement = Nodes.getProgramNode( + const astTree: TNodeWithBlockScope = Nodes.getProgramNode( NodeUtils.convertCodeToStructure(code) ); diff --git a/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts b/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts index a7d3d5ec..a563684d 100644 --- a/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts +++ b/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../helpers/readFileAsString'; @@ -21,7 +21,7 @@ describe('ConsoleOutputDisableExpressionNode', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, disableConsoleOutput: true } ); @@ -50,7 +50,7 @@ describe('ConsoleOutputDisableExpressionNode', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, disableConsoleOutput: false } ); diff --git a/test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts b/test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts index 007df024..54d07797 100644 --- a/test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts +++ b/test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../helpers/readFileAsString'; @@ -19,7 +19,7 @@ describe('DomainLockNode', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, domainLock: ['.example.com'] } ); @@ -40,7 +40,7 @@ describe('DomainLockNode', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, domainLock: [] } ); diff --git a/test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts index 86789093..db895e3a 100644 --- a/test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts +++ b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../helpers/readFileAsString'; @@ -20,7 +20,7 @@ describe('StringArrayCallsWrapper', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -43,7 +43,7 @@ describe('StringArrayCallsWrapper', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: false } ); diff --git a/test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts index 8a4df36f..4b6b7ed7 100644 --- a/test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts +++ b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../helpers/readFileAsString'; @@ -20,7 +20,7 @@ describe('StringArrayNode', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -43,7 +43,7 @@ describe('StringArrayNode', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: false } ); diff --git a/test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts index 9ea7e475..2d986dea 100644 --- a/test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts +++ b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../helpers/readFileAsString'; @@ -20,7 +20,7 @@ describe('StringArrayRotateFunctionNode', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, rotateStringArray: true, stringArray: true, stringArrayThreshold: 1 @@ -44,7 +44,7 @@ describe('StringArrayRotateFunctionNode', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, rotateStringArray: false, stringArray: true, stringArrayThreshold: 1 diff --git a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts index 42f42773..c194cc07 100644 --- a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts +++ b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts @@ -7,7 +7,7 @@ import { StringArrayEncoding } from '../../../src/enums/StringArrayEncoding'; import { JavaScriptObfuscator } from '../../../src/JavaScriptObfuscatorFacade'; -import { NO_CUSTOM_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes'; import { IdentifierNamesGenerator } from '../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator'; @@ -26,7 +26,7 @@ describe('JavaScriptObfuscator', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -91,7 +91,7 @@ describe('JavaScriptObfuscator', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, sourceMap: true } ); @@ -120,7 +120,7 @@ describe('JavaScriptObfuscator', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, sourceMap: true, sourceMapMode: SourceMapMode.Inline } @@ -195,7 +195,7 @@ describe('JavaScriptObfuscator', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -217,7 +217,7 @@ describe('JavaScriptObfuscator', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -240,7 +240,7 @@ describe('JavaScriptObfuscator', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -269,7 +269,7 @@ describe('JavaScriptObfuscator', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -438,7 +438,7 @@ describe('JavaScriptObfuscator', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -494,6 +494,7 @@ describe('JavaScriptObfuscator', () => { stringArray: true, stringArrayEncoding: StringArrayEncoding.Rc4, stringArrayThreshold: 1, + transformObjectKeys: true, unicodeEscapeSequence: false } ); diff --git a/test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts b/test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts index 073227a0..087a9490 100644 --- a/test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts +++ b/test/functional-tests/node-transformers/control-flow-transformers/block-statement-control-flow-transformer/BlockStatementControlFlowTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { getRegExpMatch } from '../../../../helpers/getRegExpMatch'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -29,13 +29,14 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } ); obfuscatedCode = obfuscationResult.getObfuscatedCode(); + console.log(obfuscatedCode); }); describe('`console.log` statements', ()=> { @@ -117,7 +118,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1, unicodeEscapeSequence: false @@ -208,7 +209,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -232,7 +233,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -256,7 +257,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -280,7 +281,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -304,7 +305,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -331,7 +332,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -360,7 +361,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -384,7 +385,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -411,7 +412,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -440,7 +441,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -471,7 +472,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code.repeat(samples), { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: controlFlowFlatteningThreshold, } @@ -513,7 +514,7 @@ describe('BlockStatementControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } diff --git a/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer/BinaryExpressionControlFlowReplacer.spec.ts b/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer/BinaryExpressionControlFlowReplacer.spec.ts index 28651770..49fbd963 100644 --- a/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer/BinaryExpressionControlFlowReplacer.spec.ts +++ b/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/binary-expression-control-flow-replacer/BinaryExpressionControlFlowReplacer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../../helpers/readFileAsString'; @@ -22,7 +22,7 @@ describe('BinaryExpressionControlFlowReplacer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -64,7 +64,7 @@ describe('BinaryExpressionControlFlowReplacer', function () { obfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } diff --git a/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer/CallExpressionControlFlowReplacer.spec.ts b/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer/CallExpressionControlFlowReplacer.spec.ts index a707e34b..a0ed9eec 100644 --- a/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer/CallExpressionControlFlowReplacer.spec.ts +++ b/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/call-expression-control-flow-replacer/CallExpressionControlFlowReplacer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../../helpers/readFileAsString'; @@ -22,7 +22,7 @@ describe('CallExpressionControlFlowReplacer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -64,7 +64,7 @@ describe('CallExpressionControlFlowReplacer', function () { obfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -111,7 +111,7 @@ describe('CallExpressionControlFlowReplacer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } diff --git a/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer/LogicalExpressionControlFlowReplacer.spec.ts b/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer/LogicalExpressionControlFlowReplacer.spec.ts index 12dc5a5d..18f1c05f 100644 --- a/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer/LogicalExpressionControlFlowReplacer.spec.ts +++ b/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/logical-expression-control-flow-replacer/LogicalExpressionControlFlowReplacer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../../helpers/readFileAsString'; @@ -22,7 +22,7 @@ describe('LogicalExpressionControlFlowReplacer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -64,7 +64,7 @@ describe('LogicalExpressionControlFlowReplacer', function () { obfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -111,7 +111,7 @@ describe('LogicalExpressionControlFlowReplacer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -135,7 +135,7 @@ describe('LogicalExpressionControlFlowReplacer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: .1 } diff --git a/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/string-litertal-control-flow-replacer/StringLiteralControlFlowReplacer.spec.ts b/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/string-litertal-control-flow-replacer/StringLiteralControlFlowReplacer.spec.ts index 2efdabd3..c820ce1a 100644 --- a/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/string-litertal-control-flow-replacer/StringLiteralControlFlowReplacer.spec.ts +++ b/test/functional-tests/node-transformers/control-flow-transformers/control-flow-replacers/string-litertal-control-flow-replacer/StringLiteralControlFlowReplacer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../../helpers/readFileAsString'; @@ -20,7 +20,7 @@ describe('StringLiteralControlFlowReplacer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } diff --git a/test/functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec.ts b/test/functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec.ts index 85d2a848..6ca4172d 100644 --- a/test/functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec.ts +++ b/test/functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -38,7 +38,7 @@ describe('FunctionControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -80,7 +80,7 @@ describe('FunctionControlFlowTransformer', function () { obfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -123,7 +123,7 @@ describe('FunctionControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -147,7 +147,7 @@ describe('FunctionControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -182,7 +182,7 @@ describe('FunctionControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -211,7 +211,7 @@ describe('FunctionControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 0 } @@ -240,7 +240,7 @@ describe('FunctionControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } @@ -264,7 +264,7 @@ describe('FunctionControlFlowTransformer', function () { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } diff --git a/test/functional-tests/node-transformers/converting-transformers/member-expression-transformer/MemberExpressionTransformer.spec.ts b/test/functional-tests/node-transformers/converting-transformers/member-expression-transformer/MemberExpressionTransformer.spec.ts index 44cd63b6..058de33a 100644 --- a/test/functional-tests/node-transformers/converting-transformers/member-expression-transformer/MemberExpressionTransformer.spec.ts +++ b/test/functional-tests/node-transformers/converting-transformers/member-expression-transformer/MemberExpressionTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -20,7 +20,7 @@ describe('MemberExpressionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -43,7 +43,7 @@ describe('MemberExpressionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -74,7 +74,7 @@ describe('MemberExpressionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -102,7 +102,7 @@ describe('MemberExpressionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); diff --git a/test/functional-tests/node-transformers/converting-transformers/method-definition-transformer/MethodDefinitionTransformer.spec.ts b/test/functional-tests/node-transformers/converting-transformers/method-definition-transformer/MethodDefinitionTransformer.spec.ts index a8459ba7..61f82f85 100644 --- a/test/functional-tests/node-transformers/converting-transformers/method-definition-transformer/MethodDefinitionTransformer.spec.ts +++ b/test/functional-tests/node-transformers/converting-transformers/method-definition-transformer/MethodDefinitionTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -19,7 +19,7 @@ describe('MethodDefinitionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -42,7 +42,7 @@ describe('MethodDefinitionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -70,7 +70,7 @@ describe('MethodDefinitionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); diff --git a/test/functional-tests/node-transformers/converting-transformers/template-literal-transformer/TemplateLiteralTransformer.spec.ts b/test/functional-tests/node-transformers/converting-transformers/template-literal-transformer/TemplateLiteralTransformer.spec.ts index 223b3cba..a254ddc1 100644 --- a/test/functional-tests/node-transformers/converting-transformers/template-literal-transformer/TemplateLiteralTransformer.spec.ts +++ b/test/functional-tests/node-transformers/converting-transformers/template-literal-transformer/TemplateLiteralTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -15,7 +15,7 @@ describe('TemplateLiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, unicodeEscapeSequence: false } ); @@ -30,7 +30,7 @@ describe('TemplateLiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, unicodeEscapeSequence: false } ); @@ -45,7 +45,7 @@ describe('TemplateLiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, unicodeEscapeSequence: false } ); @@ -60,7 +60,7 @@ describe('TemplateLiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, unicodeEscapeSequence: false } ); diff --git a/test/functional-tests/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.spec.ts b/test/functional-tests/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.spec.ts index 5067b6d4..ce1a5fc1 100644 --- a/test/functional-tests/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.spec.ts +++ b/test/functional-tests/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../helpers/readFileAsString'; @@ -33,7 +33,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 1, stringArray: true, @@ -69,7 +69,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 1, stringArray: true, @@ -105,7 +105,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 0, stringArray: true, @@ -149,7 +149,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 1, stringArray: true, @@ -200,7 +200,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 1, stringArray: true, @@ -251,7 +251,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 1, stringArray: true, @@ -339,7 +339,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 1, stringArray: true, @@ -396,7 +396,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1, deadCodeInjection: true, @@ -422,7 +422,7 @@ describe('DeadCodeInjectionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 1, debugProtection: true diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/catch-clause-transformer/CatchClauseTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/catch-clause-transformer/CatchClauseTransformer.spec.ts index 8bed91a1..50e41f14 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/catch-clause-transformer/CatchClauseTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/catch-clause-transformer/CatchClauseTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { getRegExpMatch } from '../../../../helpers/getRegExpMatch'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -24,7 +24,7 @@ describe('CatchClauseTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -55,7 +55,7 @@ describe('CatchClauseTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/class-declaration-transformer/ClassDeclarationTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/class-declaration-transformer/ClassDeclarationTransformer.spec.ts index 4b0b1887..962df243 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/class-declaration-transformer/ClassDeclarationTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/class-declaration-transformer/ClassDeclarationTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { getRegExpMatch } from '../../../../helpers/getRegExpMatch'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -24,7 +24,7 @@ describe('ClassDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -50,7 +50,7 @@ describe('ClassDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -77,7 +77,7 @@ describe('ClassDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, renameGlobals: true } ); diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/function-declaration-transformer/FunctionDeclarationTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/function-declaration-transformer/FunctionDeclarationTransformer.spec.ts index 5c3e07f7..b4c92013 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/function-declaration-transformer/FunctionDeclarationTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/function-declaration-transformer/FunctionDeclarationTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { getRegExpMatch } from '../../../../helpers/getRegExpMatch'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -24,7 +24,7 @@ describe('FunctionDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -50,7 +50,7 @@ describe('FunctionDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -77,7 +77,7 @@ describe('FunctionDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, renameGlobals: true } ); @@ -108,7 +108,7 @@ describe('FunctionDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -135,7 +135,7 @@ describe('FunctionDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/FunctionTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/FunctionTransformer.spec.ts index 38816c8d..47b9df11 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/FunctionTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/function-transformer/FunctionTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -24,7 +24,7 @@ describe('FunctionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -60,7 +60,7 @@ describe('FunctionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -87,7 +87,7 @@ describe('FunctionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -116,7 +116,7 @@ describe('FunctionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -148,7 +148,7 @@ describe('FunctionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -198,7 +198,7 @@ describe('FunctionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -265,7 +265,7 @@ describe('FunctionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); const obfuscatedCode: string = obfuscationResult.getObfuscatedCode(); diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/labeled-statement-transformer/LabeledStatementTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/labeled-statement-transformer/LabeledStatementTransformer.spec.ts index ba3b2628..b2361562 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/labeled-statement-transformer/LabeledStatementTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/labeled-statement-transformer/LabeledStatementTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { getRegExpMatch } from '../../../../helpers/getRegExpMatch'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -25,7 +25,7 @@ describe('LabeledStatementTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts index 482d8e4a..a8b59254 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/literal-transformer/LiteralTransformer.spec.ts @@ -4,7 +4,7 @@ import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationRe import { StringArrayEncoding } from '../../../../../src/enums/StringArrayEncoding'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -23,7 +23,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -51,7 +51,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -72,7 +72,7 @@ describe('LiteralTransformer', () => { testFunc = () => JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -95,7 +95,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -123,7 +123,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, unicodeEscapeSequence: true } @@ -148,7 +148,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1, unicodeEscapeSequence: true @@ -177,7 +177,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -202,7 +202,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayEncoding: StringArrayEncoding.Base64, stringArrayThreshold: 1 @@ -231,7 +231,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayEncoding: StringArrayEncoding.Rc4, stringArrayThreshold: 1 @@ -262,7 +262,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `${code}\n`.repeat(samples), { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: stringArrayThreshold } @@ -301,7 +301,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -325,7 +325,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } @@ -349,7 +349,7 @@ describe('LiteralTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/object-expression-transformer/ObjectExpressionTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/object-expression-transformer/ObjectExpressionTransformer.spec.ts index 06ab9acd..353a5919 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/object-expression-transformer/ObjectExpressionTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/object-expression-transformer/ObjectExpressionTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -19,7 +19,7 @@ describe('ObjectExpressionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -41,7 +41,7 @@ describe('ObjectExpressionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -63,7 +63,7 @@ describe('ObjectExpressionTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); diff --git a/test/functional-tests/node-transformers/obfuscating-transformers/variable-declaration-transformer/VariableDeclarationTransformer.spec.ts b/test/functional-tests/node-transformers/obfuscating-transformers/variable-declaration-transformer/VariableDeclarationTransformer.spec.ts index b21d1fa4..88bfc03d 100644 --- a/test/functional-tests/node-transformers/obfuscating-transformers/variable-declaration-transformer/VariableDeclarationTransformer.spec.ts +++ b/test/functional-tests/node-transformers/obfuscating-transformers/variable-declaration-transformer/VariableDeclarationTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { getRegExpMatch } from '../../../../helpers/getRegExpMatch'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -21,7 +21,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -49,7 +49,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -76,7 +76,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, renameGlobals: true } ); @@ -104,7 +104,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -126,7 +126,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -149,7 +149,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -183,7 +183,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); const obfuscatedCode: string = obfuscationResult.getObfuscatedCode(); @@ -238,7 +238,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); const obfuscatedCode: string = obfuscationResult.getObfuscatedCode(); @@ -286,7 +286,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -308,7 +308,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -332,7 +332,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -363,7 +363,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -402,7 +402,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -424,7 +424,7 @@ describe('VariableDeclarationTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); diff --git a/test/functional-tests/node-transformers/preparing-transformers/comments-transformer/CommentsTransformer.spec.ts b/test/functional-tests/node-transformers/preparing-transformers/comments-transformer/CommentsTransformer.spec.ts index acc92b87..224b2bdd 100644 --- a/test/functional-tests/node-transformers/preparing-transformers/comments-transformer/CommentsTransformer.spec.ts +++ b/test/functional-tests/node-transformers/preparing-transformers/comments-transformer/CommentsTransformer.spec.ts @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../helpers/readFileAsString'; @@ -19,7 +19,7 @@ describe('CommentsTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -41,7 +41,7 @@ describe('CommentsTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -63,7 +63,7 @@ describe('CommentsTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -92,7 +92,7 @@ describe('CommentsTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -112,7 +112,7 @@ describe('CommentsTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -134,7 +134,7 @@ describe('CommentsTransformer', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); diff --git a/test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/black-list-obfuscating-guard/BlackListObfuscatingGuard.spec.ts b/test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/black-list-obfuscating-guard/BlackListObfuscatingGuard.spec.ts index e88e21de..a472bcc0 100644 --- a/test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/black-list-obfuscating-guard/BlackListObfuscatingGuard.spec.ts +++ b/test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/black-list-obfuscating-guard/BlackListObfuscatingGuard.spec.ts @@ -4,7 +4,7 @@ import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscatio import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscatorFacade'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../../helpers/readFileAsString'; @@ -22,7 +22,7 @@ describe('BlackListObfuscatingGuard', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, stringArray: true, stringArrayThreshold: 1 } diff --git a/test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/conditional-comment-obfuscating-guard/ConditionalCommentObfuscatingGuard.spec.ts b/test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/conditional-comment-obfuscating-guard/ConditionalCommentObfuscatingGuard.spec.ts index bef94271..7d1e1ed3 100644 --- a/test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/conditional-comment-obfuscating-guard/ConditionalCommentObfuscatingGuard.spec.ts +++ b/test/functional-tests/node-transformers/preparing-transformers/obfuscating-guards/conditional-comment-obfuscating-guard/ConditionalCommentObfuscatingGuard.spec.ts @@ -4,7 +4,7 @@ import { IObfuscationResult } from '../../../../../../src/interfaces/IObfuscatio import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscatorFacade'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../src/options/presets/NoCustomNodes'; import { readFileAsString } from '../../../../../helpers/readFileAsString'; @@ -22,7 +22,7 @@ describe('ConditionalCommentObfuscatingGuard', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -54,7 +54,7 @@ describe('ConditionalCommentObfuscatingGuard', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -85,7 +85,7 @@ describe('ConditionalCommentObfuscatingGuard', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET + ...NO_ADDITIONAL_NODES_PRESET } ); @@ -123,7 +123,7 @@ describe('ConditionalCommentObfuscatingGuard', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, deadCodeInjection: true, deadCodeInjectionThreshold: 1 } @@ -183,7 +183,7 @@ describe('ConditionalCommentObfuscatingGuard', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, controlFlowFlattening: true, controlFlowFlatteningThreshold: 1 } diff --git a/test/functional-tests/templates/custom-nodes/debug-protection-nodes/DebufProtectionFunctionCallTemplate.spec.ts b/test/functional-tests/templates/custom-nodes/debug-protection-nodes/DebufProtectionFunctionCallTemplate.spec.ts index a75c17e3..e7ea6a66 100644 --- a/test/functional-tests/templates/custom-nodes/debug-protection-nodes/DebufProtectionFunctionCallTemplate.spec.ts +++ b/test/functional-tests/templates/custom-nodes/debug-protection-nodes/DebufProtectionFunctionCallTemplate.spec.ts @@ -5,7 +5,7 @@ import { IObfuscationResult } from '../../../../../src/interfaces/IObfuscationRe import { readFileAsString } from '../../../../helpers/readFileAsString'; -import { NO_CUSTOM_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes'; import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade'; @@ -40,7 +40,7 @@ describe('DebugProtectionFunctionCallTemplate (): string', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, debugProtection: true } ); @@ -75,7 +75,7 @@ describe('DebugProtectionFunctionCallTemplate (): string', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, debugProtection: true, mangle: true } @@ -111,7 +111,7 @@ describe('DebugProtectionFunctionCallTemplate (): string', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, debugProtection: true } ); @@ -147,7 +147,7 @@ describe('DebugProtectionFunctionCallTemplate (): string', () => { const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, debugProtection: true } ); diff --git a/test/runtime-tests/JavaScriptObfuscatorRuntime.spec.ts b/test/runtime-tests/JavaScriptObfuscatorRuntime.spec.ts index edba94e7..26390ae4 100644 --- a/test/runtime-tests/JavaScriptObfuscatorRuntime.spec.ts +++ b/test/runtime-tests/JavaScriptObfuscatorRuntime.spec.ts @@ -22,7 +22,8 @@ describe('JavaScriptObfuscator runtime eval', function () { deadCodeInjection: true, debugProtection: true, selfDefending: true, - stringArrayEncoding: StringArrayEncoding.Rc4 + stringArrayEncoding: StringArrayEncoding.Rc4, + transformObjectKeys: true } ); diff --git a/test/unit-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts b/test/unit-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts index 16adcabd..26d8ecde 100644 --- a/test/unit-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts +++ b/test/unit-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts @@ -6,7 +6,7 @@ import { IInversifyContainerFacade } from '../../../src/interfaces/container/IIn import { IJavaScriptObfuscator } from '../../../src/interfaces/IJavaScriptObfsucator'; import { IObfuscationResult } from '../../../src/interfaces/IObfuscationResult'; -import { NO_CUSTOM_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes'; +import { NO_ADDITIONAL_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes'; import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade'; @@ -30,7 +30,7 @@ describe('JavaScriptObfuscator', () => { inversifyContainerFacade.load( '', { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, sourceMap: true, sourceMapFileName: sourceMapUrl } @@ -66,7 +66,7 @@ describe('JavaScriptObfuscator', () => { inversifyContainerFacade.load( '', { - ...NO_CUSTOM_NODES_PRESET, + ...NO_ADDITIONAL_NODES_PRESET, sourceMap: true, sourceMapBaseUrl: sourceMapBaseUrl, sourceMapFileName: sourceMapUrl diff --git a/test/unit-tests/node/node-appender/NodeAppender.spec.ts b/test/unit-tests/node/node-appender/NodeAppender.spec.ts index c4c53af6..8746ea1c 100644 --- a/test/unit-tests/node/node-appender/NodeAppender.spec.ts +++ b/test/unit-tests/node/node-appender/NodeAppender.spec.ts @@ -36,7 +36,7 @@ const convertCodeToAst: (fixturePath: string) => ESTree.Program = (fixturePath) }; describe('NodeAppender', () => { - describe('appendNode (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[]): void', () => { + describe('appendNode (blockScopeNode: TNodeWithBlockScope[], nodeBodyStatements: TStatement[]): void', () => { let astTree: ESTree.Program, expectedAstTree: ESTree.Program, node: TStatement[]; @@ -57,7 +57,7 @@ describe('NodeAppender', () => { }); }); - describe('appendNodeToOptimalBlockScope (blockScopeStackTraceData: IStackTraceData[], blockScopeNode: TNodeWithBlockStatement, nodeBodyStatements: TStatement[], index: number = 0): void', () => { + describe('appendNodeToOptimalBlockScope (blockScopeStackTraceData: IStackTraceData[], blockScopeNode: TNodeWithBlockScope, nodeBodyStatements: TStatement[], index: number = 0): void', () => { let stackTraceAnalyzer: IStackTraceAnalyzer, astTree: ESTree.Program, expectedAstTree: ESTree.Program, @@ -162,7 +162,7 @@ describe('NodeAppender', () => { }); }); - describe('insertNodeAtIndex (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[], index: number): void', () => { + describe('insertNodeAtIndex (blockScopeNode: TNodeWithBlockScope[], nodeBodyStatements: TStatement[], index: number): void', () => { let astTree: ESTree.Program, expectedAstTree: ESTree.Program, node: TStatement[]; @@ -183,7 +183,7 @@ describe('NodeAppender', () => { }); }); - describe('prependNode (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[]): void', () => { + describe('prependNode (blockScopeNode: TNodeWithBlockScope[], nodeBodyStatements: TStatement[]): void', () => { let astTree: ESTree.Program, expectedAstTree: ESTree.Program, node: TStatement[]; diff --git a/test/unit-tests/node/node-utils/NodeUtils.spec.ts b/test/unit-tests/node/node-utils/NodeUtils.spec.ts index 8034caf3..7840378c 100644 --- a/test/unit-tests/node/node-utils/NodeUtils.spec.ts +++ b/test/unit-tests/node/node-utils/NodeUtils.spec.ts @@ -9,8 +9,8 @@ import { NodeUtils } from '../../../../src/node/NodeUtils'; describe('NodeUtils', () => { describe('addXVerbatimPropertyToLiterals (node: ESTree.Node): void', () => { - let literalNode: any, - expectedLiteralNode: any; + let literalNode: ESTree.Literal, + expectedLiteralNode: ESTree.Literal; before(() => { literalNode = Nodes.getLiteralNode('value'); @@ -179,39 +179,7 @@ describe('NodeUtils', () => { }); }); - describe('getBlockStatementNodeByIndex (node: ESTree.Node, index: number = 0): ESTree.Node', () => { - let blockStatementNode: ESTree.BlockStatement, - expressionStatementNode1: ESTree.ExpressionStatement, - expressionStatementNode2: ESTree.ExpressionStatement; - - beforeEach(() => { - expressionStatementNode1 = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); - expressionStatementNode2 = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); - - blockStatementNode = Nodes.getBlockStatementNode([ - expressionStatementNode1, - expressionStatementNode2 - ]); - }); - - it('should return block-statement child node of given node if that node has block-statement', () => { - assert.deepEqual(NodeUtils.getBlockStatementNodeByIndex(blockStatementNode), expressionStatementNode1); - }); - - it('should return block-statement child node of given node with index `1` if that node has block-statement', () => { - assert.deepEqual(NodeUtils.getBlockStatementNodeByIndex(blockStatementNode, 1), expressionStatementNode2); - }); - - it('should throw a `ReferenceError` if index is out of boundaries', () => { - assert.throws(() => NodeUtils.getBlockStatementNodeByIndex(blockStatementNode, 2), ReferenceError); - }); - - it('should throw a `TypeError` if node have no a block-statement', () => { - assert.throws(() => NodeUtils.getBlockStatementNodeByIndex(expressionStatementNode1, 1), TypeError); - }); - }); - - describe('getBlockScopesOfNode (node: ESTree.Node, blockScopes: TNodeWithBlockStatement[] = []): TNodeWithBlockStatement[]', () => { + describe('getBlockScopesOfNode (node: ESTree.Node, blockScopes: TNodeWithBlockScope[] = []): TNodeWithBlockScope[]', () => { let functionDeclarationBlockStatementNode: ESTree.BlockStatement, ifStatementBlockStatementNode1: ESTree.BlockStatement, ifStatementBlockStatementNode2: ESTree.BlockStatement, @@ -326,18 +294,20 @@ describe('NodeUtils', () => { }); }); - describe('getNodeBlockScopeDepth (node: ESTree.Node, depth: number = 0): number', () => { - let functionDeclarationBlockStatementNode1: ESTree.BlockStatement, - functionDeclarationBlockStatementNode2: ESTree.BlockStatement, + describe('getScopeOfNode (node: ESTree.Node): TNodeWithScope | null', () => { + let functionDeclarationBlockStatementNode: ESTree.BlockStatement, ifStatementBlockStatementNode1: ESTree.BlockStatement, ifStatementBlockStatementNode2: ESTree.BlockStatement, + ifStatementBlockStatementNode3: ESTree.BlockStatement, ifStatementNode1: ESTree.IfStatement, ifStatementNode2: ESTree.IfStatement, - expressionStatementNode1: ESTree.ExpressionStatement, - expressionStatementNode2: ESTree.ExpressionStatement, + ifStatementNode3: ESTree.IfStatement, + switchCaseNode: ESTree.SwitchCase, + switchStatementNode: ESTree.SwitchStatement, expressionStatementNode3: ESTree.ExpressionStatement, - functionDeclarationNode1: ESTree.FunctionDeclaration, - functionDeclarationNode2: ESTree.FunctionDeclaration, + expressionStatementNode2: ESTree.ExpressionStatement, + expressionStatementNode1: ESTree.ExpressionStatement, + functionDeclarationNode: ESTree.FunctionDeclaration, programNode: ESTree.Program; before(() => { @@ -345,101 +315,123 @@ describe('NodeUtils', () => { expressionStatementNode2 = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); expressionStatementNode3 = Nodes.getExpressionStatementNode(Nodes.getIdentifierNode('identifier')); - ifStatementBlockStatementNode2 = Nodes.getBlockStatementNode([ + ifStatementBlockStatementNode3 = Nodes.getBlockStatementNode([ + expressionStatementNode2, expressionStatementNode3 ]); + ifStatementNode3 = Nodes.getIfStatementNode( + Nodes.getLiteralNode(true), + ifStatementBlockStatementNode3 + ); + + ifStatementBlockStatementNode2 = Nodes.getBlockStatementNode(); + + ifStatementBlockStatementNode1 = Nodes.getBlockStatementNode([ + ifStatementNode3 + ]); + ifStatementNode2 = Nodes.getIfStatementNode( Nodes.getLiteralNode(true), ifStatementBlockStatementNode2 ); - functionDeclarationBlockStatementNode2 = Nodes.getBlockStatementNode([ - ifStatementNode2, - expressionStatementNode2 - ]); - - functionDeclarationNode2 = Nodes.getFunctionDeclarationNode('test', [], functionDeclarationBlockStatementNode2); - - ifStatementBlockStatementNode1 = Nodes.getBlockStatementNode([ - functionDeclarationNode2 - ]); - ifStatementNode1 = Nodes.getIfStatementNode( Nodes.getLiteralNode(true), ifStatementBlockStatementNode1 ); - functionDeclarationBlockStatementNode1 = Nodes.getBlockStatementNode([ + switchCaseNode = Nodes.getSwitchCaseNode( + Nodes.getLiteralNode(1), + [ + ifStatementNode2 + ] + ); + + switchStatementNode = Nodes.getSwitchStatementNode( + Nodes.getLiteralNode(1), + [ + switchCaseNode + ] + ); + + functionDeclarationBlockStatementNode = Nodes.getBlockStatementNode([ expressionStatementNode1, - ifStatementNode1 + ifStatementNode1, + switchStatementNode ]); - functionDeclarationNode1 = Nodes.getFunctionDeclarationNode('test', [], functionDeclarationBlockStatementNode1); + functionDeclarationNode = Nodes.getFunctionDeclarationNode('test', [], functionDeclarationBlockStatementNode); programNode = Nodes.getProgramNode([ - functionDeclarationNode1 + functionDeclarationNode ]); programNode.parentNode = programNode; - functionDeclarationNode1.parentNode = programNode; - functionDeclarationBlockStatementNode1.parentNode = functionDeclarationNode1; - expressionStatementNode1.parentNode = functionDeclarationBlockStatementNode1; - ifStatementNode1.parentNode = functionDeclarationBlockStatementNode1; + functionDeclarationNode.parentNode = programNode; + functionDeclarationBlockStatementNode.parentNode = functionDeclarationNode; + expressionStatementNode1.parentNode = functionDeclarationBlockStatementNode; + ifStatementNode1.parentNode = functionDeclarationBlockStatementNode; ifStatementBlockStatementNode1.parentNode = ifStatementNode1; - functionDeclarationNode2.parentNode = ifStatementBlockStatementNode1; - functionDeclarationBlockStatementNode2.parentNode = functionDeclarationNode2; - expressionStatementNode2.parentNode = functionDeclarationBlockStatementNode2; - ifStatementNode2.parentNode = functionDeclarationBlockStatementNode2; + switchStatementNode.parentNode = functionDeclarationBlockStatementNode; + switchCaseNode.parentNode = switchStatementNode; + ifStatementNode2.parentNode = switchCaseNode; ifStatementBlockStatementNode2.parentNode = ifStatementNode2; + ifStatementNode3.parentNode = ifStatementBlockStatementNode1; + ifStatementBlockStatementNode3.parentNode = ifStatementNode3; + expressionStatementNode3.parentNode = ifStatementBlockStatementNode3; }); - it('should return block-scope depth for `program` node', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(programNode), 0); + it('should return scope node for `program` node child', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(programNode), programNode); }); - it('should return block-scope depth for `functionDeclaration` node #1', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(functionDeclarationNode1), 0); + it('should return scope node for `functionDeclaration` node child node #1', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(functionDeclarationNode), programNode); }); - it('should return block-scope depth for `functionDeclaration blockStatement` node #1', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(functionDeclarationBlockStatementNode1), 1); + it('should return scope node for `functionDeclaration blockStatement` node child node #1', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(functionDeclarationBlockStatementNode), programNode); }); - it('should return block-scope depth for `expressionStatement` node #1', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(expressionStatementNode1), 1); + it('should return scope node for `expressionStatement` node #1 child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(expressionStatementNode1), functionDeclarationBlockStatementNode); }); - it('should return block-scope depth for `ifStatement` node #1', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(ifStatementNode1), 1); + it('should return scope node for `ifStatement` node #1 child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(ifStatementNode1), functionDeclarationBlockStatementNode); }); - it('should return block-scope depth for `ifStatement blockStatement` node #1', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(ifStatementBlockStatementNode1), 1); + it('should return scope node for `switchStatement` node child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(switchStatementNode), functionDeclarationBlockStatementNode); }); - it('should return block-scope depth for `functionDeclaration` node #2', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(functionDeclarationNode2), 1); + it('should return scope node for `switchCase` node child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(switchCaseNode), functionDeclarationBlockStatementNode); }); - it('should return block-scope depth for `functionDeclaration blockStatement` node #2', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(functionDeclarationBlockStatementNode2), 2); + it('should return scope node for `ifStatement` node #2 child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(ifStatementNode2), switchCaseNode); }); - it('should return block-scope depth for `expressionStatement` node #2', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(expressionStatementNode2), 2); + it('should return scope node for `ifStatement blockStatement` node #2 child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(ifStatementBlockStatementNode2), switchCaseNode); }); - it('should return block-scope depth for `ifStatement` node #2', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(ifStatementNode2), 2); + it('should return scope node for `ifStatement blockStatement` node #1 child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(ifStatementBlockStatementNode1), functionDeclarationBlockStatementNode); }); - it('should return block-scope depth for `ifStatement blockStatement` node #2', () => { - assert.deepEqual(NodeUtils.getNodeBlockScopeDepth(ifStatementBlockStatementNode2), 2); + it('should return scope node for `ifStatement blockStatement` node #3 child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(ifStatementBlockStatementNode3), ifStatementBlockStatementNode1); + }); + + it('should return scope node for `expressionStatement` node #3 child node', () => { + assert.deepEqual(NodeUtils.getScopeOfNode(expressionStatementNode3), ifStatementBlockStatementNode3); }); it('should throw a `ReferenceError` if node has no `parentNode` property', () => { - assert.throws(() => NodeUtils.getNodeBlockScopeDepth(expressionStatementNode3), ReferenceError); + assert.throws(() => NodeUtils.getScopeOfNode(expressionStatementNode2), ReferenceError); }); }); diff --git a/yarn.lock b/yarn.lock index 12a94c36..b3488e9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,9 +6,9 @@ version "4.0.10" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.10.tgz#0eb222c7353adde8e0980bea04165d4d3b6afef3" -"@types/chance@0.7.35": - version "0.7.35" - resolved "https://registry.yarnpkg.com/@types/chance/-/chance-0.7.35.tgz#e76f3441b7763476c58eb7dc32f62da3d8ea547e" +"@types/chance@0.7.36": + version "0.7.36" + resolved "https://registry.yarnpkg.com/@types/chance/-/chance-0.7.36.tgz#1c3e14b9b11463d454182393ebcd8e977f1daff5" "@types/commander@2.12.2": version "2.12.2" @@ -74,9 +74,9 @@ version "8.0.53" resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.53.tgz#396b35af826fa66aad472c8cb7b8d5e277f4e6d8" -"@types/node@8.5.2": - version "8.5.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-8.5.2.tgz#83b8103fa9a2c2e83d78f701a9aa7c9539739aa5" +"@types/node@8.5.5": + version "8.5.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.5.5.tgz#6f9e8164ae1a55a9beb1d2571cfb7acf9d720c61" "@types/rimraf@^2.0.2": version "2.0.2" @@ -1450,9 +1450,9 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -escodegen-wallaby@1.6.15: - version "1.6.15" - resolved "https://registry.yarnpkg.com/escodegen-wallaby/-/escodegen-wallaby-1.6.15.tgz#9d5ef67dd4d8c7c8a58aff1e4edd63512566ba9f" +escodegen-wallaby@1.6.16: + version "1.6.16" + resolved "https://registry.yarnpkg.com/escodegen-wallaby/-/escodegen-wallaby-1.6.16.tgz#f55b65d1a846d98584f1be18a2bf463f96280527" dependencies: esprima "^2.7.1" estraverse "^1.9.1"