javascript-obfuscator 4.2.0 → 5.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-obfuscator",
3
- "version": "4.2.0",
3
+ "version": "5.0.0",
4
4
  "description": "JavaScript obfuscator",
5
5
  "keywords": [
6
6
  "obfuscator",
@@ -36,7 +36,7 @@
36
36
  "js-string-escape": "1.0.1",
37
37
  "md5": "2.3.0",
38
38
  "mkdirp": "3.0.1",
39
- "multimatch": "7.0.0",
39
+ "multimatch": "5.0.0",
40
40
  "opencollective-postinstall": "2.0.3",
41
41
  "process": "0.11.10",
42
42
  "reflect-metadata": "0.2.2",
@@ -71,10 +71,12 @@
71
71
  "chai-exclude": "3.0.1",
72
72
  "cross-env": "10.1.0",
73
73
  "eslint": "8.57.1",
74
+ "eslint-config-prettier": "10.1.8",
74
75
  "eslint-plugin-import": "2.32.0",
75
76
  "eslint-plugin-jsdoc": "50.6.3",
76
77
  "eslint-plugin-no-null": "1.0.2",
77
78
  "eslint-plugin-prefer-arrow": "1.2.3",
79
+ "eslint-plugin-prettier": "5.5.4",
78
80
  "eslint-plugin-unicorn": "56.0.1",
79
81
  "eslint-webpack-plugin": "4.2.0",
80
82
  "fork-ts-checker-notifier-webpack-plugin": "9.0.0",
@@ -84,6 +86,7 @@
84
86
  "mocha": "11.7.4",
85
87
  "nyc": "17.1.0",
86
88
  "pjson": "1.0.9",
89
+ "prettier": "3.6.2",
87
90
  "rimraf": "6.0.1",
88
91
  "sinon": "19.0.2",
89
92
  "source-map-resolve": "0.6.0",
@@ -104,7 +107,7 @@
104
107
  "scripts": {
105
108
  "start": "yarn run watch",
106
109
  "webpack:prod": "webpack --config ./webpack/webpack.node.config.js --config ./webpack/webpack.browser.config.js --mode production",
107
- "build": "yarn run webpack:prod && yarn run eslint && yarn test",
110
+ "build": "yarn run webpack:prod && yarn run eslint",
108
111
  "build:typings": "rm -rf ./typings && tsc --project src/tsconfig.typings.json",
109
112
  "watch": "webpack --config ./webpack/webpack.node.config.js --mode development --watch",
110
113
  "test:dev": "ts-node --type-check test/dev/dev.ts",
@@ -117,10 +120,13 @@
117
120
  "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
121
  "test": "yarn run test:full",
119
122
  "eslint": "eslint src/**/*.ts",
123
+ "prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
124
+ "prettier:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
125
+ "format": "yarn run prettier && yarn run eslint --fix",
120
126
  "git:addFiles": "git add .",
121
127
  "postinstall": "opencollective-postinstall",
122
- "precommit": "npm run build",
123
- "prepublishOnly": "npm run build && npm run build:typings",
128
+ "precommit": "yarn run eslint",
129
+ "prepublishOnly": "yarn run build && yarn run build:typings",
124
130
  "prepare": "husky install"
125
131
  },
126
132
  "author": {
@@ -137,5 +143,6 @@
137
143
  },
138
144
  "collective": {
139
145
  "url": "https://opencollective.com/javascript-obfuscator"
140
- }
146
+ },
147
+ "packageManager": "yarn@1.22.21+sha512.ca75da26c00327d26267ce33536e5790f18ebd53266796fbb664d2a4a5116308042dd8ee7003b276a20eace7d3c5561c3577bdd71bcb67071187af124779620a"
141
148
  }
@@ -3,10 +3,17 @@ import { TInputOptions } from './src/types/options/TInputOptions';
3
3
  import { TObfuscationResultsObject } from './src/types/TObfuscationResultsObject';
4
4
  import { TOptionsPreset } from './src/types/options/TOptionsPreset';
5
5
  import { IObfuscationResult } from './src/interfaces/source-code/IObfuscationResult';
6
+ import { IProApiConfig, IProObfuscationResult, TProApiProgressCallback } from './src/interfaces/pro-api/IProApiClient';
7
+ import { ApiError } from './src/JavaScriptObfuscatorFacade';
6
8
  export type ObfuscatorOptions = TInputOptions;
7
9
  export interface ObfuscationResult extends IObfuscationResult {
8
10
  }
11
+ export interface ProObfuscationResult extends IProObfuscationResult {
12
+ }
13
+ export type { IProApiConfig, TProApiProgressCallback };
14
+ export { ApiError };
9
15
  export declare function obfuscate(sourceCode: string, inputOptions?: ObfuscatorOptions): ObfuscationResult;
10
16
  export declare function obfuscateMultiple<TSourceCodesObject extends TDictionary<string>>(sourceCodesObject: TSourceCodesObject, inputOptions?: TInputOptions): TObfuscationResultsObject<TSourceCodesObject>;
17
+ export declare function obfuscatePro(sourceCode: string, inputOptions: ObfuscatorOptions, proApiConfig: IProApiConfig, onProgress?: TProApiProgressCallback): Promise<ProObfuscationResult>;
11
18
  export declare function getOptionsByPreset(optionsPreset: TOptionsPreset): TInputOptions;
