You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const HID = require('@ledgerhq/hw-transport-node-hid').default
const { Observable, timer } = require('rxjs')
const { takeUntil, filter, scan } = require('rxjs/operators')
async function main() {
const devices = await Promise.all([
new Observable(HID.listen)
.pipe(
// searching for 2 seconds
takeUntil(timer(2000)),
filter(e => e.type === 'add'),
scan((acc, e) => {
return [
...acc,
{
descriptor: e.descriptor,
vendorId: e.device.vendorId,
manufacturer: e.device.manufacturer,
product: e.device.product,
}
]
}, []),
)
.toPromise()
// If the computer does not have Bluetooth support, ledgerjs may throw an error.
.catch((err) => {
console.log(err)
})
])
const device = devices.flat()[0]
if (!device) {
return
}
console.log(device.descriptor)
const transport = await HID.open()
const res = await transport.send(0xe0, 0x01, 0x00, 0x00)
const byteArray = [...res]
const data = byteArray.slice(0, byteArray.length - 2)
const versionLength = data[4]
const version = Buffer.from(data.slice(5, 5 + versionLength)).toString()
console.log(version)
return version
}
main()
It will throw an Error
Error
at new TransportStatusError (/Users/wangxiaoxiao/Documents/ygy/test/node_modules/@ledgerhq/errors/lib/index.js:258:18)
at TransportNodeHid.<anonymous> (/Users/wangxiaoxiao/Documents/ygy/test/node_modules/@ledgerhq/hw-transport-node-hid-noevents/node_modules/@ledgerhq/hw-transport/lib/Transport.js:127:39)
at step (/Users/wangxiaoxiao/Documents/ygy/test/node_modules/@ledgerhq/hw-transport-node-hid-noevents/node_modules/@ledgerhq/hw-transport/lib/Transport.js:33:23)
at Object.next (/Users/wangxiaoxiao/Documents/ygy/test/node_modules/@ledgerhq/hw-transport-node-hid-noevents/node_modules/@ledgerhq/hw-transport/lib/Transport.js:14:53)
at fulfilled (/Users/wangxiaoxiao/Documents/ygy/test/node_modules/@ledgerhq/hw-transport-node-hid-noevents/node_modules/@ledgerhq/hw-transport/lib/Transport.js:5:58) {
message: 'Ledger device: CLA_NOT_SUPPORTED (0x6e00)',
statusCode: 28160,
statusText: 'CLA_NOT_SUPPORTED'
Expected behavior
I can successfully get the firmware version.
Additional context
I also try it on @ledgerhq/[email protected], but it also failed. Maybe it's caused by the ledger version. I upgrade the ledger version recently.
The text was updated successfully, but these errors were encountered:
An easy way to test out the responses from the device is to use the repl tool we have made available. If you connect a Nano S Plus and send the getVersion APDU e001000000 you need to be in the dashboard and unlocked so if the device is running an application open it wont work.
Looking at the linked issues in here I assume that the app in question would be Nervos 0.5.5 and the exchange matches what you describe. With the application open, you are getting basically this. This is not a bug, it's the expected behaviour from the device.
=> e001000000
<= 6e00
The repository for the app in question is located here.
As the logs explain, CLA_NOT_SUPPORTED or INS_NOT_SUPPORTED mean that you are sending a message that the current application can't handle. Some APDU messages such as b001000000 will work regardless of the app running and will give you information about the current app running on the device. Depending on what you are trying to do, perhaps we can help better on Discord for development.
Since this is not a bug, I'm going to close the issue.
Good luck with the project and don't hesitate to contact us if you find an issue.
Impacted Library name
@ledgerhq/hw-transport-node-hid
Impacted Library version
6.27.6
Describe the bug
Ledger Nano S Plus V0.5.5
Here is my code:
It will throw an Error
Expected behavior
I can successfully get the firmware version.
Additional context
I also try it on @ledgerhq/[email protected], but it also failed. Maybe it's caused by the ledger version. I upgrade the ledger version recently.
The text was updated successfully, but these errors were encountered: