@ledgerhq/hw-transport-node-hid
Advanced tools
Comparing version 1.2.0-beta.10b44916 to 1.2.0-beta.5f7fbb68
@@ -70,3 +70,3 @@ "use strict"; | ||
exchange(apduHex, statusList) { | ||
exchange(apdu) { | ||
function ledgerWrap(channel, command, packetSize) { | ||
@@ -159,4 +159,2 @@ let sequenceIdx = 0; | ||
const apdu = Buffer.from(apduHex, "hex"); | ||
const deferred = defer(); | ||
@@ -270,9 +268,7 @@ let exchangeTimeout; | ||
performExchange().then(result => { | ||
let status, | ||
response, | ||
let response, | ||
resultBin = result; | ||
if (!this.ledgerTransport) { | ||
if (resultBin.length === 2 || resultBin[0] !== 0x61) { | ||
status = resultBin[0] << 8 | resultBin[1]; | ||
response = resultBin.toString("hex"); | ||
response = resultBin; | ||
} else { | ||
@@ -284,15 +280,7 @@ let size = resultBin[1]; | ||
} | ||
response = resultBin.toString("hex", 2); | ||
status = resultBin[2 + size] << 8 | resultBin[2 + size + 1]; | ||
response = resultBin.slice(2); | ||
} | ||
} else { | ||
response = resultBin.toString("hex"); | ||
status = resultBin[resultBin.length - 2] << 8 | resultBin[resultBin.length - 1]; | ||
response = resultBin; | ||
} | ||
// Check the status | ||
const statusFound = statusList.some(s => s === status); | ||
if (!statusFound) { | ||
deferred.reject("Invalid status " + status.toString(16)); | ||
} | ||
// build the response | ||
@@ -299,0 +287,0 @@ if (this.timeout !== 0) { |
{ | ||
"name": "@ledgerhq/hw-transport-node-hid", | ||
"version": "1.2.0-beta.10b44916", | ||
"version": "1.2.0-beta.5f7fbb68", | ||
"description": "Ledger Hardware Wallet Node implementation of the communication layer, using node-hid", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^1.2.0-beta.10b44916", | ||
"@ledgerhq/hw-transport": "^1.2.0-beta.5f7fbb68", | ||
"node-hid": "^0.7.2" | ||
@@ -31,0 +31,0 @@ }, |
@@ -96,3 +96,3 @@ //@flow | ||
exchange(apduHex: string, statusList: Array<number>): Promise<string> { | ||
exchange(apdu: Buffer): Promise<Buffer> { | ||
function ledgerWrap(channel, command, packetSize) { | ||
@@ -202,4 +202,2 @@ let sequenceIdx = 0; | ||
const apdu = Buffer.from(apduHex, "hex"); | ||
const deferred = defer(); | ||
@@ -330,9 +328,7 @@ let exchangeTimeout; | ||
.then(result => { | ||
let status, | ||
response, | ||
let response, | ||
resultBin = result; | ||
if (!this.ledgerTransport) { | ||
if (resultBin.length === 2 || resultBin[0] !== 0x61) { | ||
status = (resultBin[0] << 8) | resultBin[1]; | ||
response = resultBin.toString("hex"); | ||
response = resultBin; | ||
} else { | ||
@@ -344,17 +340,7 @@ let size = resultBin[1]; | ||
} | ||
response = resultBin.toString("hex", 2); | ||
status = (resultBin[2 + size] << 8) | resultBin[2 + size + 1]; | ||
response = resultBin.slice(2); | ||
} | ||
} else { | ||
response = resultBin.toString("hex"); | ||
status = | ||
(resultBin[resultBin.length - 2] << 8) | | ||
resultBin[resultBin.length - 1]; | ||
response = resultBin; | ||
} | ||
// Check the status | ||
const statusFound = statusList.some(s => s === status); | ||
if (!statusFound) { | ||
deferred.reject("Invalid status " + status.toString(16)); | ||
} | ||
// build the response | ||
@@ -361,0 +347,0 @@ if (this.timeout !== 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
73140
1020