12
19
  export declare const version: string;
@@ -4,10 +4,14 @@ import { TInputOptions } from './types/options/TInputOptions';
4
4
  import { TObfuscationResultsObject } from './types/TObfuscationResultsObject';
5
5
  import { TOptionsPreset } from './types/options/TOptionsPreset';
6
6
  import { IObfuscationResult } from './interfaces/source-code/IObfuscationResult';
7
+ import { IProApiConfig, IProObfuscationResult, TProApiProgressCallback } from './interfaces/pro-api/IProApiClient';
7
8
  declare class JavaScriptObfuscatorFacade {
8
9
  static version: string;
9
10
  static obfuscate(sourceCode: string, inputOptions?: TInputOptions): IObfuscationResult;
10
11
  static obfuscateMultiple<TSourceCodesObject extends TDictionary<string>>(sourceCodesObject: TSourceCodesObject, inputOptions?: TInputOptions): TObfuscationResultsObject<TSourceCodesObject>;
11
12
  static getOptionsByPreset(optionsPreset: TOptionsPreset): TInputOptions;
13
+ static obfuscatePro(sourceCode: string, inputOptions: TInputOptions, proApiConfig: IProApiConfig, onProgress?: TProApiProgressCallback): Promise<IProObfuscationResult>;
12
14
  }
13
15
  export { JavaScriptObfuscatorFacade as JavaScriptObfuscator };
16
+ export { ApiError } from './pro-api/ApiError';
17
+ export type { IProApiConfig, TProApiProgressCallback } from './interfaces/pro-api/IProApiClient';
@@ -0,0 +1,22 @@
1
+ import { TIdentifierNamesCache } from '../../types/TIdentifierNamesCache';
2
+ export interface IProObfuscationResult {
3
+ getIdentifierNamesCache(): TIdentifierNamesCache;
4
+ getObfuscatedCode(): string;
5
+ getSourceMap(): string;
6
+ toString(): string;
7
+ }
8
+ export interface IProApiConfig {
9
+ apiToken: string;
10
+ timeout?: number;
11
+ }
12
+ export type TProApiProgressCallback = (message: string) => void;
13
+ export interface IProApiStreamMessage {
14
+ type: 'progress' | 'result' | 'chunk' | 'chunk_end' | 'error';
15
+ message?: string;
16
+ code?: string;
17
+ sourceMap?: string;
18
+ field?: 'code' | 'sourceMap';
19
+ data?: string;
20
+ index?: number;
21
+ total?: number;
22
+ }
@@ -0,0 +1,5 @@
1
+ export declare class ApiError extends Error {
2
+ readonly statusCode: number;
3
+ readonly response?: string;
4
+ constructor(message: string, statusCode: number, response?: string);
5
+ }
@@ -0,0 +1,9 @@
1
+ import { TInputOptions } from '../types/options/TInputOptions';
2
+ import { IProApiConfig, IProObfuscationResult, TProApiProgressCallback } from '../interfaces/pro-api/IProApiClient';
3
+ export declare class ProApiClient {
4
+ private readonly config;
5
+ constructor(config: IProApiConfig);
6
+ obfuscate(sourceCode: string, options?: TInputOptions, onProgress?: TProApiProgressCallback): Promise<IProObfuscationResult>;
7
+ private handleStreamingResponse;
8
+ private reassembleChunkedResponse;
9
+ }
@@ -0,0 +1,11 @@
1
+ import { TIdentifierNamesCache } from '../types/TIdentifierNamesCache';
2
+ import { IProObfuscationResult } from '../interfaces/pro-api/IProApiClient';
3
+ export declare class ProApiObfuscationResult implements IProObfuscationResult {
4
+ private readonly obfuscatedCode;
5
+ private readonly sourceMapValue;
6
+ constructor(code: string, sourceMap?: string);
7
+ getObfuscatedCode(): string;
8
+ getSourceMap(): string;
9
+ getIdentifierNamesCache(): TIdentifierNamesCache;
10
+ toString(): string;
11
+ }
@@ -1,7 +1,7 @@
1
1
  import * as ESTree from 'estree';
2
- export type TNodeWithSingleStatementBody = (ESTree.LabeledStatement | ESTree.WithStatement | ESTree.WhileStatement | ESTree.DoWhileStatement | ESTree.ForStatement | ESTree.ForInStatement | ESTree.ForOfStatement & {
2
+ export type TNodeWithSingleStatementBody = (ESTree.LabeledStatement | ESTree.WithStatement | ESTree.WhileStatement | ESTree.DoWhileStatement | ESTree.ForStatement | ESTree.ForInStatement | (ESTree.ForOfStatement & {
3
3
  body: Exclude<ESTree.Statement, ESTree.BlockStatement>;
4
- }) | (ESTree.IfStatement & {
4
+ })) | (ESTree.IfStatement & {
5
5
  consequent: Exclude<ESTree.Statement, ESTree.BlockStatement>;
6
6
  alternate?: Exclude<ESTree.Statement, ESTree.BlockStatement> | null;
7
7
  });
@@ -1 +1 @@
1
- export type TTypeFromEnum<T extends object> = (T)[keyof T];
1
+ export type TTypeFromEnum<T extends object> = T[keyof T];