javascript-obfuscator 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -1
- package/.mocharc.json +1 -1
- package/CHANGELOG.md +20 -1
- package/CLAUDE.md +1478 -0
- package/README.md +7 -3
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.LICENSE.txt +1 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cli.js +1 -1
- package/dist/index.cli.js.LICENSE.txt +1 -1
- package/dist/index.cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +55 -54
- package/typings/src/cli/JavaScriptObfuscatorCLI.d.ts +0 -1
- package/typings/src/constants/EcmaVersion.d.ts +2 -1
- package/typings/src/custom-code-helpers/common/templates/GlobalVariableServiceWorkerTemplate.d.ts +1 -0
- package/typings/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.d.ts +2 -1
- package/typings/src/enums/ObfuscationTarget.d.ts +1 -0
- package/typings/src/enums/node/NodeType.d.ts +1 -0
- package/typings/src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.d.ts +1 -0
- package/typings/src/interfaces/node-transformers/INodeTransformer.d.ts +0 -1
- package/typings/src/interfaces/node-transformers/IVisitor.d.ts +0 -1
- package/typings/src/interfaces/utils/IRandomGenerator.d.ts +0 -1
- package/typings/src/node/NodeFactory.d.ts +2 -1
- package/typings/src/node/NodeGuards.d.ts +2 -0
- package/typings/src/node-transformers/AbstractNodeTransformer.d.ts +0 -1
- package/typings/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.d.ts +0 -1
- package/typings/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.d.ts +0 -1
- package/typings/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.d.ts +0 -1
- package/typings/src/node-transformers/preparing-transformers/obfuscating-guards/ImportMetaObfuscationGuard.d.ts +6 -0
- package/typings/src/node-transformers/simplifying-transformers/ExpressionStatementsMergeTransformer.d.ts +0 -1
- package/typings/src/node-transformers/simplifying-transformers/VariableDeclarationsMergeTransformer.d.ts +0 -1
- package/typings/src/types/node-transformers/TVisitorResult.d.ts +0 -1
- package/typings/src/utils/RandomGenerator.d.ts +0 -1
- package/index.cli.ts +0 -5
- package/index.ts +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "javascript-obfuscator",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "JavaScript obfuscator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"obfuscator",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"js obfuscator"
|
|
13
13
|
],
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": "
|
|
15
|
+
"node": ">=18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"main": "dist/index.js",
|
|
18
18
|
"browser": "dist/index.browser.js",
|
|
@@ -21,79 +21,79 @@
|
|
|
21
21
|
},
|
|
22
22
|
"types": "typings/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@javascript-obfuscator/escodegen": "2.3.
|
|
24
|
+
"@javascript-obfuscator/escodegen": "2.3.1",
|
|
25
25
|
"@javascript-obfuscator/estraverse": "5.4.0",
|
|
26
|
-
"acorn": "8.
|
|
27
|
-
"assert": "2.
|
|
26
|
+
"acorn": "8.15.0",
|
|
27
|
+
"assert": "2.1.0",
|
|
28
28
|
"chalk": "4.1.2",
|
|
29
|
-
"chance": "1.1.
|
|
30
|
-
"class-validator": "0.14.
|
|
31
|
-
"commander": "
|
|
32
|
-
"eslint-scope": "
|
|
33
|
-
"eslint-visitor-keys": "
|
|
29
|
+
"chance": "1.1.13",
|
|
30
|
+
"class-validator": "0.14.3",
|
|
31
|
+
"commander": "12.1.0",
|
|
32
|
+
"eslint-scope": "8.4.0",
|
|
33
|
+
"eslint-visitor-keys": "4.2.1",
|
|
34
34
|
"fast-deep-equal": "3.1.3",
|
|
35
|
-
"inversify": "6.
|
|
35
|
+
"inversify": "6.1.4",
|
|
36
36
|
"js-string-escape": "1.0.1",
|
|
37
37
|
"md5": "2.3.0",
|
|
38
|
-
"mkdirp": "
|
|
39
|
-
"multimatch": "
|
|
38
|
+
"mkdirp": "3.0.1",
|
|
39
|
+
"multimatch": "7.0.0",
|
|
40
40
|
"opencollective-postinstall": "2.0.3",
|
|
41
41
|
"process": "0.11.10",
|
|
42
|
-
"reflect-metadata": "0.
|
|
42
|
+
"reflect-metadata": "0.2.2",
|
|
43
43
|
"source-map-support": "0.5.21",
|
|
44
44
|
"string-template": "1.0.0",
|
|
45
45
|
"stringz": "2.1.0",
|
|
46
|
-
"tslib": "2.
|
|
46
|
+
"tslib": "2.8.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@istanbuljs/nyc-config-typescript": "1.0.2",
|
|
50
|
-
"@types/chai": "4.3.
|
|
51
|
-
"@types/chance": "1.1.
|
|
52
|
-
"@types/escodegen": "0.0.
|
|
53
|
-
"@types/eslint-scope": "3.7.
|
|
50
|
+
"@types/chai": "4.3.20",
|
|
51
|
+
"@types/chance": "1.1.7",
|
|
52
|
+
"@types/escodegen": "0.0.10",
|
|
53
|
+
"@types/eslint-scope": "3.7.7",
|
|
54
54
|
"@types/eslint-visitor-keys": "1.0.0",
|
|
55
|
-
"@types/estraverse": "5.1.
|
|
55
|
+
"@types/estraverse": "5.1.7",
|
|
56
56
|
"@types/estree": "0.0.51",
|
|
57
|
-
"@types/js-beautify": "1.
|
|
58
|
-
"@types/js-string-escape": "1.0.
|
|
59
|
-
"@types/md5": "2.3.
|
|
57
|
+
"@types/js-beautify": "1.14.3",
|
|
58
|
+
"@types/js-string-escape": "1.0.3",
|
|
59
|
+
"@types/md5": "2.3.6",
|
|
60
60
|
"@types/mkdirp": "1.0.2",
|
|
61
|
-
"@types/mocha": "10.0.
|
|
61
|
+
"@types/mocha": "10.0.10",
|
|
62
62
|
"@types/multimatch": "4.0.0",
|
|
63
|
-
"@types/node": "
|
|
63
|
+
"@types/node": "22.10.2",
|
|
64
64
|
"@types/rimraf": "3.0.2",
|
|
65
|
-
"@types/sinon": "
|
|
66
|
-
"@types/string-template": "1.0.
|
|
67
|
-
"@types/webpack-env": "1.18.
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "
|
|
69
|
-
"@typescript-eslint/parser": "
|
|
70
|
-
"chai": "4.
|
|
71
|
-
"chai-exclude": "
|
|
72
|
-
"cross-env": "
|
|
73
|
-
"eslint": "8.
|
|
74
|
-
"eslint-plugin-import": "2.
|
|
75
|
-
"eslint-plugin-jsdoc": "
|
|
65
|
+
"@types/sinon": "17.0.4",
|
|
66
|
+
"@types/string-template": "1.0.7",
|
|
67
|
+
"@types/webpack-env": "1.18.8",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "7.18.0",
|
|
69
|
+
"@typescript-eslint/parser": "7.18.0",
|
|
70
|
+
"chai": "4.5.0",
|
|
71
|
+
"chai-exclude": "3.0.1",
|
|
72
|
+
"cross-env": "10.1.0",
|
|
73
|
+
"eslint": "8.57.1",
|
|
74
|
+
"eslint-plugin-import": "2.32.0",
|
|
75
|
+
"eslint-plugin-jsdoc": "50.6.3",
|
|
76
76
|
"eslint-plugin-no-null": "1.0.2",
|
|
77
77
|
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
78
|
-
"eslint-plugin-unicorn": "
|
|
79
|
-
"eslint-webpack-plugin": "4.
|
|
80
|
-
"fork-ts-checker-notifier-webpack-plugin": "
|
|
81
|
-
"fork-ts-checker-webpack-plugin": "
|
|
82
|
-
"husky": "
|
|
83
|
-
"js-beautify": "1.
|
|
84
|
-
"mocha": "
|
|
85
|
-
"nyc": "
|
|
78
|
+
"eslint-plugin-unicorn": "56.0.1",
|
|
79
|
+
"eslint-webpack-plugin": "4.2.0",
|
|
80
|
+
"fork-ts-checker-notifier-webpack-plugin": "9.0.0",
|
|
81
|
+
"fork-ts-checker-webpack-plugin": "9.1.0",
|
|
82
|
+
"husky": "9.1.7",
|
|
83
|
+
"js-beautify": "1.15.4",
|
|
84
|
+
"mocha": "11.7.4",
|
|
85
|
+
"nyc": "17.1.0",
|
|
86
86
|
"pjson": "1.0.9",
|
|
87
|
-
"rimraf": "
|
|
88
|
-
"sinon": "
|
|
87
|
+
"rimraf": "6.0.1",
|
|
88
|
+
"sinon": "19.0.2",
|
|
89
89
|
"source-map-resolve": "0.6.0",
|
|
90
|
-
"terser": "5.
|
|
90
|
+
"terser": "5.44.0",
|
|
91
91
|
"threads": "1.7.0",
|
|
92
|
-
"ts-loader": "9.4
|
|
93
|
-
"ts-node": "10.9.
|
|
94
|
-
"typescript": "
|
|
95
|
-
"webpack": "5.
|
|
96
|
-
"webpack-cli": "
|
|
92
|
+
"ts-loader": "9.5.4",
|
|
93
|
+
"ts-node": "10.9.2",
|
|
94
|
+
"typescript": "5.9.3",
|
|
95
|
+
"webpack": "5.102.1",
|
|
96
|
+
"webpack-cli": "6.0.1",
|
|
97
97
|
"webpack-node-externals": "3.0.0"
|
|
98
98
|
},
|
|
99
99
|
"repository": {
|
|
@@ -111,15 +111,16 @@
|
|
|
111
111
|
"test:devCompilePerformance": "ts-node test/dev/dev-compile-performance.ts",
|
|
112
112
|
"test:devRuntimePerformance": "ts-node test/dev/dev-runtime-performance.ts",
|
|
113
113
|
"test:full": "yarn run test:dev && yarn run test:mocha-coverage && yarn run test:mocha-memory-performance",
|
|
114
|
-
"test:mocha": "mocha --require source-map-support/register test/index.spec.ts --exit",
|
|
114
|
+
"test:mocha": "mocha --require ts-node/register --require source-map-support/register test/index.spec.ts --exit",
|
|
115
115
|
"test:mocha-coverage": "cross-env NODE_OPTIONS=--max-old-space-size=4096 nyc --reporter text-summary --no-clean yarn run test:mocha",
|
|
116
116
|
"test:mocha-coverage:report": "nyc report --reporter=lcov",
|
|
117
|
-
"test:mocha-memory-performance": "cross-env NODE_OPTIONS=--max-old-space-size=280 mocha test/performance-tests/JavaScriptObfuscatorMemory.spec.ts",
|
|
117
|
+
"test:mocha-memory-performance": "cross-env NODE_OPTIONS=--max-old-space-size=280 mocha --require ts-node/register test/performance-tests/JavaScriptObfuscatorMemory.spec.ts",
|
|
118
118
|
"test": "yarn run test:full",
|
|
119
119
|
"eslint": "eslint src/**/*.ts",
|
|
120
120
|
"git:addFiles": "git add .",
|
|
121
121
|
"postinstall": "opencollective-postinstall",
|
|
122
122
|
"precommit": "npm run build",
|
|
123
|
+
"prepublishOnly": "npm run build && npm run build:typings",
|
|
123
124
|
"prepare": "husky install"
|
|
124
125
|
},
|
|
125
126
|
"author": {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as acorn from 'acorn';
|
|
2
|
+
export declare const ecmaVersion: acorn.Options["ecmaVersion"] & number;
|
package/typings/src/custom-code-helpers/common/templates/GlobalVariableServiceWorkerTemplate.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function GlobalVariableServiceWorkerTemplate(): string;
|
package/typings/src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
|
7
7
|
import { AbstractCustomNode } from '../AbstractCustomNode';
|
|
8
8
|
export declare class CallExpressionFunctionNode extends AbstractCustomNode {
|
|
9
9
|
private expressionArguments;
|
|
10
|
+
private isChainExpressionParent;
|
|
10
11
|
constructor(identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, customCodeHelperFormatter: ICustomCodeHelperFormatter, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
-
initialize(expressionArguments: (ESTree.Expression | ESTree.SpreadElement)[]): void;
|
|
12
|
+
initialize(expressionArguments: (ESTree.Expression | ESTree.SpreadElement)[], isChainExpressionParent: boolean): void;
|
|
12
13
|
protected getNodeStructure(): TStatement[];
|
|
13
14
|
}
|
|
@@ -36,6 +36,7 @@ export declare enum NodeType {
|
|
|
36
36
|
Literal = "Literal",
|
|
37
37
|
LogicalExpression = "LogicalExpression",
|
|
38
38
|
MemberExpression = "MemberExpression",
|
|
39
|
+
MetaProperty = "MetaProperty",
|
|
39
40
|
MethodDefinition = "MethodDefinition",
|
|
40
41
|
NewExpression = "NewExpression",
|
|
41
42
|
ObjectExpression = "ObjectExpression",
|
|
@@ -3,5 +3,6 @@ export declare enum ObfuscatingGuard {
|
|
|
3
3
|
ConditionalCommentObfuscatingGuard = "ConditionalCommentObfuscatingGuard",
|
|
4
4
|
ForceTransformStringObfuscatingGuard = "ForceTransformStringObfuscatingGuard",
|
|
5
5
|
IgnoredImportObfuscatingGuard = "IgnoredImportObfuscatingGuard",
|
|
6
|
+
ImportMetaObfuscationGuard = "ImportMetaObfuscationGuard",
|
|
6
7
|
ReservedStringObfuscatingGuard = "ReservedStringObfuscatingGuard"
|
|
7
8
|
}
|
|
@@ -8,6 +8,7 @@ export declare class NodeFactory {
|
|
|
8
8
|
static blockStatementNode(body?: ESTree.Statement[]): ESTree.BlockStatement;
|
|
9
9
|
static breakStatement(label?: ESTree.Identifier): ESTree.BreakStatement;
|
|
10
10
|
static callExpressionNode(callee: ESTree.Expression, args?: (ESTree.Expression | ESTree.SpreadElement)[], optional?: boolean): ESTree.CallExpression;
|
|
11
|
+
static chainExpressionNode(expression: ESTree.ChainElement): ESTree.ChainExpression;
|
|
11
12
|
static conditionalExpressionNode(test: ESTree.Expression, consequent: ESTree.Expression, alternate: ESTree.Expression): ESTree.ConditionalExpression;
|
|
12
13
|
static continueStatement(label?: ESTree.Identifier): ESTree.ContinueStatement;
|
|
13
14
|
static directiveNode(expression: ESTree.Literal, directive: string): ESTree.Directive;
|
|
@@ -17,7 +18,7 @@ export declare class NodeFactory {
|
|
|
17
18
|
static expressionStatementNode(expression: ESTree.Expression): ESTree.ExpressionStatement;
|
|
18
19
|
static forStatementNode(init: ESTree.VariableDeclaration | ESTree.Expression | null, test: ESTree.Expression | null, update: ESTree.Expression | null, body: ESTree.Statement): ESTree.ForStatement;
|
|
19
20
|
static forInStatementNode(left: ESTree.VariableDeclaration | ESTree.Pattern, right: ESTree.Expression, body: ESTree.Statement): ESTree.ForInStatement;
|
|
20
|
-
static forOfStatementNode(
|
|
21
|
+
static forOfStatementNode(asAwait: boolean, left: ESTree.VariableDeclaration | ESTree.Pattern, right: ESTree.Expression, body: ESTree.Statement): ESTree.ForOfStatement;
|
|
21
22
|
static functionDeclarationNode(functionName: string, params: ESTree.Identifier[], body: ESTree.BlockStatement): ESTree.FunctionDeclaration;
|
|
22
23
|
static functionExpressionNode(params: ESTree.Pattern[], body: ESTree.BlockStatement): ESTree.FunctionExpression;
|
|
23
24
|
static ifStatementNode(test: ESTree.Expression, consequent: ESTree.Statement, alternate?: ESTree.Statement | null): ESTree.IfStatement;
|
|
@@ -14,6 +14,7 @@ export declare class NodeGuards {
|
|
|
14
14
|
static isBlockStatementNode(node: ESTree.Node): node is ESTree.BlockStatement;
|
|
15
15
|
static isBreakStatementNode(node: ESTree.Node): node is ESTree.BreakStatement;
|
|
16
16
|
static isCallExpressionNode(node: ESTree.Node): node is ESTree.CallExpression;
|
|
17
|
+
static isChainExpressionNode(node: ESTree.Node): node is ESTree.ChainExpression;
|
|
17
18
|
static isClassBodyNode(node: ESTree.Node): node is ESTree.ClassBody;
|
|
18
19
|
static isClassDeclarationNode(node: ESTree.Node): node is ESTree.ClassDeclaration & {
|
|
19
20
|
id: ESTree.Identifier;
|
|
@@ -45,6 +46,7 @@ export declare class NodeGuards {
|
|
|
45
46
|
static isLiteralNode(node: ESTree.Node): node is ESTree.Literal;
|
|
46
47
|
static isLogicalExpressionNode(node: ESTree.Node): node is ESTree.LogicalExpression;
|
|
47
48
|
static isMemberExpressionNode(node: ESTree.Node): node is ESTree.MemberExpression;
|
|
49
|
+
static isMetaPropertyNode(node: ESTree.Node): node is ESTree.MetaProperty;
|
|
48
50
|
static isMethodDefinitionNode(node: ESTree.Node): node is ESTree.MethodDefinition;
|
|
49
51
|
static isNewExpressionNode(node: ESTree.Node): node is ESTree.NewExpression;
|
|
50
52
|
static isNode(object: Object & {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as ESTree from 'estree';
|
|
2
|
+
import { IObfuscatingGuard } from '../../../interfaces/node-transformers/preparing-transformers/obfuscating-guards/IObfuscatingGuard';
|
|
3
|
+
import { ObfuscatingGuardResult } from '../../../enums/node/ObfuscatingGuardResult';
|
|
4
|
+
export declare class ImportMetaObfuscationGuard implements IObfuscatingGuard {
|
|
5
|
+
check(node: ESTree.Node): ObfuscatingGuardResult;
|
|
6
|
+
}
|
package/index.cli.ts
DELETED
package/index.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { TDictionary } from './src/types/TDictionary';
|
|
4
|
-
import { TInputOptions } from './src/types/options/TInputOptions';
|
|
5
|
-
import { TObfuscationResultsObject } from './src/types/TObfuscationResultsObject';
|
|
6
|
-
import { TOptionsPreset } from './src/types/options/TOptionsPreset';
|
|
7
|
-
|
|
8
|
-
import { IObfuscationResult } from './src/interfaces/source-code/IObfuscationResult';
|
|
9
|
-
|
|
10
|
-
import { JavaScriptObfuscator } from './src/JavaScriptObfuscatorFacade';
|
|
11
|
-
|
|
12
|
-
export type ObfuscatorOptions = TInputOptions;
|
|
13
|
-
|
|
14
|
-
export interface ObfuscationResult extends IObfuscationResult {}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {string} sourceCode
|
|
18
|
-
* @param {ObfuscatorOptions} inputOptions
|
|
19
|
-
* @returns {ObfuscatedCode}
|
|
20
|
-
*/
|
|
21
|
-
export declare function obfuscate (sourceCode: string, inputOptions?: ObfuscatorOptions): ObfuscationResult;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @param {TSourceCodesObject} sourceCodesObject
|
|
25
|
-
* @param {TInputOptions} inputOptions
|
|
26
|
-
* @returns {TObfuscationResultsObject<TSourceCodesObject>}
|
|
27
|
-
*/
|
|
28
|
-
export declare function obfuscateMultiple <TSourceCodesObject extends TDictionary<string>> (
|
|
29
|
-
sourceCodesObject: TSourceCodesObject,
|
|
30
|
-
inputOptions?: TInputOptions
|
|
31
|
-
): TObfuscationResultsObject<TSourceCodesObject>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {TOptionsPreset} optionsPreset
|
|
35
|
-
* @returns {TInputOptions}
|
|
36
|
-
*/
|
|
37
|
-
export declare function getOptionsByPreset (optionsPreset: TOptionsPreset): TInputOptions;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @type {string}
|
|
41
|
-
*/
|
|
42
|
-
export declare const version: string;
|
|
43
|
-
|
|
44
|
-
module.exports = JavaScriptObfuscator;
|