Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Change Log

v0.23.2
---
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/475
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/326

v0.23.1
---
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/498
Expand Down
6 changes: 3 additions & 3 deletions dist/index.browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.cli.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "0.23.1",
"version": "0.23.2",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
Expand Down Expand Up @@ -28,7 +28,7 @@
"chance": "1.1.4",
"class-validator": "0.11.0",
"commander": "4.1.0",
"escodegen": "1.12.1",
"escodegen": "1.13.0",
"estraverse": "4.3.0",
"eventemitter3": "4.0.0",
"inversify": "5.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFac
describe('CatchClauseTransformer', () => {
let obfuscatedCode: string;

describe('transformNode', () => {
describe('Variant #1: base transform of catch clause parameter', () => {
const paramNameRegExp: RegExp = /catch *\((_0x([a-f0-9]){4,6})\) *\{/;
const bodyParamNameRegExp: RegExp = /console\['log'\]\((_0x([a-f0-9]){4,6})\);/;

Expand Down Expand Up @@ -43,7 +43,7 @@ describe('CatchClauseTransformer', () => {
});
});

describe('object pattern as parameter', () => {
describe('Variant #2: object pattern as parameter', () => {
const functionParameterMatch: RegExp = /\} *catch *\(\{ *name *\}\) *\{/;
const functionBodyMatch: RegExp = /return *name;/;

Expand All @@ -66,4 +66,28 @@ describe('CatchClauseTransformer', () => {
assert.match(obfuscatedCode, functionBodyMatch);
});
});

describe('Variant #3: optional catch binding support', () => {
const optionalCatchClauseRegExp: RegExp = /} *catch *\{/;
const bodyParamNameRegExp: RegExp = /console\['log'\]\(0x1\);/;

before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/optional-catch-binding.js');

obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET
}
).getObfuscatedCode();
});

it('match #1: should transform catch clause node', () => {
assert.match(obfuscatedCode, optionalCatchClauseRegExp);
});

it('match #2: should transform catch clause node', () => {
assert.match(obfuscatedCode, bodyParamNameRegExp);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
try {

} catch {
console.log(1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,26 @@ describe('ClassDeclarationTransformer', () => {
assert.match(obfuscatedCode, defaultExportRegExp);
});
});

describe('Variant #8: super class expression parenthesis', () => {
const defaultExportRegExp: RegExp = /class Baz extends *\(Foo *\|| *Bar\) *{}/;

let obfuscatedCode: string;

before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/super-class-expression-parenthesis.js');

obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET
}
).getObfuscatedCode();
});

it('Match #1: should keep super class expression parenthesis', () => {
assert.match(obfuscatedCode, defaultExportRegExp);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Foo {}
class Bar {}
class Baz extends (Foo || Bar) {}

17 changes: 6 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1577,12 +1577,12 @@ [email protected], escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=

escodegen@1.12.1:
version "1.12.1"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.12.1.tgz#08770602a74ac34c7a90ca9229e7d51e379abc76"
integrity sha512-Q8t2YZ+0e0pc7NRVj3B4tSQ9rim1oi4Fh46k2xhJ2qOiEwhQfdjyEQddWdj7ZFaKmU+5104vn1qrcjEPWq+bgQ==
escodegen@1.13.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.13.0.tgz#c7adf9bd3f3cc675bb752f202f79a720189cab29"
integrity sha512-eYk2dCkxR07DsHA/X2hRBj0CFAZeri/LyDMc0C8JT1Hqi6JnVpMhJ7XFITbb0+yZS3lVkaPL2oCkZ3AVmeVbMw==
dependencies:
esprima "^3.1.3"
esprima "^4.0.1"
estraverse "^4.2.0"
esutils "^2.0.2"
optionator "^0.8.1"
Expand All @@ -1602,12 +1602,7 @@ esm@^3.2.25:
resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10"
integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==

esprima@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
integrity sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=

esprima@^4.0.0:
esprima@^4.0.0, esprima@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
Expand Down