Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
open: (id: string): ?Promise<*> => {
if (id.startsWith("webusb")) {
const existingDevice = webusbDevices[id];
return existingDevice
? TransportWebUSB.open(existingDevice)
: TransportWebUSB.create();
}
return null;
},
export async function openTransport(device: USBDevice): Promise {
if (!(window && window.navigator.usb))
throw new WebUSBNotAvailable()
try {
return await TransportWebUSB.open(device)
} catch (err) {
if (err.name === 'TransportInterfaceNotAvailable') {
throw new ConflictingApp('Ledger')
}
throw new WebUSBCouldNotInitialize('Ledger', err.message)
}
}