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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.awcache
.DS_Store
.idea
.nyc_output
npm-debug.log
*.js.map
/coverage
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.awcache
.github
.idea
.nyc_output
coverage
images
test/fixtures/compile-performance.js
Expand Down
2 changes: 1 addition & 1 deletion dist/index.browser.js

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@
},
"types": "index.d.ts",
"dependencies": {
"@nuxtjs/opencollective": "0.2.2",
"chalk": "3.0.0",
"chance": "1.1.3",
"chance": "1.1.4",
"class-validator": "0.11.0",
"commander": "4.0.1",
"escodegen-wallaby": "1.6.27",
"espree": "^6.1.2",
"espree": "6.1.2",
"estraverse": "4.3.0",
"eventemitter3": "4.0.0",
"inversify": "5.0.1",
"js-string-escape": "1.0.1",
"md5": "2.2.1",
"mkdirp": "0.5.1",
"multimatch": "4.0.0",
"opencollective": "1.0.3",
"reflect-metadata": "0.1.13",
"source-map-support": "0.5.16",
"string-template": "1.0.0",
"tslib": "1.10.0"
},
"devDependencies": {
"@types/chai": "4.2.5",
"@types/chance": "1.0.7",
"@types/chai": "4.2.7",
"@types/chance": "1.0.8",
"@types/escodegen": "0.0.6",
"@types/estraverse": "0.0.6",
"@types/estree": "0.0.38",
Expand All @@ -58,21 +58,21 @@
"awesome-typescript-loader": "5.2.1",
"chai": "4.2.0",
"coveralls": "3.0.9",
"istanbul": "1.1.0-alpha.1",
"mocha": "6.2.2",
"nyc": "15.0.0",
"pjson": "1.0.9",
"pre-commit": "1.2.2",
"rimraf": "3.0.0",
"sinon": "7.5.0",
"threads": "0.12.0",
"threads": "1.0.0",
"ts-node": "6.1.0",
"tslint": "5.11.0",
"tslint-eslint-rules": "5.3.1",
"tslint": "5.20.1",
"tslint-eslint-rules": "5.4.0",
"tslint-language-service": "0.9.9",
"tslint-microsoft-contrib": "5.2.0",
"tslint-microsoft-contrib": "6.2.0",
"tslint-webpack-plugin": "1.2.2",
"typescript": "3.7.2",
"webpack": "4.41.2",
"typescript": "3.7.4",
"webpack": "4.41.5",
"webpack-cli": "3.3.10",
"webpack-node-externals": "1.7.2"
},
Expand All @@ -99,7 +99,7 @@
"tslint": "scripts/tslint",
"travis": "scripts/travis",
"git:addFiles": "scripts/git-add-files",
"postinstall": "opencollective postinstall"
"postinstall": "opencollective || exit 0"
},
"pre-commit": [
"build",
Expand All @@ -114,8 +114,6 @@
],
"license": "BSD-2-Clause",
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/javascript-obfuscator",
"logo": "https://opencollective.com/opencollective/logo.txt"
"url": "https://opencollective.com/javascript-obfuscator"
}
}
4 changes: 2 additions & 2 deletions scripts/test-coveralls
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

yarn run test:removeTmpDir &&
yarn run test:compile &&
$(yarn bin)/istanbul cover $(yarn bin)/_mocha -- test-tmp/test/index.spec.js --report lcovonly &&
cat ./coverage/lcov.info | $(yarn bin)/coveralls &&
$(yarn bin)/nyc $(yarn bin)/mocha -- test-tmp/test/index.spec.js --exit &&
$(yarn bin)/nyc report --reporter=text-lcov | $(yarn bin)/coveralls &&
yarn run test:removeTmpDir
2 changes: 1 addition & 1 deletion scripts/test-full
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
yarn run test:removeTmpDir &&
yarn run test:compile &&
node test-tmp/test/dev/dev.js &&
$(yarn bin)/istanbul cover $(yarn bin)/_mocha -- test-tmp/test/index.spec.js &&
$(yarn bin)/nyc --reporter text-summary $(yarn bin)/mocha -- test-tmp/test/index.spec.js --exit &&
yarn run test:removeTmpDir
15 changes: 0 additions & 15 deletions src/declarations/threads.d.ts

This file was deleted.

