Possible to stream desktop in a webapp using webrtc - javascript

Is it possible to stream the Desktop Information using webrtc in a webapplication. Would an application like that be a security issue if that is possible, currently we built an application which can stream using the Webcam with webrtc. But I have no real idea of how to stream the actual Desktop of the Computer to someone, I only know of native application like Skype or TeamViewer which can do something like this, but a webapplication?

Yes it's possible. To stream the user's desktop instead of their camera, replace
const stream = await navigator.mediaDevices.getUserMedia({video: true});
with
const stream = await navigator.mediaDevices.getDisplayMedia({video: true});
This will prompt the user to share an application window or desktop surface of their choice.
Note that browser support is limited at the moment. getDisplayMedia is implemented in Chrome 72, Firefox 66, Edge 17, and behind a flag in Safari 11.
It is also available using the adapter.js polyfill on older versions of Firefox and Chrome, though this requires installing a web extension in Chrome.
Would an application like that be a security issue
Yes, there are significant security issues related to screen sharing.
The obvious risk of letting a web site record your desktop is it may reveal private information.
A nonobvious risk is that sharing your browser or the entire desktop when your browser is visible on it, is dangerous, and should only be done with sites you trust.
This is because a malicious web site present on such web surfaces may effectively browse on your behalf and record the results, circumventing important cross-origin protections in the browser.

Related

How to work around lack WebRTC support in a browser?

