Socket
Socket
Sign inDemoInstall

@ledgerhq/hw-transport-node-hid-noevents

Package Overview
Dependencies
Maintainers
20
Versions
276
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 6.27.12 to 6.27.15

62

CHANGELOG.md
# @ledgerhq/hw-transport-node-hid-noevents
## 6.27.15
### Patch Changes
- Updated dependencies [[`77f990e207`](https://github.com/LedgerHQ/ledger-live/commit/77f990e2075c7c9a4be69b364e3754b449c7a546)]:
- @ledgerhq/errors@6.12.6
- @ledgerhq/devices@8.0.3
- @ledgerhq/hw-transport@6.28.4
## 6.27.15-next.0
### Patch Changes
- Updated dependencies [[`77f990e207`](https://github.com/LedgerHQ/ledger-live/commit/77f990e2075c7c9a4be69b364e3754b449c7a546)]:
- @ledgerhq/errors@6.12.6-next.0
- @ledgerhq/devices@8.0.3-next.0
- @ledgerhq/hw-transport@6.28.4-next.0
## 6.27.14
### Patch Changes
- Updated dependencies [[`87d2349fd8`](https://github.com/LedgerHQ/ledger-live/commit/87d2349fd835e5deb39d1ee8dfcf3539f4195472)]:
- @ledgerhq/errors@6.12.5
- @ledgerhq/devices@8.0.2
- @ledgerhq/hw-transport@6.28.3
## 6.27.14-next.0
### Patch Changes
- Updated dependencies [[`87d2349fd8`](https://github.com/LedgerHQ/ledger-live/commit/87d2349fd835e5deb39d1ee8dfcf3539f4195472)]:
- @ledgerhq/errors@6.12.5-next.0
- @ledgerhq/devices@8.0.2-next.0
- @ledgerhq/hw-transport@6.28.3-next.0
## 6.27.13
### Patch Changes
- Updated dependencies [[`1d0b2d19eb`](https://github.com/LedgerHQ/ledger-live/commit/1d0b2d19ebc5acd058930b842c6d37f8daf2a5a3), [`ef945b05c0`](https://github.com/LedgerHQ/ledger-live/commit/ef945b05c01a791281687abb28e639e1bcc4e472), [`5fa68510b4`](https://github.com/LedgerHQ/ledger-live/commit/5fa68510b49334cfd80c30793dfe68900f1b9b3b)]:
- @ledgerhq/errors@6.12.4
- @ledgerhq/devices@8.0.1
- @ledgerhq/hw-transport@6.28.2
## 6.27.13-next.0
### Patch Changes
- Updated dependencies [[`1d0b2d19eb`](https://github.com/LedgerHQ/ledger-live/commit/1d0b2d19ebc5acd058930b842c6d37f8daf2a5a3), [`ef945b05c0`](https://github.com/LedgerHQ/ledger-live/commit/ef945b05c01a791281687abb28e639e1bcc4e472), [`5fa68510b4`](https://github.com/LedgerHQ/ledger-live/commit/5fa68510b49334cfd80c30793dfe68900f1b9b3b)]:
- @ledgerhq/errors@6.12.4-next.0
- @ledgerhq/devices@8.0.1-next.0
- @ledgerhq/hw-transport@6.28.2-next.0
## 6.27.12

@@ -11,2 +65,10 @@

## 6.27.12-next.0
### Patch Changes
- Updated dependencies [[`62af25493e`](https://github.com/LedgerHQ/ledger-live/commit/62af25493e2becf897d517af42542db208b971c7)]:
- @ledgerhq/devices@8.0.0-next.0
- @ledgerhq/hw-transport@6.28.1-next.0
## 6.27.11

@@ -13,0 +75,0 @@

297

lib-es/TransportNodeHid.js

@@ -1,16 +0,1 @@

var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -25,29 +10,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import HID from "node-hid";

@@ -60,7 +18,5 @@ import { log } from "@ledgerhq/logs";

import { TransportError, DisconnectedDevice, DisconnectedDeviceDuringOperation, } from "@ledgerhq/errors";
var filterInterface = function (device) {
return ["win32", "darwin"].includes(process.platform)
? device.usagePage === 0xffa0
: device.interface === 0;
};
const filterInterface = (device) => ["win32", "darwin"].includes(process.platform)
? device.usagePage === 0xffa0
: device.interface === 0;
export function getDevices() {

@@ -76,28 +32,41 @@ return HID.devices(ledgerUSBVendorId, 0x0).filter(filterInterface);

*/
var TransportNodeHidNoEvents = /** @class */ (function (_super) {
__extends(TransportNodeHidNoEvents, _super);
function TransportNodeHidNoEvents(device) {
var _this = _super.call(this) || this;
_this.channel = Math.floor(Math.random() * 0xffff);
_this.packetSize = 64;
_this.disconnected = false;
_this.setDisconnected = function () {
if (!_this.disconnected) {
_this.emit("disconnect");
_this.disconnected = true;
export default class TransportNodeHidNoEvents extends Transport {
/**
* if path="" is not provided, the library will take the first device
*/
static open(path) {
return Promise.resolve().then(() => {
if (path) {
return new TransportNodeHidNoEvents(new HID.HID(path));
}
const device = getDevices()[0];
if (!device)
throw new TransportError("NoDevice", "NoDevice");
return new TransportNodeHidNoEvents(new HID.HID(device.path));
});
}
constructor(device) {
super();
this.channel = Math.floor(Math.random() * 0xffff);
this.packetSize = 64;
this.disconnected = false;
this.setDisconnected = () => {
if (!this.disconnected) {
this.emit("disconnect");
this.disconnected = true;
}
};
_this.writeHID = function (content) {
var data = [0x00];
for (var i = 0; i < content.length; i++) {
this.writeHID = (content) => {
const data = [0x00];
for (let i = 0; i < content.length; i++) {
data.push(content[i]);
}
try {
_this.device.write(data);
this.device.write(data);
return Promise.resolve();
}
catch (e) {
var maybeMappedError = e && e.message ? new DisconnectedDeviceDuringOperation(e.message) : e;
const maybeMappedError = e && e.message ? new DisconnectedDeviceDuringOperation(e.message) : e;
if (maybeMappedError instanceof DisconnectedDeviceDuringOperation) {
_this.setDisconnected();
this.setDisconnected();
}

@@ -107,46 +76,27 @@ return Promise.reject(maybeMappedError);

};
_this.readHID = function () {
return new Promise(function (resolve, reject) {
return _this.device.read(function (e, res) {
if (!res) {
return reject(new DisconnectedDevice());
}
if (e) {
var maybeMappedError = e && e.message
? new DisconnectedDeviceDuringOperation(e.message)
: e;
if (maybeMappedError instanceof DisconnectedDeviceDuringOperation) {
_this.setDisconnected();
}
reject(maybeMappedError);
}
else {
var buffer = Buffer.from(res);
resolve(buffer);
}
});
});
};
_this.device = device;
this.readHID = () => new Promise((resolve, reject) => this.device.read((e, res) => {
if (!res) {
return reject(new DisconnectedDevice());
}
if (e) {
const maybeMappedError = e && e.message
? new DisconnectedDeviceDuringOperation(e.message)
: e;
if (maybeMappedError instanceof DisconnectedDeviceDuringOperation) {
this.setDisconnected();
}
reject(maybeMappedError);
}
else {
const buffer = Buffer.from(res);
resolve(buffer);
}
}));
this.device = device;
// @ts-expect-error accessing low level API in C
var info = device.getDeviceInfo();
_this.deviceModel =
const info = device.getDeviceInfo();
this.deviceModel =
info && info.product ? identifyProductName(info.product) : null;
return _this;
}
/**
* if path="" is not provided, the library will take the first device
*/
TransportNodeHidNoEvents.open = function (path) {
return Promise.resolve().then(function () {
if (path) {
return new TransportNodeHidNoEvents(new HID.HID(path));
}
var device = getDevices()[0];
if (!device)
throw new TransportError("NoDevice", "NoDevice");
return new TransportNodeHidNoEvents(new HID.HID(device.path));
});
};
/**
* Exchange with the device using APDU protocol.

@@ -156,97 +106,62 @@ * @param apdu

*/
TransportNodeHidNoEvents.prototype.exchange = function (apdu) {
return __awaiter(this, void 0, void 0, function () {
var b;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.exchangeAtomicImpl(function () { return __awaiter(_this, void 0, void 0, function () {
var _a, channel, packetSize, framing, blocks, i, result, acc, buffer;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this, channel = _a.channel, packetSize = _a.packetSize;
log("apdu", "=> " + apdu.toString("hex"));
framing = hidFraming(channel, packetSize);
blocks = framing.makeBlocks(apdu);
i = 0;
_b.label = 1;
case 1:
if (!(i < blocks.length)) return [3 /*break*/, 4];
return [4 /*yield*/, this.writeHID(blocks[i])];
case 2:
_b.sent();
_b.label = 3;
case 3:
i++;
return [3 /*break*/, 1];
case 4:
if (!!(result = framing.getReducedResult(acc))) return [3 /*break*/, 6];
return [4 /*yield*/, this.readHID()];
case 5:
buffer = _b.sent();
acc = framing.reduceResponse(acc, buffer);
return [3 /*break*/, 4];
case 6:
log("apdu", "<= " + result.toString("hex"));
return [2 /*return*/, result];
}
});
}); })];
case 1:
b = _a.sent();
return [2 /*return*/, b];
exchange(apdu) {
return __awaiter(this, void 0, void 0, function* () {
const b = yield this.exchangeAtomicImpl(() => __awaiter(this, void 0, void 0, function* () {
const { channel, packetSize } = this;
log("apdu", "=> " + apdu.toString("hex"));
const framing = hidFraming(channel, packetSize);
// Write...
const blocks = framing.makeBlocks(apdu);
for (let i = 0; i < blocks.length; i++) {
yield this.writeHID(blocks[i]);
}
});
// Read...
let result;
let acc;
while (!(result = framing.getReducedResult(acc))) {
const buffer = yield this.readHID();
acc = framing.reduceResponse(acc, buffer);
}
log("apdu", "<= " + result.toString("hex"));
return result;
}));
return b;
});
};
TransportNodeHidNoEvents.prototype.setScrambleKey = function () { };
}
setScrambleKey() { }
/**
* release the USB device.
*/
TransportNodeHidNoEvents.prototype.close = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.exchangeBusyPromise];
case 1:
_a.sent();
this.device.close();
return [2 /*return*/];
}
});
close() {
return __awaiter(this, void 0, void 0, function* () {
yield this.exchangeBusyPromise;
this.device.close();
});
};
/**
*
*/
TransportNodeHidNoEvents.isSupported = function () {
return Promise.resolve(typeof HID.HID === "function");
};
/**
*
*/
TransportNodeHidNoEvents.list = function () {
return Promise.resolve(getDevices().map(function (d) { return d.path; }));
};
/**
*/
TransportNodeHidNoEvents.listen = function (observer) {
getDevices().forEach(function (device) {
var deviceModel = identifyUSBProductId(device.productId);
observer.next({
type: "add",
descriptor: device.path,
deviceModel: deviceModel,
device: device
});
}
}
/**
*
*/
TransportNodeHidNoEvents.isSupported = () => Promise.resolve(typeof HID.HID === "function");
/**
*
*/
TransportNodeHidNoEvents.list = () => Promise.resolve(getDevices().map((d) => d.path));
/**
*/
TransportNodeHidNoEvents.listen = (observer) => {
getDevices().forEach((device) => {
const deviceModel = identifyUSBProductId(device.productId);
observer.next({
type: "add",
descriptor: device.path,
deviceModel,
device: device,
});
observer.complete();
return {
unsubscribe: function () { }
};
});
observer.complete();
return {
unsubscribe: () => { },
};
return TransportNodeHidNoEvents;
}(Transport));
export default TransportNodeHidNoEvents;
};
//# sourceMappingURL=TransportNodeHid.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -26,48 +11,19 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDevices = void 0;
var node_hid_1 = __importDefault(require("node-hid"));
var logs_1 = require("@ledgerhq/logs");
var hw_transport_1 = __importDefault(require("@ledgerhq/hw-transport"));
var devices_1 = require("@ledgerhq/devices");
var hid_framing_1 = __importDefault(require("@ledgerhq/devices/hid-framing"));
var devices_2 = require("@ledgerhq/devices");
var errors_1 = require("@ledgerhq/errors");
var filterInterface = function (device) {
return ["win32", "darwin"].includes(process.platform)
? device.usagePage === 0xffa0
: device.interface === 0;
};
const node_hid_1 = __importDefault(require("node-hid"));
const logs_1 = require("@ledgerhq/logs");
const hw_transport_1 = __importDefault(require("@ledgerhq/hw-transport"));
const devices_1 = require("@ledgerhq/devices");
const hid_framing_1 = __importDefault(require("@ledgerhq/devices/hid-framing"));
const devices_2 = require("@ledgerhq/devices");
const errors_1 = require("@ledgerhq/errors");
const filterInterface = (device) => ["win32", "darwin"].includes(process.platform)
? device.usagePage === 0xffa0
: device.interface === 0;
function getDevices() {
return node_hid_1["default"].devices(devices_1.ledgerUSBVendorId, 0x0).filter(filterInterface);
return node_hid_1.default.devices(devices_1.ledgerUSBVendorId, 0x0).filter(filterInterface);
}

@@ -82,28 +38,41 @@ exports.getDevices = getDevices;

*/
var TransportNodeHidNoEvents = /** @class */ (function (_super) {
__extends(TransportNodeHidNoEvents, _super);
function TransportNodeHidNoEvents(device) {
var _this = _super.call(this) || this;
_this.channel = Math.floor(Math.random() * 0xffff);
_this.packetSize = 64;
_this.disconnected = false;
_this.setDisconnected = function () {
if (!_this.disconnected) {
_this.emit("disconnect");
_this.disconnected = true;
class TransportNodeHidNoEvents extends hw_transport_1.default {
/**
* if path="" is not provided, the library will take the first device
*/
static open(path) {
return Promise.resolve().then(() => {
if (path) {
return new TransportNodeHidNoEvents(new node_hid_1.default.HID(path));
}
const device = getDevices()[0];
if (!device)
throw new errors_1.TransportError("NoDevice", "NoDevice");
return new TransportNodeHidNoEvents(new node_hid_1.default.HID(device.path));
});
}
constructor(device) {
super();
this.channel = Math.floor(Math.random() * 0xffff);
this.packetSize = 64;
this.disconnected = false;
this.setDisconnected = () => {
if (!this.disconnected) {
this.emit("disconnect");
this.disconnected = true;
}
};
_this.writeHID = function (content) {
var data = [0x00];
for (var i = 0; i < content.length; i++) {
this.writeHID = (content) => {
const data = [0x00];
for (let i = 0; i < content.length; i++) {
data.push(content[i]);
}
try {
_this.device.write(data);
this.device.write(data);
return Promise.resolve();
}
catch (e) {
var maybeMappedError = e && e.message ? new errors_1.DisconnectedDeviceDuringOperation(e.message) : e;
const maybeMappedError = e && e.message ? new errors_1.DisconnectedDeviceDuringOperation(e.message) : e;
if (maybeMappedError instanceof errors_1.DisconnectedDeviceDuringOperation) {
_this.setDisconnected();
this.setDisconnected();
}

@@ -113,46 +82,27 @@ return Promise.reject(maybeMappedError);

};
_this.readHID = function () {
return new Promise(function (resolve, reject) {
return _this.device.read(function (e, res) {
if (!res) {
return reject(new errors_1.DisconnectedDevice());
}
if (e) {
var maybeMappedError = e && e.message
? new errors_1.DisconnectedDeviceDuringOperation(e.message)
: e;
if (maybeMappedError instanceof errors_1.DisconnectedDeviceDuringOperation) {
_this.setDisconnected();
}
reject(maybeMappedError);
}
else {
var buffer = Buffer.from(res);
resolve(buffer);
}
});
});
};
_this.device = device;
this.readHID = () => new Promise((resolve, reject) => this.device.read((e, res) => {
if (!res) {
return reject(new errors_1.DisconnectedDevice());
}
if (e) {
const maybeMappedError = e && e.message
? new errors_1.DisconnectedDeviceDuringOperation(e.message)
: e;
if (maybeMappedError instanceof errors_1.DisconnectedDeviceDuringOperation) {
this.setDisconnected();
}
reject(maybeMappedError);
}
else {
const buffer = Buffer.from(res);
resolve(buffer);
}
}));
this.device = device;
// @ts-expect-error accessing low level API in C
var info = device.getDeviceInfo();
_this.deviceModel =
const info = device.getDeviceInfo();
this.deviceModel =
info && info.product ? (0, devices_2.identifyProductName)(info.product) : null;
return _this;
}
/**
* if path="" is not provided, the library will take the first device
*/
TransportNodeHidNoEvents.open = function (path) {
return Promise.resolve().then(function () {
if (path) {
return new TransportNodeHidNoEvents(new node_hid_1["default"].HID(path));
}
var device = getDevices()[0];
if (!device)
throw new errors_1.TransportError("NoDevice", "NoDevice");
return new TransportNodeHidNoEvents(new node_hid_1["default"].HID(device.path));
});
};
/**
* Exchange with the device using APDU protocol.

@@ -162,97 +112,63 @@ * @param apdu

*/
TransportNodeHidNoEvents.prototype.exchange = function (apdu) {
return __awaiter(this, void 0, void 0, function () {
var b;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.exchangeAtomicImpl(function () { return __awaiter(_this, void 0, void 0, function () {
var _a, channel, packetSize, framing, blocks, i, result, acc, buffer;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this, channel = _a.channel, packetSize = _a.packetSize;
(0, logs_1.log)("apdu", "=> " + apdu.toString("hex"));
framing = (0, hid_framing_1["default"])(channel, packetSize);
blocks = framing.makeBlocks(apdu);
i = 0;
_b.label = 1;
case 1:
if (!(i < blocks.length)) return [3 /*break*/, 4];
return [4 /*yield*/, this.writeHID(blocks[i])];
case 2:
_b.sent();
_b.label = 3;
case 3:
i++;
return [3 /*break*/, 1];
case 4:
if (!!(result = framing.getReducedResult(acc))) return [3 /*break*/, 6];
return [4 /*yield*/, this.readHID()];
case 5:
buffer = _b.sent();
acc = framing.reduceResponse(acc, buffer);
return [3 /*break*/, 4];
case 6:
(0, logs_1.log)("apdu", "<= " + result.toString("hex"));
return [2 /*return*/, result];
}
});
}); })];
case 1:
b = _a.sent();
return [2 /*return*/, b];
exchange(apdu) {
return __awaiter(this, void 0, void 0, function* () {
const b = yield this.exchangeAtomicImpl(() => __awaiter(this, void 0, void 0, function* () {
const { channel, packetSize } = this;
(0, logs_1.log)("apdu", "=> " + apdu.toString("hex"));
const framing = (0, hid_framing_1.default)(channel, packetSize);
// Write...
const blocks = framing.makeBlocks(apdu);
for (let i = 0; i < blocks.length; i++) {
yield this.writeHID(blocks[i]);
}
});
// Read...
let result;
let acc;
while (!(result = framing.getReducedResult(acc))) {
const buffer = yield this.readHID();
acc = framing.reduceResponse(acc, buffer);
}
(0, logs_1.log)("apdu", "<= " + result.toString("hex"));
return result;
}));
return b;
});
};
TransportNodeHidNoEvents.prototype.setScrambleKey = function () { };
}
setScrambleKey() { }
/**
* release the USB device.
*/
TransportNodeHidNoEvents.prototype.close = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.exchangeBusyPromise];
case 1:
_a.sent();
this.device.close();
return [2 /*return*/];
}
});
close() {
return __awaiter(this, void 0, void 0, function* () {
yield this.exchangeBusyPromise;
this.device.close();
});
};
/**
*
*/
TransportNodeHidNoEvents.isSupported = function () {
return Promise.resolve(typeof node_hid_1["default"].HID === "function");
};
/**
*
*/
TransportNodeHidNoEvents.list = function () {
return Promise.resolve(getDevices().map(function (d) { return d.path; }));
};
/**
*/
TransportNodeHidNoEvents.listen = function (observer) {
getDevices().forEach(function (device) {
var deviceModel = (0, devices_2.identifyUSBProductId)(device.productId);
observer.next({
type: "add",
descriptor: device.path,
deviceModel: deviceModel,
device: device
});
}
}
exports.default = TransportNodeHidNoEvents;
/**
*
*/
TransportNodeHidNoEvents.isSupported = () => Promise.resolve(typeof node_hid_1.default.HID === "function");
/**
*
*/
TransportNodeHidNoEvents.list = () => Promise.resolve(getDevices().map((d) => d.path));
/**
*/
TransportNodeHidNoEvents.listen = (observer) => {
getDevices().forEach((device) => {
const deviceModel = (0, devices_2.identifyUSBProductId)(device.productId);
observer.next({
type: "add",
descriptor: device.path,
deviceModel,
device: device,
});
observer.complete();
return {
unsubscribe: function () { }
};
});
observer.complete();
return {
unsubscribe: () => { },
};
return TransportNodeHidNoEvents;
}(hw_transport_1["default"]));
exports["default"] = TransportNodeHidNoEvents;
};
//# sourceMappingURL=TransportNodeHid.js.map
{
"name": "@ledgerhq/hw-transport-node-hid-noevents",
"version": "6.27.12",
"version": "6.27.15",
"description": "Ledger Hardware Wallet Node implementation of the communication layer, using node-hid. without usb events",

@@ -31,9 +31,17 @@ "keywords": [

"node-hid": "^2.1.2",
"@ledgerhq/devices": "^8.0.0",
"@ledgerhq/errors": "^6.12.3",
"@ledgerhq/hw-transport": "^6.28.1",
"@ledgerhq/devices": "^8.0.3",
"@ledgerhq/errors": "^6.12.6",
"@ledgerhq/hw-transport": "^6.28.4",
"@ledgerhq/logs": "^6.10.1"
},
"devDependencies": {
"@types/node-hid": "^1.3.1"
"@types/jest": "^29.5.0",
"@types/node": "^18.15.3",
"@types/node-hid": "^1.3.1",
"documentation": "13.2.4",
"jest": "^28.1.1",
"rimraf": "^4.4.1",
"source-map-support": "^0.5.21",
"ts-jest": "^28.0.5",
"ts-node": "^10.4.0"
},

@@ -40,0 +48,0 @@ "gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec",

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc