Using PNaCl with node.js? - node.js

Is there anyway to use PNaCl or just Google Native Client with node.js?

The V8 JavaScript engine can be configured to target NaCl and PNaCl (which node.js uses).
If you're trying to sandbox node.js outside of the browser then you may want to check out the Codius paper.
If you want to use node.js inside a PNaCl/NaCl process inside Chrome then you may want to look at other naclports and nacl_io: in general PNaCl/NaCl support POSIX interfaces but they have to conform to the Web model, for example you need to mount the html5 filesystem before being able to do the usual read/write calls. This should work for a regular web page (using PNaCl) or for a Chrome app or extension.
I recently wrote a few more details pertaining to porting PHP which may be helpful. If you do get it working, please let the naclports folks know, and if something breaks do let them know too!

Related

Nodejs and/or PHP mobile detection

Is there a good and reliable library or method, or whatever, that can detect if the request is coming from a mobile environment?
I found a few packages, but non seems to work properly. I am looking for a basic/simple one that is able to detect just this: isMobile; isDesktop. Needs to be reliable, up to date and working.
If there is none free, even payed solutions would be acceptable. I am not looking for 100% detection, but I expect that top most popular devices to be detected without problem.
I am looking for a nodejs (express) solution, and/or a PHP one.
For PHP you can use Mobile-detect. According to its official description in Github, Mobile_Detect is a lightweight PHP class for detecting mobile devices.
For node.js you can use mobile-detect.js. It's a port of Mobile-detect to javascript.
DeviceAtlas has a good article:
How to detect a mobile browser by Pawel Piejko.
They have examples with PHP, Java and Python and they have API to use. It is a a paid service but with free trial.
Mobile detection is a complicated problem. Of course it's easy to detect an iPhone with some client-side JavaScript, but mobile devices are not only iPhones or Android phones. And if you want to detect it before running client-side JavaScript like you need here then you cannot rely only on client-side JavaScript.
More options
General options:
WURFL, 51Degrees, OpenDDR, MobileESP, ua-parser, Detect Mobile Browsers.
Node modules:
mobile-detect,
device-detect,
detect-mobile-browser,
sniffr,
dagent,
device-detective,
ismobilejs.

How can I secure the source code of my Firefox OS application?

I have an app for Firefox OS, and I would not like to expose any of the source code, even obfuscated source. Is there currently any means to do this? Is this functionality even planned? Also, this app has ALL functionality implemented in the client, so "move the business logic to the server back-end" does not address this issue.
There is no real solution yet, since every web page exposes the JavaScript source code.
Why not trying obfuscate ?
Since JavaScript is executed on the client side, not only in Firefox OS but every other platform too. The possible options are limited to obfuscating with aforementioned transformations or hiding the application logic in server-side code.
You can read more about app source protection from Mozilla official blog here: https://hacks.mozilla.org/2013/12/protecting-your-firefox-os-app-code/
You could write your application logic in C/C++ and protect it by encryption libraries and convert them into JavaScript using, Mozilla’s Emscripten tool which compiles C and C++ to JavaScript: https://github.com/kripken/emscripten/wiki
You're asking "how do I give someone something, and simultaneously take it away?" You can't. This issue hasn't been solved with JS, and neither with native code.

Embed node.js website in exe

I want to build desktop application that will use node.js and express to "render" the gui in a browser.
Since the client will have access to my application, is there any easy method to embed everything in my exe ?
I don't like the idea of having so many folders in my application folder, this makes it easy for everyone to modify and steal the source code.
The two popular solutions for delivering web-based cross-platform applications are:
NW.js
Electron
I prefer NW.js because it has better backward compatibility, particularly on OS X. They have different feature sets, so you may want to play around with both to see which one meets your needs.

Is it possible to develop Google Chrome extensions using node.js?

I'd like to start developing Google Chrome extension using node.js (since I've already written a "text-to-song" script in node.js, and I'd like to turn it into a Chrome extension.) What would be the most straightforward way of approaching this problem?
Actually it is. Look at this Developers Live-cast. This is something I've been looking for as well, and this would help you.
This brings your node applications bundled to your browser.
Here is the repo!
EDIT:
I've noticed that this old answer of mine keeps getting upvotes now and then (thank you all).
But nowadays I'm more an advocate of using web apps instead of bundling your application into many platforms like the chrome store or whatever.
You can check the google's post here and here indicating some directions.
In practice I advise for you to start building a progressive web app (PWA) with offline capabilities using service worker and progressive stuff.
There are plenty of resources around the web nowadays and you can offer a much richer application that may achieve a much broader audience if you do it the right way.
Thanks again, and good coding.
Simple answer is NO, unless you can find a way to install node.js with an extension using NPAPI.
Nodejs and a Google Chrome Extension do have a couple things in common i.e they both understand javascript and they both use the v8 javascript engine.
Google Chrome Extension
"Google Chrome Extensions are small software programs that can modify and enhance the functionality of the Chrome browser".
To develop a Google Chrome Extension you should write some javascript and or html/css.
Then you can run the extension in your browser.
If you wish for others to download your extension you will have to provide config.json file that describes you extension sets permissions etc.
Nodejs
"Node.js is a platform built on Google Chrome's JavaScript runtime for easily building fast, scalable network applications".
To develop applications in nodejs you write some javascript and or html/css for web applications.
If wish for others to use you application you start you nodejs server and listen for incoming requests.
Summary
Despite some of the similarities a Google Chrome Extension and Nodejs have nothing to with each other. You cannot use them together in some special way outside of the normal client/server communication.
You can use a WebPack (GitHub) or Browserify (see handbook) to build web-browser extension based on the node.js code.
With Browserify, to convert your code, you can simply run:
browserify node-code.js -o node-code-out.js
Read more:
Browserify vs Webpack.
Build a Chrome Extension with Preact and Webpack (see: Preact Chrome Extension Starter).

Olark like software in node.js needed

Do you know any node.js application that do something similar to http://olark.com. Not necessarily for multiple website, I just need it for single domain.
I just want to install it myself on heroku and run chat customer support for my website on it.
Thanks,
Michal
Try out opensource-olark. I built it for my own use - it may be useful to you. It is not entirely based on Nodejs. But it works exactly like Olark. It uses strophe.js - A xmpp push based library for jabber which works with BOSH
try http://www.vivocha.com, based on node.js
It's very symple to use and you can integrate with other applications via API (with CRMs and ticketing systems for exemple).
This platform, with only one line of code on your website, allow you to configure all the widgets, without other tech skills needed.
And also, you can adding voice on your website, so you can call with your visitors directly on your web pages.
There are open source tools that you can check out like :
http://nowjs.com
http://www.socketstream.org
They allow you to incorporate realtime features into your nodejs app & you can probably have a very simplified olark-type app in just a couple lines of code.

Resources