esbuild-javascript-obfuscator 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin/plugin.js +1 -2
- package/dist/tests/plugin.test.js +15 -3
- package/package.json +18 -1
package/dist/plugin/plugin.js
CHANGED
|
@@ -27,7 +27,6 @@ async function ObfuscateFile(pluginOptions, finalized, file) {
|
|
|
27
27
|
logger('obfusacting with no VM protection...');
|
|
28
28
|
const obfuscateResult = JsObf.obfuscate(new TextDecoder().decode(file.contents), pluginOptions.ObfuscatorOptions);
|
|
29
29
|
finalized.push({ fileName: file.path, outputCode: obfuscateResult.getObfuscatedCode().toString() });
|
|
30
|
-
console.log(finalized);
|
|
31
30
|
logger('obfuscation completed for file: ', file.path);
|
|
32
31
|
return true;
|
|
33
32
|
}
|
|
@@ -45,7 +44,7 @@ export function JSObfuscatorPlugin(options) {
|
|
|
45
44
|
return {
|
|
46
45
|
name: 'esbuild-javascript-obfuscator',
|
|
47
46
|
setup(build) {
|
|
48
|
-
if (build.initialOptions.write) {
|
|
47
|
+
if (build.initialOptions.write || build.initialOptions.write === undefined) {
|
|
49
48
|
throw new Error('esbuild-javascript-obfuscator plugin requires write: false in build options');
|
|
50
49
|
}
|
|
51
50
|
build.onEnd(async ({ errors, outputFiles }) => {
|
|
@@ -15,13 +15,15 @@ const ObfuscationOptions = {
|
|
|
15
15
|
ObfuscateAllFiles: false,
|
|
16
16
|
};
|
|
17
17
|
function CreateDummyFiles() {
|
|
18
|
+
function cleanup() {
|
|
19
|
+
fs.rmSync(path.join(__dirname, 'temp'), { recursive: true, force: true });
|
|
20
|
+
}
|
|
21
|
+
cleanup(); /* needs to be called incase other tests failed and left the temp folder behind */
|
|
18
22
|
fs.mkdirSync(path.join(__dirname, 'temp'));
|
|
19
23
|
fs.writeFileSync(path.join(__dirname, 'temp', 'index.ts'), `
|
|
20
24
|
console.log("Hello World")
|
|
21
25
|
`);
|
|
22
|
-
return
|
|
23
|
-
fs.rmSync(path.join(__dirname, 'temp'), { recursive: true, force: true });
|
|
24
|
-
};
|
|
26
|
+
return cleanup;
|
|
25
27
|
}
|
|
26
28
|
test('plugin should throw error when write: true', async () => {
|
|
27
29
|
const cleanup = CreateDummyFiles();
|
|
@@ -34,6 +36,16 @@ test('plugin should throw error when write: true', async () => {
|
|
|
34
36
|
})).rejects.toThrow(`esbuild-javascript-obfuscator plugin requires write: false in build options`);
|
|
35
37
|
cleanup();
|
|
36
38
|
});
|
|
39
|
+
test('plugin should throw error when write option is not provided', async () => {
|
|
40
|
+
const cleanup = CreateDummyFiles();
|
|
41
|
+
expect(esbuild.build({
|
|
42
|
+
entryPoints: [path.join(__dirname, 'temp', 'index.ts')],
|
|
43
|
+
bundle: true,
|
|
44
|
+
minify: true,
|
|
45
|
+
plugins: [JSObfuscatorPlugin(ObfuscationOptions)],
|
|
46
|
+
})).rejects.toThrow(`esbuild-javascript-obfuscator plugin requires write: false in build options`);
|
|
47
|
+
cleanup();
|
|
48
|
+
});
|
|
37
49
|
test('plugin should successfully obfuscate a single file', async () => {
|
|
38
50
|
const cleanup = CreateDummyFiles();
|
|
39
51
|
await esbuild.build({
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esbuild-javascript-obfuscator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "An esbuild plugin to obfuscate JavaScript code.",
|
|
5
|
+
|
|
5
6
|
"author": {
|
|
6
7
|
"name": "Patchix"
|
|
7
8
|
},
|
|
9
|
+
|
|
8
10
|
"license": "MIT",
|
|
11
|
+
|
|
9
12
|
"keywords": [
|
|
10
13
|
"esbuild",
|
|
11
14
|
"esbuild-plugin",
|
|
12
15
|
"javascript-obfuscator",
|
|
13
16
|
"obfuscator"
|
|
14
17
|
],
|
|
18
|
+
|
|
15
19
|
"type": "module",
|
|
16
20
|
"main": "./dist/index.js",
|
|
17
21
|
"module": "./dist/index.js",
|
|
@@ -19,6 +23,7 @@
|
|
|
19
23
|
"files": [
|
|
20
24
|
"dist"
|
|
21
25
|
],
|
|
26
|
+
|
|
22
27
|
"scripts": {
|
|
23
28
|
"clean": "rm -rf dist",
|
|
24
29
|
"build:js": "bun build ./src/index.ts --outdir ./dist --target node",
|
|
@@ -27,15 +32,27 @@
|
|
|
27
32
|
"prettier": "prettier --write .",
|
|
28
33
|
"prepublishOnly": "bun run build"
|
|
29
34
|
},
|
|
35
|
+
|
|
30
36
|
"dependencies": {
|
|
31
37
|
"esbuild": "^0.28.1",
|
|
32
38
|
"javascript-obfuscator": "^5.4.5"
|
|
33
39
|
},
|
|
40
|
+
|
|
34
41
|
"devDependencies": {
|
|
35
42
|
"@types/bun": "latest",
|
|
36
43
|
"prettier": "^3.9.4"
|
|
37
44
|
},
|
|
45
|
+
|
|
38
46
|
"peerDependencies": {
|
|
39
47
|
"typescript": "^5"
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
"repository": {
|
|
51
|
+
"url": "https://github.com/patchixgit/esbuild-javascript-obfuscator.git",
|
|
52
|
+
"type": "git"
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/patchixgit/esbuild-javascript-obfuscator/issues"
|
|
40
57
|
}
|
|
41
58
|
}
|