javascript-obfuscator 2.19.1 → 3.2.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 (65) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +58 -33
  3. package/dist/index.browser.js +1 -1
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.cli.js +1 -1
  6. package/dist/index.cli.js.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/package.json +35 -33
  10. package/typings/src/code-transformers/AbstractCodeTransformer.d.ts +1 -1
  11. package/typings/src/container/InversifyContainerFacade.d.ts +2 -1
  12. package/typings/src/container/ServiceIdentifiers.d.ts +2 -1
  13. package/typings/src/custom-code-helpers/AbstractCustomCodeHelper.d.ts +1 -1
  14. package/typings/src/custom-nodes/AbstractCustomNode.d.ts +1 -1
  15. package/typings/src/custom-nodes/control-flow-flattening-nodes/{StringLiteralNode.d.ts → LiteralNode.d.ts} +4 -3
  16. package/typings/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.d.ts +2 -2
  17. package/typings/src/custom-nodes/string-array-nodes/AbstractStringArrayCallNode.d.ts +1 -1
  18. package/typings/src/custom-nodes/string-array-nodes/string-array-index-nodes/AbstractStringArrayIndexNode.d.ts +1 -1
  19. package/typings/src/enums/custom-nodes/ControlFlowCustomNode.d.ts +2 -2
  20. package/typings/src/enums/node/NodeType.d.ts +2 -0
  21. package/typings/src/enums/node-transformers/NodeTransformer.d.ts +1 -0
  22. package/typings/src/enums/node-transformers/control-flow-transformers/control-flow-replacers/ControlFlowReplacer.d.ts +1 -0
  23. package/typings/src/enums/node-transformers/preparing-transformers/obfuscating-guards/ObfuscatingGuard.d.ts +1 -1
  24. package/typings/src/enums/storages/ControlFlowStorage.d.ts +4 -0
  25. package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts +2 -1
  26. package/typings/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.d.ts +1 -0
  27. package/typings/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.d.ts +1 -0
  28. package/typings/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.d.ts +9 -2
  29. package/typings/src/generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator.d.ts +2 -2
  30. package/typings/src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts +1 -0
  31. package/typings/src/interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer.d.ts +3 -2
  32. package/typings/src/interfaces/options/IOptions.d.ts +5 -3
  33. package/typings/src/interfaces/storages/IWeakMapStorage.d.ts +9 -0
  34. package/typings/src/interfaces/storages/control-flow-transformers/IControlFlowStorage.d.ts +4 -0
  35. package/typings/src/interfaces/storages/string-array-transformers/IStringArrayScopeCallsWrappersDataStorage.d.ts +2 -2
  36. package/typings/src/interfaces/utils/ISetUtils.d.ts +3 -0
  37. package/typings/src/node/NodeFactory.d.ts +1 -0
  38. package/typings/src/node/NodeGuards.d.ts +2 -0
  39. package/typings/src/node/NodeLiteralUtils.d.ts +2 -0
  40. package/typings/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.d.ts +22 -13
  41. package/typings/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.d.ts +25 -0
  42. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.d.ts +8 -5
  43. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.d.ts +4 -3
  44. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.d.ts +4 -3
  45. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.d.ts +2 -1
  46. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.d.ts +4 -3
  47. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/StringArrayCallControlFlowReplacer.d.ts +14 -0
  48. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.d.ts +5 -4
  49. package/typings/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.d.ts +0 -2
  50. package/typings/src/node-transformers/preparing-transformers/obfuscating-guards/{IgnoredRequireImportObfuscatingGuard.d.ts → IgnoredImportObfuscatingGuard.d.ts} +3 -1
  51. package/typings/src/node-transformers/simplifying-transformers/AbstractStatementSimplifyTransformer.d.ts +1 -1
  52. package/typings/src/options/Options.d.ts +5 -3
  53. package/typings/src/options/normalizer-rules/StringArrayCallsTransformThresholdRule.d.ts +2 -0
  54. package/typings/src/storages/ArrayStorage.d.ts +1 -1
  55. package/typings/src/storages/WeakMapStorage.d.ts +17 -0
  56. package/typings/src/storages/control-flow-transformers/FunctionControlFlowStorage.d.ts +11 -0
  57. package/typings/src/storages/control-flow-transformers/StringControlFlowStorage.d.ts +8 -0
  58. package/typings/src/storages/string-array-transformers/StringArrayScopeCallsWrappersDataStorage.d.ts +2 -2
  59. package/typings/src/types/TConstructor.d.ts +1 -0
  60. package/typings/src/types/container/node-transformers/TControlFlowStorageFactory.d.ts +2 -2
  61. package/typings/src/types/container/node-transformers/TControlFlowStorageFactoryCreator.d.ts +3 -0
  62. package/typings/src/types/node/TNumberLiteralNode.d.ts +4 -0
  63. package/typings/src/utils/SetUtils.d.ts +7 -0
  64. package/typings/src/storages/custom-nodes/ControlFlowStorage.d.ts +0 -7
  65. package/typings/src/types/storages/TControlFlowStorage.d.ts +0 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  Change Log
2
2
 
3
+ v3.2.0
4
+ ---
5
+ * **New options**: `stringArrayCallsTransform` and `stringArrayCallsTransformThreshold`
6
+ * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/pull/1046
7
+
8
+ v3.1.0
9
+ ---
10
+ * Added support of `es2022` features: class static block
11
+
12
+ v3.0.1
13
+ ---
14
+ * Dependencies update
15
+ * Fixed performance for Apple M1 chip
16
+
17
+ v3.0.0
18
+ ---
19
+ * **Breaking change:** `ignoreRequireImports` option renamed to `ignoreImports`
20
+ * **Breaking change:** `rotateStringArray` option renamed to `stringArrayRotate`
21
+ * **Breaking change:** `shuffleStringArray` option renamed to `stringArrayShuffle`
22
+ * `ignoreImports` now ignores `dynamic` imports in addition to `require` imports
23
+
3
24
  v2.19.1
4
25
  ---
5
26
  * Updated `@javascript-obfuscator/escodegen` with fixed parenthesis of `default export` IIFE
package/README.md CHANGED
@@ -112,7 +112,7 @@ var obfuscationResult = JavaScriptObfuscator.obfuscate(
112
112
  controlFlowFlatteningThreshold: 1,
113
113
  numbersToExpressions: true,
114
114
  simplify: true,
115
- shuffleStringArray: true,
115
+ stringArrayShuffle: true,
116
116
  splitStrings: true,
117
117
  stringArrayThreshold: 1
118
118
  }
@@ -368,10 +368,8 @@ Following options are available for the JS Obfuscator:
368
368
  renamePropertiesMode: 'safe',
369
369
  reservedNames: [],
370
370
  reservedStrings: [],
371
- rotateStringArray: true,
372
371
  seed: 0,
373
372
  selfDefending: false,
374
- shuffleStringArray: true,
375
373
  simplify: true,
376
374
  sourceMap: false,
377
375
  sourceMapBaseUrl: '',
@@ -381,11 +379,15 @@ Following options are available for the JS Obfuscator:
381
379
  splitStrings: false,
382
380
  splitStringsChunkLength: 10,
383
381
  stringArray: true,
382
+ stringArrayCallsTransform: true,
383
+ stringArrayCallsTransformThreshold: 0.5,
384
+ stringArrayEncoding: [],
384
385
  stringArrayIndexesType: [
385
386
  'hexadecimal-number'
386
387
  ],
387
- stringArrayEncoding: [],
388
388
  stringArrayIndexShift: true,
389
+ stringArrayRotate: true,
390
+ stringArrayShuffle: true,
389
391
  stringArrayWrappersCount: 1,
390
392
  stringArrayWrappersChainedCalls: true,
391
393
  stringArrayWrappersParametersMaxCount: 2,
@@ -421,7 +423,7 @@ Following options are available for the JS Obfuscator:
421
423
  --identifier-names-generator <string> [dictionary, hexadecimal, mangled, mangled-shuffled]
422
424
  --identifiers-dictionary '<list>' (comma separated)
423
425
  --identifiers-prefix <string>
424
- --ignore-require-imports <boolean>
426
+ --ignore-imports <boolean>
425
427
  --log <boolean>
426
428
  --numbers-to-expressions <boolean>
427
429
  --options-preset <string> [default, low-obfuscation, medium-obfuscation, high-obfuscation]
@@ -430,10 +432,8 @@ Following options are available for the JS Obfuscator:
430
432
  --rename-properties-mode <string> [safe, unsafe]
431
433
  --reserved-names '<list>' (comma separated)
432
434
  --reserved-strings '<list>' (comma separated)
433
- --rotate-string-array <boolean>
434
435
  --seed <string|number>
435
436
  --self-defending <boolean>
436
- --shuffle-string-array <boolean>
437
437
  --simplify <boolean>
438
438
  --source-map <boolean>
439
439
  --source-map-base-url <string>
@@ -443,9 +443,13 @@ Following options are available for the JS Obfuscator:
443
443
  --split-strings <boolean>
444
444
  --split-strings-chunk-length <number>
