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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Change Log

v2.7.0
---
* Switched form `escodegen` to `@javascript-obfuscator/escodegen`
* Full support of `nullish-coalescing`. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/604
* Support for `exported` field of `ExportAllDeclaration` node. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/710

v2.6.4
---
* Added ignoring of all object members previous to `SpreadElement` when `transformObjectKeys` option is enabled. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/797
Expand Down
2 changes: 1 addition & 1 deletion 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.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "2.6.4",
"version": "2.7.0",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
Expand All @@ -21,14 +21,14 @@
},
"types": "index.d.ts",
"dependencies": {
"@nuxtjs/opencollective": "0.2.2",
"@javascript-obfuscator/escodegen": "2.1.0",
"@nuxtjs/opencollective": "0.3.2",
"acorn": "8.0.4",
"assert": "2.0.0",
"chalk": "4.1.0",
"chance": "1.1.7",
"class-validator": "0.12.2",
"commander": "6.2.0",
"escodegen": "2.0.0",
"eslint-scope": "5.1.1",
"estraverse": "5.2.0",
"eventemitter3": "4.0.7",
Expand Down Expand Up @@ -84,10 +84,10 @@
"rimraf": "3.0.2",
"sinon": "9.2.1",
"threads": "1.6.3",
"ts-loader": "8.0.7",
"ts-loader": "8.0.8",
"ts-node": "9.0.0",
"typescript": "4.1.0-beta",
"webpack": "5.3.2",
"webpack": "5.4.0",
"webpack-cli": "4.1.0",
"webpack-node-externals": "2.5.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/JavaScriptObfuscator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from './container/ServiceIdentifiers';

import * as acorn from 'acorn';
import * as escodegen from 'escodegen';
import * as escodegen from '@javascript-obfuscator/escodegen';
import * as ESTree from 'estree';

import { TObfuscatedCodeFactory } from './types/container/source-code/TObfuscatedCodeFactory';
Expand Down
2 changes: 1 addition & 1 deletion src/constants/EcmaVersion.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as acorn from 'acorn';

export const ecmaVersion: acorn.Options['ecmaVersion'] & number = 11;
export const ecmaVersion: acorn.Options['ecmaVersion'] & number = 12;
2 changes: 1 addition & 1 deletion src/declarations/ESTree.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */

import * as acorn from 'acorn';
import * as escodegen from 'escodegen';
import * as escodegen from '@javascript-obfuscator/escodegen';
import * as eslintScope from 'eslint-scope';

declare module 'estree' {
Expand Down
15 changes: 10 additions & 5 deletions src/declarations/escodegen.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
/* eslint-disable */

import * as ESTree from 'estree';
declare module '@javascript-obfuscator/escodegen' {
import * as ESTree from 'estree';
import * as escodegen from 'escodegen';
export * from 'escodegen';

import { IGeneratorOutput } from '../interfaces/IGeneratorOutput';
export interface IGeneratorOutput {
code: string;
map: string;
}

declare module 'escodegen' {
export interface XVerbatimProperty {
content?: string;
precedence: Precedence;
precedence: escodegen.Precedence;
}

/**
* @param ast
* @param options
* @returns IGeneratorOutput
*/
export function generate (ast: ESTree.Node, options?: GenerateOptions): IGeneratorOutput;
export function generate (ast: ESTree.Node, options?: escodegen.GenerateOptions): IGeneratorOutput;
}
2 changes: 1 addition & 1 deletion src/node/NodeFactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-lines */
import * as escodegen from 'escodegen';
import * as escodegen from '@javascript-obfuscator/escodegen';
import * as ESTree from 'estree';

import { TStatement } from '../types/node/TStatement';
Expand Down
2 changes: 1 addition & 1 deletion src/node/NodeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as escodegen from 'escodegen';
import * as escodegen from '@javascript-obfuscator/escodegen';
import * as estraverse from 'estraverse';
import * as ESTree from 'estree';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,30 @@ describe('JavaScriptObfuscator', () => {
});
});

/**
* https://github.com/javascript-obfuscator/javascript-obfuscator/issues/710
*/
describe('export * as', () => {
const regExp: RegExp = /export *\* *as foo from *'bar';/;

let obfuscatedCode: string;

beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/export-all-named-support.js');

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

it('should support `export * as` syntax', () => {
assert.match(obfuscatedCode, regExp);
});
});

/**
* https://github.com/estools/escodegen/pull/407
*/
Expand Down Expand Up @@ -712,6 +736,48 @@ describe('JavaScriptObfuscator', () => {
});
});

describe('Nullish coalescing support', () => {
const regExp: RegExp = /\(foo *\?\? *bar\) *&& *baz;/;

let obfuscatedCode: string;

beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/nullish-coalescing-support.js');

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

it('should support nullish coalescing operator', () => {
assert.match(obfuscatedCode, regExp);
});
});

describe('Numeric separators support', () => {
const regExp: RegExp = /const foo *= *0x64;/;

let obfuscatedCode: string;

beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/numeric-separators-support.js');

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

it('should support numeric separators', () => {
assert.match(obfuscatedCode, regExp);
});
});

