@ledgerhq/hw-transport-node-hid
Advanced tools
Comparing version 4.33.0 to 4.33.1
@@ -352,5 +352,7 @@ "use strict"; | ||
/** | ||
* if path is not provided, the library will take the first device | ||
*/ | ||
value: function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(path) { | ||
var device; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -360,5 +362,23 @@ while (1) { | ||
case 0: | ||
return _context.abrupt("return", Promise.resolve(new TransportNodeHid(path ? new _nodeHid2.default.HID(path) : new _nodeHid2.default.HID(0x2c97, 0x01)))); | ||
if (!path) { | ||
_context.next = 2; | ||
break; | ||
} | ||
case 1: | ||
return _context.abrupt("return", Promise.resolve(new TransportNodeHid(new _nodeHid2.default.HID(path)))); | ||
case 2: | ||
device = (0, _getDevices2.default)()[0]; | ||
if (device) { | ||
_context.next = 5; | ||
break; | ||
} | ||
throw new _hwTransport.TransportError("NoDevice", "NoDevice"); | ||
case 5: | ||
return _context.abrupt("return", Promise.resolve(new TransportNodeHid(device))); | ||
case 6: | ||
case "end": | ||
@@ -365,0 +385,0 @@ return _context.stop(); |
{ | ||
"name": "@ledgerhq/hw-transport-node-hid", | ||
"version": "4.33.0", | ||
"version": "4.33.1", | ||
"description": "Ledger Hardware Wallet Node implementation of the communication layer, using node-hid", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -40,3 +40,3 @@ //@flow | ||
*/ | ||
export default class TransportNodeHid extends Transport<string> { | ||
export default class TransportNodeHid extends Transport<?string> { | ||
device: HID.HID; | ||
@@ -123,7 +123,11 @@ ledgerTransport: boolean; | ||
/** | ||
* if path is not provided, the library will take the first device | ||
*/ | ||
static async open(path: string) { | ||
return Promise.resolve( | ||
new TransportNodeHid(path ? new HID.HID(path) : new HID.HID(0x2c97, 0x01)) | ||
); | ||
static async open(path: ?string) { | ||
if (path) { | ||
return Promise.resolve(new TransportNodeHid(new HID.HID(path))); | ||
} | ||
const device = getDevices()[0]; | ||
if (!device) throw new TransportError("NoDevice", "NoDevice"); | ||
return Promise.resolve(new TransportNodeHid(device)); | ||
} | ||
@@ -130,0 +134,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85130
1014