445
445
  --string-array <boolean>
446
- --string-array-indexes-type '<list>' (comma separated) [hexadecimal-number, hexadecimal-numeric-string]
446
+ --string-array-calls-transform <boolean>
447
+ --string-array-calls-transform-threshold <number>
447
448
  --string-array-encoding '<list>' (comma separated) [none, base64, rc4]
449
+ --string-array-indexes-type '<list>' (comma separated) [hexadecimal-number, hexadecimal-numeric-string]
448
450
  --string-array-index-shift <boolean>
451
+ --string-array-rotate <boolean>
452
+ --string-array-shuffle <boolean>
449
453
  --string-array-wrappers-count <number>
450
454
  --string-array-wrappers-chained-calls <boolean>
451
455
  --string-array-wrappers-parameters-max-count <number>
@@ -968,13 +972,6 @@ Example:
968
972
  }
969
973
  ```
970
974
 
971
- ### `rotateStringArray`
972
- Type: `boolean` Default: `true`
973
-
974
- ##### :warning: [`stringArray`](#stringarray) must be enabled
975
-
976
- Shift the `stringArray` array by a fixed and random (generated at the code obfuscation) places. This makes it harder to match the order of the removed strings to their original place.
977
-
978
975
  ### `seed`
979
976
  Type: `string|number` Default: `0`
980
977
 
@@ -990,13 +987,6 @@ Type: `boolean` Default: `false`
990
987
 
991
988
  This option makes the output code resilient against formatting and variable renaming. If one tries to use a JavaScript beautifier on the obfuscated code, the code won't work anymore, making it harder to understand and modify it.
992
989
 
993
- ### `shuffleStringArray`
994
- Type: `boolean` Default: `true`
995
-
996
- ##### :warning: [`stringArray`](#stringarray) must be enabled
997
-
998
- Randomly shuffles the `stringArray` array items.
999
-
1000
990
  ### `simplify`
1001
991
  Type: `boolean` Default: `true`
1002
992
 
@@ -1111,6 +1101,20 @@ Type: `boolean` Default: `true`
1111
1101
 
1112
1102
  Removes string literals and place them in a special array. For instance, the string `"Hello World"` in `var m = "Hello World";` will be replaced with something like `var m = _0x12c456[0x1];`
1113
1103
 
1104
+ ### `stringArrayCallsTransform`
1105
+ Type: `boolean` Default: `true`
1106
+
1107
+ ##### :warning: [`stringArray`](#stringarray) option must be enabled
1108
+
1109
+ Enables the transformation of calls to the [`stringArray`](#stringarray). All arguments of these calls may be extracted to different object depending on [`stringArrayCallsTransformThreshold`](#stringarraycallstransformthreshold) value.
1110
+
1111
+ ### `stringArrayCallsTransformThreshold`
1112
+ Type: `number` Default: `0.5`
1113
+
1114
+ ##### :warning: [`stringArray`](#stringarray) and [`stringArrayCallsTransformThreshold`](#stringarraycallstransformthreshold) options must be enabled
1115
+
1116
+ You can use this setting to adjust the probability (from 0 to 1) that calls to the string array will be transformed.
1117
+
1114
1118
  ### `stringArrayEncoding`
1115
1119
  Type: `string[]` Default: `[]`
1116
1120
 
@@ -1163,6 +1167,20 @@ Type: `boolean` Default: `true`
1163
1167
 
1164
1168
  Enables additional index shift for all string array calls
1165
1169
 
1170
+ ### `stringArrayRotate`
1171
+ Type: `boolean` Default: `true`
1172
+
1173
+ ##### :warning: [`stringArray`](#stringarray) must be enabled
1174
+
1175
+ Shift the `stringArray` array by a fixed and random (generated at the code obfuscation) places. This makes it harder to match the order of the removed strings to their original place.
1176
+
1177
+ ### `stringArrayShuffle`
1178
+ Type: `boolean` Default: `true`
1179
+
1180
+ ##### :warning: [`stringArray`](#stringarray) must be enabled
1181
+
1182
+ Randomly shuffles the `stringArray` array items.
1183
+
1166
1184
  ### `stringArrayWrappersCount`
1167
1185
  Type: `number` Default: `1`
1168
1186
 
@@ -1419,7 +1437,7 @@ Unicode escape sequence increases code size greatly and strings easily can be re
1419
1437
  ## Preset Options
1420
1438
  ### High obfuscation, low performance
1421
1439
 
1422
- Performance will 50-100% slower than without obfuscation
1440
+ The performance will be much slower than without obfuscation
1423
1441
 
1424
1442
  ```javascript
