@emurgo/ledger-connect-handler

7.0.1 • Public • Published

yoroi-extension-ledger-connect-handler

This library enables Yoroi extension to communicate with Ledger device, in process this library needs one web page that directly communicates with Ledger device. This library is responsible for opening, sendind resquest, passing back response to Yoroi and closing the target web page.

Message Passing

ledger-content-script

Flow:

  1. Yoroi requests yoroi-extension-ledger-connect-handler(Using function call).
  2. yoroi-extension-ledger-connect-handler opens target Website.
  3. yoroi-extension-ledger-connect-handler sends request message to content-script(Using extension port).
  4. content-script passes request to the target Website app(Using postMessage()).
  5. Target Website app processes the request and send response to content-script(Using postMessage()).
  6. content-script passes response to yoroi-extension-ledger-connect-handler(Using extension port).
  7. Finally, yoroi-extension-ledger-connect-handler passes response to Yoroi(Using function return).

Supported Functions

getExtendedPublicKey

Inputs

{
  serial: ?string,
  params: {
    path: BIP32Path
  },
}

Outputs

{
  deriveSerial: {
    serial: string
  },
  deviceVersion: {
    flags: Flags,
    major: string,
    minor: string,
    patch: string
  },
  response: GetExtendedPublicKeysResponse<GetExtendedPublicKeyResponse>
}

getExtendedPublicKeys

Inputs

{
  serial: ?string,
  params: {
    paths: Array<BIP32Path>
  },
}

Outputs

{
  deriveSerial: {
    serial: string
  },
  deviceVersion: {
    flags: Flags,
    major: string,
    minor: string,
    patch: string
  },
  response: GetExtendedPublicKeysResponse<GetExtendedPublicKeysResponse>
}

signTransaction

Inputs

{
  serial: ?string,
  params: Transaction,
}

Outputs

SignTransactionResponse

showAddress

Inputs

{|
  serial: ?string,
  params: {
    ...ShowAddressRequest,
    expectedAddr: string,
  },
|}

Outputs

undefined

deriveAddress

Inputs

{
  serial: ?string,
  params: DeriveAddressRequest,
}

Outputs

DeriveAddressResponse

getVersion

Inputs

{
  serial: ?string,
  params: undefined,
}

Outputs

GetVersionResponse

getSerial

Inputs

{
  serial: ?string,
  params: undefined,
}

Outputs

GetSerialResponse

Example

Import

import LedgerConnect from 'yoroi-extension-ledger-connect-handler';

Create new instance


const ledgerConnect = new LedgerConnect(config);

config is type of: Config

Calling function

const deviceVersionResp = await ledgerConnect.getVersion();

Supported Ledger Transport

Building up

  • nvm i
  • yarn
  • yarn run build

Publishing

Make sure you have followed Building up steps before publishing.

  • npm publish

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
7.0.14latest

Version History

VersionDownloads (Last 7 Days)Published
7.0.14
6.0.00
5.0.00
4.7.00
4.6.00
4.5.00
4.4.01
4.3.01
4.2.00
4.1.00
4.0.00
3.1.20
3.1.10
3.1.00
3.0.20
3.0.10
3.0.00
2.0.50

Package Sidebar

Install

npm i @emurgo/ledger-connect-handler

Weekly Downloads

6

Version

7.0.1

License

MIT

Unpacked Size

32.1 kB

Total Files

13

Last publish

Collaborators

  • cryptotitan
  • twwu123
  • lisicky_emurgo
  • stackchain
  • vsubhuman