javascript-obfuscator 3.0.0 → 3.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 (66) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +91 -6
  3. package/dist/index.browser.js +1 -1
  4. package/dist/index.browser.js.LICENSE.txt +1 -1
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.cli.js +1 -1
  7. package/dist/index.cli.js.LICENSE.txt +1 -1
  8. package/dist/index.cli.js.map +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/index.js.LICENSE.txt +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/package.json +35 -33
  13. package/typings/src/code-transformers/AbstractCodeTransformer.d.ts +1 -1
  14. package/typings/src/container/InversifyContainerFacade.d.ts +2 -1
  15. package/typings/src/container/ServiceIdentifiers.d.ts +2 -1
  16. package/typings/src/custom-code-helpers/AbstractCustomCodeHelper.d.ts +1 -1
  17. package/typings/src/custom-nodes/AbstractCustomNode.d.ts +1 -1
  18. package/typings/src/custom-nodes/control-flow-flattening-nodes/{StringLiteralNode.d.ts → LiteralNode.d.ts} +4 -3
  19. package/typings/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.d.ts +2 -2
  20. package/typings/src/custom-nodes/string-array-nodes/AbstractStringArrayCallNode.d.ts +1 -1
  21. package/typings/src/custom-nodes/string-array-nodes/string-array-index-nodes/AbstractStringArrayIndexNode.d.ts +1 -1
  22. package/typings/src/enums/custom-nodes/ControlFlowCustomNode.d.ts +2 -2
  23. package/typings/src/enums/node/NodeType.d.ts +1 -0
  24. package/typings/src/enums/node-transformers/NodeTransformer.d.ts +1 -0
  25. package/typings/src/enums/node-transformers/control-flow-transformers/control-flow-replacers/ControlFlowReplacer.d.ts +1 -0
  26. package/typings/src/enums/storages/ControlFlowStorage.d.ts +4 -0
  27. package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts +2 -1
  28. package/typings/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.d.ts +1 -0
  29. package/typings/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.d.ts +1 -0
  30. package/typings/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.d.ts +9 -2
  31. package/typings/src/generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator.d.ts +2 -2
  32. package/typings/src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts +1 -0
  33. package/typings/src/interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer.d.ts +3 -2
  34. package/typings/src/interfaces/options/IOptions.d.ts +2 -0
  35. package/typings/src/interfaces/storages/IWeakMapStorage.d.ts +9 -0
  36. package/typings/src/interfaces/storages/control-flow-transformers/IControlFlowStorage.d.ts +4 -0
  37. package/typings/src/interfaces/storages/string-array-transformers/IStringArrayScopeCallsWrappersDataStorage.d.ts +2 -2
  38. package/typings/src/interfaces/utils/ISetUtils.d.ts +3 -0
  39. package/typings/src/node/NodeFactory.d.ts +1 -0
  40. package/typings/src/node/NodeGuards.d.ts +1 -0
  41. package/typings/src/node/NodeLiteralUtils.d.ts +2 -0
  42. package/typings/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.d.ts +22 -13
  43. package/typings/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.d.ts +25 -0
  44. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.d.ts +8 -5
  45. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.d.ts +4 -3
  46. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.d.ts +4 -3
  47. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.d.ts +2 -1
  48. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.d.ts +4 -3
  49. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/StringArrayCallControlFlowReplacer.d.ts +14 -0
  50. package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.d.ts +5 -4
  51. package/typings/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.d.ts +0 -2
  52. package/typings/src/node-transformers/simplifying-transformers/AbstractStatementSimplifyTransformer.d.ts +1 -1
  53. package/typings/src/options/Options.d.ts +2 -0
  54. package/typings/src/options/normalizer-rules/StringArrayCallsTransformThresholdRule.d.ts +2 -0
  55. package/typings/src/storages/ArrayStorage.d.ts +1 -1
  56. package/typings/src/storages/WeakMapStorage.d.ts +17 -0
  57. package/typings/src/storages/control-flow-transformers/FunctionControlFlowStorage.d.ts +11 -0
  58. package/typings/src/storages/control-flow-transformers/StringControlFlowStorage.d.ts +8 -0
  59. package/typings/src/storages/string-array-transformers/StringArrayScopeCallsWrappersDataStorage.d.ts +2 -2
  60. package/typings/src/types/TConstructor.d.ts +1 -0
  61. package/typings/src/types/container/node-transformers/TControlFlowStorageFactory.d.ts +2 -2
  62. package/typings/src/types/container/node-transformers/TControlFlowStorageFactoryCreator.d.ts +3 -0
  63. package/typings/src/types/node/TNumberLiteralNode.d.ts +4 -0
  64. package/typings/src/utils/SetUtils.d.ts +7 -0
  65. package/typings/src/storages/custom-nodes/ControlFlowStorage.d.ts +0 -7
  66. package/typings/src/types/storages/TControlFlowStorage.d.ts +0 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  Change Log