1425
1443
  {
@@ -1435,15 +1453,17 @@ Performance will 50-100% slower than without obfuscation
1435
1453
  log: false,
1436
1454
  numbersToExpressions: true,
1437
1455
  renameGlobals: false,
1438
- rotateStringArray: true,
1439
1456
  selfDefending: true,
1440
- shuffleStringArray: true,
1441
1457
  simplify: true,
1442
1458
  splitStrings: true,
1443
1459
  splitStringsChunkLength: 5,
1444
1460
  stringArray: true,
1461
+ stringArray: true,
1462
+ stringArrayCallsTransform: true,
1445
1463
  stringArrayEncoding: ['rc4'],
1446
1464
  stringArrayIndexShift: true,
1465
+ stringArrayRotate: true,
1466
+ stringArrayShuffle: true,
1447
1467
  stringArrayWrappersCount: 5,
1448
1468
  stringArrayWrappersChainedCalls: true,
1449
1469
  stringArrayWrappersParametersMaxCount: 5,
@@ -1456,7 +1476,7 @@ Performance will 50-100% slower than without obfuscation
1456
1476
 
1457
1477
  ### Medium obfuscation, optimal performance
1458
1478
 
1459
- Performance will 30-35% slower than without obfuscation
1479
+ The performance will be slower than without obfuscation
1460
1480
 
1461
1481
  ```javascript
1462
1482
  {
@@ -1472,15 +1492,17 @@ Performance will 30-35% slower than without obfuscation
1472
1492
  log: false,
1473
1493
  numbersToExpressions: true,
1474
1494
  renameGlobals: false,
1475
- rotateStringArray: true,
1476
1495
  selfDefending: true,
1477
- shuffleStringArray: true,
1478
1496
  simplify: true,
1479
1497
  splitStrings: true,
1480
1498
  splitStringsChunkLength: 10,
1481
1499
  stringArray: true,
1500
+ stringArrayCallsTransform: true,
1501
+ stringArrayCallsTransformThreshold: 0.75,
1482
1502
  stringArrayEncoding: ['base64'],
1483
1503
  stringArrayIndexShift: true,
1504
+ stringArrayRotate: true,
1505
+ stringArrayShuffle: true,
1484
1506
  stringArrayWrappersCount: 2,
1485
1507
  stringArrayWrappersChainedCalls: true,
1486
1508
  stringArrayWrappersParametersMaxCount: 4,
@@ -1493,7 +1515,7 @@ Performance will 30-35% slower than without obfuscation
1493
1515
 
1494
1516
  ### Low obfuscation, High performance
1495
1517
 
1496
- Performance will slightly slower than without obfuscation
1518
+ The performance will be at a relatively normal level
1497
1519
 
1498
1520
  ```javascript
1499
1521
  {
@@ -1507,14 +1529,15 @@ Performance will slightly slower than without obfuscation
1507
1529
  log: false,
1508
1530
  numbersToExpressions: false,
1509
1531
  renameGlobals: false,
1510
- rotateStringArray: true,
1511
1532
  selfDefending: true,
1512
- shuffleStringArray: true,
1513
1533
  simplify: true,
1514
1534
  splitStrings: false,
1515
1535
  stringArray: true,
1536
+ stringArrayCallsTransform: false,
1516
1537
  stringArrayEncoding: [],
1517
1538
  stringArrayIndexShift: true,
1539
+ stringArrayRotate: true,
1540
+ stringArrayShuffle: true,
1518
1541
  stringArrayWrappersCount: 1,
1519
1542
  stringArrayWrappersChainedCalls: true,
1520
1543
  stringArrayWrappersParametersMaxCount: 2,
@@ -1538,14 +1561,16 @@ Performance will slightly slower than without obfuscation
1538
1561
  log: false,
1539
1562
  numbersToExpressions: false,
1540
1563
  renameGlobals: false,
1541
- rotateStringArray: true,
1542
1564
  selfDefending: false,
1543
- shuffleStringArray: true,
1544
1565
  simplify: true,
1545
1566
  splitStrings: false,
1546
1567
  stringArray: true,
1568
+ stringArrayCallsTransform: false,
1569
+ stringArrayCallsTransformThreshold: 0.5,
1547
1570
  stringArrayEncoding: [],
1548
1571
  stringArrayIndexShift: true,
1572
+ stringArrayRotate: true,
1573
+ stringArrayShuffle: true,
1549
1574
  stringArrayWrappersCount: 1,
1550
1575
  stringArrayWrappersChainedCalls: true,
1551
1576
  stringArrayWrappersParametersMaxCount: 2,