Skip to content

Commit

Permalink
doc: add new changes from device management kit to portal
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 27, 2025
1 parent 7f71d1c commit e677f26
Show file tree
Hide file tree
Showing 64 changed files with 1,430 additions and 6,117 deletions.
18 changes: 7 additions & 11 deletions pages/docs/device-interaction/_meta.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
export default {
'---': {
title: 'Device Interaction',
type: 'separator'
},
'getting-started': "Getting started",
beginner: "Beginner's guides",
integration: "Integration walkthroughs",
references: "References",
explanation: "Explanation",
ledgerjs: "LedgerJS: Soon deprecated"
}
docs: "Ledger Device Management Kits",
explanations: "Explanations",
beginners: "Beginner's guide",
integration_walkthroughs: "Integration Walkthrough",
migrations: "Migrations",
references: "References (TSDoc)",
};
23 changes: 0 additions & 23 deletions pages/docs/device-interaction/beginner/init_dmk.mdx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
setup: "Setup",
init_dmk: "Initialize Device Management Kit",
discover_and_connect: "Discover and connect",
exchange_data: "Exchange data with the device"
exchange_data: "Exchange data with the device",
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

There are two steps to connecting to a device:

- **Discovery**: `sdk.startDiscovering()`
- **Discovery**: `dmk.startDiscovering()`
- Returns an observable which will emit a new `DiscoveredDevice` for every scanned device.
- The `DiscoveredDevice` objects contain information about the device model.
- Use one of these values to connect to a given discovered device.
- **Connection**: `sdk.connect({ deviceId: device.id })`
- **Connection**: `dmk.connect({ deviceId: device.id })`
- Returns a Promise resolving in a device session identifier `DeviceSessionId`.
- **Keep this device session identifier to further interact with the device.**
- Then, `sdk.getConnectedDevice({ sessionId })` returns the `ConnectedDevice`, which contains information about the device model and its name.
- Then, `dmk.getConnectedDevice({ sessionId })` returns the `ConnectedDevice`, which contains information about the device model and its name.

```ts
sdk.startDiscovering().subscribe({
dmk.startDiscovering().subscribe({
next: (device) => {
sdk.connect({ deviceId: device.id }).then((sessionId) => {
const connectedDevice = sdk.getConnectedDevice({ sessionId });
dmk.connect({ deviceId: device.id }).then((sessionId) => {
const connectedDevice = dmk.getConnectedDevice({ sessionId });
});
},
error: (error) => {
Expand All @@ -26,8 +26,8 @@ sdk.startDiscovering().subscribe({

Then once a device is connected:

- **Disconnection**: `sdk.disconnect({ sessionId })`
- **Observe the device session state**: `sdk.getDeviceSessionState({ sessionId })`
- **Disconnection**: `dmk.disconnect({ sessionId })`
- **Observe the device session state**: `dmk.getDeviceSessionState({ sessionId })`
- This will return an `Observable<DeviceSessionState>` to listen to the known information about the device:
- device status:
- ready to process a command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const apdu = new ApduBuilder(openAppApduArgs)

// ### 2. Sending the APDU

const apduResponse = await sdk.sendApdu({ sessionId, apdu });
const apduResponse = await dmk.sendApdu({ sessionId, apdu });

// ### 3. Parsing the result

Expand All @@ -53,7 +53,7 @@ The `sendCommand` method will take care of building the APDU, sending it to the
> ## ❗️ Error Responses
>
> Most of the commands will reject with an error if the device is locked.
> Ensure that the device is unlocked before sending commands. You can check the device session state (`sdk.getDeviceSessionState`) to know if the device is locked.
> Ensure that the device is unlocked before sending commands. You can check the device session state (`dmk.getDeviceSessionState`) to know if the device is locked.
>
> Most of the commands will reject with an error if the response status word is not `0x9000` (success response from the device).
Expand All @@ -66,7 +66,7 @@ import { OpenAppCommand } from "@ledgerhq/device-management-kit";

const command = new OpenAppCommand("Bitcoin"); // Open the Bitcoin app

await sdk.sendCommand({ sessionId, command });
await dmk.sendCommand({ sessionId, command });
```

### Close App
Expand All @@ -78,36 +78,36 @@ import { CloseAppCommand } from "@ledgerhq/device-management-kit";

const command = new CloseAppCommand();

await sdk.sendCommand({ sessionId, command });
await dmk.sendCommand({ sessionId, command });
```

### Get OS Version

This command will return information about the currently installed OS on the device.

> ℹ️ If you want this information you can simply get it from the device session state by observing it with `sdk.getDeviceSessionState({ sessionId })`.
> ℹ️ If you want this information you can simply get it from the device session state by observing it with `dmk.getDeviceSessionState({ sessionId })`.
```ts
import { GetOsVersionCommand } from "@ledgerhq/device-management-kit";

const command = new GetOsVersionCommand();

