Skip to content

Commit f784a97

Browse files
committed
Obfuscator version update to 2.0.0.
Added `optionsPreset` and updated `stringArrayEncoding` controls and logic
1 parent 7505ccb commit f784a97

File tree

7 files changed

+110
-34
lines changed

7 files changed

+110
-34
lines changed

App/actions/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export const resetOptions = () => ({
6565
'type': types.RESET_OPTIONS,
6666
});
6767

68+
export const setOptionsPreset = (optionsPreset) => ({
69+
'type': types.SET_OPTIONS_PRESET,
70+
optionsPreset
71+
});
72+
6873
export const toggleOption = (optionType) => ({
6974
'type': optionType
7075
});

App/constants/ActionTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const OBFUSCATE_REJECTED = 'OBFUSCATE_REJECTED';
88

99
export const RESET_OPTIONS = 'RESET_OPTIONS';
1010

11+
export const SET_OPTIONS_PRESET = 'SET_OPTIONS_PRESET';
12+
1113
export const TOGGLE_COMPACT_CODE = 'TOGGLE_COMPACT_CODE';
1214
export const TOGGLE_SIMPLIFY = 'TOGGLE_SIMPLIFY';
1315

App/containers/OptionsContainer.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ import EntryInputContainer from '../containers/EntryInputContainer';
1010
import * as types from '../constants/ActionTypes';
1111
import * as actions from '../actions';
1212

13+
export const OPTIONS_PRESET_DEFAULT = 'default';
14+
export const OPTIONS_PRESET_LOW_OBFUSCATION = 'low-obfuscation';
15+
export const OPTIONS_PRESET_MEDIUM_OBFUSCATION = 'medium-obfuscation';
16+
export const OPTIONS_PRESET_HIGH_OBFUSCATION = 'high-obfuscation';
17+
18+
const OPTIONS_PRESET_OPTIONS = [
19+
{text: 'default', value: OPTIONS_PRESET_DEFAULT},
20+
{text: 'low', value: OPTIONS_PRESET_LOW_OBFUSCATION},
21+
{text: 'medium', value: OPTIONS_PRESET_MEDIUM_OBFUSCATION},
22+
{text: 'high', value: OPTIONS_PRESET_HIGH_OBFUSCATION},
23+
];
24+
1325
export const SOURCEMAP_OFF = 'off';
1426
export const SOURCEMAP_INLINE = 'inline';
1527
export const SOURCEMAP_SEPARATE = 'separate';
@@ -20,10 +32,14 @@ const SOURCEMAP_OPTIONS = [
2032
{text: 'Separate', value: SOURCEMAP_SEPARATE},
2133
];
2234

35+
export const STRING_ARRAY_ENCODING_NONE = 'none';
36+
export const STRING_ARRAY_ENCODING_BASE64 = 'base64';
37+
export const STRING_ARRAY_ENCODING_RC4 = 'rc4';
38+
2339
const STRING_ARRAY_ENCODING_OPTIONS = [
24-
{text: 'Off', value: 'false'},
25-
{text: 'Base64', value: 'base64'},
26-
{text: 'RC4', value: 'rc4'},
40+
{text: 'None', value: STRING_ARRAY_ENCODING_NONE},
41+
{text: 'Base64', value: STRING_ARRAY_ENCODING_BASE64},
42+
{text: 'RC4', value: STRING_ARRAY_ENCODING_RC4},
2743
];
2844

2945
export const TARGET_BROWSER = 'browser';
@@ -62,6 +78,15 @@ const Options = ({dispatch, options}) =>
6278

6379
<Divider/>
6480

