How to use the @ledgerhq/hw-transport-webusb.open function in @ledgerhq/hw-transport-webusb

To help you get started, we’ve selected a few @ledgerhq/hw-transport-webusb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledger-live-common / tools / src / live-common-setup.js View on Github external
open: (id: string): ?Promise<*> => {
    if (id.startsWith("webusb")) {
      const existingDevice = webusbDevices[id];
      return existingDevice
        ? TransportWebUSB.open(existingDevice)
        : TransportWebUSB.create();
    }
    return null;
  },
github shapeshift / hdwallet / packages / hdwallet-ledger-webusb / src / transport.ts View on Github external
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)
  }
}