Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async handleDisconnectWebUSBLedger(e: USBConnectionEvent): Promise {
if (e.device.vendorId !== VENDOR_ID) return
await timeout(APP_NAVIGATION_DELAY) // timeout gives time to detect if it is an app navigation based disconnec/connect event
if (this.connectTimestamp !== 0) return
try {
await this.keyring.remove(e.device.serialNumber)
} catch(e) {
console.error(e)
} finally {
this.keyring.emit([e.device.manufacturerName, e.device.productName, Events.DISCONNECT], e.device.serialNumber)
}
}
private async handleDisconnectWebUSBKeepKey (e: USBConnectionEvent): Promise {
try {
await this.keyring.remove(e.device.serialNumber)
} catch(e) {
console.error(e)
} finally {
this.keyring.emit([e.device.productName, e.device.serialNumber, Events.DISCONNECT], e.device.serialNumber)
}
}
private async handleDisconnectTrezor (event: any): Promise {
const { payload: { features: { device_id } } } = event
try {
await this.keyring.remove(device_id)
} catch (e) {
console.error(e)
} finally {
this.keyring.emit(['Trezor', device_id, Events.DISCONNECT], device_id)
}
}
.then(() => this.keyring.emit([device.productName, device.serialNumber, Events.DISCONNECT], device.serialNumber))
.catch(() => this.keyring.emit([device.productName, device.serialNumber, Events.DISCONNECT], device.serialNumber))
.catch(() =>
this.keyring.emit(
[device.product, device.serialNumber, Events.DISCONNECT],
device.serialNumber
)
)
this.portis.onLogout( () => {
this.keyring.emit(["Portis", this.currentDeviceId, Events.DISCONNECT], this.currentDeviceId)
this.keyring.remove(this.currentDeviceId)
})
return wallet
await wallet.initialize()
}
window['wallet'] = wallet
})
wallet = keyring.get()
window['wallet'] = wallet
if (wallet) {
let deviceID = wallet.getDeviceID()
$keyring.val(deviceID).change()
}
keyring.on(['*', '*', Events.CONNECT], async (deviceId) => {
await deviceConnected(deviceId)
})
keyring.on(['*', '*', Events.DISCONNECT], async (deviceId) => {
$keyring.find(`option[value="${deviceId}"]`).remove()
})
})()
componentWillUnmount() {
this.keyring.off(`*.*.${Events.CONNECT}`, this.handleDeviceConnect);
this.keyring.off(`*.*.${Events.DISCONNECT}`, this.handleDeviceDisconnect);
}