Securing Javascript (server side?) - javascript

We have a project with a lot of proprietary calculations which we would rather not have downloadbable. Unfortunately the project was developed using tools that render the project in Javascript.
Is there any way to take browser based Javascript and put it on a server-side application that will render the HTML for the browser?

Have you looked at NodeJs? https://nodejs.org/en/
It's server side javascript

Related

Electron GUI with C# backend

Use case
I've got an existing project developed in C# using WinForms with custom controls for the GUI. We are amazed by the approach to write GUIs using HTML/CSS/JS and we are looking for the best way to write a GUI for our desktop application using the above mentioned languages. We only need to support Windows devices.
My worries:
It doesn't take long to come across recommendations using electron-edge. While I am not so worried to get everything working, I am worried about:
Debugging my C# code (I still want to be able to start my whole application right from VS and debug it look I am used to it). I read that I would need to attach to the node.js application in order to debug my C# code afterwards. Since the whole program language is written in C# that sounds like a pain?
As far as I got edge will let it run as just one process. Can I consider the electron application as an own thread which would still run while my C# code is stuck somewhere?
My option:
I am still positive I want to write my desktop GUI with HTML/CSS/JS. What I considered instead of using electron-edge is writing an own electron application which does communicate with my C# backend using named pipes. I wonder if there are larger roadblocks why I wouldn't want to do this and use electron-edge instead?
My question:
I would like to get feedback for my two concerns mentioned above and I also would like to get input about my option to create the GUI as own electron process, so that I have two processes (GUI+Backend) when someone runs my application.
Electron.NET may be a option for you. You can write c# code with electron.
You can do it in many ways
1) COM. Create C# COM DLL. Create wrapper functions for the DLL using N-API (Native node module) or use FFI. You can access the functions from JS.
2) Create a .Net web server and include your functions as REST endpoints. From UI make http request to communicate (Clear separation of UI & BEnd)
You can checkout my github repo for a few alternatives to electron.
I think a most import question would be how your frontend interacts with the backend? Is there any notifications need push to the frontend?
WebSocket could be a good option for two ends communication.

Best way for implementing JavaScript lib in Java WebApplication

I am an Android developer and I am new to java web development, so please apologize if my thought is wrong. In our web app project we have to compare images (GIF/PNG/JPEG) and have to show the result.
We got a javascript lib (Resemble.js) which will compare the images and will give the result.
Please help on implementing this lib to my web app project. As its a js lib we can implement it only in front end right? If so is this a correct way? Because we have all other process in backend. Or else how to use a js lib in backend
Or let me know the best way in implementing the same. We are using React.js for front-end.
To execute javascript you need a javascript engine. A java virtual machine is not designed to run javascript so short answer is: You should use the Resemble.js into your front-end browser's engine (or into a back-end server that process javascript like Node.js).
Long answer: There are implementation of JavaScript written in Java that you could use (I don't konw if supports HTML). Take a look at: How can I run JavaScript code at server side Java code?

Use Java Library in Javascript

I am planning a project where I will develop bots for Agar.io by using the NEAT algorithm, which is implemented in Java (this is called ANJI). I will use the open-source Agar.io server called Ogar, which is implemented in Javascript. The Javascript implementation should communicate with the Java library to evolve the bots while the game is running, but I have no previous experience of how to make Java and Javascript communicate. I have considered using Rhino, but it does not seem like it is possible to use in a browser. So, are there any way to let a Javascript implementation like Ogar use a Java library?
using the Rhino / Nashorm is not relevant in this case and as for performance focus its should be much hard to run nodeJS based application via Java JS engine.
the Agar.io server is a NodeJS server that expose a WebSocket API and the client solution need to communicate this way.
Using spring websocket client for example
have you seen Agar.io-bot ? its seems like the way they implement the BOT is javascript browser extension and communicate via the browser.
In common, Javascript and Java library communicate using Rest and Json, Java provide Rest API and Javascript send Json request to this API.
This is list of java library: for developing Java Rest API and working with JSON. I recommend using RESTEasy.

Socket.io/Node.js & SCTP?

I am developing an web application that will use web sockets to dynamically update the website for the user. The idea is to have changes in the back-end engine be dynamically transmitted. In order to do that, I want to use a Node.js server as a link between the web browser and back-end engine. Unfortunately, Node.js/JavaScript does not support SCTP sockets, which is what the back-end engine is using. Can you think of any way around this? It would be a shame if I couldn't use Socket.io and would have to deploy my own Javascript plugin & Java websocket server.
You can write the SCTP part in C or C++ and then write an addon to make it available in Node.js. I am currently trying that for one of my projects using SCTP.
Of cource, this is not super elegant, not very portable and it is some extra work, but if you really want to use Node.js, this is one of the possible ways...

How to pass data from C++ application to Javascript

I'm developing a jQuery-based pivot table.
The goal is not a web app but a desktop-based application (C++). In my idea, data is retrieved by the application from the database, then passed to a html page and then showed through the pivot-table plugin.
There is no web server and the web page containing the plugin cannot access to the database.
So, how to pass data in an efficient way? I've seen other questions here on SO around this matter, but I think we're in a different scenario. Of course I can write the data in a txt/xml/js file, but I've experienced that for huge amounts of data, writing down files is costing a lot.
If you don't want to add support for the http protocol to your application, and you don't want to write to additional files, then IMO your best bet is to create a wrapping http server for your application. Then the javascript page can access the running wrapper which can talk to your "real" application.
You could create such a server relatively easily in python using the twisted framework, ruby using rails and the bundled webrick server, or the v8 Javascript engine node.js. (I'm sure there's dozens of other options out there too)
Which of there would be best for you will depend a lot on which languages you have experience with and what your deployment requirements are (supported OSes, existing installed applications, installation size, license terms on your software etc.)
Do you have a specific framework for your desktop app ? If you use Qt for the GUI, you can also integrate javascript quite easily.
http://efforts.embedded.ufcg.edu.br/qt/?p=84
You might be able to use named pipes to pass data to a static page.
It might also be better to just make your c++ program into a simple web server which opens a port, and have it generate the web page when the user goes to http://localhost:8080.

Categories

Resources