Skip to content
Closed
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
136 changes: 0 additions & 136 deletions .npmignore

This file was deleted.

14 changes: 0 additions & 14 deletions babel.config.js

This file was deleted.

7 changes: 0 additions & 7 deletions babel.register.js

This file was deleted.

17 changes: 0 additions & 17 deletions index.d.ts

This file was deleted.

4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const transform = require("ts-jest").createDefaultPreset().transform;

const options = [
"minify",
"renameVariables",
Expand Down Expand Up @@ -43,6 +45,7 @@ module.exports = {
// Main suite: all tests except the test/features folder
{
displayName: "main",
transform,
testPathIgnorePatterns: [
"<rootDir>/node_modules/",
"<rootDir>/test/features/",
Expand All @@ -52,6 +55,7 @@ module.exports = {
// Feature suites: one project per OPTIONS_MATRIX entry
...OPTIONS_MATRIX.map(({ displayName, OPTIONS }) => ({
displayName: `features:${displayName}`,
transform,
testMatch: ["<rootDir>/test/features/**/*.test.ts?(x)"],
globals: { OPTIONS },
})),
Expand Down
30 changes: 13 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"name": "js-confuser",
"version": "2.1.2",
"description": "JavaScript Obfuscation Tool.",
"main": "dist/index.js",
"types": "index.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc --noEmit && babel src --out-dir dist --extensions \".ts,.tsx\"",
"dev": "node babel.register.js",
"build": "npm run typecheck && tsdown",
"dev": "tsx dev.ts",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
"test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --coverageReporters=html",
"typecheck": "tsc --noEmit",
"prepublishOnly": "npm run typecheck && npm run test && npm run build"
"prepublishOnly": "npm run test && npm run build"
},
"keywords": [
"obfuscator",
Expand All @@ -30,24 +30,20 @@
"lz-string": "^1.5.0"
},
"devDependencies": {
"@babel/cli": "^7.24.8",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.24.7",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/preset-env": "^7.25.3",
"@babel/preset-typescript": "^7.24.7",
"@babel/register": "^7.24.6",
"@eslint/js": "^9.9.0",
"@types/babel__core": "^7.20.5",
"@types/jest": "^29.5.14",
"@types/jest": "^30.0.0",
"@types/node": "^22.2.0",
"babel-plugin-replace-import-extension": "^1.1.5",
"cross-env": "^10.1.0",
"globals": "^15.9.0",
"jest": "^29.7.0",
"jest": "^30.4.2",
"ts-jest": "^29.4.11",
"tsdown": "^0.22.2",
"tsx": "^4.22.4",
"typescript": "^5.5.4",
"typescript-eslint": "^8.1.0"
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "https://github.com/MichaelXF/js-confuser"
Expand Down
4 changes: 2 additions & 2 deletions test/code/AES.test.js → test/code/AES.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync } from "fs";
import { readFileSync } from "fs";
import { join } from "path";
import JsConfuser from "../../src/index";
import { ok } from "assert";
Expand All @@ -21,7 +21,7 @@ test("Variant #1: AES-JS on 'High' Preset", async () => {
eval(code);

// Module.exports is now AES-JS
var aesjs = module.exports;
var aesjs = module.exports as Record<string, any>;

// Ensure that the module is properly loaded
expect(typeof aesjs).toStrictEqual("object");
Expand Down
6 changes: 3 additions & 3 deletions test/code/ES6.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync } from "fs";
import { readFileSync } from "fs";
import { join } from "path";
import JsConfuser from "../../src/index";

Expand Down Expand Up @@ -38,7 +38,7 @@ test("Variant #1: ES6 code on High Preset", async () => {
preserveFunctionLength: true,
});

const TEST_OUTPUT = {};
let TEST_OUTPUT = {};
eval(code);
expect(TEST_OUTPUT).toStrictEqual(EXPECTED_RESULT);
});
Expand All @@ -61,7 +61,7 @@ test("Variant #2: ES6 code on High Preset + RGF + Self Defending + Tamper Protec
// let newCode = `var TEST_OUTPUT;\n${code}\n\nconsole.log(TEST_OUTPUT);`;
// writeFileSync("./dev.output.js", newCode, "utf-8");

const TEST_OUTPUT = {};
let TEST_OUTPUT = {};
eval(code);
expect(TEST_OUTPUT).toStrictEqual(EXPECTED_RESULT);
});
8 changes: 3 additions & 5 deletions test/code/StrictMode.test.js → test/code/StrictMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { readFileSync } from "fs";
import { join } from "path";
import JsConfuser from "../../src/index";

var StrictMode_JS = readFileSync(
const StrictMode_JS = readFileSync(
join(__dirname, "./StrictMode.src.js"),
"utf-8"
);

test("Variant #1: StrictMode on High Preset", async () => {
var { code: output } = await JsConfuser.obfuscate(StrictMode_JS, {
const { code: output } = await JsConfuser.obfuscate(StrictMode_JS, {
target: "node",
preset: "high",
pack: true,
Expand All @@ -18,9 +18,7 @@ test("Variant #1: StrictMode on High Preset", async () => {
globalConcealing: (globalName) => globalName != "TEST_OUTPUT",
});

//writeFileSync("./dev.output.js", output);

var TEST_OUTPUT = {};
const TEST_OUTPUT = {} as Record<string, any>;

eval(output);

Expand Down
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"target": "esnext",
"module": "nodenext",
"outDir": "./dist",
"rootDir": "./",
"strict": false,
"noEmit": true,
"types": ["node", "jest"],
"allowImportingTsExtensions": true
}
"allowImportingTsExtensions": true,
"isolatedModules": true
},
"include": ["./src/**/*"]
}
7 changes: 7 additions & 0 deletions tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = require("tsdown").defineConfig({
format: ["cjs"],
outExtensions: () => ({ js: ".js" }),
outputOptions: {
exports: "named",
},
});
Loading