🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@ledgerhq/hw-transport-node-hid

Package Overview
Dependencies
Maintainers
7
Versions
410
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ledgerhq/hw-transport-node-hid - npm Package Compare versions

Comparing version

to
4.7.6

4

flow-typed/npm/@ledgerhq/hw-transport_vx.x.x.js

@@ -1,3 +0,3 @@

// flow-typed signature: 734bbd1052919281b6413ee31a329928
// flow-typed version: <<STUB>>/@ledgerhq/hw-transport_v^4.7.0/flow_v0.68.0
// flow-typed signature: 6220112b7742ba854c727ef6735bb602
// flow-typed version: <<STUB>>/@ledgerhq/hw-transport_v^2.1.0/flow_v0.63.1

@@ -4,0 +4,0 @@ /**

@@ -7,5 +7,6 @@ "use strict";

exports.default = function (device) {
return device.vendorId === 0x2581 && device.productId === 0x3b7c || device.vendorId === 0x2c97;
// We check the usagePage on Win/OSX, and interface on Linux for get only HID device
exports.default = function (d) {
return (["win32", "darwin"].includes(process.platform) ? d.usagePage === 0xffa0 : d.interface === 0) && (d.vendorId === 0x2581 && d.productId === 0x3b7c || d.vendorId === 0x2c97);
};
//# sourceMappingURL=isLedgerDevice.js.map

@@ -30,17 +30,19 @@ "use strict";

events.setMaxListeners(0);
var timeoutDetection = void 0;
var listDevices = (0, _getDevices2.default)();
var flatDevice = function flatDevice(device) {
return device.path;
var flatDevice = function flatDevice(d) {
return d.path;
};
var getFlatDevices = function getFlatDevices() {
return [].concat((0, _toConsumableArray3.default)(new _set2.default((0, _getDevices2.default)().map(function (device) {
return flatDevice(device);
return [].concat((0, _toConsumableArray3.default)(new _set2.default((0, _getDevices2.default)().map(function (d) {
return flatDevice(d);
}))));
};
var getDeviceByPath = function getDeviceByPath(ids) {
return listDevices.find(function (device) {
return flatDevice(device) === ids;
var getDeviceByPaths = function getDeviceByPaths(paths) {
return listDevices.find(function (d) {
return paths.includes(flatDevice(d));
});

@@ -55,18 +57,18 @@ };

var addDevice = currentDevices.find(function (device) {
return !lastDevices.includes(device);
var newDevices = currentDevices.filter(function (d) {
return !lastDevices.includes(d);
});
var removeDevice = lastDevices.find(function (device) {
return !currentDevices.includes(device);
var removeDevices = lastDevices.filter(function (d) {
return !currentDevices.includes(d);
});
if (addDevice) {
if (newDevices.length > 0) {
listDevices = (0, _getDevices2.default)();
events.emit("add", getDeviceByPath(addDevice));
events.emit("add", getDeviceByPaths(newDevices));
}
if (removeDevice) {
events.emit("remove", getDeviceByPath(removeDevice));
listDevices = listDevices.filter(function (device) {
return flatDevice(device) !== removeDevice;
if (removeDevices.length > 0) {
events.emit("remove", getDeviceByPaths(removeDevices));
listDevices = listDevices.filter(function (d) {
return !removeDevices.includes(flatDevice(d));
});

@@ -73,0 +75,0 @@ }

{
"name": "@ledgerhq/hw-transport-node-hid",
"version": "4.7.3",
"version": "4.7.6",
"description": "Ledger Hardware Wallet Node implementation of the communication layer, using node-hid",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,3 +0,6 @@

export default device =>
(device.vendorId === 0x2581 && device.productId === 0x3b7c) ||
device.vendorId === 0x2c97;
// We check the usagePage on Win/OSX, and interface on Linux for get only HID device
export default d =>
(["win32", "darwin"].includes(process.platform)
? d.usagePage === 0xffa0
: d.interface === 0) &&
((d.vendorId === 0x2581 && d.productId === 0x3b7c) || d.vendorId === 0x2c97);

@@ -14,13 +14,15 @@ // @flow

events.setMaxListeners(0);
let timeoutDetection;
let listDevices = getDevices();
const flatDevice = device => device.path;
const flatDevice = d => d.path;
const getFlatDevices = () => [
...new Set(getDevices().map(device => flatDevice(device)))
...new Set(getDevices().map(d => flatDevice(d)))
];
const getDeviceByPath = ids =>
listDevices.find(device => flatDevice(device) === ids);
const getDeviceByPaths = paths =>
listDevices.find(d => paths.includes(flatDevice(d)));
let lastDevices = getFlatDevices();

@@ -32,18 +34,16 @@

const addDevice = currentDevices.find(
device => !lastDevices.includes(device)
const newDevices = currentDevices.filter(d => !lastDevices.includes(d));
const removeDevices = lastDevices.filter(
d => !currentDevices.includes(d)
);
const removeDevice = lastDevices.find(
device => !currentDevices.includes(device)
);
if (addDevice) {
if (newDevices.length > 0) {
listDevices = getDevices();
events.emit("add", getDeviceByPath(addDevice));
events.emit("add", getDeviceByPaths(newDevices));
}
if (removeDevice) {
events.emit("remove", getDeviceByPath(removeDevice));
if (removeDevices.length > 0) {
events.emit("remove", getDeviceByPaths(removeDevices));
listDevices = listDevices.filter(
device => flatDevice(device) !== removeDevice
d => !removeDevices.includes(flatDevice(d))
);

@@ -50,0 +50,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet