Socket
Socket
Sign inDemoInstall

@ledgerhq/hw-transport

Package Overview
Dependencies
Maintainers
6
Versions
366
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ledgerhq/hw-transport - npm Package Compare versions

Comparing version 1.2.0-beta.10b44916 to 1.2.0-beta.5f7fbb68

22

lib/Transport.js

@@ -32,5 +32,10 @@ "use strict";

this.send = (() => {
var _ref = _asyncToGenerator(function* (cla, ins, p1, p2, data = Buffer.alloc(0)) {
var _ref = _asyncToGenerator(function* (cla, ins, p1, p2, data = Buffer.alloc(0), statusList = [0x9000]) {
(0, _invariant2.default)(data.length < 256, "data.length exceed 256 bytes limit. Got: %s", data.length);
return Buffer.from((yield _this.exchange(Buffer.concat([Buffer.from([cla, ins, p1, p2]), Buffer.from([data.length]), data]).toString("hex"), [0x9000])), "hex");
const response = yield _this.exchange(Buffer.concat([Buffer.from([cla, ins, p1, p2]), Buffer.from([data.length]), data]));
const sw = response.readUInt16BE(response.length - 2);
(0, _invariant2.default)(statusList.some(function (s) {
return s === sw;
}), "Invalid status %s", sw.toString(16));
return response;
});

@@ -79,6 +84,6 @@

* low level api to communicate with the device
* TODO: in the future we'll refactor this to be Buffer=>Buffer instead
* @param apduHex hex string of the data to send
* @param statusList an array of accepted status code to be considered successful
* @return a Promise of hex string response data
* This method is for implementations to implement but should not be directly called.
* Instead, the recommanded way is to use send() method
* @param apdu the data to send
* @return a Promise of response data
*/

@@ -134,2 +139,3 @@

* @param data
* @param statusList is a list of accepted status code (shorts). [0x9000] by default
* @return a Promise of response buffer

@@ -149,5 +155,3 @@ */

const descriptors = yield _this2.list();
if (descriptors.length === 0) {
throw "No device found";
}
(0, _invariant2.default)(descriptors.length !== 0, "No device found");
const transport = yield _this2.open(descriptors[0], timeout);

@@ -154,0 +158,0 @@ transport.setDebugMode(debug);

{
"name": "@ledgerhq/hw-transport",
"version": "1.2.0-beta.10b44916",
"version": "1.2.0-beta.5f7fbb68",
"description": "Ledger Hardware Wallet common interface of the communication layer",

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

@@ -59,8 +59,8 @@ //@flow

* low level api to communicate with the device
* TODO: in the future we'll refactor this to be Buffer=>Buffer instead
* @param apduHex hex string of the data to send
* @param statusList an array of accepted status code to be considered successful
* @return a Promise of hex string response data
* This method is for implementations to implement but should not be directly called.
* Instead, the recommanded way is to use send() method
* @param apdu the data to send
* @return a Promise of response data
*/
+exchange: (apduHex: string, statusList: Array<number>) => Promise<string>;
+exchange: (apdu: Buffer) => Promise<Buffer>;

@@ -116,2 +116,3 @@ /**

* @param data
* @param statusList is a list of accepted status code (shorts). [0x9000] by default
* @return a Promise of response buffer

@@ -124,3 +125,4 @@ */

p2: number,
data: Buffer = Buffer.alloc(0)
data: Buffer = Buffer.alloc(0),
statusList: Array<number> = [0x9000]
): Promise<Buffer> => {

@@ -132,13 +134,16 @@ invariant(

);
return Buffer.from(
await this.exchange(
Buffer.concat([
Buffer.from([cla, ins, p1, p2]),
Buffer.from([data.length]),
data
]).toString("hex"),
[0x9000]
),
"hex"
const response = await this.exchange(
Buffer.concat([
Buffer.from([cla, ins, p1, p2]),
Buffer.from([data.length]),
data
])
);
const sw = response.readUInt16BE(response.length - 2);
invariant(
statusList.some(s => s === sw),
"Invalid status %s",
sw.toString(16)
);
return response;
};

@@ -159,5 +164,3 @@

const descriptors = await this.list();
if (descriptors.length === 0) {
throw "No device found";
}
invariant(descriptors.length !== 0, "No device found");
const transport = await this.open(descriptors[0], timeout);

@@ -164,0 +167,0 @@ transport.setDebugMode(debug);

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