diff --git a/.babelrc b/.babelrc index af0f0c3d..8b6f24f8 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,6 @@ { + "generatorOpts": { + "retainFunctionParens": true + }, "presets": ["es2015"] } \ No newline at end of file diff --git a/.gitignore b/.gitignore index eeba4d47..5518770b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +.awcache .idea npm-debug.log +yarn.lock *.js.map /coverage /node_modules diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..9a60c118 --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +test/fixtures/compile-performance.js \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 2e9c1b2d..add483a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,9 @@ node_js: - "4" - "6" - "stable" - + script: "npm run travis" after_success: - npm run test:coveralls - - rm -rf ./coverage \ No newline at end of file + - rm -rf ./coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d124bd..bd997ee2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,19 @@ Change Log === -v0.7.2 +v0.8.0 --- -* runtime error fix [#7](https://github.com/sanex3339/webpack-obfuscator/issues/7) - -* shorthand object expression fix [#16](https://github.com/sanex3339/javascript-obfuscator/issues/16) +* **Breaking options change:** `encodeUnicodeArray` has been renamed to `unicodeArrayEncoding` and now accepts following values: `true|false|'base64'|'rc4'`. +* **Breaking change:** option `wrapUnicodeArrayCalls` was removed and now all calls to `unicodeArray` are always wrapped by special wrapper function. +* New option `sourceMapBaseUrl` sets base url to the source map import url when `sourceMapMode: 'separate'`. +* Custom nodes like `selfDefendingNode` or `consoleOutputNode` now inserted into deepest stack trace function call. +* Rewrite of many custom nodes. v0.7.1 --- * IE error fix [#14](https://github.com/sanex3339/javascript-obfuscator/issues/14) -v0.7.0-dev.3 +v0.7.0 --- * Obfuscator now returns an empty string instead of obfuscated code if source code is empty diff --git a/README.md b/README.md index b847c398..196feb33 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,21 @@ JavaScript obfuscator for Node.js is a free alternative to [js-obfuscator](https * compatible with ES6; * tested on Angular2 bundle. -https://gist.github.com/sanex3339/ffc2876123b52e6d11ce45369fd53acf +Online version: [javascriptobfuscator.herokuapp.com](https://javascriptobfuscator.herokuapp.com) + +Example of obfuscated code: [gist.github.com](https://gist.github.com/sanex3339/ffc2876123b52e6d11ce45369fd53acf) + +#### Plugins: +* Webpack: [webpack-obfuscator](https://github.com/javascript-obfuscator/webpack-obfuscator) +* Gulp: [gulp-javascript-obfuscator](https://github.com/javascript-obfuscator/gulp-javascript-obfuscator) +* Grunt: [grunt-contrib-obfuscator](https://github.com/javascript-obfuscator/grunt-contrib-obfuscator) [![npm version](https://badge.fury.io/js/javascript-obfuscator.svg)](https://badge.fury.io/js/javascript-obfuscator) -[![Build Status](https://travis-ci.org/sanex3339/javascript-obfuscator.svg?branch=master)](https://travis-ci.org/sanex3339/javascript-obfuscator) -[![Coverage Status](https://coveralls.io/repos/github/sanex3339/javascript-obfuscator/badge.svg?branch=master)](https://coveralls.io/github/sanex3339/javascript-obfuscator?branch=master) +[![Build Status](https://travis-ci.org/javascript-obfuscator/javascript-obfuscator.svg?branch=master)](https://travis-ci.org/javascript-obfuscator/javascript-obfuscator) +[![Coverage Status](https://coveralls.io/repos/github/javascript-obfuscator/javascript-obfuscator/badge.svg?branch=master)](https://coveralls.io/github/javascript-obfuscator/javascript-obfuscator?branch=master) -[![Dependency Status](https://david-dm.org/sanex3339/javascript-obfuscator.svg)](https://david-dm.org/sanex3339/javascript-obfuscator) -[![devDependency Status](https://david-dm.org/sanex3339/javascript-obfuscator/dev-status.svg)](https://david-dm.org/sanex3339/javascript-obfuscator#info=devDependencies) +[![Dependency Status](https://david-dm.org/javascript-obfuscator/javascript-obfuscator.svg)](https://david-dm.org/javascript-obfuscator/javascript-obfuscator) +[![devDependency Status](https://david-dm.org/javascript-obfuscator/javascript-obfuscator/dev-status.svg)](https://david-dm.org/javascript-obfuscator/javascript-obfuscator#info=devDependencies) ## Installation @@ -109,15 +116,16 @@ Following options available for the JS Obfuscator: debugProtection: false, debugProtectionInterval: false, disableConsoleOutput: true, - encodeUnicodeLiterals: false, reservedNames: [], rotateUnicodeArray: true, selfDefending: true, sourceMap: false, + sourceMapBaseUrl: '', + sourceMapFileName: '', sourceMapMode: 'separate', unicodeArray: true, - unicodeArrayThreshold: 0.8, - wrapUnicodeArrayCalls: true + unicodeArrayEncoding: false, + unicodeArrayThreshold: 0.8 } ``` @@ -132,15 +140,16 @@ Following options available for the JS Obfuscator: --debugProtection --debugProtectionInterval --disableConsoleOutput - --encodeUnicodeLiterals --reservedNames (comma separated) --rotateUnicodeArray --selfDefending --sourceMap + --sourceMapBaseUrl + --sourceMapFileName --sourceMapMode [inline, separate] --unicodeArray + --unicodeArrayEncoding [true, false, base64, rc4] --unicodeArrayThreshold - --wrapUnicodeArrayCalls ``` ### `compact` @@ -151,9 +160,9 @@ Compact code output on one line. ### `debugProtection` Type: `boolean` Default: `false` -##### :warning: Can freeze browser while Developer Tools are enabled! Use at own risk. +##### :warning: Can freeze your browser if you open the Developer Tools. -Force enable debug mode on page load if Developer Tools panel is enabled (in some, mainly WebKit-based, browsers). This makes it almost impossible to use the Console (the debug panel). +This option makes it almost impossible to use the `console` tab of the Developer Tools (both on WebKit-based and Mozilla Firefox). * WebKit-based: blocks the site window, but you still can navigate through Developer Tools panel. * Firefox: does *not* block the site window, but still won't let you use DevTools. @@ -161,31 +170,27 @@ Force enable debug mode on page load if Developer Tools panel is enabled (in som ### `debugProtectionInterval` Type: `boolean` Default: `false` -##### :warning: Can freeze browser even while Developer Tools are disabled! Use at own risk. +##### :warning: Can freeze your browser! Use at own risk. -Works if `debugProtection` is enabled. - -Force enable debug mode in some browsers (mainly WebKit-based) when Developer Tools panel is enabled, even after page is loaded. +If checked, an interval is used to force the debug mode on the Console tab, making it harder to use other features of the Developer Tools. Works if `debugProtection` is enabled. ### `disableConsoleOutput` Type: `boolean` Default: `true` -Disable `console.log`, `console.info`, `console.error` and `console.warn` messages output into the browser console. +Disables the use of `console.log`, `console.info`, `console.error` and `console.warn` by replacing them with empty functions. This makes the use of the debugger harder. -### `encodeUnicodeLiterals` -Type: `boolean` Default: `false` +### `domainLock` +Type: `string[]` Default: `[]` -##### :warning: `unicodeArray` option must be enabled +Locks the obfuscated source code so it only runs on specific domains and/or sub-domains. This makes really hard for someone just copy and paste your source code and run elsewhere. -This option can slightly slow down your code speed. - -All literals in Unicode array become encoded in Base64. -To decode strings, a special function will be inserted on the page under `unicodeArray` node. +##### Multiple domains and sub-domains +It's possible to lock your code to more than one domain or sub-domain. For instance, to lock it so the code only runs on **www.example.com** add `www.example.com`, to make it work on any sub-domain from example.com, use `.example.com`. ### `reservedNames` Type: `string[]` Default: `[]` -Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp pattern. +Disables the obfuscation of variables names, function names and function parameters that match the Regular Expression used. Example: ```javascript @@ -202,24 +207,55 @@ Type: `boolean` Default: `true` ##### :warning: `unicodeArray` must be enabled -Shift the `unicodeArray` values by a random number of places during the code obfuscation and insert a helper function for shifting the array back into the source code. (It works just like the Caesar cypher.) +Shift the `unicodeArray` array by a fixed and random (generated at the code obfuscation) places. This makes it harder to match the order of the removed strings to their original place. -Keep in mind that this option affects only how the code is visually organised, since the original arrays can be easily accessed during the debug process. +This option is recommended if your original source code isn't small, as the helper function can attract attention. -It is also not recommended to enable `rotateUnicodeArray` for small source code because a helper function might attract attention. ### `selfDefending` Type: `boolean` Default: `true` ##### :warning: this option forcibly set `compact` value to `true` -Enables self-defending for obfuscated code. If obfuscated compact code is formatted, it will not work any more. +This option makes the output code resilient against formatting and variable renaming. If one tries to use a JavaScript beautifier on the obfuscated code, the code won't work anymore, making it harder to understand and modify it. ### `sourceMap` Type: `boolean` Default: `false` Enables source map generation for obfuscated code. +Source maps can be useful to help you debug your obfuscated Java Script source code. If you want or need to debug in production, you can upload the separate source map file to a secret location and then point your browser there. + +### `sourceMapBaseUrl` +Type: `string` Default: `` + +Sets base url to the source map import url when `sourceMapMode: 'separate'`. + +CLI example: +``` +javascript-obfuscator input.js --output out.js --sourceMap true --sourceMapBaseUrl 'http://localhost:9000' +``` + +Result: +``` +//# sourceMappingURL=http://localhost:9000/out.js.map +``` + +### `sourceMapFileName` +Type: `string` Default: `` + +Sets file name for output source map when `sourceMapMode: 'separate'`. + +CLI example: +``` +javascript-obfuscator input.js --output out.js --sourceMap true --sourceMapBaseUrl 'http://localhost:9000' --sourceMapFileName example +``` + +Result: +``` +//# sourceMappingURL=http://localhost:9000/example.js.map +``` + ### `sourceMapMode` Type: `string` Default: `separate` @@ -230,29 +266,34 @@ Specifies source map generation mode: ### `unicodeArray` Type: `boolean` Default: `true` -Put all literal strings into an array and replace every literal string by an array call. +Removes string literals and place them in a special array. For instance the string `"Hello World"` in `var m = "Hello World";` will be replaced with something like `var m = _0x12c456[0x1];` + +### `unicodeArrayEncoding` +Type: `boolean|string` Default: `false` +##### :warning: `unicodeArray` option must be enabled + +This option can slightly slow down your script. + +Encode all string literals of the `unicodeArray` using `base64` or `rc4` and inserts a special code that used to decode it back at runtime. + +Available values: +* `true` (`boolean`): encode `unicodeArray` values using `base64` +* `false` (`boolean`): don't encode `unicodeArray` values +* `'base64'` (`string`): encode `unicodeArray` values using `base64` +* `'rc4'` (`string`): encode `unicodeArray` values using `rc4`. **About 30-35% slower then `base64`, but more harder to get initial values** + ### `unicodeArrayThreshold` Type: `number` Default: `0.8` Min: `0` Max: `1` ##### :warning: `unicodeArray` option must be enabled -The probability that the literal string will be inserted into `unicodeArray`. -Use this option for huge source code size, because many calls to `unicodeArray` will slow down code performance. +You can use this setting to adjust the probability (from 0 to 1) that a string literal will be inserted into the `unicodeArray`. + +This setting is useful with large code size because repeatdely calls to the `Unicode Array` function can slow down your code. `unicodeArrayThreshold: 0` equals to `unicodeArray: false`. -### `wrapUnicodeArrayCalls` -Type: `boolean` Default: `true` - -##### :warning: `unicodeArray` option must be enabled - -Instead of using direct calls to `unicodeArray` items `var t = _0x43a123[0x0]`, when index `0x0` can be easily reverted to `0` with few js beautifiers, this option will wrap all calls to special function instead. - -```javascript -var t = _0x12a634('0x0') -``` - ## License Copyright (C) 2016 [Timofey Kachalov](http://github.com/sanex3339). @@ -274,4 +315,4 @@ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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. \ No newline at end of file +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/bin/javascript-obfuscator.js b/bin/javascript-obfuscator.js index 4fe76f7e..038336d8 100755 --- a/bin/javascript-obfuscator.js +++ b/bin/javascript-obfuscator.js @@ -1,3 +1,7 @@ #!/usr/bin/env node +if (!global._babelPolyfill) { + require('babel-polyfill'); +} + require('../dist/index').runCLI(process.argv); \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 83f46197..a77add99 100644 --- a/dist/index.js +++ b/dist/index.js @@ -88,7 +88,7 @@ module.exports = /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 66); +/******/ return __webpack_require__(__webpack_require__.s = 87); /******/ }) /************************************************************************/ /******/ ([ @@ -98,12 +98,12 @@ module.exports = "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var chance_1 = __webpack_require__(61); -var JSFuck_1 = __webpack_require__(16); +var chance_1 = __webpack_require__(81); +var JSFuck_1 = __webpack_require__(21); var Utils = function () { function Utils() { @@ -135,9 +135,19 @@ var Utils = function () { }, { key: 'btoa', value: function btoa(string) { - var encode = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; - - return new Buffer(encode ? encodeURI(string) : string).toString('base64'); + var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + var output = ''; + string = encodeURIComponent(string).replace(/%([0-9A-F]{2})/g, function (match, p1) { + return String.fromCharCode(parseInt('0x' + p1)); + }); + for (var block, charCode, idx = 0, map = chars; string.charAt(idx | 0) || (map = '=', idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) { + charCode = string.charCodeAt(idx += 3 / 4); + if (charCode > 0xFF) { + throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); + } + block = block << 8 | charCode; + } + return output; } }, { key: 'decToHex', @@ -145,6 +155,18 @@ var Utils = function () { var radix = 16; return Number(dec).toString(radix); } + }, { + key: 'extractDomainFromUrl', + value: function extractDomainFromUrl(url) { + var domain = void 0; + if (url.indexOf('://') > -1 || url.indexOf('//') === 0) { + domain = url.split('/')[2]; + } else { + domain = url.split('/')[0]; + } + domain = domain.split(':')[0]; + return domain; + } }, { key: 'getRandomGenerator', value: function getRandomGenerator() { @@ -153,7 +175,7 @@ var Utils = function () { }, { key: 'getRandomVariableName', value: function getRandomVariableName() { - var length = arguments.length <= 0 || arguments[0] === undefined ? 6 : arguments[0]; + var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 6; var rangeMinInteger = 10000, rangeMaxInteger = 99999999, @@ -163,11 +185,66 @@ var Utils = function () { max: rangeMaxInteger })).substr(0, length); } + }, { + key: 'hideString', + value: function hideString(str, length) { + var escapeRegExp = function escapeRegExp(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + }; + var randomMerge = function randomMerge(s1, s2) { + var i1 = -1, + i2 = -1, + result = ''; + while (i1 < s1.length || i2 < s2.length) { + if (Math.random() < 0.5 && i2 < s2.length) { + result += s2.charAt(++i2); + } else { + result += s1.charAt(++i1); + } + } + return result; + }; + var customPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + var randomString = Utils.randomGenerator.string({ length: length, pool: customPool }), + randomStringDiff = randomString.replace(new RegExp('[' + escapeRegExp(str) + ']', 'g'), ''), + randomStringDiffArray = randomStringDiff.split(''); + Utils.randomGenerator.shuffle(randomStringDiffArray); + randomStringDiff = randomStringDiffArray.join(''); + return [randomMerge(str, randomStringDiff), randomStringDiff]; + } }, { key: 'isInteger', value: function isInteger(number) { return number % 1 === 0; } + }, { + key: 'rc4', + value: function rc4(string, key) { + var s = [], + j = 0, + x = void 0, + result = ''; + for (var i = 0; i < 256; i++) { + s[i] = i; + } + for (i = 0; i < 256; i++) { + j = (j + s[i] + key.charCodeAt(i % key.length)) % 256; + x = s[i]; + s[i] = s[j]; + s[j] = x; + } + i = 0; + j = 0; + for (var y = 0; y < string.length; y++) { + i = (i + 1) % 256; + j = (j + s[i]) % 256; + x = s[i]; + s[i] = s[j]; + s[j] = x; + result += String.fromCharCode(string.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]); + } + return result; + } }, { key: 'strEnumify', value: function strEnumify(obj) { @@ -213,15 +290,15 @@ exports.Utils = Utils; "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var escodegen = __webpack_require__(10); -var esprima = __webpack_require__(18); -var estraverse = __webpack_require__(4); +var escodegen = __webpack_require__(12); +var esprima = __webpack_require__(24); +var estraverse = __webpack_require__(5); var NodeType_1 = __webpack_require__(7); -var Nodes_1 = __webpack_require__(5); +var Nodes_1 = __webpack_require__(2); var Utils_1 = __webpack_require__(0); var NodeUtils = function () { @@ -232,37 +309,27 @@ var NodeUtils = function () { _createClass(NodeUtils, null, [{ key: 'addXVerbatimPropertyToLiterals', value: function addXVerbatimPropertyToLiterals(node) { - estraverse.replace(node, { - enter: function enter(node, parentNode) { - if (Nodes_1.Nodes.isLiteralNode(node)) { - node['x-verbatim-property'] = { - content: node.raw, - precedence: escodegen.Precedence.Primary - }; - } + NodeUtils.typedReplace(node, NodeType_1.NodeType.Literal, { + leave: function leave(node) { + node['x-verbatim-property'] = { + content: node.raw, + precedence: escodegen.Precedence.Primary + }; } }); } - }, { - key: 'appendNode', - value: function appendNode(blockScopeBody, node) { - if (!NodeUtils.validateNode(node)) { - return; - } - blockScopeBody.push(node); - } }, { key: 'convertCodeToStructure', value: function convertCodeToStructure(code) { var structure = esprima.parse(code); NodeUtils.addXVerbatimPropertyToLiterals(structure); NodeUtils.parentize(structure); - return NodeUtils.getBlockStatementNodeByIndex(structure); + return structure.body; } }, { key: 'getBlockStatementNodeByIndex', value: function getBlockStatementNodeByIndex(node) { - var index = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; + var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; if (Nodes_1.Nodes.isNodeHasBlockStatement(node)) { if (node.body[index] === undefined) { @@ -275,7 +342,7 @@ var NodeUtils = function () { }, { key: 'getBlockScopeOfNode', value: function getBlockScopeOfNode(node) { - var depth = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; + var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var parentNode = node.parentNode; if (!parentNode) { @@ -297,14 +364,6 @@ var NodeUtils = function () { } return NodeUtils.getBlockScopeOfNode(parentNode); } - }, { - key: 'insertNodeAtIndex', - value: function insertNodeAtIndex(blockScopeBody, node, index) { - if (!NodeUtils.validateNode(node)) { - return; - } - blockScopeBody.splice(index, 0, node); - } }, { key: 'parentize', value: function parentize(node) { @@ -329,17 +388,27 @@ var NodeUtils = function () { }); } }, { - key: 'prependNode', - value: function prependNode(blockScopeBody, node) { - if (!NodeUtils.validateNode(node)) { - return; - } - blockScopeBody.unshift(node); + key: 'typedReplace', + value: function typedReplace(node, nodeType, visitor) { + NodeUtils.typedTraverse(node, nodeType, visitor, 'replace'); } }, { - key: 'validateNode', - value: function validateNode(node) { - return !!node && node.hasOwnProperty('type'); + key: 'typedTraverse', + value: function typedTraverse(node, nodeType, visitor) { + var traverseType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'traverse'; + + estraverse[traverseType](node, { + enter: function enter(node, parentNode) { + if (node.type === nodeType && visitor.enter) { + visitor.enter(node, parentNode); + } + }, + leave: function leave(node, parentNode) { + if (node.type === nodeType && visitor.leave) { + visitor.leave(node, parentNode); + } + } + }); } }]); @@ -351,6 +420,126 @@ exports.NodeUtils = NodeUtils; /***/ }, /* 2 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var NodeType_1 = __webpack_require__(7); + +var Nodes = function () { + function Nodes() { + _classCallCheck(this, Nodes); + } + + _createClass(Nodes, null, [{ + key: 'getProgramNode', + value: function getProgramNode(bodyNode) { + return { + 'type': NodeType_1.NodeType.Program, + 'body': bodyNode, + 'sourceType': 'script', + 'obfuscated': false + }; + } + }, { + key: 'isArrowFunctionExpressionNode', + value: function isArrowFunctionExpressionNode(node) { + return node.type === NodeType_1.NodeType.ArrowFunctionExpression; + } + }, { + key: 'isBlockStatementNode', + value: function isBlockStatementNode(node) { + return node.type === NodeType_1.NodeType.BlockStatement; + } + }, { + key: 'isCallExpressionNode', + value: function isCallExpressionNode(node) { + return node.type === NodeType_1.NodeType.CallExpression; + } + }, { + key: 'isExpressionStatementNode', + value: function isExpressionStatementNode(node) { + return node.type === NodeType_1.NodeType.ExpressionStatement; + } + }, { + key: 'isFunctionDeclarationNode', + value: function isFunctionDeclarationNode(node) { + return node.type === NodeType_1.NodeType.FunctionDeclaration; + } + }, { + key: 'isFunctionExpressionNode', + value: function isFunctionExpressionNode(node) { + return node.type === NodeType_1.NodeType.FunctionExpression; + } + }, { + key: 'isIdentifierNode', + value: function isIdentifierNode(node) { + return node.type === NodeType_1.NodeType.Identifier; + } + }, { + key: 'isLiteralNode', + value: function isLiteralNode(node) { + return node.type === NodeType_1.NodeType.Literal; + } + }, { + key: 'isMemberExpressionNode', + value: function isMemberExpressionNode(node) { + return node.type === NodeType_1.NodeType.MemberExpression; + } + }, { + key: 'isObjectExpressionNode', + value: function isObjectExpressionNode(node) { + return node.type === NodeType_1.NodeType.ObjectExpression; + } + }, { + key: 'isProgramNode', + value: function isProgramNode(node) { + return node.type === NodeType_1.NodeType.Program; + } + }, { + key: 'isPropertyNode', + value: function isPropertyNode(node) { + return node.type === NodeType_1.NodeType.Property; + } + }, { + key: 'isReplaceableIdentifierNode', + value: function isReplaceableIdentifierNode(node, parentNode) { + if (!Nodes.isIdentifierNode(node)) { + return false; + } + var parentNodeIsPropertyNode = Nodes.isPropertyNode(parentNode) && parentNode.key === node; + var parentNodeIsMemberExpressionNode = Nodes.isMemberExpressionNode(parentNode) && parentNode.computed === false && parentNode.property === node; + return !parentNodeIsPropertyNode && !parentNodeIsMemberExpressionNode; + } + }, { + key: 'isVariableDeclarationNode', + value: function isVariableDeclarationNode(node) { + return node.type === NodeType_1.NodeType.VariableDeclaration; + } + }, { + key: 'isVariableDeclaratorNode', + value: function isVariableDeclaratorNode(node) { + return node.type === NodeType_1.NodeType.VariableDeclarator; + } + }, { + key: 'isNodeHasBlockStatement', + value: function isNodeHasBlockStatement(node) { + return node.hasOwnProperty('body') && Array.isArray(node.body); + } + }]); + + return Nodes; +}(); + +exports.Nodes = Nodes; + +/***/ }, +/* 3 */ /***/ function(module, exports) { "use strict"; @@ -363,24 +552,157 @@ exports.NodeUtils = NodeUtils; var AppendState = exports.AppendState; /***/ }, -/* 3 */ +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Utils_1 = __webpack_require__(0); + +var NodeAppender = function () { + function NodeAppender() { + _classCallCheck(this, NodeAppender); + } + + _createClass(NodeAppender, null, [{ + key: 'appendNode', + value: function appendNode(blockScopeNode, nodeBodyStatements) { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + blockScopeNode.body = [].concat(_toConsumableArray(blockScopeNode.body), _toConsumableArray(nodeBodyStatements)); + } + }, { + key: 'appendNodeToOptimalBlockScope', + value: function appendNodeToOptimalBlockScope(blockScopeStackTraceData, blockScopeNode, nodeBodyStatements) { + var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; + + var targetBlockScope = void 0; + if (!blockScopeStackTraceData.length) { + targetBlockScope = blockScopeNode; + } else { + targetBlockScope = NodeAppender.getOptimalBlockScope(blockScopeStackTraceData, index); + } + NodeAppender.prependNode(targetBlockScope, nodeBodyStatements); + } + }, { + key: 'getOptimalBlockScope', + value: function getOptimalBlockScope(blockScopeTraceData, index) { + var deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity; + + var firstCall = blockScopeTraceData[index]; + if (deep <= 0) { + throw new Error('Invalid `deep` argument value. Value should be bigger then 0.'); + } + if (deep > 1 && firstCall.stackTrace.length) { + return NodeAppender.getOptimalBlockScope(firstCall.stackTrace, 0, --deep); + } else { + return firstCall.callee; + } + } + }, { + key: 'getRandomStackTraceIndex', + value: function getRandomStackTraceIndex(stackTraceRootLength) { + return Utils_1.Utils.getRandomGenerator().integer({ + min: 0, + max: Math.max(0, Math.round(stackTraceRootLength - 1)) + }); + } + }, { + key: 'insertNodeAtIndex', + value: function insertNodeAtIndex(blockScopeNode, nodeBodyStatements, index) { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + blockScopeNode.body = [].concat(_toConsumableArray(blockScopeNode.body.slice(0, index)), _toConsumableArray(nodeBodyStatements), _toConsumableArray(blockScopeNode.body.slice(index))); + } + }, { + key: 'prependNode', + value: function prependNode(blockScopeNode, nodeBodyStatements) { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + blockScopeNode.body = [].concat(_toConsumableArray(nodeBodyStatements), _toConsumableArray(blockScopeNode.body)); + } + }, { + key: 'parentizeBodyStatementsBeforeAppend', + value: function parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements) { + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = nodeBodyStatements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var statement = _step.value; + + statement.parentNode = blockScopeNode; + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return nodeBodyStatements; + } + }, { + key: 'validateBodyStatements', + value: function validateBodyStatements(nodeBodyStatements) { + return nodeBodyStatements.every(function (statementNode) { + return !!statementNode && statementNode.hasOwnProperty('type'); + }); + } + }]); + + return NodeAppender; +}(); + +exports.NodeAppender = NodeAppender; + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + +module.exports = require("estraverse"); + +/***/ }, +/* 6 */ /***/ function(module, exports) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var Node = function () { - function Node(options) { - _classCallCheck(this, Node); +var AbstractCustomNode = function () { + function AbstractCustomNode(options) { + _classCallCheck(this, AbstractCustomNode); this.options = options; } - _createClass(Node, [{ + _createClass(AbstractCustomNode, [{ key: "getAppendState", value: function getAppendState() { return this.appendState; @@ -390,208 +712,17 @@ var Node = function () { value: function getNode() { return this.getNodeStructure(); } - }]); - - return Node; -}(); - -exports.Node = Node; - -/***/ }, -/* 4 */ -/***/ function(module, exports) { - -module.exports = require("estraverse"); - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -"use strict"; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var NodeType_1 = __webpack_require__(7); - -var Nodes = function () { - function Nodes() { - _classCallCheck(this, Nodes); - } - - _createClass(Nodes, null, [{ - key: "getProgramNode", - value: function getProgramNode(bodyNode) { - return { - 'type': NodeType_1.NodeType.Program, - 'body': bodyNode, - 'sourceType': 'script', - 'obfuscated': false - }; - } }, { - key: "isBlockStatementNode", - value: function isBlockStatementNode(node) { - return node.type === NodeType_1.NodeType.BlockStatement; - } - }, { - key: "isCallExpressionNode", - value: function isCallExpressionNode(node) { - return node.type === NodeType_1.NodeType.CallExpression; - } - }, { - key: "isIdentifierNode", - value: function isIdentifierNode(node) { - return node.type === NodeType_1.NodeType.Identifier; - } - }, { - key: "isLiteralNode", - value: function isLiteralNode(node) { - return node.type === NodeType_1.NodeType.Literal; - } - }, { - key: "isMemberExpressionNode", - value: function isMemberExpressionNode(node) { - return node.type === NodeType_1.NodeType.MemberExpression; - } - }, { - key: "isProgramNode", - value: function isProgramNode(node) { - return node.type === NodeType_1.NodeType.Program; - } - }, { - key: "isPropertyNode", - value: function isPropertyNode(node) { - return node.type === NodeType_1.NodeType.Property; - } - }, { - key: "isVariableDeclaratorNode", - value: function isVariableDeclaratorNode(node) { - return node.type === NodeType_1.NodeType.VariableDeclarator; - } - }, { - key: "isNodeHasBlockStatement", - value: function isNodeHasBlockStatement(node) { - return node.hasOwnProperty('body') && Array.isArray(node.body); + key: "setAppendState", + value: function setAppendState(appendState) { + this.appendState = appendState; } }]); - return Nodes; + return AbstractCustomNode; }(); -exports.Nodes = Nodes; - -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -"use strict"; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var JSFuck_1 = __webpack_require__(16); -var Nodes_1 = __webpack_require__(5); -var Utils_1 = __webpack_require__(0); - -var NodeObfuscator = function () { - function NodeObfuscator(nodes, options) { - _classCallCheck(this, NodeObfuscator); - - this.nodes = nodes; - this.options = options; - } - - _createClass(NodeObfuscator, [{ - key: "isReservedName", - value: function isReservedName(name) { - return this.options.reservedNames.some(function (reservedName) { - return new RegExp(reservedName, 'g').test(name); - }); - } - }, { - key: "storeIdentifiersNames", - value: function storeIdentifiersNames(node, namesMap) { - if (Nodes_1.Nodes.isIdentifierNode(node) && !this.isReservedName(node.name)) { - namesMap.set(node.name, Utils_1.Utils.getRandomVariableName()); - } - } - }, { - key: "replaceIdentifiersWithRandomNames", - value: function replaceIdentifiersWithRandomNames(node, parentNode, namesMap) { - if (Nodes_1.Nodes.isIdentifierNode(node) && namesMap.has(node.name)) { - var parentNodeIsPropertyNode = Nodes_1.Nodes.isPropertyNode(parentNode) && parentNode.key === node, - parentNodeIsMemberExpressionNode = Nodes_1.Nodes.isMemberExpressionNode(parentNode) && parentNode.computed === false && parentNode.property === node; - if (parentNodeIsPropertyNode || parentNodeIsMemberExpressionNode) { - return; - } - node.name = namesMap.get(node.name); - } - } - }, { - key: "replaceLiteralBooleanWithJSFuck", - value: function replaceLiteralBooleanWithJSFuck(nodeValue) { - return nodeValue ? JSFuck_1.JSFuck.True : JSFuck_1.JSFuck.False; - } - }, { - key: "replaceLiteralNumberWithHexadecimalValue", - value: function replaceLiteralNumberWithHexadecimalValue(nodeValue) { - var prefix = '0x'; - if (!Utils_1.Utils.isInteger(nodeValue)) { - return String(nodeValue); - } - return "" + prefix + Utils_1.Utils.decToHex(nodeValue); - } - }, { - key: "replaceLiteralValueWithUnicodeValue", - value: function replaceLiteralValueWithUnicodeValue(nodeValue) { - var replaceWithUnicodeArrayFlag = Math.random() <= this.options.unicodeArrayThreshold; - if (this.options.encodeUnicodeLiterals && replaceWithUnicodeArrayFlag) { - nodeValue = Utils_1.Utils.btoa(nodeValue); - } - nodeValue = Utils_1.Utils.stringToUnicode(nodeValue); - if (this.options.unicodeArray && replaceWithUnicodeArrayFlag) { - return this.replaceLiteralValueWithUnicodeArrayCall(nodeValue); - } - return nodeValue; - } - }, { - key: "replaceLiteralValueWithUnicodeArrayCall", - value: function replaceLiteralValueWithUnicodeArrayCall(value) { - var unicodeArrayNode = this.nodes.get('unicodeArrayNode'); - if (!unicodeArrayNode) { - throw new ReferenceError('`unicodeArrayNode` node is not found in Map with custom nodes.'); - } - var unicodeArray = unicodeArrayNode.getNodeData(), - valueIndex = unicodeArray.indexOf(value), - literalValueCallIndex = void 0, - hexadecimalIndex = void 0; - if (valueIndex >= 0) { - literalValueCallIndex = valueIndex; - } else { - literalValueCallIndex = unicodeArray.length; - unicodeArrayNode.updateNodeData(value); - } - hexadecimalIndex = this.replaceLiteralNumberWithHexadecimalValue(literalValueCallIndex); - if (this.options.wrapUnicodeArrayCalls) { - var unicodeArrayCallsWrapper = this.nodes.get('unicodeArrayCallsWrapper'); - if (!unicodeArrayCallsWrapper) { - throw new ReferenceError('`unicodeArrayCallsWrapper` node is not found in Map with custom nodes.'); - } - return unicodeArrayCallsWrapper.getNodeIdentifier() + "('" + hexadecimalIndex + "')"; - } - return unicodeArrayNode.getNodeIdentifier() + "[" + hexadecimalIndex + "]"; - } - }]); - - return NodeObfuscator; -}(); - -exports.NodeObfuscator = NodeObfuscator; +exports.AbstractCustomNode = AbstractCustomNode; /***/ }, /* 7 */ @@ -639,17 +770,35 @@ module.exports = require("format-unicorn"); /***/ }, /* 9 */ +/***/ function(module, exports) { + +"use strict"; +"use strict"; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var AbstractNodeObfuscator = function AbstractNodeObfuscator(nodes, options) { + _classCallCheck(this, AbstractNodeObfuscator); + + this.nodes = nodes; + this.options = options; +}; + +exports.AbstractNodeObfuscator = AbstractNodeObfuscator; + +/***/ }, +/* 10 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var JavaScriptObfuscatorCLI_1 = __webpack_require__(24); -var JavaScriptObfuscatorInternal_1 = __webpack_require__(14); +var JavaScriptObfuscatorCLI_1 = __webpack_require__(32); +var JavaScriptObfuscatorInternal_1 = __webpack_require__(27); var JavaScriptObfuscator = function () { function JavaScriptObfuscator() { @@ -657,16 +806,16 @@ var JavaScriptObfuscator = function () { } _createClass(JavaScriptObfuscator, null, [{ - key: "obfuscate", + key: 'obfuscate', value: function obfuscate(sourceCode) { - var obfuscatorOptions = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var obfuscatorOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var javaScriptObfuscator = new JavaScriptObfuscatorInternal_1.JavaScriptObfuscatorInternal(sourceCode, obfuscatorOptions); javaScriptObfuscator.obfuscate(); return javaScriptObfuscator.getObfuscationResult(); } }, { - key: "runCLI", + key: 'runCLI', value: function runCLI(argv) { new JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI(argv).run(); } @@ -678,13 +827,52 @@ var JavaScriptObfuscator = function () { exports.JavaScriptObfuscator = JavaScriptObfuscator; /***/ }, -/* 10 */ +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var AppendState_1 = __webpack_require__(3); + +var AbstractNodesGroup = function () { + function AbstractNodesGroup(stackTraceData, options) { + _classCallCheck(this, AbstractNodesGroup); + + this.appendState = AppendState_1.AppendState.BeforeObfuscation; + this.stackTraceData = stackTraceData; + this.options = options; + } + + _createClass(AbstractNodesGroup, [{ + key: "syncCustomNodesWithNodesGroup", + value: function syncCustomNodesWithNodesGroup(customNodes) { + var _this = this; + + customNodes.forEach(function (node) { + node.setAppendState(_this.appendState); + }); + return customNodes; + } + }]); + + return AbstractNodesGroup; +}(); + +exports.AbstractNodesGroup = AbstractNodesGroup; + +/***/ }, +/* 12 */ /***/ function(module, exports) { module.exports = require("escodegen"); /***/ }, -/* 11 */ +/* 13 */ /***/ function(module, exports) { "use strict"; @@ -696,143 +884,285 @@ exports.SourceMapMode = { }; /***/ }, -/* 12 */ +/* 14 */ /***/ function(module, exports) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var NodesGroup = function () { - function NodesGroup(options) { - _classCallCheck(this, NodesGroup); +var AbstractReplacer = function AbstractReplacer(nodes, options) { + _classCallCheck(this, AbstractReplacer); - this.nodes = new Map(); - this.options = options; - } + this.nodes = nodes; + this.options = options; +}; - _createClass(NodesGroup, [{ - key: "getNodes", - value: function getNodes() { - return this.nodes; - } - }]); - - return NodesGroup; -}(); - -exports.NodesGroup = NodesGroup; +exports.AbstractReplacer = AbstractReplacer; /***/ }, -/* 13 */ +/* 15 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var SourceMapMode_1 = __webpack_require__(11); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var AbstractReplacer_1 = __webpack_require__(14); +var Utils_1 = __webpack_require__(0); + +var IdentifierReplacer = function (_AbstractReplacer_1$A) { + _inherits(IdentifierReplacer, _AbstractReplacer_1$A); + + function IdentifierReplacer() { + _classCallCheck(this, IdentifierReplacer); + + var _this = _possibleConstructorReturn(this, (IdentifierReplacer.__proto__ || Object.getPrototypeOf(IdentifierReplacer)).apply(this, arguments)); + + _this.namesMap = new Map(); + return _this; + } + + _createClass(IdentifierReplacer, [{ + key: 'replace', + value: function replace(nodeValue) { + var obfuscatedIdentifierName = this.namesMap.get(nodeValue); + if (!obfuscatedIdentifierName) { + return nodeValue; + } + return obfuscatedIdentifierName; + } + }, { + key: 'storeNames', + value: function storeNames(nodeName) { + if (!this.isReservedName(nodeName)) { + this.namesMap.set(nodeName, Utils_1.Utils.getRandomVariableName()); + } + } + }, { + key: 'isReservedName', + value: function isReservedName(name) { + return this.options.reservedNames.some(function (reservedName) { + return new RegExp(reservedName, 'g').test(name); + }); + } + }]); + + return IdentifierReplacer; +}(AbstractReplacer_1.AbstractReplacer); + +exports.IdentifierReplacer = IdentifierReplacer; + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var SourceMapMode_1 = __webpack_require__(13); exports.NO_CUSTOM_NODES_PRESET = Object.freeze({ compact: true, debugProtection: false, debugProtectionInterval: false, disableConsoleOutput: false, - encodeUnicodeLiterals: false, + domainLock: [], reservedNames: [], rotateUnicodeArray: false, selfDefending: false, sourceMap: false, + sourceMapBaseUrl: '', + sourceMapFileName: '', sourceMapMode: SourceMapMode_1.SourceMapMode.Separate, unicodeArray: false, - unicodeArrayThreshold: 0, - wrapUnicodeArrayCalls: false + unicodeArrayEncoding: false, + unicodeArrayThreshold: 0 }); /***/ }, -/* 14 */ +/* 17 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var esprima = __webpack_require__(18); -var escodegen = __webpack_require__(10); -var ObfuscationResult_1 = __webpack_require__(15); -var Obfuscator_1 = __webpack_require__(21); -var Options_1 = __webpack_require__(46); -var SourceMapCorrector_1 = __webpack_require__(22); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -var JavaScriptObfuscatorInternal = function () { - function JavaScriptObfuscatorInternal(sourceCode, obfuscatorOptions) { - _classCallCheck(this, JavaScriptObfuscatorInternal); +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - this.sourceMapUrl = ''; - this.sourceCode = sourceCode; - if (obfuscatorOptions) { - this.options = new Options_1.Options(obfuscatorOptions); - } +__webpack_require__(8); +var AppendState_1 = __webpack_require__(3); +var SingleNodeCallControllerTemplate_1 = __webpack_require__(65); +var NoCustomNodesPreset_1 = __webpack_require__(16); +var AbstractCustomNode_1 = __webpack_require__(6); +var JavaScriptObfuscator_1 = __webpack_require__(10); +var NodeAppender_1 = __webpack_require__(4); +var NodeUtils_1 = __webpack_require__(1); + +var NodeCallsControllerFunctionNode = function (_AbstractCustomNode_) { + _inherits(NodeCallsControllerFunctionNode, _AbstractCustomNode_); + + function NodeCallsControllerFunctionNode(stackTraceData, callsControllerFunctionName, randomStackTraceIndex, options) { + _classCallCheck(this, NodeCallsControllerFunctionNode); + + var _this = _possibleConstructorReturn(this, (NodeCallsControllerFunctionNode.__proto__ || Object.getPrototypeOf(NodeCallsControllerFunctionNode)).call(this, options)); + + _this.appendState = AppendState_1.AppendState.BeforeObfuscation; + _this.stackTraceData = stackTraceData; + _this.callsControllerFunctionName = callsControllerFunctionName; + _this.randomStackTraceIndex = randomStackTraceIndex; + return _this; } - _createClass(JavaScriptObfuscatorInternal, [{ - key: 'getObfuscationResult', - value: function getObfuscationResult() { - return new SourceMapCorrector_1.SourceMapCorrector(new ObfuscationResult_1.ObfuscationResult(this.generatorOutput.code, this.generatorOutput.map), this.sourceMapUrl, this.options.sourceMapMode).correct(); - } - }, { - key: 'obfuscate', - value: function obfuscate() { - var astTree = esprima.parse(this.sourceCode, { - loc: true - }); - astTree = new Obfuscator_1.Obfuscator(this.options).obfuscateNode(astTree); - this.generatorOutput = JavaScriptObfuscatorInternal.generateCode(this.sourceCode, astTree, this.options); - } - }, { - key: 'setSourceMapUrl', - value: function setSourceMapUrl(url) { - this.sourceMapUrl = url; - } - }], [{ - key: 'generateCode', - value: function generateCode(sourceCode, astTree, options) { - var escodegenParams = Object.assign({}, JavaScriptObfuscatorInternal.escodegenParams), - generatorOutput = void 0; - if (options.sourceMap) { - escodegenParams.sourceMap = 'sourceMap'; - escodegenParams.sourceContent = sourceCode; + _createClass(NodeCallsControllerFunctionNode, [{ + key: 'appendNode', + value: function appendNode(blockScopeNode) { + var targetBlockScope = void 0; + if (this.stackTraceData.length) { + targetBlockScope = NodeAppender_1.NodeAppender.getOptimalBlockScope(this.stackTraceData, this.randomStackTraceIndex, 1); + } else { + targetBlockScope = blockScopeNode; } - escodegenParams.format = { - compact: options.compact - }; - generatorOutput = escodegen.generate(astTree, escodegenParams); - generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : ''; - return generatorOutput; + NodeAppender_1.NodeAppender.prependNode(targetBlockScope, this.getNode()); + } + }, { + key: 'getNodeStructure', + value: function getNodeStructure() { + if (this.appendState === AppendState_1.AppendState.AfterObfuscation) { + return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(SingleNodeCallControllerTemplate_1.SingleNodeCallControllerTemplate().formatUnicorn({ + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }), NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET).getObfuscatedCode()); + } + return NodeUtils_1.NodeUtils.convertCodeToStructure(SingleNodeCallControllerTemplate_1.SingleNodeCallControllerTemplate().formatUnicorn({ + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + })); } }]); - return JavaScriptObfuscatorInternal; -}(); + return NodeCallsControllerFunctionNode; +}(AbstractCustomNode_1.AbstractCustomNode); -JavaScriptObfuscatorInternal.escodegenParams = { - verbatim: 'x-verbatim-property', - sourceMapWithCode: true -}; -exports.JavaScriptObfuscatorInternal = JavaScriptObfuscatorInternal; +exports.NodeCallsControllerFunctionNode = NodeCallsControllerFunctionNode; /***/ }, -/* 15 */ +/* 18 */ /***/ function(module, exports) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +exports.UnicodeArrayEncoding = { + base64: 'base64', + rc4: 'rc4' +}; + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var UnicodeArrayEncoding_1 = __webpack_require__(18); +var AbstractReplacer_1 = __webpack_require__(14); +var NumberLiteralReplacer_1 = __webpack_require__(22); +var Utils_1 = __webpack_require__(0); + +var StringLiteralReplacer = function (_AbstractReplacer_1$A) { + _inherits(StringLiteralReplacer, _AbstractReplacer_1$A); + + function StringLiteralReplacer() { + _classCallCheck(this, StringLiteralReplacer); + + return _possibleConstructorReturn(this, (StringLiteralReplacer.__proto__ || Object.getPrototypeOf(StringLiteralReplacer)).apply(this, arguments)); + } + + _createClass(StringLiteralReplacer, [{ + key: 'replace', + value: function replace(nodeValue) { + var replaceWithUnicodeArrayFlag = nodeValue.length >= StringLiteralReplacer.minimumLengthForUnicodeArray && Math.random() <= this.options.unicodeArrayThreshold; + if (this.options.unicodeArray && replaceWithUnicodeArrayFlag) { + return this.replaceStringLiteralWithUnicodeArrayCall(nodeValue); + } + return Utils_1.Utils.stringToUnicode(nodeValue); + } + }, { + key: 'replaceStringLiteralWithUnicodeArrayCall', + value: function replaceStringLiteralWithUnicodeArrayCall(value) { + var unicodeArrayNode = this.nodes.get('unicodeArrayNode'); + if (!unicodeArrayNode) { + throw new ReferenceError('`unicodeArrayNode` node is not found in Map with custom nodes.'); + } + var rc4Key = ''; + switch (this.options.unicodeArrayEncoding) { + case UnicodeArrayEncoding_1.UnicodeArrayEncoding.base64: + value = Utils_1.Utils.btoa(value); + break; + case UnicodeArrayEncoding_1.UnicodeArrayEncoding.rc4: + rc4Key = Utils_1.Utils.getRandomGenerator().pickone(StringLiteralReplacer.rc4Keys); + value = Utils_1.Utils.btoa(Utils_1.Utils.rc4(value, rc4Key)); + break; + } + value = Utils_1.Utils.stringToUnicode(value); + var unicodeArray = unicodeArrayNode.getNodeData(), + indexOfExistingValue = unicodeArray.getIndexOf(value), + indexOfValue = void 0, + hexadecimalIndex = void 0; + if (indexOfExistingValue >= 0) { + indexOfValue = indexOfExistingValue; + } else { + indexOfValue = unicodeArray.getLength(); + unicodeArrayNode.updateNodeData(value); + } + hexadecimalIndex = new NumberLiteralReplacer_1.NumberLiteralReplacer(this.nodes, this.options).replace(indexOfValue); + var unicodeArrayCallsWrapper = this.nodes.get('unicodeArrayCallsWrapper'); + if (!unicodeArrayCallsWrapper) { + throw new ReferenceError('`unicodeArrayCallsWrapper` node is not found in Map with custom nodes.'); + } + if (this.options.unicodeArrayEncoding === UnicodeArrayEncoding_1.UnicodeArrayEncoding.rc4) { + return unicodeArrayCallsWrapper.getNodeIdentifier() + '(\'' + hexadecimalIndex + '\', ' + Utils_1.Utils.stringToUnicode(rc4Key) + ')'; + } + return unicodeArrayCallsWrapper.getNodeIdentifier() + '(\'' + hexadecimalIndex + '\')'; + } + }]); + + return StringLiteralReplacer; +}(AbstractReplacer_1.AbstractReplacer); + +StringLiteralReplacer.minimumLengthForUnicodeArray = 3; +StringLiteralReplacer.rc4Keys = Utils_1.Utils.getRandomGenerator().n(function () { + return Utils_1.Utils.getRandomGenerator().string({ length: 4 }); +}, 50); +exports.StringLiteralReplacer = StringLiteralReplacer; + +/***/ }, +/* 20 */ +/***/ function(module, exports) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -867,7 +1197,7 @@ var ObfuscationResult = function () { exports.ObfuscationResult = ObfuscationResult; /***/ }, -/* 16 */ +/* 21 */ /***/ function(module, exports) { "use strict"; @@ -932,85 +1262,199 @@ exports.JSFuck = { }; /***/ }, -/* 17 */ +/* 22 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var SourceMapMode_1 = __webpack_require__(11); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var AbstractReplacer_1 = __webpack_require__(14); +var Utils_1 = __webpack_require__(0); + +var NumberLiteralReplacer = function (_AbstractReplacer_1$A) { + _inherits(NumberLiteralReplacer, _AbstractReplacer_1$A); + + function NumberLiteralReplacer() { + _classCallCheck(this, NumberLiteralReplacer); + + return _possibleConstructorReturn(this, (NumberLiteralReplacer.__proto__ || Object.getPrototypeOf(NumberLiteralReplacer)).apply(this, arguments)); + } + + _createClass(NumberLiteralReplacer, [{ + key: 'replace', + value: function replace(nodeValue) { + var prefix = '0x'; + if (!Utils_1.Utils.isInteger(nodeValue)) { + return String(nodeValue); + } + return '' + prefix + Utils_1.Utils.decToHex(nodeValue); + } + }]); + + return NumberLiteralReplacer; +}(AbstractReplacer_1.AbstractReplacer); + +exports.NumberLiteralReplacer = NumberLiteralReplacer; + +/***/ }, +/* 23 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var SourceMapMode_1 = __webpack_require__(13); exports.DEFAULT_PRESET = Object.freeze({ compact: true, debugProtection: false, debugProtectionInterval: false, disableConsoleOutput: true, - encodeUnicodeLiterals: false, + domainLock: [], reservedNames: [], rotateUnicodeArray: true, selfDefending: true, sourceMap: false, + sourceMapBaseUrl: '', + sourceMapFileName: '', sourceMapMode: SourceMapMode_1.SourceMapMode.Separate, unicodeArray: true, - unicodeArrayThreshold: 0.8, - wrapUnicodeArrayCalls: true + unicodeArrayEncoding: false, + unicodeArrayThreshold: 0.8 }); /***/ }, -/* 18 */ +/* 24 */ /***/ function(module, exports) { module.exports = require("esprima"); /***/ }, -/* 19 */ +/* 25 */ /***/ function(module, exports) { module.exports = require("path"); /***/ }, -/* 20 */ +/* 26 */ /***/ function(module, exports) { module.exports = require("babel-polyfill"); /***/ }, -/* 21 */ +/* 27 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var esprima = __webpack_require__(24); +var escodegen = __webpack_require__(12); +var ObfuscationResult_1 = __webpack_require__(20); +var Obfuscator_1 = __webpack_require__(28); +var Options_1 = __webpack_require__(56); +var SourceMapCorrector_1 = __webpack_require__(29); + +var JavaScriptObfuscatorInternal = function () { + function JavaScriptObfuscatorInternal(sourceCode) { + var obfuscatorOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _classCallCheck(this, JavaScriptObfuscatorInternal); + + this.sourceCode = sourceCode; + this.options = new Options_1.Options(obfuscatorOptions); + } + + _createClass(JavaScriptObfuscatorInternal, [{ + key: 'getObfuscationResult', + value: function getObfuscationResult() { + return new SourceMapCorrector_1.SourceMapCorrector(new ObfuscationResult_1.ObfuscationResult(this.generatorOutput.code, this.generatorOutput.map), this.options.sourceMapBaseUrl + this.options.sourceMapFileName, this.options.sourceMapMode).correct(); + } + }, { + key: 'obfuscate', + value: function obfuscate() { + var astTree = esprima.parse(this.sourceCode, { + loc: true + }); + astTree = new Obfuscator_1.Obfuscator(this.options).obfuscateNode(astTree); + this.generatorOutput = JavaScriptObfuscatorInternal.generateCode(this.sourceCode, astTree, this.options); + } + }], [{ + key: 'generateCode', + value: function generateCode(sourceCode, astTree, options) { + var escodegenParams = Object.assign({}, JavaScriptObfuscatorInternal.escodegenParams); + if (options.sourceMap) { + escodegenParams.sourceMap = 'sourceMap'; + escodegenParams.sourceContent = sourceCode; + } + escodegenParams.format = { + compact: options.compact + }; + var generatorOutput = escodegen.generate(astTree, escodegenParams); + generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : ''; + return generatorOutput; + } + }]); + + return JavaScriptObfuscatorInternal; +}(); + +JavaScriptObfuscatorInternal.escodegenParams = { + verbatim: 'x-verbatim-property', + sourceMapWithCode: true +}; +exports.JavaScriptObfuscatorInternal = JavaScriptObfuscatorInternal; + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var estraverse = __webpack_require__(4); -var AppendState_1 = __webpack_require__(2); +var estraverse = __webpack_require__(5); +var AppendState_1 = __webpack_require__(3); var NodeType_1 = __webpack_require__(7); -var CatchClauseObfuscator_1 = __webpack_require__(38); -var ConsoleOutputNodesGroup_1 = __webpack_require__(34); -var DebugProtectionNodesGroup_1 = __webpack_require__(35); -var FunctionDeclarationObfuscator_1 = __webpack_require__(39); -var FunctionObfuscator_1 = __webpack_require__(40); -var LiteralObfuscator_1 = __webpack_require__(41); -var MemberExpressionObfuscator_1 = __webpack_require__(42); -var MethodDefinitionObfuscator_1 = __webpack_require__(43); -var Nodes_1 = __webpack_require__(5); +var CatchClauseObfuscator_1 = __webpack_require__(47); +var ConsoleOutputNodesGroup_1 = __webpack_require__(42); +var DebugProtectionNodesGroup_1 = __webpack_require__(43); +var DomainLockNodesGroup_1 = __webpack_require__(44); +var FunctionDeclarationObfuscator_1 = __webpack_require__(48); +var FunctionObfuscator_1 = __webpack_require__(49); +var LiteralObfuscator_1 = __webpack_require__(50); +var MemberExpressionObfuscator_1 = __webpack_require__(51); +var MethodDefinitionObfuscator_1 = __webpack_require__(52); +var Nodes_1 = __webpack_require__(2); var NodeUtils_1 = __webpack_require__(1); -var ObjectExpressionObfuscator_1 = __webpack_require__(44); -var SelfDefendingNodesGroup_1 = __webpack_require__(36); -var UnicodeArrayNodesGroup_1 = __webpack_require__(37); -var VariableDeclarationObfuscator_1 = __webpack_require__(45); +var ObjectExpressionObfuscator_1 = __webpack_require__(53); +var SelfDefendingNodesGroup_1 = __webpack_require__(45); +var UnicodeArrayNodesGroup_1 = __webpack_require__(46); +var VariableDeclarationObfuscator_1 = __webpack_require__(54); +var StackTraceAnalyzer_1 = __webpack_require__(59); var Obfuscator = function () { function Obfuscator(options) { _classCallCheck(this, Obfuscator); - this.nodeObfuscators = new Map([[NodeType_1.NodeType.ArrowFunctionExpression, [FunctionObfuscator_1.FunctionObfuscator]], [NodeType_1.NodeType.ClassDeclaration, [FunctionDeclarationObfuscator_1.FunctionDeclarationObfuscator]], [NodeType_1.NodeType.CatchClause, [CatchClauseObfuscator_1.CatchClauseObfuscator]], [NodeType_1.NodeType.FunctionDeclaration, [FunctionDeclarationObfuscator_1.FunctionDeclarationObfuscator, FunctionObfuscator_1.FunctionObfuscator]], [NodeType_1.NodeType.FunctionExpression, [FunctionObfuscator_1.FunctionObfuscator]], [NodeType_1.NodeType.MemberExpression, [MemberExpressionObfuscator_1.MemberExpressionObfuscator]], [NodeType_1.NodeType.MethodDefinition, [MethodDefinitionObfuscator_1.MethodDefinitionObfuscator]], [NodeType_1.NodeType.ObjectExpression, [ObjectExpressionObfuscator_1.ObjectExpressionObfuscator]], [NodeType_1.NodeType.VariableDeclaration, [VariableDeclarationObfuscator_1.VariableDeclarationObfuscator]], [NodeType_1.NodeType.Literal, [LiteralObfuscator_1.LiteralObfuscator]]]); + this.customNodes = new Map(); this.options = options; - this.nodes = new Map([].concat(_toConsumableArray(new SelfDefendingNodesGroup_1.SelfDefendingNodesGroup(this.options).getNodes()), _toConsumableArray(new ConsoleOutputNodesGroup_1.ConsoleOutputNodesGroup(this.options).getNodes()), _toConsumableArray(new DebugProtectionNodesGroup_1.DebugProtectionNodesGroup(this.options).getNodes()), _toConsumableArray(new UnicodeArrayNodesGroup_1.UnicodeArrayNodesGroup(this.options).getNodes()))); } _createClass(Obfuscator, [{ @@ -1020,6 +1464,8 @@ var Obfuscator = function () { return node; } NodeUtils_1.NodeUtils.parentize(node); + var stackTraceData = new StackTraceAnalyzer_1.StackTraceAnalyzer(node.body).analyze(); + this.initializeCustomNodes(stackTraceData); this.beforeObfuscation(node); this.obfuscate(node); this.afterObfuscation(node); @@ -1028,7 +1474,7 @@ var Obfuscator = function () { }, { key: 'afterObfuscation', value: function afterObfuscation(astTree) { - this.nodes.forEach(function (node) { + this.customNodes.forEach(function (node) { if (node.getAppendState() === AppendState_1.AppendState.AfterObfuscation) { node.appendNode(astTree); } @@ -1037,33 +1483,46 @@ var Obfuscator = function () { }, { key: 'beforeObfuscation', value: function beforeObfuscation(astTree) { - this.nodes.forEach(function (node) { + this.customNodes.forEach(function (node) { if (node.getAppendState() === AppendState_1.AppendState.BeforeObfuscation) { node.appendNode(astTree); } }); } }, { - key: 'initializeNodeObfuscators', - value: function initializeNodeObfuscators(node, parentNode) { + key: 'initializeCustomNodes', + value: function initializeCustomNodes(stackTraceData) { var _this = this; - var nodeObfuscators = this.nodeObfuscators.get(node.type); + Obfuscator.nodeGroups.forEach(function (nodeGroupConstructor) { + var nodeGroupNodes = new nodeGroupConstructor(stackTraceData, _this.options).getNodes(); + if (!nodeGroupNodes) { + return; + } + _this.customNodes = new Map([].concat(_toConsumableArray(_this.customNodes), _toConsumableArray(nodeGroupNodes))); + }); + } + }, { + key: 'initializeNodeObfuscators', + value: function initializeNodeObfuscators(node, parentNode) { + var _this2 = this; + + var nodeObfuscators = Obfuscator.nodeObfuscators.get(node.type); if (!nodeObfuscators) { return; } nodeObfuscators.forEach(function (obfuscator) { - new obfuscator(_this.nodes, _this.options).obfuscateNode(node, parentNode); + new obfuscator(_this2.customNodes, _this2.options).obfuscateNode(node, parentNode); }); } }, { key: 'obfuscate', value: function obfuscate(node) { - var _this2 = this; + var _this3 = this; estraverse.replace(node, { enter: function enter(node, parentNode) { - _this2.initializeNodeObfuscators(node, parentNode); + _this3.initializeNodeObfuscators(node, parentNode); } }); } @@ -1072,21 +1531,23 @@ var Obfuscator = function () { return Obfuscator; }(); +Obfuscator.nodeGroups = [DomainLockNodesGroup_1.DomainLockNodesGroup, SelfDefendingNodesGroup_1.SelfDefendingNodesGroup, ConsoleOutputNodesGroup_1.ConsoleOutputNodesGroup, DebugProtectionNodesGroup_1.DebugProtectionNodesGroup, UnicodeArrayNodesGroup_1.UnicodeArrayNodesGroup]; +Obfuscator.nodeObfuscators = new Map([[NodeType_1.NodeType.ArrowFunctionExpression, [FunctionObfuscator_1.FunctionObfuscator]], [NodeType_1.NodeType.ClassDeclaration, [FunctionDeclarationObfuscator_1.FunctionDeclarationObfuscator]], [NodeType_1.NodeType.CatchClause, [CatchClauseObfuscator_1.CatchClauseObfuscator]], [NodeType_1.NodeType.FunctionDeclaration, [FunctionDeclarationObfuscator_1.FunctionDeclarationObfuscator, FunctionObfuscator_1.FunctionObfuscator]], [NodeType_1.NodeType.FunctionExpression, [FunctionObfuscator_1.FunctionObfuscator]], [NodeType_1.NodeType.MemberExpression, [MemberExpressionObfuscator_1.MemberExpressionObfuscator]], [NodeType_1.NodeType.MethodDefinition, [MethodDefinitionObfuscator_1.MethodDefinitionObfuscator]], [NodeType_1.NodeType.ObjectExpression, [ObjectExpressionObfuscator_1.ObjectExpressionObfuscator]], [NodeType_1.NodeType.VariableDeclaration, [VariableDeclarationObfuscator_1.VariableDeclarationObfuscator]], [NodeType_1.NodeType.Literal, [LiteralObfuscator_1.LiteralObfuscator]]]); exports.Obfuscator = Obfuscator; /***/ }, -/* 22 */ +/* 29 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var SourceMapMode_1 = __webpack_require__(11); -var ObfuscationResult_1 = __webpack_require__(15); +var SourceMapMode_1 = __webpack_require__(13); +var ObfuscationResult_1 = __webpack_require__(20); var Utils_1 = __webpack_require__(0); var SourceMapCorrector = function () { @@ -1100,12 +1561,12 @@ var SourceMapCorrector = function () { } _createClass(SourceMapCorrector, [{ - key: "correct", + key: 'correct', value: function correct() { - return new ObfuscationResult_1.ObfuscationResult(this.correctObfuscatedCode(), this.correctSourceMap()); + return new ObfuscationResult_1.ObfuscationResult(this.correctObfuscatedCode(), this.sourceMap); } }, { - key: "correctObfuscatedCode", + key: 'correctObfuscatedCode', value: function correctObfuscatedCode() { if (!this.sourceMap) { return this.obfuscatedCode; @@ -1113,25 +1574,17 @@ var SourceMapCorrector = function () { var sourceMappingUrl = '//# sourceMappingURL='; switch (this.sourceMapMode) { case SourceMapMode_1.SourceMapMode.Inline: - sourceMappingUrl += "data:application/json;base64," + Utils_1.Utils.btoa(this.sourceMapUrl || this.sourceMap, false); + sourceMappingUrl += 'data:application/json;base64,' + Utils_1.Utils.btoa(this.sourceMap); break; case SourceMapMode_1.SourceMapMode.Separate: default: - if (this.sourceMapUrl) { - sourceMappingUrl += this.sourceMapUrl; - break; + if (!this.sourceMapUrl) { + return this.obfuscatedCode; } - return this.obfuscatedCode; + sourceMappingUrl += this.sourceMapUrl; + break; } - return this.obfuscatedCode + "\n" + sourceMappingUrl; - } - }, { - key: "correctSourceMap", - value: function correctSourceMap() { - if (this.sourceMapMode === SourceMapMode_1.SourceMapMode.Inline) { - return ''; - } - return this.sourceMap; + return this.obfuscatedCode + '\n' + sourceMappingUrl; } }]); @@ -1141,19 +1594,76 @@ var SourceMapCorrector = function () { exports.SourceMapCorrector = SourceMapCorrector; /***/ }, -/* 23 */ +/* 30 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var fs = __webpack_require__(64); -var mkdirp = __webpack_require__(65); -var path = __webpack_require__(19); +var Utils_1 = __webpack_require__(0); + +var UnicodeArray = function () { + function UnicodeArray() { + _classCallCheck(this, UnicodeArray); + + this.array = []; + } + + _createClass(UnicodeArray, [{ + key: "addToArray", + value: function addToArray(value) { + this.array.push(value); + } + }, { + key: "getArray", + value: function getArray() { + return this.array; + } + }, { + key: "getIndexOf", + value: function getIndexOf(value) { + return this.array.indexOf(value); + } + }, { + key: "getLength", + value: function getLength() { + return this.array.length; + } + }, { + key: "rotateArray", + value: function rotateArray(rotationValue) { + this.array = Utils_1.Utils.arrayRotate(this.array, rotationValue); + } + }, { + key: "toString", + value: function toString() { + return this.array.toString(); + } + }]); + + return UnicodeArray; +}(); + +exports.UnicodeArray = UnicodeArray; + +/***/ }, +/* 31 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var fs = __webpack_require__(84); +var mkdirp = __webpack_require__(85); +var path = __webpack_require__(25); var Utils_1 = __webpack_require__(0); var CLIUtils = function () { @@ -1174,9 +1684,17 @@ var CLIUtils = function () { }, { key: 'getOutputSourceMapPath', value: function getOutputSourceMapPath(outputCodePath) { - return outputCodePath.split('.').map(function (value, index, array) { - return index === array.length - 1 ? value + '.map' : value; - }).join('.'); + var sourceMapFileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; + + if (sourceMapFileName) { + outputCodePath = outputCodePath.substr(0, outputCodePath.lastIndexOf('/')) + '/' + sourceMapFileName; + } + if (!/\.js\.map$/.test(outputCodePath)) { + outputCodePath = outputCodePath.split('.')[0] + '.js.map'; + } else if (/\.js$/.test(outputCodePath)) { + outputCodePath += '.map'; + } + return outputCodePath; } }, { key: 'getPackageConfig', @@ -1225,23 +1743,23 @@ CLIUtils.encoding = 'utf8'; exports.CLIUtils = CLIUtils; /***/ }, -/* 24 */ +/* 32 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var commander = __webpack_require__(63); -var path = __webpack_require__(19); -var SourceMapMode_1 = __webpack_require__(11); -var DefaultPreset_1 = __webpack_require__(17); -var CLIUtils_1 = __webpack_require__(23); -var JavaScriptObfuscator_1 = __webpack_require__(9); -var JavaScriptObfuscatorInternal_1 = __webpack_require__(14); +var commander = __webpack_require__(83); +var path = __webpack_require__(25); +var SourceMapMode_1 = __webpack_require__(13); +var UnicodeArrayEncoding_1 = __webpack_require__(18); +var DefaultPreset_1 = __webpack_require__(23); +var CLIUtils_1 = __webpack_require__(31); +var JavaScriptObfuscator_1 = __webpack_require__(10); var Utils_1 = __webpack_require__(0); var JavaScriptObfuscatorCLI = function () { @@ -1285,9 +1803,11 @@ var JavaScriptObfuscatorCLI = function () { }, { key: 'configureCommands', value: function configureCommands() { - this.commands = new commander.Command().version(JavaScriptObfuscatorCLI.getBuildVersion(), '-v, --version').usage(' [options]').option('-o, --output ', 'Output path for obfuscated code').option('--compact ', 'Disable one line output code compacting', JavaScriptObfuscatorCLI.parseBoolean).option('--debugProtection ', 'Disable browser Debug panel (can cause DevTools enabled browser freeze)', JavaScriptObfuscatorCLI.parseBoolean).option('--debugProtectionInterval ', 'Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)', JavaScriptObfuscatorCLI.parseBoolean).option('--disableConsoleOutput ', 'Allow console.log, console.info, console.error and console.warn messages output into browser console', JavaScriptObfuscatorCLI.parseBoolean).option('--encodeUnicodeLiterals ', 'All literals in Unicode array become encoded in Base64 (this option can slightly slow down your code speed)', JavaScriptObfuscatorCLI.parseBoolean).option('--reservedNames ', 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)', function (val) { + this.commands = new commander.Command().version(JavaScriptObfuscatorCLI.getBuildVersion(), '-v, --version').usage(' [options]').option('-o, --output ', 'Output path for obfuscated code').option('--compact ', 'Disable one line output code compacting', JavaScriptObfuscatorCLI.parseBoolean).option('--debugProtection ', 'Disable browser Debug panel (can cause DevTools enabled browser freeze)', JavaScriptObfuscatorCLI.parseBoolean).option('--debugProtectionInterval ', 'Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)', JavaScriptObfuscatorCLI.parseBoolean).option('--disableConsoleOutput ', 'Allow console.log, console.info, console.error and console.warn messages output into browser console', JavaScriptObfuscatorCLI.parseBoolean).option('--domainLock ', 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)', function (val) { return val.split(','); - }).option('--rotateUnicodeArray ', 'Disable rotation of unicode array values during obfuscation', JavaScriptObfuscatorCLI.parseBoolean).option('--selfDefending ', 'Disables self-defending for obfuscated code', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMap ', 'Enables source map generation', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMapMode [inline, separate]', 'Specify source map output mode', JavaScriptObfuscatorCLI.parseSourceMapMode).option('--unicodeArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean).option('--unicodeArrayThreshold ', 'The probability that the literal string will be inserted into unicodeArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).option('--wrapUnicodeArrayCalls ', 'Disables usage of special access function instead of direct array call', JavaScriptObfuscatorCLI.parseBoolean).parse(this.rawArguments); + }).option('--reservedNames ', 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)', function (val) { + return val.split(','); + }).option('--rotateUnicodeArray ', 'Disable rotation of unicode array values during obfuscation', JavaScriptObfuscatorCLI.parseBoolean).option('--selfDefending ', 'Disables self-defending for obfuscated code', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMap ', 'Enables source map generation', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMapBaseUrl ', 'Sets base url to the source map import url when `--sourceMapMode=separate`').option('--sourceMapFileName ', 'Sets file name for output source map when `--sourceMapMode=separate`').option('--sourceMapMode [inline, separate]', 'Specify source map output mode', JavaScriptObfuscatorCLI.parseSourceMapMode).option('--unicodeArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean).option('--unicodeArrayEncoding [true, false, base64, rc4]', 'All literals in Unicode array become encoded in using base64 or rc4 (this option can slightly slow down your code speed', JavaScriptObfuscatorCLI.parseUnicodeArrayEncoding).option('--unicodeArrayThreshold ', 'The probability that the literal string will be inserted into unicodeArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).parse(this.rawArguments); this.commands.on('--help', function () { console.log(' Examples:\n'); console.log(' %> javascript-obfuscator in.js --compact true --selfDefending false'); @@ -1320,16 +1840,11 @@ var JavaScriptObfuscatorCLI = function () { }, { key: 'processDataWithSourceMap', value: function processDataWithSourceMap(outputCodePath, options) { - var javaScriptObfuscator = new JavaScriptObfuscatorInternal_1.JavaScriptObfuscatorInternal(this.data, options), - obfuscationResult = void 0, - outputSourceMapPath = CLIUtils_1.CLIUtils.getOutputSourceMapPath(outputCodePath); - javaScriptObfuscator.obfuscate(); - if (options.sourceMapMode === SourceMapMode_1.SourceMapMode.Separate) { - javaScriptObfuscator.setSourceMapUrl(path.basename(outputSourceMapPath)); - } - obfuscationResult = javaScriptObfuscator.getObfuscationResult(); + var outputSourceMapPath = CLIUtils_1.CLIUtils.getOutputSourceMapPath(outputCodePath, options.sourceMapFileName || ''); + options.sourceMapFileName = path.basename(outputSourceMapPath); + var obfuscationResult = JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(this.data, options); CLIUtils_1.CLIUtils.writeFile(outputCodePath, obfuscationResult.getObfuscatedCode()); - if (obfuscationResult.getSourceMap()) { + if (options.sourceMapMode === 'separate' && obfuscationResult.getSourceMap()) { CLIUtils_1.CLIUtils.writeFile(outputSourceMapPath, obfuscationResult.getSourceMap()); } } @@ -1354,6 +1869,20 @@ var JavaScriptObfuscatorCLI = function () { } return value; } + }, { + key: 'parseUnicodeArrayEncoding', + value: function parseUnicodeArrayEncoding(value) { + switch (value) { + case 'true': + case '1': + case UnicodeArrayEncoding_1.UnicodeArrayEncoding.base64: + return true; + case UnicodeArrayEncoding_1.UnicodeArrayEncoding.rc4: + return UnicodeArrayEncoding_1.UnicodeArrayEncoding.rc4; + default: + return false; + } + } }]); return JavaScriptObfuscatorCLI; @@ -1362,62 +1891,13 @@ var JavaScriptObfuscatorCLI = function () { exports.JavaScriptObfuscatorCLI = JavaScriptObfuscatorCLI; /***/ }, -/* 25 */ +/* 33 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var AppendState_1 = __webpack_require__(2); -var ConsoleOutputDisableExpressionTemplate_1 = __webpack_require__(50); -var Node_1 = __webpack_require__(3); -var NodeUtils_1 = __webpack_require__(1); - -var ConsoleOutputDisableExpressionNode = function (_Node_1$Node) { - _inherits(ConsoleOutputDisableExpressionNode, _Node_1$Node); - - function ConsoleOutputDisableExpressionNode() { - _classCallCheck(this, ConsoleOutputDisableExpressionNode); - - var _this = _possibleConstructorReturn(this, (ConsoleOutputDisableExpressionNode.__proto__ || Object.getPrototypeOf(ConsoleOutputDisableExpressionNode)).apply(this, arguments)); - - _this.appendState = AppendState_1.AppendState.BeforeObfuscation; - return _this; - } - - _createClass(ConsoleOutputDisableExpressionNode, [{ - key: "appendNode", - value: function appendNode(blockScopeNode) { - NodeUtils_1.NodeUtils.prependNode(blockScopeNode.body, this.getNode()); - } - }, { - key: "getNodeStructure", - value: function getNodeStructure() { - return NodeUtils_1.NodeUtils.convertCodeToStructure(ConsoleOutputDisableExpressionTemplate_1.ConsoleOutputDisableExpressionTemplate()); - } - }]); - - return ConsoleOutputDisableExpressionNode; -}(Node_1.Node); - -exports.ConsoleOutputDisableExpressionNode = ConsoleOutputDisableExpressionNode; - -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -"use strict"; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -1426,13 +1906,72 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } __webpack_require__(8); -var AppendState_1 = __webpack_require__(2); -var DebufProtectionFunctionCallTemplate_1 = __webpack_require__(51); -var Node_1 = __webpack_require__(3); +var AppendState_1 = __webpack_require__(3); +var ConsoleOutputDisableExpressionTemplate_1 = __webpack_require__(66); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeAppender_1 = __webpack_require__(4); +var NodeUtils_1 = __webpack_require__(1); +var Utils_1 = __webpack_require__(0); + +var ConsoleOutputDisableExpressionNode = function (_AbstractCustomNode_) { + _inherits(ConsoleOutputDisableExpressionNode, _AbstractCustomNode_); + + function ConsoleOutputDisableExpressionNode(stackTraceData, callsControllerFunctionName, randomStackTraceIndex, options) { + _classCallCheck(this, ConsoleOutputDisableExpressionNode); + + var _this = _possibleConstructorReturn(this, (ConsoleOutputDisableExpressionNode.__proto__ || Object.getPrototypeOf(ConsoleOutputDisableExpressionNode)).call(this, options)); + + _this.appendState = AppendState_1.AppendState.BeforeObfuscation; + _this.stackTraceData = stackTraceData; + _this.callsControllerFunctionName = callsControllerFunctionName; + _this.randomStackTraceIndex = randomStackTraceIndex; + return _this; + } + + _createClass(ConsoleOutputDisableExpressionNode, [{ + key: 'appendNode', + value: function appendNode(blockScopeNode) { + NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(this.stackTraceData, blockScopeNode, this.getNode(), this.randomStackTraceIndex); + } + }, { + key: 'getNodeStructure', + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(ConsoleOutputDisableExpressionTemplate_1.ConsoleOutputDisableExpressionTemplate().formatUnicorn({ + consoleLogDisableFunctionName: Utils_1.Utils.getRandomVariableName(), + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + })); + } + }]); + + return ConsoleOutputDisableExpressionNode; +}(AbstractCustomNode_1.AbstractCustomNode); + +exports.ConsoleOutputDisableExpressionNode = ConsoleOutputDisableExpressionNode; + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +__webpack_require__(8); +var AppendState_1 = __webpack_require__(3); +var DebufProtectionFunctionCallTemplate_1 = __webpack_require__(67); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeAppender_1 = __webpack_require__(4); var NodeUtils_1 = __webpack_require__(1); -var DebugProtectionFunctionCallNode = function (_Node_1$Node) { - _inherits(DebugProtectionFunctionCallNode, _Node_1$Node); +var DebugProtectionFunctionCallNode = function (_AbstractCustomNode_) { + _inherits(DebugProtectionFunctionCallNode, _AbstractCustomNode_); function DebugProtectionFunctionCallNode(debugProtectionFunctionName, options) { _classCallCheck(this, DebugProtectionFunctionCallNode); @@ -1445,12 +1984,12 @@ var DebugProtectionFunctionCallNode = function (_Node_1$Node) { } _createClass(DebugProtectionFunctionCallNode, [{ - key: "appendNode", + key: 'appendNode', value: function appendNode(blockScopeNode) { - NodeUtils_1.NodeUtils.appendNode(blockScopeNode.body, this.getNode()); + NodeAppender_1.NodeAppender.appendNode(blockScopeNode, this.getNode()); } }, { - key: "getNodeStructure", + key: 'getNodeStructure', value: function getNodeStructure() { return NodeUtils_1.NodeUtils.convertCodeToStructure(DebufProtectionFunctionCallTemplate_1.DebugProtectionFunctionCallTemplate().formatUnicorn({ debugProtectionFunctionName: this.debugProtectionFunctionName @@ -1459,18 +1998,18 @@ var DebugProtectionFunctionCallNode = function (_Node_1$Node) { }]); return DebugProtectionFunctionCallNode; -}(Node_1.Node); +}(AbstractCustomNode_1.AbstractCustomNode); exports.DebugProtectionFunctionCallNode = DebugProtectionFunctionCallNode; /***/ }, -/* 27 */ +/* 35 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -1479,13 +2018,14 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } __webpack_require__(8); -var AppendState_1 = __webpack_require__(2); -var DebugProtectionFunctionIntervalTemplate_1 = __webpack_require__(52); -var Node_1 = __webpack_require__(3); +var AppendState_1 = __webpack_require__(3); +var DebugProtectionFunctionIntervalTemplate_1 = __webpack_require__(68); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeAppender_1 = __webpack_require__(4); var NodeUtils_1 = __webpack_require__(1); -var DebugProtectionFunctionIntervalNode = function (_Node_1$Node) { - _inherits(DebugProtectionFunctionIntervalNode, _Node_1$Node); +var DebugProtectionFunctionIntervalNode = function (_AbstractCustomNode_) { + _inherits(DebugProtectionFunctionIntervalNode, _AbstractCustomNode_); function DebugProtectionFunctionIntervalNode(debugProtectionFunctionName, options) { _classCallCheck(this, DebugProtectionFunctionIntervalNode); @@ -1498,12 +2038,12 @@ var DebugProtectionFunctionIntervalNode = function (_Node_1$Node) { } _createClass(DebugProtectionFunctionIntervalNode, [{ - key: "appendNode", + key: 'appendNode', value: function appendNode(blockScopeNode) { - NodeUtils_1.NodeUtils.appendNode(blockScopeNode.body, this.getNode()); + NodeAppender_1.NodeAppender.appendNode(blockScopeNode, this.getNode()); } }, { - key: "getNodeStructure", + key: 'getNodeStructure', value: function getNodeStructure() { return NodeUtils_1.NodeUtils.convertCodeToStructure(DebugProtectionFunctionIntervalTemplate_1.DebugProtectionFunctionIntervalTemplate().formatUnicorn({ debugProtectionFunctionName: this.debugProtectionFunctionName @@ -1512,18 +2052,18 @@ var DebugProtectionFunctionIntervalNode = function (_Node_1$Node) { }]); return DebugProtectionFunctionIntervalNode; -}(Node_1.Node); +}(AbstractCustomNode_1.AbstractCustomNode); exports.DebugProtectionFunctionIntervalNode = DebugProtectionFunctionIntervalNode; /***/ }, -/* 28 */ +/* 36 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -1532,14 +2072,15 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } __webpack_require__(8); -var AppendState_1 = __webpack_require__(2); -var DebugProtectionFunctionTemplate_1 = __webpack_require__(53); -var Node_1 = __webpack_require__(3); +var AppendState_1 = __webpack_require__(3); +var DebugProtectionFunctionTemplate_1 = __webpack_require__(69); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeAppender_1 = __webpack_require__(4); var NodeUtils_1 = __webpack_require__(1); var Utils_1 = __webpack_require__(0); -var DebugProtectionFunctionNode = function (_Node_1$Node) { - _inherits(DebugProtectionFunctionNode, _Node_1$Node); +var DebugProtectionFunctionNode = function (_AbstractCustomNode_) { + _inherits(DebugProtectionFunctionNode, _AbstractCustomNode_); function DebugProtectionFunctionNode(debugProtectionFunctionName, options) { _classCallCheck(this, DebugProtectionFunctionNode); @@ -1552,22 +2093,22 @@ var DebugProtectionFunctionNode = function (_Node_1$Node) { } _createClass(DebugProtectionFunctionNode, [{ - key: "appendNode", + key: 'appendNode', value: function appendNode(blockScopeNode) { var programBodyLength = blockScopeNode.body.length, randomIndex = Utils_1.Utils.getRandomGenerator().integer({ min: 0, max: programBodyLength }); - NodeUtils_1.NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), randomIndex); + NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), randomIndex); } }, { - key: "getNodeIdentifier", + key: 'getNodeIdentifier', value: function getNodeIdentifier() { return this.debugProtectionFunctionName; } }, { - key: "getNodeStructure", + key: 'getNodeStructure', value: function getNodeStructure() { return NodeUtils_1.NodeUtils.convertCodeToStructure(DebugProtectionFunctionTemplate_1.DebugProtectionFunctionTemplate().formatUnicorn({ debugProtectionFunctionName: this.debugProtectionFunctionName @@ -1576,80 +2117,20 @@ var DebugProtectionFunctionNode = function (_Node_1$Node) { }]); return DebugProtectionFunctionNode; -}(Node_1.Node); +}(AbstractCustomNode_1.AbstractCustomNode); exports.DebugProtectionFunctionNode = DebugProtectionFunctionNode; /***/ }, -/* 29 */ +/* 37 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var AppendState_1 = __webpack_require__(2); -var NoCustomNodesPreset_1 = __webpack_require__(13); -var SelfDefendingTemplate_1 = __webpack_require__(54); -var JavaScriptObfuscator_1 = __webpack_require__(9); -var Node_1 = __webpack_require__(3); -var NodeUtils_1 = __webpack_require__(1); -var Utils_1 = __webpack_require__(0); - -var SelfDefendingUnicodeNode = function (_Node_1$Node) { - _inherits(SelfDefendingUnicodeNode, _Node_1$Node); - - function SelfDefendingUnicodeNode() { - _classCallCheck(this, SelfDefendingUnicodeNode); - - var _this = _possibleConstructorReturn(this, (SelfDefendingUnicodeNode.__proto__ || Object.getPrototypeOf(SelfDefendingUnicodeNode)).apply(this, arguments)); - - _this.appendState = AppendState_1.AppendState.AfterObfuscation; - return _this; - } - - _createClass(SelfDefendingUnicodeNode, [{ - key: "appendNode", - value: function appendNode(blockScopeNode) { - var programBodyLength = blockScopeNode.body.length, - randomIndex = 0; - if (programBodyLength > 2) { - randomIndex = Utils_1.Utils.getRandomGenerator().integer({ - min: programBodyLength / 2, - max: programBodyLength - 1 - }); - } - NodeUtils_1.NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), randomIndex); - } - }, { - key: "getNodeStructure", - value: function getNodeStructure() { - return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(SelfDefendingTemplate_1.SelfDefendingTemplate(), NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET).getObfuscatedCode()); - } - }]); - - return SelfDefendingUnicodeNode; -}(Node_1.Node); - -exports.SelfDefendingUnicodeNode = SelfDefendingUnicodeNode; - -/***/ }, -/* 30 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -"use strict"; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -1658,14 +2139,151 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } __webpack_require__(8); -var AppendState_1 = __webpack_require__(2); -var UnicodeArrayCallsWrapperTemplate_1 = __webpack_require__(55); -var Node_1 = __webpack_require__(3); +var AppendState_1 = __webpack_require__(3); +var DomainLockNodeTemplate_1 = __webpack_require__(70); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeAppender_1 = __webpack_require__(4); var NodeUtils_1 = __webpack_require__(1); var Utils_1 = __webpack_require__(0); -var UnicodeArrayCallsWrapper = function (_Node_1$Node) { - _inherits(UnicodeArrayCallsWrapper, _Node_1$Node); +var DomainLockNode = function (_AbstractCustomNode_) { + _inherits(DomainLockNode, _AbstractCustomNode_); + + function DomainLockNode(stackTraceData, callsControllerFunctionName, randomStackTraceIndex, options) { + _classCallCheck(this, DomainLockNode); + + var _this = _possibleConstructorReturn(this, (DomainLockNode.__proto__ || Object.getPrototypeOf(DomainLockNode)).call(this, options)); + + _this.appendState = AppendState_1.AppendState.BeforeObfuscation; + _this.stackTraceData = stackTraceData; + _this.callsControllerFunctionName = callsControllerFunctionName; + _this.randomStackTraceIndex = randomStackTraceIndex; + return _this; + } + + _createClass(DomainLockNode, [{ + key: 'appendNode', + value: function appendNode(blockScopeNode) { + NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(this.stackTraceData, blockScopeNode, this.getNode(), this.randomStackTraceIndex); + } + }, { + key: 'getNodeStructure', + value: function getNodeStructure() { + var domainsString = this.options.domainLock.join(';'); + var _Utils_1$Utils$hideSt = Utils_1.Utils.hideString(domainsString, domainsString.length * 3); + + var _Utils_1$Utils$hideSt2 = _slicedToArray(_Utils_1$Utils$hideSt, 2); + + var hiddenDomainsString = _Utils_1$Utils$hideSt2[0]; + var diff = _Utils_1$Utils$hideSt2[1]; + + return NodeUtils_1.NodeUtils.convertCodeToStructure(DomainLockNodeTemplate_1.DomainLockNodeTemplate().formatUnicorn({ + domainLockFunctionName: Utils_1.Utils.getRandomVariableName(), + diff: diff, + domains: hiddenDomainsString, + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + })); + } + }]); + + return DomainLockNode; +}(AbstractCustomNode_1.AbstractCustomNode); + +exports.DomainLockNode = DomainLockNode; + +/***/ }, +/* 38 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var AppendState_1 = __webpack_require__(3); +var NoCustomNodesPreset_1 = __webpack_require__(16); +var SelfDefendingTemplate_1 = __webpack_require__(71); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeAppender_1 = __webpack_require__(4); +var JavaScriptObfuscator_1 = __webpack_require__(10); +var NodeUtils_1 = __webpack_require__(1); +var Utils_1 = __webpack_require__(0); + +var SelfDefendingUnicodeNode = function (_AbstractCustomNode_) { + _inherits(SelfDefendingUnicodeNode, _AbstractCustomNode_); + + function SelfDefendingUnicodeNode(stackTraceData, callsControllerFunctionName, randomStackTraceIndex, options) { + _classCallCheck(this, SelfDefendingUnicodeNode); + + var _this = _possibleConstructorReturn(this, (SelfDefendingUnicodeNode.__proto__ || Object.getPrototypeOf(SelfDefendingUnicodeNode)).call(this, options)); + + _this.appendState = AppendState_1.AppendState.AfterObfuscation; + _this.stackTraceData = stackTraceData; + _this.callsControllerFunctionName = callsControllerFunctionName; + _this.randomStackTraceIndex = randomStackTraceIndex; + return _this; + } + + _createClass(SelfDefendingUnicodeNode, [{ + key: 'appendNode', + value: function appendNode(blockScopeNode) { + NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(this.stackTraceData, blockScopeNode, this.getNode(), this.randomStackTraceIndex); + } + }, { + key: 'getNodeStructure', + value: function getNodeStructure() { + return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(SelfDefendingTemplate_1.SelfDefendingTemplate().formatUnicorn({ + selfDefendingFunctionName: Utils_1.Utils.getRandomVariableName(), + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }), NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET).getObfuscatedCode()); + } + }]); + + return SelfDefendingUnicodeNode; +}(AbstractCustomNode_1.AbstractCustomNode); + +exports.SelfDefendingUnicodeNode = SelfDefendingUnicodeNode; + +/***/ }, +/* 39 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = (function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +__webpack_require__(8); +var AppendState_1 = __webpack_require__(3); +var UnicodeArrayEncoding_1 = __webpack_require__(18); +var NoCustomNodesPreset_1 = __webpack_require__(16); +var AtobTemplate_1 = __webpack_require__(63); +var Rc4Template_1 = __webpack_require__(64); +var SelfDefendingTemplate_1 = __webpack_require__(72); +var UnicodeArrayBase64DecodeNodeTemplate_1 = __webpack_require__(73); +var UnicodeArrayCallsWrapperTemplate_1 = __webpack_require__(74); +var UnicodeArrayRC4DecodeNodeTemplate_1 = __webpack_require__(75); +var AbstractCustomNode_1 = __webpack_require__(6); +var JavaScriptObfuscator_1 = __webpack_require__(10); +var NodeAppender_1 = __webpack_require__(4); +var NodeUtils_1 = __webpack_require__(1); + +var UnicodeArrayCallsWrapper = function (_AbstractCustomNode_) { + _inherits(UnicodeArrayCallsWrapper, _AbstractCustomNode_); function UnicodeArrayCallsWrapper(unicodeArrayCallsWrapperName, unicodeArrayName, unicodeArray, options) { _classCallCheck(this, UnicodeArrayCallsWrapper); @@ -1680,131 +2298,80 @@ var UnicodeArrayCallsWrapper = function (_Node_1$Node) { } _createClass(UnicodeArrayCallsWrapper, [{ - key: "appendNode", + key: 'appendNode', value: function appendNode(blockScopeNode) { - if (!this.unicodeArray.length) { + if (!this.unicodeArray.getLength()) { return; } - NodeUtils_1.NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), 1); + NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), 1); } }, { - key: "getNodeIdentifier", + key: 'getNodeIdentifier', value: function getNodeIdentifier() { return this.unicodeArrayCallsWrapperName; } }, { - key: "getNode", + key: 'getNode', value: function getNode() { - return _get(UnicodeArrayCallsWrapper.prototype.__proto__ || Object.getPrototypeOf(UnicodeArrayCallsWrapper.prototype), "getNode", this).call(this); + return _get(UnicodeArrayCallsWrapper.prototype.__proto__ || Object.getPrototypeOf(UnicodeArrayCallsWrapper.prototype), 'getNode', this).call(this); } }, { - key: "getNodeStructure", - value: function getNodeStructure() { - var keyName = Utils_1.Utils.getRandomVariableName(); - return NodeUtils_1.NodeUtils.convertCodeToStructure(UnicodeArrayCallsWrapperTemplate_1.UnicodeArrayCallsWrapperTemplate().formatUnicorn({ - keyName: keyName, - unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName, - unicodeArrayName: this.unicodeArrayName - })); - } - }]); - - return UnicodeArrayCallsWrapper; -}(Node_1.Node); - -exports.UnicodeArrayCallsWrapper = UnicodeArrayCallsWrapper; - -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -"use strict"; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -__webpack_require__(8); -var AppendState_1 = __webpack_require__(2); -var NoCustomNodesPreset_1 = __webpack_require__(13); -var AtobTemplate_1 = __webpack_require__(49); -var SelfDefendingTemplate_1 = __webpack_require__(56); -var UnicodeArrayDecodeTemplate_1 = __webpack_require__(57); -var JavaScriptObfuscator_1 = __webpack_require__(9); -var Node_1 = __webpack_require__(3); -var NodeUtils_1 = __webpack_require__(1); - -var UnicodeArrayDecodeNode = function (_Node_1$Node) { - _inherits(UnicodeArrayDecodeNode, _Node_1$Node); - - function UnicodeArrayDecodeNode(unicodeArrayName, unicodeArray, options) { - _classCallCheck(this, UnicodeArrayDecodeNode); - - var _this = _possibleConstructorReturn(this, (UnicodeArrayDecodeNode.__proto__ || Object.getPrototypeOf(UnicodeArrayDecodeNode)).call(this, options)); - - _this.appendState = AppendState_1.AppendState.AfterObfuscation; - _this.unicodeArrayName = unicodeArrayName; - _this.unicodeArray = unicodeArray; - return _this; - } - - _createClass(UnicodeArrayDecodeNode, [{ - key: "appendNode", - value: function appendNode(blockScopeNode) { - if (!this.unicodeArray.length) { - return; - } - NodeUtils_1.NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), 1); - } - }, { - key: "getNode", - value: function getNode() { - return _get(UnicodeArrayDecodeNode.prototype.__proto__ || Object.getPrototypeOf(UnicodeArrayDecodeNode.prototype), "getNode", this).call(this); - } - }, { - key: "getNodeStructure", - value: function getNodeStructure() { - var forLoopFunctionName = 'forLoopFunc'; - var code = void 0; + key: 'getDecodeUnicodeArrayTemplate', + value: function getDecodeUnicodeArrayTemplate() { + var decodeUnicodeArrayTemplate = '', + selfDefendingCode = ''; if (this.options.selfDefending) { - code = SelfDefendingTemplate_1.SelfDefendingTemplate().formatUnicorn({ - forLoopFunctionName: forLoopFunctionName, + selfDefendingCode = SelfDefendingTemplate_1.SelfDefendingTemplate().formatUnicorn({ + unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName, unicodeArrayName: this.unicodeArrayName }); - } else { - code = forLoopFunctionName + "();"; } - return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(UnicodeArrayDecodeTemplate_1.UnicodeArrayDecodeTemplate().formatUnicorn({ - atobPolyfill: AtobTemplate_1.AtobTemplate(), - code: code, - forLoopFunctionName: forLoopFunctionName, + switch (this.options.unicodeArrayEncoding) { + case UnicodeArrayEncoding_1.UnicodeArrayEncoding.base64: + decodeUnicodeArrayTemplate = UnicodeArrayBase64DecodeNodeTemplate_1.UnicodeArrayBase64DecodeNodeTemplate().formatUnicorn({ + atobPolyfill: AtobTemplate_1.AtobTemplate(), + selfDefendingCode: selfDefendingCode, + unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName + }); + break; + case UnicodeArrayEncoding_1.UnicodeArrayEncoding.rc4: + decodeUnicodeArrayTemplate = UnicodeArrayRC4DecodeNodeTemplate_1.UnicodeArrayRc4DecodeNodeTemplate().formatUnicorn({ + atobPolyfill: AtobTemplate_1.AtobTemplate(), + rc4Polyfill: Rc4Template_1.Rc4Template(), + selfDefendingCode: selfDefendingCode, + unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName + }); + break; + } + return decodeUnicodeArrayTemplate; + } + }, { + key: 'getNodeStructure', + value: function getNodeStructure() { + var decodeNodeTemplate = this.getDecodeUnicodeArrayTemplate(); + return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(UnicodeArrayCallsWrapperTemplate_1.UnicodeArrayCallsWrapperTemplate().formatUnicorn({ + decodeNodeTemplate: decodeNodeTemplate, + unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName, unicodeArrayName: this.unicodeArrayName }), NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET).getObfuscatedCode()); } }]); - return UnicodeArrayDecodeNode; -}(Node_1.Node); + return UnicodeArrayCallsWrapper; +}(AbstractCustomNode_1.AbstractCustomNode); -exports.UnicodeArrayDecodeNode = UnicodeArrayDecodeNode; +exports.UnicodeArrayCallsWrapper = UnicodeArrayCallsWrapper; /***/ }, -/* 32 */ +/* 40 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; +var _get = (function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -1813,25 +2380,25 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } __webpack_require__(8); -var AppendState_1 = __webpack_require__(2); -var UnicodeArrayTemplate_1 = __webpack_require__(58); -var Node_1 = __webpack_require__(3); +var AppendState_1 = __webpack_require__(3); +var UnicodeArrayTemplate_1 = __webpack_require__(76); +var AbstractCustomNode_1 = __webpack_require__(6); +var NodeAppender_1 = __webpack_require__(4); var NodeUtils_1 = __webpack_require__(1); -var Utils_1 = __webpack_require__(0); -var UnicodeArrayNode = function (_Node_1$Node) { - _inherits(UnicodeArrayNode, _Node_1$Node); +var UnicodeArrayNode = function (_AbstractCustomNode_) { + _inherits(UnicodeArrayNode, _AbstractCustomNode_); - function UnicodeArrayNode(unicodeArrayName) { - var unicodeArrayRotateValue = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; - var options = arguments[2]; + function UnicodeArrayNode(unicodeArray, unicodeArrayName) { + var unicodeArrayRotateValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; + var options = arguments[3]; _classCallCheck(this, UnicodeArrayNode); var _this = _possibleConstructorReturn(this, (UnicodeArrayNode.__proto__ || Object.getPrototypeOf(UnicodeArrayNode)).call(this, options)); _this.appendState = AppendState_1.AppendState.AfterObfuscation; - _this.unicodeArray = []; + _this.unicodeArray = unicodeArray; _this.unicodeArrayName = unicodeArrayName; _this.unicodeArrayRotateValue = unicodeArrayRotateValue; return _this; @@ -1840,10 +2407,10 @@ var UnicodeArrayNode = function (_Node_1$Node) { _createClass(UnicodeArrayNode, [{ key: 'appendNode', value: function appendNode(blockScopeNode) { - if (!this.unicodeArray.length) { + if (!this.unicodeArray.getLength()) { return; } - NodeUtils_1.NodeUtils.prependNode(blockScopeNode.body, this.getNode()); + NodeAppender_1.NodeAppender.prependNode(blockScopeNode, this.getNode()); } }, { key: 'getNodeIdentifier', @@ -1858,40 +2425,40 @@ var UnicodeArrayNode = function (_Node_1$Node) { }, { key: 'getNode', value: function getNode() { - Utils_1.Utils.arrayRotate(this.unicodeArray, this.unicodeArrayRotateValue); + this.unicodeArray.rotateArray(this.unicodeArrayRotateValue); return _get(UnicodeArrayNode.prototype.__proto__ || Object.getPrototypeOf(UnicodeArrayNode.prototype), 'getNode', this).call(this); } }, { key: 'updateNodeData', value: function updateNodeData(data) { - this.unicodeArray.push(data); + this.unicodeArray.addToArray(data); } }, { key: 'getNodeStructure', value: function getNodeStructure() { return NodeUtils_1.NodeUtils.convertCodeToStructure(UnicodeArrayTemplate_1.UnicodeArrayTemplate().formatUnicorn({ unicodeArrayName: this.unicodeArrayName, - unicodeArray: this.unicodeArray.join(',') + unicodeArray: this.unicodeArray.toString() })); } }]); return UnicodeArrayNode; -}(Node_1.Node); +}(AbstractCustomNode_1.AbstractCustomNode); UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH = 4; exports.UnicodeArrayNode = UnicodeArrayNode; /***/ }, -/* 33 */ +/* 41 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; +var _get = (function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -1900,17 +2467,18 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } __webpack_require__(8); -var AppendState_1 = __webpack_require__(2); -var NoCustomNodesPreset_1 = __webpack_require__(13); -var SelfDefendingTemplate_1 = __webpack_require__(59); -var UnicodeArrayRotateFunctionTemplate_1 = __webpack_require__(60); -var JavaScriptObfuscator_1 = __webpack_require__(9); -var Node_1 = __webpack_require__(3); +var AppendState_1 = __webpack_require__(3); +var NoCustomNodesPreset_1 = __webpack_require__(16); +var SelfDefendingTemplate_1 = __webpack_require__(77); +var UnicodeArrayRotateFunctionTemplate_1 = __webpack_require__(78); +var AbstractCustomNode_1 = __webpack_require__(6); +var JavaScriptObfuscator_1 = __webpack_require__(10); +var NodeAppender_1 = __webpack_require__(4); var NodeUtils_1 = __webpack_require__(1); var Utils_1 = __webpack_require__(0); -var UnicodeArrayRotateFunctionNode = function (_Node_1$Node) { - _inherits(UnicodeArrayRotateFunctionNode, _Node_1$Node); +var UnicodeArrayRotateFunctionNode = function (_AbstractCustomNode_) { + _inherits(UnicodeArrayRotateFunctionNode, _AbstractCustomNode_); function UnicodeArrayRotateFunctionNode(unicodeArrayName, unicodeArray, unicodeArrayRotateValue, options) { _classCallCheck(this, UnicodeArrayRotateFunctionNode); @@ -1925,20 +2493,20 @@ var UnicodeArrayRotateFunctionNode = function (_Node_1$Node) { } _createClass(UnicodeArrayRotateFunctionNode, [{ - key: "appendNode", + key: 'appendNode', value: function appendNode(blockScopeNode) { - if (!this.unicodeArray.length) { + if (!this.unicodeArray.getLength()) { return; } - NodeUtils_1.NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), 1); + NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), 1); } }, { - key: "getNode", + key: 'getNode', value: function getNode() { - return _get(UnicodeArrayRotateFunctionNode.prototype.__proto__ || Object.getPrototypeOf(UnicodeArrayRotateFunctionNode.prototype), "getNode", this).call(this); + return _get(UnicodeArrayRotateFunctionNode.prototype.__proto__ || Object.getPrototypeOf(UnicodeArrayRotateFunctionNode.prototype), 'getNode', this).call(this); } }, { - key: "getNodeStructure", + key: 'getNodeStructure', value: function getNodeStructure() { var code = '', timesName = Utils_1.Utils.getRandomVariableName(), @@ -1949,7 +2517,7 @@ var UnicodeArrayRotateFunctionNode = function (_Node_1$Node) { whileFunctionName: whileFunctionName }); } else { - code = whileFunctionName + "(++" + timesName + ")"; + code = whileFunctionName + '(++' + timesName + ')'; } return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(UnicodeArrayRotateFunctionTemplate_1.UnicodeArrayRotateFunctionTemplate().formatUnicorn({ code: code, @@ -1962,195 +2530,279 @@ var UnicodeArrayRotateFunctionNode = function (_Node_1$Node) { }]); return UnicodeArrayRotateFunctionNode; -}(Node_1.Node); +}(AbstractCustomNode_1.AbstractCustomNode); exports.UnicodeArrayRotateFunctionNode = UnicodeArrayRotateFunctionNode; /***/ }, -/* 34 */ +/* 42 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var ConsoleOutputDisableExpressionNode_1 = __webpack_require__(25); -var NodesGroup_1 = __webpack_require__(12); +var ConsoleOutputDisableExpressionNode_1 = __webpack_require__(33); +var NodeCallsControllerFunctionNode_1 = __webpack_require__(17); +var AbstractNodesGroup_1 = __webpack_require__(11); +var NodeAppender_1 = __webpack_require__(4); +var Utils_1 = __webpack_require__(0); -var ConsoleOutputNodesGroup = function (_NodesGroup_1$NodesGr) { - _inherits(ConsoleOutputNodesGroup, _NodesGroup_1$NodesGr); +var ConsoleOutputNodesGroup = function (_AbstractNodesGroup_) { + _inherits(ConsoleOutputNodesGroup, _AbstractNodesGroup_); - function ConsoleOutputNodesGroup(options) { + function ConsoleOutputNodesGroup() { _classCallCheck(this, ConsoleOutputNodesGroup); - var _this = _possibleConstructorReturn(this, (ConsoleOutputNodesGroup.__proto__ || Object.getPrototypeOf(ConsoleOutputNodesGroup)).call(this, options)); - - if (!_this.options.disableConsoleOutput) { - return _possibleConstructorReturn(_this); - } - _this.nodes.set('consoleOutputDisableExpressionNode', new ConsoleOutputDisableExpressionNode_1.ConsoleOutputDisableExpressionNode(_this.options)); - return _this; + return _possibleConstructorReturn(this, (ConsoleOutputNodesGroup.__proto__ || Object.getPrototypeOf(ConsoleOutputNodesGroup)).apply(this, arguments)); } + _createClass(ConsoleOutputNodesGroup, [{ + key: 'getNodes', + value: function getNodes() { + if (!this.options.disableConsoleOutput) { + return; + } + var callsControllerFunctionName = Utils_1.Utils.getRandomVariableName(); + var randomStackTraceIndex = NodeAppender_1.NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length); + return this.syncCustomNodesWithNodesGroup(new Map([['consoleOutputDisableExpressionNode', new ConsoleOutputDisableExpressionNode_1.ConsoleOutputDisableExpressionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['ConsoleOutputNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]])); + } + }]); + return ConsoleOutputNodesGroup; -}(NodesGroup_1.NodesGroup); +}(AbstractNodesGroup_1.AbstractNodesGroup); exports.ConsoleOutputNodesGroup = ConsoleOutputNodesGroup; /***/ }, -/* 35 */ +/* 43 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var DebugProtectionFunctionCallNode_1 = __webpack_require__(26); -var DebugProtectionFunctionIntervalNode_1 = __webpack_require__(27); -var DebugProtectionFunctionNode_1 = __webpack_require__(28); -var NodesGroup_1 = __webpack_require__(12); +var DebugProtectionFunctionCallNode_1 = __webpack_require__(34); +var DebugProtectionFunctionIntervalNode_1 = __webpack_require__(35); +var DebugProtectionFunctionNode_1 = __webpack_require__(36); +var AbstractNodesGroup_1 = __webpack_require__(11); var Utils_1 = __webpack_require__(0); -var DebugProtectionNodesGroup = function (_NodesGroup_1$NodesGr) { - _inherits(DebugProtectionNodesGroup, _NodesGroup_1$NodesGr); +var DebugProtectionNodesGroup = function (_AbstractNodesGroup_) { + _inherits(DebugProtectionNodesGroup, _AbstractNodesGroup_); - function DebugProtectionNodesGroup(options) { + function DebugProtectionNodesGroup() { _classCallCheck(this, DebugProtectionNodesGroup); - var _this = _possibleConstructorReturn(this, (DebugProtectionNodesGroup.__proto__ || Object.getPrototypeOf(DebugProtectionNodesGroup)).call(this, options)); - - _this.debugProtectionFunctionIdentifier = Utils_1.Utils.getRandomVariableName(); - if (!_this.options.debugProtection) { - return _possibleConstructorReturn(_this); - } - _this.nodes.set('debugProtectionFunctionNode', new DebugProtectionFunctionNode_1.DebugProtectionFunctionNode(_this.debugProtectionFunctionIdentifier, _this.options)); - _this.nodes.set('debugProtectionFunctionCallNode', new DebugProtectionFunctionCallNode_1.DebugProtectionFunctionCallNode(_this.debugProtectionFunctionIdentifier, _this.options)); - if (_this.options.debugProtectionInterval) { - _this.nodes.set('debugProtectionFunctionIntervalNode', new DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode(_this.debugProtectionFunctionIdentifier, _this.options)); - } - return _this; + return _possibleConstructorReturn(this, (DebugProtectionNodesGroup.__proto__ || Object.getPrototypeOf(DebugProtectionNodesGroup)).apply(this, arguments)); } + _createClass(DebugProtectionNodesGroup, [{ + key: 'getNodes', + value: function getNodes() { + if (!this.options.debugProtection) { + return; + } + var debugProtectionFunctionName = Utils_1.Utils.getRandomVariableName(); + var customNodes = new Map([['debugProtectionFunctionNode', new DebugProtectionFunctionNode_1.DebugProtectionFunctionNode(debugProtectionFunctionName, this.options)], ['debugProtectionFunctionCallNode', new DebugProtectionFunctionCallNode_1.DebugProtectionFunctionCallNode(debugProtectionFunctionName, this.options)]]); + if (this.options.debugProtectionInterval) { + customNodes.set('debugProtectionFunctionIntervalNode', new DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode(debugProtectionFunctionName, this.options)); + } + return this.syncCustomNodesWithNodesGroup(customNodes); + } + }]); + return DebugProtectionNodesGroup; -}(NodesGroup_1.NodesGroup); +}(AbstractNodesGroup_1.AbstractNodesGroup); exports.DebugProtectionNodesGroup = DebugProtectionNodesGroup; /***/ }, -/* 36 */ +/* 44 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var NodesGroup_1 = __webpack_require__(12); -var SelfDefendingUnicodeNode_1 = __webpack_require__(29); +var DomainLockNode_1 = __webpack_require__(37); +var NodeCallsControllerFunctionNode_1 = __webpack_require__(17); +var AbstractNodesGroup_1 = __webpack_require__(11); +var NodeAppender_1 = __webpack_require__(4); +var Utils_1 = __webpack_require__(0); -var SelfDefendingNodesGroup = function (_NodesGroup_1$NodesGr) { - _inherits(SelfDefendingNodesGroup, _NodesGroup_1$NodesGr); +var DomainLockNodesGroup = function (_AbstractNodesGroup_) { + _inherits(DomainLockNodesGroup, _AbstractNodesGroup_); - function SelfDefendingNodesGroup(options) { + function DomainLockNodesGroup() { + _classCallCheck(this, DomainLockNodesGroup); + + return _possibleConstructorReturn(this, (DomainLockNodesGroup.__proto__ || Object.getPrototypeOf(DomainLockNodesGroup)).apply(this, arguments)); + } + + _createClass(DomainLockNodesGroup, [{ + key: 'getNodes', + value: function getNodes() { + if (!this.options.domainLock.length) { + return; + } + var callsControllerFunctionName = Utils_1.Utils.getRandomVariableName(); + var randomStackTraceIndex = NodeAppender_1.NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length); + return this.syncCustomNodesWithNodesGroup(new Map([['DomainLockNode', new DomainLockNode_1.DomainLockNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['DomainLockNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]])); + } + }]); + + return DomainLockNodesGroup; +}(AbstractNodesGroup_1.AbstractNodesGroup); + +exports.DomainLockNodesGroup = DomainLockNodesGroup; + +/***/ }, +/* 45 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var AppendState_1 = __webpack_require__(3); +var NodeCallsControllerFunctionNode_1 = __webpack_require__(17); +var SelfDefendingUnicodeNode_1 = __webpack_require__(38); +var AbstractNodesGroup_1 = __webpack_require__(11); +var NodeAppender_1 = __webpack_require__(4); +var Utils_1 = __webpack_require__(0); + +var SelfDefendingNodesGroup = function (_AbstractNodesGroup_) { + _inherits(SelfDefendingNodesGroup, _AbstractNodesGroup_); + + function SelfDefendingNodesGroup() { _classCallCheck(this, SelfDefendingNodesGroup); - var _this = _possibleConstructorReturn(this, (SelfDefendingNodesGroup.__proto__ || Object.getPrototypeOf(SelfDefendingNodesGroup)).call(this, options)); + var _this = _possibleConstructorReturn(this, (SelfDefendingNodesGroup.__proto__ || Object.getPrototypeOf(SelfDefendingNodesGroup)).apply(this, arguments)); - if (!_this.options.selfDefending) { - return _possibleConstructorReturn(_this); - } - _this.nodes.set('selfDefendingUnicodeNode', new SelfDefendingUnicodeNode_1.SelfDefendingUnicodeNode(_this.options)); + _this.appendState = AppendState_1.AppendState.AfterObfuscation; return _this; } + _createClass(SelfDefendingNodesGroup, [{ + key: 'getNodes', + value: function getNodes() { + if (!this.options.selfDefending) { + return; + } + var callsControllerFunctionName = Utils_1.Utils.getRandomVariableName(); + var randomStackTraceIndex = NodeAppender_1.NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length); + return this.syncCustomNodesWithNodesGroup(new Map([['selfDefendingUnicodeNode', new SelfDefendingUnicodeNode_1.SelfDefendingUnicodeNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['SelfDefendingNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]])); + } + }]); + return SelfDefendingNodesGroup; -}(NodesGroup_1.NodesGroup); +}(AbstractNodesGroup_1.AbstractNodesGroup); exports.SelfDefendingNodesGroup = SelfDefendingNodesGroup; /***/ }, -/* 37 */ +/* 46 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var NodesGroup_1 = __webpack_require__(12); -var UnicodeArrayCallsWrapper_1 = __webpack_require__(30); -var UnicodeArrayDecodeNode_1 = __webpack_require__(31); -var UnicodeArrayNode_1 = __webpack_require__(32); -var UnicodeArrayRotateFunctionNode_1 = __webpack_require__(33); +var AppendState_1 = __webpack_require__(3); +var UnicodeArrayCallsWrapper_1 = __webpack_require__(39); +var UnicodeArrayNode_1 = __webpack_require__(40); +var UnicodeArrayRotateFunctionNode_1 = __webpack_require__(41); +var AbstractNodesGroup_1 = __webpack_require__(11); +var UnicodeArray_1 = __webpack_require__(30); var Utils_1 = __webpack_require__(0); -var UnicodeArrayNodesGroup = function (_NodesGroup_1$NodesGr) { - _inherits(UnicodeArrayNodesGroup, _NodesGroup_1$NodesGr); +var UnicodeArrayNodesGroup = function (_AbstractNodesGroup_) { + _inherits(UnicodeArrayNodesGroup, _AbstractNodesGroup_); - function UnicodeArrayNodesGroup(options) { + function UnicodeArrayNodesGroup() { _classCallCheck(this, UnicodeArrayNodesGroup); - var _this = _possibleConstructorReturn(this, (UnicodeArrayNodesGroup.__proto__ || Object.getPrototypeOf(UnicodeArrayNodesGroup)).call(this, options)); + var _this = _possibleConstructorReturn(this, (UnicodeArrayNodesGroup.__proto__ || Object.getPrototypeOf(UnicodeArrayNodesGroup)).apply(this, arguments)); + _this.appendState = AppendState_1.AppendState.AfterObfuscation; _this.unicodeArrayName = Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH); - _this.unicodeArrayTranslatorName = Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH); - if (!_this.options.unicodeArray) { - return _possibleConstructorReturn(_this); - } - if (_this.options.rotateUnicodeArray) { - _this.unicodeArrayRotateValue = Utils_1.Utils.getRandomGenerator().integer({ - min: 100, - max: 500 - }); - } else { - _this.unicodeArrayRotateValue = 0; - } - var unicodeArrayNode = new UnicodeArrayNode_1.UnicodeArrayNode(_this.unicodeArrayName, _this.unicodeArrayRotateValue, _this.options), - unicodeArray = unicodeArrayNode.getNodeData(); - _this.nodes.set('unicodeArrayNode', unicodeArrayNode); - if (_this.options.wrapUnicodeArrayCalls) { - _this.nodes.set('unicodeArrayCallsWrapper', new UnicodeArrayCallsWrapper_1.UnicodeArrayCallsWrapper(_this.unicodeArrayTranslatorName, _this.unicodeArrayName, unicodeArray, _this.options)); - } - if (_this.options.encodeUnicodeLiterals) { - _this.nodes.set('unicodeArrayDecodeNode', new UnicodeArrayDecodeNode_1.UnicodeArrayDecodeNode(_this.unicodeArrayName, unicodeArray, _this.options)); - } - if (_this.options.rotateUnicodeArray) { - _this.nodes.set('unicodeArrayRotateFunctionNode', new UnicodeArrayRotateFunctionNode_1.UnicodeArrayRotateFunctionNode(_this.unicodeArrayName, unicodeArray, _this.unicodeArrayRotateValue, _this.options)); - } + _this.unicodeArrayCallsWrapper = Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH); return _this; } + _createClass(UnicodeArrayNodesGroup, [{ + key: 'getNodes', + value: function getNodes() { + if (!this.options.unicodeArray) { + return; + } + if (this.options.rotateUnicodeArray) { + this.unicodeArrayRotateValue = Utils_1.Utils.getRandomGenerator().integer({ + min: 100, + max: 500 + }); + } else { + this.unicodeArrayRotateValue = 0; + } + var unicodeArray = new UnicodeArray_1.UnicodeArray(); + var unicodeArrayNode = new UnicodeArrayNode_1.UnicodeArrayNode(unicodeArray, this.unicodeArrayName, this.unicodeArrayRotateValue, this.options); + var customNodes = new Map([['unicodeArrayNode', unicodeArrayNode], ['unicodeArrayCallsWrapper', new UnicodeArrayCallsWrapper_1.UnicodeArrayCallsWrapper(this.unicodeArrayCallsWrapper, this.unicodeArrayName, unicodeArray, this.options)]]); + if (this.options.rotateUnicodeArray) { + customNodes.set('unicodeArrayRotateFunctionNode', new UnicodeArrayRotateFunctionNode_1.UnicodeArrayRotateFunctionNode(this.unicodeArrayName, unicodeArray, this.unicodeArrayRotateValue, this.options)); + } + return this.syncCustomNodesWithNodesGroup(customNodes); + } + }]); + return UnicodeArrayNodesGroup; -}(NodesGroup_1.NodesGroup); +}(AbstractNodesGroup_1.AbstractNodesGroup); exports.UnicodeArrayNodesGroup = UnicodeArrayNodesGroup; /***/ }, -/* 38 */ +/* 47 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2158,18 +2810,22 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var estraverse = __webpack_require__(4); -var NodeObfuscator_1 = __webpack_require__(6); +var estraverse = __webpack_require__(5); +var NodeType_1 = __webpack_require__(7); +var AbstractNodeObfuscator_1 = __webpack_require__(9); +var IdentifierReplacer_1 = __webpack_require__(15); +var Nodes_1 = __webpack_require__(2); +var NodeUtils_1 = __webpack_require__(1); -var CatchClauseObfuscator = function (_NodeObfuscator_1$Nod) { - _inherits(CatchClauseObfuscator, _NodeObfuscator_1$Nod); +var CatchClauseObfuscator = function (_AbstractNodeObfuscat) { + _inherits(CatchClauseObfuscator, _AbstractNodeObfuscat); - function CatchClauseObfuscator() { + function CatchClauseObfuscator(nodes, options) { _classCallCheck(this, CatchClauseObfuscator); - var _this = _possibleConstructorReturn(this, (CatchClauseObfuscator.__proto__ || Object.getPrototypeOf(CatchClauseObfuscator)).apply(this, arguments)); + var _this = _possibleConstructorReturn(this, (CatchClauseObfuscator.__proto__ || Object.getPrototypeOf(CatchClauseObfuscator)).call(this, nodes, options)); - _this.catchClauseParam = new Map(); + _this.identifierReplacer = new IdentifierReplacer_1.IdentifierReplacer(_this.nodes, _this.options); return _this; } @@ -2184,9 +2840,9 @@ var CatchClauseObfuscator = function (_NodeObfuscator_1$Nod) { value: function storeCatchClauseParam(catchClauseNode) { var _this2 = this; - estraverse.traverse(catchClauseNode.param, { + NodeUtils_1.NodeUtils.typedReplace(catchClauseNode.param, NodeType_1.NodeType.Identifier, { enter: function enter(node) { - return _this2.storeIdentifiersNames(node, _this2.catchClauseParam); + return _this2.identifierReplacer.storeNames(node.name); } }); } @@ -2197,25 +2853,27 @@ var CatchClauseObfuscator = function (_NodeObfuscator_1$Nod) { estraverse.replace(catchClauseNode, { enter: function enter(node, parentNode) { - _this3.replaceIdentifiersWithRandomNames(node, parentNode, _this3.catchClauseParam); + if (Nodes_1.Nodes.isReplaceableIdentifierNode(node, parentNode)) { + node.name = _this3.identifierReplacer.replace(node.name); + } } }); } }]); return CatchClauseObfuscator; -}(NodeObfuscator_1.NodeObfuscator); +}(AbstractNodeObfuscator_1.AbstractNodeObfuscator); exports.CatchClauseObfuscator = CatchClauseObfuscator; /***/ }, -/* 39 */ +/* 48 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2223,25 +2881,27 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var estraverse = __webpack_require__(4); +var estraverse = __webpack_require__(5); var NodeType_1 = __webpack_require__(7); -var NodeObfuscator_1 = __webpack_require__(6); +var AbstractNodeObfuscator_1 = __webpack_require__(9); +var IdentifierReplacer_1 = __webpack_require__(15); +var Nodes_1 = __webpack_require__(2); var NodeUtils_1 = __webpack_require__(1); -var FunctionDeclarationObfuscator = function (_NodeObfuscator_1$Nod) { - _inherits(FunctionDeclarationObfuscator, _NodeObfuscator_1$Nod); +var FunctionDeclarationObfuscator = function (_AbstractNodeObfuscat) { + _inherits(FunctionDeclarationObfuscator, _AbstractNodeObfuscat); - function FunctionDeclarationObfuscator() { + function FunctionDeclarationObfuscator(nodes, options) { _classCallCheck(this, FunctionDeclarationObfuscator); - var _this = _possibleConstructorReturn(this, (FunctionDeclarationObfuscator.__proto__ || Object.getPrototypeOf(FunctionDeclarationObfuscator)).apply(this, arguments)); + var _this = _possibleConstructorReturn(this, (FunctionDeclarationObfuscator.__proto__ || Object.getPrototypeOf(FunctionDeclarationObfuscator)).call(this, nodes, options)); - _this.functionName = new Map(); + _this.identifierReplacer = new IdentifierReplacer_1.IdentifierReplacer(_this.nodes, _this.options); return _this; } _createClass(FunctionDeclarationObfuscator, [{ - key: "obfuscateNode", + key: 'obfuscateNode', value: function obfuscateNode(functionDeclarationNode, parentNode) { if (parentNode.type === NodeType_1.NodeType.Program) { return; @@ -2250,43 +2910,45 @@ var FunctionDeclarationObfuscator = function (_NodeObfuscator_1$Nod) { this.replaceFunctionName(functionDeclarationNode); } }, { - key: "storeFunctionName", + key: 'storeFunctionName', value: function storeFunctionName(functionDeclarationNode) { var _this2 = this; - estraverse.traverse(functionDeclarationNode.id, { + NodeUtils_1.NodeUtils.typedReplace(functionDeclarationNode.id, NodeType_1.NodeType.Identifier, { enter: function enter(node) { - return _this2.storeIdentifiersNames(node, _this2.functionName); + return _this2.identifierReplacer.storeNames(node.name); } }); } }, { - key: "replaceFunctionName", + key: 'replaceFunctionName', value: function replaceFunctionName(functionDeclarationNode) { var _this3 = this; var scopeNode = NodeUtils_1.NodeUtils.getBlockScopeOfNode(functionDeclarationNode); estraverse.replace(scopeNode, { enter: function enter(node, parentNode) { - _this3.replaceIdentifiersWithRandomNames(node, parentNode, _this3.functionName); + if (Nodes_1.Nodes.isReplaceableIdentifierNode(node, parentNode)) { + node.name = _this3.identifierReplacer.replace(node.name); + } } }); } }]); return FunctionDeclarationObfuscator; -}(NodeObfuscator_1.NodeObfuscator); +}(AbstractNodeObfuscator_1.AbstractNodeObfuscator); exports.FunctionDeclarationObfuscator = FunctionDeclarationObfuscator; /***/ }, -/* 40 */ +/* 49 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2294,19 +2956,22 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var estraverse = __webpack_require__(4); -var NodeObfuscator_1 = __webpack_require__(6); -var Nodes_1 = __webpack_require__(5); +var estraverse = __webpack_require__(5); +var NodeType_1 = __webpack_require__(7); +var AbstractNodeObfuscator_1 = __webpack_require__(9); +var IdentifierReplacer_1 = __webpack_require__(15); +var Nodes_1 = __webpack_require__(2); +var NodeUtils_1 = __webpack_require__(1); -var FunctionObfuscator = function (_NodeObfuscator_1$Nod) { - _inherits(FunctionObfuscator, _NodeObfuscator_1$Nod); +var FunctionObfuscator = function (_AbstractNodeObfuscat) { + _inherits(FunctionObfuscator, _AbstractNodeObfuscat); - function FunctionObfuscator() { + function FunctionObfuscator(nodes, options) { _classCallCheck(this, FunctionObfuscator); - var _this = _possibleConstructorReturn(this, (FunctionObfuscator.__proto__ || Object.getPrototypeOf(FunctionObfuscator)).apply(this, arguments)); + var _this = _possibleConstructorReturn(this, (FunctionObfuscator.__proto__ || Object.getPrototypeOf(FunctionObfuscator)).call(this, nodes, options)); - _this.functionParams = new Map(); + _this.identifierReplacer = new IdentifierReplacer_1.IdentifierReplacer(_this.nodes, _this.options); return _this; } @@ -2322,9 +2987,9 @@ var FunctionObfuscator = function (_NodeObfuscator_1$Nod) { var _this2 = this; functionNode.params.forEach(function (paramsNode) { - estraverse.traverse(paramsNode, { + NodeUtils_1.NodeUtils.typedReplace(paramsNode, NodeType_1.NodeType.Identifier, { enter: function enter(node) { - return _this2.storeIdentifiersNames(node, _this2.functionParams); + return _this2.identifierReplacer.storeNames(node.name); } }); }); @@ -2336,13 +3001,10 @@ var FunctionObfuscator = function (_NodeObfuscator_1$Nod) { var replaceVisitor = { enter: function enter(node, parentNode) { - var newNodeName = ''; - if (Nodes_1.Nodes.isIdentifierNode(node)) { - newNodeName = node.name; - } - _this3.replaceIdentifiersWithRandomNames(node, parentNode, _this3.functionParams); - if (Nodes_1.Nodes.isIdentifierNode(node)) { + if (Nodes_1.Nodes.isReplaceableIdentifierNode(node, parentNode)) { + var newNodeName = _this3.identifierReplacer.replace(node.name); if (node.name !== newNodeName) { + node.name = newNodeName; node.obfuscated = true; } } @@ -2356,20 +3018,20 @@ var FunctionObfuscator = function (_NodeObfuscator_1$Nod) { }]); return FunctionObfuscator; -}(NodeObfuscator_1.NodeObfuscator); +}(AbstractNodeObfuscator_1.AbstractNodeObfuscator); exports.FunctionObfuscator = FunctionObfuscator; /***/ }, -/* 41 */ +/* 50 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2377,12 +3039,15 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var escodegen = __webpack_require__(10); -var NodeObfuscator_1 = __webpack_require__(6); -var Nodes_1 = __webpack_require__(5); +var escodegen = __webpack_require__(12); +var AbstractNodeObfuscator_1 = __webpack_require__(9); +var BooleanLiteralReplacer_1 = __webpack_require__(55); +var Nodes_1 = __webpack_require__(2); +var NumberLiteralReplacer_1 = __webpack_require__(22); +var StringLiteralReplacer_1 = __webpack_require__(19); -var LiteralObfuscator = function (_NodeObfuscator_1$Nod) { - _inherits(LiteralObfuscator, _NodeObfuscator_1$Nod); +var LiteralObfuscator = function (_AbstractNodeObfuscat) { + _inherits(LiteralObfuscator, _AbstractNodeObfuscat); function LiteralObfuscator() { _classCallCheck(this, LiteralObfuscator); @@ -2396,19 +3061,16 @@ var LiteralObfuscator = function (_NodeObfuscator_1$Nod) { if (Nodes_1.Nodes.isPropertyNode(parentNode) && parentNode.key === literalNode) { return; } - if (literalNode['x-verbatim-property']) { - return; - } var content = void 0; switch (_typeof(literalNode.value)) { case 'boolean': - content = this.replaceLiteralBooleanWithJSFuck(literalNode.value); + content = new BooleanLiteralReplacer_1.BooleanLiteralReplacer(this.nodes, this.options).replace(literalNode.value); break; case 'number': - content = this.replaceLiteralNumberWithHexadecimalValue(literalNode.value); + content = new NumberLiteralReplacer_1.NumberLiteralReplacer(this.nodes, this.options).replace(literalNode.value); break; case 'string': - content = this.replaceLiteralValueWithUnicodeValue(literalNode.value); + content = new StringLiteralReplacer_1.StringLiteralReplacer(this.nodes, this.options).replace(literalNode.value); break; default: return; @@ -2421,18 +3083,18 @@ var LiteralObfuscator = function (_NodeObfuscator_1$Nod) { }]); return LiteralObfuscator; -}(NodeObfuscator_1.NodeObfuscator); +}(AbstractNodeObfuscator_1.AbstractNodeObfuscator); exports.LiteralObfuscator = LiteralObfuscator; /***/ }, -/* 42 */ +/* 51 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2440,14 +3102,15 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var escodegen = __webpack_require__(10); -var estraverse = __webpack_require__(4); +var escodegen = __webpack_require__(12); +var estraverse = __webpack_require__(5); var NodeType_1 = __webpack_require__(7); -var NodeObfuscator_1 = __webpack_require__(6); -var Nodes_1 = __webpack_require__(5); +var AbstractNodeObfuscator_1 = __webpack_require__(9); +var Nodes_1 = __webpack_require__(2); +var StringLiteralReplacer_1 = __webpack_require__(19); -var MemberExpressionObfuscator = function (_NodeObfuscator_1$Nod) { - _inherits(MemberExpressionObfuscator, _NodeObfuscator_1$Nod); +var MemberExpressionObfuscator = function (_AbstractNodeObfuscat) { + _inherits(MemberExpressionObfuscator, _AbstractNodeObfuscat); function MemberExpressionObfuscator() { _classCallCheck(this, MemberExpressionObfuscator); @@ -2483,7 +3146,7 @@ var MemberExpressionObfuscator = function (_NodeObfuscator_1$Nod) { literalNode = { raw: '\'' + nodeValue + '\'', 'x-verbatim-property': { - content: this.replaceLiteralValueWithUnicodeValue(nodeValue), + content: new StringLiteralReplacer_1.StringLiteralReplacer(this.nodes, this.options).replace(nodeValue), precedence: escodegen.Precedence.Primary }, type: NodeType_1.NodeType.Literal, @@ -2497,7 +3160,7 @@ var MemberExpressionObfuscator = function (_NodeObfuscator_1$Nod) { value: function obfuscateLiteralProperty(node) { if (typeof node.value === 'string' && !node['x-verbatim-property']) { node['x-verbatim-property'] = { - content: this.replaceLiteralValueWithUnicodeValue(node.value), + content: new StringLiteralReplacer_1.StringLiteralReplacer(this.nodes, this.options).replace(node.value), precedence: escodegen.Precedence.Primary }; } @@ -2505,18 +3168,18 @@ var MemberExpressionObfuscator = function (_NodeObfuscator_1$Nod) { }]); return MemberExpressionObfuscator; -}(NodeObfuscator_1.NodeObfuscator); +}(AbstractNodeObfuscator_1.AbstractNodeObfuscator); exports.MemberExpressionObfuscator = MemberExpressionObfuscator; /***/ }, -/* 43 */ +/* 52 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2524,13 +3187,14 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var estraverse = __webpack_require__(4); -var NodeObfuscator_1 = __webpack_require__(6); -var Nodes_1 = __webpack_require__(5); +var estraverse = __webpack_require__(5); +var AbstractNodeObfuscator_1 = __webpack_require__(9); +var Nodes_1 = __webpack_require__(2); var Utils_1 = __webpack_require__(0); +var StringLiteralReplacer_1 = __webpack_require__(19); -var MethodDefinitionObfuscator = function (_NodeObfuscator_1$Nod) { - _inherits(MethodDefinitionObfuscator, _NodeObfuscator_1$Nod); +var MethodDefinitionObfuscator = function (_AbstractNodeObfuscat) { + _inherits(MethodDefinitionObfuscator, _AbstractNodeObfuscat); function MethodDefinitionObfuscator() { _classCallCheck(this, MethodDefinitionObfuscator); @@ -2552,10 +3216,10 @@ var MethodDefinitionObfuscator = function (_NodeObfuscator_1$Nod) { var _this2 = this; estraverse.replace(methodDefinitionNode.key, { - leave: function leave(node) { + enter: function enter(node) { if (Nodes_1.Nodes.isIdentifierNode(node) && !Utils_1.Utils.arrayContains(_this2.ignoredNames, node.name) && methodDefinitionNode.computed === false) { methodDefinitionNode.computed = true; - node.name = _this2.replaceLiteralValueWithUnicodeValue(node.name); + node.name = new StringLiteralReplacer_1.StringLiteralReplacer(_this2.nodes, _this2.options).replace(node.name); return; } return estraverse.VisitorOption.Skip; @@ -2565,18 +3229,18 @@ var MethodDefinitionObfuscator = function (_NodeObfuscator_1$Nod) { }]); return MethodDefinitionObfuscator; -}(NodeObfuscator_1.NodeObfuscator); +}(AbstractNodeObfuscator_1.AbstractNodeObfuscator); exports.MethodDefinitionObfuscator = MethodDefinitionObfuscator; /***/ }, -/* 44 */ +/* 53 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2584,15 +3248,15 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var escodegen = __webpack_require__(10); -var estraverse = __webpack_require__(4); +var escodegen = __webpack_require__(12); +var estraverse = __webpack_require__(5); var NodeType_1 = __webpack_require__(7); -var NodeObfuscator_1 = __webpack_require__(6); -var Nodes_1 = __webpack_require__(5); +var AbstractNodeObfuscator_1 = __webpack_require__(9); +var Nodes_1 = __webpack_require__(2); var Utils_1 = __webpack_require__(0); -var ObjectExpressionObfuscator = function (_NodeObfuscator_1$Nod) { - _inherits(ObjectExpressionObfuscator, _NodeObfuscator_1$Nod); +var ObjectExpressionObfuscator = function (_AbstractNodeObfuscat) { + _inherits(ObjectExpressionObfuscator, _AbstractNodeObfuscat); function ObjectExpressionObfuscator() { _classCallCheck(this, ObjectExpressionObfuscator); @@ -2610,7 +3274,7 @@ var ObjectExpressionObfuscator = function (_NodeObfuscator_1$Nod) { property.shorthand = false; } estraverse.replace(property.key, { - leave: function leave(node, parentNode) { + enter: function enter(node, parentNode) { if (Nodes_1.Nodes.isLiteralNode(node)) { _this2.obfuscateLiteralPropertyKey(node); return; @@ -2651,18 +3315,18 @@ var ObjectExpressionObfuscator = function (_NodeObfuscator_1$Nod) { }]); return ObjectExpressionObfuscator; -}(NodeObfuscator_1.NodeObfuscator); +}(AbstractNodeObfuscator_1.AbstractNodeObfuscator); exports.ObjectExpressionObfuscator = ObjectExpressionObfuscator; /***/ }, -/* 45 */ +/* 54 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2670,25 +3334,27 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var estraverse = __webpack_require__(4); +var estraverse = __webpack_require__(5); var NodeType_1 = __webpack_require__(7); -var NodeObfuscator_1 = __webpack_require__(6); +var AbstractNodeObfuscator_1 = __webpack_require__(9); +var IdentifierReplacer_1 = __webpack_require__(15); +var Nodes_1 = __webpack_require__(2); var NodeUtils_1 = __webpack_require__(1); -var VariableDeclarationObfuscator = function (_NodeObfuscator_1$Nod) { - _inherits(VariableDeclarationObfuscator, _NodeObfuscator_1$Nod); +var VariableDeclarationObfuscator = function (_AbstractNodeObfuscat) { + _inherits(VariableDeclarationObfuscator, _AbstractNodeObfuscat); - function VariableDeclarationObfuscator() { + function VariableDeclarationObfuscator(nodes, options) { _classCallCheck(this, VariableDeclarationObfuscator); - var _this = _possibleConstructorReturn(this, (VariableDeclarationObfuscator.__proto__ || Object.getPrototypeOf(VariableDeclarationObfuscator)).apply(this, arguments)); + var _this = _possibleConstructorReturn(this, (VariableDeclarationObfuscator.__proto__ || Object.getPrototypeOf(VariableDeclarationObfuscator)).call(this, nodes, options)); - _this.variableNames = new Map(); + _this.identifierReplacer = new IdentifierReplacer_1.IdentifierReplacer(_this.nodes, _this.options); return _this; } _createClass(VariableDeclarationObfuscator, [{ - key: "obfuscateNode", + key: 'obfuscateNode', value: function obfuscateNode(variableDeclarationNode, parentNode) { if (parentNode.type === NodeType_1.NodeType.Program) { return; @@ -2697,28 +3363,28 @@ var VariableDeclarationObfuscator = function (_NodeObfuscator_1$Nod) { this.replaceVariableNames(variableDeclarationNode, parentNode); } }, { - key: "storeVariableNames", + key: 'storeVariableNames', value: function storeVariableNames(variableDeclarationNode) { var _this2 = this; variableDeclarationNode.declarations.forEach(function (declarationNode) { - estraverse.traverse(declarationNode.id, { + NodeUtils_1.NodeUtils.typedReplace(declarationNode.id, NodeType_1.NodeType.Identifier, { enter: function enter(node) { - return _this2.storeIdentifiersNames(node, _this2.variableNames); + return _this2.identifierReplacer.storeNames(node.name); } }); }); } }, { - key: "replaceVariableNames", + key: 'replaceVariableNames', value: function replaceVariableNames(variableDeclarationNode, variableParentNode) { var _this3 = this; var scopeNode = variableDeclarationNode.kind === 'var' ? NodeUtils_1.NodeUtils.getBlockScopeOfNode(variableDeclarationNode) : variableParentNode; estraverse.replace(scopeNode, { enter: function enter(node, parentNode) { - if (!node.obfuscated) { - _this3.replaceIdentifiersWithRandomNames(node, parentNode, _this3.variableNames); + if (!node.obfuscated && Nodes_1.Nodes.isReplaceableIdentifierNode(node, parentNode)) { + node.name = _this3.identifierReplacer.replace(node.name); } } }); @@ -2726,18 +3392,57 @@ var VariableDeclarationObfuscator = function (_NodeObfuscator_1$Nod) { }]); return VariableDeclarationObfuscator; -}(NodeObfuscator_1.NodeObfuscator); +}(AbstractNodeObfuscator_1.AbstractNodeObfuscator); exports.VariableDeclarationObfuscator = VariableDeclarationObfuscator; /***/ }, -/* 46 */ +/* 55 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var JSFuck_1 = __webpack_require__(21); +var AbstractReplacer_1 = __webpack_require__(14); + +var BooleanLiteralReplacer = function (_AbstractReplacer_1$A) { + _inherits(BooleanLiteralReplacer, _AbstractReplacer_1$A); + + function BooleanLiteralReplacer() { + _classCallCheck(this, BooleanLiteralReplacer); + + return _possibleConstructorReturn(this, (BooleanLiteralReplacer.__proto__ || Object.getPrototypeOf(BooleanLiteralReplacer)).apply(this, arguments)); + } + + _createClass(BooleanLiteralReplacer, [{ + key: 'replace', + value: function replace(nodeValue) { + return nodeValue ? JSFuck_1.JSFuck.True : JSFuck_1.JSFuck.False; + } + }]); + + return BooleanLiteralReplacer; +}(AbstractReplacer_1.AbstractReplacer); + +exports.BooleanLiteralReplacer = BooleanLiteralReplacer; + +/***/ }, +/* 56 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2752,10 +3457,12 @@ var __decorate = undefined && undefined.__decorate || function (decorators, targ var __metadata = undefined && undefined.__metadata || function (k, v) { if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var class_validator_1 = __webpack_require__(62); -var DefaultPreset_1 = __webpack_require__(17); -var OptionsNormalizer_1 = __webpack_require__(47); -var ValidationErrorsFormatter_1 = __webpack_require__(48); +var class_validator_1 = __webpack_require__(82); +var TSourceMapMode_1 = __webpack_require__(79); +var TUnicodeArrayEncoding_1 = __webpack_require__(80); +var DefaultPreset_1 = __webpack_require__(23); +var OptionsNormalizer_1 = __webpack_require__(57); +var ValidationErrorsFormatter_1 = __webpack_require__(58); var Options = function Options(obfuscatorOptions) { _classCallCheck(this, Options); @@ -2777,37 +3484,49 @@ __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "debugProtection", void 0); __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "debugProtectionInterval", void 0); __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "disableConsoleOutput", void 0); -__decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "encodeUnicodeLiterals", void 0); -__decorate([class_validator_1.IsString({ +__decorate([class_validator_1.IsArray(), class_validator_1.ArrayUnique(), class_validator_1.IsString({ + each: true +}), __metadata('design:type', Array)], Options.prototype, "domainLock", void 0); +__decorate([class_validator_1.IsArray(), class_validator_1.ArrayUnique(), class_validator_1.IsString({ each: true }), __metadata('design:type', Array)], Options.prototype, "reservedNames", void 0); __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "rotateUnicodeArray", void 0); __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "selfDefending", void 0); __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "sourceMap", void 0); -__decorate([class_validator_1.IsIn(['inline', 'separate']), __metadata('design:type', String)], Options.prototype, "sourceMapMode", void 0); +__decorate([class_validator_1.IsString(), class_validator_1.ValidateIf(function (options) { + return Boolean(options.sourceMapBaseUrl); +}), class_validator_1.IsUrl({ + require_protocol: true, + require_valid_protocol: true +}), __metadata('design:type', String)], Options.prototype, "sourceMapBaseUrl", void 0); +__decorate([class_validator_1.IsString(), __metadata('design:type', String)], Options.prototype, "sourceMapFileName", void 0); +__decorate([class_validator_1.IsIn(['inline', 'separate']), __metadata('design:type', typeof (_a = typeof TSourceMapMode_1.TSourceMapMode !== 'undefined' && TSourceMapMode_1.TSourceMapMode) === 'function' && _a || Object)], Options.prototype, "sourceMapMode", void 0); __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "unicodeArray", void 0); +__decorate([class_validator_1.IsIn([true, false, 'base64', 'rc4']), __metadata('design:type', typeof (_b = typeof TUnicodeArrayEncoding_1.TUnicodeArrayEncoding !== 'undefined' && TUnicodeArrayEncoding_1.TUnicodeArrayEncoding) === 'function' && _b || Object)], Options.prototype, "unicodeArrayEncoding", void 0); __decorate([class_validator_1.IsNumber(), class_validator_1.Min(0), class_validator_1.Max(1), __metadata('design:type', Number)], Options.prototype, "unicodeArrayThreshold", void 0); -__decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "wrapUnicodeArrayCalls", void 0); exports.Options = Options; +var _a, _b; /***/ }, -/* 47 */ -/***/ function(module, exports) { +/* 57 */ +/***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +var Utils_1 = __webpack_require__(0); + var OptionsNormalizer = function () { function OptionsNormalizer() { _classCallCheck(this, OptionsNormalizer); } _createClass(OptionsNormalizer, null, [{ - key: "normalizeOptions", + key: 'normalizeOptions', value: function normalizeOptions(options) { var normalizedOptions = Object.assign({}, options); var _iteratorNormalCompletion = true; @@ -2838,15 +3557,43 @@ var OptionsNormalizer = function () { return normalizedOptions; } }, { - key: "encodeUnicodeLiteralsRule", - value: function encodeUnicodeLiteralsRule(options) { - if (options.unicodeArray && options.encodeUnicodeLiterals) { - Object.assign(options, OptionsNormalizer.ENCODE_UNICODE_LITERALS_OPTIONS); + key: 'domainLockRule', + value: function domainLockRule(options) { + if (options.domainLock.length) { + var normalizedDomains = []; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = options.domainLock[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var domain = _step2.value; + + normalizedDomains.push(Utils_1.Utils.extractDomainFromUrl(domain)); + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + Object.assign(options, { + domainLock: normalizedDomains + }); } return options; } }, { - key: "selfDefendingRule", + key: 'selfDefendingRule', value: function selfDefendingRule(options) { if (options.selfDefending) { Object.assign(options, OptionsNormalizer.SELF_DEFENDING_OPTIONS); @@ -2854,7 +3601,36 @@ var OptionsNormalizer = function () { return options; } }, { - key: "unicodeArrayRule", + key: 'sourceMapBaseUrl', + value: function sourceMapBaseUrl(options) { + var sourceMapBaseUrl = options.sourceMapBaseUrl; + if (!options.sourceMapFileName) { + Object.assign(options, { + sourceMapBaseUrl: '' + }); + return options; + } + if (sourceMapBaseUrl && !sourceMapBaseUrl.endsWith('/')) { + Object.assign(options, { + sourceMapBaseUrl: sourceMapBaseUrl + '/' + }); + } + return options; + } + }, { + key: 'sourceMapFileName', + value: function sourceMapFileName(options) { + var sourceMapFileName = options.sourceMapFileName; + if (sourceMapFileName) { + sourceMapFileName = sourceMapFileName.replace(/^\/+/, '').split('.')[0]; + Object.assign(options, { + sourceMapFileName: sourceMapFileName + '.js.map' + }); + } + return options; + } + }, { + key: 'unicodeArrayRule', value: function unicodeArrayRule(options) { if (!options.unicodeArray) { Object.assign(options, OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS); @@ -2862,7 +3638,15 @@ var OptionsNormalizer = function () { return options; } }, { - key: "unicodeArrayThresholdRule", + key: 'unicodeArrayEncodingRule', + value: function unicodeArrayEncodingRule(options) { + if (options.unicodeArrayEncoding === true) { + Object.assign(options, OptionsNormalizer.UNICODE_ARRAY_ENCODING_OPTIONS); + } + return options; + } + }, { + key: 'unicodeArrayThresholdRule', value: function unicodeArrayThresholdRule(options) { if (options.unicodeArrayThreshold === 0) { Object.assign(options, OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS); @@ -2875,31 +3659,29 @@ var OptionsNormalizer = function () { }(); OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS = { - encodeUnicodeLiterals: false, rotateUnicodeArray: false, unicodeArray: false, - unicodeArrayThreshold: 0, - wrapUnicodeArrayCalls: false -}; -OptionsNormalizer.ENCODE_UNICODE_LITERALS_OPTIONS = { - encodeUnicodeLiterals: true, - wrapUnicodeArrayCalls: true + unicodeArrayEncoding: false, + unicodeArrayThreshold: 0 }; OptionsNormalizer.SELF_DEFENDING_OPTIONS = { compact: true, selfDefending: true }; -OptionsNormalizer.normalizerRules = [OptionsNormalizer.unicodeArrayRule, OptionsNormalizer.unicodeArrayThresholdRule, OptionsNormalizer.encodeUnicodeLiteralsRule, OptionsNormalizer.selfDefendingRule]; +OptionsNormalizer.UNICODE_ARRAY_ENCODING_OPTIONS = { + unicodeArrayEncoding: 'base64' +}; +OptionsNormalizer.normalizerRules = [OptionsNormalizer.domainLockRule, OptionsNormalizer.selfDefendingRule, OptionsNormalizer.sourceMapBaseUrl, OptionsNormalizer.sourceMapFileName, OptionsNormalizer.unicodeArrayRule, OptionsNormalizer.unicodeArrayEncodingRule, OptionsNormalizer.unicodeArrayThresholdRule]; exports.OptionsNormalizer = OptionsNormalizer; /***/ }, -/* 48 */ +/* 58 */ /***/ function(module, exports) { "use strict"; "use strict"; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2960,7 +3742,352 @@ var ValidationErrorsFormatter = function () { exports.ValidationErrorsFormatter = ValidationErrorsFormatter; /***/ }, -/* 49 */ +/* 59 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var estraverse = __webpack_require__(5); +var NodeType_1 = __webpack_require__(7); +var FunctionDeclarationCalleeDataExtractor_1 = __webpack_require__(60); +var FunctionExpressionCalleeDataExtractor_1 = __webpack_require__(61); +var ObjectExpressionCalleeDataExtractor_1 = __webpack_require__(62); +var Nodes_1 = __webpack_require__(2); +var NodeUtils_1 = __webpack_require__(1); + +var StackTraceAnalyzer = function () { + function StackTraceAnalyzer(blockScopeBody) { + _classCallCheck(this, StackTraceAnalyzer); + + this.calleeDataExtractors = new Map([[NodeType_1.NodeType.FunctionDeclaration, FunctionDeclarationCalleeDataExtractor_1.FunctionDeclarationCalleeDataExtractor], [NodeType_1.NodeType.FunctionExpression, FunctionExpressionCalleeDataExtractor_1.FunctionExpressionCalleeDataExtractor], [NodeType_1.NodeType.ObjectExpression, ObjectExpressionCalleeDataExtractor_1.ObjectExpressionCalleeDataExtractor]]); + this.blockScopeBody = blockScopeBody; + } + + _createClass(StackTraceAnalyzer, [{ + key: 'analyze', + value: function analyze() { + return this.analyzeRecursive(this.blockScopeBody); + } + }, { + key: 'analyzeRecursive', + value: function analyzeRecursive(blockScopeBody) { + var _this = this; + + var limitIndex = StackTraceAnalyzer.getLimitIndex(blockScopeBody.length); + var stackTraceData = []; + + var _loop = function _loop(index, blockScopeBodyLength) { + var rootNode = blockScopeBody[index]; + if (index > limitIndex) { + return 'break'; + } + estraverse.traverse(rootNode, { + enter: function enter(node) { + if (!Nodes_1.Nodes.isCallExpressionNode(node) || rootNode.parentNode !== NodeUtils_1.NodeUtils.getBlockScopeOfNode(node)) { + return; + } + _this.calleeDataExtractors.forEach(function (calleeDataExtractor) { + var calleeData = new calleeDataExtractor(blockScopeBody, node.callee).extract(); + if (!calleeData) { + return; + } + stackTraceData.push(Object.assign({}, calleeData, { + stackTrace: _this.analyzeRecursive(calleeData.callee.body) + })); + }); + } + }); + }; + + for (var index = 0, blockScopeBodyLength = blockScopeBody.length; index < blockScopeBodyLength; index++) { + var _ret = _loop(index, blockScopeBodyLength); + + if (_ret === 'break') break; + } + return stackTraceData; + } + }], [{ + key: 'getLimitIndex', + value: function getLimitIndex(blockScopeBodyLength) { + var lastIndex = blockScopeBodyLength - 1; + var limitThresholdActivationIndex = StackTraceAnalyzer.limitThresholdActivationLength - 1; + var limitIndex = lastIndex; + if (lastIndex > limitThresholdActivationIndex) { + limitIndex = Math.round(limitThresholdActivationIndex + lastIndex * StackTraceAnalyzer.limitThreshold); + if (limitIndex > lastIndex) { + limitIndex = lastIndex; + } + } + return limitIndex; + } + }]); + + return StackTraceAnalyzer; +}(); + +StackTraceAnalyzer.limitThresholdActivationLength = 25; +StackTraceAnalyzer.limitThreshold = 0.002; +exports.StackTraceAnalyzer = StackTraceAnalyzer; + +/***/ }, +/* 60 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var estraverse = __webpack_require__(5); +var Nodes_1 = __webpack_require__(2); +var NodeUtils_1 = __webpack_require__(1); + +var FunctionDeclarationCalleeDataExtractor = function () { + function FunctionDeclarationCalleeDataExtractor(blockScopeBody, callee) { + _classCallCheck(this, FunctionDeclarationCalleeDataExtractor); + + this.blockScopeBody = blockScopeBody; + this.callee = callee; + } + + _createClass(FunctionDeclarationCalleeDataExtractor, [{ + key: 'extract', + value: function extract() { + var calleeBlockStatement = null; + if (Nodes_1.Nodes.isIdentifierNode(this.callee)) { + calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopeOfNode(this.blockScopeBody[0]), this.callee.name); + } + if (!calleeBlockStatement) { + return null; + } + return { + callee: calleeBlockStatement, + name: this.callee.name + }; + } + }, { + key: 'getCalleeBlockStatement', + value: function getCalleeBlockStatement(node, name) { + var calleeBlockStatement = null; + estraverse.traverse(node, { + enter: function enter(node) { + if (Nodes_1.Nodes.isFunctionDeclarationNode(node) && node.id.name === name) { + calleeBlockStatement = node.body; + return estraverse.VisitorOption.Break; + } + } + }); + return calleeBlockStatement; + } + }]); + + return FunctionDeclarationCalleeDataExtractor; +}(); + +exports.FunctionDeclarationCalleeDataExtractor = FunctionDeclarationCalleeDataExtractor; + +/***/ }, +/* 61 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var estraverse = __webpack_require__(5); +var Nodes_1 = __webpack_require__(2); +var NodeUtils_1 = __webpack_require__(1); + +var FunctionExpressionCalleeDataExtractor = function () { + function FunctionExpressionCalleeDataExtractor(blockScopeBody, callee) { + _classCallCheck(this, FunctionExpressionCalleeDataExtractor); + + this.blockScopeBody = blockScopeBody; + this.callee = callee; + } + + _createClass(FunctionExpressionCalleeDataExtractor, [{ + key: 'extract', + value: function extract() { + var calleeBlockStatement = null; + if (Nodes_1.Nodes.isIdentifierNode(this.callee)) { + calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopeOfNode(this.blockScopeBody[0]), this.callee.name); + } + if (Nodes_1.Nodes.isFunctionExpressionNode(this.callee)) { + calleeBlockStatement = this.callee.body; + } + if (!calleeBlockStatement) { + return null; + } + return { + callee: calleeBlockStatement, + name: this.callee.name || null + }; + } + }, { + key: 'getCalleeBlockStatement', + value: function getCalleeBlockStatement(node, name) { + var calleeBlockStatement = null; + estraverse.traverse(node, { + enter: function enter(node, parentNode) { + if (Nodes_1.Nodes.isFunctionExpressionNode(node) && Nodes_1.Nodes.isVariableDeclaratorNode(parentNode) && Nodes_1.Nodes.isIdentifierNode(parentNode.id) && parentNode.id.name === name) { + calleeBlockStatement = node.body; + return estraverse.VisitorOption.Break; + } + } + }); + return calleeBlockStatement; + } + }]); + + return FunctionExpressionCalleeDataExtractor; +}(); + +exports.FunctionExpressionCalleeDataExtractor = FunctionExpressionCalleeDataExtractor; + +/***/ }, +/* 62 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var estraverse = __webpack_require__(5); +var Nodes_1 = __webpack_require__(2); +var NodeUtils_1 = __webpack_require__(1); + +var ObjectExpressionCalleeDataExtractor = function () { + function ObjectExpressionCalleeDataExtractor(blockScopeBody, callee) { + _classCallCheck(this, ObjectExpressionCalleeDataExtractor); + + this.objectMembersCallsChain = []; + this.blockScopeBody = blockScopeBody; + this.callee = callee; + } + + _createClass(ObjectExpressionCalleeDataExtractor, [{ + key: 'extract', + value: function extract() { + var calleeBlockStatement = null, + functionExpressionName = null; + if (Nodes_1.Nodes.isMemberExpressionNode(this.callee)) { + this.objectMembersCallsChain = this.createObjectMembersCallsChain(this.objectMembersCallsChain, this.callee); + if (!this.objectMembersCallsChain.length) { + return null; + } + functionExpressionName = this.objectMembersCallsChain[this.objectMembersCallsChain.length - 1]; + calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopeOfNode(this.blockScopeBody[0]), this.objectMembersCallsChain); + } + if (!calleeBlockStatement) { + return null; + } + return { + callee: calleeBlockStatement, + name: functionExpressionName + }; + } + }, { + key: 'createObjectMembersCallsChain', + value: function createObjectMembersCallsChain(currentChain, memberExpression) { + if (Nodes_1.Nodes.isIdentifierNode(memberExpression.property)) { + currentChain.unshift(memberExpression.property.name); + } else if (Nodes_1.Nodes.isLiteralNode(memberExpression.property) && typeof memberExpression.property.value === 'string') { + currentChain.unshift(memberExpression.property.value); + } else { + return currentChain; + } + if (Nodes_1.Nodes.isMemberExpressionNode(memberExpression.object)) { + return this.createObjectMembersCallsChain(currentChain, memberExpression.object); + } + if (Nodes_1.Nodes.isIdentifierNode(memberExpression.object)) { + currentChain.unshift(memberExpression.object.name); + } + return currentChain; + } + }, { + key: 'getCalleeBlockStatement', + value: function getCalleeBlockStatement(node, objectMembersCallsChain) { + var _this = this; + + var objectName = objectMembersCallsChain.shift(); + var calleeBlockStatement = null; + estraverse.traverse(node, { + enter: function enter(node, parentNode) { + if (Nodes_1.Nodes.isVariableDeclaratorNode(node) && Nodes_1.Nodes.isIdentifierNode(node.id) && node.init && Nodes_1.Nodes.isObjectExpressionNode(node.init) && node.id.name === objectName) { + calleeBlockStatement = _this.findCalleeBlockStatement(node.init.properties, objectMembersCallsChain); + return estraverse.VisitorOption.Break; + } + } + }); + return calleeBlockStatement; + } + }, { + key: 'findCalleeBlockStatement', + value: function findCalleeBlockStatement(objectExpressionProperties, objectMembersCallsChain) { + var nextItemInCallsChain = objectMembersCallsChain.shift(); + if (!nextItemInCallsChain) { + return null; + } + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = objectExpressionProperties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var propertyNode = _step.value; + + var isTargetPropertyNodeWithIdentifierKey = Nodes_1.Nodes.isIdentifierNode(propertyNode.key) && propertyNode.key.name === nextItemInCallsChain; + var isTargetPropertyNodeWithLiteralKey = Nodes_1.Nodes.isLiteralNode(propertyNode.key) && Boolean(propertyNode.key.value) && propertyNode.key.value === nextItemInCallsChain; + if (!isTargetPropertyNodeWithIdentifierKey && !isTargetPropertyNodeWithLiteralKey) { + continue; + } + if (Nodes_1.Nodes.isObjectExpressionNode(propertyNode.value)) { + return this.findCalleeBlockStatement(propertyNode.value.properties, objectMembersCallsChain); + } + if (Nodes_1.Nodes.isFunctionExpressionNode(propertyNode.value)) { + return propertyNode.value.body; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return null; + } + }]); + + return ObjectExpressionCalleeDataExtractor; +}(); + +exports.ObjectExpressionCalleeDataExtractor = ObjectExpressionCalleeDataExtractor; + +/***/ }, +/* 63 */ /***/ function(module, exports) { "use strict"; @@ -2972,19 +4099,43 @@ function AtobTemplate() { exports.AtobTemplate = AtobTemplate; /***/ }, -/* 50 */ +/* 64 */ +/***/ function(module, exports) { + +"use strict"; +"use strict"; + +function Rc4Template() { + return "\n var rc4 = function (str, key) {\n var s = [], j = 0, x, res = '', newStr = '';\n \n str = atob(str);\n \n for (var k = 0, length = str.length; k < length; k++) {\n newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);\n }\n \n str = decodeURIComponent(newStr);\n \t \n\t for (var i = 0; i < 256; i++) {\n s[i] = i;\n }\n \n for (i = 0; i < 256; i++) {\n j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n }\n \n i = 0;\n j = 0;\n \n for (var y = 0; y < str.length; y++) {\n i = (i + 1) % 256;\n j = (j + s[i]) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);\n }\n \n return res;\n }\n "; +} +exports.Rc4Template = Rc4Template; + +/***/ }, +/* 65 */ +/***/ function(module, exports) { + +"use strict"; +"use strict"; + +function SingleNodeCallControllerTemplate() { + return "\n var {singleNodeCallControllerFunctionName} = (function(){\n var firstCall = true;\n \n return function (context, fn){\t\n var rfn = firstCall ? function(){\n if(fn){\n var res = fn.apply(context, arguments);\n fn = null;\n return res;\n }\n } : function(){}\n \n firstCall = false;\n \n return rfn;\n }\n })();\n "; +} +exports.SingleNodeCallControllerTemplate = SingleNodeCallControllerTemplate; + +/***/ }, +/* 66 */ /***/ function(module, exports) { "use strict"; "use strict"; function ConsoleOutputDisableExpressionTemplate() { - return "\n (function () {\n var _ = '(\u0004\u0006\u0003\u0005[]' + '[\"filter\"][\"\u0007tructor\"]' + '(\"return this\")()' + '.' + '\u0003;\u0006\u0002\u0005\u0004};' + '_\u0003.log\u0001.in' + 'fo\u0001.' + 'war' + 'n\u0001.er' + 'r' + 'or\u0001})();' + '\u0001\u0005_\u0002;' + '_\u0003\u0002function' + '\u0003\u0007ole\u0004\u0002 ()' + '{\u0005 = \u0006var ' + '_\u0007cons', \n Y, \n $;\n \n for (Y in $ = \"\u0007\u0006\u0005\u0004\u0003\u0002\u0001\") {\n var arr = _.split($[Y]);\n _ = arr.join(arr.pop());\n }\n \n [][\"filter\"][\"constructor\"](_)();\n })()\n "; + return "\n var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var getGlobal = Function('return typeof self !== \"undefined\"' + ' ? self : ' + 'typeof window !== \"undefined\"' + ' ? window : ' + 'typeof global !== \"undefined\"' + ' ? global : ' + '[][\"filter\"][\"constructor\"](\"return this\")()');\n \n var func = Function('for ' + '(;;)' + ' {}');\n var that = getGlobal();\n \n that.console.log = func; \n that.console.error = func;\n that.console.warn = func;\n that.console.info = func;\n });\n \n {consoleLogDisableFunctionName}();\n "; } exports.ConsoleOutputDisableExpressionTemplate = ConsoleOutputDisableExpressionTemplate; /***/ }, -/* 51 */ +/* 67 */ /***/ function(module, exports) { "use strict"; @@ -2996,7 +4147,7 @@ function DebugProtectionFunctionCallTemplate() { exports.DebugProtectionFunctionCallTemplate = DebugProtectionFunctionCallTemplate; /***/ }, -/* 52 */ +/* 68 */ /***/ function(module, exports) { "use strict"; @@ -3008,7 +4159,7 @@ function DebugProtectionFunctionIntervalTemplate() { exports.DebugProtectionFunctionIntervalTemplate = DebugProtectionFunctionIntervalTemplate; /***/ }, -/* 53 */ +/* 69 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -3016,12 +4167,24 @@ exports.DebugProtectionFunctionIntervalTemplate = DebugProtectionFunctionInterva var Utils_1 = __webpack_require__(0); function DebugProtectionFunctionTemplate() { - return "\n var {debugProtectionFunctionName} = function () {\n function debuggerProtection (counter) {\n if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {\n (function () {}.constructor('debugger')());\n } else {\n [].filter.constructor(" + Utils_1.Utils.stringToJSFuck('debugger') + ")();\n }\n \n debuggerProtection(++counter);\n }\n \n try {\n debuggerProtection(0);\n } catch (y) {}\n };\n "; + return '\n var {debugProtectionFunctionName} = function () {\n function debuggerProtection (counter) {\n if ((\'\' + counter / counter)[\'length\'] !== 1 || counter % 20 === 0) {\n (function () {}.constructor(\'debugger\')());\n } else {\n [].filter.constructor(' + Utils_1.Utils.stringToJSFuck('debugger') + ')();\n }\n \n debuggerProtection(++counter);\n }\n \n try {\n debuggerProtection(0);\n } catch (y) {}\n };\n '; } exports.DebugProtectionFunctionTemplate = DebugProtectionFunctionTemplate; /***/ }, -/* 54 */ +/* 70 */ +/***/ function(module, exports) { + +"use strict"; +"use strict"; + +function DomainLockNodeTemplate() { + return "\n var {domainLockFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var getGlobal = Function('return typeof self !== \"undefined\"' + ' ? self : ' + 'typeof window !== \"undefined\"' + ' ? window : ' + 'typeof global !== \"undefined\"' + ' ? global : ' + '[][\"filter\"][\"constructor\"](\"return this\")()');\n \n var func = function () { \n return {\n key: 'item',\n value: 'attribute',\n getAttribute: function () {\n getGlobal()['eval']('while(true){}')();\n }()\n };\n };\n \n var regExp = new RegExp(\"[{diff}]\", \"g\");\n var domains = \"{domains}\".replace(regExp, \"\").split(\";\");\n var eval = [][\"forEach\"][\"constructor\"];\n var windowObject = eval(\"return this\")();\n var document;\n var domain;\n \n for (var d in windowObject) {\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 windowObject[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) || (!windowObject[document] && !windowObject[document][domain])) {\n return;\n }\n \n var currentDomain = windowObject[document][domain];\n\n var ok = false;\n \n for (var i = 0; i < domains.length; i++) {\n var domain = domains[i];\n var position = currentDomain.length - domain.length;\n var lastIndex = currentDomain.indexOf(domain, position);\n var endsWith = lastIndex !== -1 && lastIndex === position;\n \n if (endsWith) {\n if (currentDomain.length == domain.length || domain.indexOf(\".\") === 0) {\n ok = true;\n }\n \n break;\n }\n }\n \n if (!ok) {\n data;\n } else {\n return;\n }\n \n func();\n });\n\n {domainLockFunctionName}();\n "; +} +exports.DomainLockNodeTemplate = DomainLockNodeTemplate; + +/***/ }, +/* 71 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -3029,49 +4192,61 @@ exports.DebugProtectionFunctionTemplate = DebugProtectionFunctionTemplate; var Utils_1 = __webpack_require__(0); function SelfDefendingTemplate() { - return "\n (function () { \n var func = function(){return 'dev';},\n func2 = function () {\n return 'window';\n };\n \n !Function(" + Utils_1.Utils.stringToUnicode("return/\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}/") + ")().test(func.toString()) ? Function(" + Utils_1.Utils.stringToUnicode("return/(\\\\[x|u](\\w){2,4})+/") + ")().test(func2.toString()) ? []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(false){}')() : []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(true){}')() : []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(false){}')();\n })();\n "; + return "\n var {selfDefendingFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var func1 = function(){return 'dev';},\n func2 = function () {\n return 'window';\n };\n \n var test1 = function () {\n var regExp = new RegExp(" + Utils_1.Utils.stringToUnicode("\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}") + ");\n \n return !regExp.test(func1.toString());\n };\n \n var test2 = function () {\n var regExp = new RegExp(" + Utils_1.Utils.stringToUnicode("(\\\\[x|u](\\w){2,4})+") + ");\n \n return regExp.test(func2.toString());\n };\n \n var recursiveFunc1 = function (string) {\n var i = ~-1 >> 1 + 255 % 0;\n \n if (string.indexOf('i' === i)) {\n recursiveFunc2(string)\n }\n };\n \n var recursiveFunc2 = function (string) {\n var i = ~-4 >> 1 + 255 % 0;\n \n if (string.indexOf((true+\"\")[3]) !== i) {\n recursiveFunc1(string)\n }\n };\n \n if (!test1()) {\n if (!test2()) {\n recursiveFunc1('ind\u0435xOf');\n } else {\n recursiveFunc1('indexOf');\n }\n } else {\n recursiveFunc1('ind\u0435xOf');\n }\n })\n \n {selfDefendingFunctionName}();\n "; } exports.SelfDefendingTemplate = SelfDefendingTemplate; /***/ }, -/* 55 */ +/* 72 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +"use strict"; + +var Utils_1 = __webpack_require__(0); +function SelfDefendingTemplate() { + return "\n var StatesClass = function (rc4Bytes) {\n this.rc4Bytes = rc4Bytes;\n this.states = [1, 0, 0];\n this.newState = function(){return 'newState';};\n this.firstState = " + Utils_1.Utils.stringToUnicode("\\w+ *\\(\\) *{\\w+ *") + ";\n this.secondState = " + Utils_1.Utils.stringToUnicode("['|\"].+['|\"];? *}") + ";\n };\n \n StatesClass.prototype.checkState = function () {\n var regExp = new RegExp(this.firstState + this.secondState);\n\n return this.runState(regExp.test(this.newState.toString()) ? --this.states[1] : --this.states[0]);\n };\n \n StatesClass.prototype.runState = function (stateResult) {\n if (!Boolean(~stateResult)) {\n return stateResult;\n }\n \n return this.getState(this.rc4Bytes);\n };\n\n StatesClass.prototype.getState = function (rc4Bytes) {\n for (var i = 0, len = this.states.length; i < len; i++) {\n this.states.push(Math.round(Math.random()));\n len = this.states.length;\n }\n \n return rc4Bytes(this.states[0]);\n };\n\n new StatesClass({unicodeArrayCallsWrapperName}).checkState();\n "; +} +exports.SelfDefendingTemplate = SelfDefendingTemplate; + +/***/ }, +/* 73 */ +/***/ function(module, exports) { + +"use strict"; +"use strict"; + +function UnicodeArrayBase64DecodeNodeTemplate() { + return " \n if (!{unicodeArrayCallsWrapperName}.atobPolyfillAppended) {\n {atobPolyfill}\n \n {unicodeArrayCallsWrapperName}.atobPolyfillAppended = true;\n }\n \n if (!{unicodeArrayCallsWrapperName}.base64DecodeUnicode) { \n {unicodeArrayCallsWrapperName}.base64DecodeUnicode = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n }\n \n if (!{unicodeArrayCallsWrapperName}.data) {\n {unicodeArrayCallsWrapperName}.data = {};\n }\n \n if (!{unicodeArrayCallsWrapperName}.data[index]) {\n {selfDefendingCode}\n \n value = {unicodeArrayCallsWrapperName}.base64DecodeUnicode(value);\n {unicodeArrayCallsWrapperName}.data[index] = value;\n } else {\n value = {unicodeArrayCallsWrapperName}.data[index];\n } \n "; +} +exports.UnicodeArrayBase64DecodeNodeTemplate = UnicodeArrayBase64DecodeNodeTemplate; + +/***/ }, +/* 74 */ /***/ function(module, exports) { "use strict"; "use strict"; function UnicodeArrayCallsWrapperTemplate() { - return "\n var {unicodeArrayCallsWrapperName} = function ({keyName}) {\n return {unicodeArrayName}[parseInt({keyName}, 0x010)];\n };\n "; + return "\n var {unicodeArrayCallsWrapperName} = function (index, key) {\n var index = parseInt(index, 0x10);\n var value = {unicodeArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "; } exports.UnicodeArrayCallsWrapperTemplate = UnicodeArrayCallsWrapperTemplate; /***/ }, -/* 56 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -"use strict"; - -var Utils_1 = __webpack_require__(0); -function SelfDefendingTemplate() { - return "\n var func = function(){return 'dev';};\n \n Function(" + Utils_1.Utils.stringToUnicode("return/\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}/") + ")()['test'](func['toString']()) !== true && !{unicodeArrayName}++ ? []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(true){}')() : Function('a', atob(" + Utils_1.Utils.stringToUnicode(Utils_1.Utils.btoa('a.call()')) + "))({forLoopFunctionName}) ? []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(false){}')() : []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(false){}')();\n "; -} -exports.SelfDefendingTemplate = SelfDefendingTemplate; - -/***/ }, -/* 57 */ +/* 75 */ /***/ function(module, exports) { "use strict"; "use strict"; -function UnicodeArrayDecodeTemplate() { - return "\n (function () {\n {atobPolyfill}\n \n var {forLoopFunctionName} = function () {\n var array = [];\n \n for (var i in {unicodeArrayName}) {\n array['push'](decodeURI(atob({unicodeArrayName}[i])));\n }\n \n {unicodeArrayName} = array;\n };\n \n {code}\n })();\n "; +function UnicodeArrayRc4DecodeNodeTemplate() { + return "\n if (!{unicodeArrayCallsWrapperName}.atobPolyfillAppended) { \n {atobPolyfill}\n \n {unicodeArrayCallsWrapperName}.atobPolyfillAppended = true;\n }\n \n if (!{unicodeArrayCallsWrapperName}.rc4) { \n {rc4Polyfill}\n \n {unicodeArrayCallsWrapperName}.rc4 = rc4;\n }\n \n if (!{unicodeArrayCallsWrapperName}.data) {\n {unicodeArrayCallsWrapperName}.data = {};\n }\n\n if ({unicodeArrayCallsWrapperName}.data[index] === undefined) {\n if (!{unicodeArrayCallsWrapperName}.once) {\n {selfDefendingCode}\n \n {unicodeArrayCallsWrapperName}.once = true;\n }\n \n value = {unicodeArrayCallsWrapperName}.rc4(value, key);\n {unicodeArrayCallsWrapperName}.data[index] = value;\n } else {\n value = {unicodeArrayCallsWrapperName}.data[index];\n }\n "; } -exports.UnicodeArrayDecodeTemplate = UnicodeArrayDecodeTemplate; +exports.UnicodeArrayRc4DecodeNodeTemplate = UnicodeArrayRc4DecodeNodeTemplate; /***/ }, -/* 58 */ +/* 76 */ /***/ function(module, exports) { "use strict"; @@ -3083,7 +4258,7 @@ function UnicodeArrayTemplate() { exports.UnicodeArrayTemplate = UnicodeArrayTemplate; /***/ }, -/* 59 */ +/* 77 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -3091,12 +4266,12 @@ exports.UnicodeArrayTemplate = UnicodeArrayTemplate; var Utils_1 = __webpack_require__(0); function SelfDefendingTemplate() { - return "(function () {\n var func = function(){return 'dev';};\n \n !Function(" + Utils_1.Utils.stringToUnicode("return/\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}/") + ")().test(func.toString()) ? []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(true){}')() : Function('a', 'b', 'a(++b)')({whileFunctionName}, {timesName}) ? []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(false){}')() : []['filter']['constructor'](" + Utils_1.Utils.stringToJSFuck('while') + " + '(false){}')();\n })();"; + return "\n var selfDefendingFunc = function () { \n var object = {\n data: {\n key: 'cookie',\n value: 'timeout'\n },\n setCookie: function (options, name, value, document) {\n document = document || {};\n \n var updatedCookie = name + \"=\" + value;\n\n var i = 0;\n \n for (var i = 0, len = options.length; i < len; i++) { \n var propName = options[i];\n \n updatedCookie += \"; \" + propName;\n \n var propValue = options[propName];\n \n options.push(propValue);\n len = options.length;\n \n if (propValue !== true) {\n updatedCookie += \"=\" + propValue;\n }\n }\n\n document['cookie'] = updatedCookie;\n },\n removeCookie: function(){return 'dev';},\n getCookie: function (document, name) { \n document = document || function (value) { return value };\n var matches = document(new RegExp(\n \"(?:^|; )\" + name.replace(/([.$?*|{}()[]\\/+^])/g, '\\$1') + \"=([^;]*)\"\n ));\n \n var func = function (param1, param2) {\n param1(++param2);\n };\n \n func({whileFunctionName}, {timesName});\n \n return matches ? decodeURIComponent(matches[1]) : undefined;\n }\n };\n \n var test1 = function () {\n var regExp = new RegExp(" + Utils_1.Utils.stringToUnicode("\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}") + ");\n \n return regExp.test(object.removeCookie.toString());\n };\n \n object['updateCookie'] = test1;\n \n var cookie = '';\n var result = object['updateCookie']();\n \n if (!result) {\n object['setCookie'](['*'], 'counter', 1);\n } else if (result) {\n cookie = object['getCookie'](null, 'counter'); \n } else {\n object['removeCookie']();\n }\n };\n \n selfDefendingFunc();\n "; } exports.SelfDefendingTemplate = SelfDefendingTemplate; /***/ }, -/* 60 */ +/* 78 */ /***/ function(module, exports) { "use strict"; @@ -3108,45 +4283,60 @@ function UnicodeArrayRotateFunctionTemplate() { exports.UnicodeArrayRotateFunctionTemplate = UnicodeArrayRotateFunctionTemplate; /***/ }, -/* 61 */ +/* 79 */ +/***/ function(module, exports) { + +"use strict"; +"use strict"; + +/***/ }, +/* 80 */ +/***/ function(module, exports) { + +"use strict"; +"use strict"; + +/***/ }, +/* 81 */ /***/ function(module, exports) { module.exports = require("chance"); /***/ }, -/* 62 */ +/* 82 */ /***/ function(module, exports) { module.exports = require("class-validator"); /***/ }, -/* 63 */ +/* 83 */ /***/ function(module, exports) { module.exports = require("commander"); /***/ }, -/* 64 */ +/* 84 */ /***/ function(module, exports) { module.exports = require("fs"); /***/ }, -/* 65 */ +/* 85 */ /***/ function(module, exports) { module.exports = require("mkdirp"); /***/ }, -/* 66 */ +/* 86 */, +/* 87 */ /***/ function(module, exports, __webpack_require__) { "use strict"; "use strict"; -var JavaScriptObfuscator_1 = __webpack_require__(9); +var JavaScriptObfuscator_1 = __webpack_require__(10); if (!global._babelPolyfill) { - __webpack_require__(20); + __webpack_require__(26); } module.exports = JavaScriptObfuscator_1.JavaScriptObfuscator; diff --git a/package.json b/package.json index 18e08781..24e6f9a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "javascript-obfuscator", - "version": "0.7.2", + "version": "0.8.0-dev.3", "description": "JavaScript obfuscator", "keywords": [ "obfuscator", @@ -20,49 +20,49 @@ "javascript-obfuscator": "./bin/javascript-obfuscator.js" }, "dependencies": { - "babel-polyfill": "^6.13.0", - "chance": "^1.0.4", - "class-validator": "^0.6.1", - "commander": "^2.9.0", - "escodegen": "^1.8.1", - "esprima": "^3.0.0", - "estraverse": "^4.2.0", - "format-unicorn": "^1.1.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.4.2" + "babel-polyfill": "6.16.0", + "chance": "1.0.4", + "class-validator": "0.6.4", + "commander": "2.9.0", + "escodegen": "1.8.1", + "esprima": "3.1.1", + "estraverse": "4.2.0", + "format-unicorn": "1.1.0", + "mkdirp": "0.5.1", + "source-map-support": "0.4.6" }, "devDependencies": { - "@types/chai": "^3.4.32", - "@types/chance": "^0.7.28", - "@types/commander": "^2.3.29", - "@types/escodegen": "0.0.3", - "@types/esprima": "^2.1.31", - "@types/estraverse": "0.0.3", - "@types/format-unicorn": "^0.0.29", - "@types/joi": "^9.0.31", - "@types/mkdirp": "^0.3.28", - "@types/mocha": "^2.2.31", - "@types/node": "^4.0.30", - "@types/sinon": "^1.16.29", - "babel-cli": "^6.14.0", - "babel-loader": "^6.2.5", - "babel-preset-es2015": "^6.14.0", - "chai": "^3.5.0", - "coveralls": "^2.11.14", + "@types/chai": "3.4.34", + "@types/chance": "0.7.30", + "@types/commander": "2.3.30", + "@types/escodegen": "0.0.6", + "@types/esprima": "2.1.33", + "@types/estraverse": "0.0.6", + "@types/estree": "0.0.34", + "@types/format-unicorn": "0.0.29", + "@types/joi": "9.0.32", + "@types/mkdirp": "0.3.29", + "@types/mocha": "2.2.32", + "@types/node": "6.0.46", + "@types/sinon": "1.16.31", + "awesome-typescript-loader": "2.2.4", + "babel-cli": "6.18.0", + "babel-loader": "6.2.7", + "babel-preset-es2015": "6.18.0", + "chai": "3.5.0", + "coveralls": "2.11.14", "istanbul": "1.1.0-alpha.1", - "mocha": "^3.0.2", - "optimize-js-plugin": "0.0.4", - "sinon": "^2.0.0-pre.3", - "ts-loader": "^0.8.2", - "ts-node": "^1.3.0", - "tslint": "^3.15.1", - "typescript": "^2.0.0", - "webpack": "^2.1.0-beta.25", - "webpack-node-externals": "^1.4.3" + "mocha": "3.1.2", + "sinon": "2.0.0-pre.3", + "ts-node": "1.6.1", + "tslint": "3.15.1", + "typescript": "2.0.7", + "webpack": "2.1.0-beta.25", + "webpack-node-externals": "1.5.4" }, "repository": { "type": "git", - "url": "git+https://github.com/sanex3339/javascript-obfuscator.git" + "url": "git+https://github.com/javascript-obfuscator/javascript-obfuscator.git" }, "scripts": { "start": "scripts/start", @@ -71,6 +71,8 @@ "watch": "scripts/watch", "test:compile": "scripts/test-compile", "test:dev": "scripts/test-dev", + "test:devCompilePerformance": "scripts/test-dev-compile-performance", + "test:devRuntimePerformance": "scripts/test-dev-runtime-performance", "test:full": "scripts/test-full", "test:coveralls": "scripts/test-coveralls", "test:mocha": "scripts/test-mocha", @@ -83,4 +85,4 @@ "name": "Timofey Kachalov" }, "license": "BSD-2-Clause" -} \ No newline at end of file +} diff --git a/scripts/build b/scripts/build index a3dccd46..3c551801 100755 --- a/scripts/build +++ b/scripts/build @@ -1,5 +1,5 @@ #!/bin/bash -npm run webpack -npm run tslint +npm run webpack && +npm run tslint && npm test \ No newline at end of file diff --git a/scripts/test-compile b/scripts/test-compile index 5fc04bec..6d0ca7fa 100755 --- a/scripts/test-compile +++ b/scripts/test-compile @@ -1,4 +1,4 @@ #!/bin/bash -$(npm bin)/tsc -p tsconfig-test.json +$(npm bin)/tsc -p tsconfig-test.json && $(npm bin)/babel test-tmp --out-dir test-tmp --source-maps inline --presets es2015 \ No newline at end of file diff --git a/scripts/test-coveralls b/scripts/test-coveralls index 03e4615a..dbeffbe4 100755 --- a/scripts/test-coveralls +++ b/scripts/test-coveralls @@ -1,6 +1,6 @@ #!/bin/bash -npm run test:compile -$(npm bin)/istanbul cover $(npm bin)/_mocha -- test-tmp/test/index.spec.js --report lcovonly -cat ./coverage/lcov.info | $(npm bin)/coveralls +npm run test:compile && +$(npm bin)/istanbul cover $(npm bin)/_mocha -- test-tmp/test/index.spec.js --report lcovonly && +cat ./coverage/lcov.info | $(npm bin)/coveralls && npm run test:removeTmpDir \ No newline at end of file diff --git a/scripts/test-dev b/scripts/test-dev index 9859cff9..574c877f 100755 --- a/scripts/test-dev +++ b/scripts/test-dev @@ -1,3 +1,3 @@ #!/bin/bash -$(npm bin)/ts-node test/dev/test.ts \ No newline at end of file +$(npm bin)/ts-node test/dev/dev.ts \ No newline at end of file diff --git a/scripts/test-dev-compile-performance b/scripts/test-dev-compile-performance new file mode 100755 index 00000000..830f2734 --- /dev/null +++ b/scripts/test-dev-compile-performance @@ -0,0 +1,3 @@ +#!/bin/bash + +$(npm bin)/ts-node test/dev/dev-compile-performance.ts \ No newline at end of file diff --git a/scripts/test-dev-runtime-performance b/scripts/test-dev-runtime-performance new file mode 100755 index 00000000..b398c877 --- /dev/null +++ b/scripts/test-dev-runtime-performance @@ -0,0 +1,3 @@ +#!/bin/bash + +$(npm bin)/ts-node test/dev/dev-runtime-performance.ts \ No newline at end of file diff --git a/scripts/test-full b/scripts/test-full index e7cfc94f..268eabb5 100755 --- a/scripts/test-full +++ b/scripts/test-full @@ -1,6 +1,6 @@ #!/bin/bash -npm run test:compile -node test-tmp/test/dev/test.js -$(npm bin)/istanbul cover $(npm bin)/_mocha -- test-tmp/test/index.spec.js +npm run test:compile && +node test-tmp/test/dev/dev.js && +$(npm bin)/istanbul cover $(npm bin)/_mocha -- test-tmp/test/index.spec.js && npm run test:removeTmpDir \ No newline at end of file diff --git a/scripts/test-mocha b/scripts/test-mocha index 03570593..b6523b91 100755 --- a/scripts/test-mocha +++ b/scripts/test-mocha @@ -1,5 +1,5 @@ #!/bin/bash -npm run test:compile -$(npm bin)/mocha test-tmp/test/index.spec.js +npm run test:compile && +$(npm bin)/mocha test-tmp/test/index.spec.js && npm run test:removeTmpDir \ No newline at end of file diff --git a/scripts/travis b/scripts/travis index 2d4e4775..8ebc6706 100755 --- a/scripts/travis +++ b/scripts/travis @@ -1,4 +1,4 @@ #!/bin/bash -npm run tslint +npm run tslint && npm test \ No newline at end of file diff --git a/src/JavaScriptObfuscator.ts b/src/JavaScriptObfuscator.ts index edb08f75..561e4d6b 100644 --- a/src/JavaScriptObfuscator.ts +++ b/src/JavaScriptObfuscator.ts @@ -1,8 +1,8 @@ -import { IObfuscationResult } from "./interfaces/IObfuscationResult"; -import { IObfuscatorOptions } from "./interfaces/IObfuscatorOptions"; +import { IObfuscationResult } from './interfaces/IObfuscationResult'; +import { IObfuscatorOptions } from './interfaces/IObfuscatorOptions'; -import { JavaScriptObfuscatorCLI } from "./cli/JavaScriptObfuscatorCLI"; -import { JavaScriptObfuscatorInternal } from "./JavaScriptObfuscatorInternal"; +import { JavaScriptObfuscatorCLI } from './cli/JavaScriptObfuscatorCLI'; +import { JavaScriptObfuscatorInternal } from './JavaScriptObfuscatorInternal'; export class JavaScriptObfuscator { /** diff --git a/src/JavaScriptObfuscatorInternal.ts b/src/JavaScriptObfuscatorInternal.ts index 2367ae70..4c32e958 100644 --- a/src/JavaScriptObfuscatorInternal.ts +++ b/src/JavaScriptObfuscatorInternal.ts @@ -1,16 +1,16 @@ import * as esprima from 'esprima'; import * as escodegen from 'escodegen'; +import * as ESTree from 'estree'; -import { IObfuscatorOptions } from "./interfaces/IObfuscatorOptions"; -import { IGeneratorOutput } from "./interfaces/IGeneratorOutput"; -import { INode } from './interfaces/nodes/INode'; -import { IObfuscationResult } from "./interfaces/IObfuscationResult"; +import { IObfuscatorOptions } from './interfaces/IObfuscatorOptions'; +import { IGeneratorOutput } from './interfaces/IGeneratorOutput'; +import { IObfuscationResult } from './interfaces/IObfuscationResult'; import { IOptions } from './interfaces/IOptions'; -import { ObfuscationResult } from "./ObfuscationResult"; -import { Obfuscator } from "./Obfuscator"; -import { Options } from "./options/Options"; -import { SourceMapCorrector } from "./SourceMapCorrector"; +import { ObfuscationResult } from './ObfuscationResult'; +import { Obfuscator } from './Obfuscator'; +import { Options } from './options/Options'; +import { SourceMapCorrector } from './SourceMapCorrector'; export class JavaScriptObfuscatorInternal { /** @@ -36,21 +36,13 @@ export class JavaScriptObfuscatorInternal { */ private sourceCode: string; - /** - * @type {string} - */ - private sourceMapUrl: string = ''; - /** * @param sourceCode * @param obfuscatorOptions */ - constructor (sourceCode: string, obfuscatorOptions?: IObfuscatorOptions) { + constructor (sourceCode: string, obfuscatorOptions: IObfuscatorOptions = {}) { this.sourceCode = sourceCode; - - if (obfuscatorOptions) { - this.options = new Options(obfuscatorOptions); - } + this.options = new Options(obfuscatorOptions); } /** @@ -58,12 +50,11 @@ export class JavaScriptObfuscatorInternal { * @param astTree * @param options */ - private static generateCode (sourceCode: string, astTree: INode, options: IOptions): IGeneratorOutput { - let escodegenParams: escodegen.GenerateOptions = Object.assign( - {}, - JavaScriptObfuscatorInternal.escodegenParams - ), - generatorOutput: IGeneratorOutput; + private static generateCode (sourceCode: string, astTree: ESTree.Node, options: IOptions): IGeneratorOutput { + const escodegenParams: escodegen.GenerateOptions = Object.assign( + {}, + JavaScriptObfuscatorInternal.escodegenParams + ); if (options.sourceMap) { escodegenParams.sourceMap = 'sourceMap'; @@ -74,7 +65,8 @@ export class JavaScriptObfuscatorInternal { compact: options.compact }; - generatorOutput = escodegen.generate(astTree, escodegenParams); + const generatorOutput: IGeneratorOutput = escodegen.generate(astTree, escodegenParams); + generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : ''; return generatorOutput; @@ -89,13 +81,13 @@ export class JavaScriptObfuscatorInternal { this.generatorOutput.code, this.generatorOutput.map ), - this.sourceMapUrl, + this.options.sourceMapBaseUrl + this.options.sourceMapFileName, this.options.sourceMapMode ).correct(); } public obfuscate (): void { - let astTree: INode = esprima.parse(this.sourceCode, { + let astTree: ESTree.Node = esprima.parse(this.sourceCode, { loc: true }); @@ -103,11 +95,4 @@ export class JavaScriptObfuscatorInternal { this.generatorOutput = JavaScriptObfuscatorInternal.generateCode(this.sourceCode, astTree, this.options); } - - /** - * @param url - */ - public setSourceMapUrl (url: string): void { - this.sourceMapUrl = url; - } } diff --git a/src/NodeAppender.ts b/src/NodeAppender.ts new file mode 100644 index 00000000..e07a6831 --- /dev/null +++ b/src/NodeAppender.ts @@ -0,0 +1,177 @@ +import * as ESTree from 'estree'; + +import { TNodeWithBlockStatement } from './types/TNodeWithBlockStatement'; +import { TStatement } from './types/TStatement'; + +import { IStackTraceData } from './interfaces/stack-trace-analyzer/IStackTraceData'; + +import { Utils } from './Utils'; + +/** + * This class appends node into a first deepest BlockStatement in order of function calls + * + * For example: + * + * function Foo () { + * var baz = function () { + * + * } + * + * baz(); + * } + * + * foo(); + * + * Appends node into block statement of `baz` function expression. + */ +export class NodeAppender { + /** + * @param blockScopeNode + * @param nodeBodyStatements + */ + public static appendNode ( + blockScopeNode: TNodeWithBlockStatement, + nodeBodyStatements: TStatement[] + ): void { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + + blockScopeNode.body = [ + ...blockScopeNode.body, + ...nodeBodyStatements + ]; + } + + /** + * @param blockScopeStackTraceData + * @param blockScopeNode + * @param nodeBodyStatements + * @param index + */ + public static appendNodeToOptimalBlockScope ( + blockScopeStackTraceData: IStackTraceData[], + blockScopeNode: TNodeWithBlockStatement, + nodeBodyStatements: TStatement[], + index: number = 0 + ): void { + let targetBlockScope: TNodeWithBlockStatement; + + if (!blockScopeStackTraceData.length) { + targetBlockScope = blockScopeNode; + } else { + targetBlockScope = NodeAppender.getOptimalBlockScope( + blockScopeStackTraceData, + index + ); + } + + NodeAppender.prependNode(targetBlockScope, nodeBodyStatements); + } + + /** + * Returns deepest block scope node at given deep. + * + * @param blockScopeTraceData + * @param index + * @param deep + * @returns {ESTree.BlockStatement} + */ + public static getOptimalBlockScope ( + blockScopeTraceData: IStackTraceData[], + index: number, + deep: number = Infinity + ): ESTree.BlockStatement { + const firstCall: IStackTraceData = blockScopeTraceData[index]; + + if (deep <= 0) { + throw new Error(`Invalid \`deep\` argument value. Value should be bigger then 0.`); + } + + if (deep > 1 && firstCall.stackTrace.length) { + return NodeAppender.getOptimalBlockScope(firstCall.stackTrace, 0, --deep); + } else { + return firstCall.callee; + } + } + + /** + * @param stackTraceRootLength + */ + public static getRandomStackTraceIndex (stackTraceRootLength: number): number { + return Utils.getRandomGenerator().integer({ + min: 0, + max: Math.max(0, Math.round(stackTraceRootLength - 1)) + }); + } + + /** + * @param blockScopeNode + * @param nodeBodyStatements + * @param index + */ + public static insertNodeAtIndex ( + blockScopeNode: TNodeWithBlockStatement, + nodeBodyStatements: TStatement[], + index: number + ): void { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + + blockScopeNode.body = [ + ...blockScopeNode.body.slice(0, index), + ...nodeBodyStatements, + ...blockScopeNode.body.slice(index) + ]; + } + + /** + * @param blockScopeNode + * @param nodeBodyStatements + */ + public static prependNode ( + blockScopeNode: TNodeWithBlockStatement, + nodeBodyStatements: TStatement[] + ): void { + if (!NodeAppender.validateBodyStatements(nodeBodyStatements)) { + nodeBodyStatements = []; + } + + nodeBodyStatements = NodeAppender.parentizeBodyStatementsBeforeAppend(blockScopeNode, nodeBodyStatements); + + blockScopeNode.body = [ + ...nodeBodyStatements, + ...blockScopeNode.body, + ]; + } + + /** + * @param blockScopeNode + * @param nodeBodyStatements + */ + private static parentizeBodyStatementsBeforeAppend ( + blockScopeNode: TNodeWithBlockStatement, + nodeBodyStatements: TStatement[] + ): TStatement[] { + for (let statement of nodeBodyStatements) { + statement.parentNode = blockScopeNode; + } + + return nodeBodyStatements; + } + + /** + * @param nodeBodyStatements + * @returns {boolean} + */ + private static validateBodyStatements (nodeBodyStatements: TStatement[]): boolean { + return nodeBodyStatements.every(statementNode => { + return !!statementNode && statementNode.hasOwnProperty('type'); + }); + } +} diff --git a/src/NodeUtils.ts b/src/NodeUtils.ts index c66b99e7..597bdc3d 100644 --- a/src/NodeUtils.ts +++ b/src/NodeUtils.ts @@ -1,16 +1,15 @@ import * as escodegen from 'escodegen'; import * as esprima from 'esprima'; import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; -import { INode } from './interfaces/nodes/INode'; +import { TNodeWithBlockStatement } from './types/TNodeWithBlockStatement'; +import { TStatement } from './types/TStatement'; -import { TNodeWithBlockStatement } from "./types/TNodeWithBlockStatement"; -import { TStatement } from "./types/nodes/TStatement"; +import { NodeType } from './enums/NodeType'; -import { NodeType } from "./enums/NodeType"; - -import { Nodes } from "./Nodes"; -import { Utils } from "./Utils"; +import { Nodes } from './Nodes'; +import { Utils } from './Utils'; export class NodeUtils { /** @@ -27,50 +26,36 @@ export class NodeUtils { /** * @param node */ - public static addXVerbatimPropertyToLiterals (node: INode): void { - estraverse.replace(node, { - enter: (node: INode, parentNode: INode): any => { - if (Nodes.isLiteralNode(node)) { - node['x-verbatim-property'] = { - content : node.raw, - precedence: escodegen.Precedence.Primary - }; - } + public static addXVerbatimPropertyToLiterals (node: ESTree.Node): void { + NodeUtils.typedReplace(node, NodeType.Literal, { + leave: (node: ESTree.Literal) => { + node['x-verbatim-property'] = { + content : node.raw, + precedence: escodegen.Precedence.Primary + }; } }); } - /** - * @param blockScopeBody - * @param node - */ - public static appendNode (blockScopeBody: INode[], node: INode): void { - if (!NodeUtils.validateNode(node)) { - return; - } - - blockScopeBody.push(node); - } - /** * @param code - * @returns {INode} + * @returns {TStatement[]} */ - public static convertCodeToStructure (code: string): INode { - let structure: INode = esprima.parse(code); + public static convertCodeToStructure (code: string): TStatement[] { + let structure: ESTree.Program = esprima.parse(code); NodeUtils.addXVerbatimPropertyToLiterals(structure); NodeUtils.parentize(structure); - return NodeUtils.getBlockStatementNodeByIndex(structure); + return structure.body; } /** * @param node * @param index - * @returns {INode} + * @returns {ESTree.Node} */ - public static getBlockStatementNodeByIndex (node: INode, index: number = 0): INode { + public static getBlockStatementNodeByIndex (node: ESTree.Node, index: number = 0): ESTree.Node { if (Nodes.isNodeHasBlockStatement(node)) { if (node.body[index] === undefined) { throw new ReferenceError(`Wrong index \`${index}\`. Block-statement body length is \`${node.body.length}\``); @@ -85,10 +70,10 @@ export class NodeUtils { /** * @param node * @param depth - * @returns {INode} + * @returns {ESTree.Node} */ - public static getBlockScopeOfNode (node: INode, depth: number = 0): TNodeWithBlockStatement { - let parentNode: INode | undefined = node.parentNode; + public static getBlockScopeOfNode (node: ESTree.Node, depth: number = 0): TNodeWithBlockStatement { + let parentNode: ESTree.Node | undefined = node.parentNode; if (!parentNode) { throw new ReferenceError('`parentNode` property of given node is `undefined`'); @@ -115,28 +100,15 @@ export class NodeUtils { return NodeUtils.getBlockScopeOfNode(parentNode); } - /** - * @param blockScopeBody - * @param node - * @param index - */ - public static insertNodeAtIndex (blockScopeBody: INode[], node: INode, index: number): void { - if (!NodeUtils.validateNode(node)) { - return; - } - - blockScopeBody.splice(index, 0, node); - } - /** * @param node */ - public static parentize (node: INode): void { + public static parentize (node: ESTree.Node): void { let isRootNode: boolean = true; estraverse.replace(node, { - enter: (node: INode, parentNode: INode): any => { - let value: INode; + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { + let value: ESTree.Node; if (isRootNode) { if (node.type === NodeType.Program) { @@ -158,22 +130,41 @@ export class NodeUtils { } /** - * @param blockScopeBody * @param node + * @param nodeType + * @param visitor */ - public static prependNode (blockScopeBody: INode[], node: INode): void { - if (!NodeUtils.validateNode(node)) { - return; - } - - blockScopeBody.unshift(node); + public static typedReplace ( + node: ESTree.Node, + nodeType: string, + visitor: {enter?: (node: ESTree.Node) => void, leave?: (node: ESTree.Node) => void}, + ): void { + NodeUtils.typedTraverse(node, nodeType, visitor, 'replace'); } /** * @param node - * @returns {boolean} + * @param nodeType + * @param visitor + * @param traverseType */ - private static validateNode (node: INode): boolean { - return !!node && node.hasOwnProperty('type'); + public static typedTraverse ( + node: ESTree.Node, + nodeType: string, + visitor: estraverse.Visitor, + traverseType: string = 'traverse' + ): void { + (estraverse)[traverseType](node, { + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { + if (node.type === nodeType && visitor.enter) { + visitor.enter(node, parentNode); + } + }, + leave: (node: ESTree.Node, parentNode: ESTree.Node): any => { + if (node.type === nodeType && visitor.leave) { + visitor.leave(node, parentNode); + } + } + }); } } diff --git a/src/Nodes.ts b/src/Nodes.ts index aafe0562..b0ae4c30 100644 --- a/src/Nodes.ts +++ b/src/Nodes.ts @@ -1,25 +1,16 @@ -import { IBlockStatementNode } from "./interfaces/nodes/IBlockStatementNode"; -import { IIdentifierNode } from "./interfaces/nodes/IIdentifierNode"; -import { ILiteralNode } from "./interfaces/nodes/ILiteralNode"; -import { IMemberExpressionNode } from "./interfaces/nodes/IMemberExpressionNode"; -import { INode } from "./interfaces/nodes/INode"; -import { IProgramNode } from "./interfaces/nodes/IProgramNode"; -import { IPropertyNode } from "./interfaces/nodes/IPropertyNode"; -import { IVariableDeclaratorNode } from "./interfaces/nodes/IVariableDeclaratorNode"; +import * as ESTree from 'estree'; -import { TStatement } from "./types/nodes/TStatement"; +import { TNodeWithBlockStatement } from './types/TNodeWithBlockStatement'; +import { TStatement } from './types/TStatement'; -import { TNodeWithBlockStatement } from "./types/TNodeWithBlockStatement"; - -import { NodeType } from "./enums/NodeType"; -import { ICallExpressionNode } from "./interfaces/nodes/ICallExpressionNode"; +import { NodeType } from './enums/NodeType'; export class Nodes { /** * @param bodyNode - * @returns IProgramNode + * @returns ESTree.Program */ - public static getProgramNode (bodyNode: TStatement[]): IProgramNode { + public static getProgramNode (bodyNode: TStatement[]): ESTree.Program { return { 'type': NodeType.Program, 'body': bodyNode, @@ -32,7 +23,15 @@ export class Nodes { * @param node * @returns {boolean} */ - public static isBlockStatementNode (node: INode): node is IBlockStatementNode { + public static isArrowFunctionExpressionNode (node: ESTree.Node): node is ESTree.ArrowFunctionExpression { + return node.type === NodeType.ArrowFunctionExpression; + } + + /** + * @param node + * @returns {boolean} + */ + public static isBlockStatementNode (node: ESTree.Node): node is ESTree.BlockStatement { return node.type === NodeType.BlockStatement; } @@ -40,7 +39,7 @@ export class Nodes { * @param node * @returns {boolean} */ - public static isCallExpressionNode (node: INode): node is ICallExpressionNode { + public static isCallExpressionNode (node: ESTree.Node): node is ESTree.CallExpression { return node.type === NodeType.CallExpression; } @@ -48,7 +47,31 @@ export class Nodes { * @param node * @returns {boolean} */ - public static isIdentifierNode (node: INode): node is IIdentifierNode { + public static isExpressionStatementNode (node: ESTree.Node): node is ESTree.ExpressionStatement { + return node.type === NodeType.ExpressionStatement; + } + + /** + * @param node + * @returns {boolean} + */ + public static isFunctionDeclarationNode (node: ESTree.Node): node is ESTree.FunctionDeclaration { + return node.type === NodeType.FunctionDeclaration; + } + + /** + * @param node + * @returns {boolean} + */ + public static isFunctionExpressionNode (node: ESTree.Node): node is ESTree.FunctionExpression { + return node.type === NodeType.FunctionExpression; + } + + /** + * @param node + * @returns {boolean} + */ + public static isIdentifierNode (node: ESTree.Node): node is ESTree.Identifier { return node.type === NodeType.Identifier; } @@ -56,7 +79,7 @@ export class Nodes { * @param node * @returns {boolean} */ - public static isLiteralNode (node: INode): node is ILiteralNode { + public static isLiteralNode (node: ESTree.Node): node is ESTree.Literal { return node.type === NodeType.Literal; } @@ -64,16 +87,24 @@ export class Nodes { * @param node * @returns {boolean} */ - public static isMemberExpressionNode (node: INode): node is IMemberExpressionNode { + public static isMemberExpressionNode (node: ESTree.Node): node is ESTree.MemberExpression { return node.type === NodeType.MemberExpression; } + /** + * @param node + * @returns {boolean} + */ + public static isObjectExpressionNode (node: ESTree.Node): node is ESTree.ObjectExpression { + return node.type === NodeType.ObjectExpression; + } + /** * * @param node * @returns {boolean} */ - public static isProgramNode (node: INode): node is IProgramNode { + public static isProgramNode (node: ESTree.Node): node is ESTree.Program { return node.type === NodeType.Program; } @@ -82,16 +113,45 @@ export class Nodes { * @param node * @returns {boolean} */ - public static isPropertyNode (node: INode): node is IPropertyNode { + public static isPropertyNode (node: ESTree.Node): node is ESTree.Property { return node.type === NodeType.Property; } + /** + * @param node + * @param parentNode + * @returns {boolean} + */ + public static isReplaceableIdentifierNode (node: ESTree.Node, parentNode: ESTree.Node): node is ESTree.Identifier { + if (!Nodes.isIdentifierNode(node)) { + return false; + } + + const parentNodeIsPropertyNode: boolean = Nodes.isPropertyNode(parentNode) && parentNode.key === node; + const parentNodeIsMemberExpressionNode: boolean = ( + Nodes.isMemberExpressionNode(parentNode) && + parentNode.computed === false && + parentNode.property === node + ); + + return !parentNodeIsPropertyNode && !parentNodeIsMemberExpressionNode; + } + /** * * @param node * @returns {boolean} */ - public static isVariableDeclaratorNode (node: INode): node is IVariableDeclaratorNode { + public static isVariableDeclarationNode (node: ESTree.Node): node is ESTree.VariableDeclaration { + return node.type === NodeType.VariableDeclaration; + } + + /** + * + * @param node + * @returns {boolean} + */ + public static isVariableDeclaratorNode (node: ESTree.Node): node is ESTree.VariableDeclarator { return node.type === NodeType.VariableDeclarator; } @@ -99,7 +159,7 @@ export class Nodes { * @param node * @returns {boolean} */ - public static isNodeHasBlockStatement (node: INode): node is TNodeWithBlockStatement { + public static isNodeHasBlockStatement (node: ESTree.Node): node is TNodeWithBlockStatement { return node.hasOwnProperty('body') && Array.isArray((node).body); } } diff --git a/src/ObfuscationResult.ts b/src/ObfuscationResult.ts index 86859809..9e1dc282 100644 --- a/src/ObfuscationResult.ts +++ b/src/ObfuscationResult.ts @@ -1,4 +1,4 @@ -import { IObfuscationResult } from "./interfaces/IObfuscationResult"; +import { IObfuscationResult } from './interfaces/IObfuscationResult'; export class ObfuscationResult implements IObfuscationResult { /** diff --git a/src/Obfuscator.ts b/src/Obfuscator.ts index 74301f30..9809cbd3 100644 --- a/src/Obfuscator.ts +++ b/src/Obfuscator.ts @@ -1,40 +1,50 @@ import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; import { ICustomNode } from './interfaces/custom-nodes/ICustomNode'; -import { INode } from './interfaces/nodes/INode'; -import { IObfuscator } from "./interfaces/IObfuscator"; -import { IOptions } from "./interfaces/IOptions"; +import { IObfuscator } from './interfaces/IObfuscator'; +import { IOptions } from './interfaces/IOptions'; +import { IStackTraceData } from './interfaces/stack-trace-analyzer/IStackTraceData'; -import { TNodeObfuscator } from "./types/TNodeObfuscator"; +import { TNodeGroup } from './types/TNodeGroup'; +import { TNodeObfuscator } from './types/TNodeObfuscator'; import { AppendState } from './enums/AppendState'; import { NodeType } from './enums/NodeType'; import { CatchClauseObfuscator } from './node-obfuscators/CatchClauseObfuscator'; -import { ConsoleOutputNodesGroup } from "./node-groups/ConsoleOutputNodesGroup"; +import { ConsoleOutputNodesGroup } from './node-groups/ConsoleOutputNodesGroup'; import { DebugProtectionNodesGroup } from './node-groups/DebugProtectionNodesGroup'; +import { DomainLockNodesGroup } from './node-groups/DomainLockNodesGroup'; import { FunctionDeclarationObfuscator } from './node-obfuscators/FunctionDeclarationObfuscator'; import { FunctionObfuscator } from './node-obfuscators/FunctionObfuscator'; import { LiteralObfuscator } from './node-obfuscators/LiteralObfuscator'; import { MemberExpressionObfuscator } from './node-obfuscators/MemberExpressionObfuscator'; import { MethodDefinitionObfuscator } from './node-obfuscators/MethodDefinitionObfuscator'; -import { Nodes } from "./Nodes"; -import { NodeUtils } from "./NodeUtils"; +import { Nodes } from './Nodes'; +import { NodeUtils } from './NodeUtils'; import { ObjectExpressionObfuscator } from './node-obfuscators/ObjectExpressionObfuscator'; -import { SelfDefendingNodesGroup } from "./node-groups/SelfDefendingNodesGroup"; +import { SelfDefendingNodesGroup } from './node-groups/SelfDefendingNodesGroup'; import { UnicodeArrayNodesGroup } from './node-groups/UnicodeArrayNodesGroup'; import { VariableDeclarationObfuscator } from './node-obfuscators/VariableDeclarationObfuscator'; +import { StackTraceAnalyzer } from './stack-trace-analyzer/StackTraceAnalyzer'; export class Obfuscator implements IObfuscator { /** - * @type {Map} + * @type {TNodeGroup[]} */ - private nodes: Map ; + private static nodeGroups: TNodeGroup[] = [ + DomainLockNodesGroup, + SelfDefendingNodesGroup, + ConsoleOutputNodesGroup, + DebugProtectionNodesGroup, + UnicodeArrayNodesGroup + ]; /** * @type {Map} */ - private nodeObfuscators: Map = new Map ([ + private static nodeObfuscators: Map = new Map ([ [NodeType.ArrowFunctionExpression, [FunctionObfuscator]], [NodeType.ClassDeclaration, [FunctionDeclarationObfuscator]], [NodeType.CatchClause, [CatchClauseObfuscator]], @@ -50,6 +60,11 @@ export class Obfuscator implements IObfuscator { [NodeType.Literal, [LiteralObfuscator]] ]); + /** + * @type {Map} + */ + private customNodes: Map = new Map (); + /** * @type {IOptions} */ @@ -60,26 +75,23 @@ export class Obfuscator implements IObfuscator { */ constructor (options: IOptions) { this.options = options; - - this.nodes = new Map ([ - ...new SelfDefendingNodesGroup(this.options).getNodes(), - ...new ConsoleOutputNodesGroup(this.options).getNodes(), - ...new DebugProtectionNodesGroup(this.options).getNodes(), - ...new UnicodeArrayNodesGroup(this.options).getNodes() - ]); } /** * @param node - * @returns {INode} + * @returns {ESTree.Node} */ - public obfuscateNode (node: INode): INode { + public obfuscateNode (node: ESTree.Program): ESTree.Node { if (Nodes.isProgramNode(node) && !node.body.length) { return node; } NodeUtils.parentize(node); + const stackTraceData: IStackTraceData[] = new StackTraceAnalyzer(node.body).analyze(); + + this.initializeCustomNodes(stackTraceData); + this.beforeObfuscation(node); this.obfuscate(node); this.afterObfuscation(node); @@ -90,8 +102,8 @@ export class Obfuscator implements IObfuscator { /** * @param astTree */ - private afterObfuscation (astTree: INode): void { - this.nodes.forEach((node: ICustomNode) => { + private afterObfuscation (astTree: ESTree.Node): void { + this.customNodes.forEach((node: ICustomNode) => { if (node.getAppendState() === AppendState.AfterObfuscation) { node.appendNode(astTree); } @@ -101,37 +113,57 @@ export class Obfuscator implements IObfuscator { /** * @param astTree */ - private beforeObfuscation (astTree: INode): void { - this.nodes.forEach((node: ICustomNode) => { + private beforeObfuscation (astTree: ESTree.Node): void { + this.customNodes.forEach((node: ICustomNode) => { if (node.getAppendState() === AppendState.BeforeObfuscation) { node.appendNode(astTree); } }); }; + /** + * @param stackTraceData + */ + private initializeCustomNodes (stackTraceData: IStackTraceData[]): void { + Obfuscator.nodeGroups.forEach((nodeGroupConstructor: TNodeGroup) => { + const nodeGroupNodes: Map | undefined = new nodeGroupConstructor( + stackTraceData, this.options + ).getNodes(); + + if (!nodeGroupNodes) { + return; + } + + this.customNodes = new Map ([ + ...this.customNodes, + ...nodeGroupNodes + ]); + }); + } + /** * @param node * @param parentNode */ - private initializeNodeObfuscators (node: INode, parentNode: INode): void { - let nodeObfuscators: TNodeObfuscator[] | undefined = this.nodeObfuscators.get(node.type); + private initializeNodeObfuscators (node: ESTree.Node, parentNode: ESTree.Node): void { + let nodeObfuscators: TNodeObfuscator[] | undefined = Obfuscator.nodeObfuscators.get(node.type); if (!nodeObfuscators) { return; } nodeObfuscators.forEach((obfuscator: TNodeObfuscator) => { - new obfuscator(this.nodes, this.options).obfuscateNode(node, parentNode); + new obfuscator(this.customNodes, this.options).obfuscateNode(node, parentNode); }); } /** * @param node */ - private obfuscate (node: INode): void { + private obfuscate (node: ESTree.Node): void { estraverse.replace(node, { - enter: (node: INode, parentNode: INode): any => { + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { this.initializeNodeObfuscators(node, parentNode); } }); diff --git a/src/SourceMapCorrector.ts b/src/SourceMapCorrector.ts index ec9f33d9..52c937b7 100644 --- a/src/SourceMapCorrector.ts +++ b/src/SourceMapCorrector.ts @@ -1,12 +1,12 @@ -import { IObfuscationResult } from "./interfaces/IObfuscationResult"; -import { ISourceMapCorrector } from "./interfaces/ISourceMapCorrector"; +import { IObfuscationResult } from './interfaces/IObfuscationResult'; +import { ISourceMapCorrector } from './interfaces/ISourceMapCorrector'; -import { TSourceMapMode } from "./types/TSourceMapMode"; +import { TSourceMapMode } from './types/TSourceMapMode'; -import { SourceMapMode } from "./enums/SourceMapMode"; +import { SourceMapMode } from './enums/SourceMapMode'; -import { ObfuscationResult } from "./ObfuscationResult"; -import { Utils } from "./Utils"; +import { ObfuscationResult } from './ObfuscationResult'; +import { Utils } from './Utils'; export class SourceMapCorrector implements ISourceMapCorrector { /** @@ -52,7 +52,7 @@ export class SourceMapCorrector implements ISourceMapCorrector { public correct (): IObfuscationResult { return new ObfuscationResult( this.correctObfuscatedCode(), - this.correctSourceMap() + this.sourceMap ); } @@ -68,32 +68,21 @@ export class SourceMapCorrector implements ISourceMapCorrector { switch (this.sourceMapMode) { case SourceMapMode.Inline: - sourceMappingUrl += `data:application/json;base64,${Utils.btoa(this.sourceMapUrl || this.sourceMap, false)}`; + sourceMappingUrl += `data:application/json;base64,${Utils.btoa(this.sourceMap)}`; break; case SourceMapMode.Separate: default: - if (this.sourceMapUrl) { - sourceMappingUrl += this.sourceMapUrl; - - break; + if (!this.sourceMapUrl) { + return this.obfuscatedCode; } - return this.obfuscatedCode; + sourceMappingUrl += this.sourceMapUrl; + + break; } return `${this.obfuscatedCode}\n${sourceMappingUrl}`; }; - - /** - * @returns {string} - */ - private correctSourceMap (): string { - if (this.sourceMapMode === SourceMapMode.Inline) { - return ''; - } - - return this.sourceMap; - } } diff --git a/src/UnicodeArray.ts b/src/UnicodeArray.ts new file mode 100644 index 00000000..fe0dbb64 --- /dev/null +++ b/src/UnicodeArray.ts @@ -0,0 +1,51 @@ +import { Utils } from './Utils'; + +export class UnicodeArray { + /** + * @type {string[]} + */ + private array: string[] = []; + + /** + * @param value + */ + public addToArray (value: string): void { + this.array.push(value); + } + + /** + * @returns {string[]} + */ + public getArray (): string[] { + return this.array; + } + + /** + * @param value + * @returns {number} + */ + public getIndexOf(value: string): number { + return this.array.indexOf(value); + } + + /** + * @returns {number} + */ + public getLength (): number { + return this.array.length; + } + + /** + * @param rotationValue + */ + public rotateArray (rotationValue: number): void { + this.array = Utils.arrayRotate(this.array, rotationValue); + } + + /** + * @returns {string} + */ + public toString (): string { + return this.array.toString(); + } +} diff --git a/src/Utils.ts b/src/Utils.ts index 5dbaaeb9..3e739602 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -44,12 +44,31 @@ export class Utils { /** * @param string - * @param encode */ - public static btoa (string: string, encode: boolean = true): string { - return new Buffer( - encode ? encodeURI(string) : string - ).toString('base64'); + public static btoa (string: string): string { + const chars: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + let output: string = ''; + + string = encodeURIComponent(string).replace(/%([0-9A-F]{2})/g, (match, p1) => { + return String.fromCharCode(parseInt('0x' + p1)); + }); + + for ( + let block: number|undefined, charCode: number, idx: number = 0, map: string = chars; + string.charAt(idx | 0) || (map = '=', idx % 1); + output += map.charAt(63 & block >> 8 - idx % 1 * 8) + ) { + charCode = string.charCodeAt(idx += 3/4); + + if (charCode > 0xFF) { + throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); + } + + block = block << 8 | charCode; + } + + return output; } /** @@ -62,6 +81,24 @@ export class Utils { return Number(dec).toString(radix); } + /** + * @param url + * @returns {string} + */ + public static extractDomainFromUrl (url: string): string { + let domain: string; + + if (url.indexOf('://') > -1 || url.indexOf('//') === 0) { + domain = url.split('/')[2]; + } else { + domain = url.split('/')[0]; + } + + domain = domain.split(':')[0]; + + return domain; + } + /** * @returns {Chance.Chance} */ @@ -71,7 +108,7 @@ export class Utils { /** * @param length - * @returns any + * @returns {string} */ public static getRandomVariableName (length: number = 6): string { const rangeMinInteger: number = 10000, @@ -88,6 +125,46 @@ export class Utils { ).substr(0, length)}`; } + /** + * @param str + * @param length + * @returns {string[]} + */ + public static hideString(str: string, length: number): [string, string] { + const escapeRegExp: (s: string) => string = (s: string) => + s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + + const randomMerge: (s1: string, s2: string) => string = function (s1: string, s2: string): string { + let i1: number = -1, + i2: number = -1, + result: string = ''; + + while (i1 < s1.length || i2 < s2.length) { + if (Math.random() < 0.5 && i2 < s2.length) { + result += s2.charAt(++i2); + } else { + result += s1.charAt(++i1); + } + } + + return result; + }; + + const customPool: string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + + let randomString: string = Utils.randomGenerator.string({length: length, pool: customPool}), + randomStringDiff: string = randomString.replace( + new RegExp('[' + escapeRegExp(str) + ']', 'g'), + ''), + randomStringDiffArray: string[] = randomStringDiff.split(''); + + Utils.randomGenerator.shuffle(randomStringDiffArray); + randomStringDiff = randomStringDiffArray.join(''); + + return [randomMerge(str, randomStringDiff), randomStringDiff]; + + } + /** * @param number * @returns {boolean} @@ -96,6 +173,46 @@ export class Utils { return number % 1 === 0; } + /** + * RC4 symmetric cipher encryption/decryption + * https://gist.github.com/farhadi/2185197 + * + * @param key + * @param string + * @returns {string} + */ + public static rc4 (string: string, key: string) { + let s: number[] = [], + j: number = 0, + x: number, + result: string = ''; + + for (var i = 0; i < 256; i++) { + s[i] = i; + } + + for (i = 0; i < 256; i++) { + j = (j + s[i] + key.charCodeAt(i % key.length)) % 256; + x = s[i]; + s[i] = s[j]; + s[j] = x; + } + + i = 0; + j = 0; + + for (let y = 0; y < string.length; y++) { + i = (i + 1) % 256; + j = (j + s[i]) % 256; + x = s[i]; + s[i] = s[j]; + s[j] = x; + result += String.fromCharCode(string.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]); + } + + return result; + } + /** * @param obj * @returns {T} @@ -134,9 +251,9 @@ export class Utils { template = '0'.repeat(2); } else { prefix = '\\u'; - template = '0'.repeat(4); + template = '0'.repeat(4); } - + return `${prefix}${(template + escape.charCodeAt(0).toString(radix)).slice(-template.length)}`; })}'`; } diff --git a/src/cli/CLIUtils.ts b/src/cli/CLIUtils.ts index 6b0bbc75..12caa909 100644 --- a/src/cli/CLIUtils.ts +++ b/src/cli/CLIUtils.ts @@ -2,9 +2,9 @@ import * as fs from 'fs'; import * as mkdirp from 'mkdirp'; import * as path from 'path'; -import { IPackageConfig } from "../interfaces/IPackageConfig"; +import { IPackageConfig } from '../interfaces/IPackageConfig'; -import { Utils } from "../Utils"; +import { Utils } from '../Utils'; export class CLIUtils { /** @@ -38,15 +38,24 @@ export class CLIUtils { } /** + * @param outputCodePath + * @param sourceMapFileName * @returns {string} */ - public static getOutputSourceMapPath (outputCodePath: string): string { - return outputCodePath - .split('.') - .map((value: string, index: number, array: string[]) => { - return index === array.length - 1 ? `${value}.map` : value; - }) - .join('.'); + public static getOutputSourceMapPath (outputCodePath: string, sourceMapFileName: string = ''): string { + if (sourceMapFileName) { + outputCodePath = `${outputCodePath.substr( + 0, outputCodePath.lastIndexOf('/') + )}/${sourceMapFileName}`; + } + + if (!/\.js\.map$/.test(outputCodePath)) { + outputCodePath = `${outputCodePath.split('.')[0]}.js.map`; + } else if (/\.js$/.test(outputCodePath)) { + outputCodePath += '.map'; + } + + return outputCodePath; } /** diff --git a/src/cli/JavaScriptObfuscatorCLI.ts b/src/cli/JavaScriptObfuscatorCLI.ts index 47fe95e3..2e864a43 100644 --- a/src/cli/JavaScriptObfuscatorCLI.ts +++ b/src/cli/JavaScriptObfuscatorCLI.ts @@ -1,17 +1,19 @@ import * as commander from 'commander'; import * as path from 'path'; -import { IObfuscationResult } from "../interfaces/IObfuscationResult"; -import { IObfuscatorOptions } from "../interfaces/IObfuscatorOptions"; +import { TUnicodeArrayEncoding } from '../types/TUnicodeArrayEncoding'; -import { SourceMapMode } from "../enums/SourceMapMode"; +import { IObfuscationResult } from '../interfaces/IObfuscationResult'; +import { IObfuscatorOptions } from '../interfaces/IObfuscatorOptions'; -import { DEFAULT_PRESET } from "../preset-options/DefaultPreset"; +import { SourceMapMode } from '../enums/SourceMapMode'; +import { UnicodeArrayEncoding } from '../enums/UnicodeArrayEncoding'; -import { CLIUtils } from "./CLIUtils"; -import { JavaScriptObfuscator } from "../JavaScriptObfuscator"; -import { JavaScriptObfuscatorInternal } from "../JavaScriptObfuscatorInternal"; -import { Utils } from "../Utils"; +import { DEFAULT_PRESET } from '../preset-options/DefaultPreset'; + +import { CLIUtils } from './CLIUtils'; +import { JavaScriptObfuscator } from '../JavaScriptObfuscator'; +import { Utils } from '../Utils'; export class JavaScriptObfuscatorCLI { /** @@ -80,6 +82,25 @@ export class JavaScriptObfuscatorCLI { return value; } + /** + * @param value + * @returns {TUnicodeArrayEncoding} + */ + private static parseUnicodeArrayEncoding (value: string): TUnicodeArrayEncoding { + switch (value) { + case 'true': + case '1': + case UnicodeArrayEncoding.base64: + return true; + + case UnicodeArrayEncoding.rc4: + return UnicodeArrayEncoding.rc4; + + default: + return false; + } + } + public run (): void { this.configureCommands(); @@ -103,7 +124,7 @@ export class JavaScriptObfuscatorCLI { let obfuscatorOptions: IObfuscatorOptions = {}, availableOptions: string[] = Object.keys(DEFAULT_PRESET); - for (let option in this.commands) { + for (const option in this.commands) { if (!this.commands.hasOwnProperty(option)) { continue; } @@ -127,19 +148,21 @@ export class JavaScriptObfuscatorCLI { .option('--debugProtection ', 'Disable browser Debug panel (can cause DevTools enabled browser freeze)', JavaScriptObfuscatorCLI.parseBoolean) .option('--debugProtectionInterval ', 'Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)', JavaScriptObfuscatorCLI.parseBoolean) .option('--disableConsoleOutput ', 'Allow console.log, console.info, console.error and console.warn messages output into browser console', JavaScriptObfuscatorCLI.parseBoolean) - .option('--encodeUnicodeLiterals ', 'All literals in Unicode array become encoded in Base64 (this option can slightly slow down your code speed)', JavaScriptObfuscatorCLI.parseBoolean) + .option('--domainLock ', 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)', (val: string) => val.split(',')) .option('--reservedNames ', 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)', (val: string) => val.split(',')) .option('--rotateUnicodeArray ', 'Disable rotation of unicode array values during obfuscation', JavaScriptObfuscatorCLI.parseBoolean) .option('--selfDefending ', 'Disables self-defending for obfuscated code', JavaScriptObfuscatorCLI.parseBoolean) .option('--sourceMap ', 'Enables source map generation', JavaScriptObfuscatorCLI.parseBoolean) + .option('--sourceMapBaseUrl ', 'Sets base url to the source map import url when `--sourceMapMode=separate`') + .option('--sourceMapFileName ', 'Sets file name for output source map when `--sourceMapMode=separate`') .option( '--sourceMapMode [inline, separate]', 'Specify source map output mode', JavaScriptObfuscatorCLI.parseSourceMapMode ) .option('--unicodeArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean) + .option('--unicodeArrayEncoding [true, false, base64, rc4]', 'All literals in Unicode array become encoded in using base64 or rc4 (this option can slightly slow down your code speed', JavaScriptObfuscatorCLI.parseUnicodeArrayEncoding) .option('--unicodeArrayThreshold ', 'The probability that the literal string will be inserted into unicodeArray (Default: 0.8, Min: 0, Max: 1)', parseFloat) - .option('--wrapUnicodeArrayCalls ', 'Disables usage of special access function instead of direct array call', JavaScriptObfuscatorCLI.parseBoolean) .parse(this.rawArguments); this.commands.on('--help', () => { @@ -180,23 +203,18 @@ export class JavaScriptObfuscatorCLI { * @param options */ private processDataWithSourceMap (outputCodePath: string, options: IObfuscatorOptions): void { - let javaScriptObfuscator: JavaScriptObfuscatorInternal = new JavaScriptObfuscatorInternal(this.data, options), - obfuscationResult: IObfuscationResult, - outputSourceMapPath: string = CLIUtils.getOutputSourceMapPath(outputCodePath); + let outputSourceMapPath: string = CLIUtils.getOutputSourceMapPath( + outputCodePath, + options.sourceMapFileName || '' + ); - javaScriptObfuscator.obfuscate(); + options.sourceMapFileName = path.basename(outputSourceMapPath); - if (options.sourceMapMode === SourceMapMode.Separate) { - javaScriptObfuscator.setSourceMapUrl( - path.basename(outputSourceMapPath) - ); - } - - obfuscationResult = javaScriptObfuscator.getObfuscationResult(); + const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(this.data, options); CLIUtils.writeFile(outputCodePath, obfuscationResult.getObfuscatedCode()); - if (obfuscationResult.getSourceMap()) { + if (options.sourceMapMode === 'separate' && obfuscationResult.getSourceMap()) { CLIUtils.writeFile(outputSourceMapPath, obfuscationResult.getSourceMap()); } } diff --git a/src/custom-nodes/Node.ts b/src/custom-nodes/AbstractCustomNode.ts similarity index 53% rename from src/custom-nodes/Node.ts rename to src/custom-nodes/AbstractCustomNode.ts index 51f281fe..00aa6a3c 100644 --- a/src/custom-nodes/Node.ts +++ b/src/custom-nodes/AbstractCustomNode.ts @@ -1,10 +1,12 @@ +import * as ESTree from 'estree'; + import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; -import { INode } from '../interfaces/nodes/INode'; -import { IOptions } from "../interfaces/IOptions"; +import { IOptions } from '../interfaces/IOptions'; +import { TStatement } from '../types/TStatement'; import { AppendState } from '../enums/AppendState'; -export abstract class Node implements ICustomNode { +export abstract class AbstractCustomNode implements ICustomNode { /** * @type {AppendState} */ @@ -25,7 +27,7 @@ export abstract class Node implements ICustomNode { /** * @param astTree */ - public abstract appendNode (astTree: INode): void; + public abstract appendNode (astTree: ESTree.Node): void; /** * @returns {AppendState} @@ -35,14 +37,21 @@ export abstract class Node implements ICustomNode { } /** - * @returns {INode} + * @returns {TStatement[]} */ - public getNode (): INode { + public getNode (): TStatement[] { return this.getNodeStructure(); } /** - * @returns {INode} + * @param appendState */ - protected abstract getNodeStructure (): INode; + public setAppendState (appendState: AppendState): void { + this.appendState = appendState; + } + + /** + * @returns {TStatement[]} + */ + protected abstract getNodeStructure (): TStatement[]; } diff --git a/src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts b/src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts index de979e16..f32e0065 100644 --- a/src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts +++ b/src/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.ts @@ -1,25 +1,70 @@ -import { INode } from "../../interfaces/nodes/INode"; +import 'format-unicorn'; -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; -import { AppendState } from "../../enums/AppendState"; +import { IOptions } from '../../interfaces/IOptions'; +import { IStackTraceData } from '../../interfaces/stack-trace-analyzer/IStackTraceData'; -import { ConsoleOutputDisableExpressionTemplate } from "../../templates/custom-nodes/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate"; +import { AppendState } from '../../enums/AppendState'; -import { Node } from '../Node'; -import { NodeUtils } from "../../NodeUtils"; +import { ConsoleOutputDisableExpressionTemplate } from '../../templates/custom-nodes/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate'; -export class ConsoleOutputDisableExpressionNode extends Node { +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { NodeAppender } from '../../NodeAppender'; +import { NodeUtils } from '../../NodeUtils'; +import { Utils } from '../../Utils'; + +export class ConsoleOutputDisableExpressionNode extends AbstractCustomNode { /** * @type {AppendState} */ protected appendState: AppendState = AppendState.BeforeObfuscation; + /** + * @type {string} + */ + protected callsControllerFunctionName: string; + + /** + * @type {number} + */ + protected randomStackTraceIndex: number; + + /** + * @type {IStackTraceData[]} + */ + protected stackTraceData: IStackTraceData[]; + + /** + * @param stackTraceData + * @param callsControllerFunctionName + * @param randomStackTraceIndex + * @param options + */ + constructor ( + stackTraceData: IStackTraceData[], + callsControllerFunctionName: string, + randomStackTraceIndex: number, + options: IOptions + ) { + super(options); + + this.stackTraceData = stackTraceData; + this.callsControllerFunctionName = callsControllerFunctionName; + this.randomStackTraceIndex = randomStackTraceIndex; + } + /** * @param blockScopeNode */ public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - NodeUtils.prependNode(blockScopeNode.body, this.getNode()); + NodeAppender.appendNodeToOptimalBlockScope( + this.stackTraceData, + blockScopeNode, + this.getNode(), + this.randomStackTraceIndex + ); } /** @@ -36,11 +81,14 @@ export class ConsoleOutputDisableExpressionNode extends Node { * _console * })(); * - * @returns {INode} + * @returns {TStatement[]} */ - protected getNodeStructure (): INode { + protected getNodeStructure (): TStatement[] { return NodeUtils.convertCodeToStructure( - ConsoleOutputDisableExpressionTemplate() + ConsoleOutputDisableExpressionTemplate().formatUnicorn({ + consoleLogDisableFunctionName: Utils.getRandomVariableName(), + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }) ); } } diff --git a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts index db237d7c..b4d4a233 100644 --- a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts +++ b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode.ts @@ -1,18 +1,19 @@ import 'format-unicorn'; -import { INode } from "../../interfaces/nodes/INode"; -import { IOptions } from "../../interfaces/IOptions"; +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; +import { IOptions } from '../../interfaces/IOptions'; -import { AppendState } from "../../enums/AppendState"; +import { AppendState } from '../../enums/AppendState'; -import { DebugProtectionFunctionCallTemplate } from "../../templates/custom-nodes/debug-protection-nodes/debug-protection-function-call-node/DebufProtectionFunctionCallTemplate"; +import { DebugProtectionFunctionCallTemplate } from '../../templates/custom-nodes/debug-protection-nodes/debug-protection-function-call-node/DebufProtectionFunctionCallTemplate'; -import { Node } from '../Node'; -import { NodeUtils } from "../../NodeUtils"; +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { NodeAppender } from '../../NodeAppender'; +import { NodeUtils } from '../../NodeUtils'; -export class DebugProtectionFunctionCallNode extends Node { +export class DebugProtectionFunctionCallNode extends AbstractCustomNode { /** * @type {AppendState} */ @@ -37,13 +38,13 @@ export class DebugProtectionFunctionCallNode extends Node { * @param blockScopeNode */ public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - NodeUtils.appendNode(blockScopeNode.body, this.getNode()); + NodeAppender.appendNode(blockScopeNode, this.getNode()); } /** - * @returns {INode} + * @returns {TStatement[]} */ - protected getNodeStructure (): INode { + protected getNodeStructure (): TStatement[] { return NodeUtils.convertCodeToStructure( DebugProtectionFunctionCallTemplate().formatUnicorn({ debugProtectionFunctionName: this.debugProtectionFunctionName diff --git a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts index f6f958bf..93c7ae14 100644 --- a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts +++ b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode.ts @@ -1,18 +1,19 @@ import 'format-unicorn'; -import { INode } from "../../interfaces/nodes/INode"; -import { IOptions } from "../../interfaces/IOptions"; +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; +import { IOptions } from '../../interfaces/IOptions'; -import { AppendState } from "../../enums/AppendState"; +import { AppendState } from '../../enums/AppendState'; -import { DebugProtectionFunctionIntervalTemplate } from "../../templates/custom-nodes/debug-protection-nodes/debug-protection-function-interval-node/DebugProtectionFunctionIntervalTemplate"; +import { DebugProtectionFunctionIntervalTemplate } from '../../templates/custom-nodes/debug-protection-nodes/debug-protection-function-interval-node/DebugProtectionFunctionIntervalTemplate'; -import { Node } from '../Node'; +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { NodeAppender } from '../../NodeAppender'; import { NodeUtils } from '../../NodeUtils'; -export class DebugProtectionFunctionIntervalNode extends Node { +export class DebugProtectionFunctionIntervalNode extends AbstractCustomNode { /** * @type {AppendState} */ @@ -37,13 +38,13 @@ export class DebugProtectionFunctionIntervalNode extends Node { * @param blockScopeNode */ public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - NodeUtils.appendNode(blockScopeNode.body, this.getNode()); + NodeAppender.appendNode(blockScopeNode, this.getNode()); } /** - * @returns {INode} + * @returns {TStatement[]} */ - protected getNodeStructure (): INode { + protected getNodeStructure (): TStatement[] { return NodeUtils.convertCodeToStructure( DebugProtectionFunctionIntervalTemplate().formatUnicorn({ debugProtectionFunctionName: this.debugProtectionFunctionName diff --git a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts index 0bff73ac..6d0668ac 100644 --- a/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts +++ b/src/custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode.ts @@ -1,19 +1,20 @@ import 'format-unicorn'; -import { INode } from "../../interfaces/nodes/INode"; -import { IOptions } from "../../interfaces/IOptions"; +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; +import { IOptions } from '../../interfaces/IOptions'; -import { AppendState } from "../../enums/AppendState"; +import { AppendState } from '../../enums/AppendState'; -import { DebugProtectionFunctionTemplate } from "../../templates/custom-nodes/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate"; +import { DebugProtectionFunctionTemplate } from '../../templates/custom-nodes/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate'; -import { Node } from '../Node'; +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { NodeAppender } from '../../NodeAppender'; import { NodeUtils } from '../../NodeUtils'; -import { Utils } from "../../Utils"; +import { Utils } from '../../Utils'; -export class DebugProtectionFunctionNode extends Node { +export class DebugProtectionFunctionNode extends AbstractCustomNode { /** * @type {AppendState} */ @@ -44,7 +45,7 @@ export class DebugProtectionFunctionNode extends Node { max: programBodyLength }); - NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), randomIndex); + NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), randomIndex); } /** @@ -57,9 +58,9 @@ export class DebugProtectionFunctionNode extends Node { /** * Found this trick in JScrambler * - * @returns {INode} + * @returns {TStatement[]} */ - protected getNodeStructure (): INode { + protected getNodeStructure (): TStatement[] { return NodeUtils.convertCodeToStructure( DebugProtectionFunctionTemplate().formatUnicorn({ debugProtectionFunctionName: this.debugProtectionFunctionName diff --git a/src/custom-nodes/domain-lock-nodes/DomainLockNode.ts b/src/custom-nodes/domain-lock-nodes/DomainLockNode.ts new file mode 100644 index 00000000..02e73d60 --- /dev/null +++ b/src/custom-nodes/domain-lock-nodes/DomainLockNode.ts @@ -0,0 +1,86 @@ +import 'format-unicorn'; + +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; + +import { IOptions } from '../../interfaces/IOptions'; +import { IStackTraceData } from '../../interfaces/stack-trace-analyzer/IStackTraceData'; + +import { AppendState } from '../../enums/AppendState'; + +import { DomainLockNodeTemplate } from '../../templates/custom-nodes/domain-lock-nodes/domain-lock-node/DomainLockNodeTemplate'; + +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { NodeAppender } from '../../NodeAppender'; +import { NodeUtils } from '../../NodeUtils'; +import { Utils } from '../../Utils'; + +export class DomainLockNode extends AbstractCustomNode { + /** + * @type {AppendState} + */ + protected appendState: AppendState = AppendState.BeforeObfuscation; + + /** + * @type {string} + */ + protected callsControllerFunctionName: string; + + /** + * @type {number} + */ + protected randomStackTraceIndex: number; + + /** + * @type {IStackTraceData[]} + */ + protected stackTraceData: IStackTraceData[]; + + /** + * @param stackTraceData + * @param callsControllerFunctionName + * @param randomStackTraceIndex + * @param options + */ + constructor ( + stackTraceData: IStackTraceData[], + callsControllerFunctionName: string, + randomStackTraceIndex: number, + options: IOptions + ) { + super(options); + + this.stackTraceData = stackTraceData; + this.callsControllerFunctionName = callsControllerFunctionName; + this.randomStackTraceIndex = randomStackTraceIndex; + } + + /** + * @param blockScopeNode + */ + public appendNode (blockScopeNode: TNodeWithBlockStatement): void { + NodeAppender.appendNodeToOptimalBlockScope( + this.stackTraceData, + blockScopeNode, + this.getNode(), + this.randomStackTraceIndex + ); + } + + /** + * @returns {TStatement[]} + */ + protected getNodeStructure (): TStatement[] { + let domainsString: string = this.options.domainLock.join(';'), + [hiddenDomainsString, diff]: string[] = Utils.hideString(domainsString, domainsString.length * 3); + + return NodeUtils.convertCodeToStructure( + DomainLockNodeTemplate().formatUnicorn({ + domainLockFunctionName: Utils.getRandomVariableName(), + diff: diff, + domains: hiddenDomainsString, + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }) + ); + } +} diff --git a/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts b/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts new file mode 100644 index 00000000..354bed64 --- /dev/null +++ b/src/custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode.ts @@ -0,0 +1,94 @@ +import 'format-unicorn'; + +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; + +import { IOptions } from '../../interfaces/IOptions'; +import { IStackTraceData } from '../../interfaces/stack-trace-analyzer/IStackTraceData'; + +import { AppendState } from '../../enums/AppendState'; + +import { SingleNodeCallControllerTemplate } from '../../templates/custom-nodes/SingleNodeCallControllerTemplate'; + +import { NO_CUSTOM_NODES_PRESET } from '../../preset-options/NoCustomNodesPreset'; + +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { JavaScriptObfuscator } from '../../JavaScriptObfuscator'; +import { NodeAppender } from '../../NodeAppender'; +import { NodeUtils } from '../../NodeUtils'; + +export class NodeCallsControllerFunctionNode extends AbstractCustomNode { + /** + * @type {AppendState} + */ + protected appendState: AppendState = AppendState.BeforeObfuscation; + + /** + * @type {string} + */ + protected callsControllerFunctionName: string; + + /** + * @type {number} + */ + protected randomStackTraceIndex: number; + + /** + * @type {IStackTraceData[]} + */ + protected stackTraceData: IStackTraceData[]; + + /** + * @param stackTraceData + * @param callsControllerFunctionName + * @param randomStackTraceIndex + * @param options + */ + constructor ( + stackTraceData: IStackTraceData[], + callsControllerFunctionName: string, + randomStackTraceIndex: number, + options: IOptions + ) { + super(options); + + this.stackTraceData = stackTraceData; + this.callsControllerFunctionName = callsControllerFunctionName; + this.randomStackTraceIndex = randomStackTraceIndex; + } + + /** + * @param blockScopeNode + */ + public appendNode (blockScopeNode: TNodeWithBlockStatement): void { + let targetBlockScope: TNodeWithBlockStatement; + + if (this.stackTraceData.length) { + targetBlockScope = NodeAppender + .getOptimalBlockScope(this.stackTraceData, this.randomStackTraceIndex, 1); + } else { + targetBlockScope = blockScopeNode; + } + + NodeAppender.prependNode(targetBlockScope, this.getNode()); + } + + /** + * @returns {TStatement[]} + */ + protected getNodeStructure (): TStatement[] { + if (this.appendState === AppendState.AfterObfuscation) { + return NodeUtils.convertCodeToStructure( + JavaScriptObfuscator.obfuscate(SingleNodeCallControllerTemplate().formatUnicorn({ + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }), NO_CUSTOM_NODES_PRESET).getObfuscatedCode() + ); + } + + return NodeUtils.convertCodeToStructure( + SingleNodeCallControllerTemplate().formatUnicorn({ + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }) + ); + } +} diff --git a/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts b/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts index e10b5b8c..f3d3b1ae 100644 --- a/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts +++ b/src/custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode.ts @@ -1,48 +1,83 @@ -import { INode } from "../../interfaces/nodes/INode"; +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; +import { IOptions } from '../../interfaces/IOptions'; +import { IStackTraceData } from '../../interfaces/stack-trace-analyzer/IStackTraceData'; -import { AppendState } from "../../enums/AppendState"; +import { AppendState } from '../../enums/AppendState'; -import { NO_CUSTOM_NODES_PRESET } from "../../preset-options/NoCustomNodesPreset"; +import { NO_CUSTOM_NODES_PRESET } from '../../preset-options/NoCustomNodesPreset'; -import { SelfDefendingTemplate } from "../../templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate"; +import { SelfDefendingTemplate } from '../../templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate'; -import { JavaScriptObfuscator } from "../../JavaScriptObfuscator"; -import { Node } from '../Node'; -import { NodeUtils } from "../../NodeUtils"; -import { Utils } from "../../Utils"; +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { NodeAppender } from '../../NodeAppender'; +import { JavaScriptObfuscator } from '../../JavaScriptObfuscator'; +import { NodeUtils } from '../../NodeUtils'; +import { Utils } from '../../Utils'; -export class SelfDefendingUnicodeNode extends Node { +export class SelfDefendingUnicodeNode extends AbstractCustomNode { /** * @type {AppendState} */ protected appendState: AppendState = AppendState.AfterObfuscation; /** - * @param blockScopeNode + * @type {string} */ - public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - let programBodyLength: number = blockScopeNode.body.length, - randomIndex: number = 0; + protected callsControllerFunctionName: string; - if (programBodyLength > 2) { - randomIndex = Utils.getRandomGenerator().integer({ - min: programBodyLength / 2, - max: programBodyLength - 1 - }); - } + /** + * @type {number} + */ + protected randomStackTraceIndex: number; - NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), randomIndex); + /** + * @type {IStackTraceData[]} + */ + protected stackTraceData: IStackTraceData[]; + + /** + * @param stackTraceData + * @param callsControllerFunctionName + * @param randomStackTraceIndex + * @param options + */ + constructor ( + stackTraceData: IStackTraceData[], + callsControllerFunctionName: string, + randomStackTraceIndex: number, + options: IOptions + ) { + super(options); + + this.stackTraceData = stackTraceData; + this.callsControllerFunctionName = callsControllerFunctionName; + this.randomStackTraceIndex = randomStackTraceIndex; } /** - * @returns {INode} + * @param blockScopeNode */ - protected getNodeStructure (): INode { + public appendNode (blockScopeNode: TNodeWithBlockStatement): void { + NodeAppender.appendNodeToOptimalBlockScope( + this.stackTraceData, + blockScopeNode, + this.getNode(), + this.randomStackTraceIndex + ); + } + + /** + * @returns {TStatement[]} + */ + protected getNodeStructure (): TStatement[] { return NodeUtils.convertCodeToStructure( JavaScriptObfuscator.obfuscate( - SelfDefendingTemplate(), + SelfDefendingTemplate().formatUnicorn({ + selfDefendingFunctionName: Utils.getRandomVariableName(), + singleNodeCallControllerFunctionName: this.callsControllerFunctionName + }), NO_CUSTOM_NODES_PRESET ).getObfuscatedCode() ); diff --git a/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts b/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts index bc34df79..31409cd0 100644 --- a/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts +++ b/src/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.ts @@ -1,28 +1,38 @@ import 'format-unicorn'; -import { INode } from "../../interfaces/nodes/INode"; -import { IOptions } from "../../interfaces/IOptions"; +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; +import { IOptions } from '../../interfaces/IOptions'; -import { AppendState } from "../../enums/AppendState"; +import { AppendState } from '../../enums/AppendState'; +import { UnicodeArrayEncoding } from '../../enums/UnicodeArrayEncoding'; -import { UnicodeArrayCallsWrapperTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayCallsWrapperTemplate"; +import { NO_CUSTOM_NODES_PRESET } from '../../preset-options/NoCustomNodesPreset'; -import { Node } from '../Node'; -import { NodeUtils } from "../../NodeUtils"; -import { Utils } from "../../Utils"; +import { AtobTemplate } from '../../templates/custom-nodes/AtobTemplate'; +import { Rc4Template } from '../../templates/custom-nodes/Rc4Template'; +import { SelfDefendingTemplate } from '../../templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/SelfDefendingTemplate'; +import { UnicodeArrayBase64DecodeNodeTemplate } from '../../templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayBase64DecodeNodeTemplate'; +import { UnicodeArrayCallsWrapperTemplate } from '../../templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayCallsWrapperTemplate'; +import { UnicodeArrayRc4DecodeNodeTemplate } from '../../templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayRC4DecodeNodeTemplate'; -export class UnicodeArrayCallsWrapper extends Node { +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { JavaScriptObfuscator } from '../../JavaScriptObfuscator'; +import { NodeAppender } from '../../NodeAppender'; +import { NodeUtils } from '../../NodeUtils'; +import { UnicodeArray } from '../../UnicodeArray'; + +export class UnicodeArrayCallsWrapper extends AbstractCustomNode { /** * @type {AppendState} */ protected appendState: AppendState = AppendState.AfterObfuscation; /** - * @type {string[]} + * @type {UnicodeArray} */ - private unicodeArray: string[]; + private unicodeArray: UnicodeArray; /** * @type {string} @@ -43,7 +53,7 @@ export class UnicodeArrayCallsWrapper extends Node { constructor ( unicodeArrayCallsWrapperName: string, unicodeArrayName: string, - unicodeArray: string[], + unicodeArray: UnicodeArray, options: IOptions ) { super(options); @@ -57,11 +67,11 @@ export class UnicodeArrayCallsWrapper extends Node { * @param blockScopeNode */ public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - if (!this.unicodeArray.length) { + if (!this.unicodeArray.getLength()) { return; } - NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), 1); + NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), 1); } /** @@ -72,24 +82,65 @@ export class UnicodeArrayCallsWrapper extends Node { }; /** - * @returns {INode} + * @returns {TStatement[]} */ - public getNode (): INode { + public getNode (): TStatement[] { return super.getNode(); } /** - * @returns {INode} + * @returns {string} */ - protected getNodeStructure (): INode { - let keyName: string = Utils.getRandomVariableName(); + protected getDecodeUnicodeArrayTemplate (): string { + let decodeUnicodeArrayTemplate: string = '', + selfDefendingCode: string = ''; - return NodeUtils.convertCodeToStructure( - UnicodeArrayCallsWrapperTemplate().formatUnicorn({ - keyName: keyName, + if (this.options.selfDefending) { + selfDefendingCode = SelfDefendingTemplate().formatUnicorn({ unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName, unicodeArrayName: this.unicodeArrayName - }) + }); + } + + switch (this.options.unicodeArrayEncoding) { + case UnicodeArrayEncoding.base64: + decodeUnicodeArrayTemplate = UnicodeArrayBase64DecodeNodeTemplate().formatUnicorn({ + atobPolyfill: AtobTemplate(), + selfDefendingCode, + unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName + }); + + break; + + case UnicodeArrayEncoding.rc4: + decodeUnicodeArrayTemplate = UnicodeArrayRc4DecodeNodeTemplate().formatUnicorn({ + atobPolyfill: AtobTemplate(), + rc4Polyfill: Rc4Template(), + selfDefendingCode, + unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName + }); + + break; + } + + return decodeUnicodeArrayTemplate; + } + + /** + * @returns {TStatement[]} + */ + protected getNodeStructure (): TStatement[] { + const decodeNodeTemplate: string = this.getDecodeUnicodeArrayTemplate(); + + return NodeUtils.convertCodeToStructure( + JavaScriptObfuscator.obfuscate( + UnicodeArrayCallsWrapperTemplate().formatUnicorn({ + decodeNodeTemplate, + unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName, + unicodeArrayName: this.unicodeArrayName + }), + NO_CUSTOM_NODES_PRESET + ).getObfuscatedCode() ); } } diff --git a/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.ts b/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.ts deleted file mode 100644 index 32487eb0..00000000 --- a/src/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.ts +++ /dev/null @@ -1,99 +0,0 @@ -import 'format-unicorn'; - -import { INode } from "../../interfaces/nodes/INode"; -import { IOptions } from "../../interfaces/IOptions"; - -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; - -import { AppendState } from "../../enums/AppendState"; - -import { NO_CUSTOM_NODES_PRESET } from "../../preset-options/NoCustomNodesPreset"; - -import { AtobTemplate } from "../../templates/custom-nodes/AtobTemplate"; -import { SelfDefendingTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/SelfDefendingTemplate"; -import { UnicodeArrayDecodeTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/UnicodeArrayDecodeTemplate"; - -import { JavaScriptObfuscator } from '../../JavaScriptObfuscator'; -import { Node } from '../Node'; -import { NodeUtils } from "../../NodeUtils"; - -export class UnicodeArrayDecodeNode extends Node { - /** - * @type {AppendState} - */ - protected appendState: AppendState = AppendState.AfterObfuscation; - - /** - * @type {string[]} - */ - private unicodeArray: string[]; - - /** - * @type {string} - */ - private unicodeArrayName: string; - - /** - * @param unicodeArrayName - * @param unicodeArray - * @param options - */ - constructor ( - unicodeArrayName: string, - unicodeArray: string[], - options: IOptions - ) { - super(options); - - this.unicodeArrayName = unicodeArrayName; - this.unicodeArray = unicodeArray; - } - - /** - * @param blockScopeNode - */ - public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - if (!this.unicodeArray.length) { - return; - } - - NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), 1); - } - - /** - * @returns {INode} - */ - public getNode (): INode { - return super.getNode(); - } - - /** - * @returns {INode} - */ - protected getNodeStructure (): INode { - const forLoopFunctionName: string = 'forLoopFunc'; - - let code: string; - - if (this.options.selfDefending) { - code = SelfDefendingTemplate().formatUnicorn({ - forLoopFunctionName, - unicodeArrayName: this.unicodeArrayName - }); - } else { - code = `${forLoopFunctionName}();`; - } - - return NodeUtils.convertCodeToStructure( - JavaScriptObfuscator.obfuscate( - UnicodeArrayDecodeTemplate().formatUnicorn({ - atobPolyfill: AtobTemplate(), - code, - forLoopFunctionName, - unicodeArrayName: this.unicodeArrayName - }), - NO_CUSTOM_NODES_PRESET - ).getObfuscatedCode() - ); - } -} diff --git a/src/custom-nodes/unicode-array-nodes/UnicodeArrayNode.ts b/src/custom-nodes/unicode-array-nodes/UnicodeArrayNode.ts index ce0ff9ef..d080930c 100644 --- a/src/custom-nodes/unicode-array-nodes/UnicodeArrayNode.ts +++ b/src/custom-nodes/unicode-array-nodes/UnicodeArrayNode.ts @@ -1,19 +1,21 @@ import 'format-unicorn'; -import { INode } from '../../interfaces/nodes/INode'; -import { IOptions } from "../../interfaces/IOptions"; +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; +import { IOptions } from '../../interfaces/IOptions'; import { AppendState } from '../../enums/AppendState'; -import { UnicodeArrayTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-node/UnicodeArrayTemplate"; +import { UnicodeArray } from '../../UnicodeArray'; -import { Node } from '../Node'; -import { NodeUtils } from "../../NodeUtils"; -import { Utils } from '../../Utils'; +import { UnicodeArrayTemplate } from '../../templates/custom-nodes/unicode-array-nodes/unicode-array-node/UnicodeArrayTemplate'; -export class UnicodeArrayNode extends Node { +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { NodeAppender } from '../../NodeAppender'; +import { NodeUtils } from '../../NodeUtils'; + +export class UnicodeArrayNode extends AbstractCustomNode { /** * @type {number} */ @@ -25,9 +27,9 @@ export class UnicodeArrayNode extends Node { protected appendState: AppendState = AppendState.AfterObfuscation; /** - * @type {string[]} + * @type {UnicodeArray} */ - private unicodeArray: string[] = []; + private unicodeArray: UnicodeArray; /** * @type {string} @@ -40,17 +42,20 @@ export class UnicodeArrayNode extends Node { private unicodeArrayRotateValue: number; /** + * @param unicodeArray * @param unicodeArrayName * @param unicodeArrayRotateValue * @param options */ constructor ( + unicodeArray: UnicodeArray, unicodeArrayName: string, unicodeArrayRotateValue: number = 0, options: IOptions ) { super(options); + this.unicodeArray = unicodeArray; this.unicodeArrayName = unicodeArrayName; this.unicodeArrayRotateValue = unicodeArrayRotateValue; } @@ -59,11 +64,11 @@ export class UnicodeArrayNode extends Node { * @param blockScopeNode */ public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - if (!this.unicodeArray.length) { + if (!this.unicodeArray.getLength()) { return; } - NodeUtils.prependNode(blockScopeNode.body, this.getNode()); + NodeAppender.prependNode(blockScopeNode, this.getNode()); } /** @@ -74,17 +79,17 @@ export class UnicodeArrayNode extends Node { } /** - * @returns {string[]} + * @returns {UnicodeArray} */ - public getNodeData (): string[] { + public getNodeData (): UnicodeArray { return this.unicodeArray; } /** - * @returns {INode} + * @returns {TStatement[]} */ - public getNode (): INode { - Utils.arrayRotate (this.unicodeArray, this.unicodeArrayRotateValue); + public getNode (): TStatement[] { + this.unicodeArray.rotateArray(this.unicodeArrayRotateValue); return super.getNode(); } @@ -93,17 +98,17 @@ export class UnicodeArrayNode extends Node { * @param data */ public updateNodeData (data: string): void { - this.unicodeArray.push(data); + this.unicodeArray.addToArray(data); } /** - * @returns {INode} + * @returns {TStatement[]} */ - protected getNodeStructure (): INode { + protected getNodeStructure (): TStatement[] { return NodeUtils.convertCodeToStructure( UnicodeArrayTemplate().formatUnicorn({ unicodeArrayName: this.unicodeArrayName, - unicodeArray: this.unicodeArray.join(',') + unicodeArray: this.unicodeArray.toString() }) ); } diff --git a/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts b/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts index 41809dab..b470014f 100644 --- a/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts +++ b/src/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.ts @@ -1,32 +1,34 @@ import 'format-unicorn'; -import { INode } from "../../interfaces/nodes/INode"; -import { IOptions } from "../../interfaces/IOptions"; +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; -import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement"; +import { IOptions } from '../../interfaces/IOptions'; -import { AppendState } from "../../enums/AppendState"; +import { AppendState } from '../../enums/AppendState'; -import { NO_CUSTOM_NODES_PRESET } from "../../preset-options/NoCustomNodesPreset"; +import { NO_CUSTOM_NODES_PRESET } from '../../preset-options/NoCustomNodesPreset'; -import { SelfDefendingTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-rotate-function-node/SelfDefendingTemplate"; -import { UnicodeArrayRotateFunctionTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-rotate-function-node/UnicodeArrayRotateFunctionTemplate"; +import { SelfDefendingTemplate } from '../../templates/custom-nodes/unicode-array-nodes/unicode-array-rotate-function-node/SelfDefendingTemplate'; +import { UnicodeArrayRotateFunctionTemplate } from '../../templates/custom-nodes/unicode-array-nodes/unicode-array-rotate-function-node/UnicodeArrayRotateFunctionTemplate'; -import { JavaScriptObfuscator } from "../../JavaScriptObfuscator"; -import { Node } from '../Node'; -import { NodeUtils } from "../../NodeUtils"; -import { Utils } from "../../Utils"; +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { JavaScriptObfuscator } from '../../JavaScriptObfuscator'; +import { NodeAppender } from '../../NodeAppender'; +import { NodeUtils } from '../../NodeUtils'; +import { UnicodeArray } from '../../UnicodeArray'; +import { Utils } from '../../Utils'; -export class UnicodeArrayRotateFunctionNode extends Node { +export class UnicodeArrayRotateFunctionNode extends AbstractCustomNode { /** * @type {AppendState} */ protected appendState: AppendState = AppendState.AfterObfuscation; /** - * @type {string[]} + * @type {UnicodeArray} */ - private unicodeArray: string[]; + private unicodeArray: UnicodeArray; /** * @type {string} @@ -46,7 +48,7 @@ export class UnicodeArrayRotateFunctionNode extends Node { */ constructor ( unicodeArrayName: string, - unicodeArray: string[], + unicodeArray: UnicodeArray, unicodeArrayRotateValue: number, options: IOptions ) { @@ -61,24 +63,24 @@ export class UnicodeArrayRotateFunctionNode extends Node { * @param blockScopeNode */ public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - if (!this.unicodeArray.length) { + if (!this.unicodeArray.getLength()) { return; } - NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), 1); + NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), 1); } /** - * @returns {INode} + * @returns {TStatement[]} */ - public getNode (): INode { + public getNode (): TStatement[] { return super.getNode(); } /** - * @returns {INode} + * @returns {TStatement[]} */ - protected getNodeStructure (): INode { + protected getNodeStructure (): TStatement[] { let code: string = '', timesName: string = Utils.getRandomVariableName(), whileFunctionName: string = Utils.getRandomVariableName(); diff --git a/src/declarations/ESTree.d.ts b/src/declarations/ESTree.d.ts new file mode 100644 index 00000000..8671ff59 --- /dev/null +++ b/src/declarations/ESTree.d.ts @@ -0,0 +1,18 @@ +/* tslint:disable:interface-name */ + +import * as ESTree from 'estree'; + +declare module 'estree' { + interface BaseNode { + parentNode?: ESTree.Node; + obfuscated?: boolean; + } + + interface SimpleLiteral extends ESTree.BaseNode, ESTree.BaseExpression { + 'x-verbatim-property'?: any; + } + + interface RegExpLiteral extends ESTree.BaseNode, ESTree.BaseExpression { + 'x-verbatim-property'?: any; + } +} diff --git a/src/enums/NodeType.ts b/src/enums/NodeType.ts index c2b8e3f1..6f3df5e6 100644 --- a/src/enums/NodeType.ts +++ b/src/enums/NodeType.ts @@ -1,4 +1,4 @@ -import { Utils } from "../Utils"; +import { Utils } from '../Utils'; export const NodeType: any = Utils.strEnumify({ ArrayExpression: 'ArrayExpression', diff --git a/src/enums/UnicodeArrayEncoding.ts b/src/enums/UnicodeArrayEncoding.ts new file mode 100644 index 00000000..6b59c7f1 --- /dev/null +++ b/src/enums/UnicodeArrayEncoding.ts @@ -0,0 +1,4 @@ +export const UnicodeArrayEncoding: any = { + base64: 'base64', + rc4: 'rc4' +}; diff --git a/src/interfaces/IGenerator.d.ts b/src/interfaces/IGenerator.d.ts index e3815ace..b185892d 100644 --- a/src/interfaces/IGenerator.d.ts +++ b/src/interfaces/IGenerator.d.ts @@ -1,4 +1,4 @@ -import { IGeneratorOutput } from "./IGeneratorOutput"; +import { IGeneratorOutput } from './IGeneratorOutput'; declare module 'escodegen' { export function generate(ast: any, options?: GenerateOptions): IGeneratorOutput; diff --git a/src/interfaces/IGeneratorOutput.ts b/src/interfaces/IGeneratorOutput.d.ts similarity index 100% rename from src/interfaces/IGeneratorOutput.ts rename to src/interfaces/IGeneratorOutput.d.ts diff --git a/src/interfaces/INodeObfuscator.d.ts b/src/interfaces/INodeObfuscator.d.ts index e9b0d073..614c7481 100644 --- a/src/interfaces/INodeObfuscator.d.ts +++ b/src/interfaces/INodeObfuscator.d.ts @@ -1,9 +1,9 @@ -import { INode } from '../interfaces/nodes/INode'; +import * as ESTree from 'estree'; export interface INodeObfuscator { /** * @param node * @param parentNode */ - obfuscateNode (node: INode, parentNode?: INode): void; + obfuscateNode (node: ESTree.Node, parentNode?: ESTree.Node): void; } diff --git a/src/interfaces/INodesGroup.d.ts b/src/interfaces/INodesGroup.d.ts index 14704d32..be7ca0e7 100644 --- a/src/interfaces/INodesGroup.d.ts +++ b/src/interfaces/INodesGroup.d.ts @@ -2,7 +2,7 @@ import { ICustomNode } from './custom-nodes/ICustomNode'; export interface INodesGroup { /** - * @returns {Map } + * @returns {Map | undefined} */ - getNodes (): Map ; + getNodes (): Map | undefined; } diff --git a/src/interfaces/IObfuscator.d.ts b/src/interfaces/IObfuscator.d.ts index df16a8fd..25f1fbbb 100644 --- a/src/interfaces/IObfuscator.d.ts +++ b/src/interfaces/IObfuscator.d.ts @@ -1,5 +1,5 @@ -import { INode } from "./nodes/INode"; +import * as ESTree from 'estree'; export interface IObfuscator { - obfuscateNode (node: INode): INode; + obfuscateNode (node: ESTree.Node): ESTree.Node; } diff --git a/src/interfaces/IObfuscatorOptions.d.ts b/src/interfaces/IObfuscatorOptions.d.ts index b4cb8808..e0f5d0ab 100644 --- a/src/interfaces/IObfuscatorOptions.d.ts +++ b/src/interfaces/IObfuscatorOptions.d.ts @@ -1,18 +1,21 @@ -import { TSourceMapMode } from "../types/TSourceMapMode"; +import { TSourceMapMode } from '../types/TSourceMapMode'; +import { TUnicodeArrayEncoding } from '../types/TUnicodeArrayEncoding'; export interface IObfuscatorOptions { compact?: boolean; debugProtection?: boolean; debugProtectionInterval?: boolean; disableConsoleOutput?: boolean; - encodeUnicodeLiterals?: boolean; + domainLock?: string[]; reservedNames?: string[]; rotateUnicodeArray?: boolean; selfDefending?: boolean; sourceMap?: boolean; + sourceMapBaseUrl?: string; + sourceMapFileName?: string; sourceMapMode?: TSourceMapMode; unicodeArray?: boolean; + unicodeArrayEncoding?: TUnicodeArrayEncoding; unicodeArrayThreshold?: number; - wrapUnicodeArrayCalls?: boolean; [key: string]: any; } diff --git a/src/interfaces/IOptions.d.ts b/src/interfaces/IOptions.d.ts index 687ffcf1..be0857c1 100644 --- a/src/interfaces/IOptions.d.ts +++ b/src/interfaces/IOptions.d.ts @@ -1,17 +1,20 @@ -import { TSourceMapMode } from "../types/TSourceMapMode"; +import { TSourceMapMode } from '../types/TSourceMapMode'; +import { TUnicodeArrayEncoding } from '../types/TUnicodeArrayEncoding'; export interface IOptions { readonly compact: boolean; readonly debugProtection: boolean; readonly debugProtectionInterval: boolean; readonly disableConsoleOutput: boolean; - readonly encodeUnicodeLiterals: boolean; + readonly domainLock: string[]; readonly reservedNames: string[]; readonly rotateUnicodeArray: boolean; readonly selfDefending: boolean; readonly sourceMap: boolean; + readonly sourceMapBaseUrl: string; + readonly sourceMapFileName: string; readonly sourceMapMode: TSourceMapMode; readonly unicodeArray: boolean; + readonly unicodeArrayEncoding: TUnicodeArrayEncoding; readonly unicodeArrayThreshold: number; - readonly wrapUnicodeArrayCalls: boolean; } diff --git a/src/interfaces/IPackageConfig.ts b/src/interfaces/IPackageConfig.d.ts similarity index 100% rename from src/interfaces/IPackageConfig.ts rename to src/interfaces/IPackageConfig.d.ts diff --git a/src/interfaces/IReplacer.d.ts b/src/interfaces/IReplacer.d.ts new file mode 100644 index 00000000..4cb487d1 --- /dev/null +++ b/src/interfaces/IReplacer.d.ts @@ -0,0 +1,3 @@ +export interface IReplacer { + replace (nodeValue: any, namesMap?: Map ): string; +} diff --git a/src/interfaces/ISourceMapCorrector.d.ts b/src/interfaces/ISourceMapCorrector.d.ts index 02360615..56aae140 100644 --- a/src/interfaces/ISourceMapCorrector.d.ts +++ b/src/interfaces/ISourceMapCorrector.d.ts @@ -1,4 +1,4 @@ -import { IObfuscationResult } from "./IObfuscationResult"; +import { IObfuscationResult } from './IObfuscationResult'; export interface ISourceMapCorrector { correct (): IObfuscationResult; diff --git a/src/interfaces/custom-nodes/ICustomNode.d.ts b/src/interfaces/custom-nodes/ICustomNode.d.ts index 30108054..6e6b84fe 100644 --- a/src/interfaces/custom-nodes/ICustomNode.d.ts +++ b/src/interfaces/custom-nodes/ICustomNode.d.ts @@ -1,4 +1,6 @@ -import { INode } from '../nodes/INode'; +import * as ESTree from 'estree'; + +import { TStatement } from '../../types/TStatement'; import { AppendState } from '../../enums/AppendState'; @@ -6,7 +8,7 @@ export interface ICustomNode { /** * @param astTree */ - appendNode (astTree: INode): void; + appendNode (astTree: ESTree.Node): void; /** * @returns {AppendState} @@ -14,7 +16,12 @@ export interface ICustomNode { getAppendState (): AppendState; /** - * @returns INode + * @returns ESTree.Node[] */ - getNode (): INode; + getNode (): TStatement[]; + + /** + * @param appendState + */ + setAppendState (appendState: AppendState): void; } diff --git a/src/interfaces/custom-nodes/ICustomNodeWithData.d.ts b/src/interfaces/custom-nodes/ICustomNodeWithData.d.ts index b2e8cd1b..a5b0fc6e 100644 --- a/src/interfaces/custom-nodes/ICustomNodeWithData.d.ts +++ b/src/interfaces/custom-nodes/ICustomNodeWithData.d.ts @@ -1,4 +1,4 @@ -import { ICustomNode } from "./ICustomNode"; +import { ICustomNode } from './ICustomNode'; export interface ICustomNodeWithData extends ICustomNode { /** diff --git a/src/interfaces/custom-nodes/ICustomNodeWithIdentifier.d.ts b/src/interfaces/custom-nodes/ICustomNodeWithIdentifier.d.ts index a290ee86..b9f9f80c 100644 --- a/src/interfaces/custom-nodes/ICustomNodeWithIdentifier.d.ts +++ b/src/interfaces/custom-nodes/ICustomNodeWithIdentifier.d.ts @@ -1,4 +1,4 @@ -import { ICustomNode } from "./ICustomNode"; +import { ICustomNode } from './ICustomNode'; export interface ICustomNodeWithIdentifier extends ICustomNode { /** diff --git a/src/interfaces/nodes/IArrowFunctionExpressionNode.d.ts b/src/interfaces/nodes/IArrowFunctionExpressionNode.d.ts deleted file mode 100644 index 83b7ae93..00000000 --- a/src/interfaces/nodes/IArrowFunctionExpressionNode.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { IFunctionNode } from "./IFunctionNode"; - -export interface IArrowFunctionExpressionNode extends IFunctionNode {} diff --git a/src/interfaces/nodes/IBlockStatementNode.d.ts b/src/interfaces/nodes/IBlockStatementNode.d.ts deleted file mode 100644 index 9f6931e3..00000000 --- a/src/interfaces/nodes/IBlockStatementNode.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TStatement } from "../../types/nodes/TStatement"; - -import { INode } from "./INode"; - -export interface IBlockStatementNode extends INode { - body: TStatement[]; -} diff --git a/src/interfaces/nodes/ICallExpressionNode.d.ts b/src/interfaces/nodes/ICallExpressionNode.d.ts deleted file mode 100644 index 90e52d29..00000000 --- a/src/interfaces/nodes/ICallExpressionNode.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { TExpression } from "../../types/nodes/TExpression"; - -import { INode } from "./INode"; -import { ISpreadElementNode } from "./ISpreadElementNode"; - -export interface ICallExpressionNode extends INode { - callee: TExpression; - arguments: TExpression[] | ISpreadElementNode[]; -} diff --git a/src/interfaces/nodes/ICatchClauseNode.d.ts b/src/interfaces/nodes/ICatchClauseNode.d.ts deleted file mode 100644 index 12a9c689..00000000 --- a/src/interfaces/nodes/ICatchClauseNode.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { IBlockStatementNode } from "./IBlockStatementNode"; -import { IIdentifierNode } from "./IIdentifierNode"; -import { INode } from "./INode"; - -export interface ICatchClauseNode extends INode { - param: IIdentifierNode; - body: IBlockStatementNode; -} diff --git a/src/interfaces/nodes/IExpressionStatementNode.d.ts b/src/interfaces/nodes/IExpressionStatementNode.d.ts deleted file mode 100644 index ca18e5cc..00000000 --- a/src/interfaces/nodes/IExpressionStatementNode.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TExpression } from "../../types/nodes/TExpression"; - -import { INode } from "./INode"; - -export interface IExpressionStatementNode extends INode { - expression: TExpression; -} diff --git a/src/interfaces/nodes/IFunctionDeclarationNode.d.ts b/src/interfaces/nodes/IFunctionDeclarationNode.d.ts deleted file mode 100644 index bbe63c66..00000000 --- a/src/interfaces/nodes/IFunctionDeclarationNode.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { IFunctionNode } from "./IFunctionNode"; - -export interface IFunctionDeclarationNode extends IFunctionNode {} diff --git a/src/interfaces/nodes/IFunctionExpressionNode.d.ts b/src/interfaces/nodes/IFunctionExpressionNode.d.ts deleted file mode 100644 index 96e85013..00000000 --- a/src/interfaces/nodes/IFunctionExpressionNode.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { IFunctionNode } from "./IFunctionNode"; - -export interface IFunctionExpressionNode extends IFunctionNode {} diff --git a/src/interfaces/nodes/IFunctionNode.d.ts b/src/interfaces/nodes/IFunctionNode.d.ts deleted file mode 100644 index fbbdd084..00000000 --- a/src/interfaces/nodes/IFunctionNode.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { TExpression } from "../../types/nodes/TExpression"; - -import { IBlockStatementNode } from "./IBlockStatementNode"; -import { IIdentifierNode } from "./IIdentifierNode"; -import { INode } from "./INode"; - -export interface IFunctionNode extends INode { - id: IIdentifierNode; - params: IIdentifierNode[]; - defaults?: TExpression[]; - body: IBlockStatementNode; - generator: boolean; - expression: boolean; -} diff --git a/src/interfaces/nodes/IIdentifierNode.d.ts b/src/interfaces/nodes/IIdentifierNode.d.ts deleted file mode 100644 index 857bdc31..00000000 --- a/src/interfaces/nodes/IIdentifierNode.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { INode } from "./INode"; - -export interface IIdentifierNode extends INode { - name: string; -} diff --git a/src/interfaces/nodes/IIfStatementNode.ts b/src/interfaces/nodes/IIfStatementNode.ts deleted file mode 100644 index 0510c752..00000000 --- a/src/interfaces/nodes/IIfStatementNode.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { IBlockStatementNode } from "./IBlockStatementNode"; -import { INode } from "./INode"; - -export interface IIfStatementNode extends INode { - test: any; - consequent: IBlockStatementNode; - alternate: IBlockStatementNode | null; -} diff --git a/src/interfaces/nodes/ILiteralNode.d.ts b/src/interfaces/nodes/ILiteralNode.d.ts deleted file mode 100644 index 7e10d0ba..00000000 --- a/src/interfaces/nodes/ILiteralNode.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { INode } from "./INode"; - -export interface ILiteralNode extends INode { - value: boolean|number|string; - raw: string; - 'x-verbatim-property'?: any; -} diff --git a/src/interfaces/nodes/IMemberExpressionNode.d.ts b/src/interfaces/nodes/IMemberExpressionNode.d.ts deleted file mode 100644 index 75620c51..00000000 --- a/src/interfaces/nodes/IMemberExpressionNode.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IIdentifierNode } from "./IIdentifierNode"; -import { ILiteralNode } from "./ILiteralNode"; -import { INode } from "./INode"; - -export interface IMemberExpressionNode extends INode { - computed: boolean; - object: IIdentifierNode; - property: IIdentifierNode|ILiteralNode; -} diff --git a/src/interfaces/nodes/IMethodDefinitionNode.d.ts b/src/interfaces/nodes/IMethodDefinitionNode.d.ts deleted file mode 100644 index 3dfbf1c9..00000000 --- a/src/interfaces/nodes/IMethodDefinitionNode.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { IFunctionExpressionNode } from "./IFunctionExpressionNode"; -import { IIdentifierNode } from "./IIdentifierNode"; -import { ILiteralNode } from "./ILiteralNode"; -import { INode } from "./INode"; - -export interface IMethodDefinitionNode extends INode { - key: IIdentifierNode|ILiteralNode; - computed: boolean; - value: IFunctionExpressionNode; - kind: string; - static: boolean; -} diff --git a/src/interfaces/nodes/INode.d.ts b/src/interfaces/nodes/INode.d.ts deleted file mode 100644 index 5c798c5f..00000000 --- a/src/interfaces/nodes/INode.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface INode { - type: string; - parentNode?: INode; - obfuscated?: boolean; -} diff --git a/src/interfaces/nodes/IObjectExpressionNode.d.ts b/src/interfaces/nodes/IObjectExpressionNode.d.ts deleted file mode 100644 index 45049551..00000000 --- a/src/interfaces/nodes/IObjectExpressionNode.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IPropertyNode } from "./IPropertyNode"; -import { INode } from "./INode"; - -export interface IObjectExpressionNode extends INode { - properties: IPropertyNode[]; -} diff --git a/src/interfaces/nodes/IProgramNode.d.ts b/src/interfaces/nodes/IProgramNode.d.ts deleted file mode 100644 index b11ce39c..00000000 --- a/src/interfaces/nodes/IProgramNode.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { TStatement } from "../../types/nodes/TStatement"; - -import { INode } from "./INode"; - -export interface IProgramNode extends INode { - body: TStatement[]; - sourceType: string; -} diff --git a/src/interfaces/nodes/IPropertyNode.d.ts b/src/interfaces/nodes/IPropertyNode.d.ts deleted file mode 100644 index 47dc7361..00000000 --- a/src/interfaces/nodes/IPropertyNode.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { IIdentifierNode } from "./IIdentifierNode"; -import { ILiteralNode } from "./ILiteralNode"; -import { INode } from "./INode"; - -export interface IPropertyNode extends INode { - key: IIdentifierNode|ILiteralNode; - computed: boolean; - value: IIdentifierNode|ILiteralNode; - kind: string; - method: boolean; - shorthand: boolean; -} diff --git a/src/interfaces/nodes/ISpreadElementNode.d.ts b/src/interfaces/nodes/ISpreadElementNode.d.ts deleted file mode 100644 index e8e21f81..00000000 --- a/src/interfaces/nodes/ISpreadElementNode.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TExpression } from "../../types/nodes/TExpression"; - -import { INode } from "./INode"; - -export interface ISpreadElementNode extends INode { - argument: TExpression; -} diff --git a/src/interfaces/nodes/IVariableDeclarationNode.d.ts b/src/interfaces/nodes/IVariableDeclarationNode.d.ts deleted file mode 100644 index fa6f29dd..00000000 --- a/src/interfaces/nodes/IVariableDeclarationNode.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { INode } from "./INode"; -import { IVariableDeclaratorNode } from "./IVariableDeclaratorNode"; - -export interface IVariableDeclarationNode extends INode { - declarations: IVariableDeclaratorNode[]; - kind: string; -} diff --git a/src/interfaces/nodes/IVariableDeclaratorNode.d.ts b/src/interfaces/nodes/IVariableDeclaratorNode.d.ts deleted file mode 100644 index a1fe82a0..00000000 --- a/src/interfaces/nodes/IVariableDeclaratorNode.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { IIdentifierNode } from "./IIdentifierNode"; -import { INode } from "./INode"; - -export interface IVariableDeclaratorNode extends INode { - id: IIdentifierNode; - init: any; -} diff --git a/src/interfaces/stack-trace-analyzer/ICalleeData.d.ts b/src/interfaces/stack-trace-analyzer/ICalleeData.d.ts new file mode 100644 index 00000000..30a2a8c5 --- /dev/null +++ b/src/interfaces/stack-trace-analyzer/ICalleeData.d.ts @@ -0,0 +1,6 @@ +import * as ESTree from 'estree'; + +export interface ICalleeData { + callee: ESTree.BlockStatement; + name: string | null; +} diff --git a/src/interfaces/stack-trace-analyzer/ICalleeDataExtractor.d.ts b/src/interfaces/stack-trace-analyzer/ICalleeDataExtractor.d.ts new file mode 100644 index 00000000..1903565f --- /dev/null +++ b/src/interfaces/stack-trace-analyzer/ICalleeDataExtractor.d.ts @@ -0,0 +1,5 @@ +import { ICalleeData } from './ICalleeData'; + +export interface ICalleeDataExtractor { + extract (): ICalleeData|null; +} diff --git a/src/interfaces/stack-trace-analyzer/IStackTraceAnalyzer.d.ts b/src/interfaces/stack-trace-analyzer/IStackTraceAnalyzer.d.ts new file mode 100644 index 00000000..293657f6 --- /dev/null +++ b/src/interfaces/stack-trace-analyzer/IStackTraceAnalyzer.d.ts @@ -0,0 +1,5 @@ +import { IStackTraceData } from './IStackTraceData'; + +export interface IStackTraceAnalyzer { + analyze (): IStackTraceData[]; +} diff --git a/src/interfaces/stack-trace-analyzer/IStackTraceData.d.ts b/src/interfaces/stack-trace-analyzer/IStackTraceData.d.ts new file mode 100644 index 00000000..cdd71e63 --- /dev/null +++ b/src/interfaces/stack-trace-analyzer/IStackTraceData.d.ts @@ -0,0 +1,5 @@ +import { ICalleeData } from './ICalleeData'; + +export interface IStackTraceData extends ICalleeData { + stackTrace: IStackTraceData[]; +} diff --git a/src/node-groups/AbstractNodesGroup.ts b/src/node-groups/AbstractNodesGroup.ts new file mode 100644 index 00000000..f4141bf2 --- /dev/null +++ b/src/node-groups/AbstractNodesGroup.ts @@ -0,0 +1,49 @@ +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; +import { INodesGroup } from '../interfaces/INodesGroup'; +import { IOptions } from '../interfaces/IOptions'; +import { IStackTraceData } from '../interfaces/stack-trace-analyzer/IStackTraceData'; + +import { AppendState } from '../enums/AppendState'; + +export abstract class AbstractNodesGroup implements INodesGroup { + /** + * @type {AppendState} + */ + protected appendState: AppendState = AppendState.BeforeObfuscation; + + /** + * @type {IStackTraceData[]} + */ + protected stackTraceData: IStackTraceData[]; + + /** + * @type {IOptions} + */ + protected options: IOptions; + + /** + * @param stackTraceData + * @param options + */ + constructor (stackTraceData: IStackTraceData[], options: IOptions) { + this.stackTraceData = stackTraceData; + this.options = options; + } + + /** + * @returns {Map | undefined} + */ + public abstract getNodes (): Map | undefined; + + /** + * @param customNodes + * @returns {Map} + */ + protected syncCustomNodesWithNodesGroup (customNodes: Map ): Map { + customNodes.forEach((node: ICustomNode) => { + node.setAppendState(this.appendState); + }); + + return customNodes; + } +} diff --git a/src/node-groups/ConsoleOutputNodesGroup.ts b/src/node-groups/ConsoleOutputNodesGroup.ts index 5d0bc958..f498c96e 100644 --- a/src/node-groups/ConsoleOutputNodesGroup.ts +++ b/src/node-groups/ConsoleOutputNodesGroup.ts @@ -1,22 +1,43 @@ -import { IOptions } from "../interfaces/IOptions"; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; -import { ConsoleOutputDisableExpressionNode } from "../custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode"; -import { NodesGroup } from './NodesGroup'; +import { ConsoleOutputDisableExpressionNode } from '../custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode'; +import { NodeCallsControllerFunctionNode } from '../custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode'; -export class ConsoleOutputNodesGroup extends NodesGroup { +import { AbstractNodesGroup } from './AbstractNodesGroup'; +import { NodeAppender } from '../NodeAppender'; +import { Utils } from '../Utils'; + +export class ConsoleOutputNodesGroup extends AbstractNodesGroup { /** - * @param options + * @returns {Map} */ - constructor (options: IOptions) { - super(options); - + public getNodes (): Map | undefined { if (!this.options.disableConsoleOutput) { return; } - this.nodes.set( - 'consoleOutputDisableExpressionNode', - new ConsoleOutputDisableExpressionNode(this.options) - ); + const callsControllerFunctionName: string = Utils.getRandomVariableName(); + const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length); + + return this.syncCustomNodesWithNodesGroup(new Map ([ + [ + 'consoleOutputDisableExpressionNode', + new ConsoleOutputDisableExpressionNode( + this.stackTraceData, + callsControllerFunctionName, + randomStackTraceIndex, + this.options + ) + ], + [ + 'ConsoleOutputNodeCallsControllerFunctionNode', + new NodeCallsControllerFunctionNode( + this.stackTraceData, + callsControllerFunctionName, + randomStackTraceIndex, + this.options + ) + ] + ])); } } diff --git a/src/node-groups/DebugProtectionNodesGroup.ts b/src/node-groups/DebugProtectionNodesGroup.ts index 9f6b6c50..de8d93e0 100644 --- a/src/node-groups/DebugProtectionNodesGroup.ts +++ b/src/node-groups/DebugProtectionNodesGroup.ts @@ -1,42 +1,40 @@ -import { IOptions } from "../interfaces/IOptions"; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; -import { DebugProtectionFunctionCallNode } from "../custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode"; -import { DebugProtectionFunctionIntervalNode } from "../custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode"; -import { DebugProtectionFunctionNode } from "../custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode"; +import { DebugProtectionFunctionCallNode } from '../custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode'; +import { DebugProtectionFunctionIntervalNode } from '../custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode'; +import { DebugProtectionFunctionNode } from '../custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode'; -import { NodesGroup } from './NodesGroup'; +import { AbstractNodesGroup } from './AbstractNodesGroup'; import { Utils } from '../Utils'; -export class DebugProtectionNodesGroup extends NodesGroup { +export class DebugProtectionNodesGroup extends AbstractNodesGroup { /** - * @type {string} + * @returns {Map | undefined} */ - private debugProtectionFunctionIdentifier: string = Utils.getRandomVariableName(); - - /** - * @param options - */ - constructor (options: IOptions) { - super(options); - + public getNodes (): Map | undefined { if (!this.options.debugProtection) { return; } - this.nodes.set( - 'debugProtectionFunctionNode', - new DebugProtectionFunctionNode(this.debugProtectionFunctionIdentifier, this.options) - ); - this.nodes.set( - 'debugProtectionFunctionCallNode', - new DebugProtectionFunctionCallNode(this.debugProtectionFunctionIdentifier, this.options) - ); + const debugProtectionFunctionName: string = Utils.getRandomVariableName(); + const customNodes: Map = new Map ([ + [ + 'debugProtectionFunctionNode', + new DebugProtectionFunctionNode(debugProtectionFunctionName, this.options) + ], + [ + 'debugProtectionFunctionCallNode', + new DebugProtectionFunctionCallNode(debugProtectionFunctionName, this.options) + ] + ]); if (this.options.debugProtectionInterval) { - this.nodes.set( + customNodes.set( 'debugProtectionFunctionIntervalNode', - new DebugProtectionFunctionIntervalNode(this.debugProtectionFunctionIdentifier, this.options) + new DebugProtectionFunctionIntervalNode(debugProtectionFunctionName, this.options) ); } + + return this.syncCustomNodesWithNodesGroup(customNodes); } } diff --git a/src/node-groups/DomainLockNodesGroup.ts b/src/node-groups/DomainLockNodesGroup.ts new file mode 100644 index 00000000..771c4d78 --- /dev/null +++ b/src/node-groups/DomainLockNodesGroup.ts @@ -0,0 +1,43 @@ +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; + +import { DomainLockNode } from '../custom-nodes/domain-lock-nodes/DomainLockNode'; +import { NodeCallsControllerFunctionNode } from '../custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode'; + +import { AbstractNodesGroup } from './AbstractNodesGroup'; +import { NodeAppender } from '../NodeAppender'; +import { Utils } from '../Utils'; + +export class DomainLockNodesGroup extends AbstractNodesGroup { + /** + * @returns {Map | undefined} + */ + public getNodes (): Map | undefined { + if (!this.options.domainLock.length) { + return; + } + + const callsControllerFunctionName: string = Utils.getRandomVariableName(); + const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length); + + return this.syncCustomNodesWithNodesGroup(new Map ([ + [ + 'DomainLockNode', + new DomainLockNode( + this.stackTraceData, + callsControllerFunctionName, + randomStackTraceIndex, + this.options + ) + ], + [ + 'DomainLockNodeCallsControllerFunctionNode', + new NodeCallsControllerFunctionNode( + this.stackTraceData, + callsControllerFunctionName, + randomStackTraceIndex, + this.options + ) + ] + ])); + } +} diff --git a/src/node-groups/NodesGroup.ts b/src/node-groups/NodesGroup.ts deleted file mode 100644 index 1e8a0a0d..00000000 --- a/src/node-groups/NodesGroup.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; - -import { INodesGroup } from '../interfaces/INodesGroup'; -import { IOptions } from "../interfaces/IOptions"; - -export abstract class NodesGroup implements INodesGroup { - /** - * @type {Map} - */ - protected nodes: Map = new Map (); - - /** - * @type {IOptions} - */ - protected options: IOptions; - - constructor (options: IOptions) { - this.options = options; - } - - /** - * @returns {Map} - */ - public getNodes (): Map { - return this.nodes; - } -} diff --git a/src/node-groups/SelfDefendingNodesGroup.ts b/src/node-groups/SelfDefendingNodesGroup.ts index c250aa30..2c17d659 100644 --- a/src/node-groups/SelfDefendingNodesGroup.ts +++ b/src/node-groups/SelfDefendingNodesGroup.ts @@ -1,22 +1,50 @@ -import { IOptions } from "../interfaces/IOptions"; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; -import { NodesGroup } from './NodesGroup'; -import { SelfDefendingUnicodeNode } from "../custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode"; +import { AppendState } from '../enums/AppendState'; -export class SelfDefendingNodesGroup extends NodesGroup { +import { NodeCallsControllerFunctionNode } from '../custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode'; +import { SelfDefendingUnicodeNode } from '../custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode'; + +import { AbstractNodesGroup } from './AbstractNodesGroup'; +import { NodeAppender } from '../NodeAppender'; +import { Utils } from '../Utils'; + +export class SelfDefendingNodesGroup extends AbstractNodesGroup { /** - * @param options + * @type {AppendState} */ - constructor (options: IOptions) { - super(options); + protected appendState: AppendState = AppendState.AfterObfuscation; + /** + * @returns {Map | undefined} + */ + public getNodes (): Map | undefined { if (!this.options.selfDefending) { return; } - this.nodes.set( - 'selfDefendingUnicodeNode', - new SelfDefendingUnicodeNode(this.options) - ); + const callsControllerFunctionName: string = Utils.getRandomVariableName(); + const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length); + + return this.syncCustomNodesWithNodesGroup(new Map ([ + [ + 'selfDefendingUnicodeNode', + new SelfDefendingUnicodeNode( + this.stackTraceData, + callsControllerFunctionName, + randomStackTraceIndex, + this.options + ) + ], + [ + 'SelfDefendingNodeCallsControllerFunctionNode', + new NodeCallsControllerFunctionNode( + this.stackTraceData, + callsControllerFunctionName, + randomStackTraceIndex, + this.options + ) + ] + ])); } } diff --git a/src/node-groups/UnicodeArrayNodesGroup.ts b/src/node-groups/UnicodeArrayNodesGroup.ts index a8f77638..1b834b97 100644 --- a/src/node-groups/UnicodeArrayNodesGroup.ts +++ b/src/node-groups/UnicodeArrayNodesGroup.ts @@ -1,34 +1,40 @@ -import { IOptions } from "../interfaces/IOptions"; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; -import { NodesGroup } from './NodesGroup'; -import { UnicodeArrayCallsWrapper } from "../custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper"; -import { UnicodeArrayDecodeNode } from "../custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode"; +import { AppendState } from '../enums/AppendState'; + +import { UnicodeArrayCallsWrapper } from '../custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper'; import { UnicodeArrayNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayNode'; import { UnicodeArrayRotateFunctionNode } from '../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode'; + +import { AbstractNodesGroup } from './AbstractNodesGroup'; +import { UnicodeArray } from '../UnicodeArray'; import { Utils } from '../Utils'; -export class UnicodeArrayNodesGroup extends NodesGroup { +export class UnicodeArrayNodesGroup extends AbstractNodesGroup { + /** + * @type {AppendState} + */ + protected appendState: AppendState = AppendState.AfterObfuscation; + /** * @type {string} */ private unicodeArrayName: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH); + /** + * @type {string} + */ + private unicodeArrayCallsWrapper: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH); + /** * @type {number} */ private unicodeArrayRotateValue: number; /** - * @type {string} + * @returns {Map | undefined} */ - private unicodeArrayTranslatorName: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH); - - /** - * @param options - */ - constructor (options: IOptions) { - super(options); - + public getNodes (): Map | undefined { if (!this.options.unicodeArray) { return; } @@ -42,43 +48,30 @@ export class UnicodeArrayNodesGroup extends NodesGroup { this.unicodeArrayRotateValue = 0; } - let unicodeArrayNode: UnicodeArrayNode = new UnicodeArrayNode( - this.unicodeArrayName, - this.unicodeArrayRotateValue, - this.options - ), - unicodeArray: string [] = unicodeArrayNode.getNodeData(); - - this.nodes.set( - 'unicodeArrayNode', - unicodeArrayNode + const unicodeArray: UnicodeArray = new UnicodeArray(); + const unicodeArrayNode: ICustomNode = new UnicodeArrayNode( + unicodeArray, + this.unicodeArrayName, + this.unicodeArrayRotateValue, + this.options ); - - if (this.options.wrapUnicodeArrayCalls) { - this.nodes.set( + const customNodes: Map = new Map ([ + [ + 'unicodeArrayNode', unicodeArrayNode, + ], + [ 'unicodeArrayCallsWrapper', new UnicodeArrayCallsWrapper( - this.unicodeArrayTranslatorName, + this.unicodeArrayCallsWrapper, this.unicodeArrayName, unicodeArray, this.options ) - ); - } - - if (this.options.encodeUnicodeLiterals) { - this.nodes.set( - 'unicodeArrayDecodeNode', - new UnicodeArrayDecodeNode ( - this.unicodeArrayName, - unicodeArray, - this.options - ) - ); - } + ] + ]); if (this.options.rotateUnicodeArray) { - this.nodes.set( + customNodes.set( 'unicodeArrayRotateFunctionNode', new UnicodeArrayRotateFunctionNode( this.unicodeArrayName, @@ -88,5 +81,7 @@ export class UnicodeArrayNodesGroup extends NodesGroup { ) ); } + + return this.syncCustomNodesWithNodesGroup(customNodes); } } diff --git a/src/node-obfuscators/AbstractNodeObfuscator.ts b/src/node-obfuscators/AbstractNodeObfuscator.ts new file mode 100644 index 00000000..c5eed01c --- /dev/null +++ b/src/node-obfuscators/AbstractNodeObfuscator.ts @@ -0,0 +1,32 @@ +import * as ESTree from 'estree'; + +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; +import { INodeObfuscator } from '../interfaces/INodeObfuscator'; +import { IOptions } from '../interfaces/IOptions'; + +export abstract class AbstractNodeObfuscator implements INodeObfuscator { + /** + * @type Map + */ + protected nodes: Map ; + + /** + * @type {IOptions} + */ + protected options: IOptions; + + /** + * @param nodes + * @param options + */ + constructor(nodes: Map , options: IOptions) { + this.nodes = nodes; + this.options = options; + } + + /** + * @param node + * @param parentNode + */ + public abstract obfuscateNode (node: ESTree.Node, parentNode?: ESTree.Node): void; +} diff --git a/src/node-obfuscators/CatchClauseObfuscator.ts b/src/node-obfuscators/CatchClauseObfuscator.ts index 6d843bf4..9e839d9b 100644 --- a/src/node-obfuscators/CatchClauseObfuscator.ts +++ b/src/node-obfuscators/CatchClauseObfuscator.ts @@ -1,9 +1,15 @@ import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; -import { ICatchClauseNode } from "../interfaces/nodes/ICatchClauseNode"; -import { INode } from '../interfaces/nodes/INode'; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; +import { IOptions } from '../interfaces/IOptions'; -import { NodeObfuscator } from './NodeObfuscator'; +import { NodeType } from '../enums/NodeType'; + +import { AbstractNodeObfuscator } from './AbstractNodeObfuscator'; +import { IdentifierReplacer } from './replacers/IdentifierReplacer'; +import { Nodes } from '../Nodes'; +import { NodeUtils } from '../NodeUtils'; /** * replaces: @@ -13,16 +19,26 @@ import { NodeObfuscator } from './NodeObfuscator'; * try {} catch (_0x12d45f) { console.log(_0x12d45f); }; * */ -export class CatchClauseObfuscator extends NodeObfuscator { +export class CatchClauseObfuscator extends AbstractNodeObfuscator { /** - * @type {Map} + * @type {IdentifierReplacer} */ - private catchClauseParam: Map = new Map (); + private identifierReplacer: IdentifierReplacer; + + /** + * @param nodes + * @param options + */ + constructor(nodes: Map , options: IOptions) { + super(nodes, options); + + this.identifierReplacer = new IdentifierReplacer(this.nodes, this.options); + } /** * @param catchClauseNode */ - public obfuscateNode (catchClauseNode: ICatchClauseNode): void { + public obfuscateNode (catchClauseNode: ESTree.CatchClause): void { this.storeCatchClauseParam(catchClauseNode); this.replaceCatchClauseParam(catchClauseNode); } @@ -30,19 +46,21 @@ export class CatchClauseObfuscator extends NodeObfuscator { /** * @param catchClauseNode */ - private storeCatchClauseParam (catchClauseNode: ICatchClauseNode): void { - estraverse.traverse(catchClauseNode.param, { - enter: (node: INode): any => this.storeIdentifiersNames(node, this.catchClauseParam) + private storeCatchClauseParam (catchClauseNode: ESTree.CatchClause): void { + NodeUtils.typedReplace(catchClauseNode.param, NodeType.Identifier, { + enter: (node: ESTree.Identifier) => this.identifierReplacer.storeNames(node.name) }); } /** * @param catchClauseNode */ - private replaceCatchClauseParam (catchClauseNode: ICatchClauseNode): void { + private replaceCatchClauseParam (catchClauseNode: ESTree.CatchClause): void { estraverse.replace(catchClauseNode, { - enter: (node: INode, parentNode: INode): any => { - this.replaceIdentifiersWithRandomNames(node, parentNode, this.catchClauseParam); + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { + if (Nodes.isReplaceableIdentifierNode(node, parentNode)) { + node.name = this.identifierReplacer.replace(node.name); + } } }); } diff --git a/src/node-obfuscators/FunctionDeclarationObfuscator.ts b/src/node-obfuscators/FunctionDeclarationObfuscator.ts index d97e1216..70df73f9 100644 --- a/src/node-obfuscators/FunctionDeclarationObfuscator.ts +++ b/src/node-obfuscators/FunctionDeclarationObfuscator.ts @@ -1,12 +1,15 @@ import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; -import { IFunctionDeclarationNode } from "../interfaces/nodes/IFunctionDeclarationNode"; -import { INode } from "../interfaces/nodes/INode"; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; +import { IOptions } from '../interfaces/IOptions'; -import { NodeType } from "../enums/NodeType"; +import { NodeType } from '../enums/NodeType'; -import { NodeObfuscator } from './NodeObfuscator'; -import { NodeUtils } from "../NodeUtils"; +import { AbstractNodeObfuscator } from './AbstractNodeObfuscator'; +import { IdentifierReplacer } from './replacers/IdentifierReplacer'; +import { Nodes } from '../Nodes'; +import { NodeUtils } from '../NodeUtils'; /** * replaces: @@ -17,17 +20,27 @@ import { NodeUtils } from "../NodeUtils"; * function _0x12d45f () { //... }; * _0x12d45f(); */ -export class FunctionDeclarationObfuscator extends NodeObfuscator { +export class FunctionDeclarationObfuscator extends AbstractNodeObfuscator { /** - * @type {Map} + * @type {IdentifierReplacer} */ - private functionName: Map = new Map (); + private identifierReplacer: IdentifierReplacer; + + /** + * @param nodes + * @param options + */ + constructor(nodes: Map , options: IOptions) { + super(nodes, options); + + this.identifierReplacer = new IdentifierReplacer(this.nodes, this.options); + } /** * @param functionDeclarationNode * @param parentNode */ - public obfuscateNode (functionDeclarationNode: IFunctionDeclarationNode, parentNode: INode): void { + public obfuscateNode (functionDeclarationNode: ESTree.FunctionDeclaration, parentNode: ESTree.Node): void { if (parentNode.type === NodeType.Program) { return; } @@ -39,23 +52,25 @@ export class FunctionDeclarationObfuscator extends NodeObfuscator { /** * @param functionDeclarationNode */ - private storeFunctionName (functionDeclarationNode: IFunctionDeclarationNode): void { - estraverse.traverse(functionDeclarationNode.id, { - enter: (node: INode): any => this.storeIdentifiersNames(node, this.functionName) + private storeFunctionName (functionDeclarationNode: ESTree.FunctionDeclaration): void { + NodeUtils.typedReplace(functionDeclarationNode.id, NodeType.Identifier, { + enter: (node: ESTree.Identifier) => this.identifierReplacer.storeNames(node.name) }); } /** * @param functionDeclarationNode */ - private replaceFunctionName (functionDeclarationNode: IFunctionDeclarationNode): void { - let scopeNode: INode = NodeUtils.getBlockScopeOfNode( + private replaceFunctionName (functionDeclarationNode: ESTree.FunctionDeclaration): void { + let scopeNode: ESTree.Node = NodeUtils.getBlockScopeOfNode( functionDeclarationNode ); estraverse.replace(scopeNode, { - enter: (node: INode, parentNode: INode): any => { - this.replaceIdentifiersWithRandomNames(node, parentNode, this.functionName); + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { + if (Nodes.isReplaceableIdentifierNode(node, parentNode)) { + node.name = this.identifierReplacer.replace(node.name); + } } }); } diff --git a/src/node-obfuscators/FunctionObfuscator.ts b/src/node-obfuscators/FunctionObfuscator.ts index 9a006a4a..634a98c7 100644 --- a/src/node-obfuscators/FunctionObfuscator.ts +++ b/src/node-obfuscators/FunctionObfuscator.ts @@ -1,10 +1,15 @@ import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; -import { IFunctionNode } from "../interfaces/nodes/IFunctionNode"; -import { INode } from "../interfaces/nodes/INode"; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; +import { IOptions } from '../interfaces/IOptions'; -import { NodeObfuscator } from './NodeObfuscator'; -import { Nodes } from "../Nodes"; +import { NodeType } from '../enums/NodeType'; + +import { AbstractNodeObfuscator } from './AbstractNodeObfuscator'; +import { IdentifierReplacer } from './replacers/IdentifierReplacer'; +import { Nodes } from '../Nodes'; +import { NodeUtils } from '../NodeUtils'; /** * replaces: @@ -14,16 +19,26 @@ import { Nodes } from "../Nodes"; * function foo (_0x12d45f) { return _0x12d45f; }; * */ -export class FunctionObfuscator extends NodeObfuscator { +export class FunctionObfuscator extends AbstractNodeObfuscator { /** - * @type {Map} + * @type {IdentifierReplacer} */ - private functionParams: Map = new Map (); + private identifierReplacer: IdentifierReplacer; + + /** + * @param nodes + * @param options + */ + constructor(nodes: Map , options: IOptions) { + super(nodes, options); + + this.identifierReplacer = new IdentifierReplacer(this.nodes, this.options); + } /** * @param functionNode */ - public obfuscateNode (functionNode: IFunctionNode): void { + public obfuscateNode (functionNode: ESTree.Function): void { this.storeFunctionParams(functionNode); this.replaceFunctionParams(functionNode); } @@ -31,11 +46,11 @@ export class FunctionObfuscator extends NodeObfuscator { /** * @param functionNode */ - private storeFunctionParams (functionNode: IFunctionNode): void { + private storeFunctionParams (functionNode: ESTree.Function): void { functionNode.params - .forEach((paramsNode: INode) => { - estraverse.traverse(paramsNode, { - enter: (node: INode): any => this.storeIdentifiersNames(node, this.functionParams) + .forEach((paramsNode: ESTree.Node) => { + NodeUtils.typedReplace(paramsNode, NodeType.Identifier, { + enter: (node: ESTree.Identifier) => this.identifierReplacer.storeNames(node.name) }); }); } @@ -43,19 +58,14 @@ export class FunctionObfuscator extends NodeObfuscator { /** * @param functionNode */ - private replaceFunctionParams (functionNode: IFunctionNode): void { + private replaceFunctionParams (functionNode: ESTree.Function): void { let replaceVisitor: estraverse.Visitor = { - enter: (node: INode, parentNode: INode): any => { - let newNodeName: string = ''; + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { + if (Nodes.isReplaceableIdentifierNode(node, parentNode)) { + const newNodeName: string = this.identifierReplacer.replace(node.name); - if (Nodes.isIdentifierNode(node)) { - newNodeName = node.name; - } - - this.replaceIdentifiersWithRandomNames(node, parentNode, this.functionParams); - - if (Nodes.isIdentifierNode(node)) { if (node.name !== newNodeName) { + node.name = newNodeName; node.obfuscated = true; } } @@ -63,7 +73,7 @@ export class FunctionObfuscator extends NodeObfuscator { }; functionNode.params - .forEach((paramsNode: INode) => { + .forEach((paramsNode: ESTree.Node) => { estraverse.replace(paramsNode, replaceVisitor); }); diff --git a/src/node-obfuscators/LiteralObfuscator.ts b/src/node-obfuscators/LiteralObfuscator.ts index bff831a1..900b5680 100644 --- a/src/node-obfuscators/LiteralObfuscator.ts +++ b/src/node-obfuscators/LiteralObfuscator.ts @@ -1,41 +1,40 @@ import * as escodegen from 'escodegen'; +import * as ESTree from 'estree'; -import { ILiteralNode } from "../interfaces/nodes/ILiteralNode"; +import { AbstractNodeObfuscator } from './AbstractNodeObfuscator'; +import { BooleanLiteralReplacer } from './replacers/BooleanLiteralReplacer'; +import { Nodes } from '../Nodes'; +import { NumberLiteralReplacer } from './replacers/NumberLiteralReplacer'; +import { StringLiteralReplacer } from './replacers/StringLiteralReplacer'; -import { INode } from "../interfaces/nodes/INode"; -import { NodeObfuscator } from './NodeObfuscator'; -import { Nodes } from "../Nodes"; - -export class LiteralObfuscator extends NodeObfuscator { +export class LiteralObfuscator extends AbstractNodeObfuscator { /** * @param literalNode * @param parentNode */ - public obfuscateNode (literalNode: ILiteralNode, parentNode: INode): void { + public obfuscateNode (literalNode: ESTree.Literal, parentNode: ESTree.Node): void { if (Nodes.isPropertyNode(parentNode) && parentNode.key === literalNode) { return; } - if (literalNode['x-verbatim-property']) { - return; - } - let content: string; switch (typeof literalNode.value) { case 'boolean': - content = this.replaceLiteralBooleanWithJSFuck(literalNode.value); + content = new BooleanLiteralReplacer(this.nodes, this.options) + .replace(literalNode.value); break; case 'number': - content = this.replaceLiteralNumberWithHexadecimalValue(literalNode.value); + content = new NumberLiteralReplacer(this.nodes, this.options) + .replace(literalNode.value); break; - case 'string': - content = this.replaceLiteralValueWithUnicodeValue(literalNode.value); + content = new StringLiteralReplacer(this.nodes, this.options) + .replace(literalNode.value); break; diff --git a/src/node-obfuscators/MemberExpressionObfuscator.ts b/src/node-obfuscators/MemberExpressionObfuscator.ts index 90066b4a..dc028b32 100644 --- a/src/node-obfuscators/MemberExpressionObfuscator.ts +++ b/src/node-obfuscators/MemberExpressionObfuscator.ts @@ -1,23 +1,20 @@ import * as escodegen from 'escodegen'; import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; -import { IIdentifierNode } from "../interfaces/nodes/IIdentifierNode"; -import { ILiteralNode } from "../interfaces/nodes/ILiteralNode"; -import { IMemberExpressionNode } from "../interfaces/nodes/IMemberExpressionNode"; -import { INode } from "../interfaces/nodes/INode"; +import { NodeType } from '../enums/NodeType'; -import { NodeType } from "../enums/NodeType"; +import { AbstractNodeObfuscator } from './AbstractNodeObfuscator'; +import { Nodes } from '../Nodes'; +import { StringLiteralReplacer } from './replacers/StringLiteralReplacer'; -import { NodeObfuscator } from './NodeObfuscator'; -import { Nodes } from "../Nodes"; - -export class MemberExpressionObfuscator extends NodeObfuscator { +export class MemberExpressionObfuscator extends AbstractNodeObfuscator { /** * @param memberExpressionNode */ - public obfuscateNode (memberExpressionNode: IMemberExpressionNode): void { + public obfuscateNode (memberExpressionNode: ESTree.MemberExpression): void { estraverse.replace(memberExpressionNode.property, { - enter: (node: INode, parentNode: INode): any => { + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { if (Nodes.isLiteralNode(node)) { this.obfuscateLiteralProperty(node); @@ -48,12 +45,12 @@ export class MemberExpressionObfuscator extends NodeObfuscator { * * @param node */ - private obfuscateIdentifierProperty (node: IIdentifierNode): void { + private obfuscateIdentifierProperty (node: ESTree.Identifier): void { let nodeValue: string = node.name, - literalNode: ILiteralNode = { + literalNode: ESTree.Literal = { raw: `'${nodeValue}'`, 'x-verbatim-property': { - content : this.replaceLiteralValueWithUnicodeValue(nodeValue), + content : new StringLiteralReplacer(this.nodes, this.options).replace(nodeValue), precedence: escodegen.Precedence.Primary }, type: NodeType.Literal, @@ -74,10 +71,10 @@ export class MemberExpressionObfuscator extends NodeObfuscator { * * @param node */ - private obfuscateLiteralProperty (node: ILiteralNode): void { + private obfuscateLiteralProperty (node: ESTree.Literal): void { if (typeof node.value === 'string' && !node['x-verbatim-property']) { node['x-verbatim-property'] = { - content : this.replaceLiteralValueWithUnicodeValue(node.value), + content : new StringLiteralReplacer(this.nodes, this.options).replace(node.value), precedence: escodegen.Precedence.Primary }; } diff --git a/src/node-obfuscators/MethodDefinitionObfuscator.ts b/src/node-obfuscators/MethodDefinitionObfuscator.ts index 4c2e06de..bee963ef 100644 --- a/src/node-obfuscators/MethodDefinitionObfuscator.ts +++ b/src/node-obfuscators/MethodDefinitionObfuscator.ts @@ -1,11 +1,10 @@ import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; -import { IMethodDefinitionNode } from "../interfaces/nodes/IMethodDefinitionNode"; -import { INode } from "../interfaces/nodes/INode"; - -import { NodeObfuscator } from './NodeObfuscator'; -import { Nodes } from "../Nodes"; -import { Utils } from "../Utils"; +import { AbstractNodeObfuscator } from './AbstractNodeObfuscator'; +import { Nodes } from '../Nodes'; +import { Utils } from '../Utils'; +import { StringLiteralReplacer } from './replacers/StringLiteralReplacer'; /** * replaces: @@ -14,7 +13,7 @@ import { Utils } from "../Utils"; * on: * [_0x9a4e('0x0')] { //... }; */ -export class MethodDefinitionObfuscator extends NodeObfuscator { +export class MethodDefinitionObfuscator extends AbstractNodeObfuscator { /** * @type {string[]} */ @@ -24,23 +23,24 @@ export class MethodDefinitionObfuscator extends NodeObfuscator { * @param methodDefinitionNode * @param parentNode */ - public obfuscateNode (methodDefinitionNode: IMethodDefinitionNode, parentNode: INode): void { + public obfuscateNode (methodDefinitionNode: ESTree.MethodDefinition, parentNode: ESTree.Node): void { this.replaceMethodName(methodDefinitionNode); } /** * @param methodDefinitionNode */ - private replaceMethodName (methodDefinitionNode: IMethodDefinitionNode): void { + private replaceMethodName (methodDefinitionNode: ESTree.MethodDefinition): void { estraverse.replace(methodDefinitionNode.key, { - leave: (node: INode): any => { + enter: (node: ESTree.Node): any => { if ( Nodes.isIdentifierNode(node) && !Utils.arrayContains(this.ignoredNames, node.name) && methodDefinitionNode.computed === false ) { methodDefinitionNode.computed = true; - node.name = this.replaceLiteralValueWithUnicodeValue(node.name); + node.name = new StringLiteralReplacer(this.nodes, this.options) + .replace(node.name); return; } diff --git a/src/node-obfuscators/NodeObfuscator.ts b/src/node-obfuscators/NodeObfuscator.ts deleted file mode 100644 index ea042fa0..00000000 --- a/src/node-obfuscators/NodeObfuscator.ts +++ /dev/null @@ -1,175 +0,0 @@ -import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; -import { INodeObfuscator } from '../interfaces/INodeObfuscator'; -import { INode } from "../interfaces/nodes/INode"; -import { IOptions } from "../interfaces/IOptions"; - -import { TUnicodeArrayCallsWrapper } from "../types/custom-nodes/TUnicodeArrayCallsWrapper"; -import { TUnicodeArrayNode } from "../types/custom-nodes/TUnicodeArrayNode"; - -import { JSFuck } from "../enums/JSFuck"; - -import { Nodes } from "../Nodes"; -import { Utils } from '../Utils'; - -export abstract class NodeObfuscator implements INodeObfuscator { - /** - * @type Map - */ - protected nodes: Map ; - - /** - * @type {IOptions} - */ - protected options: IOptions; - - /** - * @param nodes - * @param options - */ - constructor(nodes: Map , options: IOptions) { - this.nodes = nodes; - this.options = options; - } - - /** - * @param node - * @param parentNode - */ - public abstract obfuscateNode (node: INode, parentNode?: INode): void; - - /** - * @param name - * @returns {boolean} - */ - protected isReservedName (name: string): boolean { - return this.options.reservedNames - .some((reservedName: string) => { - return new RegExp(reservedName, 'g').test(name); - }); - } - - /** - * Store all identifiers names as keys in given `namesMap` with random names as value. - * Reserved names will be ignored. - * - * @param node - * @param namesMap - */ - protected storeIdentifiersNames ( - node: INode, - namesMap: Map - ): void { - if (Nodes.isIdentifierNode(node) && !this.isReservedName(node.name)) { - namesMap.set(node.name, Utils.getRandomVariableName()); - } - } - - /** - * @param node - * @param parentNode - * @param namesMap - */ - protected replaceIdentifiersWithRandomNames ( - node: INode, - parentNode: INode, - namesMap: Map - ): void { - if (Nodes.isIdentifierNode(node) && namesMap.has(node.name)) { - const parentNodeIsPropertyNode: boolean = ( - Nodes.isPropertyNode(parentNode) && - parentNode.key === node - ), - parentNodeIsMemberExpressionNode: boolean = ( - Nodes.isMemberExpressionNode(parentNode) && - parentNode.computed === false && - parentNode.property === node - ); - - if (parentNodeIsPropertyNode || parentNodeIsMemberExpressionNode) { - return; - } - - node.name = namesMap.get(node.name); - } - } - - /** - * @param nodeValue - * @returns {string} - */ - protected replaceLiteralBooleanWithJSFuck (nodeValue: boolean): string { - return nodeValue ? JSFuck.True : JSFuck.False; - } - - /** - * @param nodeValue - * @returns {string} - */ - protected replaceLiteralNumberWithHexadecimalValue (nodeValue: number): string { - const prefix: string = '0x'; - - if (!Utils.isInteger(nodeValue)) { - return String(nodeValue); - } - - return `${prefix}${Utils.decToHex(nodeValue)}`; - } - - /** - * @param nodeValue - * @returns {string} - */ - protected replaceLiteralValueWithUnicodeValue (nodeValue: string): string { - let replaceWithUnicodeArrayFlag: boolean = Math.random() <= this.options.unicodeArrayThreshold; - - if (this.options.encodeUnicodeLiterals && replaceWithUnicodeArrayFlag) { - nodeValue = Utils.btoa(nodeValue); - } - - nodeValue = Utils.stringToUnicode(nodeValue); - - if (this.options.unicodeArray && replaceWithUnicodeArrayFlag) { - return this.replaceLiteralValueWithUnicodeArrayCall(nodeValue); - } - - return nodeValue; - } - - /** - * @param value - * @returns {string} - */ - protected replaceLiteralValueWithUnicodeArrayCall (value: string): string { - let unicodeArrayNode: TUnicodeArrayNode = this.nodes.get('unicodeArrayNode'); - - if (!unicodeArrayNode) { - throw new ReferenceError('`unicodeArrayNode` node is not found in Map with custom nodes.'); - } - - let unicodeArray: string[] = unicodeArrayNode.getNodeData(), - valueIndex: number = unicodeArray.indexOf(value), - literalValueCallIndex: number, - hexadecimalIndex: string; - - if (valueIndex >= 0) { - literalValueCallIndex = valueIndex; - } else { - literalValueCallIndex = unicodeArray.length; - unicodeArrayNode.updateNodeData(value); - } - - hexadecimalIndex = this.replaceLiteralNumberWithHexadecimalValue(literalValueCallIndex); - - if (this.options.wrapUnicodeArrayCalls) { - let unicodeArrayCallsWrapper: TUnicodeArrayCallsWrapper = this.nodes.get('unicodeArrayCallsWrapper'); - - if (!unicodeArrayCallsWrapper) { - throw new ReferenceError('`unicodeArrayCallsWrapper` node is not found in Map with custom nodes.'); - } - - return `${unicodeArrayCallsWrapper.getNodeIdentifier()}('${hexadecimalIndex}')`; - } - - return `${unicodeArrayNode.getNodeIdentifier()}[${hexadecimalIndex}]`; - } -} diff --git a/src/node-obfuscators/ObjectExpressionObfuscator.ts b/src/node-obfuscators/ObjectExpressionObfuscator.ts index 68610753..0ba6af5b 100644 --- a/src/node-obfuscators/ObjectExpressionObfuscator.ts +++ b/src/node-obfuscators/ObjectExpressionObfuscator.ts @@ -1,16 +1,11 @@ import * as escodegen from 'escodegen'; import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; -import { IIdentifierNode } from "../interfaces/nodes/IIdentifierNode"; -import { ILiteralNode } from "../interfaces/nodes/ILiteralNode"; -import { IObjectExpressionNode } from "../interfaces/nodes/IObjectExpressionNode"; -import { IPropertyNode } from "../interfaces/nodes/IPropertyNode"; -import { INode } from "../interfaces/nodes/INode"; +import { NodeType } from '../enums/NodeType'; -import { NodeType } from "../enums/NodeType"; - -import { NodeObfuscator } from './NodeObfuscator'; -import { Nodes } from "../Nodes"; +import { AbstractNodeObfuscator } from './AbstractNodeObfuscator'; +import { Nodes } from '../Nodes'; import { Utils } from '../Utils'; /** @@ -23,19 +18,19 @@ import { Utils } from '../Utils'; * on: * var object = { '\u0050\u0053\u0045\u0055\u0044\u004f': 1 }; */ -export class ObjectExpressionObfuscator extends NodeObfuscator { +export class ObjectExpressionObfuscator extends AbstractNodeObfuscator { /** * @param objectExpressionNode */ - public obfuscateNode (objectExpressionNode: IObjectExpressionNode): void { + public obfuscateNode (objectExpressionNode: ESTree.ObjectExpression): void { objectExpressionNode.properties - .forEach((property: IPropertyNode) => { + .forEach((property: ESTree.Property) => { if (property.shorthand) { property.shorthand = false; } estraverse.replace(property.key, { - leave: (node: INode, parentNode: INode): any => { + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { if (Nodes.isLiteralNode(node)) { this.obfuscateLiteralPropertyKey(node); @@ -53,7 +48,7 @@ export class ObjectExpressionObfuscator extends NodeObfuscator { /** * @param node */ - private obfuscateLiteralPropertyKey (node: ILiteralNode): void { + private obfuscateLiteralPropertyKey (node: ESTree.Literal): void { if (typeof node.value === 'string' && !node['x-verbatim-property']) { node['x-verbatim-property'] = { content : Utils.stringToUnicode(node.value), @@ -65,9 +60,9 @@ export class ObjectExpressionObfuscator extends NodeObfuscator { /** * @param node */ - private obfuscateIdentifierPropertyKey (node: IIdentifierNode): void { + private obfuscateIdentifierPropertyKey (node: ESTree.Identifier): void { let nodeValue: string = node.name, - literalNode: ILiteralNode = { + literalNode: ESTree.Literal = { raw: `'${nodeValue}'`, 'x-verbatim-property': { content : Utils.stringToUnicode(nodeValue), diff --git a/src/node-obfuscators/VariableDeclarationObfuscator.ts b/src/node-obfuscators/VariableDeclarationObfuscator.ts index 441a540f..3ed28142 100644 --- a/src/node-obfuscators/VariableDeclarationObfuscator.ts +++ b/src/node-obfuscators/VariableDeclarationObfuscator.ts @@ -1,13 +1,15 @@ import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; -import { INode } from "../interfaces/nodes/INode"; -import { IVariableDeclarationNode } from "../interfaces/nodes/IVariableDeclarationNode"; -import { IVariableDeclaratorNode } from "../interfaces/nodes/IVariableDeclaratorNode"; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; +import { IOptions } from '../interfaces/IOptions'; -import { NodeType } from "../enums/NodeType"; +import { NodeType } from '../enums/NodeType'; -import { NodeObfuscator } from './NodeObfuscator'; -import { NodeUtils } from "../NodeUtils"; +import { AbstractNodeObfuscator } from './AbstractNodeObfuscator'; +import { IdentifierReplacer } from './replacers/IdentifierReplacer'; +import { Nodes } from '../Nodes'; +import { NodeUtils } from '../NodeUtils'; /** * replaces: @@ -19,17 +21,27 @@ import { NodeUtils } from "../NodeUtils"; * _0x12d45f++; * */ -export class VariableDeclarationObfuscator extends NodeObfuscator { +export class VariableDeclarationObfuscator extends AbstractNodeObfuscator { /** - * @type {Map} + * @type {IdentifierReplacer} */ - private variableNames: Map = new Map (); + private identifierReplacer: IdentifierReplacer; + + /** + * @param nodes + * @param options + */ + constructor(nodes: Map , options: IOptions) { + super(nodes, options); + + this.identifierReplacer = new IdentifierReplacer(this.nodes, this.options); + } /** * @param variableDeclarationNode * @param parentNode */ - public obfuscateNode (variableDeclarationNode: IVariableDeclarationNode, parentNode: INode): void { + public obfuscateNode (variableDeclarationNode: ESTree.VariableDeclaration, parentNode: ESTree.Node): void { if (parentNode.type === NodeType.Program) { return; } @@ -41,11 +53,11 @@ export class VariableDeclarationObfuscator extends NodeObfuscator { /** * @param variableDeclarationNode */ - private storeVariableNames (variableDeclarationNode: IVariableDeclarationNode): void { + private storeVariableNames (variableDeclarationNode: ESTree.VariableDeclaration): void { variableDeclarationNode.declarations - .forEach((declarationNode: IVariableDeclaratorNode) => { - estraverse.traverse(declarationNode.id, { - enter: (node: INode): any => this.storeIdentifiersNames(node, this.variableNames) + .forEach((declarationNode: ESTree.VariableDeclarator) => { + NodeUtils.typedReplace(declarationNode.id, NodeType.Identifier, { + enter: (node: ESTree.Identifier) => this.identifierReplacer.storeNames(node.name) }); }); } @@ -54,15 +66,15 @@ export class VariableDeclarationObfuscator extends NodeObfuscator { * @param variableDeclarationNode * @param variableParentNode */ - private replaceVariableNames (variableDeclarationNode: IVariableDeclarationNode, variableParentNode: INode): void { - let scopeNode: INode = variableDeclarationNode.kind === 'var' ? NodeUtils.getBlockScopeOfNode( + private replaceVariableNames (variableDeclarationNode: ESTree.VariableDeclaration, variableParentNode: ESTree.Node): void { + let scopeNode: ESTree.Node = variableDeclarationNode.kind === 'var' ? NodeUtils.getBlockScopeOfNode( variableDeclarationNode ) : variableParentNode; estraverse.replace(scopeNode, { - enter: (node: INode, parentNode: INode): any => { - if (!node.obfuscated) { - this.replaceIdentifiersWithRandomNames(node, parentNode, this.variableNames); + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { + if (!node.obfuscated && Nodes.isReplaceableIdentifierNode(node, parentNode)) { + node.name = this.identifierReplacer.replace(node.name); } } }); diff --git a/src/node-obfuscators/replacers/AbstractReplacer.ts b/src/node-obfuscators/replacers/AbstractReplacer.ts new file mode 100644 index 00000000..09bc1980 --- /dev/null +++ b/src/node-obfuscators/replacers/AbstractReplacer.ts @@ -0,0 +1,31 @@ +import { ICustomNode } from '../../interfaces/custom-nodes/ICustomNode'; +import { IOptions } from '../../interfaces/IOptions'; +import { IReplacer } from '../../interfaces/IReplacer'; + +export abstract class AbstractReplacer implements IReplacer { + /** + * @type Map + */ + protected nodes: Map ; + + /** + * @type {IOptions} + */ + protected options : IOptions; + + /** + * @param nodes + * @param options + */ + constructor (nodes: Map , options: IOptions) { + this.nodes = nodes; + this.options = options; + } + + /** + * @param nodeValue + * @param namesMap + * @returns {string} + */ + public abstract replace (nodeValue: any, namesMap?: Map ): string; +} diff --git a/src/node-obfuscators/replacers/BooleanLiteralReplacer.ts b/src/node-obfuscators/replacers/BooleanLiteralReplacer.ts new file mode 100644 index 00000000..30d98218 --- /dev/null +++ b/src/node-obfuscators/replacers/BooleanLiteralReplacer.ts @@ -0,0 +1,13 @@ +import { JSFuck } from '../../enums/JSFuck'; + +import { AbstractReplacer } from './AbstractReplacer'; + +export class BooleanLiteralReplacer extends AbstractReplacer { + /** + * @param nodeValue + * @returns {string} + */ + public replace (nodeValue: boolean): string { + return nodeValue ? JSFuck.True : JSFuck.False; + } +} diff --git a/src/node-obfuscators/replacers/IdentifierReplacer.ts b/src/node-obfuscators/replacers/IdentifierReplacer.ts new file mode 100644 index 00000000..3cf97ade --- /dev/null +++ b/src/node-obfuscators/replacers/IdentifierReplacer.ts @@ -0,0 +1,46 @@ +import { AbstractReplacer } from './AbstractReplacer'; +import { Utils } from '../../Utils'; + +export class IdentifierReplacer extends AbstractReplacer { + /** + * @type {Map} + */ + private namesMap: Map = new Map(); + + /** + * @param nodeValue + * @returns {string} + */ + public replace (nodeValue: string): string { + const obfuscatedIdentifierName: string|undefined = this.namesMap.get(nodeValue); + + if (!obfuscatedIdentifierName) { + return nodeValue; + } + + return obfuscatedIdentifierName; + } + + /** + * Store all identifiers names as keys in given `namesMap` with random names as value. + * Reserved names will be ignored. + * + * @param nodeName + */ + public storeNames (nodeName: string): void { + if (!this.isReservedName(nodeName)) { + this.namesMap.set(nodeName, Utils.getRandomVariableName()); + } + } + + /** + * @param name + * @returns {boolean} + */ + private isReservedName (name: string): boolean { + return this.options.reservedNames + .some((reservedName: string) => { + return new RegExp(reservedName, 'g').test(name); + }); + } +} diff --git a/src/node-obfuscators/replacers/NumberLiteralReplacer.ts b/src/node-obfuscators/replacers/NumberLiteralReplacer.ts new file mode 100644 index 00000000..3daa2ae4 --- /dev/null +++ b/src/node-obfuscators/replacers/NumberLiteralReplacer.ts @@ -0,0 +1,18 @@ +import { AbstractReplacer } from './AbstractReplacer'; +import { Utils } from '../../Utils'; + +export class NumberLiteralReplacer extends AbstractReplacer { + /** + * @param nodeValue + * @returns {string} + */ + public replace (nodeValue: number): string { + const prefix: string = '0x'; + + if (!Utils.isInteger(nodeValue)) { + return String(nodeValue); + } + + return `${prefix}${Utils.decToHex(nodeValue)}`; + } +} diff --git a/src/node-obfuscators/replacers/StringLiteralReplacer.ts b/src/node-obfuscators/replacers/StringLiteralReplacer.ts new file mode 100644 index 00000000..320a248c --- /dev/null +++ b/src/node-obfuscators/replacers/StringLiteralReplacer.ts @@ -0,0 +1,95 @@ +import { TUnicodeArrayCallsWrapper } from '../../types/custom-nodes/TUnicodeArrayCallsWrapper'; +import { TUnicodeArrayNode } from '../../types/custom-nodes/TUnicodeArrayNode'; + +import { UnicodeArrayEncoding } from '../../enums/UnicodeArrayEncoding'; + +import { AbstractReplacer } from './AbstractReplacer'; +import { NumberLiteralReplacer } from './NumberLiteralReplacer'; +import { UnicodeArray } from '../../UnicodeArray'; +import { Utils } from '../../Utils'; + +export class StringLiteralReplacer extends AbstractReplacer { + /** + * @type {number} + */ + private static minimumLengthForUnicodeArray: number = 3; + + /** + * @type {string[]} + */ + private static rc4Keys: string[] = Utils.getRandomGenerator() + .n(() => Utils.getRandomGenerator().string({length: 4}), 50); + + /** + * @param nodeValue + * @returns {string} + */ + public replace (nodeValue: string): string { + const replaceWithUnicodeArrayFlag: boolean = ( + nodeValue.length >= StringLiteralReplacer.minimumLengthForUnicodeArray + && Math.random() <= this.options.unicodeArrayThreshold + ); + + if (this.options.unicodeArray && replaceWithUnicodeArrayFlag) { + return this.replaceStringLiteralWithUnicodeArrayCall(nodeValue); + } + + return Utils.stringToUnicode(nodeValue); + } + + /** + * @param value + * @returns {string} + */ + private replaceStringLiteralWithUnicodeArrayCall (value: string): string { + const unicodeArrayNode: TUnicodeArrayNode = this.nodes.get('unicodeArrayNode'); + + if (!unicodeArrayNode) { + throw new ReferenceError('`unicodeArrayNode` node is not found in Map with custom nodes.'); + } + + let rc4Key: string = ''; + + switch (this.options.unicodeArrayEncoding) { + case UnicodeArrayEncoding.base64: + value = Utils.btoa(value); + + break; + + case UnicodeArrayEncoding.rc4: + rc4Key = Utils.getRandomGenerator().pickone(StringLiteralReplacer.rc4Keys); + value = Utils.btoa(Utils.rc4(value, rc4Key)); + + break; + } + + value = Utils.stringToUnicode(value); + + let unicodeArray: UnicodeArray = unicodeArrayNode.getNodeData(), + indexOfExistingValue: number = unicodeArray.getIndexOf(value), + indexOfValue: number, + hexadecimalIndex: string; + + if (indexOfExistingValue >= 0) { + indexOfValue = indexOfExistingValue; + } else { + indexOfValue = unicodeArray.getLength(); + unicodeArrayNode.updateNodeData(value); + } + + hexadecimalIndex = new NumberLiteralReplacer(this.nodes, this.options) + .replace(indexOfValue); + + const unicodeArrayCallsWrapper: TUnicodeArrayCallsWrapper = this.nodes.get('unicodeArrayCallsWrapper'); + + if (!unicodeArrayCallsWrapper) { + throw new ReferenceError('`unicodeArrayCallsWrapper` node is not found in Map with custom nodes.'); + } + + if (this.options.unicodeArrayEncoding === UnicodeArrayEncoding.rc4) { + return `${unicodeArrayCallsWrapper.getNodeIdentifier()}('${hexadecimalIndex}', ${Utils.stringToUnicode(rc4Key)})`; + } + + return `${unicodeArrayCallsWrapper.getNodeIdentifier()}('${hexadecimalIndex}')`; + } +} diff --git a/src/options/Options.ts b/src/options/Options.ts index 36110219..dd62229b 100644 --- a/src/options/Options.ts +++ b/src/options/Options.ts @@ -1,14 +1,29 @@ -import { IsBoolean, IsIn, IsNumber, IsString, Min, Max, validateSync, ValidationError, ValidatorOptions } from 'class-validator'; +import { + ArrayUnique, + IsBoolean, + IsArray, + IsIn, + IsNumber, + IsString, + IsUrl, + Min, + Max, + ValidateIf, + validateSync, + ValidationError, + ValidatorOptions +} from 'class-validator'; -import { IObfuscatorOptions } from "../interfaces/IObfuscatorOptions"; -import { IOptions } from "../interfaces/IOptions"; +import { IObfuscatorOptions } from '../interfaces/IObfuscatorOptions'; +import { IOptions } from '../interfaces/IOptions'; -import { TSourceMapMode } from "../types/TSourceMapMode"; +import { TSourceMapMode } from '../types/TSourceMapMode'; +import { TUnicodeArrayEncoding } from '../types/TUnicodeArrayEncoding'; -import { DEFAULT_PRESET } from "../preset-options/DefaultPreset"; +import { DEFAULT_PRESET } from '../preset-options/DefaultPreset'; -import { OptionsNormalizer } from "./OptionsNormalizer"; -import { ValidationErrorsFormatter } from "./ValidationErrorsFormatter"; +import { OptionsNormalizer } from './OptionsNormalizer'; +import { ValidationErrorsFormatter } from './ValidationErrorsFormatter'; export class Options implements IOptions { /** @@ -45,14 +60,20 @@ export class Options implements IOptions { public readonly disableConsoleOutput: boolean; /** - * @type {boolean} + * @type {string[]} */ - @IsBoolean() - public readonly encodeUnicodeLiterals: boolean; + @IsArray() + @ArrayUnique() + @IsString({ + each: true + }) + public readonly domainLock: string[]; /** * @type {string[]} */ + @IsArray() + @ArrayUnique() @IsString({ each: true }) @@ -76,6 +97,23 @@ export class Options implements IOptions { @IsBoolean() public readonly sourceMap: boolean; + /** + * @type {string} + */ + @IsString() + @ValidateIf((options: IOptions) => Boolean(options.sourceMapBaseUrl)) + @IsUrl({ + require_protocol: true, + require_valid_protocol: true + }) + public readonly sourceMapBaseUrl: string; + + /** + * @type {string} + */ + @IsString() + public readonly sourceMapFileName: string; + /** * @type {TSourceMapMode} */ @@ -88,6 +126,12 @@ export class Options implements IOptions { @IsBoolean() public readonly unicodeArray: boolean; + /** + * @type {TUnicodeArrayEncoding} + */ + @IsIn([true, false, 'base64', 'rc4']) + public readonly unicodeArrayEncoding: TUnicodeArrayEncoding; + /** * @type {number} */ @@ -96,12 +140,6 @@ export class Options implements IOptions { @Max(1) public readonly unicodeArrayThreshold: number; - /** - * @type {boolean} - */ - @IsBoolean() - public readonly wrapUnicodeArrayCalls: boolean; - /** * @param obfuscatorOptions */ diff --git a/src/options/OptionsNormalizer.ts b/src/options/OptionsNormalizer.ts index 08cc401d..bf0abcb5 100644 --- a/src/options/OptionsNormalizer.ts +++ b/src/options/OptionsNormalizer.ts @@ -1,26 +1,19 @@ -import { IObfuscatorOptions } from "../interfaces/IObfuscatorOptions"; -import { IOptions } from "../interfaces/IOptions"; +import { IObfuscatorOptions } from '../interfaces/IObfuscatorOptions'; +import { IOptions } from '../interfaces/IOptions'; -import { TOptionsNormalizerRule } from "../types/TOptionsNormalizerRule"; +import { TOptionsNormalizerRule } from '../types/TOptionsNormalizerRule'; + +import { Utils } from '../Utils'; export class OptionsNormalizer { /** * @type {IObfuscatorOptions} */ private static DISABLED_UNICODE_ARRAY_OPTIONS: IObfuscatorOptions = { - encodeUnicodeLiterals: false, rotateUnicodeArray: false, unicodeArray: false, - unicodeArrayThreshold: 0, - wrapUnicodeArrayCalls: false - }; - - /** - * @type {IObfuscatorOptions} - */ - private static ENCODE_UNICODE_LITERALS_OPTIONS: IObfuscatorOptions = { - encodeUnicodeLiterals: true, - wrapUnicodeArrayCalls: true + unicodeArrayEncoding: false, + unicodeArrayThreshold: 0 }; /** @@ -31,14 +24,24 @@ export class OptionsNormalizer { selfDefending: true }; + /** + * @type {IObfuscatorOptions} + */ + private static UNICODE_ARRAY_ENCODING_OPTIONS: IObfuscatorOptions = { + unicodeArrayEncoding: 'base64' + }; + /** * @type {TOptionsNormalizerRule[]} */ private static normalizerRules: TOptionsNormalizerRule[] = [ + OptionsNormalizer.domainLockRule, + OptionsNormalizer.selfDefendingRule, + OptionsNormalizer.sourceMapBaseUrl, + OptionsNormalizer.sourceMapFileName, OptionsNormalizer.unicodeArrayRule, + OptionsNormalizer.unicodeArrayEncodingRule, OptionsNormalizer.unicodeArrayThresholdRule, - OptionsNormalizer.encodeUnicodeLiteralsRule, - OptionsNormalizer.selfDefendingRule ]; /** @@ -48,7 +51,7 @@ export class OptionsNormalizer { public static normalizeOptions (options: IOptions): IOptions { let normalizedOptions: IOptions = Object.assign({}, options); - for (let normalizerRule of OptionsNormalizer.normalizerRules) { + for (const normalizerRule of OptionsNormalizer.normalizerRules) { normalizedOptions = normalizerRule(normalizedOptions); } @@ -59,9 +62,17 @@ export class OptionsNormalizer { * @param options * @returns {IOptions} */ - private static encodeUnicodeLiteralsRule (options: IOptions): IOptions { - if (options.unicodeArray && options.encodeUnicodeLiterals) { - Object.assign(options, OptionsNormalizer.ENCODE_UNICODE_LITERALS_OPTIONS); + private static domainLockRule (options: IOptions): IOptions { + if (options.domainLock.length) { + let normalizedDomains: string[] = []; + + for (const domain of options.domainLock) { + normalizedDomains.push(Utils.extractDomainFromUrl(domain)); + } + + Object.assign(options, { + domainLock: normalizedDomains + }); } return options; @@ -79,6 +90,50 @@ export class OptionsNormalizer { return options; } + /** + * @param options + * @returns {IOptions} + */ + private static sourceMapBaseUrl (options: IOptions): IOptions { + let sourceMapBaseUrl: string = options.sourceMapBaseUrl; + + if (!options.sourceMapFileName) { + Object.assign(options, { + sourceMapBaseUrl: '' + }); + + return options; + } + + if (sourceMapBaseUrl && !sourceMapBaseUrl.endsWith('/')) { + Object.assign(options, { + sourceMapBaseUrl: `${sourceMapBaseUrl}/` + }); + } + + return options; + } + + /** + * @param options + * @returns {IOptions} + */ + private static sourceMapFileName (options: IOptions): IOptions { + let sourceMapFileName: string = options.sourceMapFileName; + + if (sourceMapFileName) { + sourceMapFileName = sourceMapFileName + .replace(/^\/+/, '') + .split('.')[0]; + + Object.assign(options, { + sourceMapFileName: `${sourceMapFileName}.js.map` + }); + } + + return options; + } + /** * @param options * @returns {IOptions} @@ -91,6 +146,18 @@ export class OptionsNormalizer { return options; } + /** + * @param options + * @returns {IOptions} + */ + private static unicodeArrayEncodingRule (options: IOptions): IOptions { + if (options.unicodeArrayEncoding === true) { + Object.assign(options, OptionsNormalizer.UNICODE_ARRAY_ENCODING_OPTIONS); + } + + return options; + } + /** * @param options * @returns {IOptions} diff --git a/src/options/ValidationErrorsFormatter.ts b/src/options/ValidationErrorsFormatter.ts index 397bd1eb..e04ef666 100644 --- a/src/options/ValidationErrorsFormatter.ts +++ b/src/options/ValidationErrorsFormatter.ts @@ -8,7 +8,7 @@ export class ValidationErrorsFormatter { public static format (validationErrors: ValidationError[]): string { let errorsArray: string[] = []; - for (let error of validationErrors) { + for (const error of validationErrors) { errorsArray.push(ValidationErrorsFormatter.formatError(error)); } @@ -23,7 +23,7 @@ export class ValidationErrorsFormatter { let errorString: string = `\`${validationError.property}\` errors:\n`, constraints: {[type: string]: string} = validationError.constraints; - for (let constraint in constraints) { + for (const constraint in constraints) { if (!constraints.hasOwnProperty(constraint)) { continue; } diff --git a/src/preset-options/DefaultPreset.ts b/src/preset-options/DefaultPreset.ts index 1e91a707..993e852a 100644 --- a/src/preset-options/DefaultPreset.ts +++ b/src/preset-options/DefaultPreset.ts @@ -1,19 +1,21 @@ -import { IObfuscatorOptions } from "../interfaces/IObfuscatorOptions"; +import { IObfuscatorOptions } from '../interfaces/IObfuscatorOptions'; -import { SourceMapMode } from "../enums/SourceMapMode"; +import { SourceMapMode } from '../enums/SourceMapMode'; export const DEFAULT_PRESET: IObfuscatorOptions = Object.freeze({ compact: true, debugProtection: false, debugProtectionInterval: false, disableConsoleOutput: true, - encodeUnicodeLiterals: false, + domainLock: [], reservedNames: [], rotateUnicodeArray: true, selfDefending: true, sourceMap: false, + sourceMapBaseUrl: '', + sourceMapFileName: '', sourceMapMode: SourceMapMode.Separate, unicodeArray: true, - unicodeArrayThreshold: 0.8, - wrapUnicodeArrayCalls: true + unicodeArrayEncoding: false, + unicodeArrayThreshold: 0.8 }); diff --git a/src/preset-options/NoCustomNodesPreset.ts b/src/preset-options/NoCustomNodesPreset.ts index 2765a04f..7be16e3e 100644 --- a/src/preset-options/NoCustomNodesPreset.ts +++ b/src/preset-options/NoCustomNodesPreset.ts @@ -1,19 +1,21 @@ -import { IObfuscatorOptions } from "../interfaces/IObfuscatorOptions"; +import { IObfuscatorOptions } from '../interfaces/IObfuscatorOptions'; -import { SourceMapMode } from "../enums/SourceMapMode"; +import { SourceMapMode } from '../enums/SourceMapMode'; export const NO_CUSTOM_NODES_PRESET: IObfuscatorOptions = Object.freeze({ compact: true, debugProtection: false, debugProtectionInterval: false, disableConsoleOutput: false, - encodeUnicodeLiterals: false, + domainLock: [], reservedNames: [], rotateUnicodeArray: false, selfDefending: false, sourceMap: false, + sourceMapBaseUrl: '', + sourceMapFileName: '', sourceMapMode: SourceMapMode.Separate, unicodeArray: false, - unicodeArrayThreshold: 0, - wrapUnicodeArrayCalls: false + unicodeArrayEncoding: false, + unicodeArrayThreshold: 0 }); diff --git a/src/stack-trace-analyzer/StackTraceAnalyzer.ts b/src/stack-trace-analyzer/StackTraceAnalyzer.ts new file mode 100644 index 00000000..c626161a --- /dev/null +++ b/src/stack-trace-analyzer/StackTraceAnalyzer.ts @@ -0,0 +1,157 @@ +import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; + +import { TCalleeDataExtractor } from '../types/TCalleeDataExtractor'; + +import { ICalleeData } from '../interfaces/stack-trace-analyzer/ICalleeData'; +import { IStackTraceAnalyzer } from '../interfaces/stack-trace-analyzer/IStackTraceAnalyzer'; +import { IStackTraceData } from '../interfaces/stack-trace-analyzer/IStackTraceData'; + +import { NodeType } from '../enums/NodeType'; + +import { FunctionDeclarationCalleeDataExtractor } from './callee-data-extractors/FunctionDeclarationCalleeDataExtractor'; +import { FunctionExpressionCalleeDataExtractor } from './callee-data-extractors/FunctionExpressionCalleeDataExtractor'; +import { ObjectExpressionCalleeDataExtractor } from './callee-data-extractors/ObjectExpressionCalleeDataExtractor'; + +import { Nodes } from '../Nodes'; +import { NodeUtils } from '../NodeUtils'; + +/** + * This class generates a data with code stack trace functions calls + * + * For example: + * + * function Foo () { + * var baz = function () { + * + * } + * + * baz(); + * } + * + * foo(); + * + * Will generate a structure like: + * + * [ + * { + * callee: FOO_FUNCTION_NODE + * name: 'Foo', + * trace: [ + * { + * callee: BAZ_FUNCTION_NODE, + * name: 'baz, + * trace: [] + * } + * ] + * } + * ] + */ +export class StackTraceAnalyzer implements IStackTraceAnalyzer { + /** + * @type {number} + */ + private static limitThresholdActivationLength: number = 25; + + /** + * @type {number} + */ + private static limitThreshold: number = 0.002; + + /** + * @type {ESTree.Node[]} + */ + private blockScopeBody: ESTree.Node[]; + + /** + * @type {Map} + */ + private calleeDataExtractors: Map = new Map ([ + [NodeType.FunctionDeclaration, FunctionDeclarationCalleeDataExtractor], + [NodeType.FunctionExpression, FunctionExpressionCalleeDataExtractor], + [NodeType.ObjectExpression, ObjectExpressionCalleeDataExtractor] + ]); + + /** + * @param blockScopeBody + */ + constructor (blockScopeBody: ESTree.Node[]) { + this.blockScopeBody = blockScopeBody; + } + + /** + * @param blockScopeBodyLength + * @returns {number} + */ + public static getLimitIndex (blockScopeBodyLength: number): number { + const lastIndex: number = blockScopeBodyLength - 1; + const limitThresholdActivationIndex: number = StackTraceAnalyzer.limitThresholdActivationLength - 1; + + let limitIndex: number = lastIndex; + + if (lastIndex > limitThresholdActivationIndex) { + limitIndex = Math.round( + limitThresholdActivationIndex + (lastIndex * StackTraceAnalyzer.limitThreshold) + ); + + if (limitIndex > lastIndex) { + limitIndex = lastIndex; + } + } + + return limitIndex; + } + + /** + * @returns {IStackTraceData[]} + */ + public analyze (): IStackTraceData[] { + return this.analyzeRecursive(this.blockScopeBody); + } + + /** + * @param blockScopeBody + * @returns {IStackTraceData[]} + */ + private analyzeRecursive (blockScopeBody: ESTree.Node[]): IStackTraceData[] { + const limitIndex: number = StackTraceAnalyzer.getLimitIndex(blockScopeBody.length); + const stackTraceData: IStackTraceData[] = []; + + for ( + let index: number = 0, blockScopeBodyLength: number = blockScopeBody.length; + index < blockScopeBodyLength; + index++ + ) { + let rootNode: ESTree.Node = blockScopeBody[index]; + + if (index > limitIndex) { + break; + } + + estraverse.traverse(rootNode, { + enter: (node: ESTree.Node): any => { + if (!Nodes.isCallExpressionNode(node) || rootNode.parentNode !== NodeUtils.getBlockScopeOfNode(node)) { + return; + } + + this.calleeDataExtractors.forEach((calleeDataExtractor: TCalleeDataExtractor) => { + const calleeData: ICalleeData|null = new calleeDataExtractor( + blockScopeBody, + node.callee + ).extract(); + + if (!calleeData) { + return; + } + + stackTraceData.push(Object.assign({}, calleeData, { + stackTrace: this.analyzeRecursive(calleeData.callee.body) + })); + }); + } + }); + } + + return stackTraceData; + } +} diff --git a/src/stack-trace-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts b/src/stack-trace-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts new file mode 100644 index 00000000..3b5ee1d4 --- /dev/null +++ b/src/stack-trace-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts @@ -0,0 +1,73 @@ +import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; + +import { ICalleeData } from '../../interfaces/stack-trace-analyzer/ICalleeData'; +import { ICalleeDataExtractor } from '../../interfaces/stack-trace-analyzer/ICalleeDataExtractor'; + +import { Nodes } from '../../Nodes'; +import { NodeUtils } from '../../NodeUtils'; + +export class FunctionDeclarationCalleeDataExtractor implements ICalleeDataExtractor { + /** + * @type {ESTree.Node[]} + */ + private blockScopeBody: ESTree.Node[]; + + /** + * @type {ESTree.Identifier} + */ + private callee: ESTree.Identifier; + + /** + * @param blockScopeBody + * @param callee + */ + constructor (blockScopeBody: ESTree.Node[], callee: ESTree.Identifier) { + this.blockScopeBody = blockScopeBody; + this.callee = callee; + } + + /** + * @returns {ICalleeData|null} + */ + public extract (): ICalleeData|null { + let calleeBlockStatement: ESTree.BlockStatement|null = null; + + if (Nodes.isIdentifierNode(this.callee)) { + calleeBlockStatement = this.getCalleeBlockStatement( + NodeUtils.getBlockScopeOfNode(this.blockScopeBody[0]), + this.callee.name + ); + } + + if (!calleeBlockStatement) { + return null; + } + + return { + callee: calleeBlockStatement, + name: this.callee.name + }; + } + + /** + * @param node + * @param name + * @returns {ESTree.BlockStatement|null} + */ + private getCalleeBlockStatement (node: ESTree.Node, name: string): ESTree.BlockStatement|null { + let calleeBlockStatement: ESTree.BlockStatement|null = null; + + estraverse.traverse(node, { + enter: (node: ESTree.Node): any => { + if (Nodes.isFunctionDeclarationNode(node) && node.id.name === name) { + calleeBlockStatement = node.body; + + return estraverse.VisitorOption.Break; + } + } + }); + + return calleeBlockStatement; + } +} diff --git a/src/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts b/src/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts new file mode 100644 index 00000000..90c683b8 --- /dev/null +++ b/src/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts @@ -0,0 +1,82 @@ +import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; + +import { ICalleeData } from '../../interfaces/stack-trace-analyzer/ICalleeData'; +import { ICalleeDataExtractor } from '../../interfaces/stack-trace-analyzer/ICalleeDataExtractor'; + +import { Nodes } from '../../Nodes'; +import { NodeUtils } from '../../NodeUtils'; + +export class FunctionExpressionCalleeDataExtractor implements ICalleeDataExtractor { + /** + * @type {ESTree.Node[]} + */ + private blockScopeBody: ESTree.Node[]; + + /** + * @type {ESTree.Identifier} + */ + private callee: ESTree.Identifier; + + /** + * @param blockScopeBody + * @param callee + */ + constructor (blockScopeBody: ESTree.Node[], callee: ESTree.Identifier) { + this.blockScopeBody = blockScopeBody; + this.callee = callee; + } + + /** + * @returns {ICalleeData|null} + */ + public extract (): ICalleeData|null { + let calleeBlockStatement: ESTree.BlockStatement|null = null; + + if (Nodes.isIdentifierNode(this.callee)) { + calleeBlockStatement = this.getCalleeBlockStatement( + NodeUtils.getBlockScopeOfNode(this.blockScopeBody[0]), + this.callee.name + ); + } + + if (Nodes.isFunctionExpressionNode(this.callee)) { + calleeBlockStatement = this.callee.body; + } + + if (!calleeBlockStatement) { + return null; + } + + return { + callee: calleeBlockStatement, + name: this.callee.name || null + }; + } + + /** + * @param node + * @param name + * @returns {ESTree.BlockStatement|null} + */ + private getCalleeBlockStatement (node: ESTree.Node, name: string): ESTree.BlockStatement|null { + let calleeBlockStatement: ESTree.BlockStatement|null = null; + + estraverse.traverse(node, { + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { + if ( + Nodes.isFunctionExpressionNode(node) && + Nodes.isVariableDeclaratorNode(parentNode) && + Nodes.isIdentifierNode(parentNode.id) && + parentNode.id.name === name + ) { + calleeBlockStatement = node.body; + + return estraverse.VisitorOption.Break; + } + } + }); + + return calleeBlockStatement; + } +} diff --git a/src/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts b/src/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts new file mode 100644 index 00000000..a7f41974 --- /dev/null +++ b/src/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts @@ -0,0 +1,163 @@ +import * as estraverse from 'estraverse'; +import * as ESTree from 'estree'; + +import { ICalleeData } from '../../interfaces/stack-trace-analyzer/ICalleeData'; +import { ICalleeDataExtractor } from '../../interfaces/stack-trace-analyzer/ICalleeDataExtractor'; + +import { Nodes } from '../../Nodes'; +import { NodeUtils } from '../../NodeUtils'; + +export class ObjectExpressionCalleeDataExtractor implements ICalleeDataExtractor { + /** + * @type {ESTree.Node[]} + */ + private blockScopeBody: ESTree.Node[]; + + /** + * @type {ESTree.MemberExpression} + */ + private callee: ESTree.MemberExpression; + + /** + * @type {Array} + */ + private objectMembersCallsChain: string[] = []; + + /** + * @param blockScopeBody + * @param callee + */ + constructor (blockScopeBody: ESTree.Node[], callee: ESTree.MemberExpression) { + this.blockScopeBody = blockScopeBody; + this.callee = callee; + } + + /** + * @returns {ICalleeData|null} + */ + public extract (): ICalleeData|null { + let calleeBlockStatement: ESTree.BlockStatement|null = null, + functionExpressionName: string|null = null; + + if (Nodes.isMemberExpressionNode(this.callee)) { + this.objectMembersCallsChain = this.createObjectMembersCallsChain(this.objectMembersCallsChain, this.callee); + + if (!this.objectMembersCallsChain.length) { + return null; + } + + functionExpressionName = this.objectMembersCallsChain[this.objectMembersCallsChain.length - 1]; + + calleeBlockStatement = this.getCalleeBlockStatement( + NodeUtils.getBlockScopeOfNode(this.blockScopeBody[0]), + this.objectMembersCallsChain + ); + } + + if (!calleeBlockStatement) { + return null; + } + + return { + callee: calleeBlockStatement, + name: functionExpressionName + }; + } + + /** + * Creates array with MemberExpression calls chain. + * + * Example: object.foo.bar(); // ['object', 'foo', 'bar'] + * + * @param currentChain + * @param memberExpression + * @returns {string[]} + */ + private createObjectMembersCallsChain (currentChain: string[], memberExpression: ESTree.MemberExpression): string[] { + if (Nodes.isIdentifierNode(memberExpression.property)) { + currentChain.unshift(memberExpression.property.name); + } else if (Nodes.isLiteralNode(memberExpression.property) && typeof memberExpression.property.value === 'string') { + currentChain.unshift(memberExpression.property.value); + } else { + return currentChain; + } + + if (Nodes.isMemberExpressionNode(memberExpression.object)) { + return this.createObjectMembersCallsChain(currentChain, memberExpression.object); + } + + if (Nodes.isIdentifierNode(memberExpression.object)) { + currentChain.unshift(memberExpression.object.name); + } + + return currentChain; + } + + /** + * @param node + * @param objectMembersCallsChain + * @returns {ESTree.BlockStatement|null} + */ + private getCalleeBlockStatement (node: ESTree.Node, objectMembersCallsChain: string[]): ESTree.BlockStatement|null { + const objectName: string = objectMembersCallsChain.shift(); + + let calleeBlockStatement: ESTree.BlockStatement|null = null; + + estraverse.traverse(node, { + enter: (node: ESTree.Node, parentNode: ESTree.Node): any => { + if ( + Nodes.isVariableDeclaratorNode(node) && + Nodes.isIdentifierNode(node.id) && + node.init && + Nodes.isObjectExpressionNode(node.init) && + node.id.name === objectName + ) { + calleeBlockStatement = this.findCalleeBlockStatement(node.init.properties, objectMembersCallsChain); + + return estraverse.VisitorOption.Break; + } + } + }); + + return calleeBlockStatement; + } + + /** + * @param objectExpressionProperties + * @param objectMembersCallsChain + * @returns {ESTree.BlockStatement|null} + */ + private findCalleeBlockStatement ( + objectExpressionProperties: ESTree.Property[], + objectMembersCallsChain: string[] + ): ESTree.BlockStatement|null { + const nextItemInCallsChain: string|undefined = objectMembersCallsChain.shift(); + + if (!nextItemInCallsChain) { + return null; + } + + for (const propertyNode of objectExpressionProperties) { + const isTargetPropertyNodeWithIdentifierKey: boolean = + Nodes.isIdentifierNode(propertyNode.key) && propertyNode.key.name === nextItemInCallsChain; + const isTargetPropertyNodeWithLiteralKey: boolean = + Nodes.isLiteralNode(propertyNode.key) && + Boolean(propertyNode.key.value) && + propertyNode.key.value === nextItemInCallsChain; + + if (!isTargetPropertyNodeWithIdentifierKey && !isTargetPropertyNodeWithLiteralKey) { + continue; + } + + if (Nodes.isObjectExpressionNode(propertyNode.value)) { + return this.findCalleeBlockStatement(propertyNode.value.properties, objectMembersCallsChain); + } + + if (Nodes.isFunctionExpressionNode(propertyNode.value)) { + return propertyNode.value.body; + } + } + + return null; + } +} diff --git a/src/templates/custom-nodes/Rc4Template.ts b/src/templates/custom-nodes/Rc4Template.ts new file mode 100644 index 00000000..bb20240e --- /dev/null +++ b/src/templates/custom-nodes/Rc4Template.ts @@ -0,0 +1,43 @@ +/** + * @returns {string} + */ +export function Rc4Template (): string { + return ` + var rc4 = function (str, key) { + var s = [], j = 0, x, res = '', newStr = ''; + + str = atob(str); + + for (var k = 0, length = str.length; k < length; k++) { + newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2); + } + + str = decodeURIComponent(newStr); + + for (var i = 0; i < 256; i++) { + s[i] = i; + } + + for (i = 0; i < 256; i++) { + j = (j + s[i] + key.charCodeAt(i % key.length)) % 256; + x = s[i]; + s[i] = s[j]; + s[j] = x; + } + + i = 0; + j = 0; + + for (var y = 0; y < str.length; y++) { + i = (i + 1) % 256; + j = (j + s[i]) % 256; + x = s[i]; + s[i] = s[j]; + s[j] = x; + res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]); + } + + return res; + } + `; +} diff --git a/src/templates/custom-nodes/SingleNodeCallControllerTemplate.ts b/src/templates/custom-nodes/SingleNodeCallControllerTemplate.ts new file mode 100644 index 00000000..ec6ff362 --- /dev/null +++ b/src/templates/custom-nodes/SingleNodeCallControllerTemplate.ts @@ -0,0 +1,24 @@ +/** + * @returns {string} + */ +export function SingleNodeCallControllerTemplate (): string { + return ` + var {singleNodeCallControllerFunctionName} = (function(){ + var firstCall = true; + + return function (context, fn){ + var rfn = firstCall ? function(){ + if(fn){ + var res = fn.apply(context, arguments); + fn = null; + return res; + } + } : function(){} + + firstCall = false; + + return rfn; + } + })(); + `; +} diff --git a/src/templates/custom-nodes/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate.ts b/src/templates/custom-nodes/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate.ts index 93d1b9fc..4819f8ad 100644 --- a/src/templates/custom-nodes/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate.ts +++ b/src/templates/custom-nodes/console-output-nodes/console-output-disable-expression-node/ConsoleOutputDisableExpressionTemplate.ts @@ -3,17 +3,18 @@ */ export function ConsoleOutputDisableExpressionTemplate (): string { return ` - (function () { - var _ = '(\u0004\u0006\u0003\u0005[]' + '["filter"]["\u0007tructor"]' + '("return this")()' + '.' + '\u0003;\u0006\u0002\u0005\u0004};' + '_\u0003.log\u0001.in' + 'fo\u0001.' + 'war' + 'n\u0001.er' + 'r' + 'or\u0001})();' + '\u0001\u0005_\u0002;' + '_\u0003\u0002function' + '\u0003\u0007ole\u0004\u0002 ()' + '{\u0005 = \u0006var ' + '_\u0007cons', - Y, - $; + var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () { + var getGlobal = Function('return typeof self !== "undefined"' + ' ? self : ' + 'typeof window !== "undefined"' + ' ? window : ' + 'typeof global !== "undefined"' + ' ? global : ' + '[]["filter"]["constructor"]("return this")()'); - for (Y in $ = "\u0007\u0006\u0005\u0004\u0003\u0002\u0001") { - var arr = _.split($[Y]); - _ = arr.join(arr.pop()); - } - - []["filter"]["constructor"](_)(); - })() + var func = Function('for ' + '(;;)' + ' {}'); + var that = getGlobal(); + + that.console.log = func; + that.console.error = func; + that.console.warn = func; + that.console.info = func; + }); + + {consoleLogDisableFunctionName}(); `; } diff --git a/src/templates/custom-nodes/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate.ts b/src/templates/custom-nodes/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate.ts index 8bf516f7..4a8627a3 100644 --- a/src/templates/custom-nodes/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate.ts +++ b/src/templates/custom-nodes/debug-protection-nodes/debug-protection-function-node/DebugProtectionFunctionTemplate.ts @@ -1,4 +1,4 @@ -import { Utils } from "../../../../Utils"; +import { Utils } from '../../../../Utils'; /** * @returns {string} diff --git a/src/templates/custom-nodes/domain-lock-nodes/domain-lock-node/DomainLockNodeTemplate.ts b/src/templates/custom-nodes/domain-lock-nodes/domain-lock-node/DomainLockNodeTemplate.ts new file mode 100644 index 00000000..64228bd6 --- /dev/null +++ b/src/templates/custom-nodes/domain-lock-nodes/domain-lock-node/DomainLockNodeTemplate.ts @@ -0,0 +1,76 @@ +/** + * @returns {string} + */ +export function DomainLockNodeTemplate (): string { + return ` + var {domainLockFunctionName} = {singleNodeCallControllerFunctionName}(this, function () { + var getGlobal = Function('return typeof self !== "undefined"' + ' ? self : ' + 'typeof window !== "undefined"' + ' ? window : ' + 'typeof global !== "undefined"' + ' ? global : ' + '[]["filter"]["constructor"]("return this")()'); + + var func = function () { + return { + key: 'item', + value: 'attribute', + getAttribute: function () { + getGlobal()['eval']('while(true){}')(); + }() + }; + }; + + var regExp = new RegExp("[{diff}]", "g"); + var domains = "{domains}".replace(regExp, "").split(";"); + var eval = []["forEach"]["constructor"]; + var windowObject = eval("return this")(); + var document; + var domain; + + for (var d in windowObject) { + if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) { + document = d; + + break; + } + } + + for (var d1 in windowObject[document]) { + if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) { + domain = d1; + + break; + } + } + + if ((!document && !domain) || (!windowObject[document] && !windowObject[document][domain])) { + return; + } + + var currentDomain = windowObject[document][domain]; + + var ok = false; + + for (var i = 0; i < domains.length; i++) { + var domain = domains[i]; + var position = currentDomain.length - domain.length; + var lastIndex = currentDomain.indexOf(domain, position); + var endsWith = lastIndex !== -1 && lastIndex === position; + + if (endsWith) { + if (currentDomain.length == domain.length || domain.indexOf(".") === 0) { + ok = true; + } + + break; + } + } + + if (!ok) { + data; + } else { + return; + } + + func(); + }); + + {domainLockFunctionName}(); + `; +} diff --git a/src/templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate.ts b/src/templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate.ts index 540c301e..8f9ee055 100644 --- a/src/templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate.ts +++ b/src/templates/custom-nodes/self-defending-nodes/self-defending-unicode-node/SelfDefendingTemplate.ts @@ -1,14 +1,58 @@ -import { Utils } from "../../../../Utils"; +import { Utils } from '../../../../Utils'; +/** + * SelfDefendingTemplate. Enters code in infinity loop. + * Notice, that second and third call to recursiveFunc1('indexOf') has cyrillic `е` character instead latin + * + * @returns {string} + */ export function SelfDefendingTemplate (): string { return ` - (function () { - var func = function(){return 'dev';}, + var {selfDefendingFunctionName} = {singleNodeCallControllerFunctionName}(this, function () { + var func1 = function(){return 'dev';}, func2 = function () { return 'window'; }; + + var test1 = function () { + var regExp = new RegExp(${Utils.stringToUnicode(`\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}`)}); + + return !regExp.test(func1.toString()); + }; + + var test2 = function () { + var regExp = new RegExp(${Utils.stringToUnicode(`(\\\\[x|u](\\w){2,4})+`)}); + + return regExp.test(func2.toString()); + }; + + var recursiveFunc1 = function (string) { + var i = ~-1 >> 1 + 255 % 0; + + if (string.indexOf('i' === i)) { + recursiveFunc2(string) + } + }; + + var recursiveFunc2 = function (string) { + var i = ~-4 >> 1 + 255 % 0; + + if (string.indexOf((true+"")[3]) !== i) { + recursiveFunc1(string) + } + }; + + if (!test1()) { + if (!test2()) { + recursiveFunc1('indеxOf'); + } else { + recursiveFunc1('indexOf'); + } + } else { + recursiveFunc1('indеxOf'); + } + }) - !Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})().test(func.toString()) ? Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func2.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')(); - })(); + {selfDefendingFunctionName}(); `; } diff --git a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/SelfDefendingTemplate.ts b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/SelfDefendingTemplate.ts new file mode 100644 index 00000000..d367b685 --- /dev/null +++ b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/SelfDefendingTemplate.ts @@ -0,0 +1,41 @@ +import { Utils } from '../../../../Utils'; + +/** + * @returns {string} + */ +export function SelfDefendingTemplate (): string { + return ` + var StatesClass = function (rc4Bytes) { + this.rc4Bytes = rc4Bytes; + this.states = [1, 0, 0]; + this.newState = function(){return 'newState';}; + this.firstState = ${Utils.stringToUnicode(`\\w+ *\\(\\) *{\\w+ *`)}; + this.secondState = ${Utils.stringToUnicode(`['|"].+['|"];? *}`)}; + }; + + StatesClass.prototype.checkState = function () { + var regExp = new RegExp(this.firstState + this.secondState); + + return this.runState(regExp.test(this.newState.toString()) ? --this.states[1] : --this.states[0]); + }; + + StatesClass.prototype.runState = function (stateResult) { + if (!Boolean(~stateResult)) { + return stateResult; + } + + return this.getState(this.rc4Bytes); + }; + + StatesClass.prototype.getState = function (rc4Bytes) { + for (var i = 0, len = this.states.length; i < len; i++) { + this.states.push(Math.round(Math.random())); + len = this.states.length; + } + + return rc4Bytes(this.states[0]); + }; + + new StatesClass({unicodeArrayCallsWrapperName}).checkState(); + `; +} diff --git a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayBase64DecodeNodeTemplate.ts b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayBase64DecodeNodeTemplate.ts new file mode 100644 index 00000000..e81482b3 --- /dev/null +++ b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayBase64DecodeNodeTemplate.ts @@ -0,0 +1,38 @@ +/** + * @returns {string} + */ +export function UnicodeArrayBase64DecodeNodeTemplate (): string { + return ` + if (!{unicodeArrayCallsWrapperName}.atobPolyfillAppended) { + {atobPolyfill} + + {unicodeArrayCallsWrapperName}.atobPolyfillAppended = true; + } + + if (!{unicodeArrayCallsWrapperName}.base64DecodeUnicode) { + {unicodeArrayCallsWrapperName}.base64DecodeUnicode = function (str) { + var string = atob(str); + var newStringChars = []; + + for (var i = 0, length = string.length; i < length; i++) { + newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2); + } + + return decodeURIComponent(newStringChars); + }; + } + + if (!{unicodeArrayCallsWrapperName}.data) { + {unicodeArrayCallsWrapperName}.data = {}; + } + + if (!{unicodeArrayCallsWrapperName}.data[index]) { + {selfDefendingCode} + + value = {unicodeArrayCallsWrapperName}.base64DecodeUnicode(value); + {unicodeArrayCallsWrapperName}.data[index] = value; + } else { + value = {unicodeArrayCallsWrapperName}.data[index]; + } + `; +} diff --git a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayCallsWrapperTemplate.ts b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayCallsWrapperTemplate.ts index 6fdb66fd..90bde463 100644 --- a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayCallsWrapperTemplate.ts +++ b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayCallsWrapperTemplate.ts @@ -3,8 +3,13 @@ */ export function UnicodeArrayCallsWrapperTemplate (): string { return ` - var {unicodeArrayCallsWrapperName} = function ({keyName}) { - return {unicodeArrayName}[parseInt({keyName}, 0x010)]; + var {unicodeArrayCallsWrapperName} = function (index, key) { + var index = parseInt(index, 0x10); + var value = {unicodeArrayName}[index]; + + {decodeNodeTemplate} + + return value; }; `; } diff --git a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayRC4DecodeNodeTemplate.ts b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayRC4DecodeNodeTemplate.ts new file mode 100644 index 00000000..5e3921d0 --- /dev/null +++ b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-calls-wrapper/UnicodeArrayRC4DecodeNodeTemplate.ts @@ -0,0 +1,35 @@ +/** + * @returns {string} + */ +export function UnicodeArrayRc4DecodeNodeTemplate (): string { + return ` + if (!{unicodeArrayCallsWrapperName}.atobPolyfillAppended) { + {atobPolyfill} + + {unicodeArrayCallsWrapperName}.atobPolyfillAppended = true; + } + + if (!{unicodeArrayCallsWrapperName}.rc4) { + {rc4Polyfill} + + {unicodeArrayCallsWrapperName}.rc4 = rc4; + } + + if (!{unicodeArrayCallsWrapperName}.data) { + {unicodeArrayCallsWrapperName}.data = {}; + } + + if ({unicodeArrayCallsWrapperName}.data[index] === undefined) { + if (!{unicodeArrayCallsWrapperName}.once) { + {selfDefendingCode} + + {unicodeArrayCallsWrapperName}.once = true; + } + + value = {unicodeArrayCallsWrapperName}.rc4(value, key); + {unicodeArrayCallsWrapperName}.data[index] = value; + } else { + value = {unicodeArrayCallsWrapperName}.data[index]; + } + `; +} diff --git a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/SelfDefendingTemplate.ts b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/SelfDefendingTemplate.ts deleted file mode 100644 index 059bbad9..00000000 --- a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/SelfDefendingTemplate.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Utils } from "../../../../Utils"; - -/** - * @returns {string} - */ -export function SelfDefendingTemplate (): string { - return ` - var func = function(){return 'dev';}; - - Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()['test'](func['toString']()) !== true && !{unicodeArrayName}++ ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')() : Function('a', atob(${Utils.stringToUnicode(Utils.btoa('a.call()'))}))({forLoopFunctionName}) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')(); - `; -} diff --git a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/UnicodeArrayDecodeTemplate.ts b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/UnicodeArrayDecodeTemplate.ts deleted file mode 100644 index 7c1872a1..00000000 --- a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/UnicodeArrayDecodeTemplate.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @returns {string} - */ -export function UnicodeArrayDecodeTemplate (): string { - return ` - (function () { - {atobPolyfill} - - var {forLoopFunctionName} = function () { - var array = []; - - for (var i in {unicodeArrayName}) { - array['push'](decodeURI(atob({unicodeArrayName}[i]))); - } - - {unicodeArrayName} = array; - }; - - {code} - })(); - `; -} diff --git a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-rotate-function-node/SelfDefendingTemplate.ts b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-rotate-function-node/SelfDefendingTemplate.ts index e12a9773..dd42b8ab 100644 --- a/src/templates/custom-nodes/unicode-array-nodes/unicode-array-rotate-function-node/SelfDefendingTemplate.ts +++ b/src/templates/custom-nodes/unicode-array-nodes/unicode-array-rotate-function-node/SelfDefendingTemplate.ts @@ -1,12 +1,79 @@ -import { Utils } from "../../../../Utils"; +import { Utils } from '../../../../Utils'; /** + * SelfDefendingTemplate. Enter code in infinity loop. + * * @returns {string} */ export function SelfDefendingTemplate (): string { - return `(function () { - var func = function(){return 'dev';}; - - !Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')() : Function('a', 'b', 'a(++b)')({whileFunctionName}, {timesName}) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')(); - })();`; + return ` + var selfDefendingFunc = function () { + var object = { + data: { + key: 'cookie', + value: 'timeout' + }, + setCookie: function (options, name, value, document) { + document = document || {}; + + var updatedCookie = name + "=" + value; + + var i = 0; + + for (var i = 0, len = options.length; i < len; i++) { + var propName = options[i]; + + updatedCookie += "; " + propName; + + var propValue = options[propName]; + + options.push(propValue); + len = options.length; + + if (propValue !== true) { + updatedCookie += "=" + propValue; + } + } + + document['cookie'] = updatedCookie; + }, + removeCookie: function(){return 'dev';}, + getCookie: function (document, name) { + document = document || function (value) { return value }; + var matches = document(new RegExp( + "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" + )); + + var func = function (param1, param2) { + param1(++param2); + }; + + func({whileFunctionName}, {timesName}); + + return matches ? decodeURIComponent(matches[1]) : undefined; + } + }; + + var test1 = function () { + var regExp = new RegExp(${Utils.stringToUnicode(`\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}`)}); + + return regExp.test(object.removeCookie.toString()); + }; + + object['updateCookie'] = test1; + + var cookie = ''; + var result = object['updateCookie'](); + + if (!result) { + object['setCookie'](['*'], 'counter', 1); + } else if (result) { + cookie = object['getCookie'](null, 'counter'); + } else { + object['removeCookie'](); + } + }; + + selfDefendingFunc(); + `; } diff --git a/src/types/TCalleeDataExtractor.d.ts b/src/types/TCalleeDataExtractor.d.ts new file mode 100644 index 00000000..00c8c1cd --- /dev/null +++ b/src/types/TCalleeDataExtractor.d.ts @@ -0,0 +1,5 @@ +import * as ESTree from 'estree'; + +import { ICalleeDataExtractor } from '../interfaces/stack-trace-analyzer/ICalleeDataExtractor'; + +export type TCalleeDataExtractor = (new (blockScopeBody: ESTree.Node[], callee: any) => ICalleeDataExtractor); diff --git a/src/types/TNodeGroup.d.ts b/src/types/TNodeGroup.d.ts new file mode 100644 index 00000000..b72421e2 --- /dev/null +++ b/src/types/TNodeGroup.d.ts @@ -0,0 +1,5 @@ +import { INodesGroup } from '../interfaces/INodesGroup'; +import { IOptions } from '../interfaces/IOptions'; +import { IStackTraceData } from '../interfaces/stack-trace-analyzer/IStackTraceData'; + +export type TNodeGroup = new (stackTraceData: IStackTraceData[], options: IOptions) => INodesGroup; diff --git a/src/types/TNodeObfuscator.d.ts b/src/types/TNodeObfuscator.d.ts index 31b5d370..7dc60547 100644 --- a/src/types/TNodeObfuscator.d.ts +++ b/src/types/TNodeObfuscator.d.ts @@ -1,5 +1,5 @@ -import { ICustomNode } from "../interfaces/custom-nodes/ICustomNode"; -import { INodeObfuscator } from "../interfaces/INodeObfuscator"; -import { IOptions } from "../interfaces/IOptions"; +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; +import { INodeObfuscator } from '../interfaces/INodeObfuscator'; +import { IOptions } from '../interfaces/IOptions'; -export type TNodeObfuscator = (new (nodes: Map , options: IOptions) => INodeObfuscator); +export type TNodeObfuscator = (new (nodes: Map , options: IOptions) => INodeObfuscator); diff --git a/src/types/TNodeWithBlockStatement.d.ts b/src/types/TNodeWithBlockStatement.d.ts index 12bf23d5..07a38285 100644 --- a/src/types/TNodeWithBlockStatement.d.ts +++ b/src/types/TNodeWithBlockStatement.d.ts @@ -1,4 +1,3 @@ -import { IBlockStatementNode } from "../interfaces/nodes/IBlockStatementNode"; -import { IProgramNode } from "../interfaces/nodes/IProgramNode"; +import * as ESTree from 'estree'; -export type TNodeWithBlockStatement = IBlockStatementNode|IProgramNode; +export type TNodeWithBlockStatement = ESTree.BlockStatement|ESTree.Program; diff --git a/src/types/TOptionsNormalizerRule.d.ts b/src/types/TOptionsNormalizerRule.d.ts index 1c79197a..7b5ff938 100644 --- a/src/types/TOptionsNormalizerRule.d.ts +++ b/src/types/TOptionsNormalizerRule.d.ts @@ -1,3 +1,3 @@ -import {IOptions} from "../interfaces/IOptions"; +import { IOptions } from '../interfaces/IOptions'; export type TOptionsNormalizerRule = (options: IOptions) => IOptions; diff --git a/src/types/TSourceMapMode.d.ts b/src/types/TSourceMapMode.ts similarity index 100% rename from src/types/TSourceMapMode.d.ts rename to src/types/TSourceMapMode.ts diff --git a/src/types/TStatement.d.ts b/src/types/TStatement.d.ts new file mode 100644 index 00000000..7fbf5b32 --- /dev/null +++ b/src/types/TStatement.d.ts @@ -0,0 +1,3 @@ +import * as ESTree from 'estree'; + +export type TStatement = ESTree.Statement|ESTree.ModuleDeclaration; diff --git a/src/types/TUnicodeArrayEncoding.ts b/src/types/TUnicodeArrayEncoding.ts new file mode 100644 index 00000000..e2406f9d --- /dev/null +++ b/src/types/TUnicodeArrayEncoding.ts @@ -0,0 +1 @@ +export type TUnicodeArrayEncoding = boolean|'base64'|'rc4'; diff --git a/src/types/custom-nodes/TUnicodeArrayCallsWrapper.d.ts b/src/types/custom-nodes/TUnicodeArrayCallsWrapper.d.ts index 7b08e36d..a6a677b1 100644 --- a/src/types/custom-nodes/TUnicodeArrayCallsWrapper.d.ts +++ b/src/types/custom-nodes/TUnicodeArrayCallsWrapper.d.ts @@ -1,3 +1,3 @@ -import { ICustomNodeWithIdentifier } from "../../interfaces/custom-nodes/ICustomNodeWithIdentifier"; +import { ICustomNodeWithIdentifier } from '../../interfaces/custom-nodes/ICustomNodeWithIdentifier'; export type TUnicodeArrayCallsWrapper = ICustomNodeWithIdentifier; diff --git a/src/types/custom-nodes/TUnicodeArrayNode.d.ts b/src/types/custom-nodes/TUnicodeArrayNode.d.ts index 6f241035..2827ffc3 100644 --- a/src/types/custom-nodes/TUnicodeArrayNode.d.ts +++ b/src/types/custom-nodes/TUnicodeArrayNode.d.ts @@ -1,4 +1,4 @@ -import { ICustomNodeWithData } from "../../interfaces/custom-nodes/ICustomNodeWithData"; -import { ICustomNodeWithIdentifier } from "../../interfaces/custom-nodes/ICustomNodeWithIdentifier"; +import { ICustomNodeWithData } from '../../interfaces/custom-nodes/ICustomNodeWithData'; +import { ICustomNodeWithIdentifier } from '../../interfaces/custom-nodes/ICustomNodeWithIdentifier'; export type TUnicodeArrayNode = ICustomNodeWithData & ICustomNodeWithIdentifier; diff --git a/src/types/nodes/TExpression.d.ts b/src/types/nodes/TExpression.d.ts deleted file mode 100644 index 9a7d22fa..00000000 --- a/src/types/nodes/TExpression.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IArrowFunctionExpressionNode } from "../../interfaces/nodes/IArrowFunctionExpressionNode"; -import { ICallExpressionNode } from "../../interfaces/nodes/ICallExpressionNode"; -import { IFunctionExpressionNode } from "../../interfaces/nodes/IFunctionExpressionNode"; -import { IIdentifierNode } from "../../interfaces/nodes/IIdentifierNode"; -import { ILiteralNode } from "../../interfaces/nodes/ILiteralNode"; -import { IMemberExpressionNode } from "../../interfaces/nodes/IMemberExpressionNode"; - -export type TExpression = IArrowFunctionExpressionNode | ICallExpressionNode | IFunctionExpressionNode | - IIdentifierNode | ILiteralNode | IMemberExpressionNode; diff --git a/src/types/nodes/TStatement.d.ts b/src/types/nodes/TStatement.d.ts deleted file mode 100644 index 916ba877..00000000 --- a/src/types/nodes/TStatement.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { IExpressionStatementNode } from "../../interfaces/nodes/IExpressionStatementNode"; -import { IFunctionDeclarationNode } from "../../interfaces/nodes/IFunctionDeclarationNode"; -import { IIfStatementNode } from "../../interfaces/nodes/IIfStatementNode"; -import { IVariableDeclarationNode } from "../../interfaces/nodes/IVariableDeclarationNode"; - -export type TStatement = IExpressionStatementNode | IFunctionDeclarationNode | IIfStatementNode | - IVariableDeclarationNode; diff --git a/test/dev/dev-compile-performance.ts b/test/dev/dev-compile-performance.ts new file mode 100644 index 00000000..9b75f874 --- /dev/null +++ b/test/dev/dev-compile-performance.ts @@ -0,0 +1,19 @@ +'use strict'; + +import * as fs from 'fs'; + +if (!(global)._babelPolyfill) { + require('babel-polyfill'); +} + +(function () { + const JavaScriptObfuscator: any = require("../../index"); + + let start: any = new Date(); + + JavaScriptObfuscator.obfuscate( + fs.readFileSync('test/fixtures/compile-performance.js', 'utf8') + ).getObfuscatedCode(); + + console.log(`Total time: ${new Date() - start}`); +})(); diff --git a/test/dev/dev-runtime-performance.ts b/test/dev/dev-runtime-performance.ts new file mode 100644 index 00000000..9e903b71 --- /dev/null +++ b/test/dev/dev-runtime-performance.ts @@ -0,0 +1,84 @@ +'use strict'; + +if (!(global)._babelPolyfill) { + require('babel-polyfill'); +} + +(function () { + const JavaScriptObfuscator: any = require("../../index"); + + let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( + ` + var start = new Date(); + var log = console.log; + console.log = function () {}; + + ${String(` + var result = 1, + term1 = 0, + term2 = 1, + i = 1; + while(i < 10) + { + var test = 10; + result = term1 + term2; + console.log(result); + term1 = term2; + term2 = result; + i++; + } + + console.log(test); + + var test = function (test) { + console.log(test); + + if (true) { + var test = 5 + } + + return test; + } + + console.log(test(1)); + + function test2 (abc) { + function test1 () { + console.log('inside', abc.item); + } + + console.log('тест', abc); + + var abc = {}; + + return abc.item = 15, test1(); + }; + + var regexptest = /version\\/(\\d+)/i; + console.log(regexptest); + + test2(22); + console.log(105.4); + console.log(true, false); + + var sA = 'shorthand1'; + var sB = 'shorthand2'; + + console.log({sA, sB}); + + try { + } catch (error) { + console.log(error); + } + `).repeat(1000)} + + console.log = log; + console.log(new Date() - start); + `, + { + disableConsoleOutput: false, + } + ).getObfuscatedCode(); + + console.log(eval(obfuscatedCode)); +})(); diff --git a/test/dev/test.ts b/test/dev/dev.ts similarity index 77% rename from test/dev/test.ts rename to test/dev/dev.ts index 2d9ef22d..43e738f1 100644 --- a/test/dev/test.ts +++ b/test/dev/dev.ts @@ -4,10 +4,11 @@ if (!(global)._babelPolyfill) { require('babel-polyfill'); } -const JavaScriptObfuscator: any = require("../../index"); +(function () { + const JavaScriptObfuscator: any = require("../../index"); -let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( - ` + let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( + ` (function(){ var result = 1, term1 = 0, @@ -67,11 +68,13 @@ let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( } })(); `, - { - disableConsoleOutput: false, - encodeUnicodeLiterals: true - } -).getObfuscatedCode(); + { + disableConsoleOutput: false, + unicodeArrayEncoding: 'rc4', + selfDefending: true + } + ).getObfuscatedCode(); -console.log(obfuscatedCode); -console.log(eval(obfuscatedCode)); + console.log(obfuscatedCode); + console.log(eval(obfuscatedCode)); +})(); diff --git a/test/fixtures/compile-performance.js b/test/fixtures/compile-performance.js new file mode 100644 index 00000000..bbe2fab8 --- /dev/null +++ b/test/fixtures/compile-performance.js @@ -0,0 +1,76382 @@ +/******/ (function(modules) { // webpackBootstrap + /******/ // install a JSONP callback for chunk loading + /******/ var parentJsonpFunction = window["webpackJsonp"]; + /******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { + /******/ // add "moreModules" to the modules object, + /******/ // then flag all "chunkIds" as loaded and fire callback + /******/ var moduleId, chunkId, i = 0, resolves = [], result; + /******/ for(;i < chunkIds.length; i++) { + /******/ chunkId = chunkIds[i]; + /******/ if(installedChunks[chunkId]) + /******/ resolves.push(installedChunks[chunkId][0]); + /******/ installedChunks[chunkId] = 0; + /******/ } + /******/ for(moduleId in moreModules) { + /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { + /******/ modules[moduleId] = moreModules[moduleId]; + /******/ } + /******/ } + /******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); + /******/ while(resolves.length) + /******/ resolves.shift()(); + /******/ if(executeModules) { + /******/ for(i=0; i < executeModules.length; i++) { + /******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]); + /******/ } + /******/ } + /******/ return result; + /******/ }; + + /******/ // The module cache + /******/ var installedModules = {}; + + /******/ // objects to store loaded and loading chunks + /******/ var installedChunks = { + /******/ 2: 0 + /******/ }; + + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) + /******/ return installedModules[moduleId].exports; + + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + + /******/ // Flag the module as loaded + /******/ module.l = true; + + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + + /******/ // This file contains only the entry chunk. + /******/ // The chunk loading function for additional chunks + /******/ __webpack_require__.e = function requireEnsure(chunkId) { + /******/ if(installedChunks[chunkId] === 0) + /******/ return Promise.resolve(); + + /******/ // an Promise means "currently loading". + /******/ if(installedChunks[chunkId]) { + /******/ return installedChunks[chunkId][2]; + /******/ } + /******/ // start chunk loading + /******/ var head = document.getElementsByTagName('head')[0]; + /******/ var script = document.createElement('script'); + /******/ script.type = 'text/javascript'; + /******/ script.charset = 'utf-8'; + /******/ script.async = true; + /******/ script.timeout = 120000; + + /******/ script.src = __webpack_require__.p + "js/chunks/" + ({"0":"main","1":"styles"}[chunkId]||chunkId) + "." + {"0":"32124e2749f372f2c348","1":"6bd84282ef3f94ec986f"}[chunkId] + ".js"; + /******/ var timeout = setTimeout(onScriptComplete, 120000); + /******/ script.onerror = script.onload = onScriptComplete; + /******/ function onScriptComplete() { + /******/ // avoid mem leaks in IE. + /******/ script.onerror = script.onload = null; + /******/ clearTimeout(timeout); + /******/ var chunk = installedChunks[chunkId]; + /******/ if(chunk !== 0) { + /******/ if(chunk) chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); + /******/ installedChunks[chunkId] = undefined; + /******/ } + /******/ }; + /******/ head.appendChild(script); + + /******/ var promise = new Promise(function(resolve, reject) { + /******/ installedChunks[chunkId] = [resolve, reject]; + /******/ }); + /******/ return installedChunks[chunkId][2] = promise; + /******/ }; + + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + + /******/ // identity function for calling harmory imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + + /******/ // define getter function for harmory exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ }; + + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + + /******/ // on error function for async loading + /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; + + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 964); + /******/ }) +/************************************************************************/ +/******/ ([ + /* 0 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + "use strict"; + var root_1 = __webpack_require__(27); + var toSubscriber_1 = __webpack_require__(961); + var observable_1 = __webpack_require__(173); + /** + * A representation of any set of values over any amount of time. This the most basic building block + * of RxJS. + * + * @class Observable + */ + var Observable = (function () { + /** + * @constructor + * @param {Function} subscribe the function that is called when the Observable is + * initially subscribed to. This function is given a Subscriber, to which new values + * can be `next`ed, or an `error` method can be called to raise an error, or + * `complete` can be called to notify of a successful completion. + */ + function Observable(subscribe) { + this._isScalar = false; + if (subscribe) { + this._subscribe = subscribe; + } + } + /** + * Creates a new Observable, with this Observable as the source, and the passed + * operator defined as the new observable's operator. + * @method lift + * @param {Operator} operator the operator defining the operation to take on the observable + * @return {Observable} a new observable with the Operator applied + */ + Observable.prototype.lift = function (operator) { + var observable = new Observable(); + observable.source = this; + observable.operator = operator; + return observable; + }; + /** + * Registers handlers for handling emitted values, error and completions from the observable, and + * executes the observable's subscriber function, which will take action to set up the underlying data stream + * @method subscribe + * @param {PartialObserver|Function} observerOrNext (optional) either an observer defining all functions to be called, + * or the first of three possible handlers, which is the handler for each value emitted from the observable. + * @param {Function} error (optional) a handler for a terminal event resulting from an error. If no error handler is provided, + * the error will be thrown as unhandled + * @param {Function} complete (optional) a handler for a terminal event resulting from successful completion. + * @return {ISubscription} a subscription reference to the registered handlers + */ + Observable.prototype.subscribe = function (observerOrNext, error, complete) { + var operator = this.operator; + var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete); + if (operator) { + operator.call(sink, this); + } + else { + sink.add(this._subscribe(sink)); + } + if (sink.syncErrorThrowable) { + sink.syncErrorThrowable = false; + if (sink.syncErrorThrown) { + throw sink.syncErrorValue; + } + } + return sink; + }; + /** + * @method forEach + * @param {Function} next a handler for each value emitted by the observable + * @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise + * @return {Promise} a promise that either resolves on observable completion or + * rejects with the handled error + */ + Observable.prototype.forEach = function (next, PromiseCtor) { + var _this = this; + if (!PromiseCtor) { + if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) { + PromiseCtor = root_1.root.Rx.config.Promise; + } + else if (root_1.root.Promise) { + PromiseCtor = root_1.root.Promise; + } + } + if (!PromiseCtor) { + throw new Error('no Promise impl found'); + } + return new PromiseCtor(function (resolve, reject) { + var subscription = _this.subscribe(function (value) { + if (subscription) { + // if there is a subscription, then we can surmise + // the next handling is asynchronous. Any errors thrown + // need to be rejected explicitly and unsubscribe must be + // called manually + try { + next(value); + } + catch (err) { + reject(err); + subscription.unsubscribe(); + } + } + else { + // if there is NO subscription, then we're getting a nexted + // value synchronously during subscription. We can just call it. + // If it errors, Observable's `subscribe` will ensure the + // unsubscription logic is called, then synchronously rethrow the error. + // After that, Promise will trap the error and send it + // down the rejection path. + next(value); + } + }, reject, resolve); + }); + }; + Observable.prototype._subscribe = function (subscriber) { + return this.source.subscribe(subscriber); + }; + /** + * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable + * @method Symbol.observable + * @return {Observable} this instance of the observable + */ + Observable.prototype[observable_1.$$observable] = function () { + return this; + }; + // HACK: Since TypeScript inherits static properties too, we have to + // fight against TypeScript here so Subject can have a different static create signature + /** + * Creates a new cold Observable by calling the Observable constructor + * @static true + * @owner Observable + * @method create + * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor + * @return {Observable} a new cold observable + */ + Observable.create = function (subscribe) { + return new Observable(subscribe); + }; + return Observable; + }()); + exports.Observable = Observable; +//# sourceMappingURL=Observable.js.map + + /***/ }, + /* 1 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_core__ = __webpack_require__(481); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "assertPlatform", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_29"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "destroyPlatform", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_30"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "getPlatform", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_31"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "createPlatform", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_32"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ApplicationRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_21"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "enableProdMode", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_33"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "isDevMode", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["c"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "createPlatformFactory", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_10"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "PlatformRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_34"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "APP_ID", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_35"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "PACKAGE_ROOT_URL", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["y"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "APP_BOOTSTRAP_LISTENER", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_36"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "PLATFORM_INITIALIZER", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_13"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ApplicationInitStatus", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_37"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "APP_INITIALIZER", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_38"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "DebugElement", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_39"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "DebugNode", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_40"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "asNativeElements", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_41"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "getDebugNode", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_22"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Testability", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_26"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "TestabilityRegistry", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_42"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "setTestabilityGetter", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_19"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "TRANSLATIONS", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_7"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "TRANSLATIONS_FORMAT", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["u"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "LOCALE_ID", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["t"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ApplicationModule", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_27"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "wtfCreateScope", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_43"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "wtfLeave", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_44"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "wtfStartTimeRange", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_45"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "wtfEndTimeRange", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_46"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Type", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_2"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "EventEmitter", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_14"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ErrorHandler", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_25"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationTransitionEvent", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_47"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationPlayer", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_48"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Sanitizer", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_24"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "SecurityContext", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["s"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Attribute", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_1"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ContentChild", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_49"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ContentChildren", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_50"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Query", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["F"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ViewChild", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_51"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ViewChildren", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_52"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ANALYZE_FOR_ENTRY_COMPONENTS", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["f"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Component", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["G"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Directive", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["z"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "HostBinding", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["D"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "HostListener", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["E"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Input", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["B"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Output", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["C"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Pipe", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["Q"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "OnDestroy", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["I"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AfterContentInit", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["L"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AfterViewChecked", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["O"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AfterViewInit", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["N"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "DoCheck", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["J"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "OnChanges", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["K"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AfterContentChecked", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["M"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "OnInit", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["H"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "CUSTOM_ELEMENTS_SCHEMA", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_6"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "NO_ERRORS_SCHEMA", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_5"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "NgModule", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["P"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ViewEncapsulation", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["a"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Class", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_53"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "forwardRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_28"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "resolveForwardRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["A"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Injector", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["p"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ReflectiveInjector", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_8"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ResolvedReflectiveFactory", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_54"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ReflectiveKey", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_55"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "OpaqueToken", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["v"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "NgZone", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_20"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "RenderComponentType", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["j"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Renderer", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["q"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "RootRenderer", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_23"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "COMPILER_OPTIONS", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_9"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "CompilerFactory", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_12"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ModuleWithComponentFactories", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_3"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Compiler", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_4"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ComponentFactory", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["n"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ComponentRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_56"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ComponentFactoryResolver", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["m"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ElementRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["g"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "NgModuleFactory", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["o"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "NgModuleRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_57"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "NgModuleFactoryLoader", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_58"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "getModuleFactory", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_59"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "QueryList", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["k"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "SystemJsNgModuleLoader", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_60"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "SystemJsNgModuleLoaderConfig", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_61"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "TemplateRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["l"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ViewContainerRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["h"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "EmbeddedViewRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_62"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ViewRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_63"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ChangeDetectionStrategy", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["b"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "ChangeDetectorRef", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["i"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "CollectionChangeRecord", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_64"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "DefaultIterableDiffer", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_65"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "IterableDiffers", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_15"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "KeyValueChangeRecord", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_66"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "KeyValueDiffers", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_16"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "SimpleChange", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["r"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "WrappedValue", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_17"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "platformCore", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_11"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "__core_private__", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["e"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AUTO_STYLE", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_18"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationEntryMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_67"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationStateMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_68"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationStateDeclarationMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["R"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationStateTransitionMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["S"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_69"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationKeyframesSequenceMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["U"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationStyleMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["T"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationAnimateMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["V"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationWithStepsMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["W"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationSequenceMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_70"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "AnimationGroupMetadata", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["X"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "animate", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_71"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "group", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_72"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "sequence", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_73"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "style", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_74"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "state", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_75"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "keyframes", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_76"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "transition", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_77"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "trigger", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_78"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Inject", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["x"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Optional", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["w"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Injectable", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["d"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Self", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["Z"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "SkipSelf", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["_0"]; }); + /* harmony namespace reexport (by provided) */ __webpack_require__.d(exports, "Host", function() { return __WEBPACK_IMPORTED_MODULE_0__src_core__["Y"]; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + /** + * @module + * @description + * Entry point for all public APIs of the core package. + */ + +//# sourceMappingURL=index.js.map + + /***/ }, + /* 2 */ + /***/ function(module, exports, __webpack_require__) { + + var global = __webpack_require__(11) + , core = __webpack_require__(69) + , hide = __webpack_require__(40) + , redefine = __webpack_require__(37) + , ctx = __webpack_require__(58) + , PROTOTYPE = 'prototype'; + + var $export = function(type, name, source){ + var IS_FORCED = type & $export.F + , IS_GLOBAL = type & $export.G + , IS_STATIC = type & $export.S + , IS_PROTO = type & $export.P + , IS_BIND = type & $export.B + , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] + , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) + , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}) + , key, own, out, exp; + if(IS_GLOBAL)source = name; + for(key in source){ + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + // export native or passed + out = (own ? target : source)[key]; + // bind timers to global for call from export context + exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; + // extend global + if(target)redefine(target, key, out, type & $export.U); + // export + if(exports[key] != out)hide(exports, key, exp); + if(IS_PROTO && expProto[key] != out)expProto[key] = out; + } + }; + global.core = core; +// type bitmap + $export.F = 1; // forced + $export.G = 2; // global + $export.S = 4; // static + $export.P = 8; // proto + $export.B = 16; // bind + $export.W = 32; // wrap + $export.U = 64; // safe + $export.R = 128; // real proto method for `library` + module.exports = $export; + + /***/ }, + /* 3 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var isFunction_1 = __webpack_require__(266); + var Subscription_1 = __webpack_require__(22); + var Observer_1 = __webpack_require__(695); + var rxSubscriber_1 = __webpack_require__(174); + /** + * Implements the {@link Observer} interface and extends the + * {@link Subscription} class. While the {@link Observer} is the public API for + * consuming the values of an {@link Observable}, all Observers get converted to + * a Subscriber, in order to provide Subscription-like capabilities such as + * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for + * implementing operators, but it is rarely used as a public API. + * + * @class Subscriber + */ + var Subscriber = (function (_super) { + __extends(Subscriber, _super); + /** + * @param {Observer|function(value: T): void} [destinationOrNext] A partially + * defined Observer or a `next` callback function. + * @param {function(e: ?any): void} [error] The `error` callback of an + * Observer. + * @param {function(): void} [complete] The `complete` callback of an + * Observer. + */ + function Subscriber(destinationOrNext, error, complete) { + _super.call(this); + this.syncErrorValue = null; + this.syncErrorThrown = false; + this.syncErrorThrowable = false; + this.isStopped = false; + switch (arguments.length) { + case 0: + this.destination = Observer_1.empty; + break; + case 1: + if (!destinationOrNext) { + this.destination = Observer_1.empty; + break; + } + if (typeof destinationOrNext === 'object') { + if (destinationOrNext instanceof Subscriber) { + this.destination = destinationOrNext; + this.destination.add(this); + } + else { + this.syncErrorThrowable = true; + this.destination = new SafeSubscriber(this, destinationOrNext); + } + break; + } + default: + this.syncErrorThrowable = true; + this.destination = new SafeSubscriber(this, destinationOrNext, error, complete); + break; + } + } + Subscriber.prototype[rxSubscriber_1.$$rxSubscriber] = function () { return this; }; + /** + * A static factory for a Subscriber, given a (potentially partial) definition + * of an Observer. + * @param {function(x: ?T): void} [next] The `next` callback of an Observer. + * @param {function(e: ?any): void} [error] The `error` callback of an + * Observer. + * @param {function(): void} [complete] The `complete` callback of an + * Observer. + * @return {Subscriber} A Subscriber wrapping the (partially defined) + * Observer represented by the given arguments. + */ + Subscriber.create = function (next, error, complete) { + var subscriber = new Subscriber(next, error, complete); + subscriber.syncErrorThrowable = false; + return subscriber; + }; + /** + * The {@link Observer} callback to receive notifications of type `next` from + * the Observable, with a value. The Observable may call this method 0 or more + * times. + * @param {T} [value] The `next` value. + * @return {void} + */ + Subscriber.prototype.next = function (value) { + if (!this.isStopped) { + this._next(value); + } + }; + /** + * The {@link Observer} callback to receive notifications of type `error` from + * the Observable, with an attached {@link Error}. Notifies the Observer that + * the Observable has experienced an error condition. + * @param {any} [err] The `error` exception. + * @return {void} + */ + Subscriber.prototype.error = function (err) { + if (!this.isStopped) { + this.isStopped = true; + this._error(err); + } + }; + /** + * The {@link Observer} callback to receive a valueless notification of type + * `complete` from the Observable. Notifies the Observer that the Observable + * has finished sending push-based notifications. + * @return {void} + */ + Subscriber.prototype.complete = function () { + if (!this.isStopped) { + this.isStopped = true; + this._complete(); + } + }; + Subscriber.prototype.unsubscribe = function () { + if (this.closed) { + return; + } + this.isStopped = true; + _super.prototype.unsubscribe.call(this); + }; + Subscriber.prototype._next = function (value) { + this.destination.next(value); + }; + Subscriber.prototype._error = function (err) { + this.destination.error(err); + this.unsubscribe(); + }; + Subscriber.prototype._complete = function () { + this.destination.complete(); + this.unsubscribe(); + }; + return Subscriber; + }(Subscription_1.Subscription)); + exports.Subscriber = Subscriber; + /** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ + var SafeSubscriber = (function (_super) { + __extends(SafeSubscriber, _super); + function SafeSubscriber(_parent, observerOrNext, error, complete) { + _super.call(this); + this._parent = _parent; + var next; + var context = this; + if (isFunction_1.isFunction(observerOrNext)) { + next = observerOrNext; + } + else if (observerOrNext) { + context = observerOrNext; + next = observerOrNext.next; + error = observerOrNext.error; + complete = observerOrNext.complete; + if (isFunction_1.isFunction(context.unsubscribe)) { + this.add(context.unsubscribe.bind(context)); + } + context.unsubscribe = this.unsubscribe.bind(this); + } + this._context = context; + this._next = next; + this._error = error; + this._complete = complete; + } + SafeSubscriber.prototype.next = function (value) { + if (!this.isStopped && this._next) { + var _parent = this._parent; + if (!_parent.syncErrorThrowable) { + this.__tryOrUnsub(this._next, value); + } + else if (this.__tryOrSetError(_parent, this._next, value)) { + this.unsubscribe(); + } + } + }; + SafeSubscriber.prototype.error = function (err) { + if (!this.isStopped) { + var _parent = this._parent; + if (this._error) { + if (!_parent.syncErrorThrowable) { + this.__tryOrUnsub(this._error, err); + this.unsubscribe(); + } + else { + this.__tryOrSetError(_parent, this._error, err); + this.unsubscribe(); + } + } + else if (!_parent.syncErrorThrowable) { + this.unsubscribe(); + throw err; + } + else { + _parent.syncErrorValue = err; + _parent.syncErrorThrown = true; + this.unsubscribe(); + } + } + }; + SafeSubscriber.prototype.complete = function () { + if (!this.isStopped) { + var _parent = this._parent; + if (this._complete) { + if (!_parent.syncErrorThrowable) { + this.__tryOrUnsub(this._complete); + this.unsubscribe(); + } + else { + this.__tryOrSetError(_parent, this._complete); + this.unsubscribe(); + } + } + else { + this.unsubscribe(); + } + } + }; + SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) { + try { + fn.call(this._context, value); + } + catch (err) { + this.unsubscribe(); + throw err; + } + }; + SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) { + try { + fn.call(this._context, value); + } + catch (err) { + parent.syncErrorValue = err; + parent.syncErrorThrown = true; + return true; + } + return false; + }; + SafeSubscriber.prototype._unsubscribe = function () { + var _parent = this._parent; + this._context = null; + this._parent = null; + _parent.unsubscribe(); + }; + return SafeSubscriber; + }(Subscriber)); +//# sourceMappingURL=Subscriber.js.map + + /***/ }, + /* 4 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* WEBPACK VAR INJECTION */(function(global) {/* unused harmony export scheduleMicroTask */ + /* harmony export (binding) */ __webpack_require__.d(exports, "p", function() { return _global; }); + /* unused harmony export getTypeNameForDebugging */ + /* unused harmony export Math */ + /* unused harmony export Date */ + /* harmony export (immutable) */ exports["a"] = isPresent; + /* harmony export (immutable) */ exports["b"] = isBlank; + /* unused harmony export isBoolean */ + /* unused harmony export isNumber */ + /* harmony export (immutable) */ exports["g"] = isString; + /* unused harmony export isFunction */ + /* unused harmony export isType */ + /* harmony export (immutable) */ exports["l"] = isStringMap; + /* harmony export (immutable) */ exports["h"] = isStrictStringMap; + /* harmony export (immutable) */ exports["c"] = isArray; + /* unused harmony export isDate */ + /* unused harmony export noop */ + /* harmony export (immutable) */ exports["q"] = stringify; + /* unused harmony export serializeEnum */ + /* unused harmony export deserializeEnum */ + /* unused harmony export resolveEnumToken */ + /* harmony export (binding) */ __webpack_require__.d(exports, "f", function() { return StringWrapper; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "n", function() { return StringJoiner; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "m", function() { return NumberWrapper; }); + /* unused harmony export RegExp */ + /* unused harmony export FunctionWrapper */ + /* unused harmony export looseIdentical */ + /* unused harmony export getMapKey */ + /* harmony export (immutable) */ exports["k"] = normalizeBlank; + /* harmony export (immutable) */ exports["j"] = normalizeBool; + /* harmony export (immutable) */ exports["d"] = isJsObject; + /* unused harmony export print */ + /* unused harmony export warn */ + /* unused harmony export Json */ + /* unused harmony export DateWrapper */ + /* unused harmony export setValueOnPath */ + /* harmony export (immutable) */ exports["e"] = getSymbolIterator; + /* harmony export (immutable) */ exports["r"] = evalExpression; + /* harmony export (immutable) */ exports["i"] = isPrimitive; + /* unused harmony export hasConstructor */ + /* unused harmony export escape */ + /* harmony export (immutable) */ exports["o"] = escapeRegExp; + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var globalScope; + if (typeof window === 'undefined') { + if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { + // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492 + globalScope = self; + } + else { + globalScope = global; + } + } + else { + globalScope = window; + } + function scheduleMicroTask(fn) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); + } +// Need to declare a new variable for global here since TypeScript +// exports the original value of the symbol. + var _global = globalScope; + + function getTypeNameForDebugging(type) { + if (type['name']) { + return type['name']; + } + return typeof type; + } + var Math = _global.Math; + var Date = _global.Date; +// TODO: remove calls to assert in production environment +// Note: Can't just export this and import in in other files +// as `assert` is a reserved keyword in Dart + _global.assert = function assert(condition) { + // TODO: to be fixed properly via #2830, noop for now + }; + function isPresent(obj) { + return obj !== undefined && obj !== null; + } + function isBlank(obj) { + return obj === undefined || obj === null; + } + function isBoolean(obj) { + return typeof obj === 'boolean'; + } + function isNumber(obj) { + return typeof obj === 'number'; + } + function isString(obj) { + return typeof obj === 'string'; + } + function isFunction(obj) { + return typeof obj === 'function'; + } + function isType(obj) { + return isFunction(obj); + } + function isStringMap(obj) { + return typeof obj === 'object' && obj !== null; + } + var STRING_MAP_PROTO = Object.getPrototypeOf({}); + function isStrictStringMap(obj) { + return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; + } + function isArray(obj) { + return Array.isArray(obj); + } + function isDate(obj) { + return obj instanceof Date && !isNaN(obj.valueOf()); + } + function noop() { } + function stringify(token) { + if (typeof token === 'string') { + return token; + } + if (token === undefined || token === null) { + return '' + token; + } + if (token.overriddenName) { + return token.overriddenName; + } + if (token.name) { + return token.name; + } + var res = token.toString(); + var newLineIndex = res.indexOf('\n'); + return (newLineIndex === -1) ? res : res.substring(0, newLineIndex); + } +// serialize / deserialize enum exist only for consistency with dart API +// enums in typescript don't need to be serialized + function serializeEnum(val) { + return val; + } + function deserializeEnum(val, values) { + return val; + } + function resolveEnumToken(enumValue, val) { + return enumValue[val]; + } + var StringWrapper = (function () { + function StringWrapper() { + } + StringWrapper.fromCharCode = function (code) { return String.fromCharCode(code); }; + StringWrapper.charCodeAt = function (s, index) { return s.charCodeAt(index); }; + StringWrapper.split = function (s, regExp) { return s.split(regExp); }; + StringWrapper.equals = function (s, s2) { return s === s2; }; + StringWrapper.stripLeft = function (s, charVal) { + if (s && s.length) { + var pos = 0; + for (var i = 0; i < s.length; i++) { + if (s[i] != charVal) + break; + pos++; + } + s = s.substring(pos); + } + return s; + }; + StringWrapper.stripRight = function (s, charVal) { + if (s && s.length) { + var pos = s.length; + for (var i = s.length - 1; i >= 0; i--) { + if (s[i] != charVal) + break; + pos--; + } + s = s.substring(0, pos); + } + return s; + }; + StringWrapper.replace = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.replaceAll = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.slice = function (s, from, to) { + if (from === void 0) { from = 0; } + if (to === void 0) { to = null; } + return s.slice(from, to === null ? undefined : to); + }; + StringWrapper.replaceAllMapped = function (s, from, cb) { + return s.replace(from, function () { + var matches = []; + for (var _i = 0; _i < arguments.length; _i++) { + matches[_i - 0] = arguments[_i]; + } + // Remove offset & string from the result array + matches.splice(-2, 2); + // The callback receives match, p1, ..., pn + return cb(matches); + }); + }; + StringWrapper.contains = function (s, substr) { return s.indexOf(substr) != -1; }; + StringWrapper.compare = function (a, b) { + if (a < b) { + return -1; + } + else if (a > b) { + return 1; + } + else { + return 0; + } + }; + return StringWrapper; + }()); + var StringJoiner = (function () { + function StringJoiner(parts) { + if (parts === void 0) { parts = []; } + this.parts = parts; + } + StringJoiner.prototype.add = function (part) { this.parts.push(part); }; + StringJoiner.prototype.toString = function () { return this.parts.join(''); }; + return StringJoiner; + }()); + var NumberWrapper = (function () { + function NumberWrapper() { + } + NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); }; + NumberWrapper.equal = function (a, b) { return a === b; }; + NumberWrapper.parseIntAutoRadix = function (text) { + var result = parseInt(text); + if (isNaN(result)) { + throw new Error('Invalid integer literal when parsing ' + text); + } + return result; + }; + NumberWrapper.parseInt = function (text, radix) { + if (radix == 10) { + if (/^(\-|\+)?[0-9]+$/.test(text)) { + return parseInt(text, radix); + } + } + else if (radix == 16) { + if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) { + return parseInt(text, radix); + } + } + else { + var result = parseInt(text, radix); + if (!isNaN(result)) { + return result; + } + } + throw new Error('Invalid integer literal when parsing ' + text + ' in base ' + radix); + }; + Object.defineProperty(NumberWrapper, "NaN", { + get: function () { return NaN; }, + enumerable: true, + configurable: true + }); + NumberWrapper.isNumeric = function (value) { return !isNaN(value - parseFloat(value)); }; + NumberWrapper.isNaN = function (value) { return isNaN(value); }; + NumberWrapper.isInteger = function (value) { return Number.isInteger(value); }; + return NumberWrapper; + }()); + var RegExp = _global.RegExp; + var FunctionWrapper = (function () { + function FunctionWrapper() { + } + FunctionWrapper.apply = function (fn, posArgs) { return fn.apply(null, posArgs); }; + FunctionWrapper.bind = function (fn, scope) { return fn.bind(scope); }; + return FunctionWrapper; + }()); +// JS has NaN !== NaN + function looseIdentical(a, b) { + return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); + } +// JS considers NaN is the same as NaN for map Key (while NaN !== NaN otherwise) +// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map + function getMapKey(value) { + return value; + } + function normalizeBlank(obj) { + return isBlank(obj) ? null : obj; + } + function normalizeBool(obj) { + return isBlank(obj) ? false : obj; + } + function isJsObject(o) { + return o !== null && (typeof o === 'function' || typeof o === 'object'); + } + function print(obj) { + console.log(obj); + } + function warn(obj) { + console.warn(obj); + } +// Can't be all uppercase as our transpiler would think it is a special directive... + var Json = (function () { + function Json() { + } + Json.parse = function (s) { return _global.JSON.parse(s); }; + Json.stringify = function (data) { + // Dart doesn't take 3 arguments + return _global.JSON.stringify(data, null, 2); + }; + return Json; + }()); + var DateWrapper = (function () { + function DateWrapper() { + } + DateWrapper.create = function (year, month, day, hour, minutes, seconds, milliseconds) { + if (month === void 0) { month = 1; } + if (day === void 0) { day = 1; } + if (hour === void 0) { hour = 0; } + if (minutes === void 0) { minutes = 0; } + if (seconds === void 0) { seconds = 0; } + if (milliseconds === void 0) { milliseconds = 0; } + return new Date(year, month - 1, day, hour, minutes, seconds, milliseconds); + }; + DateWrapper.fromISOString = function (str) { return new Date(str); }; + DateWrapper.fromMillis = function (ms) { return new Date(ms); }; + DateWrapper.toMillis = function (date) { return date.getTime(); }; + DateWrapper.now = function () { return new Date(); }; + DateWrapper.toJson = function (date) { return date.toJSON(); }; + return DateWrapper; + }()); + function setValueOnPath(global, path, value) { + var parts = path.split('.'); + var obj = global; + while (parts.length > 1) { + var name = parts.shift(); + if (obj.hasOwnProperty(name) && isPresent(obj[name])) { + obj = obj[name]; + } + else { + obj = obj[name] = {}; + } + } + if (obj === undefined || obj === null) { + obj = {}; + } + obj[parts.shift()] = value; + } + var _symbolIterator = null; + function getSymbolIterator() { + if (isBlank(_symbolIterator)) { + if (isPresent(globalScope.Symbol) && isPresent(Symbol.iterator)) { + _symbolIterator = Symbol.iterator; + } + else { + // es6-shim specific logic + var keys = Object.getOwnPropertyNames(Map.prototype); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (key !== 'entries' && key !== 'size' && + Map.prototype[key] === Map.prototype['entries']) { + _symbolIterator = key; + } + } + } + } + return _symbolIterator; + } + function evalExpression(sourceUrl, expr, declarations, vars) { + var fnBody = declarations + "\nreturn " + expr + "\n//# sourceURL=" + sourceUrl; + var fnArgNames = []; + var fnArgValues = []; + for (var argName in vars) { + fnArgNames.push(argName); + fnArgValues.push(vars[argName]); + } + return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues); + } + function isPrimitive(obj) { + return !isJsObject(obj); + } + function hasConstructor(value, type) { + return value.constructor === type; + } + function escape(s) { + return _global.encodeURI(s); + } + function escapeRegExp(s) { + return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); + } +//# sourceMappingURL=lang.js.map + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(64))) + + /***/ }, + /* 5 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (immutable) */ exports["q"] = scheduleMicroTask; + /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return _global; }); + /* harmony export (immutable) */ exports["o"] = getTypeNameForDebugging; + /* harmony export (binding) */ __webpack_require__.d(exports, "j", function() { return Math; }); + /* unused harmony export Date */ + /* harmony export (immutable) */ exports["e"] = isPresent; + /* harmony export (immutable) */ exports["d"] = isBlank; + /* unused harmony export isBoolean */ + /* unused harmony export isNumber */ + /* harmony export (immutable) */ exports["r"] = isString; + /* harmony export (immutable) */ exports["a"] = isFunction; + /* unused harmony export isType */ + /* unused harmony export isStringMap */ + /* unused harmony export isStrictStringMap */ + /* harmony export (immutable) */ exports["f"] = isArray; + /* unused harmony export isDate */ + /* unused harmony export noop */ + /* harmony export (immutable) */ exports["b"] = stringify; + /* unused harmony export serializeEnum */ + /* unused harmony export deserializeEnum */ + /* unused harmony export resolveEnumToken */ + /* harmony export (binding) */ __webpack_require__.d(exports, "i", function() { return StringWrapper; }); + /* unused harmony export StringJoiner */ + /* unused harmony export NumberWrapper */ + /* unused harmony export RegExp */ + /* unused harmony export FunctionWrapper */ + /* harmony export (immutable) */ exports["m"] = looseIdentical; + /* harmony export (immutable) */ exports["n"] = getMapKey; + /* unused harmony export normalizeBlank */ + /* unused harmony export normalizeBool */ + /* harmony export (immutable) */ exports["g"] = isJsObject; + /* harmony export (immutable) */ exports["k"] = print; + /* harmony export (immutable) */ exports["l"] = warn; + /* unused harmony export Json */ + /* unused harmony export DateWrapper */ + /* unused harmony export setValueOnPath */ + /* harmony export (immutable) */ exports["h"] = getSymbolIterator; + /* unused harmony export evalExpression */ + /* harmony export (immutable) */ exports["p"] = isPrimitive; + /* unused harmony export hasConstructor */ + /* unused harmony export escape */ + /* unused harmony export escapeRegExp */ + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var globalScope; + if (typeof window === 'undefined') { + if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { + // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492 + globalScope = self; + } + else { + globalScope = global; + } + } + else { + globalScope = window; + } + function scheduleMicroTask(fn) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); + } +// Need to declare a new variable for global here since TypeScript +// exports the original value of the symbol. + var _global = globalScope; + + function getTypeNameForDebugging(type) { + if (type['name']) { + return type['name']; + } + return typeof type; + } + var Math = _global.Math; + var Date = _global.Date; +// TODO: remove calls to assert in production environment +// Note: Can't just export this and import in in other files +// as `assert` is a reserved keyword in Dart + _global.assert = function assert(condition) { + // TODO: to be fixed properly via #2830, noop for now + }; + function isPresent(obj) { + return obj !== undefined && obj !== null; + } + function isBlank(obj) { + return obj === undefined || obj === null; + } + function isBoolean(obj) { + return typeof obj === 'boolean'; + } + function isNumber(obj) { + return typeof obj === 'number'; + } + function isString(obj) { + return typeof obj === 'string'; + } + function isFunction(obj) { + return typeof obj === 'function'; + } + function isType(obj) { + return isFunction(obj); + } + function isStringMap(obj) { + return typeof obj === 'object' && obj !== null; + } + var STRING_MAP_PROTO = Object.getPrototypeOf({}); + function isStrictStringMap(obj) { + return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; + } + function isArray(obj) { + return Array.isArray(obj); + } + function isDate(obj) { + return obj instanceof Date && !isNaN(obj.valueOf()); + } + function noop() { } + function stringify(token) { + if (typeof token === 'string') { + return token; + } + if (token === undefined || token === null) { + return '' + token; + } + if (token.overriddenName) { + return token.overriddenName; + } + if (token.name) { + return token.name; + } + var res = token.toString(); + var newLineIndex = res.indexOf('\n'); + return (newLineIndex === -1) ? res : res.substring(0, newLineIndex); + } +// serialize / deserialize enum exist only for consistency with dart API +// enums in typescript don't need to be serialized + function serializeEnum(val) { + return val; + } + function deserializeEnum(val, values) { + return val; + } + function resolveEnumToken(enumValue, val) { + return enumValue[val]; + } + var StringWrapper = (function () { + function StringWrapper() { + } + StringWrapper.fromCharCode = function (code) { return String.fromCharCode(code); }; + StringWrapper.charCodeAt = function (s, index) { return s.charCodeAt(index); }; + StringWrapper.split = function (s, regExp) { return s.split(regExp); }; + StringWrapper.equals = function (s, s2) { return s === s2; }; + StringWrapper.stripLeft = function (s, charVal) { + if (s && s.length) { + var pos = 0; + for (var i = 0; i < s.length; i++) { + if (s[i] != charVal) + break; + pos++; + } + s = s.substring(pos); + } + return s; + }; + StringWrapper.stripRight = function (s, charVal) { + if (s && s.length) { + var pos = s.length; + for (var i = s.length - 1; i >= 0; i--) { + if (s[i] != charVal) + break; + pos--; + } + s = s.substring(0, pos); + } + return s; + }; + StringWrapper.replace = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.replaceAll = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.slice = function (s, from, to) { + if (from === void 0) { from = 0; } + if (to === void 0) { to = null; } + return s.slice(from, to === null ? undefined : to); + }; + StringWrapper.replaceAllMapped = function (s, from, cb) { + return s.replace(from, function () { + var matches = []; + for (var _i = 0; _i < arguments.length; _i++) { + matches[_i - 0] = arguments[_i]; + } + // Remove offset & string from the result array + matches.splice(-2, 2); + // The callback receives match, p1, ..., pn + return cb(matches); + }); + }; + StringWrapper.contains = function (s, substr) { return s.indexOf(substr) != -1; }; + StringWrapper.compare = function (a, b) { + if (a < b) { + return -1; + } + else if (a > b) { + return 1; + } + else { + return 0; + } + }; + return StringWrapper; + }()); + var StringJoiner = (function () { + function StringJoiner(parts) { + if (parts === void 0) { parts = []; } + this.parts = parts; + } + StringJoiner.prototype.add = function (part) { this.parts.push(part); }; + StringJoiner.prototype.toString = function () { return this.parts.join(''); }; + return StringJoiner; + }()); + var NumberWrapper = (function () { + function NumberWrapper() { + } + NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); }; + NumberWrapper.equal = function (a, b) { return a === b; }; + NumberWrapper.parseIntAutoRadix = function (text) { + var result = parseInt(text); + if (isNaN(result)) { + throw new Error('Invalid integer literal when parsing ' + text); + } + return result; + }; + NumberWrapper.parseInt = function (text, radix) { + if (radix == 10) { + if (/^(\-|\+)?[0-9]+$/.test(text)) { + return parseInt(text, radix); + } + } + else if (radix == 16) { + if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) { + return parseInt(text, radix); + } + } + else { + var result = parseInt(text, radix); + if (!isNaN(result)) { + return result; + } + } + throw new Error('Invalid integer literal when parsing ' + text + ' in base ' + radix); + }; + Object.defineProperty(NumberWrapper, "NaN", { + get: function () { return NaN; }, + enumerable: true, + configurable: true + }); + NumberWrapper.isNumeric = function (value) { return !isNaN(value - parseFloat(value)); }; + NumberWrapper.isNaN = function (value) { return isNaN(value); }; + NumberWrapper.isInteger = function (value) { return Number.isInteger(value); }; + return NumberWrapper; + }()); + var RegExp = _global.RegExp; + var FunctionWrapper = (function () { + function FunctionWrapper() { + } + FunctionWrapper.apply = function (fn, posArgs) { return fn.apply(null, posArgs); }; + FunctionWrapper.bind = function (fn, scope) { return fn.bind(scope); }; + return FunctionWrapper; + }()); +// JS has NaN !== NaN + function looseIdentical(a, b) { + return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); + } +// JS considers NaN is the same as NaN for map Key (while NaN !== NaN otherwise) +// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map + function getMapKey(value) { + return value; + } + function normalizeBlank(obj) { + return isBlank(obj) ? null : obj; + } + function normalizeBool(obj) { + return isBlank(obj) ? false : obj; + } + function isJsObject(o) { + return o !== null && (typeof o === 'function' || typeof o === 'object'); + } + function print(obj) { + console.log(obj); + } + function warn(obj) { + console.warn(obj); + } +// Can't be all uppercase as our transpiler would think it is a special directive... + var Json = (function () { + function Json() { + } + Json.parse = function (s) { return _global.JSON.parse(s); }; + Json.stringify = function (data) { + // Dart doesn't take 3 arguments + return _global.JSON.stringify(data, null, 2); + }; + return Json; + }()); + var DateWrapper = (function () { + function DateWrapper() { + } + DateWrapper.create = function (year, month, day, hour, minutes, seconds, milliseconds) { + if (month === void 0) { month = 1; } + if (day === void 0) { day = 1; } + if (hour === void 0) { hour = 0; } + if (minutes === void 0) { minutes = 0; } + if (seconds === void 0) { seconds = 0; } + if (milliseconds === void 0) { milliseconds = 0; } + return new Date(year, month - 1, day, hour, minutes, seconds, milliseconds); + }; + DateWrapper.fromISOString = function (str) { return new Date(str); }; + DateWrapper.fromMillis = function (ms) { return new Date(ms); }; + DateWrapper.toMillis = function (date) { return date.getTime(); }; + DateWrapper.now = function () { return new Date(); }; + DateWrapper.toJson = function (date) { return date.toJSON(); }; + return DateWrapper; + }()); + function setValueOnPath(global, path, value) { + var parts = path.split('.'); + var obj = global; + while (parts.length > 1) { + var name = parts.shift(); + if (obj.hasOwnProperty(name) && isPresent(obj[name])) { + obj = obj[name]; + } + else { + obj = obj[name] = {}; + } + } + if (obj === undefined || obj === null) { + obj = {}; + } + obj[parts.shift()] = value; + } + var _symbolIterator = null; + function getSymbolIterator() { + if (isBlank(_symbolIterator)) { + if (isPresent(globalScope.Symbol) && isPresent(Symbol.iterator)) { + _symbolIterator = Symbol.iterator; + } + else { + // es6-shim specific logic + var keys = Object.getOwnPropertyNames(Map.prototype); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (key !== 'entries' && key !== 'size' && + Map.prototype[key] === Map.prototype['entries']) { + _symbolIterator = key; + } + } + } + } + return _symbolIterator; + } + function evalExpression(sourceUrl, expr, declarations, vars) { + var fnBody = declarations + "\nreturn " + expr + "\n//# sourceURL=" + sourceUrl; + var fnArgNames = []; + var fnArgValues = []; + for (var argName in vars) { + fnArgNames.push(argName); + fnArgValues.push(vars[argName]); + } + return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues); + } + function isPrimitive(obj) { + return !isJsObject(obj); + } + function hasConstructor(value, type) { + return value.constructor === type; + } + function escape(s) { + return _global.encodeURI(s); + } + function escapeRegExp(s) { + return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); + } +//# sourceMappingURL=lang.js.map + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(64))) + + /***/ }, + /* 6 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var Subscriber_1 = __webpack_require__(3); + /** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ + var OuterSubscriber = (function (_super) { + __extends(OuterSubscriber, _super); + function OuterSubscriber() { + _super.apply(this, arguments); + } + OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.destination.next(innerValue); + }; + OuterSubscriber.prototype.notifyError = function (error, innerSub) { + this.destination.error(error); + }; + OuterSubscriber.prototype.notifyComplete = function (innerSub) { + this.destination.complete(); + }; + return OuterSubscriber; + }(Subscriber_1.Subscriber)); + exports.OuterSubscriber = OuterSubscriber; +//# sourceMappingURL=OuterSubscriber.js.map + + /***/ }, + /* 7 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + "use strict"; + var root_1 = __webpack_require__(27); + var isArray_1 = __webpack_require__(48); + var isPromise_1 = __webpack_require__(418); + var Observable_1 = __webpack_require__(0); + var iterator_1 = __webpack_require__(124); + var InnerSubscriber_1 = __webpack_require__(694); + var observable_1 = __webpack_require__(173); + function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) { + var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex); + if (destination.closed) { + return null; + } + if (result instanceof Observable_1.Observable) { + if (result._isScalar) { + destination.next(result.value); + destination.complete(); + return null; + } + else { + return result.subscribe(destination); + } + } + if (isArray_1.isArray(result)) { + for (var i = 0, len = result.length; i < len && !destination.closed; i++) { + destination.next(result[i]); + } + if (!destination.closed) { + destination.complete(); + } + } + else if (isPromise_1.isPromise(result)) { + result.then(function (value) { + if (!destination.closed) { + destination.next(value); + destination.complete(); + } + }, function (err) { return destination.error(err); }) + .then(null, function (err) { + // Escaping the Promise trap: globally throw unhandled errors + root_1.root.setTimeout(function () { throw err; }); + }); + return destination; + } + else if (typeof result[iterator_1.$$iterator] === 'function') { + var iterator = result[iterator_1.$$iterator](); + do { + var item = iterator.next(); + if (item.done) { + destination.complete(); + break; + } + destination.next(item.value); + if (destination.closed) { + break; + } + } while (true); + } + else if (typeof result[observable_1.$$observable] === 'function') { + var obs = result[observable_1.$$observable](); + if (typeof obs.subscribe !== 'function') { + destination.error(new Error('invalid observable')); + } + else { + return obs.subscribe(new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex)); + } + } + else { + destination.error(new TypeError('unknown type returned')); + } + return null; + } + exports.subscribeToResult = subscribeToResult; +//# sourceMappingURL=subscribeToResult.js.map + + /***/ }, + /* 8 */ + /***/ function(module, exports, __webpack_require__) { + + var isObject = __webpack_require__(10); + module.exports = function(it){ + if(!isObject(it))throw TypeError(it + ' is not an object!'); + return it; + }; + + /***/ }, + /* 9 */ + /***/ function(module, exports) { + + module.exports = function(exec){ + try { + return !!exec(); + } catch(e){ + return true; + } + }; + + /***/ }, + /* 10 */ + /***/ function(module, exports) { + + module.exports = function(it){ + return typeof it === 'object' ? it !== null : typeof it === 'function'; + }; + + /***/ }, + /* 11 */ + /***/ function(module, exports) { + +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); + if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef + + /***/ }, + /* 12 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__facade_lang__ = __webpack_require__(4); + /* harmony export (binding) */ __webpack_require__.d(exports, "d", function() { return TypeModifier; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "Q", function() { return Type; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "R", function() { return BuiltinTypeName; }); + /* unused harmony export BuiltinType */ + /* harmony export (binding) */ __webpack_require__.d(exports, "I", function() { return ExternalType; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "q", function() { return ArrayType; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "w", function() { return MapType; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "l", function() { return DYNAMIC_TYPE; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "D", function() { return BOOL_TYPE; }); + /* unused harmony export INT_TYPE */ + /* harmony export (binding) */ __webpack_require__.d(exports, "L", function() { return NUMBER_TYPE; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "K", function() { return STRING_TYPE; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "E", function() { return FUNCTION_TYPE; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "y", function() { return BinaryOperator; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "m", function() { return Expression; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "O", function() { return BuiltinVar; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "B", function() { return ReadVarExpr; }); + /* unused harmony export WriteVarExpr */ + /* unused harmony export WriteKeyExpr */ + /* unused harmony export WritePropExpr */ + /* harmony export (binding) */ __webpack_require__.d(exports, "r", function() { return BuiltinMethod; }); + /* unused harmony export InvokeMethodExpr */ + /* unused harmony export InvokeFunctionExpr */ + /* unused harmony export InstantiateExpr */ + /* harmony export (binding) */ __webpack_require__.d(exports, "G", function() { return LiteralExpr; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "S", function() { return ExternalExpr; }); + /* unused harmony export ConditionalExpr */ + /* unused harmony export NotExpr */ + /* unused harmony export CastExpr */ + /* harmony export (binding) */ __webpack_require__.d(exports, "k", function() { return FnParam; }); + /* unused harmony export FunctionExpr */ + /* harmony export (binding) */ __webpack_require__.d(exports, "z", function() { return BinaryOperatorExpr; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "o", function() { return ReadPropExpr; }); + /* unused harmony export ReadKeyExpr */ + /* unused harmony export LiteralArrayExpr */ + /* unused harmony export LiteralMapExpr */ + /* harmony export (binding) */ __webpack_require__.d(exports, "n", function() { return THIS_EXPR; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "J", function() { return SUPER_EXPR; }); + /* unused harmony export CATCH_ERROR_VAR */ + /* unused harmony export CATCH_STACK_VAR */ + /* harmony export (binding) */ __webpack_require__.d(exports, "h", function() { return NULL_EXPR; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "u", function() { return StmtModifier; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "P", function() { return Statement; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "x", function() { return DeclareVarStmt; }); + /* unused harmony export DeclareFunctionStmt */ + /* harmony export (binding) */ __webpack_require__.d(exports, "F", function() { return ExpressionStatement; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "t", function() { return ReturnStatement; }); + /* unused harmony export AbstractClassPart */ + /* harmony export (binding) */ __webpack_require__.d(exports, "s", function() { return ClassField; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "C", function() { return ClassMethod; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "v", function() { return ClassGetter; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "M", function() { return ClassStmt; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "i", function() { return IfStmt; }); + /* unused harmony export CommentStmt */ + /* harmony export (binding) */ __webpack_require__.d(exports, "H", function() { return TryCatchStmt; }); + /* unused harmony export ThrowStmt */ + /* unused harmony export ExpressionTransformer */ + /* unused harmony export RecursiveExpressionVisitor */ + /* harmony export (immutable) */ exports["p"] = replaceVarInExpression; + /* harmony export (immutable) */ exports["N"] = findReadVarNames; + /* harmony export (immutable) */ exports["e"] = variable; + /* harmony export (immutable) */ exports["b"] = importExpr; + /* harmony export (immutable) */ exports["c"] = importType; + /* harmony export (immutable) */ exports["g"] = literalArr; + /* harmony export (immutable) */ exports["f"] = literalMap; + /* harmony export (immutable) */ exports["A"] = not; + /* harmony export (immutable) */ exports["j"] = fn; + /* harmony export (immutable) */ exports["a"] = literal; + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + +//// Types + var TypeModifier; + (function (TypeModifier) { + TypeModifier[TypeModifier["Const"] = 0] = "Const"; + })(TypeModifier || (TypeModifier = {})); + var Type = (function () { + function Type(modifiers) { + if (modifiers === void 0) { modifiers = null; } + this.modifiers = modifiers; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["b" /* isBlank */])(modifiers)) { + this.modifiers = []; + } + } + Type.prototype.hasModifier = function (modifier) { return this.modifiers.indexOf(modifier) !== -1; }; + return Type; + }()); + var BuiltinTypeName; + (function (BuiltinTypeName) { + BuiltinTypeName[BuiltinTypeName["Dynamic"] = 0] = "Dynamic"; + BuiltinTypeName[BuiltinTypeName["Bool"] = 1] = "Bool"; + BuiltinTypeName[BuiltinTypeName["String"] = 2] = "String"; + BuiltinTypeName[BuiltinTypeName["Int"] = 3] = "Int"; + BuiltinTypeName[BuiltinTypeName["Number"] = 4] = "Number"; + BuiltinTypeName[BuiltinTypeName["Function"] = 5] = "Function"; + })(BuiltinTypeName || (BuiltinTypeName = {})); + var BuiltinType = (function (_super) { + __extends(BuiltinType, _super); + function BuiltinType(name, modifiers) { + if (modifiers === void 0) { modifiers = null; } + _super.call(this, modifiers); + this.name = name; + } + BuiltinType.prototype.visitType = function (visitor, context) { + return visitor.visitBuiltintType(this, context); + }; + return BuiltinType; + }(Type)); + var ExternalType = (function (_super) { + __extends(ExternalType, _super); + function ExternalType(value, typeParams, modifiers) { + if (typeParams === void 0) { typeParams = null; } + if (modifiers === void 0) { modifiers = null; } + _super.call(this, modifiers); + this.value = value; + this.typeParams = typeParams; + } + ExternalType.prototype.visitType = function (visitor, context) { + return visitor.visitExternalType(this, context); + }; + return ExternalType; + }(Type)); + var ArrayType = (function (_super) { + __extends(ArrayType, _super); + function ArrayType(of, modifiers) { + if (modifiers === void 0) { modifiers = null; } + _super.call(this, modifiers); + this.of = of; + } + ArrayType.prototype.visitType = function (visitor, context) { + return visitor.visitArrayType(this, context); + }; + return ArrayType; + }(Type)); + var MapType = (function (_super) { + __extends(MapType, _super); + function MapType(valueType, modifiers) { + if (modifiers === void 0) { modifiers = null; } + _super.call(this, modifiers); + this.valueType = valueType; + } + MapType.prototype.visitType = function (visitor, context) { return visitor.visitMapType(this, context); }; + return MapType; + }(Type)); + var DYNAMIC_TYPE = new BuiltinType(BuiltinTypeName.Dynamic); + var BOOL_TYPE = new BuiltinType(BuiltinTypeName.Bool); + var INT_TYPE = new BuiltinType(BuiltinTypeName.Int); + var NUMBER_TYPE = new BuiltinType(BuiltinTypeName.Number); + var STRING_TYPE = new BuiltinType(BuiltinTypeName.String); + var FUNCTION_TYPE = new BuiltinType(BuiltinTypeName.Function); +///// Expressions + var BinaryOperator; + (function (BinaryOperator) { + BinaryOperator[BinaryOperator["Equals"] = 0] = "Equals"; + BinaryOperator[BinaryOperator["NotEquals"] = 1] = "NotEquals"; + BinaryOperator[BinaryOperator["Identical"] = 2] = "Identical"; + BinaryOperator[BinaryOperator["NotIdentical"] = 3] = "NotIdentical"; + BinaryOperator[BinaryOperator["Minus"] = 4] = "Minus"; + BinaryOperator[BinaryOperator["Plus"] = 5] = "Plus"; + BinaryOperator[BinaryOperator["Divide"] = 6] = "Divide"; + BinaryOperator[BinaryOperator["Multiply"] = 7] = "Multiply"; + BinaryOperator[BinaryOperator["Modulo"] = 8] = "Modulo"; + BinaryOperator[BinaryOperator["And"] = 9] = "And"; + BinaryOperator[BinaryOperator["Or"] = 10] = "Or"; + BinaryOperator[BinaryOperator["Lower"] = 11] = "Lower"; + BinaryOperator[BinaryOperator["LowerEquals"] = 12] = "LowerEquals"; + BinaryOperator[BinaryOperator["Bigger"] = 13] = "Bigger"; + BinaryOperator[BinaryOperator["BiggerEquals"] = 14] = "BiggerEquals"; + })(BinaryOperator || (BinaryOperator = {})); + var Expression = (function () { + function Expression(type) { + this.type = type; + } + Expression.prototype.prop = function (name) { return new ReadPropExpr(this, name); }; + Expression.prototype.key = function (index, type) { + if (type === void 0) { type = null; } + return new ReadKeyExpr(this, index, type); + }; + Expression.prototype.callMethod = function (name, params) { + return new InvokeMethodExpr(this, name, params); + }; + Expression.prototype.callFn = function (params) { return new InvokeFunctionExpr(this, params); }; + Expression.prototype.instantiate = function (params, type) { + if (type === void 0) { type = null; } + return new InstantiateExpr(this, params, type); + }; + Expression.prototype.conditional = function (trueCase, falseCase) { + if (falseCase === void 0) { falseCase = null; } + return new ConditionalExpr(this, trueCase, falseCase); + }; + Expression.prototype.equals = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs); + }; + Expression.prototype.notEquals = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs); + }; + Expression.prototype.identical = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs); + }; + Expression.prototype.notIdentical = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs); + }; + Expression.prototype.minus = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs); + }; + Expression.prototype.plus = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs); + }; + Expression.prototype.divide = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs); + }; + Expression.prototype.multiply = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs); + }; + Expression.prototype.modulo = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs); + }; + Expression.prototype.and = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.And, this, rhs); + }; + Expression.prototype.or = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs); + }; + Expression.prototype.lower = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs); + }; + Expression.prototype.lowerEquals = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs); + }; + Expression.prototype.bigger = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs); + }; + Expression.prototype.biggerEquals = function (rhs) { + return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs); + }; + Expression.prototype.isBlank = function () { + // Note: We use equals by purpose here to compare to null and undefined in JS. + return this.equals(NULL_EXPR); + }; + Expression.prototype.cast = function (type) { return new CastExpr(this, type); }; + Expression.prototype.toStmt = function () { return new ExpressionStatement(this); }; + return Expression; + }()); + var BuiltinVar; + (function (BuiltinVar) { + BuiltinVar[BuiltinVar["This"] = 0] = "This"; + BuiltinVar[BuiltinVar["Super"] = 1] = "Super"; + BuiltinVar[BuiltinVar["CatchError"] = 2] = "CatchError"; + BuiltinVar[BuiltinVar["CatchStack"] = 3] = "CatchStack"; + })(BuiltinVar || (BuiltinVar = {})); + var ReadVarExpr = (function (_super) { + __extends(ReadVarExpr, _super); + function ReadVarExpr(name, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["g" /* isString */])(name)) { + this.name = name; + this.builtin = null; + } + else { + this.name = null; + this.builtin = name; + } + } + ReadVarExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitReadVarExpr(this, context); + }; + ReadVarExpr.prototype.set = function (value) { return new WriteVarExpr(this.name, value); }; + return ReadVarExpr; + }(Expression)); + var WriteVarExpr = (function (_super) { + __extends(WriteVarExpr, _super); + function WriteVarExpr(name, value, type) { + if (type === void 0) { type = null; } + _super.call(this, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(type) ? type : value.type); + this.name = name; + this.value = value; + } + WriteVarExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitWriteVarExpr(this, context); + }; + WriteVarExpr.prototype.toDeclStmt = function (type, modifiers) { + if (type === void 0) { type = null; } + if (modifiers === void 0) { modifiers = null; } + return new DeclareVarStmt(this.name, this.value, type, modifiers); + }; + return WriteVarExpr; + }(Expression)); + var WriteKeyExpr = (function (_super) { + __extends(WriteKeyExpr, _super); + function WriteKeyExpr(receiver, index, value, type) { + if (type === void 0) { type = null; } + _super.call(this, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(type) ? type : value.type); + this.receiver = receiver; + this.index = index; + this.value = value; + } + WriteKeyExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitWriteKeyExpr(this, context); + }; + return WriteKeyExpr; + }(Expression)); + var WritePropExpr = (function (_super) { + __extends(WritePropExpr, _super); + function WritePropExpr(receiver, name, value, type) { + if (type === void 0) { type = null; } + _super.call(this, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(type) ? type : value.type); + this.receiver = receiver; + this.name = name; + this.value = value; + } + WritePropExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitWritePropExpr(this, context); + }; + return WritePropExpr; + }(Expression)); + var BuiltinMethod; + (function (BuiltinMethod) { + BuiltinMethod[BuiltinMethod["ConcatArray"] = 0] = "ConcatArray"; + BuiltinMethod[BuiltinMethod["SubscribeObservable"] = 1] = "SubscribeObservable"; + BuiltinMethod[BuiltinMethod["Bind"] = 2] = "Bind"; + })(BuiltinMethod || (BuiltinMethod = {})); + var InvokeMethodExpr = (function (_super) { + __extends(InvokeMethodExpr, _super); + function InvokeMethodExpr(receiver, method, args, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + this.receiver = receiver; + this.args = args; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["g" /* isString */])(method)) { + this.name = method; + this.builtin = null; + } + else { + this.name = null; + this.builtin = method; + } + } + InvokeMethodExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitInvokeMethodExpr(this, context); + }; + return InvokeMethodExpr; + }(Expression)); + var InvokeFunctionExpr = (function (_super) { + __extends(InvokeFunctionExpr, _super); + function InvokeFunctionExpr(fn, args, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + this.fn = fn; + this.args = args; + } + InvokeFunctionExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitInvokeFunctionExpr(this, context); + }; + return InvokeFunctionExpr; + }(Expression)); + var InstantiateExpr = (function (_super) { + __extends(InstantiateExpr, _super); + function InstantiateExpr(classExpr, args, type) { + _super.call(this, type); + this.classExpr = classExpr; + this.args = args; + } + InstantiateExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitInstantiateExpr(this, context); + }; + return InstantiateExpr; + }(Expression)); + var LiteralExpr = (function (_super) { + __extends(LiteralExpr, _super); + function LiteralExpr(value, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + this.value = value; + } + LiteralExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitLiteralExpr(this, context); + }; + return LiteralExpr; + }(Expression)); + var ExternalExpr = (function (_super) { + __extends(ExternalExpr, _super); + function ExternalExpr(value, type, typeParams) { + if (type === void 0) { type = null; } + if (typeParams === void 0) { typeParams = null; } + _super.call(this, type); + this.value = value; + this.typeParams = typeParams; + } + ExternalExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitExternalExpr(this, context); + }; + return ExternalExpr; + }(Expression)); + var ConditionalExpr = (function (_super) { + __extends(ConditionalExpr, _super); + function ConditionalExpr(condition, trueCase, falseCase, type) { + if (falseCase === void 0) { falseCase = null; } + if (type === void 0) { type = null; } + _super.call(this, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(type) ? type : trueCase.type); + this.condition = condition; + this.falseCase = falseCase; + this.trueCase = trueCase; + } + ConditionalExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitConditionalExpr(this, context); + }; + return ConditionalExpr; + }(Expression)); + var NotExpr = (function (_super) { + __extends(NotExpr, _super); + function NotExpr(condition) { + _super.call(this, BOOL_TYPE); + this.condition = condition; + } + NotExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitNotExpr(this, context); + }; + return NotExpr; + }(Expression)); + var CastExpr = (function (_super) { + __extends(CastExpr, _super); + function CastExpr(value, type) { + _super.call(this, type); + this.value = value; + } + CastExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitCastExpr(this, context); + }; + return CastExpr; + }(Expression)); + var FnParam = (function () { + function FnParam(name, type) { + if (type === void 0) { type = null; } + this.name = name; + this.type = type; + } + return FnParam; + }()); + var FunctionExpr = (function (_super) { + __extends(FunctionExpr, _super); + function FunctionExpr(params, statements, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + this.params = params; + this.statements = statements; + } + FunctionExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitFunctionExpr(this, context); + }; + FunctionExpr.prototype.toDeclStmt = function (name, modifiers) { + if (modifiers === void 0) { modifiers = null; } + return new DeclareFunctionStmt(name, this.params, this.statements, this.type, modifiers); + }; + return FunctionExpr; + }(Expression)); + var BinaryOperatorExpr = (function (_super) { + __extends(BinaryOperatorExpr, _super); + function BinaryOperatorExpr(operator, lhs, rhs, type) { + if (type === void 0) { type = null; } + _super.call(this, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(type) ? type : lhs.type); + this.operator = operator; + this.rhs = rhs; + this.lhs = lhs; + } + BinaryOperatorExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitBinaryOperatorExpr(this, context); + }; + return BinaryOperatorExpr; + }(Expression)); + var ReadPropExpr = (function (_super) { + __extends(ReadPropExpr, _super); + function ReadPropExpr(receiver, name, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + this.receiver = receiver; + this.name = name; + } + ReadPropExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitReadPropExpr(this, context); + }; + ReadPropExpr.prototype.set = function (value) { + return new WritePropExpr(this.receiver, this.name, value); + }; + return ReadPropExpr; + }(Expression)); + var ReadKeyExpr = (function (_super) { + __extends(ReadKeyExpr, _super); + function ReadKeyExpr(receiver, index, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + this.receiver = receiver; + this.index = index; + } + ReadKeyExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitReadKeyExpr(this, context); + }; + ReadKeyExpr.prototype.set = function (value) { + return new WriteKeyExpr(this.receiver, this.index, value); + }; + return ReadKeyExpr; + }(Expression)); + var LiteralArrayExpr = (function (_super) { + __extends(LiteralArrayExpr, _super); + function LiteralArrayExpr(entries, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + this.entries = entries; + } + LiteralArrayExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitLiteralArrayExpr(this, context); + }; + return LiteralArrayExpr; + }(Expression)); + var LiteralMapExpr = (function (_super) { + __extends(LiteralMapExpr, _super); + function LiteralMapExpr(entries, type) { + if (type === void 0) { type = null; } + _super.call(this, type); + this.entries = entries; + this.valueType = null; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(type)) { + this.valueType = type.valueType; + } + } + LiteralMapExpr.prototype.visitExpression = function (visitor, context) { + return visitor.visitLiteralMapExpr(this, context); + }; + return LiteralMapExpr; + }(Expression)); + var THIS_EXPR = new ReadVarExpr(BuiltinVar.This); + var SUPER_EXPR = new ReadVarExpr(BuiltinVar.Super); + var CATCH_ERROR_VAR = new ReadVarExpr(BuiltinVar.CatchError); + var CATCH_STACK_VAR = new ReadVarExpr(BuiltinVar.CatchStack); + var NULL_EXPR = new LiteralExpr(null, null); +//// Statements + var StmtModifier; + (function (StmtModifier) { + StmtModifier[StmtModifier["Final"] = 0] = "Final"; + StmtModifier[StmtModifier["Private"] = 1] = "Private"; + })(StmtModifier || (StmtModifier = {})); + var Statement = (function () { + function Statement(modifiers) { + if (modifiers === void 0) { modifiers = null; } + this.modifiers = modifiers; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["b" /* isBlank */])(modifiers)) { + this.modifiers = []; + } + } + Statement.prototype.hasModifier = function (modifier) { return this.modifiers.indexOf(modifier) !== -1; }; + return Statement; + }()); + var DeclareVarStmt = (function (_super) { + __extends(DeclareVarStmt, _super); + function DeclareVarStmt(name, value, type, modifiers) { + if (type === void 0) { type = null; } + if (modifiers === void 0) { modifiers = null; } + _super.call(this, modifiers); + this.name = name; + this.value = value; + this.type = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(type) ? type : value.type; + } + DeclareVarStmt.prototype.visitStatement = function (visitor, context) { + return visitor.visitDeclareVarStmt(this, context); + }; + return DeclareVarStmt; + }(Statement)); + var DeclareFunctionStmt = (function (_super) { + __extends(DeclareFunctionStmt, _super); + function DeclareFunctionStmt(name, params, statements, type, modifiers) { + if (type === void 0) { type = null; } + if (modifiers === void 0) { modifiers = null; } + _super.call(this, modifiers); + this.name = name; + this.params = params; + this.statements = statements; + this.type = type; + } + DeclareFunctionStmt.prototype.visitStatement = function (visitor, context) { + return visitor.visitDeclareFunctionStmt(this, context); + }; + return DeclareFunctionStmt; + }(Statement)); + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expr) { + _super.call(this); + this.expr = expr; + } + ExpressionStatement.prototype.visitStatement = function (visitor, context) { + return visitor.visitExpressionStmt(this, context); + }; + return ExpressionStatement; + }(Statement)); + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(value) { + _super.call(this); + this.value = value; + } + ReturnStatement.prototype.visitStatement = function (visitor, context) { + return visitor.visitReturnStmt(this, context); + }; + return ReturnStatement; + }(Statement)); + var AbstractClassPart = (function () { + function AbstractClassPart(type, modifiers) { + if (type === void 0) { type = null; } + this.type = type; + this.modifiers = modifiers; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["b" /* isBlank */])(modifiers)) { + this.modifiers = []; + } + } + AbstractClassPart.prototype.hasModifier = function (modifier) { return this.modifiers.indexOf(modifier) !== -1; }; + return AbstractClassPart; + }()); + var ClassField = (function (_super) { + __extends(ClassField, _super); + function ClassField(name, type, modifiers) { + if (type === void 0) { type = null; } + if (modifiers === void 0) { modifiers = null; } + _super.call(this, type, modifiers); + this.name = name; + } + return ClassField; + }(AbstractClassPart)); + var ClassMethod = (function (_super) { + __extends(ClassMethod, _super); + function ClassMethod(name, params, body, type, modifiers) { + if (type === void 0) { type = null; } + if (modifiers === void 0) { modifiers = null; } + _super.call(this, type, modifiers); + this.name = name; + this.params = params; + this.body = body; + } + return ClassMethod; + }(AbstractClassPart)); + var ClassGetter = (function (_super) { + __extends(ClassGetter, _super); + function ClassGetter(name, body, type, modifiers) { + if (type === void 0) { type = null; } + if (modifiers === void 0) { modifiers = null; } + _super.call(this, type, modifiers); + this.name = name; + this.body = body; + } + return ClassGetter; + }(AbstractClassPart)); + var ClassStmt = (function (_super) { + __extends(ClassStmt, _super); + function ClassStmt(name, parent, fields, getters, constructorMethod, methods, modifiers) { + if (modifiers === void 0) { modifiers = null; } + _super.call(this, modifiers); + this.name = name; + this.parent = parent; + this.fields = fields; + this.getters = getters; + this.constructorMethod = constructorMethod; + this.methods = methods; + } + ClassStmt.prototype.visitStatement = function (visitor, context) { + return visitor.visitDeclareClassStmt(this, context); + }; + return ClassStmt; + }(Statement)); + var IfStmt = (function (_super) { + __extends(IfStmt, _super); + function IfStmt(condition, trueCase, falseCase) { + if (falseCase === void 0) { falseCase = []; } + _super.call(this); + this.condition = condition; + this.trueCase = trueCase; + this.falseCase = falseCase; + } + IfStmt.prototype.visitStatement = function (visitor, context) { + return visitor.visitIfStmt(this, context); + }; + return IfStmt; + }(Statement)); + var CommentStmt = (function (_super) { + __extends(CommentStmt, _super); + function CommentStmt(comment) { + _super.call(this); + this.comment = comment; + } + CommentStmt.prototype.visitStatement = function (visitor, context) { + return visitor.visitCommentStmt(this, context); + }; + return CommentStmt; + }(Statement)); + var TryCatchStmt = (function (_super) { + __extends(TryCatchStmt, _super); + function TryCatchStmt(bodyStmts, catchStmts) { + _super.call(this); + this.bodyStmts = bodyStmts; + this.catchStmts = catchStmts; + } + TryCatchStmt.prototype.visitStatement = function (visitor, context) { + return visitor.visitTryCatchStmt(this, context); + }; + return TryCatchStmt; + }(Statement)); + var ThrowStmt = (function (_super) { + __extends(ThrowStmt, _super); + function ThrowStmt(error) { + _super.call(this); + this.error = error; + } + ThrowStmt.prototype.visitStatement = function (visitor, context) { + return visitor.visitThrowStmt(this, context); + }; + return ThrowStmt; + }(Statement)); + var ExpressionTransformer = (function () { + function ExpressionTransformer() { + } + ExpressionTransformer.prototype.visitReadVarExpr = function (ast, context) { return ast; }; + ExpressionTransformer.prototype.visitWriteVarExpr = function (expr, context) { + return new WriteVarExpr(expr.name, expr.value.visitExpression(this, context)); + }; + ExpressionTransformer.prototype.visitWriteKeyExpr = function (expr, context) { + return new WriteKeyExpr(expr.receiver.visitExpression(this, context), expr.index.visitExpression(this, context), expr.value.visitExpression(this, context)); + }; + ExpressionTransformer.prototype.visitWritePropExpr = function (expr, context) { + return new WritePropExpr(expr.receiver.visitExpression(this, context), expr.name, expr.value.visitExpression(this, context)); + }; + ExpressionTransformer.prototype.visitInvokeMethodExpr = function (ast, context) { + var method = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(ast.builtin) ? ast.builtin : ast.name; + return new InvokeMethodExpr(ast.receiver.visitExpression(this, context), method, this.visitAllExpressions(ast.args, context), ast.type); + }; + ExpressionTransformer.prototype.visitInvokeFunctionExpr = function (ast, context) { + return new InvokeFunctionExpr(ast.fn.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type); + }; + ExpressionTransformer.prototype.visitInstantiateExpr = function (ast, context) { + return new InstantiateExpr(ast.classExpr.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type); + }; + ExpressionTransformer.prototype.visitLiteralExpr = function (ast, context) { return ast; }; + ExpressionTransformer.prototype.visitExternalExpr = function (ast, context) { return ast; }; + ExpressionTransformer.prototype.visitConditionalExpr = function (ast, context) { + return new ConditionalExpr(ast.condition.visitExpression(this, context), ast.trueCase.visitExpression(this, context), ast.falseCase.visitExpression(this, context)); + }; + ExpressionTransformer.prototype.visitNotExpr = function (ast, context) { + return new NotExpr(ast.condition.visitExpression(this, context)); + }; + ExpressionTransformer.prototype.visitCastExpr = function (ast, context) { + return new CastExpr(ast.value.visitExpression(this, context), context); + }; + ExpressionTransformer.prototype.visitFunctionExpr = function (ast, context) { + // Don't descend into nested functions + return ast; + }; + ExpressionTransformer.prototype.visitBinaryOperatorExpr = function (ast, context) { + return new BinaryOperatorExpr(ast.operator, ast.lhs.visitExpression(this, context), ast.rhs.visitExpression(this, context), ast.type); + }; + ExpressionTransformer.prototype.visitReadPropExpr = function (ast, context) { + return new ReadPropExpr(ast.receiver.visitExpression(this, context), ast.name, ast.type); + }; + ExpressionTransformer.prototype.visitReadKeyExpr = function (ast, context) { + return new ReadKeyExpr(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context), ast.type); + }; + ExpressionTransformer.prototype.visitLiteralArrayExpr = function (ast, context) { + return new LiteralArrayExpr(this.visitAllExpressions(ast.entries, context)); + }; + ExpressionTransformer.prototype.visitLiteralMapExpr = function (ast, context) { + var _this = this; + return new LiteralMapExpr(ast.entries.map(function (entry) { return [entry[0], entry[1].visitExpression(_this, context)]; })); + }; + ExpressionTransformer.prototype.visitAllExpressions = function (exprs, context) { + var _this = this; + return exprs.map(function (expr) { return expr.visitExpression(_this, context); }); + }; + ExpressionTransformer.prototype.visitDeclareVarStmt = function (stmt, context) { + return new DeclareVarStmt(stmt.name, stmt.value.visitExpression(this, context), stmt.type, stmt.modifiers); + }; + ExpressionTransformer.prototype.visitDeclareFunctionStmt = function (stmt, context) { + // Don't descend into nested functions + return stmt; + }; + ExpressionTransformer.prototype.visitExpressionStmt = function (stmt, context) { + return new ExpressionStatement(stmt.expr.visitExpression(this, context)); + }; + ExpressionTransformer.prototype.visitReturnStmt = function (stmt, context) { + return new ReturnStatement(stmt.value.visitExpression(this, context)); + }; + ExpressionTransformer.prototype.visitDeclareClassStmt = function (stmt, context) { + // Don't descend into nested functions + return stmt; + }; + ExpressionTransformer.prototype.visitIfStmt = function (stmt, context) { + return new IfStmt(stmt.condition.visitExpression(this, context), this.visitAllStatements(stmt.trueCase, context), this.visitAllStatements(stmt.falseCase, context)); + }; + ExpressionTransformer.prototype.visitTryCatchStmt = function (stmt, context) { + return new TryCatchStmt(this.visitAllStatements(stmt.bodyStmts, context), this.visitAllStatements(stmt.catchStmts, context)); + }; + ExpressionTransformer.prototype.visitThrowStmt = function (stmt, context) { + return new ThrowStmt(stmt.error.visitExpression(this, context)); + }; + ExpressionTransformer.prototype.visitCommentStmt = function (stmt, context) { return stmt; }; + ExpressionTransformer.prototype.visitAllStatements = function (stmts, context) { + var _this = this; + return stmts.map(function (stmt) { return stmt.visitStatement(_this, context); }); + }; + return ExpressionTransformer; + }()); + var RecursiveExpressionVisitor = (function () { + function RecursiveExpressionVisitor() { + } + RecursiveExpressionVisitor.prototype.visitReadVarExpr = function (ast, context) { return ast; }; + RecursiveExpressionVisitor.prototype.visitWriteVarExpr = function (expr, context) { + expr.value.visitExpression(this, context); + return expr; + }; + RecursiveExpressionVisitor.prototype.visitWriteKeyExpr = function (expr, context) { + expr.receiver.visitExpression(this, context); + expr.index.visitExpression(this, context); + expr.value.visitExpression(this, context); + return expr; + }; + RecursiveExpressionVisitor.prototype.visitWritePropExpr = function (expr, context) { + expr.receiver.visitExpression(this, context); + expr.value.visitExpression(this, context); + return expr; + }; + RecursiveExpressionVisitor.prototype.visitInvokeMethodExpr = function (ast, context) { + ast.receiver.visitExpression(this, context); + this.visitAllExpressions(ast.args, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitInvokeFunctionExpr = function (ast, context) { + ast.fn.visitExpression(this, context); + this.visitAllExpressions(ast.args, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitInstantiateExpr = function (ast, context) { + ast.classExpr.visitExpression(this, context); + this.visitAllExpressions(ast.args, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitLiteralExpr = function (ast, context) { return ast; }; + RecursiveExpressionVisitor.prototype.visitExternalExpr = function (ast, context) { return ast; }; + RecursiveExpressionVisitor.prototype.visitConditionalExpr = function (ast, context) { + ast.condition.visitExpression(this, context); + ast.trueCase.visitExpression(this, context); + ast.falseCase.visitExpression(this, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitNotExpr = function (ast, context) { + ast.condition.visitExpression(this, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitCastExpr = function (ast, context) { + ast.value.visitExpression(this, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitFunctionExpr = function (ast, context) { return ast; }; + RecursiveExpressionVisitor.prototype.visitBinaryOperatorExpr = function (ast, context) { + ast.lhs.visitExpression(this, context); + ast.rhs.visitExpression(this, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitReadPropExpr = function (ast, context) { + ast.receiver.visitExpression(this, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitReadKeyExpr = function (ast, context) { + ast.receiver.visitExpression(this, context); + ast.index.visitExpression(this, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitLiteralArrayExpr = function (ast, context) { + this.visitAllExpressions(ast.entries, context); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitLiteralMapExpr = function (ast, context) { + var _this = this; + ast.entries.forEach(function (entry) { return entry[1].visitExpression(_this, context); }); + return ast; + }; + RecursiveExpressionVisitor.prototype.visitAllExpressions = function (exprs, context) { + var _this = this; + exprs.forEach(function (expr) { return expr.visitExpression(_this, context); }); + }; + RecursiveExpressionVisitor.prototype.visitDeclareVarStmt = function (stmt, context) { + stmt.value.visitExpression(this, context); + return stmt; + }; + RecursiveExpressionVisitor.prototype.visitDeclareFunctionStmt = function (stmt, context) { + // Don't descend into nested functions + return stmt; + }; + RecursiveExpressionVisitor.prototype.visitExpressionStmt = function (stmt, context) { + stmt.expr.visitExpression(this, context); + return stmt; + }; + RecursiveExpressionVisitor.prototype.visitReturnStmt = function (stmt, context) { + stmt.value.visitExpression(this, context); + return stmt; + }; + RecursiveExpressionVisitor.prototype.visitDeclareClassStmt = function (stmt, context) { + // Don't descend into nested functions + return stmt; + }; + RecursiveExpressionVisitor.prototype.visitIfStmt = function (stmt, context) { + stmt.condition.visitExpression(this, context); + this.visitAllStatements(stmt.trueCase, context); + this.visitAllStatements(stmt.falseCase, context); + return stmt; + }; + RecursiveExpressionVisitor.prototype.visitTryCatchStmt = function (stmt, context) { + this.visitAllStatements(stmt.bodyStmts, context); + this.visitAllStatements(stmt.catchStmts, context); + return stmt; + }; + RecursiveExpressionVisitor.prototype.visitThrowStmt = function (stmt, context) { + stmt.error.visitExpression(this, context); + return stmt; + }; + RecursiveExpressionVisitor.prototype.visitCommentStmt = function (stmt, context) { return stmt; }; + RecursiveExpressionVisitor.prototype.visitAllStatements = function (stmts, context) { + var _this = this; + stmts.forEach(function (stmt) { return stmt.visitStatement(_this, context); }); + }; + return RecursiveExpressionVisitor; + }()); + function replaceVarInExpression(varName, newValue, expression) { + var transformer = new _ReplaceVariableTransformer(varName, newValue); + return expression.visitExpression(transformer, null); + } + var _ReplaceVariableTransformer = (function (_super) { + __extends(_ReplaceVariableTransformer, _super); + function _ReplaceVariableTransformer(_varName, _newValue) { + _super.call(this); + this._varName = _varName; + this._newValue = _newValue; + } + _ReplaceVariableTransformer.prototype.visitReadVarExpr = function (ast, context) { + return ast.name == this._varName ? this._newValue : ast; + }; + return _ReplaceVariableTransformer; + }(ExpressionTransformer)); + function findReadVarNames(stmts) { + var finder = new _VariableFinder(); + finder.visitAllStatements(stmts, null); + return finder.varNames; + } + var _VariableFinder = (function (_super) { + __extends(_VariableFinder, _super); + function _VariableFinder() { + _super.apply(this, arguments); + this.varNames = new Set(); + } + _VariableFinder.prototype.visitReadVarExpr = function (ast, context) { + this.varNames.add(ast.name); + return null; + }; + return _VariableFinder; + }(RecursiveExpressionVisitor)); + function variable(name, type) { + if (type === void 0) { type = null; } + return new ReadVarExpr(name, type); + } + function importExpr(id, typeParams) { + if (typeParams === void 0) { typeParams = null; } + return new ExternalExpr(id, null, typeParams); + } + function importType(id, typeParams, typeModifiers) { + if (typeParams === void 0) { typeParams = null; } + if (typeModifiers === void 0) { typeModifiers = null; } + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(id) ? new ExternalType(id, typeParams, typeModifiers) : null; + } + function literalArr(values, type) { + if (type === void 0) { type = null; } + return new LiteralArrayExpr(values, type); + } + function literalMap(values, type) { + if (type === void 0) { type = null; } + return new LiteralMapExpr(values, type); + } + function not(expr) { + return new NotExpr(expr); + } + function fn(params, body, type) { + if (type === void 0) { type = null; } + return new FunctionExpr(params, body, type); + } + function literal(value, type) { + if (type === void 0) { type = null; } + return new LiteralExpr(value, type); + } +//# sourceMappingURL=output_ast.js.map + + /***/ }, + /* 13 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__lang__ = __webpack_require__(4); + /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return MapWrapper; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return StringMapWrapper; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "a", function() { return ListWrapper; }); + /* unused harmony export isListLikeIterable */ + /* unused harmony export areIterablesEqual */ + /* unused harmony export iterateListLike */ + /* harmony export (binding) */ __webpack_require__.d(exports, "d", function() { return SetWrapper; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +// Safari and Internet Explorer do not support the iterable parameter to the +// Map constructor. We work around that by manually adding the items. + var createMapFromPairs = (function () { + try { + if (new Map([[1, 2]]).size === 1) { + return function createMapFromPairs(pairs) { return new Map(pairs); }; + } + } + catch (e) { + } + return function createMapAndPopulateFromPairs(pairs) { + var map = new Map(); + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + map.set(pair[0], pair[1]); + } + return map; + }; + })(); + var createMapFromMap = (function () { + try { + if (new Map(new Map())) { + return function createMapFromMap(m) { return new Map(m); }; + } + } + catch (e) { + } + return function createMapAndPopulateFromMap(m) { + var map = new Map(); + m.forEach(function (v, k) { map.set(k, v); }); + return map; + }; + })(); + var _clearValues = (function () { + if ((new Map()).keys().next) { + return function _clearValues(m) { + var keyIterator = m.keys(); + var k; + while (!((k = keyIterator.next()).done)) { + m.set(k.value, null); + } + }; + } + else { + return function _clearValuesWithForeEach(m) { + m.forEach(function (v, k) { m.set(k, null); }); + }; + } + })(); +// Safari doesn't implement MapIterator.next(), which is used is Traceur's polyfill of Array.from +// TODO(mlaval): remove the work around once we have a working polyfill of Array.from + var _arrayFromMap = (function () { + try { + if ((new Map()).values().next) { + return function createArrayFromMap(m, getValues) { + return getValues ? Array.from(m.values()) : Array.from(m.keys()); + }; + } + } + catch (e) { + } + return function createArrayFromMapWithForeach(m, getValues) { + var res = new Array(m.size), i = 0; + m.forEach(function (v, k) { + res[i] = getValues ? v : k; + i++; + }); + return res; + }; + })(); + var MapWrapper = (function () { + function MapWrapper() { + } + MapWrapper.createFromStringMap = function (stringMap) { + var result = new Map(); + for (var prop in stringMap) { + result.set(prop, stringMap[prop]); + } + return result; + }; + MapWrapper.toStringMap = function (m) { + var r = {}; + m.forEach(function (v, k) { return r[k] = v; }); + return r; + }; + MapWrapper.createFromPairs = function (pairs) { return createMapFromPairs(pairs); }; + MapWrapper.iterable = function (m) { return m; }; + MapWrapper.keys = function (m) { return _arrayFromMap(m, false); }; + MapWrapper.values = function (m) { return _arrayFromMap(m, true); }; + return MapWrapper; + }()); + /** + * Wraps Javascript Objects + */ + var StringMapWrapper = (function () { + function StringMapWrapper() { + } + StringMapWrapper.get = function (map, key) { + return map.hasOwnProperty(key) ? map[key] : undefined; + }; + StringMapWrapper.set = function (map, key, value) { map[key] = value; }; + StringMapWrapper.keys = function (map) { return Object.keys(map); }; + StringMapWrapper.values = function (map) { + return Object.keys(map).map(function (k) { return map[k]; }); + }; + StringMapWrapper.isEmpty = function (map) { + for (var prop in map) { + return false; + } + return true; + }; + StringMapWrapper.forEach = function (map, callback) { + for (var _i = 0, _a = Object.keys(map); _i < _a.length; _i++) { + var k = _a[_i]; + callback(map[k], k); + } + }; + StringMapWrapper.merge = function (m1, m2) { + var m = {}; + for (var _i = 0, _a = Object.keys(m1); _i < _a.length; _i++) { + var k = _a[_i]; + m[k] = m1[k]; + } + for (var _b = 0, _c = Object.keys(m2); _b < _c.length; _b++) { + var k = _c[_b]; + m[k] = m2[k]; + } + return m; + }; + StringMapWrapper.equals = function (m1, m2) { + var k1 = Object.keys(m1); + var k2 = Object.keys(m2); + if (k1.length != k2.length) { + return false; + } + for (var i = 0; i < k1.length; i++) { + var key = k1[i]; + if (m1[key] !== m2[key]) { + return false; + } + } + return true; + }; + return StringMapWrapper; + }()); + var ListWrapper = (function () { + function ListWrapper() { + } + // JS has no way to express a statically fixed size list, but dart does so we + // keep both methods. + ListWrapper.createFixedSize = function (size) { return new Array(size); }; + ListWrapper.createGrowableSize = function (size) { return new Array(size); }; + ListWrapper.clone = function (array) { return array.slice(0); }; + ListWrapper.forEachWithIndex = function (array, fn) { + for (var i = 0; i < array.length; i++) { + fn(array[i], i); + } + }; + ListWrapper.first = function (array) { + if (!array) + return null; + return array[0]; + }; + ListWrapper.last = function (array) { + if (!array || array.length == 0) + return null; + return array[array.length - 1]; + }; + ListWrapper.indexOf = function (array, value, startIndex) { + if (startIndex === void 0) { startIndex = 0; } + return array.indexOf(value, startIndex); + }; + ListWrapper.contains = function (list, el) { return list.indexOf(el) !== -1; }; + ListWrapper.reversed = function (array) { + var a = ListWrapper.clone(array); + return a.reverse(); + }; + ListWrapper.concat = function (a, b) { return a.concat(b); }; + ListWrapper.insert = function (list, index, value) { list.splice(index, 0, value); }; + ListWrapper.removeAt = function (list, index) { + var res = list[index]; + list.splice(index, 1); + return res; + }; + ListWrapper.removeAll = function (list, items) { + for (var i = 0; i < items.length; ++i) { + var index = list.indexOf(items[i]); + list.splice(index, 1); + } + }; + ListWrapper.remove = function (list, el) { + var index = list.indexOf(el); + if (index > -1) { + list.splice(index, 1); + return true; + } + return false; + }; + ListWrapper.clear = function (list) { list.length = 0; }; + ListWrapper.isEmpty = function (list) { return list.length == 0; }; + ListWrapper.fill = function (list, value, start, end) { + if (start === void 0) { start = 0; } + if (end === void 0) { end = null; } + list.fill(value, start, end === null ? list.length : end); + }; + ListWrapper.equals = function (a, b) { + if (a.length != b.length) + return false; + for (var i = 0; i < a.length; ++i) { + if (a[i] !== b[i]) + return false; + } + return true; + }; + ListWrapper.slice = function (l, from, to) { + if (from === void 0) { from = 0; } + if (to === void 0) { to = null; } + return l.slice(from, to === null ? undefined : to); + }; + ListWrapper.splice = function (l, from, length) { return l.splice(from, length); }; + ListWrapper.sort = function (l, compareFn) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["a" /* isPresent */])(compareFn)) { + l.sort(compareFn); + } + else { + l.sort(); + } + }; + ListWrapper.toString = function (l) { return l.toString(); }; + ListWrapper.toJSON = function (l) { return JSON.stringify(l); }; + ListWrapper.maximum = function (list, predicate) { + if (list.length == 0) { + return null; + } + var solution = null; + var maxValue = -Infinity; + for (var index = 0; index < list.length; index++) { + var candidate = list[index]; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["b" /* isBlank */])(candidate)) { + continue; + } + var candidateValue = predicate(candidate); + if (candidateValue > maxValue) { + solution = candidate; + maxValue = candidateValue; + } + } + return solution; + }; + ListWrapper.flatten = function (list) { + var target = []; + _flattenArray(list, target); + return target; + }; + ListWrapper.addAll = function (list, source) { + for (var i = 0; i < source.length; i++) { + list.push(source[i]); + } + }; + return ListWrapper; + }()); + function _flattenArray(source, target) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["a" /* isPresent */])(source)) { + for (var i = 0; i < source.length; i++) { + var item = source[i]; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["c" /* isArray */])(item)) { + _flattenArray(item, target); + } + else { + target.push(item); + } + } + } + return target; + } + function isListLikeIterable(obj) { + if (!__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["d" /* isJsObject */])(obj)) + return false; + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["c" /* isArray */])(obj) || + (!(obj instanceof Map) && + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["e" /* getSymbolIterator */])() in obj); // JS Iterable have a Symbol.iterator prop + } + function areIterablesEqual(a, b, comparator) { + var iterator1 = a[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["e" /* getSymbolIterator */])()](); + var iterator2 = b[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["e" /* getSymbolIterator */])()](); + while (true) { + var item1 = iterator1.next(); + var item2 = iterator2.next(); + if (item1.done && item2.done) + return true; + if (item1.done || item2.done) + return false; + if (!comparator(item1.value, item2.value)) + return false; + } + } + function iterateListLike(obj, fn) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["c" /* isArray */])(obj)) { + for (var i = 0; i < obj.length; i++) { + fn(obj[i]); + } + } + else { + var iterator = obj[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["e" /* getSymbolIterator */])()](); + var item; + while (!((item = iterator.next()).done)) { + fn(item.value); + } + } + } +// Safari and Internet Explorer do not support the iterable parameter to the +// Set constructor. We work around that by manually adding the items. + var createSetFromList = (function () { + var test = new Set([1, 2, 3]); + if (test.size === 3) { + return function createSetFromList(lst) { return new Set(lst); }; + } + else { + return function createSetAndPopulateFromList(lst) { + var res = new Set(lst); + if (res.size !== lst.length) { + for (var i = 0; i < lst.length; i++) { + res.add(lst[i]); + } + } + return res; + }; + } + })(); + var SetWrapper = (function () { + function SetWrapper() { + } + SetWrapper.createFromList = function (lst) { return createSetFromList(lst); }; + SetWrapper.has = function (s, key) { return s.has(key); }; + SetWrapper.delete = function (m, k) { m.delete(k); }; + return SetWrapper; + }()); +//# sourceMappingURL=collection.js.map + + /***/ }, + /* 14 */ + /***/ function(module, exports, __webpack_require__) { + + var store = __webpack_require__(165)('wks') + , uid = __webpack_require__(81) + , Symbol = __webpack_require__(11).Symbol + , USE_SYMBOL = typeof Symbol == 'function'; + + var $exports = module.exports = function(name){ + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); + }; + + $exports.store = store; + + /***/ }, + /* 15 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var Observable_1 = __webpack_require__(0); + var Subscriber_1 = __webpack_require__(3); + var Subscription_1 = __webpack_require__(22); + var ObjectUnsubscribedError_1 = __webpack_require__(265); + var SubjectSubscription_1 = __webpack_require__(697); + var rxSubscriber_1 = __webpack_require__(174); + /** + * @class SubjectSubscriber + */ + var SubjectSubscriber = (function (_super) { + __extends(SubjectSubscriber, _super); + function SubjectSubscriber(destination) { + _super.call(this, destination); + this.destination = destination; + } + return SubjectSubscriber; + }(Subscriber_1.Subscriber)); + exports.SubjectSubscriber = SubjectSubscriber; + /** + * @class Subject + */ + var Subject = (function (_super) { + __extends(Subject, _super); + function Subject() { + _super.call(this); + this.observers = []; + this.closed = false; + this.isStopped = false; + this.hasError = false; + this.thrownError = null; + } + Subject.prototype[rxSubscriber_1.$$rxSubscriber] = function () { + return new SubjectSubscriber(this); + }; + Subject.prototype.lift = function (operator) { + var subject = new AnonymousSubject(this, this); + subject.operator = operator; + return subject; + }; + Subject.prototype.next = function (value) { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + if (!this.isStopped) { + var observers = this.observers; + var len = observers.length; + var copy = observers.slice(); + for (var i = 0; i < len; i++) { + copy[i].next(value); + } + } + }; + Subject.prototype.error = function (err) { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + this.hasError = true; + this.thrownError = err; + this.isStopped = true; + var observers = this.observers; + var len = observers.length; + var copy = observers.slice(); + for (var i = 0; i < len; i++) { + copy[i].error(err); + } + this.observers.length = 0; + }; + Subject.prototype.complete = function () { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + this.isStopped = true; + var observers = this.observers; + var len = observers.length; + var copy = observers.slice(); + for (var i = 0; i < len; i++) { + copy[i].complete(); + } + this.observers.length = 0; + }; + Subject.prototype.unsubscribe = function () { + this.isStopped = true; + this.closed = true; + this.observers = null; + }; + Subject.prototype._subscribe = function (subscriber) { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + else if (this.hasError) { + subscriber.error(this.thrownError); + return Subscription_1.Subscription.EMPTY; + } + else if (this.isStopped) { + subscriber.complete(); + return Subscription_1.Subscription.EMPTY; + } + else { + this.observers.push(subscriber); + return new SubjectSubscription_1.SubjectSubscription(this, subscriber); + } + }; + Subject.prototype.asObservable = function () { + var observable = new Observable_1.Observable(); + observable.source = this; + return observable; + }; + Subject.create = function (destination, source) { + return new AnonymousSubject(destination, source); + }; + return Subject; + }(Observable_1.Observable)); + exports.Subject = Subject; + /** + * @class AnonymousSubject + */ + var AnonymousSubject = (function (_super) { + __extends(AnonymousSubject, _super); + function AnonymousSubject(destination, source) { + _super.call(this); + this.destination = destination; + this.source = source; + } + AnonymousSubject.prototype.next = function (value) { + var destination = this.destination; + if (destination && destination.next) { + destination.next(value); + } + }; + AnonymousSubject.prototype.error = function (err) { + var destination = this.destination; + if (destination && destination.error) { + this.destination.error(err); + } + }; + AnonymousSubject.prototype.complete = function () { + var destination = this.destination; + if (destination && destination.complete) { + this.destination.complete(); + } + }; + AnonymousSubject.prototype._subscribe = function (subscriber) { + var source = this.source; + if (source) { + return this.source.subscribe(subscriber); + } + else { + return Subscription_1.Subscription.EMPTY; + } + }; + return AnonymousSubject; + }(Subject)); + exports.AnonymousSubject = AnonymousSubject; +//# sourceMappingURL=Subject.js.map + + /***/ }, + /* 16 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__lang__ = __webpack_require__(5); + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return MapWrapper; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "d", function() { return StringMapWrapper; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "a", function() { return ListWrapper; }); + /* harmony export (immutable) */ exports["e"] = isListLikeIterable; + /* harmony export (immutable) */ exports["g"] = areIterablesEqual; + /* harmony export (immutable) */ exports["f"] = iterateListLike; + /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return SetWrapper; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +// Safari and Internet Explorer do not support the iterable parameter to the +// Map constructor. We work around that by manually adding the items. + var createMapFromPairs = (function () { + try { + if (new Map([[1, 2]]).size === 1) { + return function createMapFromPairs(pairs) { return new Map(pairs); }; + } + } + catch (e) { + } + return function createMapAndPopulateFromPairs(pairs) { + var map = new Map(); + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + map.set(pair[0], pair[1]); + } + return map; + }; + })(); + var createMapFromMap = (function () { + try { + if (new Map(new Map())) { + return function createMapFromMap(m) { return new Map(m); }; + } + } + catch (e) { + } + return function createMapAndPopulateFromMap(m) { + var map = new Map(); + m.forEach(function (v, k) { map.set(k, v); }); + return map; + }; + })(); + var _clearValues = (function () { + if ((new Map()).keys().next) { + return function _clearValues(m) { + var keyIterator = m.keys(); + var k; + while (!((k = keyIterator.next()).done)) { + m.set(k.value, null); + } + }; + } + else { + return function _clearValuesWithForeEach(m) { + m.forEach(function (v, k) { m.set(k, null); }); + }; + } + })(); +// Safari doesn't implement MapIterator.next(), which is used is Traceur's polyfill of Array.from +// TODO(mlaval): remove the work around once we have a working polyfill of Array.from + var _arrayFromMap = (function () { + try { + if ((new Map()).values().next) { + return function createArrayFromMap(m, getValues) { + return getValues ? Array.from(m.values()) : Array.from(m.keys()); + }; + } + } + catch (e) { + } + return function createArrayFromMapWithForeach(m, getValues) { + var res = new Array(m.size), i = 0; + m.forEach(function (v, k) { + res[i] = getValues ? v : k; + i++; + }); + return res; + }; + })(); + var MapWrapper = (function () { + function MapWrapper() { + } + MapWrapper.createFromStringMap = function (stringMap) { + var result = new Map(); + for (var prop in stringMap) { + result.set(prop, stringMap[prop]); + } + return result; + }; + MapWrapper.toStringMap = function (m) { + var r = {}; + m.forEach(function (v, k) { return r[k] = v; }); + return r; + }; + MapWrapper.createFromPairs = function (pairs) { return createMapFromPairs(pairs); }; + MapWrapper.iterable = function (m) { return m; }; + MapWrapper.keys = function (m) { return _arrayFromMap(m, false); }; + MapWrapper.values = function (m) { return _arrayFromMap(m, true); }; + return MapWrapper; + }()); + /** + * Wraps Javascript Objects + */ + var StringMapWrapper = (function () { + function StringMapWrapper() { + } + StringMapWrapper.get = function (map, key) { + return map.hasOwnProperty(key) ? map[key] : undefined; + }; + StringMapWrapper.set = function (map, key, value) { map[key] = value; }; + StringMapWrapper.keys = function (map) { return Object.keys(map); }; + StringMapWrapper.values = function (map) { + return Object.keys(map).map(function (k) { return map[k]; }); + }; + StringMapWrapper.isEmpty = function (map) { + for (var prop in map) { + return false; + } + return true; + }; + StringMapWrapper.forEach = function (map, callback) { + for (var _i = 0, _a = Object.keys(map); _i < _a.length; _i++) { + var k = _a[_i]; + callback(map[k], k); + } + }; + StringMapWrapper.merge = function (m1, m2) { + var m = {}; + for (var _i = 0, _a = Object.keys(m1); _i < _a.length; _i++) { + var k = _a[_i]; + m[k] = m1[k]; + } + for (var _b = 0, _c = Object.keys(m2); _b < _c.length; _b++) { + var k = _c[_b]; + m[k] = m2[k]; + } + return m; + }; + StringMapWrapper.equals = function (m1, m2) { + var k1 = Object.keys(m1); + var k2 = Object.keys(m2); + if (k1.length != k2.length) { + return false; + } + for (var i = 0; i < k1.length; i++) { + var key = k1[i]; + if (m1[key] !== m2[key]) { + return false; + } + } + return true; + }; + return StringMapWrapper; + }()); + var ListWrapper = (function () { + function ListWrapper() { + } + // JS has no way to express a statically fixed size list, but dart does so we + // keep both methods. + ListWrapper.createFixedSize = function (size) { return new Array(size); }; + ListWrapper.createGrowableSize = function (size) { return new Array(size); }; + ListWrapper.clone = function (array) { return array.slice(0); }; + ListWrapper.forEachWithIndex = function (array, fn) { + for (var i = 0; i < array.length; i++) { + fn(array[i], i); + } + }; + ListWrapper.first = function (array) { + if (!array) + return null; + return array[0]; + }; + ListWrapper.last = function (array) { + if (!array || array.length == 0) + return null; + return array[array.length - 1]; + }; + ListWrapper.indexOf = function (array, value, startIndex) { + if (startIndex === void 0) { startIndex = 0; } + return array.indexOf(value, startIndex); + }; + ListWrapper.contains = function (list, el) { return list.indexOf(el) !== -1; }; + ListWrapper.reversed = function (array) { + var a = ListWrapper.clone(array); + return a.reverse(); + }; + ListWrapper.concat = function (a, b) { return a.concat(b); }; + ListWrapper.insert = function (list, index, value) { list.splice(index, 0, value); }; + ListWrapper.removeAt = function (list, index) { + var res = list[index]; + list.splice(index, 1); + return res; + }; + ListWrapper.removeAll = function (list, items) { + for (var i = 0; i < items.length; ++i) { + var index = list.indexOf(items[i]); + list.splice(index, 1); + } + }; + ListWrapper.remove = function (list, el) { + var index = list.indexOf(el); + if (index > -1) { + list.splice(index, 1); + return true; + } + return false; + }; + ListWrapper.clear = function (list) { list.length = 0; }; + ListWrapper.isEmpty = function (list) { return list.length == 0; }; + ListWrapper.fill = function (list, value, start, end) { + if (start === void 0) { start = 0; } + if (end === void 0) { end = null; } + list.fill(value, start, end === null ? list.length : end); + }; + ListWrapper.equals = function (a, b) { + if (a.length != b.length) + return false; + for (var i = 0; i < a.length; ++i) { + if (a[i] !== b[i]) + return false; + } + return true; + }; + ListWrapper.slice = function (l, from, to) { + if (from === void 0) { from = 0; } + if (to === void 0) { to = null; } + return l.slice(from, to === null ? undefined : to); + }; + ListWrapper.splice = function (l, from, length) { return l.splice(from, length); }; + ListWrapper.sort = function (l, compareFn) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["e" /* isPresent */])(compareFn)) { + l.sort(compareFn); + } + else { + l.sort(); + } + }; + ListWrapper.toString = function (l) { return l.toString(); }; + ListWrapper.toJSON = function (l) { return JSON.stringify(l); }; + ListWrapper.maximum = function (list, predicate) { + if (list.length == 0) { + return null; + } + var solution = null; + var maxValue = -Infinity; + for (var index = 0; index < list.length; index++) { + var candidate = list[index]; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["d" /* isBlank */])(candidate)) { + continue; + } + var candidateValue = predicate(candidate); + if (candidateValue > maxValue) { + solution = candidate; + maxValue = candidateValue; + } + } + return solution; + }; + ListWrapper.flatten = function (list) { + var target = []; + _flattenArray(list, target); + return target; + }; + ListWrapper.addAll = function (list, source) { + for (var i = 0; i < source.length; i++) { + list.push(source[i]); + } + }; + return ListWrapper; + }()); + function _flattenArray(source, target) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["e" /* isPresent */])(source)) { + for (var i = 0; i < source.length; i++) { + var item = source[i]; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["f" /* isArray */])(item)) { + _flattenArray(item, target); + } + else { + target.push(item); + } + } + } + return target; + } + function isListLikeIterable(obj) { + if (!__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["g" /* isJsObject */])(obj)) + return false; + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["f" /* isArray */])(obj) || + (!(obj instanceof Map) && + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["h" /* getSymbolIterator */])() in obj); // JS Iterable have a Symbol.iterator prop + } + function areIterablesEqual(a, b, comparator) { + var iterator1 = a[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["h" /* getSymbolIterator */])()](); + var iterator2 = b[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["h" /* getSymbolIterator */])()](); + while (true) { + var item1 = iterator1.next(); + var item2 = iterator2.next(); + if (item1.done && item2.done) + return true; + if (item1.done || item2.done) + return false; + if (!comparator(item1.value, item2.value)) + return false; + } + } + function iterateListLike(obj, fn) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["f" /* isArray */])(obj)) { + for (var i = 0; i < obj.length; i++) { + fn(obj[i]); + } + } + else { + var iterator = obj[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__lang__["h" /* getSymbolIterator */])()](); + var item; + while (!((item = iterator.next()).done)) { + fn(item.value); + } + } + } +// Safari and Internet Explorer do not support the iterable parameter to the +// Set constructor. We work around that by manually adding the items. + var createSetFromList = (function () { + var test = new Set([1, 2, 3]); + if (test.size === 3) { + return function createSetFromList(lst) { return new Set(lst); }; + } + else { + return function createSetAndPopulateFromList(lst) { + var res = new Set(lst); + if (res.size !== lst.length) { + for (var i = 0; i < lst.length; i++) { + res.add(lst[i]); + } + } + return res; + }; + } + })(); + var SetWrapper = (function () { + function SetWrapper() { + } + SetWrapper.createFromList = function (lst) { return createSetFromList(lst); }; + SetWrapper.has = function (s, key) { return s.has(key); }; + SetWrapper.delete = function (m, k) { m.delete(k); }; + return SetWrapper; + }()); +//# sourceMappingURL=collection.js.map + + /***/ }, + /* 17 */ + /***/ function(module, exports, __webpack_require__) { + + var anObject = __webpack_require__(8) + , IE8_DOM_DEFINE = __webpack_require__(367) + , toPrimitive = __webpack_require__(73) + , dP = Object.defineProperty; + + exports.f = __webpack_require__(21) ? Object.defineProperty : function defineProperty(O, P, Attributes){ + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if(IE8_DOM_DEFINE)try { + return dP(O, P, Attributes); + } catch(e){ /* empty */ } + if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); + if('value' in Attributes)O[P] = Attributes.value; + return O; + }; + + /***/ }, + /* 18 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__facade_lang__ = __webpack_require__(31); + /* harmony export (immutable) */ exports["a"] = getDOM; + /* unused harmony export setDOM */ + /* harmony export (immutable) */ exports["c"] = setRootDomAdapter; + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return DomAdapter; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + + var _DOM = null; + function getDOM() { + return _DOM; + } + function setDOM(adapter) { + _DOM = adapter; + } + function setRootDomAdapter(adapter) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["b" /* isBlank */])(_DOM)) { + _DOM = adapter; + } + } + /* tslint:disable:requireParameterType */ + /** + * Provides DOM operations in an environment-agnostic way. + * + * @security Tread carefully! Interacting with the DOM directly is dangerous and + * can introduce XSS risks. + */ + var DomAdapter = (function () { + function DomAdapter() { + this.resourceLoaderType = null; + } + Object.defineProperty(DomAdapter.prototype, "attrToPropMap", { + /** + * Maps attribute names to their corresponding property names for cases + * where attribute name doesn't match property name. + */ + get: function () { return this._attrToPropMap; }, + set: function (value) { this._attrToPropMap = value; }, + enumerable: true, + configurable: true + }); + ; + ; + return DomAdapter; + }()); +//# sourceMappingURL=dom_adapter.js.map + + /***/ }, + /* 19 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__compile_metadata__ = __webpack_require__(25); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__private_import_core__ = __webpack_require__(20); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util__ = __webpack_require__(29); + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return Identifiers; }); + /* harmony export (immutable) */ exports["d"] = resolveIdentifier; + /* harmony export (immutable) */ exports["c"] = identifierToken; + /* harmony export (immutable) */ exports["a"] = resolveIdentifierToken; + /* harmony export (immutable) */ exports["e"] = resolveEnumIdentifier; + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + + + + + var APP_VIEW_MODULE_URL = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/view'); + var VIEW_UTILS_MODULE_URL = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/view_utils'); + var CD_MODULE_URL = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'change_detection/change_detection'); + var ANIMATION_STYLE_UTIL_ASSET_URL = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'animation/animation_style_util'); + var Identifiers = (function () { + function Identifiers() { + } + Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS = { + name: 'ANALYZE_FOR_ENTRY_COMPONENTS', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'metadata/di'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ANALYZE_FOR_ENTRY_COMPONENTS"] + }; + Identifiers.ViewUtils = { + name: 'ViewUtils', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/view_utils'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["a" /* ViewUtils */] + }; + Identifiers.AppView = { name: 'AppView', moduleUrl: APP_VIEW_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["b" /* AppView */] }; + Identifiers.DebugAppView = { + name: 'DebugAppView', + moduleUrl: APP_VIEW_MODULE_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["c" /* DebugAppView */] + }; + Identifiers.AppElement = { + name: 'AppElement', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/element'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["d" /* AppElement */] + }; + Identifiers.ElementRef = { + name: 'ElementRef', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/element_ref'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ElementRef"] + }; + Identifiers.ViewContainerRef = { + name: 'ViewContainerRef', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/view_container_ref'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewContainerRef"] + }; + Identifiers.ChangeDetectorRef = { + name: 'ChangeDetectorRef', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'change_detection/change_detector_ref'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ChangeDetectorRef"] + }; + Identifiers.RenderComponentType = { + name: 'RenderComponentType', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'render/api'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["RenderComponentType"] + }; + Identifiers.QueryList = { + name: 'QueryList', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/query_list'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["QueryList"] + }; + Identifiers.TemplateRef = { + name: 'TemplateRef', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/template_ref'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["TemplateRef"] + }; + Identifiers.TemplateRef_ = { + name: 'TemplateRef_', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/template_ref'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["e" /* TemplateRef_ */] + }; + Identifiers.CodegenComponentFactoryResolver = { + name: 'CodegenComponentFactoryResolver', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/component_factory_resolver'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["f" /* CodegenComponentFactoryResolver */] + }; + Identifiers.ComponentFactoryResolver = { + name: 'ComponentFactoryResolver', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/component_factory_resolver'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ComponentFactoryResolver"] + }; + Identifiers.ComponentFactory = { + name: 'ComponentFactory', + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ComponentFactory"], + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/component_factory') + }; + Identifiers.NgModuleFactory = { + name: 'NgModuleFactory', + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["NgModuleFactory"], + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/ng_module_factory') + }; + Identifiers.NgModuleInjector = { + name: 'NgModuleInjector', + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["g" /* NgModuleInjector */], + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/ng_module_factory') + }; + Identifiers.RegisterModuleFactoryFn = { + name: 'registerModuleFactory', + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["h" /* registerModuleFactory */], + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/ng_module_factory_loader') + }; + Identifiers.ValueUnwrapper = { name: 'ValueUnwrapper', moduleUrl: CD_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["i" /* ValueUnwrapper */] }; + Identifiers.Injector = { + name: 'Injector', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'di/injector'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Injector"] + }; + Identifiers.ViewEncapsulation = { + name: 'ViewEncapsulation', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'metadata/view'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewEncapsulation"] + }; + Identifiers.ViewType = { + name: 'ViewType', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/view_type'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["j" /* ViewType */] + }; + Identifiers.ChangeDetectionStrategy = { + name: 'ChangeDetectionStrategy', + moduleUrl: CD_MODULE_URL, + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ChangeDetectionStrategy"] + }; + Identifiers.StaticNodeDebugInfo = { + name: 'StaticNodeDebugInfo', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/debug_context'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["k" /* StaticNodeDebugInfo */] + }; + Identifiers.DebugContext = { + name: 'DebugContext', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'linker/debug_context'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["l" /* DebugContext */] + }; + Identifiers.Renderer = { + name: 'Renderer', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'render/api'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Renderer"] + }; + Identifiers.SimpleChange = { name: 'SimpleChange', moduleUrl: CD_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["SimpleChange"] }; + Identifiers.UNINITIALIZED = { name: 'UNINITIALIZED', moduleUrl: CD_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["m" /* UNINITIALIZED */] }; + Identifiers.ChangeDetectorStatus = { + name: 'ChangeDetectorStatus', + moduleUrl: CD_MODULE_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["n" /* ChangeDetectorStatus */] + }; + Identifiers.checkBinding = { + name: 'checkBinding', + moduleUrl: VIEW_UTILS_MODULE_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["o" /* checkBinding */] + }; + Identifiers.flattenNestedViewRenderNodes = { + name: 'flattenNestedViewRenderNodes', + moduleUrl: VIEW_UTILS_MODULE_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["p" /* flattenNestedViewRenderNodes */] + }; + Identifiers.devModeEqual = { name: 'devModeEqual', moduleUrl: CD_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["q" /* devModeEqual */] }; + Identifiers.interpolate = { + name: 'interpolate', + moduleUrl: VIEW_UTILS_MODULE_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["r" /* interpolate */] + }; + Identifiers.castByValue = { + name: 'castByValue', + moduleUrl: VIEW_UTILS_MODULE_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["s" /* castByValue */] + }; + Identifiers.EMPTY_ARRAY = { + name: 'EMPTY_ARRAY', + moduleUrl: VIEW_UTILS_MODULE_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["t" /* EMPTY_ARRAY */] + }; + Identifiers.EMPTY_MAP = { name: 'EMPTY_MAP', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["u" /* EMPTY_MAP */] }; + Identifiers.pureProxies = [ + null, + { name: 'pureProxy1', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["v" /* pureProxy1 */] }, + { name: 'pureProxy2', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["w" /* pureProxy2 */] }, + { name: 'pureProxy3', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["x" /* pureProxy3 */] }, + { name: 'pureProxy4', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["y" /* pureProxy4 */] }, + { name: 'pureProxy5', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["z" /* pureProxy5 */] }, + { name: 'pureProxy6', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["A" /* pureProxy6 */] }, + { name: 'pureProxy7', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["B" /* pureProxy7 */] }, + { name: 'pureProxy8', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["C" /* pureProxy8 */] }, + { name: 'pureProxy9', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["D" /* pureProxy9 */] }, + { name: 'pureProxy10', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["E" /* pureProxy10 */] }, + ]; + Identifiers.SecurityContext = { + name: 'SecurityContext', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'security'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["SecurityContext"], + }; + Identifiers.AnimationKeyframe = { + name: 'AnimationKeyframe', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'animation/animation_keyframe'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["F" /* AnimationKeyframe */] + }; + Identifiers.AnimationStyles = { + name: 'AnimationStyles', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'animation/animation_styles'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["G" /* AnimationStyles */] + }; + Identifiers.NoOpAnimationPlayer = { + name: 'NoOpAnimationPlayer', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'animation/animation_player'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["H" /* NoOpAnimationPlayer */] + }; + Identifiers.AnimationGroupPlayer = { + name: 'AnimationGroupPlayer', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'animation/animation_group_player'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["I" /* AnimationGroupPlayer */] + }; + Identifiers.AnimationSequencePlayer = { + name: 'AnimationSequencePlayer', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'animation/animation_sequence_player'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["J" /* AnimationSequencePlayer */] + }; + Identifiers.prepareFinalAnimationStyles = { + name: 'prepareFinalAnimationStyles', + moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["K" /* prepareFinalAnimationStyles */] + }; + Identifiers.balanceAnimationKeyframes = { + name: 'balanceAnimationKeyframes', + moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["L" /* balanceAnimationKeyframes */] + }; + Identifiers.clearStyles = { + name: 'clearStyles', + moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["M" /* clearStyles */] + }; + Identifiers.renderStyles = { + name: 'renderStyles', + moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["N" /* renderStyles */] + }; + Identifiers.collectAndResolveStyles = { + name: 'collectAndResolveStyles', + moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL, + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["O" /* collectAndResolveStyles */] + }; + Identifiers.LOCALE_ID = { + name: 'LOCALE_ID', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'i18n/tokens'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["LOCALE_ID"] + }; + Identifiers.TRANSLATIONS_FORMAT = { + name: 'TRANSLATIONS_FORMAT', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'i18n/tokens'), + runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["TRANSLATIONS_FORMAT"] + }; + Identifiers.AnimationOutput = { + name: 'AnimationOutput', + moduleUrl: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* assetUrl */])('core', 'animation/animation_output'), + runtime: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["P" /* AnimationOutput */] + }; + return Identifiers; + }()); + function resolveIdentifier(identifier) { + return new __WEBPACK_IMPORTED_MODULE_1__compile_metadata__["a" /* CompileIdentifierMetadata */]({ + name: identifier.name, + moduleUrl: identifier.moduleUrl, + reference: __WEBPACK_IMPORTED_MODULE_2__private_import_core__["Q" /* reflector */].resolveIdentifier(identifier.name, identifier.moduleUrl, identifier.runtime) + }); + } + function identifierToken(identifier) { + return new __WEBPACK_IMPORTED_MODULE_1__compile_metadata__["b" /* CompileTokenMetadata */]({ identifier: identifier }); + } + function resolveIdentifierToken(identifier) { + return identifierToken(resolveIdentifier(identifier)); + } + function resolveEnumIdentifier(enumType, name) { + var resolvedEnum = __WEBPACK_IMPORTED_MODULE_2__private_import_core__["Q" /* reflector */].resolveEnum(enumType.reference, name); + return new __WEBPACK_IMPORTED_MODULE_1__compile_metadata__["a" /* CompileIdentifierMetadata */]({ name: enumType.name + "." + name, moduleUrl: enumType.moduleUrl, reference: resolvedEnum }); + } +//# sourceMappingURL=identifiers.js.map + + /***/ }, + /* 20 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(1); + /* harmony export (binding) */ __webpack_require__.d(exports, "Y", function() { return isDefaultChangeDetectionStrategy; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "n", function() { return ChangeDetectorStatus; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "X", function() { return LifecycleHooks; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "_0", function() { return LIFECYCLE_HOOKS_VALUES; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "Z", function() { return ReflectorReader; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "d", function() { return AppElement; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "f", function() { return CodegenComponentFactoryResolver; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return AppView; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return DebugAppView; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "g", function() { return NgModuleInjector; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "h", function() { return registerModuleFactory; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "j", function() { return ViewType; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "S", function() { return MAX_INTERPOLATION_VALUES; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "o", function() { return checkBinding; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "p", function() { return flattenNestedViewRenderNodes; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "r", function() { return interpolate; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "a", function() { return ViewUtils; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "l", function() { return DebugContext; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "k", function() { return StaticNodeDebugInfo; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "q", function() { return devModeEqual; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "m", function() { return UNINITIALIZED; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "i", function() { return ValueUnwrapper; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "e", function() { return TemplateRef_; }); + /* unused harmony export RenderDebugInfo */ + /* harmony export (binding) */ __webpack_require__.d(exports, "t", function() { return EMPTY_ARRAY; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "u", function() { return EMPTY_MAP; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "v", function() { return pureProxy1; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "w", function() { return pureProxy2; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "x", function() { return pureProxy3; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "y", function() { return pureProxy4; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "z", function() { return pureProxy5; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "A", function() { return pureProxy6; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "B", function() { return pureProxy7; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "C", function() { return pureProxy8; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "D", function() { return pureProxy9; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "E", function() { return pureProxy10; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "s", function() { return castByValue; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "R", function() { return Console; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "Q", function() { return reflector; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "_2", function() { return Reflector; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "_3", function() { return ReflectionCapabilities; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "H", function() { return NoOpAnimationPlayer; }); + /* unused harmony export AnimationPlayer */ + /* harmony export (binding) */ __webpack_require__.d(exports, "J", function() { return AnimationSequencePlayer; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "I", function() { return AnimationGroupPlayer; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "F", function() { return AnimationKeyframe; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "G", function() { return AnimationStyles; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "P", function() { return AnimationOutput; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "T", function() { return ANY_STATE; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "V", function() { return DEFAULT_STATE; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "W", function() { return EMPTY_STATE; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "U", function() { return FILL_STYLE_FLAG; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "K", function() { return prepareFinalAnimationStyles; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "L", function() { return balanceAnimationKeyframes; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "M", function() { return clearStyles; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "O", function() { return collectAndResolveStyles; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "N", function() { return renderStyles; }); + /* unused harmony export ViewMetadata */ + /* harmony export (binding) */ __webpack_require__.d(exports, "_1", function() { return ComponentStillLoadingError; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + + var isDefaultChangeDetectionStrategy = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].isDefaultChangeDetectionStrategy; + var ChangeDetectorStatus = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ChangeDetectorStatus; + __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].CHANGE_DETECTION_STRATEGY_VALUES; + var LifecycleHooks = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].LifecycleHooks; + var LIFECYCLE_HOOKS_VALUES = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].LIFECYCLE_HOOKS_VALUES; + var ReflectorReader = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ReflectorReader; + var AppElement = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].AppElement; + var CodegenComponentFactoryResolver = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].CodegenComponentFactoryResolver; + var AppView = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].AppView; + var DebugAppView = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].DebugAppView; + var NgModuleInjector = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].NgModuleInjector; + var registerModuleFactory = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].registerModuleFactory; + var ViewType = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ViewType; + var MAX_INTERPOLATION_VALUES = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].MAX_INTERPOLATION_VALUES; + var checkBinding = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].checkBinding; + var flattenNestedViewRenderNodes = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].flattenNestedViewRenderNodes; + var interpolate = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].interpolate; + var ViewUtils = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ViewUtils; + var DebugContext = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].DebugContext; + var StaticNodeDebugInfo = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].StaticNodeDebugInfo; + var devModeEqual = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].devModeEqual; + var UNINITIALIZED = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].UNINITIALIZED; + var ValueUnwrapper = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ValueUnwrapper; + var TemplateRef_ = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].TemplateRef_; + var RenderDebugInfo = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].RenderDebugInfo; + var EMPTY_ARRAY = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].EMPTY_ARRAY; + var EMPTY_MAP = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].EMPTY_MAP; + var pureProxy1 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy1; + var pureProxy2 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy2; + var pureProxy3 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy3; + var pureProxy4 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy4; + var pureProxy5 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy5; + var pureProxy6 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy6; + var pureProxy7 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy7; + var pureProxy8 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy8; + var pureProxy9 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy9; + var pureProxy10 = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].pureProxy10; + var castByValue = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].castByValue; + var Console = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].Console; + var reflector = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].reflector; + var Reflector = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].Reflector; + var ReflectionCapabilities = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ReflectionCapabilities; + var NoOpAnimationPlayer = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].NoOpAnimationPlayer; + var AnimationPlayer = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].AnimationPlayer; + var AnimationSequencePlayer = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].AnimationSequencePlayer; + var AnimationGroupPlayer = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].AnimationGroupPlayer; + var AnimationKeyframe = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].AnimationKeyframe; + var AnimationStyles = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].AnimationStyles; + var AnimationOutput = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].AnimationOutput; + var ANY_STATE = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ANY_STATE; + var DEFAULT_STATE = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].DEFAULT_STATE; + var EMPTY_STATE = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].EMPTY_STATE; + var FILL_STYLE_FLAG = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].FILL_STYLE_FLAG; + var prepareFinalAnimationStyles = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].prepareFinalAnimationStyles; + var balanceAnimationKeyframes = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].balanceAnimationKeyframes; + var clearStyles = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].clearStyles; + var collectAndResolveStyles = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].collectAndResolveStyles; + var renderStyles = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].renderStyles; + var ViewMetadata = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ViewMetadata; + var ComponentStillLoadingError = __WEBPACK_IMPORTED_MODULE_0__angular_core__["__core_private__"].ComponentStillLoadingError; +//# sourceMappingURL=private_import_core.js.map + + /***/ }, + /* 21 */ + /***/ function(module, exports, __webpack_require__) { + +// Thank's IE8 for his funny defineProperty + module.exports = !__webpack_require__(9)(function(){ + return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; + }); + + /***/ }, + /* 22 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + "use strict"; + var isArray_1 = __webpack_require__(48); + var isObject_1 = __webpack_require__(959); + var isFunction_1 = __webpack_require__(266); + var tryCatch_1 = __webpack_require__(24); + var errorObject_1 = __webpack_require__(23); + var UnsubscriptionError_1 = __webpack_require__(416); + /** + * Represents a disposable resource, such as the execution of an Observable. A + * Subscription has one important method, `unsubscribe`, that takes no argument + * and just disposes the resource held by the subscription. + * + * Additionally, subscriptions may be grouped together through the `add()` + * method, which will attach a child Subscription to the current Subscription. + * When a Subscription is unsubscribed, all its children (and its grandchildren) + * will be unsubscribed as well. + * + * @class Subscription + */ + var Subscription = (function () { + /** + * @param {function(): void} [unsubscribe] A function describing how to + * perform the disposal of resources when the `unsubscribe` method is called. + */ + function Subscription(unsubscribe) { + /** + * A flag to indicate whether this Subscription has already been unsubscribed. + * @type {boolean} + */ + this.closed = false; + if (unsubscribe) { + this._unsubscribe = unsubscribe; + } + } + /** + * Disposes the resources held by the subscription. May, for instance, cancel + * an ongoing Observable execution or cancel any other type of work that + * started when the Subscription was created. + * @return {void} + */ + Subscription.prototype.unsubscribe = function () { + var hasErrors = false; + var errors; + if (this.closed) { + return; + } + this.closed = true; + var _a = this, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions; + this._subscriptions = null; + if (isFunction_1.isFunction(_unsubscribe)) { + var trial = tryCatch_1.tryCatch(_unsubscribe).call(this); + if (trial === errorObject_1.errorObject) { + hasErrors = true; + (errors = errors || []).push(errorObject_1.errorObject.e); + } + } + if (isArray_1.isArray(_subscriptions)) { + var index = -1; + var len = _subscriptions.length; + while (++index < len) { + var sub = _subscriptions[index]; + if (isObject_1.isObject(sub)) { + var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub); + if (trial === errorObject_1.errorObject) { + hasErrors = true; + errors = errors || []; + var err = errorObject_1.errorObject.e; + if (err instanceof UnsubscriptionError_1.UnsubscriptionError) { + errors = errors.concat(err.errors); + } + else { + errors.push(err); + } + } + } + } + } + if (hasErrors) { + throw new UnsubscriptionError_1.UnsubscriptionError(errors); + } + }; + /** + * Adds a tear down to be called during the unsubscribe() of this + * Subscription. + * + * If the tear down being added is a subscription that is already + * unsubscribed, is the same reference `add` is being called on, or is + * `Subscription.EMPTY`, it will not be added. + * + * If this subscription is already in an `closed` state, the passed + * tear down logic will be executed immediately. + * + * @param {TeardownLogic} teardown The additional logic to execute on + * teardown. + * @return {Subscription} Returns the Subscription used or created to be + * added to the inner subscriptions list. This Subscription can be used with + * `remove()` to remove the passed teardown logic from the inner subscriptions + * list. + */ + Subscription.prototype.add = function (teardown) { + if (!teardown || (teardown === Subscription.EMPTY)) { + return Subscription.EMPTY; + } + if (teardown === this) { + return this; + } + var sub = teardown; + switch (typeof teardown) { + case 'function': + sub = new Subscription(teardown); + case 'object': + if (sub.closed || typeof sub.unsubscribe !== 'function') { + break; + } + else if (this.closed) { + sub.unsubscribe(); + } + else { + (this._subscriptions || (this._subscriptions = [])).push(sub); + } + break; + default: + throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.'); + } + return sub; + }; + /** + * Removes a Subscription from the internal list of subscriptions that will + * unsubscribe during the unsubscribe process of this Subscription. + * @param {Subscription} subscription The subscription to remove. + * @return {void} + */ + Subscription.prototype.remove = function (subscription) { + // HACK: This might be redundant because of the logic in `add()` + if (subscription == null || (subscription === this) || (subscription === Subscription.EMPTY)) { + return; + } + var subscriptions = this._subscriptions; + if (subscriptions) { + var subscriptionIndex = subscriptions.indexOf(subscription); + if (subscriptionIndex !== -1) { + subscriptions.splice(subscriptionIndex, 1); + } + } + }; + Subscription.EMPTY = (function (empty) { + empty.closed = true; + return empty; + }(new Subscription())); + return Subscription; + }()); + exports.Subscription = Subscription; +//# sourceMappingURL=Subscription.js.map + + /***/ }, + /* 23 */ + /***/ function(module, exports) { + + "use strict"; + "use strict"; +// typeof any so that it we don't have to cast when comparing a result to the error object + exports.errorObject = { e: {} }; +//# sourceMappingURL=errorObject.js.map + + /***/ }, + /* 24 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + "use strict"; + var errorObject_1 = __webpack_require__(23); + var tryCatchTarget; + function tryCatcher() { + try { + return tryCatchTarget.apply(this, arguments); + } + catch (e) { + errorObject_1.errorObject.e = e; + return errorObject_1.errorObject; + } + } + function tryCatch(fn) { + tryCatchTarget = fn; + return tryCatcher; + } + exports.tryCatch = tryCatch; + ; +//# sourceMappingURL=tryCatch.js.map + + /***/ }, + /* 25 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__facade_collection__ = __webpack_require__(13); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__facade_lang__ = __webpack_require__(4); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__selector__ = __webpack_require__(195); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util__ = __webpack_require__(29); + /* harmony export (binding) */ __webpack_require__.d(exports, "A", function() { return CompileMetadataWithIdentifier; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "r", function() { return CompileAnimationEntryMetadata; }); + /* unused harmony export CompileAnimationStateMetadata */ + /* harmony export (binding) */ __webpack_require__.d(exports, "g", function() { return CompileAnimationStateDeclarationMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "s", function() { return CompileAnimationStateTransitionMetadata; }); + /* unused harmony export CompileAnimationMetadata */ + /* harmony export (binding) */ __webpack_require__.d(exports, "m", function() { return CompileAnimationKeyframesSequenceMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "h", function() { return CompileAnimationStyleMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "l", function() { return CompileAnimationAnimateMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "k", function() { return CompileAnimationWithStepsMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "i", function() { return CompileAnimationSequenceMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "j", function() { return CompileAnimationGroupMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "a", function() { return CompileIdentifierMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return CompileDiDependencyMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "d", function() { return CompileProviderMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "v", function() { return CompileFactoryMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return CompileTokenMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "e", function() { return CompileTypeMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "y", function() { return CompileQueryMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "o", function() { return CompileStylesheetMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "p", function() { return CompileTemplateMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "q", function() { return CompileDirectiveMetadata; }); + /* harmony export (immutable) */ exports["n"] = createHostComponentMeta; + /* harmony export (binding) */ __webpack_require__.d(exports, "w", function() { return CompilePipeMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "t", function() { return CompileNgModuleMetadata; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "u", function() { return TransitiveCompileNgModuleMetadata; }); + /* harmony export (immutable) */ exports["f"] = removeIdentifierDuplicates; + /* harmony export (immutable) */ exports["z"] = isStaticSymbol; + /* harmony export (binding) */ __webpack_require__.d(exports, "x", function() { return ProviderMeta; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + + + + + + function unimplemented() { + throw new Error('unimplemented'); + } +// group 0: "[prop] or (event) or @trigger" +// group 1: "prop" from "[prop]" +// group 2: "event" from "(event)" +// group 3: "@trigger" from "@trigger" + var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/; + var UNDEFINED = new Object(); + var CompileMetadataWithIdentifier = (function () { + function CompileMetadataWithIdentifier() { + } + Object.defineProperty(CompileMetadataWithIdentifier.prototype, "identifier", { + get: function () { return unimplemented(); }, + enumerable: true, + configurable: true + }); + return CompileMetadataWithIdentifier; + }()); + var CompileAnimationEntryMetadata = (function () { + function CompileAnimationEntryMetadata(name, definitions) { + if (name === void 0) { name = null; } + if (definitions === void 0) { definitions = null; } + this.name = name; + this.definitions = definitions; + } + return CompileAnimationEntryMetadata; + }()); + var CompileAnimationStateMetadata = (function () { + function CompileAnimationStateMetadata() { + } + return CompileAnimationStateMetadata; + }()); + var CompileAnimationStateDeclarationMetadata = (function (_super) { + __extends(CompileAnimationStateDeclarationMetadata, _super); + function CompileAnimationStateDeclarationMetadata(stateNameExpr, styles) { + _super.call(this); + this.stateNameExpr = stateNameExpr; + this.styles = styles; + } + return CompileAnimationStateDeclarationMetadata; + }(CompileAnimationStateMetadata)); + var CompileAnimationStateTransitionMetadata = (function (_super) { + __extends(CompileAnimationStateTransitionMetadata, _super); + function CompileAnimationStateTransitionMetadata(stateChangeExpr, steps) { + _super.call(this); + this.stateChangeExpr = stateChangeExpr; + this.steps = steps; + } + return CompileAnimationStateTransitionMetadata; + }(CompileAnimationStateMetadata)); + var CompileAnimationMetadata = (function () { + function CompileAnimationMetadata() { + } + return CompileAnimationMetadata; + }()); + var CompileAnimationKeyframesSequenceMetadata = (function (_super) { + __extends(CompileAnimationKeyframesSequenceMetadata, _super); + function CompileAnimationKeyframesSequenceMetadata(steps) { + if (steps === void 0) { steps = []; } + _super.call(this); + this.steps = steps; + } + return CompileAnimationKeyframesSequenceMetadata; + }(CompileAnimationMetadata)); + var CompileAnimationStyleMetadata = (function (_super) { + __extends(CompileAnimationStyleMetadata, _super); + function CompileAnimationStyleMetadata(offset, styles) { + if (styles === void 0) { styles = null; } + _super.call(this); + this.offset = offset; + this.styles = styles; + } + return CompileAnimationStyleMetadata; + }(CompileAnimationMetadata)); + var CompileAnimationAnimateMetadata = (function (_super) { + __extends(CompileAnimationAnimateMetadata, _super); + function CompileAnimationAnimateMetadata(timings, styles) { + if (timings === void 0) { timings = 0; } + if (styles === void 0) { styles = null; } + _super.call(this); + this.timings = timings; + this.styles = styles; + } + return CompileAnimationAnimateMetadata; + }(CompileAnimationMetadata)); + var CompileAnimationWithStepsMetadata = (function (_super) { + __extends(CompileAnimationWithStepsMetadata, _super); + function CompileAnimationWithStepsMetadata(steps) { + if (steps === void 0) { steps = null; } + _super.call(this); + this.steps = steps; + } + return CompileAnimationWithStepsMetadata; + }(CompileAnimationMetadata)); + var CompileAnimationSequenceMetadata = (function (_super) { + __extends(CompileAnimationSequenceMetadata, _super); + function CompileAnimationSequenceMetadata(steps) { + if (steps === void 0) { steps = null; } + _super.call(this, steps); + } + return CompileAnimationSequenceMetadata; + }(CompileAnimationWithStepsMetadata)); + var CompileAnimationGroupMetadata = (function (_super) { + __extends(CompileAnimationGroupMetadata, _super); + function CompileAnimationGroupMetadata(steps) { + if (steps === void 0) { steps = null; } + _super.call(this, steps); + } + return CompileAnimationGroupMetadata; + }(CompileAnimationWithStepsMetadata)); + var CompileIdentifierMetadata = (function () { + function CompileIdentifierMetadata(_a) { + var _b = _a === void 0 ? {} : _a, reference = _b.reference, name = _b.name, moduleUrl = _b.moduleUrl, prefix = _b.prefix, value = _b.value; + this.reference = reference; + this.name = name; + this.prefix = prefix; + this.moduleUrl = moduleUrl; + this.value = value; + } + Object.defineProperty(CompileIdentifierMetadata.prototype, "identifier", { + get: function () { return this; }, + enumerable: true, + configurable: true + }); + return CompileIdentifierMetadata; + }()); + var CompileDiDependencyMetadata = (function () { + function CompileDiDependencyMetadata(_a) { + var _b = _a === void 0 ? {} : _a, isAttribute = _b.isAttribute, isSelf = _b.isSelf, isHost = _b.isHost, isSkipSelf = _b.isSkipSelf, isOptional = _b.isOptional, isValue = _b.isValue, query = _b.query, viewQuery = _b.viewQuery, token = _b.token, value = _b.value; + this.isAttribute = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(isAttribute); + this.isSelf = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(isSelf); + this.isHost = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(isHost); + this.isSkipSelf = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(isSkipSelf); + this.isOptional = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(isOptional); + this.isValue = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(isValue); + this.query = query; + this.viewQuery = viewQuery; + this.token = token; + this.value = value; + } + return CompileDiDependencyMetadata; + }()); + var CompileProviderMetadata = (function () { + function CompileProviderMetadata(_a) { + var token = _a.token, useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi; + this.token = token; + this.useClass = useClass; + this.useValue = useValue; + this.useExisting = useExisting; + this.useFactory = useFactory; + this.deps = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["k" /* normalizeBlank */])(deps); + this.multi = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(multi); + } + return CompileProviderMetadata; + }()); + var CompileFactoryMetadata = (function (_super) { + __extends(CompileFactoryMetadata, _super); + function CompileFactoryMetadata(_a) { + var reference = _a.reference, name = _a.name, moduleUrl = _a.moduleUrl, prefix = _a.prefix, diDeps = _a.diDeps, value = _a.value; + _super.call(this, { reference: reference, name: name, prefix: prefix, moduleUrl: moduleUrl, value: value }); + this.diDeps = _normalizeArray(diDeps); + } + return CompileFactoryMetadata; + }(CompileIdentifierMetadata)); + var CompileTokenMetadata = (function () { + function CompileTokenMetadata(_a) { + var value = _a.value, identifier = _a.identifier, identifierIsInstance = _a.identifierIsInstance; + this.value = value; + this.identifier = identifier; + this.identifierIsInstance = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(identifierIsInstance); + } + Object.defineProperty(CompileTokenMetadata.prototype, "reference", { + get: function () { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(this.identifier)) { + return this.identifier.reference; + } + else { + return this.value; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CompileTokenMetadata.prototype, "name", { + get: function () { + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(this.value) ? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__util__["a" /* sanitizeIdentifier */])(this.value) : this.identifier.name; + }, + enumerable: true, + configurable: true + }); + return CompileTokenMetadata; + }()); + /** + * Metadata regarding compilation of a type. + */ + var CompileTypeMetadata = (function (_super) { + __extends(CompileTypeMetadata, _super); + function CompileTypeMetadata(_a) { + var _b = _a === void 0 ? {} : _a, reference = _b.reference, name = _b.name, moduleUrl = _b.moduleUrl, prefix = _b.prefix, isHost = _b.isHost, value = _b.value, diDeps = _b.diDeps, lifecycleHooks = _b.lifecycleHooks; + _super.call(this, { reference: reference, name: name, moduleUrl: moduleUrl, prefix: prefix, value: value }); + this.isHost = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(isHost); + this.diDeps = _normalizeArray(diDeps); + this.lifecycleHooks = _normalizeArray(lifecycleHooks); + } + return CompileTypeMetadata; + }(CompileIdentifierMetadata)); + var CompileQueryMetadata = (function () { + function CompileQueryMetadata(_a) { + var _b = _a === void 0 ? {} : _a, selectors = _b.selectors, descendants = _b.descendants, first = _b.first, propertyName = _b.propertyName, read = _b.read; + this.selectors = selectors; + this.descendants = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(descendants); + this.first = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(first); + this.propertyName = propertyName; + this.read = read; + } + return CompileQueryMetadata; + }()); + /** + * Metadata about a stylesheet + */ + var CompileStylesheetMetadata = (function () { + function CompileStylesheetMetadata(_a) { + var _b = _a === void 0 ? {} : _a, moduleUrl = _b.moduleUrl, styles = _b.styles, styleUrls = _b.styleUrls; + this.moduleUrl = moduleUrl; + this.styles = _normalizeArray(styles); + this.styleUrls = _normalizeArray(styleUrls); + } + return CompileStylesheetMetadata; + }()); + /** + * Metadata regarding compilation of a template. + */ + var CompileTemplateMetadata = (function () { + function CompileTemplateMetadata(_a) { + var _b = _a === void 0 ? {} : _a, encapsulation = _b.encapsulation, template = _b.template, templateUrl = _b.templateUrl, styles = _b.styles, styleUrls = _b.styleUrls, externalStylesheets = _b.externalStylesheets, animations = _b.animations, ngContentSelectors = _b.ngContentSelectors, interpolation = _b.interpolation; + this.encapsulation = encapsulation; + this.template = template; + this.templateUrl = templateUrl; + this.styles = _normalizeArray(styles); + this.styleUrls = _normalizeArray(styleUrls); + this.externalStylesheets = _normalizeArray(externalStylesheets); + this.animations = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(animations) ? __WEBPACK_IMPORTED_MODULE_1__facade_collection__["a" /* ListWrapper */].flatten(animations) : []; + this.ngContentSelectors = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(ngContentSelectors) ? ngContentSelectors : []; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(interpolation) && interpolation.length != 2) { + throw new Error("'interpolation' should have a start and an end symbol."); + } + this.interpolation = interpolation; + } + return CompileTemplateMetadata; + }()); + /** + * Metadata regarding compilation of a directive. + */ + var CompileDirectiveMetadata = (function () { + function CompileDirectiveMetadata(_a) { + var _b = _a === void 0 ? {} : _a, type = _b.type, isComponent = _b.isComponent, selector = _b.selector, exportAs = _b.exportAs, changeDetection = _b.changeDetection, inputs = _b.inputs, outputs = _b.outputs, hostListeners = _b.hostListeners, hostProperties = _b.hostProperties, hostAttributes = _b.hostAttributes, providers = _b.providers, viewProviders = _b.viewProviders, queries = _b.queries, viewQueries = _b.viewQueries, entryComponents = _b.entryComponents, template = _b.template; + this.type = type; + this.isComponent = isComponent; + this.selector = selector; + this.exportAs = exportAs; + this.changeDetection = changeDetection; + this.inputs = inputs; + this.outputs = outputs; + this.hostListeners = hostListeners; + this.hostProperties = hostProperties; + this.hostAttributes = hostAttributes; + this.providers = _normalizeArray(providers); + this.viewProviders = _normalizeArray(viewProviders); + this.queries = _normalizeArray(queries); + this.viewQueries = _normalizeArray(viewQueries); + this.entryComponents = _normalizeArray(entryComponents); + this.template = template; + } + CompileDirectiveMetadata.create = function (_a) { + var _b = _a === void 0 ? {} : _a, type = _b.type, isComponent = _b.isComponent, selector = _b.selector, exportAs = _b.exportAs, changeDetection = _b.changeDetection, inputs = _b.inputs, outputs = _b.outputs, host = _b.host, providers = _b.providers, viewProviders = _b.viewProviders, queries = _b.queries, viewQueries = _b.viewQueries, entryComponents = _b.entryComponents, template = _b.template; + var hostListeners = {}; + var hostProperties = {}; + var hostAttributes = {}; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(host)) { + __WEBPACK_IMPORTED_MODULE_1__facade_collection__["b" /* StringMapWrapper */].forEach(host, function (value, key) { + var matches = key.match(HOST_REG_EXP); + if (matches === null) { + hostAttributes[key] = value; + } + else if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(matches[1])) { + hostProperties[matches[1]] = value; + } + else if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(matches[2])) { + hostListeners[matches[2]] = value; + } + }); + } + var inputsMap = {}; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(inputs)) { + inputs.forEach(function (bindConfig) { + // canonical syntax: `dirProp: elProp` + // if there is no `:`, use dirProp = elProp + var parts = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__util__["b" /* splitAtColon */])(bindConfig, [bindConfig, bindConfig]); + inputsMap[parts[0]] = parts[1]; + }); + } + var outputsMap = {}; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(outputs)) { + outputs.forEach(function (bindConfig) { + // canonical syntax: `dirProp: elProp` + // if there is no `:`, use dirProp = elProp + var parts = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__util__["b" /* splitAtColon */])(bindConfig, [bindConfig, bindConfig]); + outputsMap[parts[0]] = parts[1]; + }); + } + return new CompileDirectiveMetadata({ + type: type, + isComponent: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(isComponent), selector: selector, exportAs: exportAs, changeDetection: changeDetection, + inputs: inputsMap, + outputs: outputsMap, + hostListeners: hostListeners, + hostProperties: hostProperties, + hostAttributes: hostAttributes, + providers: providers, + viewProviders: viewProviders, + queries: queries, + viewQueries: viewQueries, + entryComponents: entryComponents, + template: template, + }); + }; + Object.defineProperty(CompileDirectiveMetadata.prototype, "identifier", { + get: function () { return this.type; }, + enumerable: true, + configurable: true + }); + return CompileDirectiveMetadata; + }()); + /** + * Construct {@link CompileDirectiveMetadata} from {@link ComponentTypeMetadata} and a selector. + */ + function createHostComponentMeta(compMeta) { + var template = __WEBPACK_IMPORTED_MODULE_3__selector__["a" /* CssSelector */].parse(compMeta.selector)[0].getMatchingElementTemplate(); + return CompileDirectiveMetadata.create({ + type: new CompileTypeMetadata({ + reference: Object, + name: compMeta.type.name + "_Host", + moduleUrl: compMeta.type.moduleUrl, + isHost: true + }), + template: new CompileTemplateMetadata({ + encapsulation: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewEncapsulation"].None, + template: template, + templateUrl: '', + styles: [], + styleUrls: [], + ngContentSelectors: [], + animations: [] + }), + changeDetection: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ChangeDetectionStrategy"].Default, + inputs: [], + outputs: [], + host: {}, + isComponent: true, + selector: '*', + providers: [], + viewProviders: [], + queries: [], + viewQueries: [] + }); + } + var CompilePipeMetadata = (function () { + function CompilePipeMetadata(_a) { + var _b = _a === void 0 ? {} : _a, type = _b.type, name = _b.name, pure = _b.pure; + this.type = type; + this.name = name; + this.pure = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["j" /* normalizeBool */])(pure); + } + Object.defineProperty(CompilePipeMetadata.prototype, "identifier", { + get: function () { return this.type; }, + enumerable: true, + configurable: true + }); + return CompilePipeMetadata; + }()); + /** + * Metadata regarding compilation of a directive. + */ + var CompileNgModuleMetadata = (function () { + function CompileNgModuleMetadata(_a) { + var _b = _a === void 0 ? {} : _a, type = _b.type, providers = _b.providers, declaredDirectives = _b.declaredDirectives, exportedDirectives = _b.exportedDirectives, declaredPipes = _b.declaredPipes, exportedPipes = _b.exportedPipes, entryComponents = _b.entryComponents, bootstrapComponents = _b.bootstrapComponents, importedModules = _b.importedModules, exportedModules = _b.exportedModules, schemas = _b.schemas, transitiveModule = _b.transitiveModule, id = _b.id; + this.type = type; + this.declaredDirectives = _normalizeArray(declaredDirectives); + this.exportedDirectives = _normalizeArray(exportedDirectives); + this.declaredPipes = _normalizeArray(declaredPipes); + this.exportedPipes = _normalizeArray(exportedPipes); + this.providers = _normalizeArray(providers); + this.entryComponents = _normalizeArray(entryComponents); + this.bootstrapComponents = _normalizeArray(bootstrapComponents); + this.importedModules = _normalizeArray(importedModules); + this.exportedModules = _normalizeArray(exportedModules); + this.schemas = _normalizeArray(schemas); + this.id = id; + this.transitiveModule = transitiveModule; + } + Object.defineProperty(CompileNgModuleMetadata.prototype, "identifier", { + get: function () { return this.type; }, + enumerable: true, + configurable: true + }); + return CompileNgModuleMetadata; + }()); + var TransitiveCompileNgModuleMetadata = (function () { + function TransitiveCompileNgModuleMetadata(modules, providers, entryComponents, directives, pipes) { + var _this = this; + this.modules = modules; + this.providers = providers; + this.entryComponents = entryComponents; + this.directives = directives; + this.pipes = pipes; + this.directivesSet = new Set(); + this.pipesSet = new Set(); + directives.forEach(function (dir) { return _this.directivesSet.add(dir.type.reference); }); + pipes.forEach(function (pipe) { return _this.pipesSet.add(pipe.type.reference); }); + } + return TransitiveCompileNgModuleMetadata; + }()); + function removeIdentifierDuplicates(items) { + var map = new Map(); + items.forEach(function (item) { + if (!map.get(item.identifier.reference)) { + map.set(item.identifier.reference, item); + } + }); + return __WEBPACK_IMPORTED_MODULE_1__facade_collection__["c" /* MapWrapper */].values(map); + } + function _normalizeArray(obj) { + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(obj) ? obj : []; + } + function isStaticSymbol(value) { + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["l" /* isStringMap */])(value) && __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(value['name']) && __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__facade_lang__["a" /* isPresent */])(value['filePath']); + } + var ProviderMeta = (function () { + function ProviderMeta(token, _a) { + var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi; + this.token = token; + this.useClass = useClass; + this.useValue = useValue; + this.useExisting = useExisting; + this.useFactory = useFactory; + this.dependencies = deps; + this.multi = !!multi; + } + return ProviderMeta; + }()); +//# sourceMappingURL=compile_metadata.js.map + + /***/ }, + /* 26 */ + /***/ function(module, exports, __webpack_require__) { + +// 7.1.15 ToLength + var toInteger = __webpack_require__(72) + , min = Math.min; + module.exports = function(it){ + return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 + }; + + /***/ }, + /* 27 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* WEBPACK VAR INJECTION */(function(global) {"use strict"; + var objectTypes = { + 'boolean': false, + 'function': true, + 'object': true, + 'number': false, + 'string': false, + 'undefined': false + }; + exports.root = (objectTypes[typeof self] && self) || (objectTypes[typeof window] && window); + var freeGlobal = objectTypes[typeof global] && global; + if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) { + exports.root = freeGlobal; + } +//# sourceMappingURL=root.js.map + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(64))) + + /***/ }, + /* 28 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* WEBPACK VAR INJECTION */(function(global) {/* unused harmony export scheduleMicroTask */ + /* unused harmony export global */ + /* harmony export (immutable) */ exports["f"] = getTypeNameForDebugging; + /* unused harmony export Math */ + /* unused harmony export Date */ + /* harmony export (immutable) */ exports["a"] = isPresent; + /* harmony export (immutable) */ exports["b"] = isBlank; + /* unused harmony export isBoolean */ + /* unused harmony export isNumber */ + /* unused harmony export isString */ + /* unused harmony export isFunction */ + /* unused harmony export isType */ + /* harmony export (immutable) */ exports["j"] = isStringMap; + /* unused harmony export isStrictStringMap */ + /* harmony export (immutable) */ exports["c"] = isArray; + /* harmony export (immutable) */ exports["i"] = isDate; + /* unused harmony export noop */ + /* harmony export (immutable) */ exports["g"] = stringify; + /* unused harmony export serializeEnum */ + /* unused harmony export deserializeEnum */ + /* unused harmony export resolveEnumToken */ + /* unused harmony export StringWrapper */ + /* unused harmony export StringJoiner */ + /* harmony export (binding) */ __webpack_require__.d(exports, "h", function() { return NumberWrapper; }); + /* unused harmony export RegExp */ + /* unused harmony export FunctionWrapper */ + /* unused harmony export looseIdentical */ + /* unused harmony export getMapKey */ + /* unused harmony export normalizeBlank */ + /* unused harmony export normalizeBool */ + /* harmony export (immutable) */ exports["d"] = isJsObject; + /* unused harmony export print */ + /* unused harmony export warn */ + /* harmony export (binding) */ __webpack_require__.d(exports, "k", function() { return Json; }); + /* unused harmony export DateWrapper */ + /* unused harmony export setValueOnPath */ + /* harmony export (immutable) */ exports["e"] = getSymbolIterator; + /* unused harmony export evalExpression */ + /* unused harmony export isPrimitive */ + /* unused harmony export hasConstructor */ + /* unused harmony export escape */ + /* unused harmony export escapeRegExp */ + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var globalScope; + if (typeof window === 'undefined') { + if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { + // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492 + globalScope = self; + } + else { + globalScope = global; + } + } + else { + globalScope = window; + } + function scheduleMicroTask(fn) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); + } +// Need to declare a new variable for global here since TypeScript +// exports the original value of the symbol. + var _global = globalScope; + + function getTypeNameForDebugging(type) { + if (type['name']) { + return type['name']; + } + return typeof type; + } + var Math = _global.Math; + var Date = _global.Date; +// TODO: remove calls to assert in production environment +// Note: Can't just export this and import in in other files +// as `assert` is a reserved keyword in Dart + _global.assert = function assert(condition) { + // TODO: to be fixed properly via #2830, noop for now + }; + function isPresent(obj) { + return obj !== undefined && obj !== null; + } + function isBlank(obj) { + return obj === undefined || obj === null; + } + function isBoolean(obj) { + return typeof obj === 'boolean'; + } + function isNumber(obj) { + return typeof obj === 'number'; + } + function isString(obj) { + return typeof obj === 'string'; + } + function isFunction(obj) { + return typeof obj === 'function'; + } + function isType(obj) { + return isFunction(obj); + } + function isStringMap(obj) { + return typeof obj === 'object' && obj !== null; + } + var STRING_MAP_PROTO = Object.getPrototypeOf({}); + function isStrictStringMap(obj) { + return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; + } + function isArray(obj) { + return Array.isArray(obj); + } + function isDate(obj) { + return obj instanceof Date && !isNaN(obj.valueOf()); + } + function noop() { } + function stringify(token) { + if (typeof token === 'string') { + return token; + } + if (token === undefined || token === null) { + return '' + token; + } + if (token.overriddenName) { + return token.overriddenName; + } + if (token.name) { + return token.name; + } + var res = token.toString(); + var newLineIndex = res.indexOf('\n'); + return (newLineIndex === -1) ? res : res.substring(0, newLineIndex); + } +// serialize / deserialize enum exist only for consistency with dart API +// enums in typescript don't need to be serialized + function serializeEnum(val) { + return val; + } + function deserializeEnum(val, values) { + return val; + } + function resolveEnumToken(enumValue, val) { + return enumValue[val]; + } + var StringWrapper = (function () { + function StringWrapper() { + } + StringWrapper.fromCharCode = function (code) { return String.fromCharCode(code); }; + StringWrapper.charCodeAt = function (s, index) { return s.charCodeAt(index); }; + StringWrapper.split = function (s, regExp) { return s.split(regExp); }; + StringWrapper.equals = function (s, s2) { return s === s2; }; + StringWrapper.stripLeft = function (s, charVal) { + if (s && s.length) { + var pos = 0; + for (var i = 0; i < s.length; i++) { + if (s[i] != charVal) + break; + pos++; + } + s = s.substring(pos); + } + return s; + }; + StringWrapper.stripRight = function (s, charVal) { + if (s && s.length) { + var pos = s.length; + for (var i = s.length - 1; i >= 0; i--) { + if (s[i] != charVal) + break; + pos--; + } + s = s.substring(0, pos); + } + return s; + }; + StringWrapper.replace = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.replaceAll = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.slice = function (s, from, to) { + if (from === void 0) { from = 0; } + if (to === void 0) { to = null; } + return s.slice(from, to === null ? undefined : to); + }; + StringWrapper.replaceAllMapped = function (s, from, cb) { + return s.replace(from, function () { + var matches = []; + for (var _i = 0; _i < arguments.length; _i++) { + matches[_i - 0] = arguments[_i]; + } + // Remove offset & string from the result array + matches.splice(-2, 2); + // The callback receives match, p1, ..., pn + return cb(matches); + }); + }; + StringWrapper.contains = function (s, substr) { return s.indexOf(substr) != -1; }; + StringWrapper.compare = function (a, b) { + if (a < b) { + return -1; + } + else if (a > b) { + return 1; + } + else { + return 0; + } + }; + return StringWrapper; + }()); + var StringJoiner = (function () { + function StringJoiner(parts) { + if (parts === void 0) { parts = []; } + this.parts = parts; + } + StringJoiner.prototype.add = function (part) { this.parts.push(part); }; + StringJoiner.prototype.toString = function () { return this.parts.join(''); }; + return StringJoiner; + }()); + var NumberWrapper = (function () { + function NumberWrapper() { + } + NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); }; + NumberWrapper.equal = function (a, b) { return a === b; }; + NumberWrapper.parseIntAutoRadix = function (text) { + var result = parseInt(text); + if (isNaN(result)) { + throw new Error('Invalid integer literal when parsing ' + text); + } + return result; + }; + NumberWrapper.parseInt = function (text, radix) { + if (radix == 10) { + if (/^(\-|\+)?[0-9]+$/.test(text)) { + return parseInt(text, radix); + } + } + else if (radix == 16) { + if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) { + return parseInt(text, radix); + } + } + else { + var result = parseInt(text, radix); + if (!isNaN(result)) { + return result; + } + } + throw new Error('Invalid integer literal when parsing ' + text + ' in base ' + radix); + }; + Object.defineProperty(NumberWrapper, "NaN", { + get: function () { return NaN; }, + enumerable: true, + configurable: true + }); + NumberWrapper.isNumeric = function (value) { return !isNaN(value - parseFloat(value)); }; + NumberWrapper.isNaN = function (value) { return isNaN(value); }; + NumberWrapper.isInteger = function (value) { return Number.isInteger(value); }; + return NumberWrapper; + }()); + var RegExp = _global.RegExp; + var FunctionWrapper = (function () { + function FunctionWrapper() { + } + FunctionWrapper.apply = function (fn, posArgs) { return fn.apply(null, posArgs); }; + FunctionWrapper.bind = function (fn, scope) { return fn.bind(scope); }; + return FunctionWrapper; + }()); +// JS has NaN !== NaN + function looseIdentical(a, b) { + return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); + } +// JS considers NaN is the same as NaN for map Key (while NaN !== NaN otherwise) +// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map + function getMapKey(value) { + return value; + } + function normalizeBlank(obj) { + return isBlank(obj) ? null : obj; + } + function normalizeBool(obj) { + return isBlank(obj) ? false : obj; + } + function isJsObject(o) { + return o !== null && (typeof o === 'function' || typeof o === 'object'); + } + function print(obj) { + console.log(obj); + } + function warn(obj) { + console.warn(obj); + } +// Can't be all uppercase as our transpiler would think it is a special directive... + var Json = (function () { + function Json() { + } + Json.parse = function (s) { return _global.JSON.parse(s); }; + Json.stringify = function (data) { + // Dart doesn't take 3 arguments + return _global.JSON.stringify(data, null, 2); + }; + return Json; + }()); + var DateWrapper = (function () { + function DateWrapper() { + } + DateWrapper.create = function (year, month, day, hour, minutes, seconds, milliseconds) { + if (month === void 0) { month = 1; } + if (day === void 0) { day = 1; } + if (hour === void 0) { hour = 0; } + if (minutes === void 0) { minutes = 0; } + if (seconds === void 0) { seconds = 0; } + if (milliseconds === void 0) { milliseconds = 0; } + return new Date(year, month - 1, day, hour, minutes, seconds, milliseconds); + }; + DateWrapper.fromISOString = function (str) { return new Date(str); }; + DateWrapper.fromMillis = function (ms) { return new Date(ms); }; + DateWrapper.toMillis = function (date) { return date.getTime(); }; + DateWrapper.now = function () { return new Date(); }; + DateWrapper.toJson = function (date) { return date.toJSON(); }; + return DateWrapper; + }()); + function setValueOnPath(global, path, value) { + var parts = path.split('.'); + var obj = global; + while (parts.length > 1) { + var name = parts.shift(); + if (obj.hasOwnProperty(name) && isPresent(obj[name])) { + obj = obj[name]; + } + else { + obj = obj[name] = {}; + } + } + if (obj === undefined || obj === null) { + obj = {}; + } + obj[parts.shift()] = value; + } + var _symbolIterator = null; + function getSymbolIterator() { + if (isBlank(_symbolIterator)) { + if (isPresent(globalScope.Symbol) && isPresent(Symbol.iterator)) { + _symbolIterator = Symbol.iterator; + } + else { + // es6-shim specific logic + var keys = Object.getOwnPropertyNames(Map.prototype); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (key !== 'entries' && key !== 'size' && + Map.prototype[key] === Map.prototype['entries']) { + _symbolIterator = key; + } + } + } + } + return _symbolIterator; + } + function evalExpression(sourceUrl, expr, declarations, vars) { + var fnBody = declarations + "\nreturn " + expr + "\n//# sourceURL=" + sourceUrl; + var fnArgNames = []; + var fnArgValues = []; + for (var argName in vars) { + fnArgNames.push(argName); + fnArgValues.push(vars[argName]); + } + return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues); + } + function isPrimitive(obj) { + return !isJsObject(obj); + } + function hasConstructor(value, type) { + return value.constructor === type; + } + function escape(s) { + return _global.encodeURI(s); + } + function escapeRegExp(s) { + return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); + } +//# sourceMappingURL=lang.js.map + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(64))) + + /***/ }, + /* 29 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__facade_collection__ = __webpack_require__(13); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__facade_lang__ = __webpack_require__(4); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__output_output_ast__ = __webpack_require__(12); + /* harmony export (binding) */ __webpack_require__.d(exports, "h", function() { return MODULE_SUFFIX; }); + /* harmony export (immutable) */ exports["f"] = camelCaseToDashCase; + /* harmony export (immutable) */ exports["b"] = splitAtColon; + /* harmony export (immutable) */ exports["a"] = sanitizeIdentifier; + /* harmony export (immutable) */ exports["d"] = visitValue; + /* harmony export (binding) */ __webpack_require__.d(exports, "i", function() { return ValueTransformer; }); + /* harmony export (immutable) */ exports["c"] = assetUrl; + /* harmony export (immutable) */ exports["e"] = createDiTokenExpression; + /* harmony export (binding) */ __webpack_require__.d(exports, "g", function() { return SyncAsyncResult; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + + + + var MODULE_SUFFIX = ''; + var CAMEL_CASE_REGEXP = /([A-Z])/g; + function camelCaseToDashCase(input) { + return __WEBPACK_IMPORTED_MODULE_1__facade_lang__["f" /* StringWrapper */].replaceAllMapped(input, CAMEL_CASE_REGEXP, function (m) { return '-' + m[1].toLowerCase(); }); + } + function splitAtColon(input, defaultValues) { + var colonIndex = input.indexOf(':'); + if (colonIndex == -1) + return defaultValues; + return [input.slice(0, colonIndex).trim(), input.slice(colonIndex + 1).trim()]; + } + function sanitizeIdentifier(name) { + return __WEBPACK_IMPORTED_MODULE_1__facade_lang__["f" /* StringWrapper */].replaceAll(name, /\W/g, '_'); + } + function visitValue(value, visitor, context) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isArray */])(value)) { + return visitor.visitArray(value, context); + } + else if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["h" /* isStrictStringMap */])(value)) { + return visitor.visitStringMap(value, context); + } + else if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["b" /* isBlank */])(value) || __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["i" /* isPrimitive */])(value)) { + return visitor.visitPrimitive(value, context); + } + else { + return visitor.visitOther(value, context); + } + } + var ValueTransformer = (function () { + function ValueTransformer() { + } + ValueTransformer.prototype.visitArray = function (arr, context) { + var _this = this; + return arr.map(function (value) { return visitValue(value, _this, context); }); + }; + ValueTransformer.prototype.visitStringMap = function (map, context) { + var _this = this; + var result = {}; + __WEBPACK_IMPORTED_MODULE_0__facade_collection__["b" /* StringMapWrapper */].forEach(map, function (value /** TODO #9100 */, key /** TODO #9100 */) { + result[key] = visitValue(value, _this, context); + }); + return result; + }; + ValueTransformer.prototype.visitPrimitive = function (value, context) { return value; }; + ValueTransformer.prototype.visitOther = function (value, context) { return value; }; + return ValueTransformer; + }()); + function assetUrl(pkg, path, type) { + if (path === void 0) { path = null; } + if (type === void 0) { type = 'src'; } + if (path == null) { + return "asset:@angular/lib/" + pkg + "/index"; + } + else { + return "asset:@angular/lib/" + pkg + "/src/" + path; + } + } + function createDiTokenExpression(token) { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["a" /* isPresent */])(token.value)) { + return __WEBPACK_IMPORTED_MODULE_2__output_output_ast__["a" /* literal */](token.value); + } + else if (token.identifierIsInstance) { + return __WEBPACK_IMPORTED_MODULE_2__output_output_ast__["b" /* importExpr */](token.identifier) + .instantiate([], __WEBPACK_IMPORTED_MODULE_2__output_output_ast__["c" /* importType */](token.identifier, [], [__WEBPACK_IMPORTED_MODULE_2__output_output_ast__["d" /* TypeModifier */].Const])); + } + else { + return __WEBPACK_IMPORTED_MODULE_2__output_output_ast__["b" /* importExpr */](token.identifier); + } + } + var SyncAsyncResult = (function () { + function SyncAsyncResult(syncResult, asyncResult) { + if (asyncResult === void 0) { asyncResult = null; } + this.syncResult = syncResult; + this.asyncResult = asyncResult; + if (!asyncResult) { + this.asyncResult = Promise.resolve(syncResult); + } + } + return SyncAsyncResult; + }()); +//# sourceMappingURL=util.js.map + + /***/ }, + /* 30 */, + /* 31 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* WEBPACK VAR INJECTION */(function(global) {/* unused harmony export scheduleMicroTask */ + /* harmony export (binding) */ __webpack_require__.d(exports, "j", function() { return _global; }); + /* unused harmony export getTypeNameForDebugging */ + /* unused harmony export Math */ + /* unused harmony export Date */ + /* harmony export (immutable) */ exports["a"] = isPresent; + /* harmony export (immutable) */ exports["b"] = isBlank; + /* unused harmony export isBoolean */ + /* harmony export (immutable) */ exports["g"] = isNumber; + /* harmony export (immutable) */ exports["l"] = isString; + /* harmony export (immutable) */ exports["h"] = isFunction; + /* unused harmony export isType */ + /* unused harmony export isStringMap */ + /* unused harmony export isStrictStringMap */ + /* harmony export (immutable) */ exports["c"] = isArray; + /* unused harmony export isDate */ + /* unused harmony export noop */ + /* harmony export (immutable) */ exports["n"] = stringify; + /* unused harmony export serializeEnum */ + /* unused harmony export deserializeEnum */ + /* unused harmony export resolveEnumToken */ + /* harmony export (binding) */ __webpack_require__.d(exports, "f", function() { return StringWrapper; }); + /* unused harmony export StringJoiner */ + /* harmony export (binding) */ __webpack_require__.d(exports, "o", function() { return NumberWrapper; }); + /* unused harmony export RegExp */ + /* unused harmony export FunctionWrapper */ + /* unused harmony export looseIdentical */ + /* unused harmony export getMapKey */ + /* unused harmony export normalizeBlank */ + /* unused harmony export normalizeBool */ + /* harmony export (immutable) */ exports["d"] = isJsObject; + /* unused harmony export print */ + /* unused harmony export warn */ + /* harmony export (binding) */ __webpack_require__.d(exports, "m", function() { return Json; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "k", function() { return DateWrapper; }); + /* harmony export (immutable) */ exports["i"] = setValueOnPath; + /* harmony export (immutable) */ exports["e"] = getSymbolIterator; + /* unused harmony export evalExpression */ + /* unused harmony export isPrimitive */ + /* unused harmony export hasConstructor */ + /* unused harmony export escape */ + /* unused harmony export escapeRegExp */ + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var globalScope; + if (typeof window === 'undefined') { + if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { + // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492 + globalScope = self; + } + else { + globalScope = global; + } + } + else { + globalScope = window; + } + function scheduleMicroTask(fn) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); + } +// Need to declare a new variable for global here since TypeScript +// exports the original value of the symbol. + var _global = globalScope; + + function getTypeNameForDebugging(type) { + if (type['name']) { + return type['name']; + } + return typeof type; + } + var Math = _global.Math; + var Date = _global.Date; +// TODO: remove calls to assert in production environment +// Note: Can't just export this and import in in other files +// as `assert` is a reserved keyword in Dart + _global.assert = function assert(condition) { + // TODO: to be fixed properly via #2830, noop for now + }; + function isPresent(obj) { + return obj !== undefined && obj !== null; + } + function isBlank(obj) { + return obj === undefined || obj === null; + } + function isBoolean(obj) { + return typeof obj === 'boolean'; + } + function isNumber(obj) { + return typeof obj === 'number'; + } + function isString(obj) { + return typeof obj === 'string'; + } + function isFunction(obj) { + return typeof obj === 'function'; + } + function isType(obj) { + return isFunction(obj); + } + function isStringMap(obj) { + return typeof obj === 'object' && obj !== null; + } + var STRING_MAP_PROTO = Object.getPrototypeOf({}); + function isStrictStringMap(obj) { + return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; + } + function isArray(obj) { + return Array.isArray(obj); + } + function isDate(obj) { + return obj instanceof Date && !isNaN(obj.valueOf()); + } + function noop() { } + function stringify(token) { + if (typeof token === 'string') { + return token; + } + if (token === undefined || token === null) { + return '' + token; + } + if (token.overriddenName) { + return token.overriddenName; + } + if (token.name) { + return token.name; + } + var res = token.toString(); + var newLineIndex = res.indexOf('\n'); + return (newLineIndex === -1) ? res : res.substring(0, newLineIndex); + } +// serialize / deserialize enum exist only for consistency with dart API +// enums in typescript don't need to be serialized + function serializeEnum(val) { + return val; + } + function deserializeEnum(val, values) { + return val; + } + function resolveEnumToken(enumValue, val) { + return enumValue[val]; + } + var StringWrapper = (function () { + function StringWrapper() { + } + StringWrapper.fromCharCode = function (code) { return String.fromCharCode(code); }; + StringWrapper.charCodeAt = function (s, index) { return s.charCodeAt(index); }; + StringWrapper.split = function (s, regExp) { return s.split(regExp); }; + StringWrapper.equals = function (s, s2) { return s === s2; }; + StringWrapper.stripLeft = function (s, charVal) { + if (s && s.length) { + var pos = 0; + for (var i = 0; i < s.length; i++) { + if (s[i] != charVal) + break; + pos++; + } + s = s.substring(pos); + } + return s; + }; + StringWrapper.stripRight = function (s, charVal) { + if (s && s.length) { + var pos = s.length; + for (var i = s.length - 1; i >= 0; i--) { + if (s[i] != charVal) + break; + pos--; + } + s = s.substring(0, pos); + } + return s; + }; + StringWrapper.replace = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.replaceAll = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.slice = function (s, from, to) { + if (from === void 0) { from = 0; } + if (to === void 0) { to = null; } + return s.slice(from, to === null ? undefined : to); + }; + StringWrapper.replaceAllMapped = function (s, from, cb) { + return s.replace(from, function () { + var matches = []; + for (var _i = 0; _i < arguments.length; _i++) { + matches[_i - 0] = arguments[_i]; + } + // Remove offset & string from the result array + matches.splice(-2, 2); + // The callback receives match, p1, ..., pn + return cb(matches); + }); + }; + StringWrapper.contains = function (s, substr) { return s.indexOf(substr) != -1; }; + StringWrapper.compare = function (a, b) { + if (a < b) { + return -1; + } + else if (a > b) { + return 1; + } + else { + return 0; + } + }; + return StringWrapper; + }()); + var StringJoiner = (function () { + function StringJoiner(parts) { + if (parts === void 0) { parts = []; } + this.parts = parts; + } + StringJoiner.prototype.add = function (part) { this.parts.push(part); }; + StringJoiner.prototype.toString = function () { return this.parts.join(''); }; + return StringJoiner; + }()); + var NumberWrapper = (function () { + function NumberWrapper() { + } + NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); }; + NumberWrapper.equal = function (a, b) { return a === b; }; + NumberWrapper.parseIntAutoRadix = function (text) { + var result = parseInt(text); + if (isNaN(result)) { + throw new Error('Invalid integer literal when parsing ' + text); + } + return result; + }; + NumberWrapper.parseInt = function (text, radix) { + if (radix == 10) { + if (/^(\-|\+)?[0-9]+$/.test(text)) { + return parseInt(text, radix); + } + } + else if (radix == 16) { + if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) { + return parseInt(text, radix); + } + } + else { + var result = parseInt(text, radix); + if (!isNaN(result)) { + return result; + } + } + throw new Error('Invalid integer literal when parsing ' + text + ' in base ' + radix); + }; + Object.defineProperty(NumberWrapper, "NaN", { + get: function () { return NaN; }, + enumerable: true, + configurable: true + }); + NumberWrapper.isNumeric = function (value) { return !isNaN(value - parseFloat(value)); }; + NumberWrapper.isNaN = function (value) { return isNaN(value); }; + NumberWrapper.isInteger = function (value) { return Number.isInteger(value); }; + return NumberWrapper; + }()); + var RegExp = _global.RegExp; + var FunctionWrapper = (function () { + function FunctionWrapper() { + } + FunctionWrapper.apply = function (fn, posArgs) { return fn.apply(null, posArgs); }; + FunctionWrapper.bind = function (fn, scope) { return fn.bind(scope); }; + return FunctionWrapper; + }()); +// JS has NaN !== NaN + function looseIdentical(a, b) { + return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); + } +// JS considers NaN is the same as NaN for map Key (while NaN !== NaN otherwise) +// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map + function getMapKey(value) { + return value; + } + function normalizeBlank(obj) { + return isBlank(obj) ? null : obj; + } + function normalizeBool(obj) { + return isBlank(obj) ? false : obj; + } + function isJsObject(o) { + return o !== null && (typeof o === 'function' || typeof o === 'object'); + } + function print(obj) { + console.log(obj); + } + function warn(obj) { + console.warn(obj); + } +// Can't be all uppercase as our transpiler would think it is a special directive... + var Json = (function () { + function Json() { + } + Json.parse = function (s) { return _global.JSON.parse(s); }; + Json.stringify = function (data) { + // Dart doesn't take 3 arguments + return _global.JSON.stringify(data, null, 2); + }; + return Json; + }()); + var DateWrapper = (function () { + function DateWrapper() { + } + DateWrapper.create = function (year, month, day, hour, minutes, seconds, milliseconds) { + if (month === void 0) { month = 1; } + if (day === void 0) { day = 1; } + if (hour === void 0) { hour = 0; } + if (minutes === void 0) { minutes = 0; } + if (seconds === void 0) { seconds = 0; } + if (milliseconds === void 0) { milliseconds = 0; } + return new Date(year, month - 1, day, hour, minutes, seconds, milliseconds); + }; + DateWrapper.fromISOString = function (str) { return new Date(str); }; + DateWrapper.fromMillis = function (ms) { return new Date(ms); }; + DateWrapper.toMillis = function (date) { return date.getTime(); }; + DateWrapper.now = function () { return new Date(); }; + DateWrapper.toJson = function (date) { return date.toJSON(); }; + return DateWrapper; + }()); + function setValueOnPath(global, path, value) { + var parts = path.split('.'); + var obj = global; + while (parts.length > 1) { + var name = parts.shift(); + if (obj.hasOwnProperty(name) && isPresent(obj[name])) { + obj = obj[name]; + } + else { + obj = obj[name] = {}; + } + } + if (obj === undefined || obj === null) { + obj = {}; + } + obj[parts.shift()] = value; + } + var _symbolIterator = null; + function getSymbolIterator() { + if (isBlank(_symbolIterator)) { + if (isPresent(globalScope.Symbol) && isPresent(Symbol.iterator)) { + _symbolIterator = Symbol.iterator; + } + else { + // es6-shim specific logic + var keys = Object.getOwnPropertyNames(Map.prototype); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (key !== 'entries' && key !== 'size' && + Map.prototype[key] === Map.prototype['entries']) { + _symbolIterator = key; + } + } + } + } + return _symbolIterator; + } + function evalExpression(sourceUrl, expr, declarations, vars) { + var fnBody = declarations + "\nreturn " + expr + "\n//# sourceURL=" + sourceUrl; + var fnArgNames = []; + var fnArgValues = []; + for (var argName in vars) { + fnArgNames.push(argName); + fnArgValues.push(vars[argName]); + } + return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues); + } + function isPrimitive(obj) { + return !isJsObject(obj); + } + function hasConstructor(value, type) { + return value.constructor === type; + } + function escape(s) { + return _global.encodeURI(s); + } + function escapeRegExp(s) { + return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); + } +//# sourceMappingURL=lang.js.map + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(64))) + + /***/ }, + /* 32 */ + /***/ function(module, exports) { + + var hasOwnProperty = {}.hasOwnProperty; + module.exports = function(it, key){ + return hasOwnProperty.call(it, key); + }; + + /***/ }, + /* 33 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + "use strict"; + var AsyncAction_1 = __webpack_require__(122); + var AsyncScheduler_1 = __webpack_require__(123); + exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction); +//# sourceMappingURL=async.js.map + + /***/ }, + /* 34 */ + /***/ function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(2) + , fails = __webpack_require__(9) + , defined = __webpack_require__(59) + , quot = /"/g; +// B.2.3.2.1 CreateHTML(string, tag, attribute, value) + var createHTML = function(string, tag, attribute, value) { + var S = String(defined(string)) + , p1 = '<' + tag; + if(attribute !== '')p1 += ' ' + attribute + '="' + String(value).replace(quot, '"') + '"'; + return p1 + '>' + S + ''; + }; + module.exports = function(NAME, exec){ + var O = {}; + O[NAME] = exec(createHTML); + $export($export.P + $export.F * fails(function(){ + var test = ''[NAME]('"'); + return test !== test.toLowerCase() || test.split('"').length > 3; + }), 'String', O); + }; + + /***/ }, + /* 35 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony export (immutable) */ exports["a"] = unimplemented; + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return BaseError; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return WrappedError; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + function unimplemented() { + throw new Error('unimplemented'); + } + /** + * @stable + */ + var BaseError = (function (_super) { + __extends(BaseError, _super); + function BaseError(message) { + // Errors don't use current this, instead they create a new instance. + // We have to do forward all of our api to the nativeInstance. + var nativeError = _super.call(this, message); + this._nativeError = nativeError; + } + Object.defineProperty(BaseError.prototype, "message", { + get: function () { return this._nativeError.message; }, + set: function (message) { this._nativeError.message = message; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseError.prototype, "name", { + get: function () { return this._nativeError.name; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseError.prototype, "stack", { + get: function () { return this._nativeError.stack; }, + set: function (value) { this._nativeError.stack = value; }, + enumerable: true, + configurable: true + }); + BaseError.prototype.toString = function () { return this._nativeError.toString(); }; + return BaseError; + }(Error)); + /** + * @stable + */ + var WrappedError = (function (_super) { + __extends(WrappedError, _super); + function WrappedError(message, error) { + _super.call(this, message + " caused by: " + (error instanceof Error ? error.message : error)); + this.originalError = error; + } + Object.defineProperty(WrappedError.prototype, "stack", { + get: function () { + return (this.originalError instanceof Error ? this.originalError : this._nativeError) + .stack; + }, + enumerable: true, + configurable: true + }); + return WrappedError; + }(BaseError)); +//# sourceMappingURL=errors.js.map + + /***/ }, + /* 36 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* WEBPACK VAR INJECTION */(function(global) {/* unused harmony export scheduleMicroTask */ + /* harmony export (binding) */ __webpack_require__.d(exports, "h", function() { return _global; }); + /* unused harmony export getTypeNameForDebugging */ + /* unused harmony export Math */ + /* unused harmony export Date */ + /* harmony export (immutable) */ exports["a"] = isPresent; + /* harmony export (immutable) */ exports["b"] = isBlank; + /* unused harmony export isBoolean */ + /* unused harmony export isNumber */ + /* harmony export (immutable) */ exports["f"] = isString; + /* unused harmony export isFunction */ + /* unused harmony export isType */ + /* unused harmony export isStringMap */ + /* unused harmony export isStrictStringMap */ + /* harmony export (immutable) */ exports["c"] = isArray; + /* unused harmony export isDate */ + /* unused harmony export noop */ + /* unused harmony export stringify */ + /* unused harmony export serializeEnum */ + /* unused harmony export deserializeEnum */ + /* unused harmony export resolveEnumToken */ + /* harmony export (binding) */ __webpack_require__.d(exports, "i", function() { return StringWrapper; }); + /* unused harmony export StringJoiner */ + /* unused harmony export NumberWrapper */ + /* unused harmony export RegExp */ + /* unused harmony export FunctionWrapper */ + /* unused harmony export looseIdentical */ + /* unused harmony export getMapKey */ + /* unused harmony export normalizeBlank */ + /* unused harmony export normalizeBool */ + /* harmony export (immutable) */ exports["d"] = isJsObject; + /* unused harmony export print */ + /* unused harmony export warn */ + /* harmony export (binding) */ __webpack_require__.d(exports, "g", function() { return Json; }); + /* unused harmony export DateWrapper */ + /* unused harmony export setValueOnPath */ + /* harmony export (immutable) */ exports["e"] = getSymbolIterator; + /* unused harmony export evalExpression */ + /* unused harmony export isPrimitive */ + /* unused harmony export hasConstructor */ + /* unused harmony export escape */ + /* unused harmony export escapeRegExp */ + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var globalScope; + if (typeof window === 'undefined') { + if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { + // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492 + globalScope = self; + } + else { + globalScope = global; + } + } + else { + globalScope = window; + } + function scheduleMicroTask(fn) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); + } +// Need to declare a new variable for global here since TypeScript +// exports the original value of the symbol. + var _global = globalScope; + + function getTypeNameForDebugging(type) { + if (type['name']) { + return type['name']; + } + return typeof type; + } + var Math = _global.Math; + var Date = _global.Date; +// TODO: remove calls to assert in production environment +// Note: Can't just export this and import in in other files +// as `assert` is a reserved keyword in Dart + _global.assert = function assert(condition) { + // TODO: to be fixed properly via #2830, noop for now + }; + function isPresent(obj) { + return obj !== undefined && obj !== null; + } + function isBlank(obj) { + return obj === undefined || obj === null; + } + function isBoolean(obj) { + return typeof obj === 'boolean'; + } + function isNumber(obj) { + return typeof obj === 'number'; + } + function isString(obj) { + return typeof obj === 'string'; + } + function isFunction(obj) { + return typeof obj === 'function'; + } + function isType(obj) { + return isFunction(obj); + } + function isStringMap(obj) { + return typeof obj === 'object' && obj !== null; + } + var STRING_MAP_PROTO = Object.getPrototypeOf({}); + function isStrictStringMap(obj) { + return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; + } + function isArray(obj) { + return Array.isArray(obj); + } + function isDate(obj) { + return obj instanceof Date && !isNaN(obj.valueOf()); + } + function noop() { } + function stringify(token) { + if (typeof token === 'string') { + return token; + } + if (token === undefined || token === null) { + return '' + token; + } + if (token.overriddenName) { + return token.overriddenName; + } + if (token.name) { + return token.name; + } + var res = token.toString(); + var newLineIndex = res.indexOf('\n'); + return (newLineIndex === -1) ? res : res.substring(0, newLineIndex); + } +// serialize / deserialize enum exist only for consistency with dart API +// enums in typescript don't need to be serialized + function serializeEnum(val) { + return val; + } + function deserializeEnum(val, values) { + return val; + } + function resolveEnumToken(enumValue, val) { + return enumValue[val]; + } + var StringWrapper = (function () { + function StringWrapper() { + } + StringWrapper.fromCharCode = function (code) { return String.fromCharCode(code); }; + StringWrapper.charCodeAt = function (s, index) { return s.charCodeAt(index); }; + StringWrapper.split = function (s, regExp) { return s.split(regExp); }; + StringWrapper.equals = function (s, s2) { return s === s2; }; + StringWrapper.stripLeft = function (s, charVal) { + if (s && s.length) { + var pos = 0; + for (var i = 0; i < s.length; i++) { + if (s[i] != charVal) + break; + pos++; + } + s = s.substring(pos); + } + return s; + }; + StringWrapper.stripRight = function (s, charVal) { + if (s && s.length) { + var pos = s.length; + for (var i = s.length - 1; i >= 0; i--) { + if (s[i] != charVal) + break; + pos--; + } + s = s.substring(0, pos); + } + return s; + }; + StringWrapper.replace = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.replaceAll = function (s, from, replace) { + return s.replace(from, replace); + }; + StringWrapper.slice = function (s, from, to) { + if (from === void 0) { from = 0; } + if (to === void 0) { to = null; } + return s.slice(from, to === null ? undefined : to); + }; + StringWrapper.replaceAllMapped = function (s, from, cb) { + return s.replace(from, function () { + var matches = []; + for (var _i = 0; _i < arguments.length; _i++) { + matches[_i - 0] = arguments[_i]; + } + // Remove offset & string from the result array + matches.splice(-2, 2); + // The callback receives match, p1, ..., pn + return cb(matches); + }); + }; + StringWrapper.contains = function (s, substr) { return s.indexOf(substr) != -1; }; + StringWrapper.compare = function (a, b) { + if (a < b) { + return -1; + } + else if (a > b) { + return 1; + } + else { + return 0; + } + }; + return StringWrapper; + }()); + var StringJoiner = (function () { + function StringJoiner(parts) { + if (parts === void 0) { parts = []; } + this.parts = parts; + } + StringJoiner.prototype.add = function (part) { this.parts.push(part); }; + StringJoiner.prototype.toString = function () { return this.parts.join(''); }; + return StringJoiner; + }()); + var NumberWrapper = (function () { + function NumberWrapper() { + } + NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); }; + NumberWrapper.equal = function (a, b) { return a === b; }; + NumberWrapper.parseIntAutoRadix = function (text) { + var result = parseInt(text); + if (isNaN(result)) { + throw new Error('Invalid integer literal when parsing ' + text); + } + return result; + }; + NumberWrapper.parseInt = function (text, radix) { + if (radix == 10) { + if (/^(\-|\+)?[0-9]+$/.test(text)) { + return parseInt(text, radix); + } + } + else if (radix == 16) { + if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) { + return parseInt(text, radix); + } + } + else { + var result = parseInt(text, radix); + if (!isNaN(result)) { + return result; + } + } + throw new Error('Invalid integer literal when parsing ' + text + ' in base ' + radix); + }; + Object.defineProperty(NumberWrapper, "NaN", { + get: function () { return NaN; }, + enumerable: true, + configurable: true + }); + NumberWrapper.isNumeric = function (value) { return !isNaN(value - parseFloat(value)); }; + NumberWrapper.isNaN = function (value) { return isNaN(value); }; + NumberWrapper.isInteger = function (value) { return Number.isInteger(value); }; + return NumberWrapper; + }()); + var RegExp = _global.RegExp; + var FunctionWrapper = (function () { + function FunctionWrapper() { + } + FunctionWrapper.apply = function (fn, posArgs) { return fn.apply(null, posArgs); }; + FunctionWrapper.bind = function (fn, scope) { return fn.bind(scope); }; + return FunctionWrapper; + }()); +// JS has NaN !== NaN + function looseIdentical(a, b) { + return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); + } +// JS considers NaN is the same as NaN for map Key (while NaN !== NaN otherwise) +// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map + function getMapKey(value) { + return value; + } + function normalizeBlank(obj) { + return isBlank(obj) ? null : obj; + } + function normalizeBool(obj) { + return isBlank(obj) ? false : obj; + } + function isJsObject(o) { + return o !== null && (typeof o === 'function' || typeof o === 'object'); + } + function print(obj) { + console.log(obj); + } + function warn(obj) { + console.warn(obj); + } +// Can't be all uppercase as our transpiler would think it is a special directive... + var Json = (function () { + function Json() { + } + Json.parse = function (s) { return _global.JSON.parse(s); }; + Json.stringify = function (data) { + // Dart doesn't take 3 arguments + return _global.JSON.stringify(data, null, 2); + }; + return Json; + }()); + var DateWrapper = (function () { + function DateWrapper() { + } + DateWrapper.create = function (year, month, day, hour, minutes, seconds, milliseconds) { + if (month === void 0) { month = 1; } + if (day === void 0) { day = 1; } + if (hour === void 0) { hour = 0; } + if (minutes === void 0) { minutes = 0; } + if (seconds === void 0) { seconds = 0; } + if (milliseconds === void 0) { milliseconds = 0; } + return new Date(year, month - 1, day, hour, minutes, seconds, milliseconds); + }; + DateWrapper.fromISOString = function (str) { return new Date(str); }; + DateWrapper.fromMillis = function (ms) { return new Date(ms); }; + DateWrapper.toMillis = function (date) { return date.getTime(); }; + DateWrapper.now = function () { return new Date(); }; + DateWrapper.toJson = function (date) { return date.toJSON(); }; + return DateWrapper; + }()); + function setValueOnPath(global, path, value) { + var parts = path.split('.'); + var obj = global; + while (parts.length > 1) { + var name = parts.shift(); + if (obj.hasOwnProperty(name) && isPresent(obj[name])) { + obj = obj[name]; + } + else { + obj = obj[name] = {}; + } + } + if (obj === undefined || obj === null) { + obj = {}; + } + obj[parts.shift()] = value; + } + var _symbolIterator = null; + function getSymbolIterator() { + if (isBlank(_symbolIterator)) { + if (isPresent(globalScope.Symbol) && isPresent(Symbol.iterator)) { + _symbolIterator = Symbol.iterator; + } + else { + // es6-shim specific logic + var keys = Object.getOwnPropertyNames(Map.prototype); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (key !== 'entries' && key !== 'size' && + Map.prototype[key] === Map.prototype['entries']) { + _symbolIterator = key; + } + } + } + } + return _symbolIterator; + } + function evalExpression(sourceUrl, expr, declarations, vars) { + var fnBody = declarations + "\nreturn " + expr + "\n//# sourceURL=" + sourceUrl; + var fnArgNames = []; + var fnArgValues = []; + for (var argName in vars) { + fnArgNames.push(argName); + fnArgValues.push(vars[argName]); + } + return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues); + } + function isPrimitive(obj) { + return !isJsObject(obj); + } + function hasConstructor(value, type) { + return value.constructor === type; + } + function escape(s) { + return _global.encodeURI(s); + } + function escapeRegExp(s) { + return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); + } +//# sourceMappingURL=lang.js.map + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(64))) + + /***/ }, + /* 37 */ + /***/ function(module, exports, __webpack_require__) { + + var global = __webpack_require__(11) + , hide = __webpack_require__(40) + , has = __webpack_require__(32) + , SRC = __webpack_require__(81)('src') + , TO_STRING = 'toString' + , $toString = Function[TO_STRING] + , TPL = ('' + $toString).split(TO_STRING); + + __webpack_require__(69).inspectSource = function(it){ + return $toString.call(it); + }; + + (module.exports = function(O, key, val, safe){ + var isFunction = typeof val == 'function'; + if(isFunction)has(val, 'name') || hide(val, 'name', key); + if(O[key] === val)return; + if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); + if(O === global){ + O[key] = val; + } else { + if(!safe){ + delete O[key]; + hide(O, key, val); + } else { + if(O[key])O[key] = val; + else hide(O, key, val); + } + } +// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative + })(Function.prototype, TO_STRING, function toString(){ + return typeof this == 'function' && this[SRC] || $toString.call(this); + }); + + /***/ }, + /* 38 */ + /***/ function(module, exports, __webpack_require__) { + +// 7.1.13 ToObject(argument) + var defined = __webpack_require__(59); + module.exports = function(it){ + return Object(defined(it)); + }; + + /***/ }, + /* 39 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__di_metadata__ = __webpack_require__(140); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__di_forward_ref__ = __webpack_require__(203); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__di_injector__ = __webpack_require__(139); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__di_reflective_injector__ = __webpack_require__(484); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__di_reflective_provider__ = __webpack_require__(206); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__di_reflective_key__ = __webpack_require__(205); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__di_opaque_token__ = __webpack_require__(204); + /* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "b", function() { return __WEBPACK_IMPORTED_MODULE_0__di_metadata__["a"]; }); + /* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "c", function() { return __WEBPACK_IMPORTED_MODULE_0__di_metadata__["b"]; }); + /* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "d", function() { return __WEBPACK_IMPORTED_MODULE_0__di_metadata__["c"]; }); + /* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "e", function() { return __WEBPACK_IMPORTED_MODULE_0__di_metadata__["f"]; }); + /* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "i", function() { return __WEBPACK_IMPORTED_MODULE_0__di_metadata__["e"]; }); + /* harmony namespace reexport (by used) */ __webpack_require__.d(exports, "j", function() { return __WEBPACK_IMPORTED_MODULE_0__di_metadata__["d"]; }); + /* harmony reexport (binding) */ __webpack_require__.d(exports, "k", function() { return __WEBPACK_IMPORTED_MODULE_1__di_forward_ref__["b"]; }); + /* harmony reexport (binding) */ __webpack_require__.d(exports, "h", function() { return __WEBPACK_IMPORTED_MODULE_1__di_forward_ref__["a"]; }); + /* harmony reexport (binding) */ __webpack_require__.d(exports, "g", function() { return __WEBPACK_IMPORTED_MODULE_2__di_injector__["b"]; }); + /* harmony reexport (binding) */ __webpack_require__.d(exports, "f", function() { return __WEBPACK_IMPORTED_MODULE_3__di_reflective_injector__["a"]; }); + /* harmony reexport (binding) */ __webpack_require__.d(exports, "l", function() { return __WEBPACK_IMPORTED_MODULE_4__di_reflective_provider__["c"]; }); + /* harmony reexport (binding) */ __webpack_require__.d(exports, "m", function() { return __WEBPACK_IMPORTED_MODULE_5__di_reflective_key__["a"]; }); + /* harmony reexport (binding) */ __webpack_require__.d(exports, "a", function() { return __WEBPACK_IMPORTED_MODULE_6__di_opaque_token__["a"]; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + /** + * @module + * @description + * The `di` module provides dependency injection container services. + */ + + + + + + + +//# sourceMappingURL=di.js.map + + /***/ }, + /* 40 */ + /***/ function(module, exports, __webpack_require__) { + + var dP = __webpack_require__(17) + , createDesc = __webpack_require__(71); + module.exports = __webpack_require__(21) ? function(object, key, value){ + return dP.f(object, key, createDesc(1, value)); + } : function(object, key, value){ + object[key] = value; + return object; + }; + + /***/ }, + /* 41 */ + /***/ function(module, exports, __webpack_require__) { + + var fails = __webpack_require__(9); + + module.exports = function(method, arg){ + return !!method && fails(function(){ + arg ? method.call(null, function(){}, 1) : method.call(null); + }); + }; + + /***/ }, + /* 42 */ + /***/ function(module, exports, __webpack_require__) { + +// to indexed object, toObject with fallback for non-array-like ES3 strings + var IObject = __webpack_require__(118) + , defined = __webpack_require__(59); + module.exports = function(it){ + return IObject(defined(it)); + }; + + /***/ }, + /* 43 */, + /* 44 */, + /* 45 */ + /***/ function(module, exports, __webpack_require__) { + +// 0 -> Array#forEach +// 1 -> Array#map +// 2 -> Array#filter +// 3 -> Array#some +// 4 -> Array#every +// 5 -> Array#find +// 6 -> Array#findIndex + var ctx = __webpack_require__(58) + , IObject = __webpack_require__(118) + , toObject = __webpack_require__(38) + , toLength = __webpack_require__(26) + , asc = __webpack_require__(542); + module.exports = function(TYPE, $create){ + var IS_MAP = TYPE == 1 + , IS_FILTER = TYPE == 2 + , IS_SOME = TYPE == 3 + , IS_EVERY = TYPE == 4 + , IS_FIND_INDEX = TYPE == 6 + , NO_HOLES = TYPE == 5 || IS_FIND_INDEX + , create = $create || asc; + return function($this, callbackfn, that){ + var O = toObject($this) + , self = IObject(O) + , f = ctx(callbackfn, that, 3) + , length = toLength(self.length) + , index = 0 + , result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined + , val, res; + for(;length > index; index++)if(NO_HOLES || index in self){ + val = self[index]; + res = f(val, index, O); + if(TYPE){ + if(IS_MAP)result[index] = res; // map + else if(res)switch(TYPE){ + case 3: return true; // some + case 5: return val; // find + case 6: return index; // findIndex + case 2: result.push(val); // filter + } else if(IS_EVERY)return false; // every + } + } + return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; + }; + }; + + /***/ }, + /* 46 */ + /***/ function(module, exports, __webpack_require__) { + +// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) + var has = __webpack_require__(32) + , toObject = __webpack_require__(38) + , IE_PROTO = __webpack_require__(250)('IE_PROTO') + , ObjectProto = Object.prototype; + + module.exports = Object.getPrototypeOf || function(O){ + O = toObject(O); + if(has(O, IE_PROTO))return O[IE_PROTO]; + if(typeof O.constructor == 'function' && O instanceof O.constructor){ + return O.constructor.prototype; + } return O instanceof Object ? ObjectProto : null; + }; + + /***/ }, + /* 47 */ + /***/ function(module, exports, __webpack_require__) { + +// most Object methods by ES6 should accept primitives + var $export = __webpack_require__(2) + , core = __webpack_require__(69) + , fails = __webpack_require__(9); + module.exports = function(KEY, exec){ + var fn = (core.Object || {})[KEY] || Object[KEY] + , exp = {}; + exp[KEY] = exec(fn); + $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp); + }; + + /***/ }, + /* 48 */ + /***/ function(module, exports) { + + "use strict"; + "use strict"; + exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); +//# sourceMappingURL=isArray.js.map + + /***/ }, + /* 49 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__assertions__ = __webpack_require__(276); + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return InterpolationConfig; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "a", function() { return DEFAULT_INTERPOLATION_CONFIG; }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + + var InterpolationConfig = (function () { + function InterpolationConfig(start, end) { + this.start = start; + this.end = end; + } + InterpolationConfig.fromArray = function (markers) { + if (!markers) { + return DEFAULT_INTERPOLATION_CONFIG; + } + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__assertions__["a" /* assertInterpolationSymbols */])('interpolation', markers); + return new InterpolationConfig(markers[0], markers[1]); + }; + ; + return InterpolationConfig; + }()); + var DEFAULT_INTERPOLATION_CONFIG = new InterpolationConfig('{{', '}}'); +//# sourceMappingURL=interpolation_config.js.map + + /***/ }, + /* 50 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__facade_lang__ = __webpack_require__(4); + /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return ParseLocation; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return ParseSourceFile; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "d", function() { return ParseSourceSpan; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "e", function() { return ParseErrorLevel; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "a", function() { return ParseError; }); + + var ParseLocation = (function () { + function ParseLocation(file, offset, line, col) { + this.file = file; + this.offset = offset; + this.line = line; + this.col = col; + } + ParseLocation.prototype.toString = function () { + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(this.offset) ? this.file.url + "@" + this.line + ":" + this.col : this.file.url; + }; + return ParseLocation; + }()); + var ParseSourceFile = (function () { + function ParseSourceFile(content, url) { + this.content = content; + this.url = url; + } + return ParseSourceFile; + }()); + var ParseSourceSpan = (function () { + function ParseSourceSpan(start, end, details) { + if (details === void 0) { details = null; } + this.start = start; + this.end = end; + this.details = details; + } + ParseSourceSpan.prototype.toString = function () { + return this.start.file.content.substring(this.start.offset, this.end.offset); + }; + return ParseSourceSpan; + }()); + var ParseErrorLevel; + (function (ParseErrorLevel) { + ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING"; + ParseErrorLevel[ParseErrorLevel["FATAL"] = 1] = "FATAL"; + })(ParseErrorLevel || (ParseErrorLevel = {})); + var ParseError = (function () { + function ParseError(span, msg, level) { + if (level === void 0) { level = ParseErrorLevel.FATAL; } + this.span = span; + this.msg = msg; + this.level = level; + } + ParseError.prototype.toString = function () { + var source = this.span.start.file.content; + var ctxStart = this.span.start.offset; + var contextStr = ''; + var details = ''; + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(ctxStart)) { + if (ctxStart > source.length - 1) { + ctxStart = source.length - 1; + } + var ctxEnd = ctxStart; + var ctxLen = 0; + var ctxLines = 0; + while (ctxLen < 100 && ctxStart > 0) { + ctxStart--; + ctxLen++; + if (source[ctxStart] == '\n') { + if (++ctxLines == 3) { + break; + } + } + } + ctxLen = 0; + ctxLines = 0; + while (ctxLen < 100 && ctxEnd < source.length - 1) { + ctxEnd++; + ctxLen++; + if (source[ctxEnd] == '\n') { + if (++ctxLines == 3) { + break; + } + } + } + var context = source.substring(ctxStart, this.span.start.offset) + '[ERROR ->]' + + source.substring(this.span.start.offset, ctxEnd + 1); + contextStr = " (\"" + context + "\")"; + } + if (this.span.details) { + details = ", " + this.span.details; + } + return "" + this.msg + contextStr + ": " + this.span.start + details; + }; + return ParseError; + }()); +//# sourceMappingURL=parse_util.js.map + + /***/ }, + /* 51 */ + /***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__facade_lang__ = __webpack_require__(4); + /* harmony export (binding) */ __webpack_require__.d(exports, "e", function() { return TextAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "d", function() { return BoundTextAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "f", function() { return AttrAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "k", function() { return BoundElementPropertyAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "m", function() { return BoundEventAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "n", function() { return ReferenceAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "j", function() { return VariableAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "i", function() { return ElementAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "h", function() { return EmbeddedTemplateAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "p", function() { return BoundDirectivePropertyAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "o", function() { return DirectiveAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "b", function() { return ProviderAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "a", function() { return ProviderAstType; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "g", function() { return NgContentAst; }); + /* harmony export (binding) */ __webpack_require__.d(exports, "l", function() { return PropertyBindingType; }); + /* harmony export (immutable) */ exports["c"] = templateVisitAll; + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + + /** + * A segment of text within the template. + */ + var TextAst = (function () { + function TextAst(value, ngContentIndex, sourceSpan) { + this.value = value; + this.ngContentIndex = ngContentIndex; + this.sourceSpan = sourceSpan; + } + TextAst.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); }; + return TextAst; + }()); + /** + * A bound expression within the text of a template. + */ + var BoundTextAst = (function () { + function BoundTextAst(value, ngContentIndex, sourceSpan) { + this.value = value; + this.ngContentIndex = ngContentIndex; + this.sourceSpan = sourceSpan; + } + BoundTextAst.prototype.visit = function (visitor, context) { + return visitor.visitBoundText(this, context); + }; + return BoundTextAst; + }()); + /** + * A plain attribute on an element. + */ + var AttrAst = (function () { + function AttrAst(name, value, sourceSpan) { + this.name = name; + this.value = value; + this.sourceSpan = sourceSpan; + } + AttrAst.prototype.visit = function (visitor, context) { return visitor.visitAttr(this, context); }; + return AttrAst; + }()); + /** + * A binding for an element property (e.g. `[property]="expression"`). + */ + var BoundElementPropertyAst = (function () { + function BoundElementPropertyAst(name, type, securityContext, value, unit, sourceSpan) { + this.name = name; + this.type = type; + this.securityContext = securityContext; + this.value = value; + this.unit = unit; + this.sourceSpan = sourceSpan; + } + BoundElementPropertyAst.prototype.visit = function (visitor, context) { + return visitor.visitElementProperty(this, context); + }; + return BoundElementPropertyAst; + }()); + /** + * A binding for an element event (e.g. `(event)="handler()"`). + */ + var BoundEventAst = (function () { + function BoundEventAst(name, target, handler, sourceSpan) { + this.name = name; + this.target = target; + this.handler = handler; + this.sourceSpan = sourceSpan; + } + BoundEventAst.prototype.visit = function (visitor, context) { + return visitor.visitEvent(this, context); + }; + Object.defineProperty(BoundEventAst.prototype, "fullName", { + get: function () { + if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["a" /* isPresent */])(this.target)) { + return this.target + ":" + this.name; + } + else { + return this.name; + } + }, + enumerable: true, + configurable: true + }); + return BoundEventAst; + }()); + /** + * A reference declaration on an element (e.g. `let someName="expression"`). + */ + var ReferenceAst = (function () { + function ReferenceAst(name, value, sourceSpan) { + this.name = name; + this.value = value; + this.sourceSpan = sourceSpan; + } + ReferenceAst.prototype.visit = function (visitor, context) { + return visitor.visitReference(this, context); + }; + return ReferenceAst; + }()); + /** + * A variable declaration on a