ledgerjs

Ledger's JavaScript libraries

  • 所有者: LedgerHQ/ledgerjs
  • 平台:
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Ledger Devs Slack
License

Welcome to Ledger's JavaScript libraries.

See also:

@ledgerhq/hw-transport-*

To communicate with a Ledger device, you first need to identify which transport(s) to use.

The hw-transport libraries implement communication protocol for our hardware wallet devices (Ledger Nano / Ledger Nano S / Ledger Nano X / Ledger Blue) in many platforms: Web, Node, Electron, React Native,... and using many different communication channels: U2F, HID, WebUSB, Bluetooth,..., Channels, U2F/WebAuthn, HID, WebUSB, Bluetooth, ----------, --------------, -----, --------, -----------, Blue, YES, YES, NO, NO, Nano S, YES, YES, YES, NO, Nano X, YES, YES, YES, YES, Summary of implementations available per platform, Platforms, U2F/WebAuthn, HID, WebUSB, Bluetooth, ------------------, ------------------, -----------------------------------, ---------------------, -------------------------------, Web, @ledgerhq/hw-transport-u2f (Chrome, Opera), @ledgerhq/hw-transport-webhid (Chrome DEV under experimental flags), @ledgerhq/hw-transport-webusb (Chrome), @ledgerhq/hw-transport-web-ble (Chrome), Electron/Node.js, NO, @ledgerhq/hw-transport-node-hid1, NO, @ledgerhq/hw-transport-node-ble, iOS, NO, NO, NO, @ledgerhq/react-native-hw-transport-ble, Android, @ledgerhq/hw-transport-u2f2, @ledgerhq/react-native-hid, @ledgerhq/hw-transport-webusb2, @ledgerhq/react-native-hw-transport-ble, 1. 3 implementations available

  1. via Android Chrome

Please find respective documentation for each transport:

An unified Transport interface

All these transports implement a generic interface exposed by
@ledgerhq/hw-transport.
There are specifics for each transport which are explained in each package.

A Transport is essentially:

  • Transport.listen: (observer)=>Subscription
  • Transport.open: (descriptor)=>Promise<Transport>
  • transport.exchange(apdu: Buffer): Promise<Buffer>
  • transport.close()

and some derivates:

  • transport.create(): Promise<Transport>: make use of listen and open for the most simple scenario.
  • transport.send(cla, ins, p1, p2, data): Promise<Buffer>: a small abstraction of exchange

NB: APDU is the encoding primitive for all binary exchange with the devices. (it comes from smart card industry)

@ledgerhq/hw-app-*

As soon as your Transport is created, you can already communicate by implementing the apps protocol (refer to application documentations, for instance BTC app and ETH app ones).

We also provide libraries that help implementing the low level exchanges. These higher level APIs are split per app:

Community packages:

We invite all third party app developers to not send PR to this repository to provide more implementations but instead to maintain your own version in your own repository and we would be happy to reference them here ♥.

Other packages

Published Packages, Package, Version, Description, ------------------------------------------------------------------------, ---------------------------------------------------------------------------------------------------------------------------------------------, ------------------------------------------------------------------------------------------------------------, create-dapp, npm, Ledger DApp Ethereum starter kit, @ledgerhq/web3-subprovider, npm, web3 subprovider implementation for web3-provider-engine, Development Tools, @ledgerhq/hw-transport-mocker, npm, Tool used for test to record and replay APDU calls., ## Basic gist

import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-web-usb";
// import Transport from "@ledgerhq/react-native-hw-transport-ble";
import AppBtc from "@ledgerhq/hw-app-btc";
const getBtcAddress = async () => {
  const transport = await Transport.create();
  const btc = new AppBtc(transport);
  const result = await btc.getWalletPublicKey("44'/0'/0'/0/0");
  return result.bitcoinAddress;
};
getBtcAddress().then(a => console.log(a));

Contributing

Please read our contribution guidelines before getting
started.

You need to have a recent Node.js and
Yarn installed.

Install dependencies

yarn

Build

Build all packages

yarn build

Watch

Watch all packages change. Very useful during development to build only file that changes.

yarn watch

Lint

Lint all packages

yarn lint

Run Tests

First of all, this ensure the libraries are correctly building, and passing lint and flow:

yarn test

then to test on a real device...

Plug a device like the Nano S and open Bitcoin app.

Then run the test and accept the commands on the devices for the tests to
continue.

yarn test-node

You can also test on the web:

yarn test-browser

make sure to configure your device app with "Browser support" set to "YES".

Deploy

Checklist before deploying a new release:

  • you have the right in the LedgerHQ org on NPM
  • you have run npm login once (check npm whoami)
  • Go to master branch
    • your master point on LedgerHQ repository (check with git config remote.$(git config branch.master.remote).url and fix it with git branch --set-upstream master origin/master)
    • you are in sync (git pull) and there is no changes in git status
  • Run yarn once, there is still no changes in git status

deploy a new release

 yarn run publish

then, go to /releases and create a release with change logs.

alternatively:

deploy a canary release (beta, etc)

 yarn run publish -c

NB: if there is a new package, AFAIK you need to manually npm publish it once on NPM.

主要指标

概览
名称与所有者LedgerHQ/ledgerjs
主编程语言TypeScript
编程语言JavaScript (语言数: 4)
平台
许可证Apache License 2.0
所有者活动
创建于2015-04-14 17:16:09
推送于2022-06-22 06:45:20
最后一次提交2022-06-08 10:41:46
发布数375
最新版本名称v6.28.2 (发布于 2022-05-05 11:06:46)
第一版名称1.1.0 (发布于 )
用户参与
星数572
关注者数90
派生数376
提交数1.7k
已启用问题?
问题数393
打开的问题数120
拉请求数387
打开的拉请求数4
关闭的拉请求数93
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?