Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
libusb.h
only)Use npm to execute all installation steps:
npm install
Use node-gyp to compile the extension.
Please note that Windows support is incomplete and needs some work to pull it to the same level as on Linux and OSX. See issues #10 and #15 in github for discussion. Pull requests to improve Windows support would be welcome.
In the src/
directory, various JavaScript programs can be found
that talk to specific devices in some way. The show-devices.js
program can be used to display all HID devices in the system.
var HID = require('node-hid');
var devices = HID.devices()
devices will contain an array of objects, one for each HID device
available. Of particular interest are the vendorId
and
productId
, as they uniquely identify a device, and the
path
, which is needed to open a particular device.
Here is some sample output:
HID.devices();
[ { vendorId: 1452,
productId: 595,
path: 'USB_05ac_0253_0x100a148e0',
serialNumber: '',
manufacturer: 'Apple Inc.',
product: 'Apple Internal Keyboard / Trackpad',
release: 280,
interface: -1 },
{ vendorId: 1452,
productId: 595,
path: 'USB_05ac_0253_0x100a14e20',
serialNumber: '',
manufacturer: 'Apple Inc.',
product: 'Apple Internal Keyboard / Trackpad',
release: 280,
interface: -1 },
<and more>
Before a device can be read from or written to, it must be opened:
var device = new HID.HID(path);
device
will contain a handle to the device. The path
can
be determined by a prior HID.devices() call. If an error occurs
opening the device, an exception will be thrown.
Reading from a device is performed by registering a "data" event handler:
device.on("data", function(data) {});
You can also listen for errors like this:
device.on("error", function(err) {});
All reading is asynchronous.
Writing to a device is performed using the write call in a device handle. All writing is synchronous.
device.write([0x00, 0x01, 0x01, 0x05, 0xff, 0xff]);
I can only provide limited support, in particular for operating systems and devices that I don't know. Please use the node-hid Google Group for general support inquiries (node-hid@googlegroups.com).
var device = new HID.HID(path);
chunk
- Buffer - the data read from the deviceerror
- The error Object emitteddata
- the data to be synchronously written to the deviceCloses the device. Subsequent reads will raise an error.
Pauses reading and the emission of data
events.
This method will cause the HID device to resume emmitting data
events.
If no listeners are registered for the data
event, data will be lost.
When a data
event is registered for this HID device, this method will
be automatically called.
Low-level function call to initiate an asynchronous read from the device.
callback
is of the form callback(err, data)
FAQs
USB HID device access library
The npm package node-hid receives a total of 57,160 weekly downloads. As such, node-hid popularity was classified as popular.
We found that node-hid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.