Ledger Developer Portal · Report Bug · Request Feature
The Device Management Kit (DMK) is a TypeScript library that provides easy communication with Ledger devices:
- Device discovery, identification, and connection
- Device management operations (app installation, device info retrieval) with comprehensive status tracking and error handling
- Ledger OS interaction
- App interaction for cryptographic operations
- Address derivation, message and transaction signing
- App installation and management
- 🔜 OS updates
The Device Management Kit features an interface for applications to handle any Ledger device (a.k. hardware wallets). It converts intention into
flowchart LR;
application(Application) <--API--> LDMK(LedgerDeviceManagementKit) <--USB/BLE--> device(Device);
The Device Management Kit is available in 3 different environments (web, Android & iOS).
This repository contains the web implementation of the Device Management Kit, built with TypeScript.
The Device Management Kit is structured as a monorepository that centralizes all TypeScript code related to the Device Management Kit in one place.
This project uses turbo monorepo to build and release different packages on NPM registry and a sample demo application on Vercel.
A brief overview of this project's packages:
Name | Path | Description |
---|---|---|
@ledgerhq/device-management-kit | packages/device-management-kit | Core package containing the main Device Management Kit functionality |
Name | Path | Description |
---|---|---|
@ledgerhq/device-transport-kit-web-hid | packages/transport/web-hid | Web HID transport implementation |
@ledgerhq/device-transport-kit-web-ble | packages/transport/web-ble | Web BLE transport implementation |
@ledgerhq/device-transport-kit-react-native-ble | packages/transport/rn-ble | React Native BLE transport implementation |
@ledgerhq/device-transport-kit-react-native-hid | packages/transport/rn-hid | React Native HID transport implementation |
@ledgerhq/device-transport-kit-speculos | packages/transport/speculos | Speculos transport implementation for testing |
Name | Path | Description |
---|---|---|
@ledgerhq/device-signer-kit-bitcoin | packages/signer/signer-btc | Bitcoin coin application dedicated handlers |
@ledgerhq/device-signer-kit-ethereum | packages/signer/signer-eth | Ethereum coin application dedicated handlers |
@ledgerhq/device-signer-kit-solana | packages/signer/signer-solana | Solana coin application dedicated handlers |
Name | Path | Description |
---|---|---|
@ledgerhq/device-trusted-app-kit-ledger-keyring-protocol | packages/trusted-apps/ledger-keyring-protocol | Ledger Keyring Protocol implementation |
Name | Path | Description |
---|---|---|
@ledgerhq/device-management-kit-sample | apps/sample | React Next web app used to test & demonstrate the Device Management Kit |
@ledgerhq/device-management-kit-flipper-plugin-client | packages/flipper-plugin-client | Flipper logger for Device Management Kit |
@ledgerhq/device-mockserver-client | packages/mockserver-client | Client to interact with the mock-server |
Name | Path | Description |
---|---|---|
@ledgerhq/eslint-config-dsdk | packages/config/eslint | ESLint shared configuration |
@ledgerhq/vitest-config-dmk | packages/config/vitest | Vitest shared configuration |
@ledgerhq/tsconfig-dsdk | packages/config/typescript | TypeScript shared configuration |
💡 The following steps describe only a minimal setup. You will need to perform additional installation steps depending on the package you want to work on, please refer to its nested README file.
proto is used as the toolchain manager to install the right version of every tool.
pnpm is used as the package manager to install all the dependencies. It is normally provided by Proto (see below).
1- Clone the repository
git clone [email protected]:LedgerHQ/device-sdk-ts.git
cd device-sdk-ts
Important: All the commands should be run at the root of the monorepo.
2- Configure using proto
proto use
3- Install dependencies
pnpm i
4- Check the shell configuration file
In you shell configuration file (e.g. .bashrc or .zshrc ) verify the path for proto
is correctly set.
Update it if needed according to the description below.
# proto
export PROTO_HOME="$HOME/.proto"
export PATH="$PROTO_HOME/shims:$PROTO_HOME/bin:$PATH"
Vitest is used for unit testing.
Each package is tested using the following command (at the root of the monorepo).
pnpm <package> test
Each package is built using the following command (at the root of the monorepo).
Device Management Kit main module.
pnpm dmk build
Transaction and message signing module. Each signer is its own package. Here is an exemple with the Ethereum signer:
pnpm signer-eth build
Security dedicated application interface module. Example with the Ledger Keyring Protocol trusted app:
pnpm app-keyring build
Sample application module.
pnpm sample build
pnpm doc build
This project uses Github CI. Please have a look to the following link for more details: GitHub
To avoid task repetition, you can add scripts to the corresponding package's script folder, or to a root script folder if they concern multiple packages.
A script is a .mjs
file interpreted by zx.
We use hygen
to quickly scaffold code and accelerate our development process.
Each project can have its own _templates
folder, making generators scoped to their respective projects.
The _templates
folder contains the basic generators to create new ones.
workspace | script | description |
---|---|---|
📦 dmk | module:create |
scaffolds a new src/internal module |
The easiest way would be to use hygen
from the root folder as so:
Options:
new
: creates a generator that takes no input during creation (but can still access metadata)with-prompt
: creates a generator that can take some input during creation (with access to metadata)
Important: All the commands should be run at the root of the monorepo.
pnpm hygen generator with-prompt|new name
This command will create a new generator folder in the root _templates
with the given name
.
It's there so that we can modify this new generator.
When done, move the new generator to it's correct project _templates
folder (again, so we can keep scope).
Finally, we should add a script in the correct package.json
as a shortcut to trigger the new generator.
eg:
pnpm dmk module:create
Under the hood, the script looks like this:
pnpm hygen <name> with-prompt
name
is the name given during the creation of the generator.with-prompt
to call the prompted version of the generator (there can be multiple targets, likenew
)
To build the required dependencies and start a dev server for the sample app, please execute the following command at the root of the repository.
pnpm dev
Each project folder has a README.md
file which contains basic documentation.
It includes background information about the project and how to setup, run and build it.
Please refer to the core package readme.
Please check the general guidelines for contributing to Ledger Live projects: CONTRIBUTING.md
.
Each individual project may include its own specific guidelines, located within its respective folder.
Please check each project's LICENSE
file, most of them are under the Apache-2.0
license.