From c940f0c0020d0968924b7f8348c62564a7aafff0 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Wed, 9 Nov 2016 13:10:40 +0300 Subject: [PATCH] stringsArray -> stringArray raname --- CHANGELOG.md | 8 +- README.md | 52 +-- dist/index.js | 362 +++++++++--------- src/Obfuscator.ts | 4 +- src/{StringsArray.ts => StringArray.ts} | 2 +- src/cli/JavaScriptObfuscatorCLI.ts | 24 +- .../StringArrayCallsWrapper.ts | 146 +++++++ .../StringArrayNode.ts} | 52 +-- .../StringArrayRotateFunctionNode.ts} | 42 +- .../StringsArrayCallsWrapper.ts | 146 ------- src/enums/StringArrayEncoding.ts | 4 + src/enums/StringsArrayEncoding.ts | 4 - src/interfaces/IObfuscatorOptions.d.ts | 10 +- src/interfaces/IOptions.d.ts | 10 +- src/node-groups/StringArrayNodesGroup.ts | 87 +++++ src/node-groups/StringsArrayNodesGroup.ts | 87 ----- .../replacers/StringLiteralReplacer.ts | 54 +-- src/options/Options.ts | 12 +- src/options/OptionsNormalizer.ts | 28 +- src/preset-options/DefaultPreset.ts | 8 +- src/preset-options/NoCustomNodesPreset.ts | 8 +- .../SelfDefendingTemplate.ts | 2 +- .../StringArrayBase64DecodeNodeTemplate.ts | 38 ++ .../StringArrayCallsWrapperTemplate.ts} | 6 +- .../StringArrayRC4DecodeNodeTemplate.ts | 35 ++ .../string-array-node/StringArrayTemplate.ts | 8 + .../SelfDefendingTemplate.ts | 0 .../StringArrayRotateFunctionTemplate.ts} | 4 +- .../StringsArrayBase64DecodeNodeTemplate.ts | 38 -- .../StringsArrayRC4DecodeNodeTemplate.ts | 35 -- .../StringsArrayTemplate.ts | 8 - src/types/TStringArrayEncoding.ts | 1 + src/types/TStringsArrayEncoding.ts | 1 - ...per.d.ts => TStringArrayCallsWrapper.d.ts} | 2 +- ...gsArrayNode.d.ts => TStringArrayNode.d.ts} | 2 +- test/dev/dev.ts | 2 +- .../JavaScriptObfuscator.spec.ts | 8 +- ...ConsoleOutputDisableExpressionNode.spec.ts | 2 +- .../StringArrayCallsWrapper.spec.ts} | 10 +- .../StringArrayNode.spec.ts} | 12 +- .../StringArrayRotateFunctionNode.spec.ts} | 18 +- .../LiteralObfuscator.spec.ts | 32 +- .../MemberExpressionObfuscator.spec.ts | 8 +- .../MethodDefinitionObfuscator.spec.ts | 4 +- ...tringArrayCallsWrapperNodeTemplate.spec.ts | 93 +++++ ...ringsArrayCallsWrapperNodeTemplate.spec.ts | 93 ----- test/index.spec.ts | 8 +- test/unit-tests/OptionsNormalizer.spec.ts | 36 +- 48 files changed, 828 insertions(+), 828 deletions(-) rename src/{StringsArray.ts => StringArray.ts} (97%) create mode 100644 src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts rename src/custom-nodes/{strings-array-nodes/StringsArrayNode.ts => string-array-nodes/StringArrayNode.ts} (56%) rename src/custom-nodes/{strings-array-nodes/StringsArrayRotateFunctionNode.ts => string-array-nodes/StringArrayRotateFunctionNode.ts} (65%) delete mode 100644 src/custom-nodes/strings-array-nodes/StringsArrayCallsWrapper.ts create mode 100644 src/enums/StringArrayEncoding.ts delete mode 100644 src/enums/StringsArrayEncoding.ts create mode 100644 src/node-groups/StringArrayNodesGroup.ts delete mode 100644 src/node-groups/StringsArrayNodesGroup.ts rename src/templates/custom-nodes/{strings-array-nodes/strings-array-calls-wrapper => string-array-nodes/string-array-calls-wrapper}/SelfDefendingTemplate.ts (95%) create mode 100644 src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayBase64DecodeNodeTemplate.ts rename src/templates/custom-nodes/{strings-array-nodes/strings-array-calls-wrapper/StringsArrayCallsWrapperTemplate.ts => string-array-nodes/string-array-calls-wrapper/StringArrayCallsWrapperTemplate.ts} (51%) create mode 100644 src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayRC4DecodeNodeTemplate.ts create mode 100644 src/templates/custom-nodes/string-array-nodes/string-array-node/StringArrayTemplate.ts rename src/templates/custom-nodes/{strings-array-nodes/strings-array-rotate-function-node => string-array-nodes/string-array-rotate-function-node}/SelfDefendingTemplate.ts (100%) rename src/templates/custom-nodes/{strings-array-nodes/strings-array-rotate-function-node/StringsArrayRotateFunctionTemplate.ts => string-array-nodes/string-array-rotate-function-node/StringArrayRotateFunctionTemplate.ts} (70%) delete mode 100644 src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayBase64DecodeNodeTemplate.ts delete mode 100644 src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayRC4DecodeNodeTemplate.ts delete mode 100644 src/templates/custom-nodes/strings-array-nodes/strings-array-node/StringsArrayTemplate.ts create mode 100644 src/types/TStringArrayEncoding.ts delete mode 100644 src/types/TStringsArrayEncoding.ts rename src/types/custom-nodes/{TStringsArrayCallsWrapper.d.ts => TStringArrayCallsWrapper.d.ts} (60%) rename src/types/custom-nodes/{TStringsArrayNode.d.ts => TStringArrayNode.d.ts} (70%) rename test/functional-tests/custom-nodes/{strings-array-nodes/StringsArrayCallsWrapper.spec.ts => string-array-nodes/StringArrayCallsWrapper.spec.ts} (71%) rename test/functional-tests/custom-nodes/{strings-array-nodes/StringsArrayNode.spec.ts => string-array-nodes/StringArrayNode.spec.ts} (69%) rename test/functional-tests/custom-nodes/{strings-array-nodes/StringsArrayRotateFunctionNode.spec.ts => string-array-nodes/StringArrayRotateFunctionNode.spec.ts} (61%) create mode 100644 test/functional-tests/templates/custom-nodes/string-array-nodes/StringArrayCallsWrapperNodeTemplate.spec.ts delete mode 100644 test/functional-tests/templates/custom-nodes/strings-array-nodes/StringsArrayCallsWrapperNodeTemplate.spec.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c222fe7..dd7cd535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,10 @@ Change Log === v0.8.0 --- -* **Breaking options change:** `unicodeArray` option has been renamed to `stringsArray`. -* **Breaking options change:** `unicodeArrayThreshold` option has been renamed to `stringsArrayThreshold`. -* **Breaking options change:** `encodeUnicodeArray` option has been renamed to `stringsArrayEncoding` and now accepts following values: `true|false|'base64'|'rc4'`. -* **Breaking change:** option `wrapUnicodeArrayCalls` was removed and now all calls to `stringsArray` are always wrapped by special wrapper function. +* **Breaking options change:** `unicodeArray` option has been renamed to `stringArray`. +* **Breaking options change:** `unicodeArrayThreshold` option has been renamed to `stringArrayThreshold`. +* **Breaking options change:** `encodeUnicodeArray` option has been renamed to `stringArrayEncoding` and now accepts following values: `true|false|'base64'|'rc4'`. +* **Breaking change:** option `wrapUnicodeArrayCalls` was removed and now all calls to `stringArray` are always wrapped by special wrapper function. * New option `unicodeEscapeSequence` allows to enable/disable strings conversion to unicode escape sequence. * New option `domainLock` locks the obfuscated source code so it only runs on specific domains and/or sub-domains. * New option `sourceMapBaseUrl` sets base url to the source map import url when `sourceMapMode: 'separate'`. diff --git a/README.md b/README.md index b27ffb62..9072dc3e 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ var obfuscationResult = JavaScriptObfuscator.obfuscate( })(); `, { - rotateStringsArray: false + rotateStringArray: false } ); @@ -117,15 +117,15 @@ Following options available for the JS Obfuscator: debugProtectionInterval: false, disableConsoleOutput: true, reservedNames: [], - rotateStringsArray: true, + rotateStringArray: true, selfDefending: true, sourceMap: false, sourceMapBaseUrl: '', sourceMapFileName: '', sourceMapMode: 'separate', - stringsArray: true, - stringsArrayEncoding: false, - stringsArrayThreshold: 0.8 + stringArray: true, + stringArrayEncoding: false, + stringArrayThreshold: 0.8 } ``` @@ -141,15 +141,15 @@ Following options available for the JS Obfuscator: --debugProtectionInterval --disableConsoleOutput --reservedNames (comma separated) - --rotateStringsArray + --rotateStringArray --selfDefending --sourceMap --sourceMapBaseUrl --sourceMapFileName --sourceMapMode [inline, separate] - --stringsArray - --stringsArrayEncoding [true, false, base64, rc4] - --stringsArrayThreshold + --stringArray + --stringArrayEncoding [true, false, base64, rc4] + --stringArrayThreshold ``` ### `compact` @@ -202,12 +202,12 @@ Example: } ``` -### `rotateStringsArray` +### `rotateStringArray` Type: `boolean` Default: `true` -##### :warning: `stringsArray` must be enabled +##### :warning: `stringArray` must be enabled -Shift the `stringsArray` 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. +Shift the `stringArray` 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. This option is recommended if your original source code isn't small, as the helper function can attract attention. @@ -263,41 +263,41 @@ Specifies source map generation mode: * `inline` - emit a single file with source maps instead of having a separate file; * `separate` - generates corresponding '.map' file with source map. If obfuscator run through CLI - adds link to source map file to the end of file with obfuscated code `//# sourceMappingUrl=file.js.map`. -### `stringsArray` +### `stringArray` Type: `boolean` Default: `true` 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];` -### `stringsArrayEncoding` +### `stringArrayEncoding` Type: `boolean|string` Default: `false` -##### :warning: `stringsArray` option must be enabled +##### :warning: `stringArray` option must be enabled This option can slightly slow down your script. -Encode all string literals of the `stringsArray` using `base64` or `rc4` and inserts a special code that used to decode it back at runtime. +Encode all string literals of the `stringArray` using `base64` or `rc4` and inserts a special code that used to decode it back at runtime. Available values: -* `true` (`boolean`): encode `stringsArray` values using `base64` -* `false` (`boolean`): don't encode `stringsArray` values -* `'base64'` (`string`): encode `stringsArray` values using `base64` -* `'rc4'` (`string`): encode `stringsArray` values using `rc4`. **About 30-35% slower then `base64`, but more harder to get initial values** +* `true` (`boolean`): encode `stringArray` values using `base64` +* `false` (`boolean`): don't encode `stringArray` values +* `'base64'` (`string`): encode `stringArray` values using `base64` +* `'rc4'` (`string`): encode `stringArray` values using `rc4`. **About 30-35% slower then `base64`, but more harder to get initial values** -### `stringsArrayThreshold` +### `stringArrayThreshold` Type: `number` Default: `0.8` Min: `0` Max: `1` -##### :warning: `stringsArray` option must be enabled +##### :warning: `stringArray` option must be enabled -You can use this setting to adjust the probability (from 0 to 1) that a string literal will be inserted into the `stringsArray`. +You can use this setting to adjust the probability (from 0 to 1) that a string literal will be inserted into the `stringArray`. -This setting is useful with large code size because repeatdely calls to the `stringsArray` array can slightly slow down your code. +This setting is useful with large code size because repeatdely calls to the `stringArray` array can slightly slow down your code. -`stringsArrayThreshold: 0` equals to `stringsArray: false`. +`stringArrayThreshold: 0` equals to `stringArray: false`. ### `unicodeEscapeSequence` Type: `boolean` Default: `true` -Allows to enable/disable strings conversion to unicode escape sequence. +Allows to enable/disable string conversion to unicode escape sequence. Unicode escape sequence greatly increases code size. Recommended to disable this option when using `stringArrayEncoding` (especially with `rc4` encoding). diff --git a/dist/index.js b/dist/index.js index 29626ea8..56d7c350 100644 --- a/dist/index.js +++ b/dist/index.js @@ -976,15 +976,15 @@ exports.NO_CUSTOM_NODES_PRESET = Object.freeze({ disableConsoleOutput: false, domainLock: [], reservedNames: [], - rotateStringsArray: false, + rotateStringArray: false, selfDefending: false, sourceMap: false, sourceMapBaseUrl: '', sourceMapFileName: '', sourceMapMode: SourceMapMode_1.SourceMapMode.Separate, - stringsArray: false, - stringsArrayEncoding: false, - stringsArrayThreshold: 0, + stringArray: false, + stringArrayEncoding: false, + stringArrayThreshold: 0, unicodeEscapeSequence: true }); @@ -1064,7 +1064,7 @@ exports.NodeCallsControllerFunctionNode = NodeCallsControllerFunctionNode; "use strict"; "use strict"; -exports.StringsArrayEncoding = { +exports.StringArrayEncoding = { base64: 'base64', rc4: 'rc4' }; @@ -1084,7 +1084,7 @@ 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 StringsArrayEncoding_1 = __webpack_require__(18); +var StringArrayEncoding_1 = __webpack_require__(18); var AbstractReplacer_1 = __webpack_require__(14); var NumberLiteralReplacer_1 = __webpack_require__(22); var Utils_1 = __webpack_require__(0); @@ -1101,25 +1101,25 @@ var StringLiteralReplacer = function (_AbstractReplacer_1$A) { _createClass(StringLiteralReplacer, [{ key: 'replace', value: function replace(nodeValue) { - var replaceWithStringsArrayFlag = nodeValue.length >= StringLiteralReplacer.minimumLengthForStringsArray && Math.random() <= this.options.stringsArrayThreshold; - if (this.options.stringsArray && replaceWithStringsArrayFlag) { - return this.replaceStringLiteralWithStringsArrayCall(nodeValue); + var replaceWithStringArrayFlag = nodeValue.length >= StringLiteralReplacer.minimumLengthForStringArray && Math.random() <= this.options.stringArrayThreshold; + if (this.options.stringArray && replaceWithStringArrayFlag) { + return this.replaceStringLiteralWithStringArrayCall(nodeValue); } return '\'' + Utils_1.Utils.stringToUnicodeEscapeSequence(nodeValue) + '\''; } }, { - key: 'replaceStringLiteralWithStringsArrayCall', - value: function replaceStringLiteralWithStringsArrayCall(value) { - var stringsArrayNode = this.nodes.get('stringsArrayNode'); - if (!stringsArrayNode) { - throw new ReferenceError('`stringsArrayNode` node is not found in Map with custom node.'); + key: 'replaceStringLiteralWithStringArrayCall', + value: function replaceStringLiteralWithStringArrayCall(value) { + var stringArrayNode = this.nodes.get('stringArrayNode'); + if (!stringArrayNode) { + throw new ReferenceError('`stringArrayNode` node is not found in Map with custom node.'); } var rc4Key = ''; - switch (this.options.stringsArrayEncoding) { - case StringsArrayEncoding_1.StringsArrayEncoding.base64: + switch (this.options.stringArrayEncoding) { + case StringArrayEncoding_1.StringArrayEncoding.base64: value = Utils_1.Utils.btoa(value); break; - case StringsArrayEncoding_1.StringsArrayEncoding.rc4: + case StringArrayEncoding_1.StringArrayEncoding.rc4: rc4Key = Utils_1.Utils.getRandomGenerator().pickone(StringLiteralReplacer.rc4Keys); value = Utils_1.Utils.btoa(Utils_1.Utils.rc4(value, rc4Key)); break; @@ -1127,32 +1127,32 @@ var StringLiteralReplacer = function (_AbstractReplacer_1$A) { if (this.options.unicodeEscapeSequence) { value = Utils_1.Utils.stringToUnicodeEscapeSequence(value); } - var stringsArray = stringsArrayNode.getNodeData(), - indexOfExistingValue = stringsArray.getIndexOf(value), + var stringArray = stringArrayNode.getNodeData(), + indexOfExistingValue = stringArray.getIndexOf(value), indexOfValue = void 0, hexadecimalIndex = void 0; if (indexOfExistingValue >= 0) { indexOfValue = indexOfExistingValue; } else { - indexOfValue = stringsArray.getLength(); - stringsArrayNode.updateNodeData(value); + indexOfValue = stringArray.getLength(); + stringArrayNode.updateNodeData(value); } hexadecimalIndex = new NumberLiteralReplacer_1.NumberLiteralReplacer(this.nodes, this.options).replace(indexOfValue); - var stringsArrayCallsWrapper = this.nodes.get('stringsArrayCallsWrapper'); - if (!stringsArrayCallsWrapper) { - throw new ReferenceError('`stringsArrayCallsWrapper` node is not found in Map with custom node.'); + var stringArrayCallsWrapper = this.nodes.get('stringArrayCallsWrapper'); + if (!stringArrayCallsWrapper) { + throw new ReferenceError('`stringArrayCallsWrapper` node is not found in Map with custom node.'); } - if (this.options.stringsArrayEncoding === StringsArrayEncoding_1.StringsArrayEncoding.rc4) { - return stringsArrayCallsWrapper.getNodeIdentifier() + '(\'' + hexadecimalIndex + '\', \'' + Utils_1.Utils.stringToUnicodeEscapeSequence(rc4Key) + '\')'; + if (this.options.stringArrayEncoding === StringArrayEncoding_1.StringArrayEncoding.rc4) { + return stringArrayCallsWrapper.getNodeIdentifier() + '(\'' + hexadecimalIndex + '\', \'' + Utils_1.Utils.stringToUnicodeEscapeSequence(rc4Key) + '\')'; } - return stringsArrayCallsWrapper.getNodeIdentifier() + '(\'' + hexadecimalIndex + '\')'; + return stringArrayCallsWrapper.getNodeIdentifier() + '(\'' + hexadecimalIndex + '\')'; } }]); return StringLiteralReplacer; }(AbstractReplacer_1.AbstractReplacer); -StringLiteralReplacer.minimumLengthForStringsArray = 3; +StringLiteralReplacer.minimumLengthForStringArray = 3; StringLiteralReplacer.rc4Keys = Utils_1.Utils.getRandomGenerator().n(function () { return Utils_1.Utils.getRandomGenerator().string({ length: 4 }); }, 50); @@ -1322,15 +1322,15 @@ exports.DEFAULT_PRESET = Object.freeze({ disableConsoleOutput: true, domainLock: [], reservedNames: [], - rotateStringsArray: true, + rotateStringArray: true, selfDefending: true, sourceMap: false, sourceMapBaseUrl: '', sourceMapFileName: '', sourceMapMode: SourceMapMode_1.SourceMapMode.Separate, - stringsArray: true, - stringsArrayEncoding: false, - stringsArrayThreshold: 0.8, + stringArray: true, + stringArrayEncoding: false, + stringArrayThreshold: 0.8, unicodeEscapeSequence: true }); @@ -1450,7 +1450,7 @@ var NodeUtils_1 = __webpack_require__(1); var ObjectExpressionObfuscator_1 = __webpack_require__(53); var SelfDefendingNodesGroup_1 = __webpack_require__(45); var StackTraceAnalyzer_1 = __webpack_require__(59); -var StringsArrayNodesGroup_1 = __webpack_require__(46); +var StringArrayNodesGroup_1 = __webpack_require__(46); var VariableDeclarationObfuscator_1 = __webpack_require__(54); var Obfuscator = function () { @@ -1537,7 +1537,7 @@ var Obfuscator = function () { return Obfuscator; }(); -Obfuscator.nodeGroups = [DomainLockNodesGroup_1.DomainLockNodesGroup, SelfDefendingNodesGroup_1.SelfDefendingNodesGroup, ConsoleOutputNodesGroup_1.ConsoleOutputNodesGroup, DebugProtectionNodesGroup_1.DebugProtectionNodesGroup, StringsArrayNodesGroup_1.StringsArrayNodesGroup]; +Obfuscator.nodeGroups = [DomainLockNodesGroup_1.DomainLockNodesGroup, SelfDefendingNodesGroup_1.SelfDefendingNodesGroup, ConsoleOutputNodesGroup_1.ConsoleOutputNodesGroup, DebugProtectionNodesGroup_1.DebugProtectionNodesGroup, StringArrayNodesGroup_1.StringArrayNodesGroup]; 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; @@ -1612,14 +1612,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var Utils_1 = __webpack_require__(0); -var StringsArray = function () { - function StringsArray() { - _classCallCheck(this, StringsArray); +var StringArray = function () { + function StringArray() { + _classCallCheck(this, StringArray); this.array = []; } - _createClass(StringsArray, [{ + _createClass(StringArray, [{ key: "addToArray", value: function addToArray(value) { this.array.push(value); @@ -1653,10 +1653,10 @@ var StringsArray = function () { } }]); - return StringsArray; + return StringArray; }(); -exports.StringsArray = StringsArray; +exports.StringArray = StringArray; /***/ }, /* 31 */ @@ -1764,7 +1764,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var commander = __webpack_require__(83); var path = __webpack_require__(25); var SourceMapMode_1 = __webpack_require__(13); -var StringsArrayEncoding_1 = __webpack_require__(18); +var StringArrayEncoding_1 = __webpack_require__(18); var DefaultPreset_1 = __webpack_require__(23); var CLIUtils_1 = __webpack_require__(31); var JavaScriptObfuscator_1 = __webpack_require__(10); @@ -1815,7 +1815,7 @@ var JavaScriptObfuscatorCLI = function () { return val.split(','); }).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('--rotateStringsArray ', '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('--stringsArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean).option('--stringsArrayEncoding [true, false, base64, rc4]', 'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed', JavaScriptObfuscatorCLI.parseStringsArrayEncoding).option('--stringsArrayThreshold ', 'The probability that the literal string will be inserted into stringsArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).option('--unicodeEscapeSequence ', 'Allows to enable/disable strings conversion to unicode escape sequence', JavaScriptObfuscatorCLI.parseBoolean).parse(this.rawArguments); + }).option('--rotateStringArray ', '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('--stringArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean).option('--stringArrayEncoding [true, false, base64, rc4]', 'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed', JavaScriptObfuscatorCLI.parseStringArrayEncoding).option('--stringArrayThreshold ', 'The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).option('--unicodeEscapeSequence ', 'Allows to enable/disable string conversion to unicode escape sequence', JavaScriptObfuscatorCLI.parseBoolean).parse(this.rawArguments); this.commands.on('--help', function () { console.log(' Examples:\n'); console.log(' %> javascript-obfuscator in.js --compact true --selfDefending false'); @@ -1878,15 +1878,15 @@ var JavaScriptObfuscatorCLI = function () { return value; } }, { - key: 'parseStringsArrayEncoding', - value: function parseStringsArrayEncoding(value) { + key: 'parseStringArrayEncoding', + value: function parseStringArrayEncoding(value) { switch (value) { case 'true': case '1': - case StringsArrayEncoding_1.StringsArrayEncoding.base64: + case StringArrayEncoding_1.StringArrayEncoding.base64: return true; - case StringsArrayEncoding_1.StringsArrayEncoding.rc4: - return StringsArrayEncoding_1.StringsArrayEncoding.rc4; + case StringArrayEncoding_1.StringArrayEncoding.rc4: + return StringArrayEncoding_1.StringArrayEncoding.rc4; default: return false; } @@ -2274,38 +2274,38 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" __webpack_require__(8); var AppendState_1 = __webpack_require__(2); -var StringsArrayEncoding_1 = __webpack_require__(18); +var StringArrayEncoding_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 StringsArrayBase64DecodeNodeTemplate_1 = __webpack_require__(73); -var StringsArrayCallsWrapperTemplate_1 = __webpack_require__(74); -var StringsArrayRC4DecodeNodeTemplate_1 = __webpack_require__(75); +var StringArrayBase64DecodeNodeTemplate_1 = __webpack_require__(73); +var StringArrayCallsWrapperTemplate_1 = __webpack_require__(74); +var StringArrayRC4DecodeNodeTemplate_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 StringsArrayCallsWrapper = function (_AbstractCustomNode_) { - _inherits(StringsArrayCallsWrapper, _AbstractCustomNode_); +var StringArrayCallsWrapper = function (_AbstractCustomNode_) { + _inherits(StringArrayCallsWrapper, _AbstractCustomNode_); - function StringsArrayCallsWrapper(stringsArrayCallsWrapperName, stringsArrayName, stringsArray, options) { - _classCallCheck(this, StringsArrayCallsWrapper); + function StringArrayCallsWrapper(stringArrayCallsWrapperName, stringArrayName, stringArray, options) { + _classCallCheck(this, StringArrayCallsWrapper); - var _this = _possibleConstructorReturn(this, (StringsArrayCallsWrapper.__proto__ || Object.getPrototypeOf(StringsArrayCallsWrapper)).call(this, options)); + var _this = _possibleConstructorReturn(this, (StringArrayCallsWrapper.__proto__ || Object.getPrototypeOf(StringArrayCallsWrapper)).call(this, options)); _this.appendState = AppendState_1.AppendState.AfterObfuscation; - _this.stringsArrayCallsWrapperName = stringsArrayCallsWrapperName; - _this.stringsArrayName = stringsArrayName; - _this.stringsArray = stringsArray; + _this.stringArrayCallsWrapperName = stringArrayCallsWrapperName; + _this.stringArrayName = stringArrayName; + _this.stringArray = stringArray; return _this; } - _createClass(StringsArrayCallsWrapper, [{ + _createClass(StringArrayCallsWrapper, [{ key: 'appendNode', value: function appendNode(blockScopeNode) { - if (!this.stringsArray.getLength()) { + if (!this.stringArray.getLength()) { return; } NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), 1); @@ -2313,59 +2313,59 @@ var StringsArrayCallsWrapper = function (_AbstractCustomNode_) { }, { key: 'getNodeIdentifier', value: function getNodeIdentifier() { - return this.stringsArrayCallsWrapperName; + return this.stringArrayCallsWrapperName; } }, { key: 'getNode', value: function getNode() { - return _get(StringsArrayCallsWrapper.prototype.__proto__ || Object.getPrototypeOf(StringsArrayCallsWrapper.prototype), 'getNode', this).call(this); + return _get(StringArrayCallsWrapper.prototype.__proto__ || Object.getPrototypeOf(StringArrayCallsWrapper.prototype), 'getNode', this).call(this); } }, { - key: 'getDecodeStringsArrayTemplate', - value: function getDecodeStringsArrayTemplate() { - var decodeStringsArrayTemplate = '', + key: 'getDecodeStringArrayTemplate', + value: function getDecodeStringArrayTemplate() { + var decodeStringArrayTemplate = '', selfDefendingCode = ''; if (this.options.selfDefending) { selfDefendingCode = SelfDefendingTemplate_1.SelfDefendingTemplate().formatUnicorn({ - stringsArrayCallsWrapperName: this.stringsArrayCallsWrapperName, - stringsArrayName: this.stringsArrayName + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName, + stringArrayName: this.stringArrayName }); } - switch (this.options.stringsArrayEncoding) { - case StringsArrayEncoding_1.StringsArrayEncoding.base64: - decodeStringsArrayTemplate = StringsArrayBase64DecodeNodeTemplate_1.StringsArrayBase64DecodeNodeTemplate().formatUnicorn({ + switch (this.options.stringArrayEncoding) { + case StringArrayEncoding_1.StringArrayEncoding.base64: + decodeStringArrayTemplate = StringArrayBase64DecodeNodeTemplate_1.StringArrayBase64DecodeNodeTemplate().formatUnicorn({ atobPolyfill: AtobTemplate_1.AtobTemplate(), selfDefendingCode: selfDefendingCode, - stringsArrayCallsWrapperName: this.stringsArrayCallsWrapperName + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName }); break; - case StringsArrayEncoding_1.StringsArrayEncoding.rc4: - decodeStringsArrayTemplate = StringsArrayRC4DecodeNodeTemplate_1.StringsArrayRc4DecodeNodeTemplate().formatUnicorn({ + case StringArrayEncoding_1.StringArrayEncoding.rc4: + decodeStringArrayTemplate = StringArrayRC4DecodeNodeTemplate_1.StringArrayRc4DecodeNodeTemplate().formatUnicorn({ atobPolyfill: AtobTemplate_1.AtobTemplate(), rc4Polyfill: Rc4Template_1.Rc4Template(), selfDefendingCode: selfDefendingCode, - stringsArrayCallsWrapperName: this.stringsArrayCallsWrapperName + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName }); break; } - return decodeStringsArrayTemplate; + return decodeStringArrayTemplate; } }, { key: 'getNodeStructure', value: function getNodeStructure() { - var decodeNodeTemplate = this.getDecodeStringsArrayTemplate(); - return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(StringsArrayCallsWrapperTemplate_1.StringsArrayCallsWrapperTemplate().formatUnicorn({ + var decodeNodeTemplate = this.getDecodeStringArrayTemplate(); + return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(StringArrayCallsWrapperTemplate_1.StringArrayCallsWrapperTemplate().formatUnicorn({ decodeNodeTemplate: decodeNodeTemplate, - stringsArrayCallsWrapperName: this.stringsArrayCallsWrapperName, - stringsArrayName: this.stringsArrayName + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName, + stringArrayName: this.stringArrayName }), NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET).getObfuscatedCode()); } }]); - return StringsArrayCallsWrapper; + return StringArrayCallsWrapper; }(AbstractCustomNode_1.AbstractCustomNode); -exports.StringsArrayCallsWrapper = StringsArrayCallsWrapper; +exports.StringArrayCallsWrapper = StringArrayCallsWrapper; /***/ }, /* 40 */ @@ -2386,33 +2386,33 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" __webpack_require__(8); var AppendState_1 = __webpack_require__(2); -var StringsArrayTemplate_1 = __webpack_require__(76); +var StringArrayTemplate_1 = __webpack_require__(76); var AbstractCustomNode_1 = __webpack_require__(6); var NodeAppender_1 = __webpack_require__(4); var NodeUtils_1 = __webpack_require__(1); -var StringsArrayNode = function (_AbstractCustomNode_) { - _inherits(StringsArrayNode, _AbstractCustomNode_); +var StringArrayNode = function (_AbstractCustomNode_) { + _inherits(StringArrayNode, _AbstractCustomNode_); - function StringsArrayNode(stringsArray, stringsArrayName) { - var stringsArrayRotateValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; + function StringArrayNode(stringArray, stringArrayName) { + var stringArrayRotateValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var options = arguments[3]; - _classCallCheck(this, StringsArrayNode); + _classCallCheck(this, StringArrayNode); - var _this = _possibleConstructorReturn(this, (StringsArrayNode.__proto__ || Object.getPrototypeOf(StringsArrayNode)).call(this, options)); + var _this = _possibleConstructorReturn(this, (StringArrayNode.__proto__ || Object.getPrototypeOf(StringArrayNode)).call(this, options)); _this.appendState = AppendState_1.AppendState.AfterObfuscation; - _this.stringsArray = stringsArray; - _this.stringsArrayName = stringsArrayName; - _this.stringsArrayRotateValue = stringsArrayRotateValue; + _this.stringArray = stringArray; + _this.stringArrayName = stringArrayName; + _this.stringArrayRotateValue = stringArrayRotateValue; return _this; } - _createClass(StringsArrayNode, [{ + _createClass(StringArrayNode, [{ key: 'appendNode', value: function appendNode(blockScopeNode) { - if (!this.stringsArray.getLength()) { + if (!this.stringArray.getLength()) { return; } NodeAppender_1.NodeAppender.prependNode(blockScopeNode, this.getNode()); @@ -2420,39 +2420,39 @@ var StringsArrayNode = function (_AbstractCustomNode_) { }, { key: 'getNodeIdentifier', value: function getNodeIdentifier() { - return this.stringsArrayName; + return this.stringArrayName; } }, { key: 'getNodeData', value: function getNodeData() { - return this.stringsArray; + return this.stringArray; } }, { key: 'getNode', value: function getNode() { - this.stringsArray.rotateArray(this.stringsArrayRotateValue); - return _get(StringsArrayNode.prototype.__proto__ || Object.getPrototypeOf(StringsArrayNode.prototype), 'getNode', this).call(this); + this.stringArray.rotateArray(this.stringArrayRotateValue); + return _get(StringArrayNode.prototype.__proto__ || Object.getPrototypeOf(StringArrayNode.prototype), 'getNode', this).call(this); } }, { key: 'updateNodeData', value: function updateNodeData(data) { - this.stringsArray.addToArray(data); + this.stringArray.addToArray(data); } }, { key: 'getNodeStructure', value: function getNodeStructure() { - return NodeUtils_1.NodeUtils.convertCodeToStructure(StringsArrayTemplate_1.StringsArrayTemplate().formatUnicorn({ - stringsArrayName: this.stringsArrayName, - stringsArray: this.stringsArray.toString() + return NodeUtils_1.NodeUtils.convertCodeToStructure(StringArrayTemplate_1.StringArrayTemplate().formatUnicorn({ + stringArrayName: this.stringArrayName, + stringArray: this.stringArray.toString() })); } }]); - return StringsArrayNode; + return StringArrayNode; }(AbstractCustomNode_1.AbstractCustomNode); -StringsArrayNode.ARRAY_RANDOM_LENGTH = 4; -exports.StringsArrayNode = StringsArrayNode; +StringArrayNode.ARRAY_RANDOM_LENGTH = 4; +exports.StringArrayNode = StringArrayNode; /***/ }, /* 41 */ @@ -2475,32 +2475,32 @@ __webpack_require__(8); var AppendState_1 = __webpack_require__(2); var NoCustomNodesPreset_1 = __webpack_require__(16); var SelfDefendingTemplate_1 = __webpack_require__(77); -var StringsArrayRotateFunctionTemplate_1 = __webpack_require__(78); +var StringArrayRotateFunctionTemplate_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 StringsArrayRotateFunctionNode = function (_AbstractCustomNode_) { - _inherits(StringsArrayRotateFunctionNode, _AbstractCustomNode_); +var StringArrayRotateFunctionNode = function (_AbstractCustomNode_) { + _inherits(StringArrayRotateFunctionNode, _AbstractCustomNode_); - function StringsArrayRotateFunctionNode(stringsArrayName, stringsArray, stringsArrayRotateValue, options) { - _classCallCheck(this, StringsArrayRotateFunctionNode); + function StringArrayRotateFunctionNode(stringArrayName, stringArray, stringArrayRotateValue, options) { + _classCallCheck(this, StringArrayRotateFunctionNode); - var _this = _possibleConstructorReturn(this, (StringsArrayRotateFunctionNode.__proto__ || Object.getPrototypeOf(StringsArrayRotateFunctionNode)).call(this, options)); + var _this = _possibleConstructorReturn(this, (StringArrayRotateFunctionNode.__proto__ || Object.getPrototypeOf(StringArrayRotateFunctionNode)).call(this, options)); _this.appendState = AppendState_1.AppendState.AfterObfuscation; - _this.stringsArrayName = stringsArrayName; - _this.stringsArray = stringsArray; - _this.stringsArrayRotateValue = stringsArrayRotateValue; + _this.stringArrayName = stringArrayName; + _this.stringArray = stringArray; + _this.stringArrayRotateValue = stringArrayRotateValue; return _this; } - _createClass(StringsArrayRotateFunctionNode, [{ + _createClass(StringArrayRotateFunctionNode, [{ key: 'appendNode', value: function appendNode(blockScopeNode) { - if (!this.stringsArray.getLength()) { + if (!this.stringArray.getLength()) { return; } NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), 1); @@ -2508,7 +2508,7 @@ var StringsArrayRotateFunctionNode = function (_AbstractCustomNode_) { }, { key: 'getNode', value: function getNode() { - return _get(StringsArrayRotateFunctionNode.prototype.__proto__ || Object.getPrototypeOf(StringsArrayRotateFunctionNode.prototype), 'getNode', this).call(this); + return _get(StringArrayRotateFunctionNode.prototype.__proto__ || Object.getPrototypeOf(StringArrayRotateFunctionNode.prototype), 'getNode', this).call(this); } }, { key: 'getNodeStructure', @@ -2524,20 +2524,20 @@ var StringsArrayRotateFunctionNode = function (_AbstractCustomNode_) { } else { code = whileFunctionName + '(++' + timesName + ')'; } - return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(StringsArrayRotateFunctionTemplate_1.StringsArrayRotateFunctionTemplate().formatUnicorn({ + return NodeUtils_1.NodeUtils.convertCodeToStructure(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(StringArrayRotateFunctionTemplate_1.StringArrayRotateFunctionTemplate().formatUnicorn({ code: code, timesName: timesName, - stringsArrayName: this.stringsArrayName, - stringsArrayRotateValue: Utils_1.Utils.decToHex(this.stringsArrayRotateValue), + stringArrayName: this.stringArrayName, + stringArrayRotateValue: Utils_1.Utils.decToHex(this.stringArrayRotateValue), whileFunctionName: whileFunctionName }), NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET).getObfuscatedCode()); } }]); - return StringsArrayRotateFunctionNode; + return StringArrayRotateFunctionNode; }(AbstractCustomNode_1.AbstractCustomNode); -exports.StringsArrayRotateFunctionNode = StringsArrayRotateFunctionNode; +exports.StringArrayRotateFunctionNode = StringArrayRotateFunctionNode; /***/ }, /* 42 */ @@ -2750,55 +2750,55 @@ 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 AppendState_1 = __webpack_require__(2); -var StringsArrayCallsWrapper_1 = __webpack_require__(39); -var StringsArrayNode_1 = __webpack_require__(40); -var StringsArrayRotateFunctionNode_1 = __webpack_require__(41); +var StringArrayCallsWrapper_1 = __webpack_require__(39); +var StringArrayNode_1 = __webpack_require__(40); +var StringArrayRotateFunctionNode_1 = __webpack_require__(41); var AbstractNodesGroup_1 = __webpack_require__(11); -var StringsArray_1 = __webpack_require__(30); +var StringArray_1 = __webpack_require__(30); var Utils_1 = __webpack_require__(0); -var StringsArrayNodesGroup = function (_AbstractNodesGroup_) { - _inherits(StringsArrayNodesGroup, _AbstractNodesGroup_); +var StringArrayNodesGroup = function (_AbstractNodesGroup_) { + _inherits(StringArrayNodesGroup, _AbstractNodesGroup_); - function StringsArrayNodesGroup() { - _classCallCheck(this, StringsArrayNodesGroup); + function StringArrayNodesGroup() { + _classCallCheck(this, StringArrayNodesGroup); - var _this = _possibleConstructorReturn(this, (StringsArrayNodesGroup.__proto__ || Object.getPrototypeOf(StringsArrayNodesGroup)).apply(this, arguments)); + var _this = _possibleConstructorReturn(this, (StringArrayNodesGroup.__proto__ || Object.getPrototypeOf(StringArrayNodesGroup)).apply(this, arguments)); _this.appendState = AppendState_1.AppendState.AfterObfuscation; - _this.stringsArrayName = Utils_1.Utils.getRandomVariableName(StringsArrayNode_1.StringsArrayNode.ARRAY_RANDOM_LENGTH); - _this.stringsArrayCallsWrapper = Utils_1.Utils.getRandomVariableName(StringsArrayNode_1.StringsArrayNode.ARRAY_RANDOM_LENGTH); + _this.stringArrayName = Utils_1.Utils.getRandomVariableName(StringArrayNode_1.StringArrayNode.ARRAY_RANDOM_LENGTH); + _this.stringArrayCallsWrapper = Utils_1.Utils.getRandomVariableName(StringArrayNode_1.StringArrayNode.ARRAY_RANDOM_LENGTH); return _this; } - _createClass(StringsArrayNodesGroup, [{ + _createClass(StringArrayNodesGroup, [{ key: 'getNodes', value: function getNodes() { - if (!this.options.stringsArray) { + if (!this.options.stringArray) { return; } - if (this.options.rotateStringsArray) { - this.stringsArrayRotateValue = Utils_1.Utils.getRandomGenerator().integer({ + if (this.options.rotateStringArray) { + this.stringArrayRotateValue = Utils_1.Utils.getRandomGenerator().integer({ min: 100, max: 500 }); } else { - this.stringsArrayRotateValue = 0; + this.stringArrayRotateValue = 0; } - var stringsArray = new StringsArray_1.StringsArray(); - var stringsArrayNode = new StringsArrayNode_1.StringsArrayNode(stringsArray, this.stringsArrayName, this.stringsArrayRotateValue, this.options); - var customNodes = new Map([['stringsArrayNode', stringsArrayNode], ['stringsArrayCallsWrapper', new StringsArrayCallsWrapper_1.StringsArrayCallsWrapper(this.stringsArrayCallsWrapper, this.stringsArrayName, stringsArray, this.options)]]); - if (this.options.rotateStringsArray) { - customNodes.set('stringsArrayRotateFunctionNode', new StringsArrayRotateFunctionNode_1.StringsArrayRotateFunctionNode(this.stringsArrayName, stringsArray, this.stringsArrayRotateValue, this.options)); + var stringArray = new StringArray_1.StringArray(); + var stringArrayNode = new StringArrayNode_1.StringArrayNode(stringArray, this.stringArrayName, this.stringArrayRotateValue, this.options); + var customNodes = new Map([['stringArrayNode', stringArrayNode], ['stringArrayCallsWrapper', new StringArrayCallsWrapper_1.StringArrayCallsWrapper(this.stringArrayCallsWrapper, this.stringArrayName, stringArray, this.options)]]); + if (this.options.rotateStringArray) { + customNodes.set('stringArrayRotateFunctionNode', new StringArrayRotateFunctionNode_1.StringArrayRotateFunctionNode(this.stringArrayName, stringArray, this.stringArrayRotateValue, this.options)); } return this.syncCustomNodesWithNodesGroup(customNodes); } }]); - return StringsArrayNodesGroup; + return StringArrayNodesGroup; }(AbstractNodesGroup_1.AbstractNodesGroup); -exports.StringsArrayNodesGroup = StringsArrayNodesGroup; +exports.StringArrayNodesGroup = StringArrayNodesGroup; /***/ }, /* 47 */ @@ -3463,7 +3463,7 @@ var __metadata = undefined && undefined.__metadata || function (k, v) { }; var class_validator_1 = __webpack_require__(82); var TSourceMapMode_1 = __webpack_require__(79); -var TStringsArrayEncoding_1 = __webpack_require__(80); +var TStringArrayEncoding_1 = __webpack_require__(80); var DefaultPreset_1 = __webpack_require__(23); var OptionsNormalizer_1 = __webpack_require__(57); var ValidationErrorsFormatter_1 = __webpack_require__(58); @@ -3494,7 +3494,7 @@ __decorate([class_validator_1.IsArray(), class_validator_1.ArrayUnique(), class_ __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, "rotateStringsArray", void 0); +__decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "rotateStringArray", 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.IsString(), class_validator_1.ValidateIf(function (options) { @@ -3505,9 +3505,9 @@ __decorate([class_validator_1.IsString(), class_validator_1.ValidateIf(function }), __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, "stringsArray", void 0); -__decorate([class_validator_1.IsIn([true, false, 'base64', 'rc4']), __metadata('design:type', typeof (_b = typeof TStringsArrayEncoding_1.TStringsArrayEncoding !== 'undefined' && TStringsArrayEncoding_1.TStringsArrayEncoding) === 'function' && _b || Object)], Options.prototype, "stringsArrayEncoding", void 0); -__decorate([class_validator_1.IsNumber(), class_validator_1.Min(0), class_validator_1.Max(1), __metadata('design:type', Number)], Options.prototype, "stringsArrayThreshold", void 0); +__decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "stringArray", void 0); +__decorate([class_validator_1.IsIn([true, false, 'base64', 'rc4']), __metadata('design:type', typeof (_b = typeof TStringArrayEncoding_1.TStringArrayEncoding !== 'undefined' && TStringArrayEncoding_1.TStringArrayEncoding) === 'function' && _b || Object)], Options.prototype, "stringArrayEncoding", void 0); +__decorate([class_validator_1.IsNumber(), class_validator_1.Min(0), class_validator_1.Max(1), __metadata('design:type', Number)], Options.prototype, "stringArrayThreshold", void 0); __decorate([class_validator_1.IsBoolean(), __metadata('design:type', Boolean)], Options.prototype, "unicodeEscapeSequence", void 0); exports.Options = Options; var _a, _b; @@ -3635,25 +3635,25 @@ var OptionsNormalizer = function () { return options; } }, { - key: 'stringsArrayRule', - value: function stringsArrayRule(options) { - if (!options.stringsArray) { + key: 'stringArrayRule', + value: function stringArrayRule(options) { + if (!options.stringArray) { Object.assign(options, OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS); } return options; } }, { - key: 'stringsArrayEncodingRule', - value: function stringsArrayEncodingRule(options) { - if (options.stringsArrayEncoding === true) { + key: 'stringArrayEncodingRule', + value: function stringArrayEncodingRule(options) { + if (options.stringArrayEncoding === true) { Object.assign(options, OptionsNormalizer.UNICODE_ARRAY_ENCODING_OPTIONS); } return options; } }, { - key: 'stringsArrayThresholdRule', - value: function stringsArrayThresholdRule(options) { - if (options.stringsArrayThreshold === 0) { + key: 'stringArrayThresholdRule', + value: function stringArrayThresholdRule(options) { + if (options.stringArrayThreshold === 0) { Object.assign(options, OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS); } return options; @@ -3664,19 +3664,19 @@ var OptionsNormalizer = function () { }(); OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS = { - rotateStringsArray: false, - stringsArray: false, - stringsArrayEncoding: false, - stringsArrayThreshold: 0 + rotateStringArray: false, + stringArray: false, + stringArrayEncoding: false, + stringArrayThreshold: 0 }; OptionsNormalizer.SELF_DEFENDING_OPTIONS = { compact: true, selfDefending: true }; OptionsNormalizer.UNICODE_ARRAY_ENCODING_OPTIONS = { - stringsArrayEncoding: 'base64' + stringArrayEncoding: 'base64' }; -OptionsNormalizer.normalizerRules = [OptionsNormalizer.domainLockRule, OptionsNormalizer.selfDefendingRule, OptionsNormalizer.sourceMapBaseUrl, OptionsNormalizer.sourceMapFileName, OptionsNormalizer.stringsArrayRule, OptionsNormalizer.stringsArrayEncodingRule, OptionsNormalizer.stringsArrayThresholdRule]; +OptionsNormalizer.normalizerRules = [OptionsNormalizer.domainLockRule, OptionsNormalizer.selfDefendingRule, OptionsNormalizer.sourceMapBaseUrl, OptionsNormalizer.sourceMapFileName, OptionsNormalizer.stringArrayRule, OptionsNormalizer.stringArrayEncodingRule, OptionsNormalizer.stringArrayThresholdRule]; exports.OptionsNormalizer = OptionsNormalizer; /***/ }, @@ -4211,7 +4211,7 @@ exports.SelfDefendingTemplate = SelfDefendingTemplate; 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.stringToUnicodeEscapeSequence("\\w+ *\\(\\) *{\\w+ *") + "';\n this.secondState = '" + Utils_1.Utils.stringToUnicodeEscapeSequence("['|\"].+['|\"];? *}") + "';\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({stringsArrayCallsWrapperName}).checkState();\n "; + 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.stringToUnicodeEscapeSequence("\\w+ *\\(\\) *{\\w+ *") + "';\n this.secondState = '" + Utils_1.Utils.stringToUnicodeEscapeSequence("['|\"].+['|\"];? *}") + "';\n };\n \n StatesClass.prototype.checkState = function () {\n var regExp = new RegExp(this.firstState + this.secondState);\n\n return this.runState(regExp.test(this.newState.toString()) ? --this.states[1] : --this.states[0]);\n };\n \n StatesClass.prototype.runState = function (stateResult) {\n if (!Boolean(~stateResult)) {\n return stateResult;\n }\n \n return this.getState(this.rc4Bytes);\n };\n\n StatesClass.prototype.getState = function (rc4Bytes) {\n for (var i = 0, len = this.states.length; i < len; i++) {\n this.states.push(Math.round(Math.random()));\n len = this.states.length;\n }\n \n return rc4Bytes(this.states[0]);\n };\n\n new StatesClass({stringArrayCallsWrapperName}).checkState();\n "; } exports.SelfDefendingTemplate = SelfDefendingTemplate; @@ -4222,10 +4222,10 @@ exports.SelfDefendingTemplate = SelfDefendingTemplate; "use strict"; "use strict"; -function StringsArrayBase64DecodeNodeTemplate() { - return " \n if (!{stringsArrayCallsWrapperName}.atobPolyfillAppended) {\n {atobPolyfill}\n \n {stringsArrayCallsWrapperName}.atobPolyfillAppended = true;\n }\n \n if (!{stringsArrayCallsWrapperName}.base64DecodeUnicode) { \n {stringsArrayCallsWrapperName}.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 (!{stringsArrayCallsWrapperName}.data) {\n {stringsArrayCallsWrapperName}.data = {};\n }\n \n if (!{stringsArrayCallsWrapperName}.data[index]) {\n {selfDefendingCode}\n \n value = {stringsArrayCallsWrapperName}.base64DecodeUnicode(value);\n {stringsArrayCallsWrapperName}.data[index] = value;\n } else {\n value = {stringsArrayCallsWrapperName}.data[index];\n } \n "; +function StringArrayBase64DecodeNodeTemplate() { + return " \n if (!{stringArrayCallsWrapperName}.atobPolyfillAppended) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}.atobPolyfillAppended = true;\n }\n \n if (!{stringArrayCallsWrapperName}.base64DecodeUnicode) { \n {stringArrayCallsWrapperName}.base64DecodeUnicode = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n }\n \n if (!{stringArrayCallsWrapperName}.data) {\n {stringArrayCallsWrapperName}.data = {};\n }\n \n if (!{stringArrayCallsWrapperName}.data[index]) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = {stringArrayCallsWrapperName}.data[index];\n } \n "; } -exports.StringsArrayBase64DecodeNodeTemplate = StringsArrayBase64DecodeNodeTemplate; +exports.StringArrayBase64DecodeNodeTemplate = StringArrayBase64DecodeNodeTemplate; /***/ }, /* 74 */ @@ -4234,10 +4234,10 @@ exports.StringsArrayBase64DecodeNodeTemplate = StringsArrayBase64DecodeNodeTempl "use strict"; "use strict"; -function StringsArrayCallsWrapperTemplate() { - return "\n var {stringsArrayCallsWrapperName} = function (index, key) {\n var index = parseInt(index, 0x10);\n var value = {stringsArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "; +function StringArrayCallsWrapperTemplate() { + return "\n var {stringArrayCallsWrapperName} = function (index, key) {\n var index = parseInt(index, 0x10);\n var value = {stringArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n "; } -exports.StringsArrayCallsWrapperTemplate = StringsArrayCallsWrapperTemplate; +exports.StringArrayCallsWrapperTemplate = StringArrayCallsWrapperTemplate; /***/ }, /* 75 */ @@ -4246,10 +4246,10 @@ exports.StringsArrayCallsWrapperTemplate = StringsArrayCallsWrapperTemplate; "use strict"; "use strict"; -function StringsArrayRc4DecodeNodeTemplate() { - return "\n if (!{stringsArrayCallsWrapperName}.atobPolyfillAppended) { \n {atobPolyfill}\n \n {stringsArrayCallsWrapperName}.atobPolyfillAppended = true;\n }\n \n if (!{stringsArrayCallsWrapperName}.rc4) { \n {rc4Polyfill}\n \n {stringsArrayCallsWrapperName}.rc4 = rc4;\n }\n \n if (!{stringsArrayCallsWrapperName}.data) {\n {stringsArrayCallsWrapperName}.data = {};\n }\n\n if ({stringsArrayCallsWrapperName}.data[index] === undefined) {\n if (!{stringsArrayCallsWrapperName}.once) {\n {selfDefendingCode}\n \n {stringsArrayCallsWrapperName}.once = true;\n }\n \n value = {stringsArrayCallsWrapperName}.rc4(value, key);\n {stringsArrayCallsWrapperName}.data[index] = value;\n } else {\n value = {stringsArrayCallsWrapperName}.data[index];\n }\n "; +function StringArrayRc4DecodeNodeTemplate() { + return "\n if (!{stringArrayCallsWrapperName}.atobPolyfillAppended) { \n {atobPolyfill}\n \n {stringArrayCallsWrapperName}.atobPolyfillAppended = true;\n }\n \n if (!{stringArrayCallsWrapperName}.rc4) { \n {rc4Polyfill}\n \n {stringArrayCallsWrapperName}.rc4 = rc4;\n }\n \n if (!{stringArrayCallsWrapperName}.data) {\n {stringArrayCallsWrapperName}.data = {};\n }\n\n if ({stringArrayCallsWrapperName}.data[index] === undefined) {\n if (!{stringArrayCallsWrapperName}.once) {\n {selfDefendingCode}\n \n {stringArrayCallsWrapperName}.once = true;\n }\n \n value = {stringArrayCallsWrapperName}.rc4(value, key);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = {stringArrayCallsWrapperName}.data[index];\n }\n "; } -exports.StringsArrayRc4DecodeNodeTemplate = StringsArrayRc4DecodeNodeTemplate; +exports.StringArrayRc4DecodeNodeTemplate = StringArrayRc4DecodeNodeTemplate; /***/ }, /* 76 */ @@ -4258,10 +4258,10 @@ exports.StringsArrayRc4DecodeNodeTemplate = StringsArrayRc4DecodeNodeTemplate; "use strict"; "use strict"; -function StringsArrayTemplate() { - return "\n var {stringsArrayName} = [{stringsArray}];\n "; +function StringArrayTemplate() { + return "\n var {stringArrayName} = [{stringArray}];\n "; } -exports.StringsArrayTemplate = StringsArrayTemplate; +exports.StringArrayTemplate = StringArrayTemplate; /***/ }, /* 77 */ @@ -4283,10 +4283,10 @@ exports.SelfDefendingTemplate = SelfDefendingTemplate; "use strict"; "use strict"; -function StringsArrayRotateFunctionTemplate() { - return "\n (function (array, {timesName}) {\n var {whileFunctionName} = function (times) {\n while (--times) {\n array['push'](array['shift']());\n }\n };\n \n {code}\n })({stringsArrayName}, 0x{stringsArrayRotateValue});\n "; +function StringArrayRotateFunctionTemplate() { + return "\n (function (array, {timesName}) {\n var {whileFunctionName} = function (times) {\n while (--times) {\n array['push'](array['shift']());\n }\n };\n \n {code}\n })({stringArrayName}, 0x{stringArrayRotateValue});\n "; } -exports.StringsArrayRotateFunctionTemplate = StringsArrayRotateFunctionTemplate; +exports.StringArrayRotateFunctionTemplate = StringArrayRotateFunctionTemplate; /***/ }, /* 79 */ diff --git a/src/Obfuscator.ts b/src/Obfuscator.ts index 08046bf4..b3a0a600 100644 --- a/src/Obfuscator.ts +++ b/src/Obfuscator.ts @@ -26,7 +26,7 @@ import { NodeUtils } from './node/NodeUtils'; import { ObjectExpressionObfuscator } from './node-obfuscators/ObjectExpressionObfuscator'; import { SelfDefendingNodesGroup } from './node-groups/SelfDefendingNodesGroup'; import { StackTraceAnalyzer } from './stack-trace-analyzer/StackTraceAnalyzer'; -import { StringsArrayNodesGroup } from './node-groups/StringsArrayNodesGroup'; +import { StringArrayNodesGroup } from './node-groups/StringArrayNodesGroup'; import { VariableDeclarationObfuscator } from './node-obfuscators/VariableDeclarationObfuscator'; export class Obfuscator implements IObfuscator { @@ -38,7 +38,7 @@ export class Obfuscator implements IObfuscator { SelfDefendingNodesGroup, ConsoleOutputNodesGroup, DebugProtectionNodesGroup, - StringsArrayNodesGroup + StringArrayNodesGroup ]; /** diff --git a/src/StringsArray.ts b/src/StringArray.ts similarity index 97% rename from src/StringsArray.ts rename to src/StringArray.ts index 72494585..99943427 100644 --- a/src/StringsArray.ts +++ b/src/StringArray.ts @@ -1,6 +1,6 @@ import { Utils } from './Utils'; -export class StringsArray { +export class StringArray { /** * @type {string[]} */ diff --git a/src/cli/JavaScriptObfuscatorCLI.ts b/src/cli/JavaScriptObfuscatorCLI.ts index 1da233ab..6776daba 100644 --- a/src/cli/JavaScriptObfuscatorCLI.ts +++ b/src/cli/JavaScriptObfuscatorCLI.ts @@ -1,13 +1,13 @@ import * as commander from 'commander'; import * as path from 'path'; -import { TStringsArrayEncoding } from '../types/TStringsArrayEncoding'; +import { TStringArrayEncoding } from '../types/TStringArrayEncoding'; import { IObfuscationResult } from '../interfaces/IObfuscationResult'; import { IObfuscatorOptions } from '../interfaces/IObfuscatorOptions'; import { SourceMapMode } from '../enums/SourceMapMode'; -import { StringsArrayEncoding } from '../enums/StringsArrayEncoding'; +import { StringArrayEncoding } from '../enums/StringArrayEncoding'; import { DEFAULT_PRESET } from '../preset-options/DefaultPreset'; @@ -84,17 +84,17 @@ export class JavaScriptObfuscatorCLI { /** * @param value - * @returns {TStringsArrayEncoding} + * @returns {TStringArrayEncoding} */ - private static parseStringsArrayEncoding (value: string): TStringsArrayEncoding { + private static parseStringArrayEncoding (value: string): TStringArrayEncoding { switch (value) { case 'true': case '1': - case StringsArrayEncoding.base64: + case StringArrayEncoding.base64: return true; - case StringsArrayEncoding.rc4: - return StringsArrayEncoding.rc4; + case StringArrayEncoding.rc4: + return StringArrayEncoding.rc4; default: return false; @@ -150,7 +150,7 @@ export class JavaScriptObfuscatorCLI { .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)', (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('--rotateStringsArray ', 'Disable rotation of unicode array values during obfuscation', JavaScriptObfuscatorCLI.parseBoolean) + .option('--rotateStringArray ', '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`') @@ -160,10 +160,10 @@ export class JavaScriptObfuscatorCLI { 'Specify source map output mode', JavaScriptObfuscatorCLI.parseSourceMapMode ) - .option('--stringsArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean) - .option('--stringsArrayEncoding [true, false, base64, rc4]', 'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed', JavaScriptObfuscatorCLI.parseStringsArrayEncoding) - .option('--stringsArrayThreshold ', 'The probability that the literal string will be inserted into stringsArray (Default: 0.8, Min: 0, Max: 1)', parseFloat) - .option('--unicodeEscapeSequence ', 'Allows to enable/disable strings conversion to unicode escape sequence', JavaScriptObfuscatorCLI.parseBoolean) + .option('--stringArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean) + .option('--stringArrayEncoding [true, false, base64, rc4]', 'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed', JavaScriptObfuscatorCLI.parseStringArrayEncoding) + .option('--stringArrayThreshold ', 'The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)', parseFloat) + .option('--unicodeEscapeSequence ', 'Allows to enable/disable string conversion to unicode escape sequence', JavaScriptObfuscatorCLI.parseBoolean) .parse(this.rawArguments); this.commands.on('--help', () => { diff --git a/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts b/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts new file mode 100644 index 00000000..849dfab5 --- /dev/null +++ b/src/custom-nodes/string-array-nodes/StringArrayCallsWrapper.ts @@ -0,0 +1,146 @@ +import 'format-unicorn'; + +import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; +import { TStatement } from '../../types/TStatement'; + +import { IOptions } from '../../interfaces/IOptions'; + +import { AppendState } from '../../enums/AppendState'; +import { StringArrayEncoding } from '../../enums/StringArrayEncoding'; + +import { NO_CUSTOM_NODES_PRESET } from '../../preset-options/NoCustomNodesPreset'; + +import { AtobTemplate } from '../../templates/custom-nodes/AtobTemplate'; +import { Rc4Template } from '../../templates/custom-nodes/Rc4Template'; +import { SelfDefendingTemplate } from '../../templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/SelfDefendingTemplate'; +import { StringArrayBase64DecodeNodeTemplate } from '../../templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayBase64DecodeNodeTemplate'; +import { StringArrayCallsWrapperTemplate } from '../../templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayCallsWrapperTemplate'; +import { StringArrayRc4DecodeNodeTemplate } from '../../templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayRC4DecodeNodeTemplate'; + +import { AbstractCustomNode } from '../AbstractCustomNode'; +import { JavaScriptObfuscator } from '../../JavaScriptObfuscator'; +import { NodeAppender } from '../../node/NodeAppender'; +import { NodeUtils } from '../../node/NodeUtils'; +import { StringArray } from '../../StringArray'; + +export class StringArrayCallsWrapper extends AbstractCustomNode { + /** + * @type {AppendState} + */ + protected appendState: AppendState = AppendState.AfterObfuscation; + + /** + * @type {StringArray} + */ + private stringArray: StringArray; + + /** + * @type {string} + */ + private stringArrayName: string; + + /** + * @type {string} + */ + private stringArrayCallsWrapperName: string; + + /** + * @param stringArrayCallsWrapperName + * @param stringArrayName + * @param stringArray + * @param options + */ + constructor ( + stringArrayCallsWrapperName: string, + stringArrayName: string, + stringArray: StringArray, + options: IOptions + ) { + super(options); + + this.stringArrayCallsWrapperName = stringArrayCallsWrapperName; + this.stringArrayName = stringArrayName; + this.stringArray = stringArray; + } + + /** + * @param blockScopeNode + */ + public appendNode (blockScopeNode: TNodeWithBlockStatement): void { + if (!this.stringArray.getLength()) { + return; + } + + NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), 1); + } + + /** + * @returns {string} + */ + public getNodeIdentifier (): string { + return this.stringArrayCallsWrapperName; + }; + + /** + * @returns {TStatement[]} + */ + public getNode (): TStatement[] { + return super.getNode(); + } + + /** + * @returns {string} + */ + protected getDecodeStringArrayTemplate (): string { + let decodeStringArrayTemplate: string = '', + selfDefendingCode: string = ''; + + if (this.options.selfDefending) { + selfDefendingCode = SelfDefendingTemplate().formatUnicorn({ + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName, + stringArrayName: this.stringArrayName + }); + } + + switch (this.options.stringArrayEncoding) { + case StringArrayEncoding.base64: + decodeStringArrayTemplate = StringArrayBase64DecodeNodeTemplate().formatUnicorn({ + atobPolyfill: AtobTemplate(), + selfDefendingCode, + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName + }); + + break; + + case StringArrayEncoding.rc4: + decodeStringArrayTemplate = StringArrayRc4DecodeNodeTemplate().formatUnicorn({ + atobPolyfill: AtobTemplate(), + rc4Polyfill: Rc4Template(), + selfDefendingCode, + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName + }); + + break; + } + + return decodeStringArrayTemplate; + } + + /** + * @returns {TStatement[]} + */ + protected getNodeStructure (): TStatement[] { + const decodeNodeTemplate: string = this.getDecodeStringArrayTemplate(); + + return NodeUtils.convertCodeToStructure( + JavaScriptObfuscator.obfuscate( + StringArrayCallsWrapperTemplate().formatUnicorn({ + decodeNodeTemplate, + stringArrayCallsWrapperName: this.stringArrayCallsWrapperName, + stringArrayName: this.stringArrayName + }), + NO_CUSTOM_NODES_PRESET + ).getObfuscatedCode() + ); + } +} diff --git a/src/custom-nodes/strings-array-nodes/StringsArrayNode.ts b/src/custom-nodes/string-array-nodes/StringArrayNode.ts similarity index 56% rename from src/custom-nodes/strings-array-nodes/StringsArrayNode.ts rename to src/custom-nodes/string-array-nodes/StringArrayNode.ts index 12eec5f9..303097b3 100644 --- a/src/custom-nodes/strings-array-nodes/StringsArrayNode.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayNode.ts @@ -7,15 +7,15 @@ import { IOptions } from '../../interfaces/IOptions'; import { AppendState } from '../../enums/AppendState'; -import { StringsArray } from '../../StringsArray'; +import { StringArray } from '../../StringArray'; -import { StringsArrayTemplate } from '../../templates/custom-nodes/strings-array-nodes/strings-array-node/StringsArrayTemplate'; +import { StringArrayTemplate } from '../../templates/custom-nodes/string-array-nodes/string-array-node/StringArrayTemplate'; import { AbstractCustomNode } from '../AbstractCustomNode'; import { NodeAppender } from '../../node/NodeAppender'; import { NodeUtils } from '../../node/NodeUtils'; -export class StringsArrayNode extends AbstractCustomNode { +export class StringArrayNode extends AbstractCustomNode { /** * @type {number} */ @@ -27,44 +27,44 @@ export class StringsArrayNode extends AbstractCustomNode { protected appendState: AppendState = AppendState.AfterObfuscation; /** - * @type {StringsArray} + * @type {StringArray} */ - private stringsArray: StringsArray; + private stringArray: StringArray; /** * @type {string} */ - private stringsArrayName: string; + private stringArrayName: string; /** * @type {number} */ - private stringsArrayRotateValue: number; + private stringArrayRotateValue: number; /** - * @param stringsArray - * @param stringsArrayName - * @param stringsArrayRotateValue + * @param stringArray + * @param stringArrayName + * @param stringArrayRotateValue * @param options */ constructor ( - stringsArray: StringsArray, - stringsArrayName: string, - stringsArrayRotateValue: number = 0, + stringArray: StringArray, + stringArrayName: string, + stringArrayRotateValue: number = 0, options: IOptions ) { super(options); - this.stringsArray = stringsArray; - this.stringsArrayName = stringsArrayName; - this.stringsArrayRotateValue = stringsArrayRotateValue; + this.stringArray = stringArray; + this.stringArrayName = stringArrayName; + this.stringArrayRotateValue = stringArrayRotateValue; } /** * @param blockScopeNode */ public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - if (!this.stringsArray.getLength()) { + if (!this.stringArray.getLength()) { return; } @@ -75,21 +75,21 @@ export class StringsArrayNode extends AbstractCustomNode { * @returns {string} */ public getNodeIdentifier (): string { - return this.stringsArrayName; + return this.stringArrayName; } /** - * @returns {StringsArray} + * @returns {StringArray} */ - public getNodeData (): StringsArray { - return this.stringsArray; + public getNodeData (): StringArray { + return this.stringArray; } /** * @returns {TStatement[]} */ public getNode (): TStatement[] { - this.stringsArray.rotateArray(this.stringsArrayRotateValue); + this.stringArray.rotateArray(this.stringArrayRotateValue); return super.getNode(); } @@ -98,7 +98,7 @@ export class StringsArrayNode extends AbstractCustomNode { * @param data */ public updateNodeData (data: string): void { - this.stringsArray.addToArray(data); + this.stringArray.addToArray(data); } /** @@ -106,9 +106,9 @@ export class StringsArrayNode extends AbstractCustomNode { */ protected getNodeStructure (): TStatement[] { return NodeUtils.convertCodeToStructure( - StringsArrayTemplate().formatUnicorn({ - stringsArrayName: this.stringsArrayName, - stringsArray: this.stringsArray.toString() + StringArrayTemplate().formatUnicorn({ + stringArrayName: this.stringArrayName, + stringArray: this.stringArray.toString() }) ); } diff --git a/src/custom-nodes/strings-array-nodes/StringsArrayRotateFunctionNode.ts b/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts similarity index 65% rename from src/custom-nodes/strings-array-nodes/StringsArrayRotateFunctionNode.ts rename to src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts index 7be74139..9f00be66 100644 --- a/src/custom-nodes/strings-array-nodes/StringsArrayRotateFunctionNode.ts +++ b/src/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.ts @@ -9,61 +9,61 @@ import { AppendState } from '../../enums/AppendState'; import { NO_CUSTOM_NODES_PRESET } from '../../preset-options/NoCustomNodesPreset'; -import { SelfDefendingTemplate } from '../../templates/custom-nodes/strings-array-nodes/strings-array-rotate-function-node/SelfDefendingTemplate'; -import { StringsArrayRotateFunctionTemplate } from '../../templates/custom-nodes/strings-array-nodes/strings-array-rotate-function-node/StringsArrayRotateFunctionTemplate'; +import { SelfDefendingTemplate } from '../../templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate'; +import { StringArrayRotateFunctionTemplate } from '../../templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/StringArrayRotateFunctionTemplate'; import { AbstractCustomNode } from '../AbstractCustomNode'; import { JavaScriptObfuscator } from '../../JavaScriptObfuscator'; import { NodeAppender } from '../../node/NodeAppender'; import { NodeUtils } from '../../node/NodeUtils'; -import { StringsArray } from '../../StringsArray'; +import { StringArray } from '../../StringArray'; import { Utils } from '../../Utils'; -export class StringsArrayRotateFunctionNode extends AbstractCustomNode { +export class StringArrayRotateFunctionNode extends AbstractCustomNode { /** * @type {AppendState} */ protected appendState: AppendState = AppendState.AfterObfuscation; /** - * @type {StringsArray} + * @type {StringArray} */ - private stringsArray: StringsArray; + private stringArray: StringArray; /** * @type {string} */ - private stringsArrayName: string; + private stringArrayName: string; /** * @param {number} */ - private stringsArrayRotateValue: number; + private stringArrayRotateValue: number; /** - * @param stringsArrayName - * @param stringsArray - * @param stringsArrayRotateValue + * @param stringArrayName + * @param stringArray + * @param stringArrayRotateValue * @param options */ constructor ( - stringsArrayName: string, - stringsArray: StringsArray, - stringsArrayRotateValue: number, + stringArrayName: string, + stringArray: StringArray, + stringArrayRotateValue: number, options: IOptions ) { super(options); - this.stringsArrayName = stringsArrayName; - this.stringsArray = stringsArray; - this.stringsArrayRotateValue = stringsArrayRotateValue; + this.stringArrayName = stringArrayName; + this.stringArray = stringArray; + this.stringArrayRotateValue = stringArrayRotateValue; } /** * @param blockScopeNode */ public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - if (!this.stringsArray.getLength()) { + if (!this.stringArray.getLength()) { return; } @@ -96,11 +96,11 @@ export class StringsArrayRotateFunctionNode extends AbstractCustomNode { return NodeUtils.convertCodeToStructure( JavaScriptObfuscator.obfuscate( - StringsArrayRotateFunctionTemplate().formatUnicorn({ + StringArrayRotateFunctionTemplate().formatUnicorn({ code, timesName, - stringsArrayName: this.stringsArrayName, - stringsArrayRotateValue: Utils.decToHex(this.stringsArrayRotateValue), + stringArrayName: this.stringArrayName, + stringArrayRotateValue: Utils.decToHex(this.stringArrayRotateValue), whileFunctionName }), NO_CUSTOM_NODES_PRESET diff --git a/src/custom-nodes/strings-array-nodes/StringsArrayCallsWrapper.ts b/src/custom-nodes/strings-array-nodes/StringsArrayCallsWrapper.ts deleted file mode 100644 index c92e2a52..00000000 --- a/src/custom-nodes/strings-array-nodes/StringsArrayCallsWrapper.ts +++ /dev/null @@ -1,146 +0,0 @@ -import 'format-unicorn'; - -import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement'; -import { TStatement } from '../../types/TStatement'; - -import { IOptions } from '../../interfaces/IOptions'; - -import { AppendState } from '../../enums/AppendState'; -import { StringsArrayEncoding } from '../../enums/StringsArrayEncoding'; - -import { NO_CUSTOM_NODES_PRESET } from '../../preset-options/NoCustomNodesPreset'; - -import { AtobTemplate } from '../../templates/custom-nodes/AtobTemplate'; -import { Rc4Template } from '../../templates/custom-nodes/Rc4Template'; -import { SelfDefendingTemplate } from '../../templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/SelfDefendingTemplate'; -import { StringsArrayBase64DecodeNodeTemplate } from '../../templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayBase64DecodeNodeTemplate'; -import { StringsArrayCallsWrapperTemplate } from '../../templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayCallsWrapperTemplate'; -import { StringsArrayRc4DecodeNodeTemplate } from '../../templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayRC4DecodeNodeTemplate'; - -import { AbstractCustomNode } from '../AbstractCustomNode'; -import { JavaScriptObfuscator } from '../../JavaScriptObfuscator'; -import { NodeAppender } from '../../node/NodeAppender'; -import { NodeUtils } from '../../node/NodeUtils'; -import { StringsArray } from '../../StringsArray'; - -export class StringsArrayCallsWrapper extends AbstractCustomNode { - /** - * @type {AppendState} - */ - protected appendState: AppendState = AppendState.AfterObfuscation; - - /** - * @type {StringsArray} - */ - private stringsArray: StringsArray; - - /** - * @type {string} - */ - private stringsArrayName: string; - - /** - * @type {string} - */ - private stringsArrayCallsWrapperName: string; - - /** - * @param stringsArrayCallsWrapperName - * @param stringsArrayName - * @param stringsArray - * @param options - */ - constructor ( - stringsArrayCallsWrapperName: string, - stringsArrayName: string, - stringsArray: StringsArray, - options: IOptions - ) { - super(options); - - this.stringsArrayCallsWrapperName = stringsArrayCallsWrapperName; - this.stringsArrayName = stringsArrayName; - this.stringsArray = stringsArray; - } - - /** - * @param blockScopeNode - */ - public appendNode (blockScopeNode: TNodeWithBlockStatement): void { - if (!this.stringsArray.getLength()) { - return; - } - - NodeAppender.insertNodeAtIndex(blockScopeNode, this.getNode(), 1); - } - - /** - * @returns {string} - */ - public getNodeIdentifier (): string { - return this.stringsArrayCallsWrapperName; - }; - - /** - * @returns {TStatement[]} - */ - public getNode (): TStatement[] { - return super.getNode(); - } - - /** - * @returns {string} - */ - protected getDecodeStringsArrayTemplate (): string { - let decodeStringsArrayTemplate: string = '', - selfDefendingCode: string = ''; - - if (this.options.selfDefending) { - selfDefendingCode = SelfDefendingTemplate().formatUnicorn({ - stringsArrayCallsWrapperName: this.stringsArrayCallsWrapperName, - stringsArrayName: this.stringsArrayName - }); - } - - switch (this.options.stringsArrayEncoding) { - case StringsArrayEncoding.base64: - decodeStringsArrayTemplate = StringsArrayBase64DecodeNodeTemplate().formatUnicorn({ - atobPolyfill: AtobTemplate(), - selfDefendingCode, - stringsArrayCallsWrapperName: this.stringsArrayCallsWrapperName - }); - - break; - - case StringsArrayEncoding.rc4: - decodeStringsArrayTemplate = StringsArrayRc4DecodeNodeTemplate().formatUnicorn({ - atobPolyfill: AtobTemplate(), - rc4Polyfill: Rc4Template(), - selfDefendingCode, - stringsArrayCallsWrapperName: this.stringsArrayCallsWrapperName - }); - - break; - } - - return decodeStringsArrayTemplate; - } - - /** - * @returns {TStatement[]} - */ - protected getNodeStructure (): TStatement[] { - const decodeNodeTemplate: string = this.getDecodeStringsArrayTemplate(); - - return NodeUtils.convertCodeToStructure( - JavaScriptObfuscator.obfuscate( - StringsArrayCallsWrapperTemplate().formatUnicorn({ - decodeNodeTemplate, - stringsArrayCallsWrapperName: this.stringsArrayCallsWrapperName, - stringsArrayName: this.stringsArrayName - }), - NO_CUSTOM_NODES_PRESET - ).getObfuscatedCode() - ); - } -} diff --git a/src/enums/StringArrayEncoding.ts b/src/enums/StringArrayEncoding.ts new file mode 100644 index 00000000..e34aa9dd --- /dev/null +++ b/src/enums/StringArrayEncoding.ts @@ -0,0 +1,4 @@ +export const StringArrayEncoding: any = { + base64: 'base64', + rc4: 'rc4' +}; diff --git a/src/enums/StringsArrayEncoding.ts b/src/enums/StringsArrayEncoding.ts deleted file mode 100644 index 230a7438..00000000 --- a/src/enums/StringsArrayEncoding.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const StringsArrayEncoding: any = { - base64: 'base64', - rc4: 'rc4' -}; diff --git a/src/interfaces/IObfuscatorOptions.d.ts b/src/interfaces/IObfuscatorOptions.d.ts index 29415423..eef2e4b1 100644 --- a/src/interfaces/IObfuscatorOptions.d.ts +++ b/src/interfaces/IObfuscatorOptions.d.ts @@ -1,5 +1,5 @@ import { TSourceMapMode } from '../types/TSourceMapMode'; -import { TStringsArrayEncoding } from '../types/TStringsArrayEncoding'; +import { TStringArrayEncoding } from '../types/TStringArrayEncoding'; export interface IObfuscatorOptions { compact?: boolean; @@ -8,15 +8,15 @@ export interface IObfuscatorOptions { disableConsoleOutput?: boolean; domainLock?: string[]; reservedNames?: string[]; - rotateStringsArray?: boolean; + rotateStringArray?: boolean; selfDefending?: boolean; sourceMap?: boolean; sourceMapBaseUrl?: string; sourceMapFileName?: string; sourceMapMode?: TSourceMapMode; - stringsArray?: boolean; - stringsArrayEncoding?: TStringsArrayEncoding; - stringsArrayThreshold?: number; + stringArray?: boolean; + stringArrayEncoding?: TStringArrayEncoding; + stringArrayThreshold?: number; unicodeEscapeSequence?: boolean; [key: string]: any; } diff --git a/src/interfaces/IOptions.d.ts b/src/interfaces/IOptions.d.ts index e9b67d09..14757a3b 100644 --- a/src/interfaces/IOptions.d.ts +++ b/src/interfaces/IOptions.d.ts @@ -1,5 +1,5 @@ import { TSourceMapMode } from '../types/TSourceMapMode'; -import { TStringsArrayEncoding } from '../types/TStringsArrayEncoding'; +import { TStringArrayEncoding } from '../types/TStringArrayEncoding'; export interface IOptions { readonly compact: boolean; @@ -8,14 +8,14 @@ export interface IOptions { readonly disableConsoleOutput: boolean; readonly domainLock: string[]; readonly reservedNames: string[]; - readonly rotateStringsArray: boolean; + readonly rotateStringArray: boolean; readonly selfDefending: boolean; readonly sourceMap: boolean; readonly sourceMapBaseUrl: string; readonly sourceMapFileName: string; readonly sourceMapMode: TSourceMapMode; - readonly stringsArray: boolean; - readonly stringsArrayEncoding: TStringsArrayEncoding; - readonly stringsArrayThreshold: number; + readonly stringArray: boolean; + readonly stringArrayEncoding: TStringArrayEncoding; + readonly stringArrayThreshold: number; readonly unicodeEscapeSequence: boolean; } diff --git a/src/node-groups/StringArrayNodesGroup.ts b/src/node-groups/StringArrayNodesGroup.ts new file mode 100644 index 00000000..242e084c --- /dev/null +++ b/src/node-groups/StringArrayNodesGroup.ts @@ -0,0 +1,87 @@ +import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; + +import { AppendState } from '../enums/AppendState'; + +import { StringArrayCallsWrapper } from '../custom-nodes/string-array-nodes/StringArrayCallsWrapper'; +import { StringArrayNode } from '../custom-nodes/string-array-nodes/StringArrayNode'; +import { StringArrayRotateFunctionNode } from '../custom-nodes/string-array-nodes/StringArrayRotateFunctionNode'; + +import { AbstractNodesGroup } from './AbstractNodesGroup'; +import { StringArray } from '../StringArray'; +import { Utils } from '../Utils'; + +export class StringArrayNodesGroup extends AbstractNodesGroup { + /** + * @type {AppendState} + */ + protected appendState: AppendState = AppendState.AfterObfuscation; + + /** + * @type {string} + */ + private stringArrayName: string = Utils.getRandomVariableName(StringArrayNode.ARRAY_RANDOM_LENGTH); + + /** + * @type {string} + */ + private stringArrayCallsWrapper: string = Utils.getRandomVariableName(StringArrayNode.ARRAY_RANDOM_LENGTH); + + /** + * @type {number} + */ + private stringArrayRotateValue: number; + + /** + * @returns {Map | undefined} + */ + public getNodes (): Map | undefined { + if (!this.options.stringArray) { + return; + } + + if (this.options.rotateStringArray) { + this.stringArrayRotateValue = Utils.getRandomGenerator().integer({ + min: 100, + max: 500 + }); + } else { + this.stringArrayRotateValue = 0; + } + + const stringArray: StringArray = new StringArray(); + const stringArrayNode: ICustomNode = new StringArrayNode( + stringArray, + this.stringArrayName, + this.stringArrayRotateValue, + this.options + ); + const customNodes: Map = new Map ([ + [ + 'stringArrayNode', stringArrayNode, + ], + [ + 'stringArrayCallsWrapper', + new StringArrayCallsWrapper( + this.stringArrayCallsWrapper, + this.stringArrayName, + stringArray, + this.options + ) + ] + ]); + + if (this.options.rotateStringArray) { + customNodes.set( + 'stringArrayRotateFunctionNode', + new StringArrayRotateFunctionNode( + this.stringArrayName, + stringArray, + this.stringArrayRotateValue, + this.options + ) + ); + } + + return this.syncCustomNodesWithNodesGroup(customNodes); + } +} diff --git a/src/node-groups/StringsArrayNodesGroup.ts b/src/node-groups/StringsArrayNodesGroup.ts deleted file mode 100644 index 0569d004..00000000 --- a/src/node-groups/StringsArrayNodesGroup.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode'; - -import { AppendState } from '../enums/AppendState'; - -import { StringsArrayCallsWrapper } from '../custom-nodes/strings-array-nodes/StringsArrayCallsWrapper'; -import { StringsArrayNode } from '../custom-nodes/strings-array-nodes/StringsArrayNode'; -import { StringsArrayRotateFunctionNode } from '../custom-nodes/strings-array-nodes/StringsArrayRotateFunctionNode'; - -import { AbstractNodesGroup } from './AbstractNodesGroup'; -import { StringsArray } from '../StringsArray'; -import { Utils } from '../Utils'; - -export class StringsArrayNodesGroup extends AbstractNodesGroup { - /** - * @type {AppendState} - */ - protected appendState: AppendState = AppendState.AfterObfuscation; - - /** - * @type {string} - */ - private stringsArrayName: string = Utils.getRandomVariableName(StringsArrayNode.ARRAY_RANDOM_LENGTH); - - /** - * @type {string} - */ - private stringsArrayCallsWrapper: string = Utils.getRandomVariableName(StringsArrayNode.ARRAY_RANDOM_LENGTH); - - /** - * @type {number} - */ - private stringsArrayRotateValue: number; - - /** - * @returns {Map | undefined} - */ - public getNodes (): Map | undefined { - if (!this.options.stringsArray) { - return; - } - - if (this.options.rotateStringsArray) { - this.stringsArrayRotateValue = Utils.getRandomGenerator().integer({ - min: 100, - max: 500 - }); - } else { - this.stringsArrayRotateValue = 0; - } - - const stringsArray: StringsArray = new StringsArray(); - const stringsArrayNode: ICustomNode = new StringsArrayNode( - stringsArray, - this.stringsArrayName, - this.stringsArrayRotateValue, - this.options - ); - const customNodes: Map = new Map ([ - [ - 'stringsArrayNode', stringsArrayNode, - ], - [ - 'stringsArrayCallsWrapper', - new StringsArrayCallsWrapper( - this.stringsArrayCallsWrapper, - this.stringsArrayName, - stringsArray, - this.options - ) - ] - ]); - - if (this.options.rotateStringsArray) { - customNodes.set( - 'stringsArrayRotateFunctionNode', - new StringsArrayRotateFunctionNode( - this.stringsArrayName, - stringsArray, - this.stringsArrayRotateValue, - this.options - ) - ); - } - - return this.syncCustomNodesWithNodesGroup(customNodes); - } -} diff --git a/src/node-obfuscators/replacers/StringLiteralReplacer.ts b/src/node-obfuscators/replacers/StringLiteralReplacer.ts index 2649b716..266337b4 100644 --- a/src/node-obfuscators/replacers/StringLiteralReplacer.ts +++ b/src/node-obfuscators/replacers/StringLiteralReplacer.ts @@ -1,18 +1,18 @@ -import { TStringsArrayCallsWrapper } from '../../types/custom-nodes/TStringsArrayCallsWrapper'; -import { TStringsArrayNode } from '../../types/custom-nodes/TStringsArrayNode'; +import { TStringArrayCallsWrapper } from '../../types/custom-nodes/TStringArrayCallsWrapper'; +import { TStringArrayNode } from '../../types/custom-nodes/TStringArrayNode'; -import { StringsArrayEncoding } from '../../enums/StringsArrayEncoding'; +import { StringArrayEncoding } from '../../enums/StringArrayEncoding'; import { AbstractReplacer } from './AbstractReplacer'; import { NumberLiteralReplacer } from './NumberLiteralReplacer'; -import { StringsArray } from '../../StringsArray'; +import { StringArray } from '../../StringArray'; import { Utils } from '../../Utils'; export class StringLiteralReplacer extends AbstractReplacer { /** * @type {number} */ - private static minimumLengthForStringsArray: number = 3; + private static minimumLengthForStringArray: number = 3; /** * @type {string[]} @@ -25,13 +25,13 @@ export class StringLiteralReplacer extends AbstractReplacer { * @returns {string} */ public replace (nodeValue: string): string { - const replaceWithStringsArrayFlag: boolean = ( - nodeValue.length >= StringLiteralReplacer.minimumLengthForStringsArray - && Math.random() <= this.options.stringsArrayThreshold + const replaceWithStringArrayFlag: boolean = ( + nodeValue.length >= StringLiteralReplacer.minimumLengthForStringArray + && Math.random() <= this.options.stringArrayThreshold ); - if (this.options.stringsArray && replaceWithStringsArrayFlag) { - return this.replaceStringLiteralWithStringsArrayCall(nodeValue); + if (this.options.stringArray && replaceWithStringArrayFlag) { + return this.replaceStringLiteralWithStringArrayCall(nodeValue); } return `'${Utils.stringToUnicodeEscapeSequence(nodeValue)}'`; @@ -41,22 +41,22 @@ export class StringLiteralReplacer extends AbstractReplacer { * @param value * @returns {string} */ - private replaceStringLiteralWithStringsArrayCall (value: string): string { - const stringsArrayNode: TStringsArrayNode = this.nodes.get('stringsArrayNode'); + private replaceStringLiteralWithStringArrayCall (value: string): string { + const stringArrayNode: TStringArrayNode = this.nodes.get('stringArrayNode'); - if (!stringsArrayNode) { - throw new ReferenceError('`stringsArrayNode` node is not found in Map with custom node.'); + if (!stringArrayNode) { + throw new ReferenceError('`stringArrayNode` node is not found in Map with custom node.'); } let rc4Key: string = ''; - switch (this.options.stringsArrayEncoding) { - case StringsArrayEncoding.base64: + switch (this.options.stringArrayEncoding) { + case StringArrayEncoding.base64: value = Utils.btoa(value); break; - case StringsArrayEncoding.rc4: + case StringArrayEncoding.rc4: rc4Key = Utils.getRandomGenerator().pickone(StringLiteralReplacer.rc4Keys); value = Utils.btoa(Utils.rc4(value, rc4Key)); @@ -67,31 +67,31 @@ export class StringLiteralReplacer extends AbstractReplacer { value = Utils.stringToUnicodeEscapeSequence(value); } - let stringsArray: StringsArray = stringsArrayNode.getNodeData(), - indexOfExistingValue: number = stringsArray.getIndexOf(value), + let stringArray: StringArray = stringArrayNode.getNodeData(), + indexOfExistingValue: number = stringArray.getIndexOf(value), indexOfValue: number, hexadecimalIndex: string; if (indexOfExistingValue >= 0) { indexOfValue = indexOfExistingValue; } else { - indexOfValue = stringsArray.getLength(); - stringsArrayNode.updateNodeData(value); + indexOfValue = stringArray.getLength(); + stringArrayNode.updateNodeData(value); } hexadecimalIndex = new NumberLiteralReplacer(this.nodes, this.options) .replace(indexOfValue); - const stringsArrayCallsWrapper: TStringsArrayCallsWrapper = this.nodes.get('stringsArrayCallsWrapper'); + const stringArrayCallsWrapper: TStringArrayCallsWrapper = this.nodes.get('stringArrayCallsWrapper'); - if (!stringsArrayCallsWrapper) { - throw new ReferenceError('`stringsArrayCallsWrapper` node is not found in Map with custom node.'); + if (!stringArrayCallsWrapper) { + throw new ReferenceError('`stringArrayCallsWrapper` node is not found in Map with custom node.'); } - if (this.options.stringsArrayEncoding === StringsArrayEncoding.rc4) { - return `${stringsArrayCallsWrapper.getNodeIdentifier()}('${hexadecimalIndex}', '${Utils.stringToUnicodeEscapeSequence(rc4Key)}')`; + if (this.options.stringArrayEncoding === StringArrayEncoding.rc4) { + return `${stringArrayCallsWrapper.getNodeIdentifier()}('${hexadecimalIndex}', '${Utils.stringToUnicodeEscapeSequence(rc4Key)}')`; } - return `${stringsArrayCallsWrapper.getNodeIdentifier()}('${hexadecimalIndex}')`; + return `${stringArrayCallsWrapper.getNodeIdentifier()}('${hexadecimalIndex}')`; } } diff --git a/src/options/Options.ts b/src/options/Options.ts index 1b280b26..49eec25d 100644 --- a/src/options/Options.ts +++ b/src/options/Options.ts @@ -18,7 +18,7 @@ import { IObfuscatorOptions } from '../interfaces/IObfuscatorOptions'; import { IOptions } from '../interfaces/IOptions'; import { TSourceMapMode } from '../types/TSourceMapMode'; -import { TStringsArrayEncoding } from '../types/TStringsArrayEncoding'; +import { TStringArrayEncoding } from '../types/TStringArrayEncoding'; import { DEFAULT_PRESET } from '../preset-options/DefaultPreset'; @@ -83,7 +83,7 @@ export class Options implements IOptions { * @type {boolean} */ @IsBoolean() - public readonly rotateStringsArray: boolean; + public readonly rotateStringArray: boolean; /** * @type {boolean} @@ -124,13 +124,13 @@ export class Options implements IOptions { * @type {boolean} */ @IsBoolean() - public readonly stringsArray: boolean; + public readonly stringArray: boolean; /** - * @type {TStringsArrayEncoding} + * @type {TStringArrayEncoding} */ @IsIn([true, false, 'base64', 'rc4']) - public readonly stringsArrayEncoding: TStringsArrayEncoding; + public readonly stringArrayEncoding: TStringArrayEncoding; /** * @type {number} @@ -138,7 +138,7 @@ export class Options implements IOptions { @IsNumber() @Min(0) @Max(1) - public readonly stringsArrayThreshold: number; + public readonly stringArrayThreshold: number; /** * @type {boolean} diff --git a/src/options/OptionsNormalizer.ts b/src/options/OptionsNormalizer.ts index ae0f1ffe..0bd09bd0 100644 --- a/src/options/OptionsNormalizer.ts +++ b/src/options/OptionsNormalizer.ts @@ -10,10 +10,10 @@ export class OptionsNormalizer { * @type {IObfuscatorOptions} */ private static DISABLED_UNICODE_ARRAY_OPTIONS: IObfuscatorOptions = { - rotateStringsArray: false, - stringsArray: false, - stringsArrayEncoding: false, - stringsArrayThreshold: 0 + rotateStringArray: false, + stringArray: false, + stringArrayEncoding: false, + stringArrayThreshold: 0 }; /** @@ -28,7 +28,7 @@ export class OptionsNormalizer { * @type {IObfuscatorOptions} */ private static UNICODE_ARRAY_ENCODING_OPTIONS: IObfuscatorOptions = { - stringsArrayEncoding: 'base64' + stringArrayEncoding: 'base64' }; /** @@ -39,9 +39,9 @@ export class OptionsNormalizer { OptionsNormalizer.selfDefendingRule, OptionsNormalizer.sourceMapBaseUrl, OptionsNormalizer.sourceMapFileName, - OptionsNormalizer.stringsArrayRule, - OptionsNormalizer.stringsArrayEncodingRule, - OptionsNormalizer.stringsArrayThresholdRule, + OptionsNormalizer.stringArrayRule, + OptionsNormalizer.stringArrayEncodingRule, + OptionsNormalizer.stringArrayThresholdRule, ]; /** @@ -138,8 +138,8 @@ export class OptionsNormalizer { * @param options * @returns {IOptions} */ - private static stringsArrayRule (options: IOptions): IOptions { - if (!options.stringsArray) { + private static stringArrayRule (options: IOptions): IOptions { + if (!options.stringArray) { Object.assign(options, OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS); } @@ -150,8 +150,8 @@ export class OptionsNormalizer { * @param options * @returns {IOptions} */ - private static stringsArrayEncodingRule (options: IOptions): IOptions { - if (options.stringsArrayEncoding === true) { + private static stringArrayEncodingRule (options: IOptions): IOptions { + if (options.stringArrayEncoding === true) { Object.assign(options, OptionsNormalizer.UNICODE_ARRAY_ENCODING_OPTIONS); } @@ -162,8 +162,8 @@ export class OptionsNormalizer { * @param options * @returns {IOptions} */ - private static stringsArrayThresholdRule (options: IOptions): IOptions { - if (options.stringsArrayThreshold === 0) { + private static stringArrayThresholdRule (options: IOptions): IOptions { + if (options.stringArrayThreshold === 0) { Object.assign(options, OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS); } diff --git a/src/preset-options/DefaultPreset.ts b/src/preset-options/DefaultPreset.ts index 165a6cf6..1d6a5fe1 100644 --- a/src/preset-options/DefaultPreset.ts +++ b/src/preset-options/DefaultPreset.ts @@ -9,14 +9,14 @@ export const DEFAULT_PRESET: IObfuscatorOptions = Object.freeze({ disableConsoleOutput: true, domainLock: [], reservedNames: [], - rotateStringsArray: true, + rotateStringArray: true, selfDefending: true, sourceMap: false, sourceMapBaseUrl: '', sourceMapFileName: '', sourceMapMode: SourceMapMode.Separate, - stringsArray: true, - stringsArrayEncoding: false, - stringsArrayThreshold: 0.8, + stringArray: true, + stringArrayEncoding: false, + stringArrayThreshold: 0.8, unicodeEscapeSequence: true }); diff --git a/src/preset-options/NoCustomNodesPreset.ts b/src/preset-options/NoCustomNodesPreset.ts index 5ab927b9..f8f000a3 100644 --- a/src/preset-options/NoCustomNodesPreset.ts +++ b/src/preset-options/NoCustomNodesPreset.ts @@ -9,14 +9,14 @@ export const NO_CUSTOM_NODES_PRESET: IObfuscatorOptions = Object.freeze({ disableConsoleOutput: false, domainLock: [], reservedNames: [], - rotateStringsArray: false, + rotateStringArray: false, selfDefending: false, sourceMap: false, sourceMapBaseUrl: '', sourceMapFileName: '', sourceMapMode: SourceMapMode.Separate, - stringsArray: false, - stringsArrayEncoding: false, - stringsArrayThreshold: 0, + stringArray: false, + stringArrayEncoding: false, + stringArrayThreshold: 0, unicodeEscapeSequence: true }); diff --git a/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/SelfDefendingTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/SelfDefendingTemplate.ts similarity index 95% rename from src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/SelfDefendingTemplate.ts rename to src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/SelfDefendingTemplate.ts index b1dc2977..1835890c 100644 --- a/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/SelfDefendingTemplate.ts +++ b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/SelfDefendingTemplate.ts @@ -36,6 +36,6 @@ export function SelfDefendingTemplate (): string { return rc4Bytes(this.states[0]); }; - new StatesClass({stringsArrayCallsWrapperName}).checkState(); + new StatesClass({stringArrayCallsWrapperName}).checkState(); `; } diff --git a/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayBase64DecodeNodeTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayBase64DecodeNodeTemplate.ts new file mode 100644 index 00000000..cb186ce5 --- /dev/null +++ b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayBase64DecodeNodeTemplate.ts @@ -0,0 +1,38 @@ +/** + * @returns {string} + */ +export function StringArrayBase64DecodeNodeTemplate (): string { + return ` + if (!{stringArrayCallsWrapperName}.atobPolyfillAppended) { + {atobPolyfill} + + {stringArrayCallsWrapperName}.atobPolyfillAppended = true; + } + + if (!{stringArrayCallsWrapperName}.base64DecodeUnicode) { + {stringArrayCallsWrapperName}.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 (!{stringArrayCallsWrapperName}.data) { + {stringArrayCallsWrapperName}.data = {}; + } + + if (!{stringArrayCallsWrapperName}.data[index]) { + {selfDefendingCode} + + value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value); + {stringArrayCallsWrapperName}.data[index] = value; + } else { + value = {stringArrayCallsWrapperName}.data[index]; + } + `; +} diff --git a/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayCallsWrapperTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayCallsWrapperTemplate.ts similarity index 51% rename from src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayCallsWrapperTemplate.ts rename to src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayCallsWrapperTemplate.ts index ab17bc77..5efc8c14 100644 --- a/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayCallsWrapperTemplate.ts +++ b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayCallsWrapperTemplate.ts @@ -1,11 +1,11 @@ /** * @returns {string} */ -export function StringsArrayCallsWrapperTemplate (): string { +export function StringArrayCallsWrapperTemplate (): string { return ` - var {stringsArrayCallsWrapperName} = function (index, key) { + var {stringArrayCallsWrapperName} = function (index, key) { var index = parseInt(index, 0x10); - var value = {stringsArrayName}[index]; + var value = {stringArrayName}[index]; {decodeNodeTemplate} diff --git a/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayRC4DecodeNodeTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayRC4DecodeNodeTemplate.ts new file mode 100644 index 00000000..12bd11e2 --- /dev/null +++ b/src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayRC4DecodeNodeTemplate.ts @@ -0,0 +1,35 @@ +/** + * @returns {string} + */ +export function StringArrayRc4DecodeNodeTemplate (): string { + return ` + if (!{stringArrayCallsWrapperName}.atobPolyfillAppended) { + {atobPolyfill} + + {stringArrayCallsWrapperName}.atobPolyfillAppended = true; + } + + if (!{stringArrayCallsWrapperName}.rc4) { + {rc4Polyfill} + + {stringArrayCallsWrapperName}.rc4 = rc4; + } + + if (!{stringArrayCallsWrapperName}.data) { + {stringArrayCallsWrapperName}.data = {}; + } + + if ({stringArrayCallsWrapperName}.data[index] === undefined) { + if (!{stringArrayCallsWrapperName}.once) { + {selfDefendingCode} + + {stringArrayCallsWrapperName}.once = true; + } + + value = {stringArrayCallsWrapperName}.rc4(value, key); + {stringArrayCallsWrapperName}.data[index] = value; + } else { + value = {stringArrayCallsWrapperName}.data[index]; + } + `; +} diff --git a/src/templates/custom-nodes/string-array-nodes/string-array-node/StringArrayTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-node/StringArrayTemplate.ts new file mode 100644 index 00000000..2209c216 --- /dev/null +++ b/src/templates/custom-nodes/string-array-nodes/string-array-node/StringArrayTemplate.ts @@ -0,0 +1,8 @@ +/** + * @returns {string} + */ +export function StringArrayTemplate (): string { + return ` + var {stringArrayName} = [{stringArray}]; + `; +} diff --git a/src/templates/custom-nodes/strings-array-nodes/strings-array-rotate-function-node/SelfDefendingTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate.ts similarity index 100% rename from src/templates/custom-nodes/strings-array-nodes/strings-array-rotate-function-node/SelfDefendingTemplate.ts rename to src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/SelfDefendingTemplate.ts diff --git a/src/templates/custom-nodes/strings-array-nodes/strings-array-rotate-function-node/StringsArrayRotateFunctionTemplate.ts b/src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/StringArrayRotateFunctionTemplate.ts similarity index 70% rename from src/templates/custom-nodes/strings-array-nodes/strings-array-rotate-function-node/StringsArrayRotateFunctionTemplate.ts rename to src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/StringArrayRotateFunctionTemplate.ts index dea3fe0e..39eba0dc 100644 --- a/src/templates/custom-nodes/strings-array-nodes/strings-array-rotate-function-node/StringsArrayRotateFunctionTemplate.ts +++ b/src/templates/custom-nodes/string-array-nodes/string-array-rotate-function-node/StringArrayRotateFunctionTemplate.ts @@ -1,7 +1,7 @@ /** * @returns {string} */ -export function StringsArrayRotateFunctionTemplate (): string { +export function StringArrayRotateFunctionTemplate (): string { return ` (function (array, {timesName}) { var {whileFunctionName} = function (times) { @@ -11,6 +11,6 @@ export function StringsArrayRotateFunctionTemplate (): string { }; {code} - })({stringsArrayName}, 0x{stringsArrayRotateValue}); + })({stringArrayName}, 0x{stringArrayRotateValue}); `; } diff --git a/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayBase64DecodeNodeTemplate.ts b/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayBase64DecodeNodeTemplate.ts deleted file mode 100644 index 01c051fe..00000000 --- a/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayBase64DecodeNodeTemplate.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @returns {string} - */ -export function StringsArrayBase64DecodeNodeTemplate (): string { - return ` - if (!{stringsArrayCallsWrapperName}.atobPolyfillAppended) { - {atobPolyfill} - - {stringsArrayCallsWrapperName}.atobPolyfillAppended = true; - } - - if (!{stringsArrayCallsWrapperName}.base64DecodeUnicode) { - {stringsArrayCallsWrapperName}.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 (!{stringsArrayCallsWrapperName}.data) { - {stringsArrayCallsWrapperName}.data = {}; - } - - if (!{stringsArrayCallsWrapperName}.data[index]) { - {selfDefendingCode} - - value = {stringsArrayCallsWrapperName}.base64DecodeUnicode(value); - {stringsArrayCallsWrapperName}.data[index] = value; - } else { - value = {stringsArrayCallsWrapperName}.data[index]; - } - `; -} diff --git a/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayRC4DecodeNodeTemplate.ts b/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayRC4DecodeNodeTemplate.ts deleted file mode 100644 index b93e3ed0..00000000 --- a/src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayRC4DecodeNodeTemplate.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @returns {string} - */ -export function StringsArrayRc4DecodeNodeTemplate (): string { - return ` - if (!{stringsArrayCallsWrapperName}.atobPolyfillAppended) { - {atobPolyfill} - - {stringsArrayCallsWrapperName}.atobPolyfillAppended = true; - } - - if (!{stringsArrayCallsWrapperName}.rc4) { - {rc4Polyfill} - - {stringsArrayCallsWrapperName}.rc4 = rc4; - } - - if (!{stringsArrayCallsWrapperName}.data) { - {stringsArrayCallsWrapperName}.data = {}; - } - - if ({stringsArrayCallsWrapperName}.data[index] === undefined) { - if (!{stringsArrayCallsWrapperName}.once) { - {selfDefendingCode} - - {stringsArrayCallsWrapperName}.once = true; - } - - value = {stringsArrayCallsWrapperName}.rc4(value, key); - {stringsArrayCallsWrapperName}.data[index] = value; - } else { - value = {stringsArrayCallsWrapperName}.data[index]; - } - `; -} diff --git a/src/templates/custom-nodes/strings-array-nodes/strings-array-node/StringsArrayTemplate.ts b/src/templates/custom-nodes/strings-array-nodes/strings-array-node/StringsArrayTemplate.ts deleted file mode 100644 index b430764f..00000000 --- a/src/templates/custom-nodes/strings-array-nodes/strings-array-node/StringsArrayTemplate.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @returns {string} - */ -export function StringsArrayTemplate (): string { - return ` - var {stringsArrayName} = [{stringsArray}]; - `; -} diff --git a/src/types/TStringArrayEncoding.ts b/src/types/TStringArrayEncoding.ts new file mode 100644 index 00000000..5f0d2d45 --- /dev/null +++ b/src/types/TStringArrayEncoding.ts @@ -0,0 +1 @@ +export type TStringArrayEncoding = boolean|'base64'|'rc4'; diff --git a/src/types/TStringsArrayEncoding.ts b/src/types/TStringsArrayEncoding.ts deleted file mode 100644 index 58f267fb..00000000 --- a/src/types/TStringsArrayEncoding.ts +++ /dev/null @@ -1 +0,0 @@ -export type TStringsArrayEncoding = boolean|'base64'|'rc4'; diff --git a/src/types/custom-nodes/TStringsArrayCallsWrapper.d.ts b/src/types/custom-nodes/TStringArrayCallsWrapper.d.ts similarity index 60% rename from src/types/custom-nodes/TStringsArrayCallsWrapper.d.ts rename to src/types/custom-nodes/TStringArrayCallsWrapper.d.ts index 32f1b74c..beb1903b 100644 --- a/src/types/custom-nodes/TStringsArrayCallsWrapper.d.ts +++ b/src/types/custom-nodes/TStringArrayCallsWrapper.d.ts @@ -1,3 +1,3 @@ import { ICustomNodeWithIdentifier } from '../../interfaces/custom-nodes/ICustomNodeWithIdentifier'; -export type TStringsArrayCallsWrapper = ICustomNodeWithIdentifier; +export type TStringArrayCallsWrapper = ICustomNodeWithIdentifier; diff --git a/src/types/custom-nodes/TStringsArrayNode.d.ts b/src/types/custom-nodes/TStringArrayNode.d.ts similarity index 70% rename from src/types/custom-nodes/TStringsArrayNode.d.ts rename to src/types/custom-nodes/TStringArrayNode.d.ts index 20c9069f..5d5e42d4 100644 --- a/src/types/custom-nodes/TStringsArrayNode.d.ts +++ b/src/types/custom-nodes/TStringArrayNode.d.ts @@ -1,4 +1,4 @@ import { ICustomNodeWithData } from '../../interfaces/custom-nodes/ICustomNodeWithData'; import { ICustomNodeWithIdentifier } from '../../interfaces/custom-nodes/ICustomNodeWithIdentifier'; -export type TStringsArrayNode = ICustomNodeWithData & ICustomNodeWithIdentifier; +export type TStringArrayNode = ICustomNodeWithData & ICustomNodeWithIdentifier; diff --git a/test/dev/dev.ts b/test/dev/dev.ts index 03047f41..f9502967 100644 --- a/test/dev/dev.ts +++ b/test/dev/dev.ts @@ -71,7 +71,7 @@ if (!(global)._babelPolyfill) { { disableConsoleOutput: false, selfDefending: true, - stringsArrayEncoding: 'rc4' + stringArrayEncoding: 'rc4' } ).getObfuscatedCode(); diff --git a/test/functional-tests/JavaScriptObfuscator.spec.ts b/test/functional-tests/JavaScriptObfuscator.spec.ts index e59ac707..1ee8cb00 100644 --- a/test/functional-tests/JavaScriptObfuscator.spec.ts +++ b/test/functional-tests/JavaScriptObfuscator.spec.ts @@ -107,15 +107,15 @@ describe('JavaScriptObfuscator', () => { obfuscatedCode1: string = JavaScriptObfuscator.obfuscate( `var test = 'abc';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ).getObfuscatedCode(), obfuscatedCode2: string = JavaScriptObfuscator.obfuscate( `var test = 'абц';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ).getObfuscatedCode(); diff --git a/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts b/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts index 4f511935..37412c5e 100644 --- a/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts +++ b/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts @@ -25,7 +25,7 @@ describe('ConsoleOutputDisableExpressionNode', () => { `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { disableConsoleOutput: false, - stringsArrayThreshold: 1 + stringArrayThreshold: 1 }) ); diff --git a/test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayCallsWrapper.spec.ts b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts similarity index 71% rename from test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayCallsWrapper.spec.ts rename to test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts index 485bfee3..11b88ecb 100644 --- a/test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayCallsWrapper.spec.ts +++ b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec.ts @@ -6,14 +6,14 @@ import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator'; const assert: Chai.AssertStatic = require('chai').assert; -describe('StringsArrayCallsWrapper', () => { - it('should correctly append `StringsArrayCallsWrapper` custom node into the obfuscated code', () => { +describe('StringArrayCallsWrapper', () => { + it('should correctly append `StringArrayCallsWrapper` custom node into the obfuscated code', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1, - wrapStringsArrayCalls: true + stringArray: true, + stringArrayThreshold: 1, + wrapStringArrayCalls: true }) ); diff --git a/test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayNode.spec.ts b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts similarity index 69% rename from test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayNode.spec.ts rename to test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts index 908a7063..cdd8d0d8 100644 --- a/test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayNode.spec.ts +++ b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts @@ -6,24 +6,24 @@ import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator'; const assert: Chai.AssertStatic = require('chai').assert; -describe('StringsArrayNode', () => { - it('should correctly append `StringsArrayNode` custom node into the obfuscated code if `stringsArray` option is set', () => { +describe('StringArrayNode', () => { + it('should correctly append `StringArrayNode` custom node into the obfuscated code if `stringArray` option is set', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ); assert.match(obfuscationResult.getObfuscatedCode(), /^var _0x([a-z0-9]){4} *= *\[/); }); - it('should\'t append `StringsArrayNode` custom node into the obfuscated code if `stringsArray` option is not set', () => { + it('should\'t append `StringArrayNode` custom node into the obfuscated code if `stringArray` option is not set', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: false + stringArray: false }) ); diff --git a/test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayRotateFunctionNode.spec.ts b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts similarity index 61% rename from test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayRotateFunctionNode.spec.ts rename to test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts index 3c98ab9f..6ba68b7b 100644 --- a/test/functional-tests/custom-nodes/strings-array-nodes/StringsArrayRotateFunctionNode.spec.ts +++ b/test/functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec.ts @@ -6,27 +6,27 @@ import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator'; const assert: Chai.AssertStatic = require('chai').assert; -describe('StringsArrayRotateFunctionNode', () => { - it('should correctly append `StringsArrayRotateFunctionNode` custom node into the obfuscated code if `rotateStringsArray` option is set', () => { +describe('StringArrayRotateFunctionNode', () => { + it('should correctly append `StringArrayRotateFunctionNode` custom node into the obfuscated code if `rotateStringArray` option is set', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - rotateStringsArray: true, - stringsArray: true, - stringsArrayThreshold: 1 + rotateStringArray: true, + stringArray: true, + stringArrayThreshold: 1 }) ); assert.match(obfuscationResult.getObfuscatedCode(), /while *\(-- *_0x([a-z0-9]){4,6}\) *\{/); }); - it('should\'t append `StringsArrayRotateFunctionNode` custom node into the obfuscated code if `rotateStringsArray` option is not set', () => { + it('should\'t append `StringArrayRotateFunctionNode` custom node into the obfuscated code if `rotateStringArray` option is not set', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - rotateStringsArray: false, - stringsArray: true, - stringsArrayThreshold: 1 + rotateStringArray: false, + stringArray: true, + stringArrayThreshold: 1 }) ); diff --git a/test/functional-tests/node-obfuscators/LiteralObfuscator.spec.ts b/test/functional-tests/node-obfuscators/LiteralObfuscator.spec.ts index cdd0bf85..837e0d54 100644 --- a/test/functional-tests/node-obfuscators/LiteralObfuscator.spec.ts +++ b/test/functional-tests/node-obfuscators/LiteralObfuscator.spec.ts @@ -21,8 +21,8 @@ describe('LiteralObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ); @@ -37,8 +37,8 @@ describe('LiteralObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1, + stringArray: true, + stringArrayThreshold: 1, unicodeEscapeSequence: false }) ); @@ -54,8 +54,8 @@ describe('LiteralObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'te';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ); @@ -66,9 +66,9 @@ describe('LiteralObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayEncoding: 'base64', - stringsArrayThreshold: 1 + stringArray: true, + stringArrayEncoding: 'base64', + stringArrayThreshold: 1 }) ); @@ -83,9 +83,9 @@ describe('LiteralObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 'test';`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayEncoding: 'rc4', - stringsArrayThreshold: 1 + stringArray: true, + stringArrayEncoding: 'rc4', + stringArrayThreshold: 1 }) ); @@ -100,8 +100,8 @@ describe('LiteralObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = true;`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ); @@ -112,8 +112,8 @@ describe('LiteralObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = 0;`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ); diff --git a/test/functional-tests/node-obfuscators/MemberExpressionObfuscator.spec.ts b/test/functional-tests/node-obfuscators/MemberExpressionObfuscator.spec.ts index 5f9d6076..e24df2e2 100644 --- a/test/functional-tests/node-obfuscators/MemberExpressionObfuscator.spec.ts +++ b/test/functional-tests/node-obfuscators/MemberExpressionObfuscator.spec.ts @@ -21,8 +21,8 @@ describe('MemberExpressionObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = console.log;`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ); @@ -36,8 +36,8 @@ describe('MemberExpressionObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( `var test = console['log'];`, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ); diff --git a/test/functional-tests/node-obfuscators/MethodDefinitionObfuscator.spec.ts b/test/functional-tests/node-obfuscators/MethodDefinitionObfuscator.spec.ts index 3dc414a0..f5d09cdd 100644 --- a/test/functional-tests/node-obfuscators/MethodDefinitionObfuscator.spec.ts +++ b/test/functional-tests/node-obfuscators/MethodDefinitionObfuscator.spec.ts @@ -27,8 +27,8 @@ describe('MethodDefinitionObfuscator', () => { let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( code, Object.assign({}, NO_CUSTOM_NODES_PRESET, { - stringsArray: true, - stringsArrayThreshold: 1 + stringArray: true, + stringArrayThreshold: 1 }) ); diff --git a/test/functional-tests/templates/custom-nodes/string-array-nodes/StringArrayCallsWrapperNodeTemplate.spec.ts b/test/functional-tests/templates/custom-nodes/string-array-nodes/StringArrayCallsWrapperNodeTemplate.spec.ts new file mode 100644 index 00000000..8135300e --- /dev/null +++ b/test/functional-tests/templates/custom-nodes/string-array-nodes/StringArrayCallsWrapperNodeTemplate.spec.ts @@ -0,0 +1,93 @@ +import 'format-unicorn'; + +import { AtobTemplate } from '../../../../../src/templates/custom-nodes/AtobTemplate'; +import { Rc4Template } from '../../../../../src/templates/custom-nodes/Rc4Template'; +import { StringArrayBase64DecodeNodeTemplate } from '../../../../../src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayBase64DecodeNodeTemplate'; +import { StringArrayCallsWrapperTemplate } from '../../../../../src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayCallsWrapperTemplate'; +import { StringArrayRc4DecodeNodeTemplate } from '../../../../../src/templates/custom-nodes/string-array-nodes/string-array-calls-wrapper/StringArrayRC4DecodeNodeTemplate'; + +import { Utils } from '../../../../../src/Utils'; + +const assert: Chai.AssertStatic = require('chai').assert; + +/** + * @param templateData + * @param stringArrayName + * @param stringArrayCallsWrapperName + * @param index + * @returns {Function} + */ +function getFunctionFromTemplateBase64Encoding ( + templateData: any, + stringArrayName: string, + stringArrayCallsWrapperName: string, + index: string +) { + let stringArrayCallsWrapperTemplate: string = StringArrayCallsWrapperTemplate().formatUnicorn(templateData); + + return Function(` + var ${stringArrayName} = ['${Utils.btoa('test1')}']; + + ${stringArrayCallsWrapperTemplate} + + return ${stringArrayCallsWrapperName}(${index}); + `)(); +} + +/** + * @param templateData + * @param stringArrayName + * @param stringArrayCallsWrapperName + * @param index + * @param key + * @returns {Function} + */ +function getFunctionFromTemplateRc4Encoding ( + templateData: any, + stringArrayName: string, + stringArrayCallsWrapperName: string, + index: string, + key: string +) { + let stringArrayCallsWrapperTemplate: string = StringArrayCallsWrapperTemplate().formatUnicorn(templateData); + + return Function(` + var ${stringArrayName} = ['${Utils.btoa(Utils.rc4('test1', key))}']; + + ${stringArrayCallsWrapperTemplate} + + return ${stringArrayCallsWrapperName}('${index}', '${key}'); + `)(); +} + +describe('StringArrayCallsWrapperNodeTemplate (): string', () => { + let stringArrayName: string = 'stringArrayName', + stringArrayCallsWrapperName: string = 'stringArrayCallsWrapperName', + atobDecodeNodeTemplate: string = StringArrayBase64DecodeNodeTemplate().formatUnicorn({ + atobPolyfill: AtobTemplate(), + selfDefendingCode: '', + stringArrayCallsWrapperName + }), + rc4DecodeNodeTemplate: string = StringArrayRc4DecodeNodeTemplate().formatUnicorn({ + atobPolyfill: AtobTemplate(), + rc4Polyfill: Rc4Template(), + selfDefendingCode: '', + stringArrayCallsWrapperName + }); + + it('should correctly returns decoded value with base64 encoding', () => { + assert.deepEqual(getFunctionFromTemplateBase64Encoding({ + decodeNodeTemplate: atobDecodeNodeTemplate, + stringArrayCallsWrapperName, + stringArrayName + }, stringArrayName, stringArrayCallsWrapperName, '0x0'), 'test1'); + }); + + it('should correctly returns decoded value with rc4 encoding', () => { + assert.deepEqual(getFunctionFromTemplateRc4Encoding({ + decodeNodeTemplate: rc4DecodeNodeTemplate, + stringArrayCallsWrapperName, + stringArrayName + }, stringArrayName, stringArrayCallsWrapperName, '0x0', 'key'), 'test1'); + }); +}); diff --git a/test/functional-tests/templates/custom-nodes/strings-array-nodes/StringsArrayCallsWrapperNodeTemplate.spec.ts b/test/functional-tests/templates/custom-nodes/strings-array-nodes/StringsArrayCallsWrapperNodeTemplate.spec.ts deleted file mode 100644 index 316b7ffa..00000000 --- a/test/functional-tests/templates/custom-nodes/strings-array-nodes/StringsArrayCallsWrapperNodeTemplate.spec.ts +++ /dev/null @@ -1,93 +0,0 @@ -import 'format-unicorn'; - -import { AtobTemplate } from '../../../../../src/templates/custom-nodes/AtobTemplate'; -import { Rc4Template } from '../../../../../src/templates/custom-nodes/Rc4Template'; -import { StringsArrayBase64DecodeNodeTemplate } from '../../../../../src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayBase64DecodeNodeTemplate'; -import { StringsArrayCallsWrapperTemplate } from '../../../../../src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayCallsWrapperTemplate'; -import { StringsArrayRc4DecodeNodeTemplate } from '../../../../../src/templates/custom-nodes/strings-array-nodes/strings-array-calls-wrapper/StringsArrayRC4DecodeNodeTemplate'; - -import { Utils } from '../../../../../src/Utils'; - -const assert: Chai.AssertStatic = require('chai').assert; - -/** - * @param templateData - * @param stringsArrayName - * @param stringsArrayCallsWrapperName - * @param index - * @returns {Function} - */ -function getFunctionFromTemplateBase64Encoding ( - templateData: any, - stringsArrayName: string, - stringsArrayCallsWrapperName: string, - index: string -) { - let stringsArrayCallsWrapperTemplate: string = StringsArrayCallsWrapperTemplate().formatUnicorn(templateData); - - return Function(` - var ${stringsArrayName} = ['${Utils.btoa('test1')}']; - - ${stringsArrayCallsWrapperTemplate} - - return ${stringsArrayCallsWrapperName}(${index}); - `)(); -} - -/** - * @param templateData - * @param stringsArrayName - * @param stringsArrayCallsWrapperName - * @param index - * @param key - * @returns {Function} - */ -function getFunctionFromTemplateRc4Encoding ( - templateData: any, - stringsArrayName: string, - stringsArrayCallsWrapperName: string, - index: string, - key: string -) { - let stringsArrayCallsWrapperTemplate: string = StringsArrayCallsWrapperTemplate().formatUnicorn(templateData); - - return Function(` - var ${stringsArrayName} = ['${Utils.btoa(Utils.rc4('test1', key))}']; - - ${stringsArrayCallsWrapperTemplate} - - return ${stringsArrayCallsWrapperName}('${index}', '${key}'); - `)(); -} - -describe('StringsArrayCallsWrapperNodeTemplate (): string', () => { - let stringsArrayName: string = 'stringsArrayName', - stringsArrayCallsWrapperName: string = 'stringsArrayCallsWrapperName', - atobDecodeNodeTemplate: string = StringsArrayBase64DecodeNodeTemplate().formatUnicorn({ - atobPolyfill: AtobTemplate(), - selfDefendingCode: '', - stringsArrayCallsWrapperName - }), - rc4DecodeNodeTemplate: string = StringsArrayRc4DecodeNodeTemplate().formatUnicorn({ - atobPolyfill: AtobTemplate(), - rc4Polyfill: Rc4Template(), - selfDefendingCode: '', - stringsArrayCallsWrapperName - }); - - it('should correctly returns decoded value with base64 encoding', () => { - assert.deepEqual(getFunctionFromTemplateBase64Encoding({ - decodeNodeTemplate: atobDecodeNodeTemplate, - stringsArrayCallsWrapperName, - stringsArrayName - }, stringsArrayName, stringsArrayCallsWrapperName, '0x0'), 'test1'); - }); - - it('should correctly returns decoded value with rc4 encoding', () => { - assert.deepEqual(getFunctionFromTemplateRc4Encoding({ - decodeNodeTemplate: rc4DecodeNodeTemplate, - stringsArrayCallsWrapperName, - stringsArrayName - }, stringsArrayName, stringsArrayCallsWrapperName, '0x0', 'key'), 'test1'); - }); -}); diff --git a/test/index.spec.ts b/test/index.spec.ts index b78b0f8c..0116f0b9 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -27,9 +27,9 @@ import './functional-tests/JavaScriptObfuscatorCLI.spec'; import './functional-tests/JavaScriptObfuscatorInternal.spec'; import './functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec'; import './functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec'; -import './functional-tests/custom-nodes/strings-array-nodes/StringsArrayCallsWrapper.spec'; -import './functional-tests/custom-nodes/strings-array-nodes/StringsArrayRotateFunctionNode.spec'; -import './functional-tests/custom-nodes/strings-array-nodes/StringsArrayNode.spec'; +import './functional-tests/custom-nodes/string-array-nodes/StringArrayCallsWrapper.spec'; +import './functional-tests/custom-nodes/string-array-nodes/StringArrayRotateFunctionNode.spec'; +import './functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec'; import './functional-tests/node-obfuscators/FunctionObfuscator.spec'; import './functional-tests/node-obfuscators/LiteralObfuscator.spec'; import './functional-tests/node-obfuscators/MemberExpressionObfuscator.spec'; @@ -38,7 +38,7 @@ import './functional-tests/node-obfuscators/ObjectExpressionObfuscator.spec'; import './functional-tests/node-obfuscators/VariableDeclarationObfuscator.spec'; import './functional-tests/stack-trace-analyzer/StackTraceAnalyzer.spec'; import './functional-tests/templates/custom-nodes/domain-lock-nodes/DomainLockNodeTemplate.spec'; -import './functional-tests/templates/custom-nodes/strings-array-nodes/StringsArrayCallsWrapperNodeTemplate.spec'; +import './functional-tests/templates/custom-nodes/string-array-nodes/StringArrayCallsWrapperNodeTemplate.spec'; /** * Performance tests diff --git a/test/unit-tests/OptionsNormalizer.spec.ts b/test/unit-tests/OptionsNormalizer.spec.ts index e8de2464..d4d9cc49 100644 --- a/test/unit-tests/OptionsNormalizer.spec.ts +++ b/test/unit-tests/OptionsNormalizer.spec.ts @@ -23,46 +23,46 @@ describe('OptionsNormalizer', () => { beforeEach(() => { optionsPreset1 = Object.assign({}, DEFAULT_PRESET, { compact: false, - rotateStringsArray: true, + rotateStringArray: true, sourceMapBaseUrl: 'http://localhost:9000', - stringsArray: false, - stringsArrayEncoding: 'rc4', - stringsArrayThreshold: 0.5 + stringArray: false, + stringArrayEncoding: 'rc4', + stringArrayThreshold: 0.5 }); optionsPreset2 = Object.assign({}, DEFAULT_PRESET, { - rotateStringsArray: true, + rotateStringArray: true, sourceMapBaseUrl: 'http://localhost:9000', sourceMapFileName: '//outputSourceMapName', - stringsArray: true, - stringsArrayThreshold: 0 + stringArray: true, + stringArrayThreshold: 0 }); optionsPreset3 = Object.assign({}, DEFAULT_PRESET, { domainLock: ['//localhost:9000', 'https://google.ru/abc?cde=fgh'], sourceMapFileName: '/outputSourceMapName.map', - stringsArray: true, - stringsArrayEncoding: true + stringArray: true, + stringArrayEncoding: true }); expectedOptionsPreset1 = Object.assign({}, DEFAULT_PRESET, { compact: true, - rotateStringsArray: false, + rotateStringArray: false, sourceMapBaseUrl: '', - stringsArray: false, - stringsArrayEncoding: false, - stringsArrayThreshold: 0 + stringArray: false, + stringArrayEncoding: false, + stringArrayThreshold: 0 }); expectedOptionsPreset2 = Object.assign({}, DEFAULT_PRESET, { - rotateStringsArray: false, + rotateStringArray: false, sourceMapBaseUrl: 'http://localhost:9000/', sourceMapFileName: 'outputSourceMapName.js.map', - stringsArray: false, - stringsArrayThreshold: 0 + stringArray: false, + stringArrayThreshold: 0 }); expectedOptionsPreset3 = Object.assign({}, DEFAULT_PRESET, { domainLock: ['localhost', 'google.ru'], sourceMapFileName: 'outputSourceMapName.js.map', - stringsArray: true, - stringsArrayEncoding: 'base64' + stringArray: true, + stringArrayEncoding: 'base64' }); options1 = new Options(optionsPreset1);