meriadec
7 years ago
No known key found for this signature in database
GPG Key ID: 1D2FC2305E2CB399
2 changed files with
12 additions and
2 deletions
-
src/internals/usb/devices.js
-
src/internals/usb/manager/constants.js
|
|
@ -38,8 +38,15 @@ export default (send: IPCSend) => ({ |
|
|
|
async function isValidHIDDevice(devicePath: string): Promise<boolean> { |
|
|
|
try { |
|
|
|
const transport: Transport<*> = await CommNodeHid.open(devicePath) |
|
|
|
await transport.send(...APDUS.GET_FIRMWARE) |
|
|
|
return true |
|
|
|
try { |
|
|
|
await transport.send(...APDUS.GET_FIRMWARE) |
|
|
|
return true |
|
|
|
} catch (err) { |
|
|
|
// if we are inside an app, the first call should have failed,
|
|
|
|
// so we try this one
|
|
|
|
await transport.send(...APDUS.GET_FIRMWARE_FALLBACK) |
|
|
|
return true |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
@ -4,4 +4,7 @@ export const BASE_SOCKET_URL = 'ws://api.ledgerwallet.com/update/install' |
|
|
|
// List of APDUS
|
|
|
|
export const APDUS = { |
|
|
|
GET_FIRMWARE: [0xe0, 0x01, 0x00, 0x00], |
|
|
|
// we dont have common call that works inside app & dashboard
|
|
|
|
// TODO: this should disappear.
|
|
|
|
GET_FIRMWARE_FALLBACK: [0xe0, 0xc4, 0x00, 0x00], |
|
|
|
} |
|
|
|