How can I access to USB stick from website? - javascript

I'm planning to make a login system by USB, so if you put in a USB-drive and open a specific webpage, the website asks the USB-drive for the code (e.g. by a JavaScript file, a redirect or something like that).
The problem is, because of sandboxing, you can't load or redirect to local files. I don't know a solution for this problem. Can you guys help me? I don't need specific code, just an example or something in that way.

Maybe you can read up on USB-HID. Wikipedia:
The USB human interface device class (USB HID class) is a part of the USB specification for computer peripherals: it specifies a device class (a type of computer hardware) for human interface devices such as keyboards, mice, game controllers and alphanumeric display devices.
Here are some references:
USB HID (Human Interface Device)
node-hid - Access USB HID devices from node.js
DepthJS: 'Allows any web page to interact with the Microsoft Kinect using Javascript'.
A related Stackoverflow question:
Write data to USB HID using Javascript, HTML5, or any cross platform language (supports Android)

One other possibility is to check out the Chrome HID (Human Interface Device) APIs:
Interacting with USB HID devices from web apps – via Chrome Apps, see below
Relevant Chrome API docs
Please note that for the time being, you cannot interact directly with the USB device (i.e. you cannot access any WebAPI offering that kind of fine-grained control).
Building a Chrome App (different from a Chrome Extension) may help; This article may point you in the right direction, since it also provides sample code.

The only way I can think of is putting a html file on the usb stick that essentially generates some sort of login token and gives you a link or a form to a login processor. You can then access the webpage by opening the local file first which will redirect you to the actual webpage.
This local script may include a javascript from the server to get some challenge-response-data which it hashes somehow (perhaps in combination with a password) and puts it into the form data.

Web PKI authentication from Modern Browsers may be achieved by using Browser Extension. One such extension is Signer.Digital browser extension. Use below Javascript promises from the APIs provided by Signer.Digital extension.
SignerDigital.getSelectedCertificate() to register user's certificate
SignerDigital.signHash(hash) to sign token at browser and verify at server
For all Javascript APIs refer to SO Answer https://stackoverflow.com/a/63173083/9659885

Disclaimer : I work for a company supporting the application below
Hello, you may try to use Nexu open-source application for communication with smartcards or USB tokens. It also support PKCS 12 keystores.
For example, the application is connected to the DSS webpage on the website of European Commission : see the link.

Related

How do i extract the number of windows open?

How do I detect the number of windows open on the screen?
Like for example, if I have chrome, visual studio, notepad open, I need to get the number of windows open as 3.
Is there a way to detect the number of windows open, specifically from a screen share or via javascript as the application is going to be an online exam taking website?
Websites are highly sandboxed programs. They don't communicate with the OS directly, only through Web APIs. If the feature you want is not available in the Web APIs, you cannot use it.
I don't know every Web API, but i don't think there's any that gives access to the number of open windows. The Screen Capture API looks promising, but I found no method that returns the number of open windows.
Also, even if there was, you would be trusting the user that he/she didn't modify your client (your client-side code), and I believe in this case you don't want to trust the user.

How can I send character to usb port?

Is there any way to send ASCII symbol/character to USB via webpage (HTML)?
We have a local PC with a webpage running in kiosk mode. The webpage have a button that should send that symbol/character to USB. How it can be done?
Thanks for any help.
No.
Code running in web pages is sandboxed and has no direct hardware access in general and definitely no direct USB access.
It may actually be possible, though only by using an experimental feature that's only available in some browsers.
More specifically, there exists a draft specification of the WebUSB API which aims to give access to USB devices from the browser, albeit with some limitations for security reasons. For instance, Chrome requires the page to be served over HTTPS.
This feature is currently implemented in newer versions of Chrome and, according to MDN, Opera.
There is some more information about it on Google's blog.
Question is:
Is there any way to send ASCII symbol/character to USB via webpage
(HTML)?
I don't know if Electron Apps is what you call a webpage, but it is to me. If Electron App enters your usecase, you can access the NodeJS API, and therefore your machine.
This could be the answer you are looking for, if the only limitation you have for your question is the use of web languages (HTML, CSS, Javascript). If your limitation is give access to the world through a classic web browser, as #Quentin sayed in his answer, it is not possible.
Thanks god it's not possible.

