Access Native Resources in Electron App - electron

I'm currently evaluating Electron for an upcoming project. Perhaps my question is trivial for someone who has used Electron. However, I can't find the answer in the documentation or maybe don't fully grasp the concept.
I want to have a web app that users can access with a browser if they choose or from a native app, if they want to use a USB device (in this case, a credit card reader) attached to their pc. So, the main.js file would open the remote web app like so
win = new BrowserWindow({width: 800, height: 600})
// and load the index.html of the app.
win.loadURL('http://www.example.com/login.html')
Is there any difference in being able to access local resources (files, ports, etc, if the page is remote vs local? In other words, can you still access the USB ports from a remotely hosted web app wrapped by Electron the same as if the files were local, as in the case of an installed native Electron app? I would think it would load a remote page the same as a local but not sure if ipc would still work.

To access native resources on devices you'll need to be running an electron BrowserWindow with nodeIntegration enabled. This is the default but there are big security implications when loading content from the web into a node enabled BrowserWindow. If you're site is compromised through XSS, all your clients PC's will be open to remote code execution.
For that reason you should build a backend service with your API and then host a front end on a website and a distributed version in your app. You can still build the two from the same code.

Related

electron app limited by browser connection limit

We are thinking of building electron app for uploading files using aws node sdk. Completely new to electron. We want to utilize node sdk multi part feature. My question is will number of multipart connections limited by max number of connections browser can make? I know electron is not browser but container, wanted to get sense before venturing into it.

I want to block electron app from communicating with outside world

I've developed an electron application and packaged it for windows x32. It's a standalone desktop app, and I want to make sure it doesn't communicate with the outside world. When I launch the compiled application for the first time, I get a prompt message asking me if I'd like to "Allow incoming network connections"
If i say no, I believe the app doesn't run properly as it will be added to my firewall's blacklist. Any advice on what the proper practices for achieving this are?
I want to block any incoming/outgoing traffic to/from my electron app, while ensuring tit runs smoothly.
by allowing incoming connection ,you may get trouble .as you have the Proper firewall to prevent it and you proceed

Can I use OpenCV with a web app?

I want to control my app using hand gestures. For various reasons I have chosen to make a web based app.
Is it possible to control/interact with a web app with OpenCV (or any other program) running as an agent on the client, communicating directly with the page on the client rather than with the server?
The web app doesn't have to be in a common browser, it can be something like Qt WebKit. I am ok requiring the user to have an agent on their computer.
The server is not running locally!

Applications that require a web server for full functionality

Is it possible to deploy an iOS application that requires a Node.js socket to do something on a computer?
For example:
Application -> Node.js socket -> Doing something on a computer
Computer does his job -> Response from Node.js socket -> Processing data with application
I don't think that Apple allows this, but one of my friends is sure about it. My point is that this solution does not reflect to an easy usage instead of making it a little bit complicated for average users.
The answer is yes. I don't know how to integrate Node.js into app, but there are many other server that can be easily added to app, such as CocoaHTTPServer. I have created a project to manage files inside app sandbox. Open web page hosted by app to manage files. I know some other apps, which provide web page hosted by app to transfer media files.

iOS: filesharing without iTunes?

I develop an enterprise application for iOS and the user should be able to add files from the desktop to the application.
I implemented this using filesharing, which works great.
Now this company wants to get rid of iTunes from their machines (which is quite understandable, iTunes is a very invasive process).
The question is, is it still possible to somehow use filesharing without iTunes? maybe with another application?
Or what other way is there to send files to the app (preferrably without the need of an internet connection)
//edit: must work on windows 7 and must not require to install iTunes (there are some other tools that allow access to the iPad filesystem, but they go through drivers installed by iTunes)
You could exchange data via the local wireless network (a connection to the internet is not required, just the iOS device and the Windows computer need to be on the same network).
One option:
You can then create a simple TCP/IP connection over sockets between an iOS app and a Windows application and exchange the data you want.
However you probably need to implement a suitable simple Windows application to do this.
An other, maybe simpler, solution:
You could start a webserver in your iOS-App and show it's IP on the screen. By entering this IP in a browser on the desktop computer you can access websites on the iOS device, which can make documents available for download or receive uploads.
For how to do this, have a look at this question.
There are a number of ways to achieve this, ranging from trivial to sophisticated.
Your question says that you would prefer to avoid an internet connection. Simple solutions may require it - if you want to abstract the difficult parts, you're going to have to let somebody do the dirty work, and that's probably going to be someone(thing) on the internet. Midrange solutions may require a network but not internet connection. A sophisticated solution could probably be whatever you want - but one thing I would say, is that trying to tap into the USB connector is either going to result in a hacktastic or very complicated solution to implement.
One method would be to integrate a third party framework that basically does what your looking for. Look at the Dropbox development kit, for example - allowing Windows (or any platform) users to drop files on their desktops into a shared dropbox, and this can then be read by an iOS application which includes the iOS drobox API.
Another method would be to setup a simple WebDAV server in your office. Host it on a windows box, or a cheap linux box. Give users desktop's access to the share via whatever protocol you want (eg, Windows File Sharing). Then you'd implement a WebDAV client in your app (eg, WTClient) to pull files.
Finally, you could build your own transmission system. A sophisticated example might involve Bonjour and TCP/IP, a simpler-but-custom solution may involve a simple JSON web service running off a local (or remote) server.
I have suggestion but that will require the Internet. I would suggest you to use the DropBox API in the windows and iPhone both. It's awesome to use and very simple for file sharing.
Now a days everybody have dropbox account and have files in it to share. So that shouldn't cost anything other than a bit of implementation (this learning can also be used in other file sharing applications).
Here are some guidance:
iOS
REST API
You can add apps and documents to USB-connected devices with the Apple Configurator
You may use a simple Ftp server installed on PC, so you can connect to server from Ios and upload/download files from iOS to PC....
http://developer.apple.com/library/ios/#documentation/Networking/Conceptual/CFNetwork/CFFTPTasks/CFFTPTasks.html
All work is done by Pc and your app will use IP (Intranet or Internet) of PC to share all files.
From Ios you can read all files in FTP server and work with them.
I use the FileBrowser app to get access to network shares over WiFi and will allow you to load supported files to the device. The company responsible is creating an API to allow you to do this within your own app: https://twitter.com/#!/Stratospherix/status/193114857271336960

Resources