javascript-obfuscator 5.2.0 → 5.3.0-beta.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.
Files changed (26) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +213 -9
  3. package/bin/javascript-obfuscator +4 -1
  4. package/dist/index.browser.js +10 -3
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.cli.js +1 -1
  7. package/dist/index.cli.js.map +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/package.json +2 -1
  11. package/typings/src/JavaScriptObfuscatorCLIFacade.d.ts +1 -1
  12. package/typings/src/JavaScriptObfuscatorFacade.d.ts +1 -1
  13. package/typings/src/cli/JavaScriptObfuscatorCLI.d.ts +2 -1
  14. package/typings/src/cli/sanitizers/StrictModeSanitizer.d.ts +2 -0
  15. package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts +3 -0
  16. package/typings/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.d.ts +2 -0
  17. package/typings/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.d.ts +3 -0
  18. package/typings/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.d.ts +2 -0
  19. package/typings/src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts +2 -0
  20. package/typings/src/interfaces/options/ICLIOptions.d.ts +2 -0
  21. package/typings/src/interfaces/pro-api/IProApiClient.d.ts +4 -0
  22. package/typings/src/node/NodeGuards.d.ts +1 -0
  23. package/typings/src/node-transformers/converting-transformers/ObjectExpressionKeysTransformer.d.ts +1 -0
  24. package/typings/src/pro-api/ProApiClient.d.ts +11 -0
  25. package/typings/src/pro-api/enums/VMBytecodeFormat.d.ts +4 -0
  26. package/typings/src/pro-api/enums/VMTargetFunctionsMode.d.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-obfuscator",
3
- "version": "5.2.0",
3
+ "version": "5.3.0-beta.0",
4
4
  "description": "JavaScript obfuscator",
5
5
  "keywords": [
6
6
  "obfuscator",
@@ -23,6 +23,7 @@
23
23
  "dependencies": {
24
24
  "@javascript-obfuscator/escodegen": "2.3.1",
25
25
  "@javascript-obfuscator/estraverse": "5.4.0",
26
+ "@vercel/blob": ">=0.23.0",
26
27
  "acorn": "8.15.0",
27
28
  "assert": "2.1.0",
28
29
  "chalk": "4.1.2",
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
2
  declare class JavaScriptObfuscatorCLIFacade {
3
- static obfuscate(argv: string[]): void;
3
+ static obfuscate(argv: string[]): Promise<void>;
4
4
  }
5
5
  export { JavaScriptObfuscatorCLIFacade as JavaScriptObfuscatorCLI };
@@ -14,4 +14,4 @@ declare class JavaScriptObfuscatorFacade {
14
14
  }
15
15
  export { JavaScriptObfuscatorFacade as JavaScriptObfuscator };
16
16
  export { ApiError } from './pro-api/ApiError';
17
- export type { IProApiConfig, TProApiProgressCallback } from './interfaces/pro-api/IProApiClient';
17
+ export type { IProApiConfig, IProObfuscationResult, TProApiProgressCallback } from './interfaces/pro-api/IProApiClient';
@@ -15,11 +15,12 @@ export declare class JavaScriptObfuscatorCLI implements IInitializable {
15
15
  private static buildOptions;
16
16
  private static filterOptions;
17
17
  initialize(): void;
18
- run(): void;
18
+ run(): Promise<void>;
19
19
  private configureCommands;
20
20
  private configureHelp;
21
21
  private processSourceCodeData;
22
22
  private processSourceCode;
23
+ private processSourceCodeWithProApi;
23
24
  private processSourceCodeWithoutSourceMap;
24
25
  private processSourceCodeWithSourceMap;
25
26
  }
@@ -0,0 +1,2 @@
1
+ import { TCLISanitizer } from '../../types/cli/TCLISanitizer';
2
+ export declare const StrictModeSanitizer: TCLISanitizer<boolean | null>;
@@ -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
  }
@@ -4,5 +4,7 @@ export interface ICLIOptions extends IOptions {
4
4
  readonly exclude: string[];
5
5
  readonly identifierNamesCachePath: string;
6
6
  readonly output: string;
7
+ readonly proApiToken: string;
8
+ readonly proApiVersion: string;
7
9
  readonly version: string;
8
10
  }
@@ -21,3 +21,7 @@ export interface IProApiStreamMessage {
21
21
  index?: number;
22
22
  total?: number;
23
23
  }
24
+ export interface IProApiBlobUploadResponse {
25
+ blobUrl?: string;
26
+ error?: string;
27
+ }
@@ -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;
@@ -12,6 +12,7 @@ export declare class ObjectExpressionKeysTransformer extends AbstractNodeTransfo
12
12
  constructor(objectExpressionExtractorFactory: TObjectExpressionExtractorFactory, randomGenerator: IRandomGenerator, options: IOptions);
13
13
  private static checkProhibitedPatterns;
14
14
  private static isProhibitedObjectExpressionNode;
15
+ private static isProhibitedLoopBody;
15
16
  private static isProhibitedArrowFunctionExpression;
16
17
  private static isProhibitedSequenceExpression;
17
18
  getVisitor(nodeTransformationStage: NodeTransformationStage): IVisitor | null;
@@ -1,9 +1,20 @@
1
1
  import { TInputOptions } from '../types/options/TInputOptions';
2
2
  import { IProApiConfig, IProObfuscationResult, TProApiProgressCallback } from '../interfaces/pro-api/IProApiClient';
3
3
  export declare class ProApiClient {
4
+ private static readonly apiHost;
5
+ private static readonly apiUrl;
6
+ private static readonly uploadTokenUrl;
7
+ private static readonly defaultTimeout;
8
+ private static readonly blobUploadThreshold;
4
9
  private readonly config;
5
10
  constructor(config: IProApiConfig);
11
+ static hasProFeatures(options: TInputOptions): boolean;
6
12
  obfuscate(sourceCode: string, options?: TInputOptions, onProgress?: TProApiProgressCallback): Promise<IProObfuscationResult>;
13
+ private obfuscateDirect;
14
+ private obfuscateWithBlobUpload;
15
+ private uploadToBlob;
16
+ private getUploadToken;
17
+ private uploadWithClientToken;
7
18
  private handleStreamingResponse;
8
19
  private reassembleChunkedResponse;
9
20
  }
@@ -0,0 +1,4 @@
1
+ export declare const VMBytecodeFormat: Readonly<{
2
+ Json: 'json';
3
+ Binary: 'binary';
4
+ }>;
@@ -0,0 +1,4 @@
1
+ export declare const VMTargetFunctionsMode: Readonly<{
2
+ Root: 'root';
3
+ Comment: 'comment';
4
+ }>;