javascript-obfuscator 3.0.0 → 3.2.1
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/CHANGELOG.md +18 -0
- package/README.md +91 -6
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.LICENSE.txt +1 -1
- 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 +35 -33
- package/typings/src/code-transformers/AbstractCodeTransformer.d.ts +1 -1
- package/typings/src/container/InversifyContainerFacade.d.ts +2 -1
- package/typings/src/container/ServiceIdentifiers.d.ts +2 -1
- package/typings/src/custom-code-helpers/AbstractCustomCodeHelper.d.ts +1 -1
- package/typings/src/custom-nodes/AbstractCustomNode.d.ts +1 -1
- package/typings/src/custom-nodes/control-flow-flattening-nodes/{StringLiteralNode.d.ts → LiteralNode.d.ts} +4 -3
- package/typings/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.d.ts +2 -2
- package/typings/src/custom-nodes/string-array-nodes/AbstractStringArrayCallNode.d.ts +1 -1
- package/typings/src/custom-nodes/string-array-nodes/string-array-index-nodes/AbstractStringArrayIndexNode.d.ts +1 -1
- package/typings/src/enums/custom-nodes/ControlFlowCustomNode.d.ts +2 -2
- package/typings/src/enums/node/NodeType.d.ts +1 -0
- package/typings/src/enums/node-transformers/NodeTransformer.d.ts +1 -0
- package/typings/src/enums/node-transformers/control-flow-transformers/control-flow-replacers/ControlFlowReplacer.d.ts +1 -0
- package/typings/src/enums/storages/ControlFlowStorage.d.ts +4 -0
- package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts +2 -1
- package/typings/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.d.ts +1 -0
- package/typings/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.d.ts +1 -0
- package/typings/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.d.ts +9 -2
- package/typings/src/generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator.d.ts +2 -2
- package/typings/src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts +1 -0
- package/typings/src/interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer.d.ts +3 -2
- package/typings/src/interfaces/options/IOptions.d.ts +2 -0
- package/typings/src/interfaces/storages/IWeakMapStorage.d.ts +9 -0
- package/typings/src/interfaces/storages/control-flow-transformers/IControlFlowStorage.d.ts +4 -0
- package/typings/src/interfaces/storages/string-array-transformers/IStringArrayScopeCallsWrappersDataStorage.d.ts +2 -2
- package/typings/src/interfaces/utils/ISetUtils.d.ts +3 -0
- package/typings/src/node/NodeFactory.d.ts +1 -0
- package/typings/src/node/NodeGuards.d.ts +1 -0
- package/typings/src/node/NodeLiteralUtils.d.ts +2 -0
- package/typings/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.d.ts +22 -13
- package/typings/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.d.ts +25 -0
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.d.ts +8 -5
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.d.ts +4 -3
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.d.ts +4 -3
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.d.ts +2 -1
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.d.ts +4 -3
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/StringArrayCallControlFlowReplacer.d.ts +14 -0
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.d.ts +5 -4
- package/typings/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.d.ts +0 -2
- package/typings/src/node-transformers/simplifying-transformers/AbstractStatementSimplifyTransformer.d.ts +1 -1
- package/typings/src/options/Options.d.ts +2 -0
- package/typings/src/options/normalizer-rules/StringArrayCallsTransformThresholdRule.d.ts +2 -0
- package/typings/src/storages/ArrayStorage.d.ts +1 -1
- package/typings/src/storages/WeakMapStorage.d.ts +17 -0
- package/typings/src/storages/control-flow-transformers/FunctionControlFlowStorage.d.ts +11 -0
- package/typings/src/storages/control-flow-transformers/StringControlFlowStorage.d.ts +8 -0
- package/typings/src/storages/string-array-transformers/StringArrayScopeCallsWrappersDataStorage.d.ts +2 -2
- package/typings/src/types/TConstructor.d.ts +1 -0
- package/typings/src/types/container/node-transformers/TControlFlowStorageFactory.d.ts +2 -2
- package/typings/src/types/container/node-transformers/TControlFlowStorageFactoryCreator.d.ts +3 -0
- package/typings/src/types/node/TNumberLiteralNode.d.ts +4 -0
- package/typings/src/utils/SetUtils.d.ts +7 -0
- package/typings/src/storages/custom-nodes/ControlFlowStorage.d.ts +0 -7
- package/typings/src/types/storages/TControlFlowStorage.d.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "javascript-obfuscator",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "JavaScript obfuscator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"obfuscator",
|
|
@@ -21,76 +21,78 @@
|
|
|
21
21
|
},
|
|
22
22
|
"types": "typings/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@javascript-obfuscator/escodegen": "2.
|
|
25
|
-
"@javascript-obfuscator/estraverse": "5.
|
|
24
|
+
"@javascript-obfuscator/escodegen": "2.3.0",
|
|
25
|
+
"@javascript-obfuscator/estraverse": "5.4.0",
|
|
26
26
|
"@nuxtjs/opencollective": "0.3.2",
|
|
27
|
-
"acorn": "8.
|
|
27
|
+
"acorn": "8.7.0",
|
|
28
28
|
"assert": "2.0.0",
|
|
29
29
|
"chalk": "4.1.2",
|
|
30
30
|
"chance": "1.1.8",
|
|
31
|
-
"class-validator": "0.13.
|
|
32
|
-
"commander": "
|
|
33
|
-
"eslint-scope": "
|
|
31
|
+
"class-validator": "0.13.2",
|
|
32
|
+
"commander": "9.0.0",
|
|
33
|
+
"eslint-scope": "7.1.0",
|
|
34
|
+
"eslint-visitor-keys": "3.2.0",
|
|
34
35
|
"fast-deep-equal": "3.1.3",
|
|
35
|
-
"inversify": "
|
|
36
|
+
"inversify": "6.0.1",
|
|
36
37
|
"js-string-escape": "1.0.1",
|
|
37
38
|
"md5": "2.3.0",
|
|
38
39
|
"mkdirp": "1.0.4",
|
|
39
40
|
"multimatch": "5.0.0",
|
|
40
41
|
"process": "0.11.10",
|
|
41
42
|
"reflect-metadata": "0.1.13",
|
|
42
|
-
"source-map-support": "0.5.
|
|
43
|
+
"source-map-support": "0.5.21",
|
|
43
44
|
"string-template": "1.0.0",
|
|
44
45
|
"stringz": "2.1.0",
|
|
45
46
|
"tslib": "2.3.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@istanbuljs/nyc-config-typescript": "1.0.
|
|
49
|
-
"@types/chai": "4.
|
|
49
|
+
"@istanbuljs/nyc-config-typescript": "1.0.2",
|
|
50
|
+
"@types/chai": "4.3.0",
|
|
50
51
|
"@types/chance": "1.1.3",
|
|
51
52
|
"@types/escodegen": "0.0.7",
|
|
52
|
-
"@types/eslint-scope": "3.7.
|
|
53
|
+
"@types/eslint-scope": "3.7.3",
|
|
54
|
+
"@types/eslint-visitor-keys": "1.0.0",
|
|
53
55
|
"@types/estraverse": "5.1.1",
|
|
54
56
|
"@types/estree": "0.0.50",
|
|
55
57
|
"@types/js-beautify": "1.13.3",
|
|
56
58
|
"@types/js-string-escape": "1.0.1",
|
|
57
59
|
"@types/md5": "2.3.1",
|
|
58
60
|
"@types/mkdirp": "1.0.2",
|
|
59
|
-
"@types/mocha": "9.
|
|
61
|
+
"@types/mocha": "9.1.0",
|
|
60
62
|
"@types/multimatch": "4.0.0",
|
|
61
|
-
"@types/node": "
|
|
63
|
+
"@types/node": "17.0.13",
|
|
62
64
|
"@types/rimraf": "3.0.2",
|
|
63
|
-
"@types/sinon": "10.0.
|
|
65
|
+
"@types/sinon": "10.0.9",
|
|
64
66
|
"@types/string-template": "1.0.2",
|
|
65
67
|
"@types/webpack-env": "1.16.3",
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
67
|
-
"@typescript-eslint/parser": "5.
|
|
68
|
-
"chai": "4.3.
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "5.10.1",
|
|
69
|
+
"@typescript-eslint/parser": "5.10.1",
|
|
70
|
+
"chai": "4.3.6",
|
|
69
71
|
"chai-exclude": "2.1.0",
|
|
70
72
|
"cross-env": "7.0.3",
|
|
71
|
-
"eslint": "
|
|
72
|
-
"eslint-plugin-import": "2.
|
|
73
|
-
"eslint-plugin-jsdoc": "
|
|
73
|
+
"eslint": "8.8.0",
|
|
74
|
+
"eslint-plugin-import": "2.25.4",
|
|
75
|
+
"eslint-plugin-jsdoc": "37.7.0",
|
|
74
76
|
"eslint-plugin-no-null": "1.0.2",
|
|
75
77
|
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
76
|
-
"eslint-plugin-unicorn": "
|
|
78
|
+
"eslint-plugin-unicorn": "40.1.0",
|
|
77
79
|
"fork-ts-checker-notifier-webpack-plugin": "4.0.0",
|
|
78
|
-
"fork-ts-checker-webpack-plugin": "6.
|
|
79
|
-
"husky": "
|
|
80
|
+
"fork-ts-checker-webpack-plugin": "6.4.0",
|
|
81
|
+
"husky": "7.0.4",
|
|
80
82
|
"js-beautify": "1.14.0",
|
|
81
|
-
"mocha": "9.
|
|
83
|
+
"mocha": "9.2.0",
|
|
82
84
|
"nyc": "15.1.0",
|
|
83
85
|
"pjson": "1.0.9",
|
|
84
86
|
"rimraf": "3.0.2",
|
|
85
|
-
"sinon": "
|
|
87
|
+
"sinon": "13.0.0",
|
|
86
88
|
"source-map-resolve": "0.6.0",
|
|
87
|
-
"terser": "
|
|
89
|
+
"terser": "5.10.0",
|
|
88
90
|
"threads": "1.7.0",
|
|
89
91
|
"ts-loader": "9.2.6",
|
|
90
|
-
"ts-node": "10.
|
|
91
|
-
"typescript": "4.
|
|
92
|
-
"webpack": "5.
|
|
93
|
-
"webpack-cli": "4.9.
|
|
92
|
+
"ts-node": "10.4.0",
|
|
93
|
+
"typescript": "4.5.5",
|
|
94
|
+
"webpack": "5.67.0",
|
|
95
|
+
"webpack-cli": "4.9.2",
|
|
94
96
|
"webpack-node-externals": "3.0.0"
|
|
95
97
|
},
|
|
96
98
|
"repository": {
|
|
@@ -109,9 +111,9 @@
|
|
|
109
111
|
"test:devRuntimePerformance": "ts-node test/dev/dev-runtime-performance.ts",
|
|
110
112
|
"test:full": "yarn run test:dev && yarn run test:mocha-coverage && yarn run test:mocha-memory-performance",
|
|
111
113
|
"test:mocha": "mocha --require ts-node/register --require source-map-support/register test/index.spec.ts --exit",
|
|
112
|
-
"test:mocha-coverage": "nyc --reporter text-summary --no-clean yarn run test:mocha",
|
|
114
|
+
"test:mocha-coverage": "NODE_OPTIONS=--max-old-space-size=4096 nyc --reporter text-summary --no-clean yarn run test:mocha",
|
|
113
115
|
"test:mocha-coverage:report": "nyc report --reporter=lcov",
|
|
114
|
-
"test:mocha-memory-performance": "cross-env NODE_OPTIONS=--max-old-space-size=
|
|
116
|
+
"test:mocha-memory-performance": "cross-env NODE_OPTIONS=--max-old-space-size=240 mocha --require ts-node/register test/performance-tests/JavaScriptObfuscatorMemory.spec.ts",
|
|
115
117
|
"test": "yarn run test:full",
|
|
116
118
|
"eslint": "eslint src/**/*.ts",
|
|
117
119
|
"git:addFiles": "git add .",
|
|
@@ -7,6 +7,6 @@ export declare abstract class AbstractCodeTransformer implements ICodeTransforme
|
|
|
7
7
|
readonly runAfter: CodeTransformer[] | undefined;
|
|
8
8
|
protected readonly options: IOptions;
|
|
9
9
|
protected readonly randomGenerator: IRandomGenerator;
|
|
10
|
-
|
|
10
|
+
constructor(randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
11
|
abstract transformCode(code: string, codeTransformationStage: CodeTransformationStage): string;
|
|
12
12
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { interfaces } from 'inversify';
|
|
2
|
+
import { TConstructor } from '../types/TConstructor';
|
|
2
3
|
import { TInputOptions } from '../types/options/TInputOptions';
|
|
3
4
|
import { IInversifyContainerFacade } from '../interfaces/container/IInversifyContainerFacade';
|
|
4
5
|
export declare class InversifyContainerFacade implements IInversifyContainerFacade {
|
|
@@ -6,7 +7,7 @@ export declare class InversifyContainerFacade implements IInversifyContainerFaca
|
|
|
6
7
|
constructor();
|
|
7
8
|
static getFactory<T extends string, U>(serviceIdentifier: interfaces.ServiceIdentifier<U>): (context: interfaces.Context) => (bindingName: T) => U;
|
|
8
9
|
static getCacheFactory<T extends string, U>(serviceIdentifier: interfaces.ServiceIdentifier<U>): (context: interfaces.Context) => (bindingName: T) => U;
|
|
9
|
-
static getConstructorFactory<T extends string, U>(serviceIdentifier: interfaces.ServiceIdentifier<
|
|
10
|
+
static getConstructorFactory<T extends string, U>(serviceIdentifier: interfaces.ServiceIdentifier<TConstructor<Record<string, any>[], U>>, ...dependencies: interfaces.ServiceIdentifier<TConstructor<Record<string, any>[], U>>[]): (context: interfaces.Context) => (bindingName: T) => U;
|
|
10
11
|
get<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>): T;
|
|
11
12
|
getNamed<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>, named: string | number | symbol): T;
|
|
12
13
|
load(sourceCode: string, sourceMap: string, options: TInputOptions): void;
|
|
@@ -21,6 +21,7 @@ export declare enum ServiceIdentifiers {
|
|
|
21
21
|
ICodeTransformer = "ICodeTransformer",
|
|
22
22
|
ICodeTransformerNamesGroupsBuilder = "ICodeTransformerNamesGroupsBuilder",
|
|
23
23
|
ICodeTransformersRunner = "ICodeTransformersRunner",
|
|
24
|
+
IControlFlowStorage = "IControlFlowStorage",
|
|
24
25
|
ICryptUtils = "ICryptUtils",
|
|
25
26
|
ICryptUtilsStringArray = "ICryptUtilsStringArray",
|
|
26
27
|
ICustomCodeHelper = "ICustomCodeHelper",
|
|
@@ -50,6 +51,7 @@ export declare enum ServiceIdentifiers {
|
|
|
50
51
|
IRandomGenerator = "IRandomGenerator",
|
|
51
52
|
IRenamePropertiesReplacer = "IRenamePropertiesReplacer",
|
|
52
53
|
IScopeIdentifiersTraverser = "IScopeIdentifiersTraverser",
|
|
54
|
+
ISetUtils = "ISetUtils",
|
|
53
55
|
ISourceCode = "ISourceCode",
|
|
54
56
|
IScopeAnalyzer = "IScopeAnalyzer",
|
|
55
57
|
IStringArrayIndexNode = "IStringArrayIndexNode",
|
|
@@ -59,7 +61,6 @@ export declare enum ServiceIdentifiers {
|
|
|
59
61
|
IThroughIdentifierReplacer = "IThroughIdentifierReplacer",
|
|
60
62
|
IVisitedLexicalScopeNodesStackStorage = "IVisitedLexicalScopeNodesStackStorage",
|
|
61
63
|
Newable__ICustomNode = "Newable<ICustomNode>",
|
|
62
|
-
Newable__TControlFlowStorage = "Newable<TControlFlowStorage>",
|
|
63
64
|
TCustomNodeGroupStorage = "TCustomNodeGroupStorage",
|
|
64
65
|
TInputOptions = "TInputOptions"
|
|
65
66
|
}
|
|
@@ -14,7 +14,7 @@ export declare abstract class AbstractCustomCodeHelper<TInitialData extends unkn
|
|
|
14
14
|
protected readonly identifierNamesGenerator: IIdentifierNamesGenerator;
|
|
15
15
|
protected readonly options: IOptions;
|
|
16
16
|
protected readonly randomGenerator: IRandomGenerator;
|
|
17
|
-
|
|
17
|
+
constructor(identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, customCodeHelperFormatter: ICustomCodeHelperFormatter, customCodeHelperObfuscator: ICustomCodeHelperObfuscator, randomGenerator: IRandomGenerator, options: IOptions);
|
|
18
18
|
getNode(): TStatement[];
|
|
19
19
|
protected getGlobalVariableTemplate(): string;
|
|
20
20
|
protected getCodeHelperTemplate(): string;
|
|
@@ -11,7 +11,7 @@ export declare abstract class AbstractCustomNode<TInitialData extends unknown[]
|
|
|
11
11
|
protected readonly identifierNamesGenerator: IIdentifierNamesGenerator;
|
|
12
12
|
protected readonly options: IOptions;
|
|
13
13
|
protected readonly randomGenerator: IRandomGenerator;
|
|
14
|
-
|
|
14
|
+
constructor(identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, customCodeHelperFormatter: ICustomCodeHelperFormatter, randomGenerator: IRandomGenerator, options: IOptions);
|
|
15
15
|
getNode(): TStatement[];
|
|
16
16
|
abstract initialize(...args: TInitialData): void;
|
|
17
17
|
protected abstract getNodeStructure(): TStatement[];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import type * as ESTree from 'estree';
|
|
1
2
|
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
2
3
|
import { TStatement } from '../../types/node/TStatement';
|
|
3
4
|
import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
|
|
4
5
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
5
6
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
6
7
|
import { AbstractCustomNode } from '../AbstractCustomNode';
|
|
7
|
-
export declare class
|
|
8
|
-
private
|
|
8
|
+
export declare class LiteralNode extends AbstractCustomNode {
|
|
9
|
+
private literalNode;
|
|
9
10
|
constructor(identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, customCodeHelperFormatter: ICustomCodeHelperFormatter, randomGenerator: IRandomGenerator, options: IOptions);
|
|
10
|
-
initialize(
|
|
11
|
+
initialize(literalNode: ESTree.Literal): void;
|
|
11
12
|
protected getNodeStructure(): TStatement[];
|
|
12
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TControlFlowStorage } from '../../../types/storages/TControlFlowStorage';
|
|
2
1
|
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
3
2
|
import { TStatement } from '../../../types/node/TStatement';
|
|
3
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
4
4
|
import { ICustomCodeHelperFormatter } from '../../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
|
|
5
5
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
6
6
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
@@ -8,6 +8,6 @@ import { AbstractCustomNode } from '../../AbstractCustomNode';
|
|
|
8
8
|
export declare class ControlFlowStorageNode extends AbstractCustomNode {
|
|
9
9
|
private controlFlowStorage;
|
|
10
10
|
constructor(identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, customCodeHelperFormatter: ICustomCodeHelperFormatter, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
-
initialize(controlFlowStorage:
|
|
11
|
+
initialize(controlFlowStorage: IControlFlowStorage): void;
|
|
12
12
|
protected getNodeStructure(): TStatement[];
|
|
13
13
|
}
|
|
@@ -13,7 +13,7 @@ export declare abstract class AbstractStringArrayCallNode extends AbstractCustom
|
|
|
13
13
|
protected readonly arrayUtils: IArrayUtils;
|
|
14
14
|
protected readonly stringArrayStorage: IStringArrayStorage;
|
|
15
15
|
private readonly stringArrayIndexNodeFactory;
|
|
16
|
-
|
|
16
|
+
constructor(identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, stringArrayIndexNodeFactory: TStringArrayIndexNodeFactory, customCodeHelperFormatter: ICustomCodeHelperFormatter, stringArrayStorage: IStringArrayStorage, arrayUtils: IArrayUtils, randomGenerator: IRandomGenerator, options: IOptions);
|
|
17
17
|
protected getStringArrayIndexNode(index: number): ESTree.Expression;
|
|
18
18
|
protected getRc4KeyLiteralNode(decodeKey: string): ESTree.Literal;
|
|
19
19
|
}
|
|
@@ -5,6 +5,6 @@ import { IStringArrayIndexNode } from '../../../interfaces/custom-nodes/string-a
|
|
|
5
5
|
export declare abstract class AbstractStringArrayIndexNode implements IStringArrayIndexNode {
|
|
6
6
|
protected readonly options: IOptions;
|
|
7
7
|
protected readonly randomGenerator: IRandomGenerator;
|
|
8
|
-
|
|
8
|
+
constructor(randomGenerator: IRandomGenerator, options: IOptions);
|
|
9
9
|
abstract getNode(index: number): ESTree.Expression;
|
|
10
10
|
}
|
|
@@ -5,7 +5,7 @@ export declare enum ControlFlowCustomNode {
|
|
|
5
5
|
CallExpressionFunctionNode = "CallExpressionFunctionNode",
|
|
6
6
|
ControlFlowStorageNode = "ControlFlowStorageNode",
|
|
7
7
|
ExpressionWithOperatorControlFlowStorageCallNode = "ExpressionWithOperatorControlFlowStorageCallNode",
|
|
8
|
+
LiteralNode = "LiteralNode",
|
|
8
9
|
LogicalExpressionFunctionNode = "LogicalExpressionFunctionNode",
|
|
9
|
-
StringLiteralControlFlowStorageCallNode = "StringLiteralControlFlowStorageCallNode"
|
|
10
|
-
StringLiteralNode = "StringLiteralNode"
|
|
10
|
+
StringLiteralControlFlowStorageCallNode = "StringLiteralControlFlowStorageCallNode"
|
|
11
11
|
}
|
|
@@ -47,6 +47,7 @@ export declare enum NodeType {
|
|
|
47
47
|
ReturnStatement = "ReturnStatement",
|
|
48
48
|
SequenceExpression = "SequenceExpression",
|
|
49
49
|
SpreadElement = "SpreadElement",
|
|
50
|
+
StaticBlock = "StaticBlock",
|
|
50
51
|
Super = "Super",
|
|
51
52
|
SwitchCase = "SwitchCase",
|
|
52
53
|
SwitchStatement = "SwitchStatement",
|
|
@@ -28,6 +28,7 @@ export declare enum NodeTransformer {
|
|
|
28
28
|
ScopeIdentifiersTransformer = "ScopeIdentifiersTransformer",
|
|
29
29
|
ScopeThroughIdentifiersTransformer = "ScopeThroughIdentifiersTransformer",
|
|
30
30
|
SplitStringTransformer = "SplitStringTransformer",
|
|
31
|
+
StringArrayControlFlowTransformer = "StringArrayControlFlowTransformer",
|
|
31
32
|
StringArrayTransformer = "StringArrayTransformer",
|
|
32
33
|
StringArrayRotateFunctionTransformer = "StringArrayRotateFunctionTransformer",
|
|
33
34
|
StringArrayScopeCallsWrapperTransformer = "StringArrayScopeCallsWrapperTransformer",
|
|
@@ -2,5 +2,6 @@ export declare enum ControlFlowReplacer {
|
|
|
2
2
|
BinaryExpressionControlFlowReplacer = "BinaryExpressionControlFlowReplacer",
|
|
3
3
|
CallExpressionControlFlowReplacer = "CallExpressionControlFlowReplacer",
|
|
4
4
|
LogicalExpressionControlFlowReplacer = "LogicalExpressionControlFlowReplacer",
|
|
5
|
+
StringArrayCallControlFlowReplacer = "StringArrayCallControlFlowReplacer",
|
|
5
6
|
StringLiteralControlFlowReplacer = "StringLiteralControlFlowReplacer"
|
|
6
7
|
}
|
package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare abstract class AbstractIdentifierNamesGenerator implements IIdent
|
|
|
6
6
|
protected readonly options: IOptions;
|
|
7
7
|
protected readonly randomGenerator: IRandomGenerator;
|
|
8
8
|
protected readonly preservedNamesSet: Set<string>;
|
|
9
|
-
protected readonly lexicalScopesPreservedNamesMap:
|
|
9
|
+
protected readonly lexicalScopesPreservedNamesMap: WeakMap<TNodeWithLexicalScope, Set<string>>;
|
|
10
10
|
constructor(randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
11
|
generate(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
12
12
|
preserveName(name: string): void;
|
|
@@ -16,5 +16,6 @@ export declare abstract class AbstractIdentifierNamesGenerator implements IIdent
|
|
|
16
16
|
private notReservedName;
|
|
17
17
|
abstract generateForGlobalScope(nameLength?: number): string;
|
|
18
18
|
abstract generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
19
|
+
abstract generateForLabel(label: string, nameLength?: number): string;
|
|
19
20
|
abstract generateNext(nameLength?: number): string;
|
|
20
21
|
}
|
package/typings/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class DictionaryIdentifierNamesGenerator extends AbstractIdentifi
|
|
|
12
12
|
generateNext(): string;
|
|
13
13
|
generateForGlobalScope(): string;
|
|
14
14
|
generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope): string;
|
|
15
|
+
generateForLabel(label: string): string;
|
|
15
16
|
private generateNewDictionaryName;
|
|
16
17
|
private getInitialIdentifierNames;
|
|
17
18
|
private getIncrementedIdentifierNames;
|
package/typings/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export declare class HexadecimalIdentifierNamesGenerator extends AbstractIdentif
|
|
|
8
8
|
generateNext(nameLength?: number): string;
|
|
9
9
|
generateForGlobalScope(nameLength?: number): string;
|
|
10
10
|
generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
11
|
+
generateForLabel(label: string, nameLength?: number): string;
|
|
11
12
|
}
|
package/typings/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
|
|
2
2
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
3
3
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
4
|
+
import { ISetUtils } from '../../interfaces/utils/ISetUtils';
|
|
4
5
|
import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGenerator';
|
|
5
6
|
export declare class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator {
|
|
7
|
+
private static readonly maxRegenerationAttempts;
|
|
6
8
|
private static readonly initMangledNameCharacter;
|
|
7
9
|
private static readonly lastMangledNameInScopeMap;
|
|
8
10
|
private static readonly nameSequence;
|
|
9
11
|
private static readonly reservedNamesSet;
|
|
12
|
+
private readonly lastMangledNameForLabelMap;
|
|
10
13
|
private previousMangledName;
|
|
11
|
-
|
|
14
|
+
private readonly setUtils;
|
|
15
|
+
constructor(randomGenerator: IRandomGenerator, options: IOptions, setUtils: ISetUtils);
|
|
12
16
|
generateNext(nameLength?: number): string;
|
|
13
17
|
generateForGlobalScope(nameLength?: number): string;
|
|
14
18
|
generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
19
|
+
generateForLabel(label: string, nameLength?: number): string;
|
|
15
20
|
isIncrementedMangledName(nextName: string, prevName: string): boolean;
|
|
16
21
|
isValidIdentifierName(mangledName: string): boolean;
|
|
17
22
|
protected getNameSequence(): string[];
|
|
18
23
|
protected updatePreviousMangledName(name: string): void;
|
|
19
|
-
protected
|
|
24
|
+
protected updatePreviousMangledNameForLabel(name: string, label: string, lastMangledNameForLabel: string): void;
|
|
25
|
+
protected generateNewMangledName(previousMangledName: string, validationFunction?: (newIdentifierName: string) => boolean): string;
|
|
20
26
|
private getLastMangledNameForScopes;
|
|
27
|
+
private getLastMangledNameForLabel;
|
|
21
28
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { IArrayUtils } from '../../interfaces/utils/IArrayUtils';
|
|
2
2
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
3
3
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
4
|
+
import { ISetUtils } from '../../interfaces/utils/ISetUtils';
|
|
4
5
|
import { MangledIdentifierNamesGenerator } from './MangledIdentifierNamesGenerator';
|
|
5
6
|
export declare class MangledShuffledIdentifierNamesGenerator extends MangledIdentifierNamesGenerator {
|
|
6
7
|
protected static shuffledNameSequence: string[];
|
|
7
8
|
private readonly arrayUtils;
|
|
8
|
-
constructor(arrayUtils: IArrayUtils, randomGenerator: IRandomGenerator, options: IOptions);
|
|
9
|
+
constructor(arrayUtils: IArrayUtils, randomGenerator: IRandomGenerator, options: IOptions, setUtils: ISetUtils);
|
|
9
10
|
initialize(): void;
|
|
10
11
|
protected initializeNameSequence(nameSequence: string[]): void;
|
|
11
12
|
protected getNameSequence(): string[];
|
|
12
|
-
protected generateNewMangledName(previousMangledName: string): string;
|
|
13
13
|
}
|
package/typings/src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface IIdentifierNamesGenerator {
|
|
|
3
3
|
generate(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
4
4
|
generateForGlobalScope(nameLength?: number): string;
|
|
5
5
|
generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
6
|
+
generateForLabel(label: string, nameLength?: number): string;
|
|
6
7
|
generateNext(nameLength?: number): string;
|
|
7
8
|
isValidIdentifierName(identifierName: string): boolean;
|
|
8
9
|
isValidIdentifierNameInLexicalScopes(identifierName: string, lexicalScopeNodes: TNodeWithLexicalScope[]): boolean;
|
package/typings/src/interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
|
-
import {
|
|
2
|
+
import { IControlFlowStorage } from '../../storages/control-flow-transformers/IControlFlowStorage';
|
|
3
3
|
export interface IControlFlowReplacer {
|
|
4
|
-
replace(node: ESTree.Node, parentNode: ESTree.Node, controlFlowStorage:
|
|
4
|
+
replace(node: ESTree.Node, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
5
|
+
generateStorageKey(controlFlowStorage: IControlFlowStorage): string;
|
|
5
6
|
}
|
|
@@ -46,6 +46,8 @@ export interface IOptions {
|
|
|
46
46
|
readonly splitStrings: boolean;
|
|
47
47
|
readonly splitStringsChunkLength: number;
|
|
48
48
|
readonly stringArray: boolean;
|
|
49
|
+
readonly stringArrayCallsTransform: boolean;
|
|
50
|
+
readonly stringArrayCallsTransformThreshold: number;
|
|
49
51
|
readonly stringArrayEncoding: TStringArrayEncoding[];
|
|
50
52
|
readonly stringArrayIndexesType: TStringArrayIndexesType[];
|
|
51
53
|
readonly stringArrayIndexShift: boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IInitializable } from '../IInitializable';
|
|
2
|
+
export interface IWeakMapStorage<K extends object, V> extends IInitializable {
|
|
3
|
+
get(key: K): V | undefined;
|
|
4
|
+
getOrThrow(key: K): V;
|
|
5
|
+
getStorage(): WeakMap<K, V>;
|
|
6
|
+
getStorageId(): string;
|
|
7
|
+
has(key: K): boolean;
|
|
8
|
+
set(key: K, value: V): void;
|
|
9
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TNodeWithLexicalScopeStatements } from '../../../types/node/TNodeWithLexicalScopeStatements';
|
|
2
2
|
import { TStringArrayScopeCallsWrappersDataByEncoding } from '../../../types/node-transformers/string-array-transformers/TStringArrayScopeCallsWrappersDataByEncoding';
|
|
3
|
-
import {
|
|
4
|
-
export interface IStringArrayScopeCallsWrappersDataStorage extends
|
|
3
|
+
import { IWeakMapStorage } from '../IWeakMapStorage';
|
|
4
|
+
export interface IStringArrayScopeCallsWrappersDataStorage extends IWeakMapStorage<TNodeWithLexicalScopeStatements, TStringArrayScopeCallsWrappersDataByEncoding> {
|
|
5
5
|
}
|
|
@@ -33,6 +33,7 @@ export declare class NodeFactory {
|
|
|
33
33
|
static returnStatementNode(argument: ESTree.Expression): ESTree.ReturnStatement;
|
|
34
34
|
static sequenceExpressionNode(expressions: ESTree.Expression[]): ESTree.SequenceExpression;
|
|
35
35
|
static spreadElementNode(argument: ESTree.Expression): ESTree.SpreadElement;
|
|
36
|
+
static staticBlockNode(body?: ESTree.Statement[]): ESTree.StaticBlock;
|
|
36
37
|
static switchStatementNode(discriminant: ESTree.Expression, cases: ESTree.SwitchCase[]): ESTree.SwitchStatement;
|
|
37
38
|
static switchCaseNode(test: ESTree.Expression, consequent: ESTree.Statement[]): ESTree.SwitchCase;
|
|
38
39
|
static unaryExpressionNode(operator: ESTree.UnaryOperator, argument: ESTree.Expression, prefix?: true): ESTree.UnaryExpression;
|
|
@@ -65,6 +65,7 @@ export declare class NodeGuards {
|
|
|
65
65
|
static isReturnStatementNode(node: ESTree.Node): node is ESTree.ReturnStatement;
|
|
66
66
|
static isSequenceExpressionNode(node: ESTree.Node): node is ESTree.SequenceExpression;
|
|
67
67
|
static isSpreadElementNode(node: ESTree.Node): node is ESTree.SpreadElement;
|
|
68
|
+
static isStaticBlockNode(node: ESTree.Node): boolean;
|
|
68
69
|
static isSuperNode(node: ESTree.Node): node is ESTree.Super;
|
|
69
70
|
static isSwitchCaseNode(node: ESTree.Node): node is ESTree.SwitchCase;
|
|
70
71
|
static isTaggedTemplateExpressionNode(node: ESTree.Node): node is ESTree.TaggedTemplateExpression;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
|
+
import { TNumberLiteralNode } from '../types/node/TNumberLiteralNode';
|
|
2
3
|
import { TStringLiteralNode } from '../types/node/TStringLiteralNode';
|
|
3
4
|
export declare class NodeLiteralUtils {
|
|
5
|
+
static isNumberLiteralNode(literalNode: ESTree.Literal): literalNode is TNumberLiteralNode;
|
|
4
6
|
static isStringLiteralNode(literalNode: ESTree.Literal): literalNode is TStringLiteralNode;
|
|
5
7
|
static isProhibitedLiteralNode(literalNode: ESTree.Literal, parentNode: ESTree.Node): boolean;
|
|
6
8
|
}
|
package/typings/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.d.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
+
/// <reference types="estraverse" />
|
|
2
|
+
import * as estraverse from '@javascript-obfuscator/estraverse';
|
|
1
3
|
import * as ESTree from 'estree';
|
|
2
4
|
import { TControlFlowCustomNodeFactory } from '../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
5
|
import { TControlFlowReplacerFactory } from '../../types/container/node-transformers/TControlFlowReplacerFactory';
|
|
4
6
|
import { TControlFlowStorageFactory } from '../../types/container/node-transformers/TControlFlowStorageFactory';
|
|
7
|
+
import { TControlFlowStorageFactoryCreator } from '../../types/container/node-transformers/TControlFlowStorageFactoryCreator';
|
|
8
|
+
import { TNodeWithStatements } from '../../types/node/TNodeWithStatements';
|
|
9
|
+
import { IControlFlowStorage } from '../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
5
10
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
6
11
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
7
12
|
import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
|
|
13
|
+
import { ControlFlowReplacer } from '../../enums/node-transformers/control-flow-transformers/control-flow-replacers/ControlFlowReplacer';
|
|
8
14
|
import { NodeTransformationStage } from '../../enums/node-transformers/NodeTransformationStage';
|
|
9
15
|
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
|
10
16
|
export declare class FunctionControlFlowTransformer extends AbstractNodeTransformer {
|
|
11
|
-
private static readonly controlFlowReplacersMap;
|
|
12
17
|
private static readonly hostNodeSearchMinDepth;
|
|
13
18
|
private static readonly hostNodeSearchMaxDepth;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
protected readonly controlFlowReplacersMap: Map<string, ControlFlowReplacer>;
|
|
20
|
+
protected readonly controlFlowData: WeakMap<TNodeWithStatements, IControlFlowStorage>;
|
|
21
|
+
protected readonly hostNodesWithControlFlowNode: WeakMap<TNodeWithStatements, ESTree.VariableDeclaration>;
|
|
22
|
+
protected readonly controlFlowReplacerFactory: TControlFlowReplacerFactory;
|
|
23
|
+
protected controlFlowStorageFactory: TControlFlowStorageFactory;
|
|
24
|
+
protected readonly controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory;
|
|
25
|
+
protected readonly visitedFunctionNodes: WeakSet<ESTree.Function>;
|
|
26
|
+
constructor(controlFlowStorageFactoryCreator: TControlFlowStorageFactoryCreator, controlFlowReplacerFactory: TControlFlowReplacerFactory, controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
21
27
|
getVisitor(nodeTransformationStage: NodeTransformationStage): IVisitor | null;
|
|
22
28
|
transformNode(functionNode: ESTree.Function, parentNode: ESTree.Node): ESTree.Function;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
protected transformFunctionBody(functionNode: ESTree.Function, controlFlowStorage: IControlFlowStorage): void;
|
|
30
|
+
protected transformFunctionBodyNode(node: ESTree.Node, parentNode: ESTree.Node | null, functionNode: ESTree.Function, controlFlowStorage: IControlFlowStorage): estraverse.VisitorOption | ESTree.Node;
|
|
31
|
+
protected getHostNode(functionNodeBody: ESTree.BlockStatement): TNodeWithStatements;
|
|
32
|
+
protected getControlFlowStorage(hostNode: TNodeWithStatements): IControlFlowStorage;
|
|
33
|
+
protected getControlFlowStorageNode(controlFlowStorage: IControlFlowStorage): ESTree.VariableDeclaration;
|
|
34
|
+
protected appendControlFlowStorageNode(hostNode: TNodeWithStatements, controlFlowStorageNode: ESTree.VariableDeclaration): void;
|
|
35
|
+
protected isVisitedFunctionNode(node: ESTree.Node): boolean;
|
|
36
|
+
protected isAllowedTransformationByThreshold(): boolean;
|
|
28
37
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="estraverse" />
|
|
2
|
+
import * as estraverse from '@javascript-obfuscator/estraverse';
|
|
3
|
+
import * as ESTree from 'estree';
|
|
4
|
+
import { TControlFlowCustomNodeFactory } from '../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
5
|
+
import { TControlFlowReplacerFactory } from '../../types/container/node-transformers/TControlFlowReplacerFactory';
|
|
6
|
+
import { TControlFlowStorageFactoryCreator } from '../../types/container/node-transformers/TControlFlowStorageFactoryCreator';
|
|
7
|
+
import { TNodeWithStatements } from '../../types/node/TNodeWithStatements';
|
|
8
|
+
import { IOptions } from '../../interfaces/options/IOptions';
|
|
9
|
+
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
10
|
+
import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
|
|
11
|
+
import { ControlFlowReplacer } from '../../enums/node-transformers/control-flow-transformers/control-flow-replacers/ControlFlowReplacer';
|
|
12
|
+
import { NodeTransformationStage } from '../../enums/node-transformers/NodeTransformationStage';
|
|
13
|
+
import { NodeTransformer } from '../../enums/node-transformers/NodeTransformer';
|
|
14
|
+
import { FunctionControlFlowTransformer } from './FunctionControlFlowTransformer';
|
|
15
|
+
import { IControlFlowStorage } from '../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
16
|
+
export declare class StringArrayControlFlowTransformer extends FunctionControlFlowTransformer {
|
|
17
|
+
readonly runAfter: NodeTransformer[];
|
|
18
|
+
protected readonly controlFlowReplacersMap: Map<string, ControlFlowReplacer>;
|
|
19
|
+
protected readonly controlFlowStorageNodes: WeakSet<ESTree.VariableDeclaration>;
|
|
20
|
+
constructor(controlFlowStorageFactoryCreator: TControlFlowStorageFactoryCreator, controlFlowReplacerFactory: TControlFlowReplacerFactory, controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
21
|
+
getVisitor(nodeTransformationStage: NodeTransformationStage): IVisitor | null;
|
|
22
|
+
protected transformFunctionBodyNode(node: ESTree.Node, parentNode: ESTree.Node | null, functionNode: ESTree.Function, controlFlowStorage: IControlFlowStorage): estraverse.VisitorOption | ESTree.Node;
|
|
23
|
+
protected appendControlFlowStorageNode(hostNode: TNodeWithStatements, controlFlowStorageNode: ESTree.VariableDeclaration): void;
|
|
24
|
+
protected isAllowedTransformationByThreshold(): boolean;
|
|
25
|
+
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
2
|
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
-
import {
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
4
4
|
import { IControlFlowReplacer } from '../../../interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer';
|
|
5
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
5
6
|
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
|
|
7
|
+
import { IIdentifierNamesGenerator } from '../../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
|
|
6
8
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
7
9
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
8
10
|
export declare abstract class AbstractControlFlowReplacer implements IControlFlowReplacer {
|
|
9
11
|
protected readonly controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory;
|
|
12
|
+
protected readonly identifierNamesGenerator: IIdentifierNamesGenerator;
|
|
10
13
|
protected readonly options: IOptions;
|
|
11
14
|
protected readonly randomGenerator: IRandomGenerator;
|
|
12
15
|
protected readonly replacerDataByControlFlowStorageId: Map<string, Map<string, string[]>>;
|
|
13
|
-
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
14
|
-
|
|
15
|
-
protected insertCustomNodeToControlFlowStorage(customNode: ICustomNode, controlFlowStorage:
|
|
16
|
-
abstract replace(node: ESTree.Node, parentNode: ESTree.Node, controlFlowStorage:
|
|
16
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
17
|
+
generateStorageKey(controlFlowStorage: IControlFlowStorage): string;
|
|
18
|
+
protected insertCustomNodeToControlFlowStorage(customNode: ICustomNode, controlFlowStorage: IControlFlowStorage, replacerId: string, usingExistingIdentifierChance: number): string;
|
|
19
|
+
abstract replace(node: ESTree.Node, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
17
20
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
2
|
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
-
import {
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
4
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
4
5
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
5
6
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
6
7
|
import { ExpressionWithOperatorControlFlowReplacer } from './ExpressionWithOperatorControlFlowReplacer';
|
|
7
8
|
export declare class BinaryExpressionControlFlowReplacer extends ExpressionWithOperatorControlFlowReplacer {
|
|
8
9
|
private static readonly usingExistingIdentifierChance;
|
|
9
|
-
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
10
|
-
replace(binaryExpressionNode: ESTree.BinaryExpression, parentNode: ESTree.Node, controlFlowStorage:
|
|
10
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
+
replace(binaryExpressionNode: ESTree.BinaryExpression, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
11
12
|
}
|