javascript-obfuscator 5.1.0 → 5.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.
Files changed (30) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CLAUDE.md +2 -2
  3. package/CODE_OF_CONDUCT.md +1 -1
  4. package/README.md +195 -31
  5. package/dist/index.browser.js +46 -2
  6. package/dist/index.browser.js.map +1 -1
  7. package/dist/index.cli.js +24 -2
  8. package/dist/index.cli.js.map +1 -1
  9. package/dist/index.js +24 -2
  10. package/dist/index.js.map +1 -1
  11. package/package.json +3 -6
  12. package/typings/src/analyzers/scope-analyzer/ScopeAnalyzer.d.ts +3 -0
  13. package/typings/src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.d.ts +1 -0
  14. package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts +3 -0
  15. package/typings/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.d.ts +2 -0
  16. package/typings/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.d.ts +3 -0
  17. package/typings/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.d.ts +2 -0
  18. package/typings/src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts +2 -0
  19. package/typings/src/node/NodeGuards.d.ts +1 -0
  20. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.d.ts +1 -0
  21. package/typings/src/node-transformers/converting-transformers/ClassFieldTransformer.d.ts +1 -1
  22. package/typings/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.d.ts +2 -3
  23. package/typings/src/node-transformers/preparing-transformers/obfuscating-guards/ProcessEnvObfuscationGuard.d.ts +8 -0
  24. package/typings/src/utils/EscapeSequenceEncoder.d.ts +1 -0
  25. package/dist/index.browser.js.LICENSE.txt +0 -45
  26. package/dist/index.cli.js.LICENSE.txt +0 -23
  27. package/dist/index.js.LICENSE.txt +0 -23
  28. package/dist/index_debug.js +0 -14907
  29. package/dist/index_debug.js.LICENSE.txt +0 -23
  30. package/dist/index_debug.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-obfuscator",
3
- "version": "5.1.0",
3
+ "version": "5.2.1",
4
4
  "description": "JavaScript obfuscator",
5
5
  "keywords": [
6
6
  "obfuscator",
@@ -129,12 +129,9 @@
129
129
  "prepare": "husky install"
130
130
  },
131
131
  "author": {
132
- "name": "Timofey Kachalov"
132
+ "name": "Timofei Kachalov"
133
133
  },
134
- "contributors": [
135
- "Timofey Kachalov (https://github.com/sanex3339)",
136
- "Dmitry Zamotkin (https://github.com/zamotkin)"
137
- ],
134
+ "contributors": ["Timofei Kachalov (https://github.com/sanex3339)", "Dmitry Zamotkin (https://github.com/zamotkin)"],
138
135
  "license": "BSD-2-Clause",
139
136
  "packageManager": "yarn@1.22.21+sha512.ca75da26c00327d26267ce33536e5790f18ebd53266796fbb664d2a4a5116308042dd8ee7003b276a20eace7d3c5561c3577bdd71bcb67071187af124779620a"
140
137
  }
@@ -10,5 +10,8 @@ export declare class ScopeAnalyzer implements IScopeAnalyzer {
10
10
  private static isRootNode;
11
11
  analyze(astTree: ESTree.Node): void;
12
12
  acquireScope(node: ESTree.Node): eslintScope.Scope;
13
+ private fixAnnexBFunctionHoisting;
14
+ private linkThroughReferences;
13
15
  private sanitizeScopes;
16
+ private walkScopes;
14
17
  }
@@ -4,5 +4,6 @@ export declare enum ObfuscatingGuard {
4
4
  ForceTransformStringObfuscatingGuard = "ForceTransformStringObfuscatingGuard",
5
5
  IgnoredImportObfuscatingGuard = "IgnoredImportObfuscatingGuard",
6
6
  ImportMetaObfuscationGuard = "ImportMetaObfuscationGuard",
7
+ ProcessEnvObfuscationGuard = "ProcessEnvObfuscationGuard",
7
8
  ReservedStringObfuscatingGuard = "ReservedStringObfuscatingGuard"
8
9
  }
@@ -7,14 +7,17 @@ export declare abstract class AbstractIdentifierNamesGenerator implements IIdent
7
7
  protected readonly randomGenerator: IRandomGenerator;
8
8
  protected readonly preservedNamesSet: Set<string>;
9
9
  protected readonly lexicalScopesPreservedNamesMap: WeakMap<TNodeWithLexicalScope, Set<string>>;
10
+ protected readonly allLexicalScopePreservedNames: Set<string>;
10
11
  constructor(randomGenerator: IRandomGenerator, options: IOptions);