const { seVersion, mcuSephVersion, mcuBootloaderVersion } =
await sdk.sendCommand({ sessionId, command });
await dmk.sendCommand({ sessionId, command });
```

### Get App and Version

This command will return the name and version of the currently running app on the device.

> ℹ️ If you want this information you can simply get it from the device session state by observing it with `sdk.getDeviceSessionState({ sessionId })`.
> ℹ️ If you want this information you can simply get it from the device session state by observing it with `dmk.getDeviceSessionState({ sessionId })`.
```ts
import { GetAppAndVersionCommand } from "@ledgerhq/device-management-kit";

const command = new GetAppAndVersionCommand();

const { name, version } = await sdk.sendCommand({ sessionId, command });
const { name, version } = await dmk.sendCommand({ sessionId, command });
```

## Sending a Pre-defined flow - Device Actions
Expand Down
25 changes: 25 additions & 0 deletions pages/docs/device-interaction/beginners/init_dmk.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Setting up the DMK

The core package exposes a builder `DeviceManagementKitBuilder` which will be used to initialise the DMK with your configuration.

For now it allows you to add one or more custom loggers and transports.

In the following example, we add a console logger (`.addLogger(new ConsoleLogger())`), then the WebHID transport (`.addTransport(webHidTransportFactory)`).
Then we build the DMK with `.build()`.

**The returned object will be the entrypoint for all your interactions with the DMK. You should keep it as a <u>SINGLETON</u>.**

The DMK should be built only once in your application runtime so keep a reference of this object somewhere.

```ts
import {
ConsoleLogger,
DeviceManagementKitBuilder,
} from "@ledgerhq/device-management-kit";
import { webHidTransportFactory } from "@ledgerhq/device-transport-kit-web-hid";

export const dmk = new DeviceManagementKitBuilder()
.addLogger(new ConsoleLogger())
.addTransport(webHidTransportFactory)
.build();
```
23 changes: 23 additions & 0 deletions pages/docs/device-interaction/beginners/setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Setup

## Description

This package contains the core of the Device Management Kit. It provides a simple interface to handle Ledger devices and features the Device Management Kit's entry points, classes, types, structures, and models.

## Installation

To install the dmk package, run the following command:

```sh
npm install @ledgerhq/device-management-kit
```

## Usage

### Compatibility

This library works in [any browser supporting the WebHID API](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API#browser_compatibility).

### Pre-requisites

Some of the APIs exposed return objects of type `Observable` from RxJS. Ensure you are familiar with the basics of the Observer pattern and RxJS before using the DMK. You can refer to [RxJS documentation](https://rxjs.dev/guide/overview) for more information.
35 changes: 35 additions & 0 deletions pages/docs/device-interaction/docs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Callout } from "nextra/components";

# Documentation

Here you will find the all the documention related to the device management kit and all the signer coming along with it.

<Callout type="warning" emoji="⚠️">
This project is still in early development so we allow ourselves to make
breaking changes regarding the usage of the Libraries.

That's why any feedback is relevant for us in order to be able to make it stable as soon as
possible. Get in touch with us on the [Ledger Discord
server](https://developers.ledger.com/discord/) to provide your feedbacks.

You can follow the migration guidelines [here](./migrations/)

</Callout>

## Glossary

Throughout all the documentation we will use several acronyms that you can find the following description :

- DMK: Device Management Kit
- DSK: Device Signer Kit

## Libraries

Here you can found a summary of all the libraries that are composing the DMK

| Library | NPM | Version |
| ---------------------- | -------------------------------------------------------------------------------------------------------------- | ------- |
| Device Management Kit | [@LedgerHQ/device-mangement-kit](https://www.npmjs.com/package/@ledgerhq/device-management-kit) | 0.6.0 |
| Device Signer Ethereum | [@LedgerHQ/device-signer-kit-ethereum](https://www.npmjs.com/package/@ledgerhq/device-signer-kit-ethereum) | 1.2.0 |
| WebHidTransport | [@ledgerhq/device-transport-kit-web-hid](https://www.npmjs.com/package/@ledgerhq/device-transport-kit-web-hid) | 1.0.0 |
| WebBleTransport | [@ledgerhq/device-transport-kit-web-ble](https://www.npmjs.com/package/@ledgerhq/device-transport-kit-web-ble) | 1.0.0 |
5 changes: 0 additions & 5 deletions pages/docs/device-interaction/explanation/_meta.js

This file was deleted.

7 changes: 7 additions & 0 deletions pages/docs/device-interaction/explanations/_meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
introduction: "Why the Device Management Kit?",
ledgerjs: "Differences with LedgerJS",
dmk: "Device Management Kit",
signers: "Signer kits",
transports: "Transports",
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# What are Device Signer Kits?
# Signer Kits

As ledger devices are able to install applications that will allow to be compatible with different blockchains, we have created Device Signer Kits.
As ledger devices are able to install applications that will allow to be compatible with different blockchains,
we have created these kits.

Each **signer kit** is coming along with a Ledger Embedded App (ex: _signer-kit-eth_ is coming with _ledger app ethereum_ ).

The main goal of each signer is to ease interaction with the app in the most seamless way possible.

## Available Signers

- [Signer Ethereum](../references/signers/eth)
- [Signer Bitcoin](./signers/btc)
- [Signer Ethereum](./signers/eth)
- [Signer Solana](./signers/solana)
Loading

0 comments on commit e677f26

Please sign in to comment.