How to Obfuscate Codes in Nuxt 3?

158 views Asked by At

I have a project that I coded with nuxt 3. I want to do Code Obfuscation, but I couldn't find a proper resource. There are .ts and .vue files in my project. Can you help me?

I couldn't try anything because I couldn't find a proper source.

2

There are 2 answers

1
Ian Andwati On

The development files are converted to js files eventually. Browsers can't parse .vue and .ts files but this doesn't stop users from reversing the process. Building the Nuxt app can minify the files. However, it's important to note that obfuscation doesn't provide complete security but can deter casual attempts to read or modify your code.

You can check out this org https://github.com/javascript-obfuscator it has some great obfuscation tools.

If possible, move sensitive logic or data manipulation to the server-side to reduce exposure of critical parts of your application.

1
snnsnn On

Obfuscation is the process of turning code into incomprehensible gibbrish that can not be understood directly but it does not truly protect your code as an experienced user still can decode your code. It is used as a means to protect javascript code from getting stolen but it will make your code run slow as it adds another layer of code processing.

https://www.npmjs.com/search?q=obfuscator

A better alternative would be shipping the sensitive code as a webassembly module because the code will be compiled to binary instructions, which is not impossible to study but harder to decifer.