11
12
  generate(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
12
13
  preserveName(name: string): void;
13
14
  preserveNameForLexicalScope(name: string, lexicalScopeNode: TNodeWithLexicalScope): void;
14
15
  isValidIdentifierName(name: string): boolean;
15
16
  isValidIdentifierNameInLexicalScopes(name: string, lexicalScopeNodes: TNodeWithLexicalScope[]): boolean;
17
+ isValidIdentifierNameInAllScopes(name: string): boolean;
16
18
  private isReservedName;
17
19
  abstract generateForGlobalScope(nameLength?: number): string;
20
+ abstract generateForGlobalScopeWithAllScopesValidation(nameLength?: number): string;
18
21
  abstract generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
19
22
  abstract generateForLabel(label: string, nameLength?: number): string;
20
23
  abstract generateNext(nameLength?: number): string;
@@ -11,8 +11,10 @@ export declare class DictionaryIdentifierNamesGenerator extends AbstractIdentifi
11
11
  private static incrementIdentifierName;
12
12
  generateNext(): string;
13
13
  generateForGlobalScope(): string;
14
+ generateForGlobalScopeWithAllScopesValidation(): string;
14
15
  generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope): string;
15
16
  generateForLabel(label: string): string;
17
+ private generateForGlobalScopeInternal;
16
18
  private generateNewDictionaryName;
17
19
  private getInitialIdentifierNames;
18
20
  private getIncrementedIdentifierNames;
@@ -7,6 +7,9 @@ export declare class HexadecimalIdentifierNamesGenerator extends AbstractIdentif
7
7
  constructor(randomGenerator: IRandomGenerator, options: IOptions);
8
8
  generateNext(nameLength?: number): string;
9
9
  generateForGlobalScope(nameLength?: number): string;
10
+ generateForGlobalScopeWithAllScopesValidation(nameLength?: number): string;
10
11
  generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
11
12
  generateForLabel(label: string, nameLength?: number): string;
13
+ private generateForGlobalScopeInternal;
14
+ private generateNextName;
12
15
  }
@@ -15,6 +15,7 @@ export declare class MangledIdentifierNamesGenerator extends AbstractIdentifierN
15
15
  constructor(randomGenerator: IRandomGenerator, options: IOptions, setUtils: ISetUtils);
16
16
  generateNext(nameLength?: number): string;
17
17
  generateForGlobalScope(nameLength?: number): string;
18
+ generateForGlobalScopeWithAllScopesValidation(nameLength?: number): string;
18
19
  generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
19
20
  generateForLabel(label: string, nameLength?: number): string;
20
21
  isIncrementedMangledName(nextName: string, prevName: string): boolean;
@@ -23,6 +24,7 @@ export declare class MangledIdentifierNamesGenerator extends AbstractIdentifierN
23
24
  protected updatePreviousMangledName(name: string): void;
24
25
  protected updatePreviousMangledNameForLabel(name: string, label: string, lastMangledNameForLabel: string): void;
25
26
  protected generateNewMangledName(previousMangledName: string, validationFunction?: (newIdentifierName: string) => boolean): string;
27
+ private generateForGlobalScopeInternal;
26
28
  private getLastMangledNameForScopes;
27
29
  private getLastMangledNameForLabel;
28
30
  }
@@ -7,6 +7,8 @@ export interface IIdentifierNamesGenerator {
7
7
  generateNext(nameLength?: number): string;
8
8
  isValidIdentifierName(identifierName: string): boolean;
9
9
  isValidIdentifierNameInLexicalScopes(identifierName: string, lexicalScopeNodes: TNodeWithLexicalScope[]): boolean;
10
+ isValidIdentifierNameInAllScopes(identifierName: string): boolean;
11
+ generateForGlobalScopeWithAllScopesValidation(nameLength?: number): string;
10
12
  preserveName(identifierName: string): void;
11
13
  preserveNameForLexicalScope(identifierName: string, lexicalScope: TNodeWithLexicalScope): void;
12
14
  }