describe('mangled identifier names generator', () => {
const regExp: RegExp = /var c *= *0x1/;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as foo from 'bar';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(foo ?? bar) && baz;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const foo = 1_0_0;
66 changes: 33 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd"
integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==

"@javascript-obfuscator/escodegen@2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@javascript-obfuscator/escodegen/-/escodegen-2.1.0.tgz#9ef8ea4966c41d1008932463a15395a37278b813"
integrity sha512-I9SEQcMWOrBp35/SScSB75QQd1BuYjZuLZnAgwwNOPudPsN8J9+rnS+InHGUsxho/Q7/sttaw/5MWH/qz2oElg==
dependencies:
esprima "^4.0.1"
estraverse "^5.2.0"
esutils "^2.0.2"
optionator "^0.8.1"
optionalDependencies:
source-map "~0.6.1"

"@nodelib/fs.scandir@2.1.3":
version "2.1.3"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"
Expand All @@ -327,14 +339,14 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

"@nuxtjs/opencollective@0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@nuxtjs/opencollective/-/opencollective-0.2.2.tgz#26a761ebf588cc92a422d7cee996a66bd6e2761e"
integrity sha512-69gFVDs7mJfNjv9Zs5DFVD+pvBW+k1TaHSOqUWqAyTTfLcKI/EMYQgvEvziRd+zAFtUOoye6MfWh0qvinGISPw==
"@nuxtjs/opencollective@0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz#620ce1044f7ac77185e825e1936115bb38e2681c"
integrity sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==
dependencies:
chalk "^2.4.1"
consola "^2.3.0"
node-fetch "^2.3.0"
chalk "^4.1.0"
consola "^2.15.0"
node-fetch "^2.6.1"

"@sinonjs/commons@^1", "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0":
version "1.7.1"
Expand Down Expand Up @@ -1194,7 +1206,7 @@ chalk@4.1.0, chalk@^4.1.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chalk@^2.0.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
chalk@^2.0.0, chalk@^2.3.0, chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
Expand Down Expand Up @@ -1384,10 +1396,10 @@ concat-stream@^1.4.7:
readable-stream "^2.2.2"
typedarray "^0.0.6"

consola@^2.3.0:
version "2.11.3"
resolved "https://registry.yarnpkg.com/consola/-/consola-2.11.3.tgz#f7315836224c143ac5094b47fd4c816c2cd1560e"
integrity sha512-aoW0YIIAmeftGR8GSpw6CGQluNdkWMWh3yEFjH/hmynTYnMtibXszii3lxCXmk8YxJtI3FAK5aTiquA5VH68Gw==
consola@^2.15.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/consola/-/consola-2.15.0.tgz#40fc4eefa4d2f8ef2e2806147f056ea207fcc0e9"
integrity sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ==

contains-path@^0.1.0:
version "0.1.0"
Expand Down Expand Up @@ -1770,18 +1782,6 @@ 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@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.0.0.tgz#5e32b12833e8aa8fa35e1bf0befa89380484c7dd"
integrity sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==
dependencies:
esprima "^4.0.1"
estraverse "^5.2.0"
esutils "^2.0.2"
optionator "^0.8.1"
optionalDependencies:
source-map "~0.6.1"

eslint-ast-utils@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/eslint-ast-utils/-/eslint-ast-utils-1.1.0.tgz#3d58ba557801cfb1c941d68131ee9f8c34bd1586"
Expand Down Expand Up @@ -3180,7 +3180,7 @@ nise@^4.0.4:
just-extend "^4.0.2"
path-to-regexp "^1.7.0"

node-fetch@^2.3.0:
node-fetch@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
Expand Down Expand Up @@ -4317,10 +4317,10 @@ tough-cookie@~2.5.0:
psl "^1.1.28"
punycode "^2.1.1"

ts-loader@8.0.7:
version "8.0.7"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.7.tgz#9ce70db5b3906cc9143a09c54ff5247d102ea974"
integrity sha512-ooa4wxlZ9TOXaJ/iVyZlWsim79Ul4KyifSwyT2hOrbQA6NZJypsLOE198o8Ko+JV+ZHnMArvWcl4AnRqpCU/Mw==
ts-loader@8.0.8:
version "8.0.8"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.8.tgz#5c514c895d3b2462bf0148f63da0c22b227f7867"
integrity sha512-wihija1i2Ub9FxKFoEgx/phToJiDZKLIbTFURgf4Efxla2QuVucDO6ZpHf2jNJsRtDQfBId0g+1HF0biIjoT6Q==
dependencies:
chalk "^2.3.0"
enhanced-resolve "^4.0.0"
Expand Down Expand Up @@ -4547,10 +4547,10 @@ webpack-sources@^2.1.1:
source-list-map "^2.0.1"
source-map "^0.6.1"

webpack@5.3.2:
version "5.3.2"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.3.2.tgz#f88f6f2c54eaa1f68c8f37d8984657eaf68b00f0"
integrity sha512-DXsfHoI6lQAR3KnQh7+FsRfs9fs+TEvzXCA35UbKv4kVuzslg7QCMAcpFRZNDMjdtm9N/PoO54XEzGN9TeacQg==
webpack@5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.4.0.tgz#4fdc6ec8a0ff9160701fb8f2eb8d06b33ecbae0f"
integrity sha512-udpYTyqz8toTTdaOsL2QKPLeZLt2IEm9qY7yTXuFEQhKu5bk0yQD9BtAdVQksmz4jFbbWOiWmm3NHarO0zr/ng==
dependencies:
"@types/eslint-scope" "^3.7.0"
"@types/estree" "^0.0.45"
Expand Down