2
2
 
3
+ v3.2.1
4
+ ---
5
+ * Updated copyright
6
+
7
+ v3.2.0
8
+ ---
9
+ * **New options**: `stringArrayCallsTransform` and `stringArrayCallsTransformThreshold`
10
+ * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/pull/1046
11
+
12
+ v3.1.0
13
+ ---
14
+ * Added support of `es2022` features: class static block
15
+
16
+ v3.0.1
17
+ ---
18
+ * Dependencies update
19
+ * Fixed performance for Apple M1 chip
20
+
3
21
  v3.0.0
4
22
  ---
5
23
  * **Breaking change:** `ignoreRequireImports` option renamed to `ignoreImports`
package/README.md CHANGED
@@ -379,10 +379,12 @@ Following options are available for the JS Obfuscator:
379
379
  splitStrings: false,
380
380
  splitStringsChunkLength: 10,
381
381
  stringArray: true,
382
+ stringArrayCallsTransform: true,
383
+ stringArrayCallsTransformThreshold: 0.5,
384
+ stringArrayEncoding: [],
382
385
  stringArrayIndexesType: [
383
386
  'hexadecimal-number'
384
387
  ],
385
- stringArrayEncoding: [],
386
388
  stringArrayIndexShift: true,
387
389
  stringArrayRotate: true,
388
390
  stringArrayShuffle: true,
@@ -441,8 +443,10 @@ Following options are available for the JS Obfuscator:
441
443
  --split-strings <boolean>
442
444
  --split-strings-chunk-length <number>
443
445
  --string-array <boolean>
444
- --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>
445
448
  --string-array-encoding '<list>' (comma separated) [none, base64, rc4]
449
+ --string-array-indexes-type '<list>' (comma separated) [hexadecimal-number, hexadecimal-numeric-string]
446
450
  --string-array-index-shift <boolean>
447
451
  --string-array-rotate <boolean>
448
452
  --string-array-shuffle <boolean>
@@ -1097,6 +1101,80 @@ Type: `boolean` Default: `true`
1097
1101
 
1098
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];`
1099
1103
 
1104
+ ### `stringArrayCallsTransform`
1105
+ Type: `boolean` Default: `false`
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 a different object depending on [`stringArrayCallsTransformThreshold`](#stringarraycallstransformthreshold) value.
1110
+ So it makes it even harder to automatically find calls to the string array.
1111
+
1112
+ Example:
1113
+ ```
1114
+ function foo() {
1115
+ var k = {
1116
+ c: 0x2f2,
1117
+ d: '0x396',
1118
+ e: '0x397',
1119
+ f: '0x39a',
1120
+ g: '0x39d',
1121
+ h: 0x398,
1122
+ l: 0x394,
1123
+ m: '0x39b',
1124
+ n: '0x39f',
1125
+ o: 0x395,
1126
+ p: 0x395,
1127
+ q: 0x399,
1128
+ r: '0x399'
1129
+ };
1130
+ var c = i(k.d, k.e);
1131
+ var d = i(k.f, k.g);
1132
+ var e = i(k.h, k.l);
1133
+ var f = i(k.m, k.n);
1134
+ function i(c, d) {
1135
+ return b(c - k.c, d);
1136
+ }
1137
+ var g = i(k.o, k.p);
1138
+ var h = i(k.q, k.r);
1139
+ }
1140
+ function j(c, d) {
1141
+ var l = { c: 0x14b };
1142
+ return b(c - -l.c, d);
1143
+ }
1144
+ console[j(-'0xa6', -'0xa6')](foo());
1145
+ function b(c, d) {
1146
+ var e = a();
1147
+ b = function (f, g) {
1148
+ f = f - 0xa3;
1149
+ var h = e[f];
1150
+ return h;
1151
+ };
1152
+ return b(c, d);
1153
+ }
1154
+ function a() {
1155
+ var m = [
1156
+ 'string5',
1157
+ 'string1',
1158
+ 'log',
1159
+ 'string3',
1160
+ 'string6',
1161
+ 'string2',
1162
+ 'string4'
1163
+ ];
1164
+ a = function () {
1165
+ return m;
1166
+ };
1167
+ return a();
1168
+ }
1169
+ ```
1170
+
1171
+ ### `stringArrayCallsTransformThreshold`
1172
+ Type: `number` Default: `0.5`
1173
+
1174
+ ##### :warning: [`stringArray`](#stringarray) and [`stringArrayCallsTransformThreshold`](#stringarraycallstransformthreshold) options must be enabled
1175
+
1176
+ You can use this setting to adjust the probability (from 0 to 1) that calls to the string array will be transformed.
1177
+
1100
1178
  ### `stringArrayEncoding`
1101
1179
  Type: `string[]` Default: `[]`
1102
1180
 
@@ -1419,7 +1497,7 @@ Unicode escape sequence increases code size greatly and strings easily can be re
1419
1497
  ## Preset Options
1420
1498
  ### High obfuscation, low performance
1421
1499
 
1422
- Performance will 50-100% slower than without obfuscation
1500
+ The performance will be much slower than without obfuscation
1423
1501
 
1424
1502
  ```javascript
