7

I am trying to package and distribute my app which is written in electron. I noticed that when the binaries build is completed, the local resource/source code are also exposed in the final built folder.

In the resource/app folder, you would have all your source code revealed to anyone who can access.

I am wondering if there's anyway to hide these information, and just deliver the built binary.

I am using Electron 1.2 and electron-packager 7.0.4

2 Answers 2

6

Beyond mini-/uglifying your js code (can still be viewed) and creating an .asar package (can be extracted) there is not a whole lot you can do to prevent the visibility of your code.

See also this post on the electron-packager github page:

theres nothing built in to electron to do that, so we don't support anything like that (since we only support what electron supports). you would have to implement that in your own module and run it on your code before using electron-packager -maxogden

Sign up to request clarification or add additional context in comments.

5 Comments

Sorry, I am fairly new to javascript world, can you specify what kind implementation is necessary to hide the code ?
Sure: Electron-packager does not actually change your JS code. If you want to achieve some basic protection you need to run your code through a parser before you package your app. This can be done using, for example, the uglify-js package. You should keep in mind that the source code is still quite visible, but by replacing variables and compacting the code it is rendered rather inelligible. Given enough motivation and time, this can, however, still be reverse engineered.
I see, so it's still sort of revealed just not very explicit. Can you explain why the source code is usually revealed in java script type of application ?
Javascript is an interpreted language, see Wikipedia: An interpreted language is a programming language for which most of its implementations execute instructions directly, without previously compiling a program into machine-language instructions. The interpreter executes the program directly, translating each statement into a sequence of one or more subroutines already compiled into machine code.
You're welcome. If that answer fullfills your requirements, feel free to accept it :)
1

If 7 years have passed but are still looking for an answer, they can use @electron/asar. When creating an application with electron packager, it creates a file with an .asar extension that will store your code if you type "--asar" on the terminal screen. For example;

electron-packager . {your exe file name} --overwrite --asar --platform=win32 --arch=x64 --icon={your icon file source} --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName="product name"

2 Comments

Don't think asar help at all; it's just an archive format. Look at the project documentation: you can either pack or unpack. Anybody can look at the install path of an Electron app, locate the app.asar file and unpack it.
Is there any other way to hide the app files then ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.