81+
<Form.Select
82+
label='Options Preset'
83+
value={options.optionsPreset}
84+
fluid
85+
onChange={(event, {value}) => dispatch(actions.setOptionsPreset(value))}
86+
options={OPTIONS_PRESET_OPTIONS}/>
87+
88+
<Divider/>
89+
6590
<Form.Checkbox
6691
label='Compact code'
6792
checked={options.compact}
@@ -169,8 +194,16 @@ const Options = ({dispatch, options}) =>
169194
disabled={!options.stringArrayEncodingEnabled}
170195
label='String Array Encoding'
171196
fluid
197+
multiple
198+
placeholder={STRING_ARRAY_ENCODING_NONE}
172199
value={options.stringArrayEncoding}
173200
onChange={(event, {value}) => dispatch(actions.setStringArrayEncoding(value))}
201+
renderLabel={(item) => {
202+
return ({
203+
content: `${item.value}`,
204+
...item.value === STRING_ARRAY_ENCODING_NONE && {onRemove: undefined}
205+
});
206+
}}
174207
options={STRING_ARRAY_ENCODING_OPTIONS}/>
175208

176209
<Form.Input

App/reducers/options.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import * as types from '../constants/ActionTypes';
22

3-
import {SOURCEMAP_SEPARATE, SOURCEMAP_OFF} from '../containers/OptionsContainer';
3+
import {
4+
SOURCEMAP_SEPARATE,
5+
SOURCEMAP_OFF,
6+
OPTIONS_PRESET_DEFAULT,
7+
IDENTIFIER_NAMES_GENERATOR_HEXADECIMAL, TARGET_BROWSER, STRING_ARRAY_ENCODING_NONE
8+
} from '../containers/OptionsContainer';
49