JavaScript - one link, all app stores, non-Safari detected

I'd like to have a single 'Get App' link that auto-detects the user's device type and browser and directs to the appropriate location (iTunes, Google Play, or website sign-up). I am currently using Onelink.to, but it has the following limitations:
if you're on iOS using a non-Safari browser (like Chrome) you end up looking at a bunch of raw JSON because it doesn't know to launch the App Store app. In this case, I'd prefer to direct to the iTunes website or better yet, deep link into the App Store app.
if using the link on your own site and a user is on a device that redirects to a different page of your own website, it complicates setting up event-based goals in Google Analytics
Are there any good JavaScript solutions that handle the App Store redirect while excluding this action on browsers that don't support the iTunes headers?
Thanks!
You can use javascript navigator.userAgent and parse it to detect the device. Then just generate the link according to it.
Here is an example for ios detection:
Detect if device is iOS

Capture web page data using native language code

I'm looking for leads on how to capture web page metadata from the current browser page. I want to create a feature in my application that will allow the user to press a hot key and record meta data from the web page currently open in the user's browser. My application will be running minimized, this feature is to be activated by a global hot key.
I'm using nw.js (formerly Node-Webkit) to create this application, so ideally, the solution would be javascript running in a desktop installation of Node.js. If this is not practical, I understand that I can call platform specific code from nw.js, so solutions developed in any desktop os language would be of interest.
My application targets OS X and Windows.
I'm hoping to capture metadata from all major modern browsers (Chrome, Firefox, Safari and IE 10+).
At a minimum I need to capture the page url, but I also want to capture Keywords, Description and highlighted text for the source web page.
I need to implement this function without modifying the source webpage in any way, and I prefer to avoid the need for browser extensions, bookmarklets or plugins.
If a solution exists using a remote controlled browser extension (no user interaction) that would be of interest, but ideally I want to avoid requiring the end user to install or interact with anything but my application.
My search to date has located no information on reading web page information from applications outside the browser.
Any thoughts or leads are much appreciated.

Get a tablets(iPad or Droid) mac address?

Synopsis: I am developing a HTML5 web app that will allow tablets(iPad or Droid) to login to a server and perform various functions. The client would like a way to check the devices mac address when logging in. From what I have read, most solutions use activex objects that will not work for webkit browsers.
Question: Does anyone know a solution that would hook into a HTML5 web app seamlessly(Idealy update a hidden form element with the value upon logging in)?
Thanks!
I don't think there's going to be a straightforward way to do this. The web server won't be exposed to a client's MAC address unless they're on the same physical segment...you'll only see the MAC from the most recent router hop in general.
If anything exists, it's going to be a browser plugin (show-stopper on iOS). And it would probably need more than the default permissions available (I don't suspect you can enumerate network interfaces in Java, for example, without asking for elevated permissions).
If you're looking for HTML/JS only then I don't think that this is possible. It won't be exposed.
The problem is that the packets you recieve back will only contain the MAC address of the node on the last hop.
This may be possible via a plugin, but then this limits you on iOS, and possibly also Android as you'd need to provide them a way of getting the plugin first (unless you used a plugin that was installed by default).
Edit: Not that I support an app for every little thing, but it shows that easy to press app buttons sometimes tend to do better than web apps (regardless of being able to make browser shortcuts to home screens). If it is suitable, you could consider loading this within a web view on the target device from within an app, from which you can then of course access MAC addresses and whatever else you may need.
MobiThinking: Mobile applications: native v Web apps – what are the pros and cons?
Forbes: Mobile Web App vs. Native App? It's Complicated

Categories