You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
453 B
22 lines
453 B
6 years ago
|
import CommNodeHid from '@ledgerhq/hw-transport-node-hid'
|
||
|
|
||
|
export default function getDevice() {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
const sub = CommNodeHid.listen({
|
||
|
error: err => {
|
||
|
sub.unsubscribe()
|
||
|
reject(err)
|
||
|
},
|
||
|
next: async e => {
|
||
|
if (!e.device) {
|
||
|
return
|
||
|
}
|
||
|
if (e.type === 'add') {
|
||
|
sub.unsubscribe()
|
||
|
resolve(e.device)
|
||
|
}
|
||
|
},
|
||
|
})
|
||
|
})
|
||
|
}
|