Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Properly using Electron

I want to get into Electron, and I have already started learning about it, however I don't think I quite understand how I am supposed to use it. From what I gathered, with Electron I am able to create cross-desktop applications (Chromium) with HTML, CSS and Javascript and do tasks in the background (NodeJS).

What confuses me is the following:

  • How am I supposed to use this with my server?

For example, I built a simple NodeJS application that uses Passport and a few other modules to create a login/registration system (with MongoDB). It has HTML files for logging in and registering.

I am not sure how to use this with my Electron app, as the matter of fact, I don't quite understand how to actually use Electron. Should I move all of my login/register application code to the Electron application, or should I use Electron to somehow connect to my login/registration application and load the websites?

  • If I were to move my code to my Electron app, would it cause security issues?
like image 867
Grim Reaper Avatar asked Nov 29 '17 16:11

Grim Reaper


People also ask

What can I do with Electron?

It's easier than you think. If you can build a website, you can build a desktop app. Electron is a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It takes care of the hard parts so you can focus on the core of your application.

Why should I use Electron?

Electron allows you to use JavaScript on the front end, just like a normal website. It also lets you use Node. js for accessing files and other system-related operations. Because Electron allows you to use JavaScript for everything, it has become popular as a way to make JavaScript desktop apps.

How do you use electrons in Python?

You can use python-shell to communicate between Python and Node. js/Electron. python-shell provides an easy way to run Python scripts from Node. js with basic and efficient inter-process communication and better error handling.


1 Answers

How am I supposed to use this with my server?

You need to think about separating the application as a stand-alone desktop app (that acts as a client-side application) vs the server for your API and backend logic which are hosted by a cloud provider.

By doing this, you can focus on the separation of concerns for the desktop (electron) application as well as ensuring servers (such as API, authentication, and other backend logic) are well optimised and serving as multiple workers of themselves.

If I were to move my code to my Electron app, would it cause security issues?

There are some security concerns with an Electron application development if you do not regularly update your Node version (such as memory buffer overflow attacks).

Another issue to consider is how the Electron community serves and resolves issues of permissions for the client-side app and the regular file permissions which are granted when the user installs your app.

As a developer, the onus is on you to ensure third-party libraries are not damaging the user's computer. (imagine installing a library dependency whose purpose is to maliciously delete the entire file system).

I built a simple NodeJS application that uses Passport and a few other modules to create a login/registration system

For authentication, you can serve responses from your API based on the client-side requests/Posts that you provide to the authentication service. You don't necessarily have to provide/install the authentication server into your Electron app, as this can be somewhat troublesome for the user to update, as well as it exposes your authentication service for others to reverse-engineer/crack.

like image 181
Denis Tsoi Avatar answered Sep 28 '22 03:09

Denis Tsoi