1425
1503
  {
@@ -1440,6 +1518,8 @@ Performance will 50-100% slower than without obfuscation
1440
1518
  splitStrings: true,
1441
1519
  splitStringsChunkLength: 5,
1442
1520
  stringArray: true,
1521
+ stringArray: true,
1522
+ stringArrayCallsTransform: true,
1443
1523
  stringArrayEncoding: ['rc4'],
1444
1524
  stringArrayIndexShift: true,
1445
1525
  stringArrayRotate: true,
@@ -1456,7 +1536,7 @@ Performance will 50-100% slower than without obfuscation
1456
1536
 
1457
1537
  ### Medium obfuscation, optimal performance
1458
1538
 
1459
- Performance will 30-35% slower than without obfuscation
1539
+ The performance will be slower than without obfuscation
1460
1540
 
1461
1541
  ```javascript
1462
1542
  {
@@ -1477,6 +1557,8 @@ Performance will 30-35% slower than without obfuscation
1477
1557
  splitStrings: true,
1478
1558
  splitStringsChunkLength: 10,
1479
1559
  stringArray: true,
1560
+ stringArrayCallsTransform: true,
1561
+ stringArrayCallsTransformThreshold: 0.75,
1480
1562
  stringArrayEncoding: ['base64'],
1481
1563
  stringArrayIndexShift: true,
1482
1564
  stringArrayRotate: true,
@@ -1493,7 +1575,7 @@ Performance will 30-35% slower than without obfuscation
1493
1575
 
1494
1576
  ### Low obfuscation, High performance
1495
1577
 
1496
- Performance will slightly slower than without obfuscation
1578
+ The performance will be at a relatively normal level
1497
1579
 
1498
1580
  ```javascript
1499
1581
  {
@@ -1511,6 +1593,7 @@ Performance will slightly slower than without obfuscation
1511
1593
  simplify: true,
1512
1594
  splitStrings: false,
1513
1595
  stringArray: true,
1596
+ stringArrayCallsTransform: false,
1514
1597
  stringArrayEncoding: [],
1515
1598
  stringArrayIndexShift: true,
1516
1599
  stringArrayRotate: true,
@@ -1542,6 +1625,8 @@ Performance will slightly slower than without obfuscation
1542
1625
  simplify: true,
1543
1626
  splitStrings: false,
1544
1627
  stringArray: true,
1628
+ stringArrayCallsTransform: false,
1629
+ stringArrayCallsTransformThreshold: 0.5,
1545
1630
  stringArrayEncoding: [],
1546
1631
  stringArrayIndexShift: true,
1547
1632
  stringArrayRotate: true,
@@ -1646,7 +1731,7 @@ Become a sponsor and get your logo on our README on Github with a link to your s
1646
1731
  ## License
1647
1732
  [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjavascript-obfuscator%2Fjavascript-obfuscator.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjavascript-obfuscator%2Fjavascript-obfuscator?ref=badge_large)
1648
1733
 
1649
- Copyright (C) 2016-2021 [Timofey Kachalov](http://github.com/sanex3339).
1734
+ Copyright (C) 2016-2022 [Timofey Kachalov](http://github.com/sanex3339).
1650
1735
 
1651
1736
  Redistribution and use in source and binary forms, with or without
1652
1737
  modification, are permitted provided that the following conditions are met: