javascript-obfuscator 5.3.0 → 5.4.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/CHANGELOG.md +17 -0
- package/README.md +2 -87
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cli.js +1 -1
- package/dist/index.cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts +2 -0
- package/typings/src/interfaces/node-transformers/rename-properties-transformers/replacer/IRenamePropertiesReplacer.d.ts +1 -1
- package/typings/src/node/NodeFactory.d.ts +1 -0
- package/typings/src/node/NodeMetadata.d.ts +1 -1
- package/typings/src/node-transformers/converting-transformers/ClassFieldTransformer.d.ts +1 -0
- package/typings/src/node-transformers/converting-transformers/ObjectPatternPropertiesTransformer.d.ts +1 -0
- package/typings/src/node-transformers/rename-identifiers-transformers/replacer/IdentifierReplacer.d.ts +1 -1
- package/typings/src/node-transformers/rename-properties-transformers/replacer/RenamePropertiesReplacer.d.ts +1 -1
- package/typings/src/utils/AdvertisementUtils.d.ts +5 -9
- package/typings/src/utils/Utils.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
Change Log
|
|
2
2
|
|
|
3
|
+
v5.4.0
|
|
4
|
+
---
|
|
5
|
+
* Add support for `import attributes`. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1256
|
|
6
|
+
* Add `renameProperties` support for private class fields and methods (`#foo`, `#bar()`). Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1220
|
|
7
|
+
* Fixed `reservedNames` not preserving class method and property names when `stringArray` or `deadCodeInjection` is enabled. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1279
|
|
8
|
+
* Fixed infinite loop / stack overflow when `reservedNames` patterns match all generated identifier names. Now throws a descriptive error instead. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1382
|
|
9
|
+
* Fixed `transformObjectKeys` changing evaluation order when object expression is inside a sequence expression with preceding side effects (e.g. `return aux(ys), { min }`). Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1246
|
|
10
|
+
* Fixed destructuring patterns inside class static blocks not being renamed when `renameGlobals` is disabled. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1141
|
|
11
|
+
* Fixed CLI `--options-preset` not applying preset values for options not explicitly set via command line (e.g. `splitStrings` from `high-obfuscation` preset was ignored). Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1236
|
|
12
|
+
* Replaced `mkdirp` dependency with native `fs.mkdirSync({ recursive: true })`. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1275. Thank you https://github.com/roli-lpci!
|
|
13
|
+
* Updated reserved DOM properties list, fixing `renameProperties` breaking modern built-in methods like `Array.prototype.at()`. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1066
|
|
14
|
+
* Replaced `conf` dependency with custom implementation using `env-paths` and native `fs`
|
|
15
|
+
|
|
16
|
+
v5.3.1
|
|
17
|
+
---
|
|
18
|
+
* Fixed class expression name references inside class body being incorrectly resolved to an import binding with the same name, causing broken code at runtime. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1386
|
|
19
|
+
|
|
3
20
|
v5.3.0
|
|
4
21
|
---
|
|
5
22
|
* Add Pro API support to CLI
|
package/README.md
CHANGED
|
@@ -302,7 +302,6 @@ const result = await JavaScriptObfuscator.obfuscatePro(
|
|
|
302
302
|
`function hello() { console.log("Hello World"); }`,
|
|
303
303
|
{
|
|
304
304
|
vmObfuscation: true, // Required!
|
|
305
|
-
vmObfuscationThreshold: 1,
|
|
306
305
|
compact: true
|
|
307
306
|
},
|
|
308
307
|
{
|
|
@@ -338,8 +337,7 @@ You can specify which obfuscator version to use via the `version` option:
|
|
|
338
337
|
const result = await JavaScriptObfuscator.obfuscatePro(
|
|
339
338
|
sourceCode,
|
|
340
339
|
{
|
|
341
|
-
vmObfuscation: true
|
|
342
|
-
vmObfuscationThreshold: 1
|
|
340
|
+
vmObfuscation: true
|
|
343
341
|
},
|
|
344
342
|
{
|
|
345
343
|
apiToken: 'your_javascript_obfuscator_pro_api_token',
|
|
@@ -356,8 +354,7 @@ The API uses streaming mode to provide real-time progress updates during obfusca
|
|
|
356
354
|
const result = await JavaScriptObfuscator.obfuscatePro(
|
|
357
355
|
sourceCode,
|
|
358
356
|
{
|
|
359
|
-
vmObfuscation: true
|
|
360
|
-
vmObfuscationThreshold: 1
|
|
357
|
+
vmObfuscation: true
|
|
361
358
|
},
|
|
362
359
|
{
|
|
363
360
|
apiToken: 'your_javascript_obfuscator_pro_api_token'
|
|
@@ -1865,20 +1862,6 @@ Enables VM-based bytecode obfuscation. When enabled, JavaScript functions are co
|
|
|
1865
1862
|
**Example:**
|
|
1866
1863
|
Your readable code like `return qty * price` becomes a list of numbers like `[0x15,0x03,0x17,...]` that only the embedded VM interpreter can execute. The original logic is no longer visible as JavaScript.
|
|
1867
1864
|
|
|
1868
|
-
### `vmObfuscationThreshold`
|
|
1869
|
-
Type: `number` Default: `1`
|
|
1870
|
-
|
|
1871
|
-
Controls what percentage of your root-level functions get VM protection.
|
|
1872
|
-
|
|
1873
|
-
> **Warning:** Values other than `1` may cause runtime bugs when VM-obfuscated and non-VM-obfuscated code share top-level variables. A value of `1` is strongly recommended. For selective function obfuscation, use `vmTargetFunctionsMode: 'comment'` with the `// javascript-obfuscator:vm` directive instead.
|
|
1874
|
-
|
|
1875
|
-
### `vmPreprocessIdentifiers`
|
|
1876
|
-
Type: `boolean` Default: `true`
|
|
1877
|
-
|
|
1878
|
-
Renames all non-global identifiers to unique hexadecimal names before VM obfuscation. This eliminates variable shadowing that can cause scope resolution issues in the VM bytecode.
|
|
1879
|
-
|
|
1880
|
-
**When to disable:** Only disable this if you encounter specific compatibility issues. The preprocessing step ensures correct variable resolution in complex nested scopes.
|
|
1881
|
-
|
|
1882
1865
|
### `vmTargetFunctions`
|
|
1883
1866
|
Type: `string[]` Default: `[]`
|
|
1884
1867
|
|
|
@@ -1987,11 +1970,6 @@ Makes the VM interpreter smaller and unique for each build.
|
|
|
1987
1970
|
|
|
1988
1971
|
As the result - smaller output and each build looks different.
|
|
1989
1972
|
|
|
1990
|
-
### `vmOpcodeShuffle`
|
|
1991
|
-
Type: `boolean` Default: `false`
|
|
1992
|
-
|
|
1993
|
-
Randomizes the numeric values assigned to each opcode. For example, the `LOAD` instruction might be `1` in one build and `47` in another.
|
|
1994
|
-
|
|
1995
1973
|
### `vmBytecodeEncoding`
|
|
1996
1974
|
Type: `boolean` Default: `false`
|
|
1997
1975
|
|
|
@@ -2067,39 +2045,6 @@ Type: `boolean` Default: `false`
|
|
|
2067
2045
|
|
|
2068
2046
|
Injects fake bytecode sequences that are never executed. These look like real instructions but are skipped during runtime, confusing analysis tools that process them.
|
|
2069
2047
|
|
|
2070
|
-
### `vmSplitDispatcher`
|
|
2071
|
-
Type: `boolean` Default: `false`
|
|
2072
|
-
|
|
2073
|
-
Splits the VM dispatcher into multiple smaller switch statements organized by opcode category, instead of one large monolithic switch. Each category (stack, arithmetic, control flow, etc.) gets its own switch, routed by if/else range checks.
|
|
2074
|
-
|
|
2075
|
-
This option supports `vmDynamicOpcodes` in both modes: `true` (shuffle first, then split into groups) and `false`.
|
|
2076
|
-
|
|
2077
|
-
> :warning: When `vmIndirectDispatch` is enabled, this option is ignored. Prefer `vmIndirectDispatch` as it provides better obfuscation with similar performance.
|
|
2078
|
-
|
|
2079
|
-
### `vmIndirectDispatch`
|
|
2080
|
-
Type: `boolean` Default: `false`
|
|
2081
|
-
|
|
2082
|
-
Uses compile-time generated handler functions for opcode dispatch instead of switch statements. Handlers are generated at compile-time with inlined opcode logic and shuffled positions.
|
|
2083
|
-
|
|
2084
|
-
Instead of:
|
|
2085
|
-
```javascript
|
|
2086
|
-
switch(op) {
|
|
2087
|
-
case 0: /* handle opcode 0 */ break;
|
|
2088
|
-
case 1: /* handle opcode 1 */ break;
|
|
2089
|
-
}
|
|
2090
|
-
```
|
|
2091
|
-
|
|
2092
|
-
It generates:
|
|
2093
|
-
```javascript
|
|
2094
|
-
var _hm = {0:42, 1:17, ...}; // opcode → handler index mapping
|
|
2095
|
-
var _h = [handler0, handler1, ...]; // shuffled handler array
|
|
2096
|
-
_h[_hm[op]](arg); // single lookup + function call
|
|
2097
|
-
```
|
|
2098
|
-
|
|
2099
|
-
This option supports `vmDynamicOpcodes` in both modes.
|
|
2100
|
-
|
|
2101
|
-
> :warning: When enabled, this takes priority over `vmSplitDispatcher`. Both options cannot be active simultaneously.
|
|
2102
|
-
|
|
2103
2048
|
### `vmCompactDispatcher`
|
|
2104
2049
|
Type: `boolean` Default: `false`
|
|
2105
2050
|
|
|
@@ -2121,11 +2066,6 @@ Type: `boolean` Default: `false`
|
|
|
2121
2066
|
|
|
2122
2067
|
Adds anti-debugging measures to the VM runtime. Detects debugger presence and alters behavior when debugging is detected.
|
|
2123
2068
|
|
|
2124
|
-
### `vmRuntimeOpcodeDerivation`
|
|
2125
|
-
Type: `boolean` Default: `false`
|
|
2126
|
-
|
|
2127
|
-
Derives the opcode mapping table at runtime from a seed value instead of hardcoding it. The seed is stored in the bytecode and used to generate the opcode-to-handler mapping via Fisher-Yates shuffle during execution.
|
|
2128
|
-
|
|
2129
2069
|
### `vmStatefulOpcodes`
|
|
2130
2070
|
Type: `boolean` Default: `false`
|
|
2131
2071
|
|
|
@@ -2138,31 +2078,6 @@ Encrypts values on the VM stack during execution. Values are encoded when pushed
|
|
|
2138
2078
|
|
|
2139
2079
|
This option heavily affects performance.
|
|
2140
2080
|
|
|
2141
|
-
### `vmInstructionShuffle`
|
|
2142
|
-
Type: `boolean` Default: `false`
|
|
2143
|
-
|
|
2144
|
-
Randomizes the bytecode instruction layout per function. Each function can have a different instruction array format:
|
|
2145
|
-
- Layout 0: `[op, arg, op, arg, ...]` (interleaved - default)
|
|
2146
|
-
- Layout 1: `[arg, op, arg, op, ...]` (swapped interleaved)
|
|
2147
|
-
- Layout 2: `[op0, op1, ..., arg0, arg1, ...]` (opcodes first, then arguments)
|
|
2148
|
-
- Layout 3: `[arg0, arg1, ..., op0, op1, ...]` (arguments first, then opcodes)
|
|
2149
|
-
|
|
2150
|
-
This makes pattern recognition across functions harder during analysis.
|
|
2151
|
-
|
|
2152
|
-
### `vmRandomizeKeys`
|
|
2153
|
-
Type: `boolean` Default: `false`
|
|
2154
|
-
|
|
2155
|
-
Randomizes the property key names used in bytecode objects. Standard keys like `i` (instructions), `c` (constants) become random 2-character identifiers, making the bytecode structure different for each build.
|
|
2156
|
-
|
|
2157
|
-
### `vmBytecodeFormat`
|
|
2158
|
-
Type: `string` Default: `binary`
|
|
2159
|
-
|
|
2160
|
-
Controls how bytecode is stored in the output.
|
|
2161
|
-
|
|
2162
|
-
**Options:**
|
|
2163
|
-
- `binary` - Compact binary format. Smaller size, recommended for production.
|
|
2164
|
-
- `json` - Human-readable JSON format. Larger size, useful for debugging.
|
|
2165
|
-
|
|
2166
2081
|
### `strictMode`
|
|
2167
2082
|
Type: `boolean | null` Default: `null`
|
|
2168
2083
|
|