@@ -45,6 +45,7 @@ export declare class NodeGuards {
45
45
  static isLabeledStatementNode(node: ESTree.Node): node is ESTree.LabeledStatement;
46
46
  static isLiteralNode(node: ESTree.Node): node is ESTree.Literal;
47
47
  static isLogicalExpressionNode(node: ESTree.Node): node is ESTree.LogicalExpression;
48
+ static isLoopStatementNode(node: ESTree.Node): node is ESTree.ForStatement | ESTree.ForInStatement | ESTree.ForOfStatement | ESTree.WhileStatement | ESTree.DoWhileStatement;
48
49
  static isMemberExpressionNode(node: ESTree.Node): node is ESTree.MemberExpression;
49
50
  static isMetaPropertyNode(node: ESTree.Node): node is ESTree.MetaProperty;
50
51
  static isMethodDefinitionNode(node: ESTree.Node): node is ESTree.MethodDefinition;
@@ -10,4 +10,5 @@ export declare class LogicalExpressionControlFlowReplacer extends ExpressionWith
10
10
  constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
11
11
  replace(logicalExpressionNode: ESTree.LogicalExpression, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
12
12
  private checkForProhibitedExpressions;
13
+ private expressionContainsProhibitedNodes;
13
14
  }
@@ -5,7 +5,7 @@ import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
5
5
  import { NodeTransformationStage } from '../../enums/node-transformers/NodeTransformationStage';
6
6
  import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
7
7
  export declare class ClassFieldTransformer extends AbstractNodeTransformer {
8
- private static readonly ignoredNames;
8
+ private static readonly ignoredName;
9
9
  constructor(randomGenerator: IRandomGenerator, options: IOptions);
10
10
  getVisitor(nodeTransformationStage: NodeTransformationStage): IVisitor | null;
11
11
  transformNode(classFieldNode: ESTree.MethodDefinition | ESTree.PropertyDefinition, parentNode: ESTree.Node): ESTree.Node;
@@ -10,11 +10,10 @@ export declare class ObjectExpressionKeysTransformer extends AbstractNodeTransfo
10
10
  private static readonly objectExpressionExtractorNames;
11
11
  private readonly objectExpressionExtractorFactory;
12
12
  constructor(objectExpressionExtractorFactory: TObjectExpressionExtractorFactory, randomGenerator: IRandomGenerator, options: IOptions);
13
+ private static checkProhibitedPatterns;
13
14
  private static isProhibitedObjectExpressionNode;
14
- private static getReferencedIdentifierName;
15
- private static isReferencedIdentifierName;
15
+ private static isProhibitedLoopBody;
16
16
  private static isProhibitedArrowFunctionExpression;
17
- private static isObjectExpressionWithCallExpression;
18
17
  private static isProhibitedSequenceExpression;
19
18
  getVisitor(nodeTransformationStage: NodeTransformationStage): IVisitor | null;
20
19
  transformNode(objectExpressionNode: ESTree.ObjectExpression, parentNode: ESTree.Node): ESTree.Node;
@@ -0,0 +1,8 @@
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 ProcessEnvObfuscationGuard implements IObfuscatingGuard {
5
+ private static isProcessEnvMemberExpression;
6
+ private static isPartOfProcessEnvChain;
7
+ check(node: ESTree.Node): ObfuscatingGuardResult;
8
+ }
@@ -2,6 +2,7 @@ import { IEscapeSequenceEncoder } from '../interfaces/utils/IEscapeSequenceEncod
2
2
  export declare class EscapeSequenceEncoder implements IEscapeSequenceEncoder {
3
3
  private static readonly ASCIICharactersRegExp;
4
4
  private static readonly forceEscapeCharactersRegExp;
5
+ private static readonly replaceRegExp;
5
6
  private readonly stringsCache;
6
7
  encode(string: string, encodeAllSymbols: boolean): string;
7
8
  }
@@ -1,45 +0,0 @@
1
- /*!
2
- * Determine if an object is a Buffer
3
- *
4
- * @author Feross Aboukhadijeh <https://feross.org>
5
- * @license MIT
6
- */
7
-
8
- /*!
9
- Copyright (C) 2016-2024 Timofey Kachalov <sanex3339@yandex.ru>
10
-
11
- Redistribution and use in source and binary forms, with or without
12
- modification, are permitted provided that the following conditions are met:
13
-
14
- * Redistributions of source code must retain the above copyright
15
- notice, this list of conditions and the following disclaimer.
16
- * Redistributions in binary form must reproduce the above copyright
17
- notice, this list of conditions and the following disclaimer in the
18
- documentation and/or other materials provided with the distribution.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
24
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- */
31
-
32
- /*! *****************************************************************************
33
- Copyright (C) Microsoft. All rights reserved.
34
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
35
- this file except in compliance with the License. You may obtain a copy of the
36
- License at http://www.apache.org/licenses/LICENSE-2.0
37
-
38
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
39
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
40
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
41
- MERCHANTABLITY OR NON-INFRINGEMENT.
42
-
43
- See the Apache Version 2.0 License for specific language governing permissions
44
- and limitations under the License.
45
- ***************************************************************************** */
@@ -1,23 +0,0 @@
1
- /*!
2
- Copyright (C) 2016-2024 Timofey Kachalov <sanex3339@yandex.ru>
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright
8
- notice, this list of conditions and the following disclaimer.
9
- * Redistributions in binary form must reproduce the above copyright
10
- notice, this list of conditions and the following disclaimer in the
11
- documentation and/or other materials provided with the distribution.
12
-
13
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
- */
@@ -1,23 +0,0 @@
1
- /*!
2
- Copyright (C) 2016-2024 Timofey Kachalov <sanex3339@yandex.ru>
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright
8
- notice, this list of conditions and the following disclaimer.
9
- * Redistributions in binary form must reproduce the above copyright
10
- notice, this list of conditions and the following disclaimer in the
11
- documentation and/or other materials provided with the distribution.
12
-
13
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
- */