3 changes: 1 addition & 2 deletions test/declarations/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
/// <reference path="../../src/declarations/escodegen-wallaby.d.ts" />
/// <reference path="../../src/declarations/espree.d.ts" />
/// <reference path="../../src/declarations/ESTree.d.ts" />
/// <reference path="../../src/declarations/js-string-escape.d.ts" />
/// <reference path="../../src/declarations/threads.d.ts" />
/// <reference path="../../src/declarations/js-string-escape.d.ts" />
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,9 @@ describe('JavaScriptObfuscator', () => {
});
});

describe('Identifier names collision between base code and appended string array nodes', () => {
describe('Identifier names collision between base code and appended string array nodes', function () {
this.timeout(10000);

const samplesCount: number = 30;

let areCollisionsExists: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from 'chai';
import { spawn } from 'threads';
import { spawn, Thread, Worker } from 'threads/dist';

import { readFileAsString } from '../../../helpers/readFileAsString';

Expand All @@ -10,26 +10,26 @@ import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';

import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';

function spawnThread(inputCallback: Function, threadCallback: Function, timeoutCallback: Function): void {
const thread = spawn<string, number>((input: string, postMessage: Function) => {
postMessage(eval(input));
});


async function spawnThread(obfuscatedCode: string, threadCallback: Function, timeoutCallback: Function): Promise<void> {
const evaluationWorker = await spawn(new Worker('./workers/evaluation-worker'));

const timeout = setTimeout(() => {
thread.kill();
Thread.terminate(evaluationWorker);
timeoutCallback();
}, 1500);

thread
.send(inputCallback())
.on('message', (response: number) => {
clearTimeout(timeout);
thread.kill();
threadCallback(response);
});
const result: string = await evaluationWorker.evaluate(obfuscatedCode);

clearTimeout(timeout);
Thread.terminate(evaluationWorker);
threadCallback(result);
}

describe('DebugProtectionFunctionCallTemplate', () => {
describe('DebugProtectionFunctionCallTemplate', function () {
this.timeout(5000);

describe('Variant #1: correctly obfuscate code with `HexadecimalIdentifierNamesGenerator``', () => {
const expectedEvaluationResult: number = 1;

Expand All @@ -49,7 +49,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
).getObfuscatedCode();

spawnThread(
() => obfuscatedCode,
obfuscatedCode,
(response: number) => {
evaluationResult = response;
done();
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
).getObfuscatedCode();

spawnThread(
() => obfuscatedCode,
obfuscatedCode,
(response: number) => {
evaluationResult = response;
done();
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
).getObfuscatedCode();

spawnThread(
() => obfuscatedCode,
obfuscatedCode,
(response: number) => {
evaluationResult = response;
done();
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
).getObfuscatedCode();

spawnThread(
() => obfuscatedCode,
obfuscatedCode,
(response: number) => {
evaluationResult = response;
done();
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
obfuscatedCode = obfuscatedCode.replace(/\+\+ *_0x([a-f0-9]){4,6}/, '');

spawnThread(
() => obfuscatedCode,
obfuscatedCode,
(response: number) => {
evaluationResult = response;
done();
Expand Down Expand Up @@ -224,7 +224,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
).getObfuscatedCode();

spawnThread(
() => obfuscatedCode,
obfuscatedCode,
(response: number) => {
evaluationResult = response;
done();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const expose = require('threads/worker').expose;

expose({
evaluate: (obfuscatedCode) => {
return eval(obfuscatedCode);
}
});
8 changes: 6 additions & 2 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"static-method-regex": "^[a-z][\\w\\d]+$",
"function-regex": "^[a-zA-Z][\\w\\d]+$"
}],
"no-function-constructor-with-string-args": false,
"no-use-before-declare": false,
"no-unnecessary-bind": false,
"indent": [
true,
"spaces"
Expand Down Expand Up @@ -140,11 +143,11 @@
"no-unsafe-any": false,
"no-unsafe-finally": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-useless-files": true,
"no-var-keyword": true,
"no-var-requires": true,
"non-literal-require": false,
"non-literal-fs-path": false,
"max-file-line-count": [true, 500],
"object-curly-spacing": [true, "always"],
"object-literal-sort-keys": false,
Expand All @@ -162,7 +165,7 @@
true,
{
"import-sources-order": "any",
"grouped-imports": true,
"grouped-imports": false,
"named-imports-order": "case-insensitive"
}
],
Expand Down Expand Up @@ -233,6 +236,7 @@
}
],
"unified-signatures": true,
"unnecessary-bind": true,
"use-isnan": true,
"valid-jsdoc": [false, {
"requireReturn": false,
Expand Down
Loading