How to use the @ledgerhq/hw-transport-webusb.create 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 burst-apps-team / phoenix / web / angular-wallet / src / app / ledger / ledger.service.ts View on Github external
public async getPublicKey(accountIndex: number): Promise {
    if (this.appService.isDesktop()) {
      const publicKeyHex: string = this.appService.sendIpcMessageSync('ledger-get-public-key', accountIndex);
      if (publicKeyHex.startsWith('Error: ')) {
        throw new Error(publicKeyHex);
      }
      return publicKeyHex;
    } else {
      const transport = await TransportWebUSB.create();
      // todo: move this to a shared fn
      const publicKey: Buffer = await transport.exchange(Buffer.from('800400' + this.byteToHex(accountIndex) + '00', 'hex'));
      return publicKey.toString('hex').substr(0, 64);
    }
  }
github forbole / big_dipper / imports / ui / ledger / ledger.js View on Github external
async connect(timeout = INTERACTION_TIMEOUT) {
        // assume well connection if connected once
        if (this.cosmosApp) return

        const transport = await TransportWebUSB.create(timeout)
        const cosmosLedgerApp = new CosmosApp(transport)

        this.cosmosApp = cosmosLedgerApp

        await this.isSendingData()
        await this.isReady()
    }
    async getCosmosAppVersion() {
github theQRL / qrl-wallet / imports / startup / client / functions.js View on Github external
export async function createTransport() {
  var transport = null;
  transport = await TransportWebUSB.create();
  console.log('USING WEBUSB');
  var qrl = await new Qrl(transport);
  return qrl
}
github vacuumlabs / adalite / app / frontend / wallet / cardano-ledger-crypto-provider.js View on Github external
const CardanoLedgerCryptoProvider = async (ADALITE_CONFIG, walletState) => {
  let transport
  try {
    transport = await LedgerTransportU2F.create()
  } catch (u2fError) {
    try {
      transport = await LedgerTransportWebusb.create()
    } catch (webUsbError) {
      debugLog(webUsbError)
      throw u2fError
    }
  }
  transport.setExchangeTimeout(ADALITE_CONFIG.ADALITE_LOGOUT_AFTER * 1000)
  const ledger = new Ledger(transport)
  const state = Object.assign(walletState, {
    derivationScheme: derivationSchemes.v2,
    rootHdPassphrase: null,
    derivedAddresses: {},
  })

  const isHwWallet = () => true
  const getHwWalletName = () => 'Ledger'
github LedgerHQ / ledger-live-common / tools / src / demos / derivations / index.js View on Github external
execInQueue(async () => {
      const { derivationMode, currency, index: account } = this.props;
      try {
        const p = transportGlobalP || TransportWebUSB.create();
        transportGlobalP = p;
        const transport = await p;
        const { address, path } = await getAddress(transport, {
          currency,
          path: runDerivationScheme(
            getDerivationScheme({ currency, derivationMode }),
            currency,
            { account }
          ),
          derivationMode,
          verify
        });
        this.setState({ address, path });
      } catch (error) {
        this.setState({ error });
      }
github burst-apps-team / phoenix / web / angular-wallet / src / app / ledger / ledger.service.ts View on Github external
public async sign(accountIndex: number, message: string): Promise {
    if (this.appService.isDesktop()) {
      const signature: string = this.appService.sendIpcMessageSync('ledger-sign', {accountIndex, message});
      if (signature.startsWith('Error: ')) {
        throw new Error(signature);
      }
      return signature;
    } else {
      const transport = await TransportWebUSB.create();
      let offset = 0;
      while (offset !== message.length) {
        let chunk: string;
        if (message.length - offset > 510) {
          chunk = message.substr(offset, 510);
        } else {
          chunk = message.substr(offset);
        }
        let apdu = '8002';
        const final = (offset + chunk.length) === message.length;
        apdu += final ? '80' : '00';
        apdu += this.byteToHex(accountIndex);
        apdu += this.byteToHex(chunk.length / 2);
        apdu += chunk;
        offset += chunk.length;
        const result: Buffer = await transport.exchange(Buffer.from(apdu, 'hex'));
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 MyEtherWallet / MyEtherWallet / src / wallets / hardware / ledger / index.js View on Github external
const getLedgerTransport = async () => {
  let transport;
  const support = await isWebUsbSupported();
  if (support) {
    transport = await webUsbTransport.create();
  } else {
    transport = await u2fTransport.create(OPEN_TIMEOUT, LISTENER_TIMEOUT);
  }
  return transport;
};
const getLedgerAppConfig = async _ledger => {