}
/**
- * Clears Ledger connections from all device interfaces.
+ * Clears Ledger connections from HID and USB interfaces.
*/
static disconnect (): void {
setTimeout(async () => {
- const hidDevices = await globalThis.navigator?.hid?.getDevices?.() ?? []
- for (const device of hidDevices) {
- if (device.vendorId === this.ledgerVendorId) {
- device.forget()
- }
- }
- const bleDevices = await globalThis.navigator?.bluetooth?.getDevices?.() ?? []
- for (const device of bleDevices) {
- TransportBLE.disconnect(device.id).catch(() => { })
- }
- const usbDevices = await globalThis.navigator?.usb?.getDevices?.() ?? []
- for (const device of usbDevices) {
- if (device.vendorId === this.ledgerVendorId) {
- device.forget()
- }
- }
+ const hidDevices = (await navigator?.hid?.getDevices?.())
+ .filter(device => device.vendorId === this.ledgerVendorId)
+ .map(device => device.close())
+ const usbDevices = (await navigator?.usb?.getDevices?.())
+ .filter(device => device.vendorId === this.ledgerVendorId)
+ .map(device => device.close())
this.#status = 'DISCONNECTED'
})
}
})
}),
- suite('Ledger hardware wallet', { skip: false || isNode || navigator?.usb == null }, async () => {
+ suite('Ledger hardware wallet', { skip: isNode || navigator?.usb == null }, async () => {
const { LEDGER_MNEMONIC, LEDGER_SEED, LEDGER_PUBLIC_0, LEDGER_ADDRESS_0 } = CUSTOM_TEST_VECTORS
const { OPEN_BLOCK, RECEIVE_BLOCK, SEND_BLOCK } = NANO_TEST_VECTORS
resolve(null)
}, 90000)
})
+
+ await assert.resolves(async () => {
+ await click(
+ 'Unlock device again, then click to continue',
+ async () => {}
+ )
+ })
+ assert.equal(wallet.isLocked, false)
+ assert.equal(Ledger.status, 'CONNECTED')
})
- await test('switch between interfaces', { skip: false }, async () => {
+ await test('switch between interfaces', { skip: false || isNode || navigator?.usb == null }, async () => {
await assert.resolves(async () => {
await click(
'Verify current interface is HID, switch to unlocked Bluetooth device, then click to continue',