510
const initialState = {
11+
optionsPreset: OPTIONS_PRESET_DEFAULT,
12+
613
compact: true,
714
selfDefending: false,
815
disableConsoleOutput: false,
@@ -28,13 +35,13 @@ const initialState = {
2835
stringArrayThreshold: 0.8,
2936
stringArrayThresholdEnabled: true,
3037

31-
stringArrayEncoding: 'false',
38+
stringArrayEncoding: [STRING_ARRAY_ENCODING_NONE],
3239
stringArrayEncodingEnabled: true,
3340

3441
numbersToExpressions: false,
3542

3643
sourceMap: false,
37-
sourceMapMode: 'off',
44+
sourceMapMode: SOURCEMAP_OFF,
3845
sourceMapBaseUrl: '',
3946
sourceMapFileName: '',
4047
sourceMapSeparate: false,
@@ -57,9 +64,9 @@ const initialState = {
5764
renameGlobals: false,
5865
renameProperties: false,
5966

60-
target: 'browser',
67+
target: TARGET_BROWSER,
6168

62-
identifierNamesGenerator: 'hexadecimal',
69+
identifierNamesGenerator: IDENTIFIER_NAMES_GENERATOR_HEXADECIMAL,
6370
identifiersDictionary: [],
6471
identifiersPrefix: '',
6572

@@ -83,6 +90,13 @@ export const options = (state = initialState, action) => {
8390
return initialState;
8491
}
8592

93+
case types.SET_OPTIONS_PRESET: {
94+
return {
95+
...state,
96+
optionsPreset: action.optionsPreset
97+
};
98+
}
99+
86100
case types.TOGGLE_COMPACT_CODE: {
87101
const compact = !state.compact;
88102
return {
@@ -173,7 +187,7 @@ export const options = (state = initialState, action) => {
173187
case types.SET_STRING_ARRAY_ENCODING:
174188
return {
175189
...state,
176-
stringArrayEncoding: action.encoding
190+
stringArrayEncoding: action.encoding.length ? action.encoding : initialState.stringArrayEncoding
177191
};
178192

179193
case types.SET_STRING_ARRAY_THRESHOLD:

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "javascript-obfuscator-web",
3-
"version": "3.10.8",
3+
"version": "3.11.0",
44
"description": "",
55
"engines": {
66
"node": ">=12.13.1"
@@ -32,7 +32,7 @@
3232
"graceful-fs": "4.1.9",
3333
"html-webpack-plugin": "^3.2.0",
3434
"inert": "5.1.0",
35-
"javascript-obfuscator": "1.11.0",
35+
"javascript-obfuscator": "2.0.0",
3636
"less": "2.7.1",
3737
"less-loader": "4.1.0",
3838
"pm2": "3.5.1",

templates/index.html

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h1>JavaScript Obfuscator Tool</h1>
4949
<p>
5050
A free and efficient obfuscator for JavaScript (including partial support of ES2019). Make your code harder to copy and
5151
prevent people from stealing your work. This tool is a Web UI to the excellent (and open source)
52-
<code><a href="https://github.com/javascript-obfuscator/javascript-obfuscator" target="_new">javascript-obfuscator</a>@1.11.0</code>
52+
<code><a href="https://github.com/javascript-obfuscator/javascript-obfuscator" target="_new">javascript-obfuscator</a>@2.0.0</code>
5353
created by Timofey Kachalov.
5454
</p>
5555
<div id="GithubBadges">
@@ -137,6 +137,24 @@ <h3>Sounds great!</h3>
137137
<table class="ui definition table" id="Options">
138138
<tbody>
139139

140+
<tr>
141+
<td class="collapsing">Options preset</td>
142+
<td>
143+
<p>Allows to set options preset.</p>
144+
145+
<p>Available values:</p>
146+
147+
<ul>
148+
<li><strong>Default</strong></li>
149+
<li><strong>Low Obfuscation</strong></li>
150+
<li><strong>Medium Obfuscation</strong></li>
151+
<li><strong>High Obfuscation</strong></li>
152+
</ul>
153+
154+
<p>All addition options will be merged with selected options preset.</p>
155+
</td>
156+
</tr>
157+
140158
<tr>
141159
<td class="collapsing">Compact Code</td>
142160
<td>
@@ -353,11 +371,15 @@ <h3>Sounds great!</h3>
353371
<td class="collapsing">Encode String Literals</td>
354372
<td>
355373
<div class="ui tiny message">
356-
<p><i class="warning sign icon"></i> This option can slightly slow down your
374+
<p><i class="warning sign icon"></i> This option can slow down your
357375
script.</p>
358376
</div>
359-
<p>Encode all string literals of the <code>stringArray</code> using either Base64 or
360-
RC4 and inserts a special function that it's used to decode it back at runtime.
377+
<p>
378+
Encode all string literals of the <code>stringArray</code> using Base64 or
379+
RC4 and inserts a special that used to decode it back at runtime.
380+
</p>
381+
<p>
382+
Each stringArray value will be encoded by the randomly picked encoding from the passed list. This makes possible to use multiple encodings.
361383
</p>
362384
<p>Beware that the RC4 option is about 30-35% slower than the Base64 option, but
363385
it's more difficult to retrieve the strings back.</p>

yarn.lock

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,10 +1626,10 @@ chalk@~0.4.0:
16261626
has-color "~0.1.0"
16271627
strip-ansi "~0.1.0"
16281628

1629-
chance@1.1.6:
1630-
version "1.1.6"
1631-
resolved "https://registry.yarnpkg.com/chance/-/chance-1.1.6.tgz#967a0a129e0f342f7c65cd5d20f5ae870a26b8af"
1632-
integrity sha512-DXLzaGjasDWbvlFAJyQBIwlzdQZuPdz4of9TTTxmHTjja88ZU/vBwUwxxjalSt43zWTPrhiJT0z0N4bZqfZS9w==
1629+
chance@1.1.7:
1630+
version "1.1.7"
1631+
resolved "https://registry.yarnpkg.com/chance/-/chance-1.1.7.tgz#e99dde5ac16681af787b5ba94c8277c090d6cfe8"
1632+
integrity sha512-bua/2cZEfzS6qPm0vi3JEvGNbriDLcMj9lKxCQOjUcCJRcyjA7umP0zZm6bKWWlBN04vA0L99QGH/CZQawr0eg==
16331633

16341634
chardet@^0.4.0:
16351635
version "0.4.2"
@@ -1910,10 +1910,10 @@ commander@2.17.x:
19101910
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
19111911
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==
19121912

1913-
commander@6.0.0:
1914-
version "6.0.0"
1915-
resolved "https://registry.yarnpkg.com/commander/-/commander-6.0.0.tgz#2b270da94f8fb9014455312f829a1129dbf8887e"
1916-
integrity sha512-s7EA+hDtTYNhuXkTlhqew4txMZVdszBmKWSPEMxGr8ru8JXR7bLUFIAtPhcSuFdJQ0ILMxnJi8GkQL0yvDy/YA==
1913+
commander@6.1.0:
1914+
version "6.1.0"
1915+
resolved "https://registry.yarnpkg.com/commander/-/commander-6.1.0.tgz#f8d722b78103141006b66f4c7ba1e97315ba75bc"
1916+
integrity sha512-wl7PNrYWd2y5mp1OK/LhTlv8Ff4kQJQRXXAvF+uU/TPNiVJUxZLRYGj/B0y/lPGAVcSbJqH2Za/cvHmrPMC8mA==
19171917

19181918
commander@~2.13.0:
19191919
version "2.13.0"
@@ -2805,10 +2805,10 @@ eventemitter2@~0.4.14:
28052805
resolved "https://registry.yarnpkg.com/eventemitter2/-/eventemitter2-0.4.14.tgz#8f61b75cde012b2e9eb284d4545583b5643b61ab"
28062806
integrity sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=
28072807

2808-
eventemitter3@4.0.4:
2809-
version "4.0.4"
2810-
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384"
2811-
integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ==
2808+
eventemitter3@4.0.7:
2809+
version "4.0.7"
2810+
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f"
2811+
integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==
28122812

28132813
events@^1.0.0:
28142814
version "1.1.1"
@@ -4149,22 +4149,22 @@ isurl@^1.0.0-alpha5:
41494149
has-to-string-tag-x "^1.2.0"
41504150
is-object "^1.0.1"
41514151

4152-
javascript-obfuscator@1.11.0:
4153-
version "1.11.0"
4154-
resolved "https://registry.yarnpkg.com/javascript-obfuscator/-/javascript-obfuscator-1.11.0.tgz#633658b91bdf26613d8170b878245ecb0e9e4061"
4155-
integrity sha512-d4i51CAnud8q9X4PELzAbmCMQ+FoFBWq1AxOHsTlvgBeUpF3GCuYNyTbjUaLGFSAuqmCetxJBwDIOoOKdLnAPA==
4152+
javascript-obfuscator@2.0.0:
4153+
version "2.0.0"
4154+
resolved "https://registry.yarnpkg.com/javascript-obfuscator/-/javascript-obfuscator-2.0.0.tgz#caccc915652a0f315dd8b5f5481307a2d3a4cebc"
4155+
integrity sha512-FbQPVJJcXHFex9YD2qEMWDM5AMP8cRpMQorOt0SNVitv8bTnCt1MYmutg2QlWWFbDQXf8o6iXCfnItwYD8TE9g==
41564156
dependencies:
41574157
"@gradecam/tsenum" "1.2.0"
41584158
"@nuxtjs/opencollective" "0.2.2"
41594159
acorn "8.0.1"
41604160
chalk "4.1.0"
4161-
chance "1.1.6"
4161+
chance "1.1.7"
41624162
class-validator "0.12.2"
4163-
commander "6.0.0"
4163+
commander "6.1.0"
41644164
escodegen "2.0.0"
41654165
eslint-scope "5.1.0"
41664166
estraverse "5.2.0"
4167-
eventemitter3 "4.0.4"
4167+
eventemitter3 "4.0.7"
41684168
fast-deep-equal "3.1.3"
41694169
inversify "5.0.1"
41704170
js-string-escape "1.0.1"

0 commit comments

Comments
 (0)