* Check which transport protocols are supported by the browser and set the\r
* transport type according to the following priorities: Bluetooth, USB, HID.\r
*/\r
- async checkBrowserSupport (): Promise<void> {\r
+ async checkBrowserSupport (): Promise<typeof TransportBLE | typeof TransportUSB | typeof TransportHID> {\r
console.log('Checking browser Ledger support...')\r
- const supports = {\r
- ble: await TransportBLE.isSupported(),\r
- usb: await TransportUSB.isSupported(),\r
- hid: await TransportHID.isSupported()\r
- }\r
- console.log(`ble: ${supports.ble}; usb: ${supports.usb}; hid: ${supports.hid}`)\r
- if (supports.ble) {\r
- this.DynamicTransport = TransportBLE\r
- } else if (supports.usb) {\r
- this.DynamicTransport = TransportUSB\r
- } else if (supports.hid) {\r
- this.DynamicTransport = TransportHID\r
- } else {\r
- throw new Error('Unsupported browser')\r
- }\r
+ try {\r
+ if (await TransportBLE.isSupported()) {\r
+ return TransportBLE\r
+ }\r
+ if (await TransportUSB.isSupported()) {\r
+ return TransportUSB\r
+ }\r
+ if (await TransportHID.isSupported()) {\r
+ return TransportHID\r
+ }\r
+ } catch { }\r
+ throw new Error('Unsupported browser')\r
}\r
\r
async connect (): Promise<LedgerResponse> {\r