Some browsers (mobile Mi Browser, for instance) don't support WebRTC - they have no RTCPeerConnection API. So the users of your WebRTC web app have to open it in another one.
Is there a way to make your WebRTC app work without an explicit browser-change action from the user, especially on a mobile device?
I tried to investigate the following:
Deep Link. Looks like we can't redirect the user to another browser using deep link (I haven't found Chrome deep link for mobile).
Send WebRTC sources to browser / use third-party WebRTC lib. This won't work either, you need WebRTC support in the browser source code.
WebRTC is a framework based on a set of standards. It includes not only capability to get information about user input/output devices, but also set of network protocols which based on UDP (from getting client's IP to transfer arbitrary data through data channel using SCTP protocol). So, as you already may guess, it's impossible to support in a browser which doesn't have it, this is why point (2) will not work.
In case of point (1 - Open Chrome). On iOS exists custom protocol to open URL in chrome "googlechromes://stackoverflow.com", but it's better to explicitly say user that current browser doesn't support required functionality; And provide links on list of popular browsers for download (Chrome, Firefox, etc.); And already on these websites user will be redirected to the proper store for downloading native app.

Browser Awareness of Bluetooth Beacons / iBeacons

Is there a way to make a browser aware of iBeacon devices in its proximity?
Similar to the way HTML5 Geolocation is working...
If not would this be something that can be achieved with a browser plug-in that can provide the detail to be consumed by javascript?
Unfortunately, no. No web browsers have implemented any bridges between beacon detection and JavaScript.
I don't think a plugin approach is possible on mobile browsers (either iOS or Android), because neither browser supports asynchronous communication between external apps and JavaScript in Mobile Safari / Mobile Chrome. The best you could do is have a custom app that responds to a beacon, then launches a web page in the browser. But I realize that isn't what you are asking for.
If you want to build a native app with JavaScript, you can use Cordova (aka PhoneGap) and use plugins that provide beacon support. My company has one for our ProximityKit beacon framework:
https://github.com/RadiusNetworks/proximitykit-plugin-cordova
There is also a Cordova plugin that has basic beacon support here:
https://github.com/petermetz/cordova-plugin-ibeacon
This looks promising (2016), Google Chrome developers site showing a desktop browser feature as a work in progress.
https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web?hl=en
Even though the Web Bluetooth API specification is not finalized yet,
the Chrome Team is actively looking for enthusiastic developers (I
mean you) to try out this work-in-progress API and give feedback on
the spec and feedback on the implementation.
Web Bluetooth API is currently available to be enabled experimentally
on your origin in Origin Trials, or locally on your machine using an
experimental flag. The implementation is partially complete and
currently available on Chrome OS, Chrome for Android M, Linux, and
Mac.
Go to chrome://flags/#enable-web-bluetooth, enable the highlighted
flag, restart Chrome and you should be able to scan for and connect to
nearby Bluetooth devices, read/write Bluetooth characteristics,
receive GATT Notifications and know when a Bluetooth device gets
disconnected.
https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md
There's a W3C specification for this Web Bluetooth, but there's no support yet: http://caniuse.com/#search=bluetooth.
If you decide to write a Phonegap plugin implementing this spec will be a good starting point.

HTML5 Video Not Working, IE11

I am in Windows Server 2012. I uploaded a site that works fine in my laptop, but has problems when I test it on the server's IE 11.0.9600.16384.
I have this code to insert html5 videos in the site
document.getElementById("videogal").innerHTML=' ';
elemv.src=mplv[0];
document.getElementById("videogal").appendChild(elemv);
videogal is a div
elemv is a global var:
var elemv = document.createElement("video");
mplv is an array that contains literals, such as "myFolder/myvideo.mp4".
As I said, it works fine in my laptop, but not in server's IE. IE's console says Not Implemented and marks this line elemv.src=mplv[0];
I dont know how to handle that. I alert the mplv[0] and has the proper value.
Most important: will this bug appear in client's browsers also? Or is just locally on server. I connect to the server as Admin and have turned off all the security restrictions of the IE.
Windows Server does not by default include certain "desktop" functionality, which includes the ability to play HTML5 video in Internet Explorer. Typically you wouldn't want users using server resources to play video. The "Desktop Experience" feature can be installed to add that functionality.
Installing this has no bearing on another machine's ability to play video served from this server. Other browsers (e.g. Chrome) running on the server have their own capability to play video and are unaffected by this feature being installed or not.

Write data to USB HID using JavaScript, HTML5, or any cross platform language (supports Android)

I've written an UI in HTML5 and JavaScript. I chose this implementation so that I could share the same code between both Android Chrome and Windows 8 RT.
Now, my next objective is to write data to a USB HID. The device that I'm communicating with is treated as an HID. I'm mentioning this part in case there's a way to write to an HID device rather than a USB RAW device.
I've done a lot of research on the matter. But, the HTML5 specifications are changing so often that maybe I missed something.
**Anyway, is there a language or implementation that I can use to share common code to access a USB device on Android and Windows 8 RT?
If there isn't a way to share between the two, how about a suggestion to get USB communication only on Android?**
Below is my research along with conclusions:
Silverlight: unsupported. In terms of web plugins, it is not supported on Windows 8 RT or Android
Flash: Possible option. It is supported in both operating systems, although they removed support for Android with release of Android 4.1 (Jelly Bean).
HTML5: unsupported
I looked at the GamePad API, but it seems to only support reading from a gamepad.
I looked at Device tag, but this tag no longer exists in the current draft. I read that the "navigator" object replaces it in JavaScript, but it seems completely different. Also, Device only targets acquiring video and audio
JavaScript: unsupported. From my understanding, this is because it'd be a security risk.
Chrome Packaged App: unsupported. I am unsure about support in Windows 8 RT. But, it is not supported in Android Chrome, either.
A USB API exists that accomplishes exactly what I need, but the API is only available to a packaged app.
Java applet: unsupported. I am unsure about support in Windows 8 RT. But, it is not supported in Android Chrome, either.
There are many resources available regarding how to communicate with USB devices. However, since Java applets aren't supported on smartphones, this ends up being unsupported.
A couple of useful posts
How can I send and receive data to a serial port or USB port in ASP.NET?
Is accessing USB from a web application for cross browser cross OS possible at all?
Is that possible to provide a JavaScript API to control USB, LPT, and COM devices?
I've actually thought about how to do things similar to this...
Here's is one way sure way to do it if you have control over the computer which has the USB device attached:
Have the computer with the USB device run a web server such as Apache and PHP. Have it only listen to localhost.
Then in the HTML page being viewed, execute an Ajax post to localhost/somescript.php (or CGI or cfm or whatever).
In the PHP/CGI script, communicate to the USB device and then return a JSON string to the browser saying something happened.
Another approach is to use custom URL protocols. You create an executable and "install" it on the client computer along with your custom URL protocol.
Then you can invoke the executable from the browser using your custom URL protocol.
There is one more alternative Web Socket.Create a web socket server which will access the usb device in local system.
Connect your web server using Web Socket from Web Application.Web Socket has standard Api
You can do something like this
var host = "wss://localhost:25000/test";
Websokcet ws = new WebSocket(host);
You can create your web sokcet Server using RFC 6455
for older browser you can think of http server as well.
Please have a look at JSFS. It works similar to Chris_vr's approach and is already a working solution.
https://github.com/jsfsproject/jsfs.
It's free and licensed under GPL.
If the USB device you want to control is a barcode printer, you can use jZebra.
This is an applet which directly communicates to locally connected printers.
Writing to a serial port:
var writeSerial = function(str) {
chrome.serial.write(connectionId, str2ab(str), onWrite);
}
// Convert string to ArrayBuffer
var str2ab = function(str) {
var buf = new ArrayBuffer(str.length);
var bufView = new Uint8Array(buf);
for (var i=0; i<str.length; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
More is at http://developer.chrome.com/apps/app_hardware.html.

web application development with j2me

The main reason I'd like to use j2me is that one of its main advantages is that it can access the phone's resources through its various APIs. However, due to newer phones having web browsers like Safari, Opera, and Windows IE, it would be advantageous to build a web application so a user wouldn't have to download some software onto their phone. Is there a way I could build a web application that can also acquire resource information about the phone? Or maybe have j2me converted to Javascript (if that's even possible)?
You can make a link that would send an SMS, but other than that, there's no cross-platform api for accessing phone internals from browser, as far as I know.
So, if you've got to access phone's resources, you'll have to write a real app.
The webkit engine on recent Series60 phones has been given access to at least some phone resources.
Nokai calls it Web Runtime or WRT.
http://www.forum.nokia.com/Resources_and_Information/Documentation/

Categories