Socket
Socket
Sign inDemoInstall

node-hid

Package Overview
Dependencies
59
Maintainers
5
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.2 to 2.0.0-0

6

nodehid.js

@@ -19,3 +19,3 @@

if( !driverType || driverType === 'hidraw' ) {
binding = require('bindings')('HID-hidraw.node');
binding = require('bindings')('HID_hidraw.node');
} else {

@@ -59,4 +59,3 @@ binding = require('bindings')('HID.node');

for(var i in binding.HID.prototype)
if(i != "close" && i != "read")
this[i] = binding.HID.prototype[i].bind(this._raw);
this[i] = binding.HID.prototype[i].bind(this._raw);

@@ -137,2 +136,1 @@ /* We are now done inheriting from `binding.HID` and EventEmitter.

exports.setDriverType = setDriverType;
// exports.devices = binding.devices;
{
"name": "node-hid",
"description": "USB HID device access library",
"version": "1.3.2",
"version": "2.0.0-0",
"author": "Hans Hübner <hans.huebner@gmail.com> (https://github.com/hanshuebner)",

@@ -10,3 +10,4 @@ "bugs": "https://github.com/node-hid/node-hid/issues",

"Blake Miner <miner.blake@gmail.com>",
"Tod Kurt <todbotdotcom@gmail.com> (https://github.com/todbot)"
"Tod Kurt <todbotdotcom@gmail.com> (https://github.com/todbot)",
"Julian Waller <git@julusian.co.uk> (https://github.com/julusian)"
],

@@ -21,5 +22,5 @@ "repository": {

"prepublishOnly": "git submodule update --init",
"install": "prebuild-install || node-gyp rebuild",
"prebuild": "prebuild --all --verbose --include-regex \"HID.*node$\"",
"prebuild-upload": "prebuild --upload-all",
"install": "prebuild-install --runtime napi || node-gyp rebuild",
"prebuild": "prebuild --runtime napi --all --verbose --include-regex \"HID.*node$\"",
"prebuild-upload": "prebuild --runtime napi --upload-all",
"prebuild-ci": "prebuild-ci",

@@ -37,4 +38,9 @@ "gypclean": "node-gyp clean",

"main": "./nodehid.js",
"binary": {
"napi_versions": [
3
]
},
"engines": {
"node": ">=6.0.0"
"node": ">=10"
},

@@ -44,4 +50,3 @@ "license": "(MIT OR X11)",

"bindings": "^1.5.0",
"nan": "^2.14.0",
"node-abi": "^2.19.3",
"node-addon-api": "^3.0.2",
"prebuild-install": "^6.0.0"

@@ -48,0 +53,0 @@ },

How to publish node-hid
========================
### newer way (in short) ###
First, make sure version is bumped to new version. (if code change)
1. First, make sure version is bumped to new version. (if code change)
Then, on each of MacOSX, Windows, Linux, do:
2. Then, on each of MacOS, Windows, Linux, do:
```

@@ -19,3 +18,4 @@ git clone https://github.com/node-hid/node-hid.git

```
And then on master dev box:
3. And then on master dev box:
```

@@ -26,21 +26,5 @@ npm run clean # clean out directory

remember for Windows
```
$env:PYTHON = "$env:USERPROFILE\.windows-build-tools\python27\python.exe"
```
#### Misc Notes (may be obviated in move to N-API)####
#### notes ####
- To check node ABI version (used by `node-abi`), check the NODE_MODULE_VERSION
on this page:
https://nodejs.org/en/download/releases/
If a prebuild is not generated for a particular version of Node or Electron,
then `node-abi` needs to be updated
- You can also grep for NODE_MODULE_VERSION in `node_version.h` in any version
of Node and Electron you've installed node-hid with:
`grep NODE_MODULE_VERSION ~/.node-gyp/*/include/node/node_version.h`
and
`grep NODE_MODULE_VERSION ~/.electron-gyp/*/include/node/node_version.h |grep define`
- As of Node v10 on Windows, may need to do:

@@ -50,135 +34,6 @@ -- `$env:Path += ";C:\Program Files\Git\mingw64\libexec\git-core

#### old way ###
1. Merge all changes and new features into master
2. Bump up npm version in `package.json`
3. Update the `README.md` to reference this current version (if needed)
4. Commit then generate new tags based on package.json version number
with e.g. `git tag v0.5.4 -a` and include the change log in the tag's annotation.
5. Push tags to Github with `git push --tags`
6. Watch Travis and Appveyor CI builds
7. Publish to npm after builds finish. Builds can take half an hour and occasionally fail for seemingly no reason. Restart any failures in the travis or appeveyor ui. While you wait, remove the content of the Github release message so the tag's text shows. When the entire matrix succeeds and all binaries exist run `npm publish`.
## Config Travis, AppVeyor and Github to generate all of the binaries.
Before we are able to run everything stated above some steps need to be taken. Specifically for being able to publish the pre compiled binaries to Github. The correct keys need to be setup in the `travis.yml` and `appveyor.yml` files. For Travis, this needs to be done by the admin of the Github repo. For AppVeyor, this will need to be done by the owner of the AppVeyor account.
### Setting up secure keys in Travis.
Setting up the keys in Travis is easy if you have Ruby and Rubygems installed and working then run:
`gem install travis`
After the Travis gem is installed run the following command for each of the required keys:
`travis encrypt SOMEVAR=secretvalue`
And substitute the values in the `.travis.yml` file for the new ones. Detailed instructions can
be found here: http://docs.travis-ci.com/user/environment-variables/#Secure-Variables
### Setting up secure keys in AppVeyor
It is even easier than Travis to configure AppVeyor. You do not need to install anything, just go to your account and click on `encrypt tool`. Enter the values in the input field and click "Encrypt". In the same way as we do for Travis, we then need to substitute the newly generated values for the old ones.
Detailed instructions can be found here: http://www.appveyor.com/docs/build-configuration#secure-variables
-----
## Hand publish method using `node-pre-gyp-github`
* Install tools globally to make things easier:
- Remember for Windows to have Windows Build Tools and Python in PATH
(this note may be stale)
```
npm install -g node-pre-gyp
npm install -g node-pre-gyp-github
npm install -g rimraf
$env:PYTHON = "$env:USERPROFILE\.windows-build-tools\python27\python.exe"
```
* Checkout clean node-hid:
```
rm -rf node-hid
git clone https://github.com/node-hid/node-hid.git
cd node-hid
npm run prepublish
```
* Clean checkout before each build:
```
npm run clean
npm install
```
* Do simple sanity tests
```
node ./src/show-devices.js
node ./src/test-blink1.js
```
* Test out node-pre-gyp packaging and publish draft:
```
node-pre-gyp configure
node-pre-gyp build
node-pre-gyp package
node-pre-gyp-github publish
```
* Do the above for each version of node:
* v6.9.1 LTS
* v4.6.2 LTS
* v0.12.17
### Windows notes:
* Using nvm-windows, install each version of node needed (32-bit & 64-bit):
```
nvm install v0.12.7 32
nvm install v0.12.7 64
nvm install v4.6.2 32
nvm install v4.6.2 64
nvm install v6.9.1 32
nvm install v6.9.1 64
```
* Then, before each build:
```
nvm use v0.12.7 32
node install -g node-pre-gyp
node install -g node-pre-gyp-github
node install -g rimraf
npm run clean
npm install
```
## Old publish method
(cribbed from node-serialport)
## Setup for Linux, Windows and OSX
1. Merge all changes and new features into master.
2. Fill out changelog.md.
3. Bump up npm version *AND* binary host version in `package.json`, commit and push.
4. Update the README.md to reference this current version and to previous major version docs.
5. Generate new tags based on package.json version number with `git tag 4.0.0 -a` and include the change log in the tag's annotation.
6. Push tags to Github with `git push --tags`
7. Switch to node v0.12 and npm 2
8. `rm -rf node_modules build && npm install`
9. Publish to npm after builds finish. Builds can take half an hour and occasionally fail for seemingly no reason. Restart any failures in the travis or appeveyor ui. While you wait, remove the content of the Github release message so the tag's text shows. When the entire matrix succeeds and all binaries exist run `npm publish`.
Differences for beta release
* Tag like: `git tag 4.0.1-beta1 -a` and include the change log in the tag's annotation.
* Publish with `npm publish --tag beta`
## Binary Hand-publish Notes
* On Mac/Linux, have a ~/.node_pre_gyprc with Amazon AWS S3 accessKeyId & secretAccessKey
* On Windows, put that file in /c/Users/{username} when using MinGW
## Hand-publish steps
1. Pick node version (e.g. "nvm use v4" or "nodist use v4")
2. Update node-hid from master: `git pull`
3. Build: `npm install`
4. Package using node-pre-gyp: `npm run gyppackage`
5. Publish to AWS S3 using node-pre-gyp: `npm run gyppublish`
6. Clean up build products: `npm run clean`
# node-hid - Access USB HID devices from Node.js #
[![npm](https://img.shields.io/npm/dm/node-hid.svg?maxAge=2592000)](http://npmjs.com/package/node-hid)
[![Build Status](https://travis-ci.org/node-hid/node-hid.svg?branch=master)](https://travis-ci.org/node-hid/node-hid)
[![Build status](https://ci.appveyor.com/api/projects/status/sqgrud8yufx12dbt?svg=true)](https://ci.appveyor.com/project/todbot/node-hid/branch/master)
[![build macos](https://github.com/node-hid/node-hid/workflows/macos/badge.svg)](https://github.com/node-hid/node-hid/actions?query=workflow%3Amacos)
[![build windows](https://github.com/node-hid/node-hid/workflows/windows/badge.svg)](https://github.com/node-hid/node-hid/actions?query=workflow%3Awindows)
[![build linux](https://github.com/node-hid/node-hid/workflows/linux/badge.svg)](https://github.com/node-hid/node-hid/actions?query=workflow%3Alinux)

@@ -80,15 +81,15 @@ * [node-hid - Access USB HID devices from Node.js](#node-hid---access-usb-hid-devices-from-nodejs)

¹ prebuilt-binaries not provided for these platforms
² prebuilt binary built on Ubuntu 16.04 x64
² prebuilt binary built on Ubuntu 18.04 x64
### Supported Node versions ###
* Node v6 to
* Node v14 (but no v14 prebuilds yet due to `node-abi` bug)
* Node v8 to
* Node v14
### Supported Electron versions ###
* Electron v1 to
* Electron v10 (but no v10 prebuilds yet due to `node-abi` bug)
* Electron v3 to
* Electron v10
#### Any newer version of Electron or Node WILL NOT WORK
#### Any newer version of Electron or Node MAY NOT WORK
Native modules like `node-hid` require upstream dependencies to be updated to work with newer Node and Electron versions. Unless you need the features in the most recent Electron or Node, use a supported version.

@@ -99,3 +100,3 @@

For most "standard" use cases (node v4.x on mac, linux, windows on a x86 or x64 processor), `node-hid` will install nice and easy with a standard:
For most "standard" use cases (node v4.x on mac, linux, windows on a x86 or x64 processor), `node-hid` will install like a standard npm package:

@@ -115,10 +116,4 @@ ```

We are using [prebuild](https://github.com/mafintosh/prebuild) to compile and post binaries of the library for most common use cases (linux, mac, windows on standard processor platforms). If you are on a special case, `node-hid` will work, but it will compile the binary when you install.
We are using [prebuild](https://github.com/mafintosh/prebuild) to compile and post binaries of the library for most common use cases (Linux, MacOS, Windows on standard processor platforms). If a prebuild is not available, `node-hid` will work, but `npm install node-hid` will compile the binary when you install. For more details on compiler setup, see [Compling from source](#compiling-from-source) below.
If `node-hid` doesn't have a pre-built binary for your system
(e.g. Linux on Raspberry Pi),
`node-gyp` is used to compile `node-hid` locally. It will need the pre-requisites
listed in [Compling from source](#compiling-from-source) below.
## Examples

@@ -135,3 +130,3 @@

To try them out, run them like `node src/showdevices.js` from within the node-hid directory.
To try them out, run them with `node src/showdevices.js` from within the node-hid directory.

@@ -393,24 +388,2 @@ ----

### Selecting driver type
By default as of `node-hid@0.7.0`, the [hidraw](https://www.kernel.org/doc/Documentation/hid/hidraw.txt) driver is used to talk to HID devices. Before `node-hid@0.7.0`, the more older but less capable [libusb](http://libusb.info/) driver was used. With `hidraw` Linux apps can now see `usage` and `usagePage` attributes of devices.
If you would still like to use the `libusb` driver, then you can do either:
During runtime, you can use `HID.setDriverType('libusb')` immediately after require()-ing `node-hid`:
```js
var HID = require('node-hid');
HID.setDriverType('libusb');
```
If you must have the libusb version and cannot use `setDriverType()`,
you can install older node-hid or build from source:
```
npm install node-hid@0.5.7
```
or:
```
npm install node-hid --build-from-source --driver=libusb
```
### udev device permissions

@@ -443,6 +416,29 @@ Most Linux distros use `udev` to manage access to physical devices,

### Selecting driver type
By default as of `node-hid@0.7.0`, the [hidraw](https://www.kernel.org/doc/Documentation/hid/hidraw.txt) driver is used to talk to HID devices. Before `node-hid@0.7.0`, the more older but less capable [libusb](http://libusb.info/) driver was used. With `hidraw` Linux apps can now see `usage` and `usagePage` attributes of devices.
If you would still like to use the `libusb` driver, then you can do either:
During runtime, you can use `HID.setDriverType('libusb')` immediately after require()-ing `node-hid`:
```js
var HID = require('node-hid');
HID.setDriverType('libusb');
```
If you must have the libusb version and cannot use `setDriverType()`,
you can install older node-hid or build from source:
```
npm install node-hid@0.5.7
```
or:
```
npm install node-hid --build-from-source --driver=libusb
```
## Compiling from source
To compile & develop locally or if `prebuild` cannot download a pre-built
binary for you, you will need the following tools:
binary for you, you will need the following compiler tools and libraries:

@@ -546,4 +542,4 @@ ### Linux (kernel 2.6+) : (install examples shown for Debian/Ubuntu)

Examples of `node-hid` in Electron:
* [electron-hid-toy](https://github.com/todbot/electron-hid-toy) - a simple example of using `node-hid`, that will hopefully always track the latest Electron release
* [electron-hid-test](https://github.com/todbot/electron-hid-test) - even simpler example of using `node-hid`
* [electron-hid-test](https://github.com/todbot/electron-hid-test) - Simple example of using `node-hid`, should track latest Electron release
* [electron-hid-toy](https://github.com/todbot/electron-hid-toy) - Simple example of using `node-hid`, showing packaging and signing
* [Blink1Control2](https://github.com/todbot/Blink1Control2/) - a complete application, using webpack (e.g. see its [webpack-config.js](https://github.com/todbot/Blink1Control2/blob/master/webpack.config.js))

@@ -550,0 +546,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc