How to use the @ledgerhq/hw-transport-http.withStaticURL function in @ledgerhq/hw-transport-http

To help you get started, we’ve selected a few @ledgerhq/hw-transport-http 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-mobile / src / hw / findFirstTransport.js View on Github external
import { Observable } from "rxjs/Observable";
import { PromiseObservable } from "rxjs/observable/PromiseObservable";
import "rxjs/add/observable/merge";
import "rxjs/add/observable/empty";
import "rxjs/add/operator/first";
import "rxjs/add/operator/map";
import "rxjs/add/operator/catch";
import "rxjs/add/operator/concatMap";
import HIDTransport from "@ledgerhq/react-native-hid";
import BluetoothTransport from "@ledgerhq/react-native-hw-transport-ble";
import { withStaticURL } from "@ledgerhq/hw-transport-http";
import Config from "react-native-config";

const transports: Array<*> = [HIDTransport, BluetoothTransport];
if (__DEV__) {
  transports.push(withStaticURL(Config.DEBUG_COMM_HTTP_PROXY));
}

export default () =>
  Observable.merge(
    ...transports.map(t =>
      Observable.create(o => t.listen(o))
        .map(({ descriptor }) => ({ descriptor, t }))
        .catch(e => {
          console.warn(`discover failed for ${t.name}: ${e}`);
          return Observable.empty();
        })
    )
  )
    .first()
    .concatMap(({ descriptor, t }) =>
      PromiseObservable.create(t.open(descriptor))

@ledgerhq/hw-transport-http

Ledger Hardware Wallet communication layer over http

MIT
Latest version published 2 months ago

Package Health Score

87 / 100
Full package analysis

Popular @ledgerhq/hw-transport-http functions