javascript-obfuscator
Advanced tools
@@ -10,3 +10,3 @@ "use strict"; | ||
export class JavaScriptObfuscator { | ||
class JavaScriptObfuscator { | ||
/** | ||
@@ -59,1 +59,3 @@ * @type any | ||
} | ||
module.exports = JavaScriptObfuscator; |
{ | ||
"name": "javascript-obfuscator", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "JavaScript obfuscator", | ||
@@ -14,3 +14,3 @@ "keywords": [ | ||
], | ||
"main": "index.js", | ||
"main": "dist/index.js", | ||
"dependencies": { | ||
@@ -35,3 +35,3 @@ "esprima": "^2.7.2", | ||
"start": "concurrent \"npm run tsc:w\" \"npm run lite\" ", | ||
"tests": "node tests/dev-test.js" | ||
"tests": "node dist/tests/dev-test.js" | ||
}, | ||
@@ -38,0 +38,0 @@ "author": { |
@@ -7,5 +7,11 @@ import { ICustomNode } from '../interfaces/ICustomNode'; | ||
import { Utils } from '../Utils'; | ||
import {UnicodeArrayTranslator} from "../custom-nodes/unicode-array-nodes/UnicodeArrayTranslator"; | ||
export class UnicodeArrayNodesGroup extends NodesGroup { | ||
/** | ||
* @type {any} | ||
*/ | ||
private options: any; | ||
/** | ||
* @type {string} | ||
@@ -20,5 +26,15 @@ */ | ||
constructor () { | ||
/** | ||
* @type {string} | ||
*/ | ||
private unicodeArrayTranslatorName: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH); | ||
/** | ||
* @param options | ||
*/ | ||
constructor (options: any) { | ||
super(); | ||
this.options = options; | ||
let unicodeArrayNode: UnicodeArrayNode = new UnicodeArrayNode( | ||
@@ -36,2 +52,13 @@ this.unicodeArrayName, | ||
[ | ||
'unicodeArrayTranslator', | ||
new UnicodeArrayTranslator( | ||
this.unicodeArrayTranslatorName, | ||
this.unicodeArrayName, | ||
unicodeArray | ||
) | ||
] | ||
]); | ||
if (this.options['rotateUnicodeArray']) { | ||
this.nodes.set( | ||
'unicodeArrayRotateFunctionNode', | ||
@@ -43,5 +70,5 @@ new UnicodeArrayRotateFunctionNode( | ||
) | ||
] | ||
]); | ||
); | ||
} | ||
} | ||
} |
@@ -38,3 +38,3 @@ import * as escodegen from 'escodegen'; | ||
case 'string': | ||
content = this.replaceLiteralStringByArrayElement(<string>literalNode.value); | ||
content = this.replaceLiteralStringByUnicodeArrayTranslatorCall(<string>literalNode.value); | ||
@@ -41,0 +41,0 @@ break; |
@@ -56,3 +56,3 @@ import * as escodegen from 'escodegen'; | ||
'x-verbatim-property': { | ||
content : this.replaceLiteralStringByArrayElement(nodeValue), | ||
content : this.replaceLiteralStringByUnicodeArrayTranslatorCall(nodeValue), | ||
precedence: escodegen.Precedence.Primary | ||
@@ -86,3 +86,3 @@ }, | ||
node['x-verbatim-property'] = { | ||
content : this.replaceLiteralStringByArrayElement(<string>node.value), | ||
content : this.replaceLiteralStringByUnicodeArrayTranslatorCall(<string>node.value), | ||
precedence: escodegen.Precedence.Primary | ||
@@ -89,0 +89,0 @@ }; |
@@ -45,3 +45,3 @@ import * as estraverse from 'estraverse'; | ||
methodDefinitionNode.computed = true; | ||
node.name = this.replaceLiteralStringByArrayElement(node.name); | ||
node.name = this.replaceLiteralStringByUnicodeArrayTranslatorCall(node.name); | ||
@@ -48,0 +48,0 @@ return; |
@@ -73,3 +73,3 @@ import { ICustomNode } from '../interfaces/ICustomNode'; | ||
*/ | ||
protected replaceLiteralStringByArrayElement (nodeValue: string): string { | ||
protected replaceLiteralStringByUnicodeArrayTranslatorCall (nodeValue: string): string { | ||
let value: string = Utils.stringToUnicode(nodeValue), | ||
@@ -90,4 +90,4 @@ unicodeArray: string[] = this.nodes.get('unicodeArrayNode').getNodeData(), | ||
return `${this.nodes.get('unicodeArrayNode').getNodeIdentifier()}[${hexadecimalIndex}]`; | ||
return `${this.nodes.get('unicodeArrayTranslator').getNodeIdentifier()}('${hexadecimalIndex}')`; | ||
} | ||
} |
@@ -158,11 +158,4 @@ import * as estraverse from 'estraverse'; | ||
*/ | ||
if (this.options['rotateUnicodeArray']) { | ||
this.setNodesGroup(new UnicodeArrayNodesGroup()); | ||
} else { | ||
this.setNode( | ||
'unicodeArrayNode', | ||
new UnicodeArrayNode(Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH)) | ||
); | ||
} | ||
this.setNodesGroup(new UnicodeArrayNodesGroup(this.options)); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { JavaScriptObfuscator } from "../index"; | ||
import * as JavaScriptObfuscator from "../index"; | ||
@@ -52,4 +52,3 @@ let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( | ||
{ | ||
disableConsoleOutput: false, | ||
rotateUnicodeArray: false | ||
disableConsoleOutput: false | ||
} | ||
@@ -56,0 +55,0 @@ ); |
@@ -5,2 +5,3 @@ { | ||
"module": "commonjs", | ||
"outDir": "dist/", | ||
"sourceMap": false, | ||
@@ -7,0 +8,0 @@ "emitDecoratorMetadata": true, |
267969
2.49%95
3.26%6715
2.57%