Skip to content

Commit 550a75a

Browse files
committed
📝 (transports): Add missing readme.md to transport packages
1 parent 40a001e commit 550a75a

File tree

5 files changed

+201
-45
lines changed

5 files changed

+201
-45
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ Device Management Kit main module.
189189
pnpm dmk build
190190
```
191191

192-
### Signer
192+
### Signers
193193

194194
Transaction and message signer module.
195195

196196
```bash
197-
pnpm signer build
197+
pnpm signer-eth build
198198
```
199199

200200
### Trusted Apps
@@ -221,6 +221,12 @@ Sample application module.
221221
pnpm sample build
222222
```
223223

224+
#### Documentation
225+
226+
```bash
227+
pnpm doc build
228+
```
229+
224230
# Processes & usage
225231

226232
## Continuous integration
@@ -295,7 +301,7 @@ It includes background information about the project and how to setup, run and b
295301

296302
## Reference API
297303

298-
Please refer to the core package [**readme**](https://github.com/LedgerHQ/device-sdk-ts/blob/develop/packages/core/README.md).
304+
Please refer to the core package [**readme**](https://github.com/LedgerHQ/device-sdk-ts/blob/develop/packages/device-management-kit/README.md).
299305

300306
# Contributing
301307

danger/helpers.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { execSync } from "child_process";
1111
type FailFn = (message: MarkdownString, file?: string, line?: number) => void;
1212
type MessageFn = (
1313
message: MarkdownString,
14-
opts?: { file?: string; line?: number; icon?: MarkdownString },
14+
opts?: { file?: string; line?: number; icon?: MarkdownString }
1515
) => void;
1616

1717
export const BRANCH_PREFIX = [
@@ -44,13 +44,13 @@ export const isFork = (pr: GitHubPRDSL) => pr?.head?.repo?.fork ?? false;
4444
const Branch = (
4545
danger: DangerDSLType,
4646
fail: FailFn,
47-
isFork: boolean = false,
47+
isFork: boolean = false
4848
) => ({
4949
regex: isFork
5050
? new RegExp(`^(${BRANCH_PREFIX.join("|")})\/.+`, "i")
5151
: new RegExp(
5252
`^(${BRANCH_PREFIX.join("|")})\/((dsdk)-[0-9]+|no-issue|issue-[0-9]+)\-.+`,
53-
"i",
53+
"i"
5454
),
5555

5656
getBranch: () => {
@@ -99,7 +99,7 @@ Please fix the PR branch name to match the convention, see [CONTRIBUTING.md](htt
9999
export const checkBranches = (
100100
danger: DangerDSLType,
101101
fail: FailFn,
102-
fork: boolean = false,
102+
fork: boolean = false
103103
) => {
104104
const config = Branch(danger, fail, fork);
105105
const currentBranch = config.getBranch();
@@ -115,7 +115,7 @@ export const checkBranches = (
115115
const Commits = (
116116
danger: DangerDSLType,
117117
fail: FailFn,
118-
fork: boolean = false,
118+
fork: boolean = false
119119
) => ({
120120
regex: /^.+\(([a-z]+\-?){1,}\): [A-Z].*/,
121121

@@ -146,7 +146,7 @@ Example: \`💚 (scope): My feature\`\
146146

147147
const currentBranch = Branch(danger, fail, fork).getBranch();
148148
return execSync(
149-
`git log origin/develop..${currentBranch} --pretty=format:%s`,
149+
`git log origin/develop..${currentBranch} --pretty=format:%s`
150150
)
151151
.toString()
152152
.split("\n");
@@ -156,14 +156,14 @@ Example: \`💚 (scope): My feature\`\
156156
export const checkCommits = (
157157
danger: DangerDSLType,
158158
fail: FailFn,
159-
fork: boolean = false,
159+
fork: boolean = false
160160
) => {
161161
const config = Commits(danger, fail, fork);
162162
const branchCommits = config.getCommits();
163163
console.log("Branch commits:", branchCommits);
164164

165165
const wrongCommits = branchCommits.filter(
166-
(commit) => !config.regex.test(commit),
166+
(commit) => !config.regex.test(commit)
167167
);
168168

169169
if (wrongCommits.length > 0) {
@@ -225,7 +225,7 @@ Please fix the PR title to match the convention, see [CONTRIBUTING.md](https://g
225225
export const checkTitle = (
226226
danger: DangerDSLType,
227227
fail: FailFn,
228-
fork: boolean = false,
228+
fork: boolean = false
229229
) => {
230230
const config = Title(danger, fail, fork);
231231
if (!config.regex.test(danger.github.pr.title)) {
@@ -240,10 +240,10 @@ export const checkChangesets = (danger: DangerDSLType, message: MessageFn) => {
240240
const changesetFiles = danger.git.fileMatch("**/.changeset/*.md");
241241
if (changesetFiles.edited === false) {
242242
message(
243-
`\ No changeset file found in the PR. Please add a changeset file.`,
243+
`\ No changeset file found. Please make sure this is intended or add a changeset file.`,
244244
{
245245
icon: "⚠️",
246-
},
246+
}
247247
);
248248
return false;
249249
}

packages/device-management-kit/README.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
- [Installation](#installation)
99
- [Usage](#usage)
1010
- [Compatibility](#compatibility)
11-
- [Pre-requisites](#pre-requisites)
1211
- [Main Features](#main-features)
1312
- [Setting up the SDK](#setting-up-the-sdk)
1413
- [Connecting to a Device](#connecting-to-a-device)
@@ -37,13 +36,9 @@ npm install @ledgerhq/device-management-kit
3736

3837
## Usage
3938

40-
### Compatibility
41-
42-
This library works in [any browser supporting the WebHID API](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API#browser_compatibility).
43-
4439
### Pre-requisites
4540

46-
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 this SDK. You can refer to [RxJS documentation](https://rxjs.dev/guide/overview) for more information.
41+
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 this dmk. You can refer to [RxJS documentation](https://rxjs.dev/guide/overview) for more information.
4742

4843
### Main Features
4944

@@ -60,48 +55,49 @@ Some of the APIs exposed return objects of type `Observable` from RxJS. Ensure y
6055
> [!NOTE]
6156
> At the moment we do not provide the possibility to distinguish two devices of the same model, via USB and to avoid connection to the same device twice.
6257
63-
### Setting up the SDK
58+
### Setting up the DMK
6459

65-
The core package exposes an SDK builder `DeviceSdkBuilder` which will be used to initialise the SDK with your configuration.
60+
The core package exposes a DMK builder `DeviceManagementKitBuilder` which will be used to initialise the DMK with your configuration.
6661

6762
For now it allows you to add one or more custom loggers.
6863

69-
In the following example, we add a console logger (`.addLogger(new ConsoleLogger())`). Then we build the SDK with `.build()`.
64+
In the following example, we add a console logger (`.addLogger(new ConsoleLogger())`) and a WebHID transport. Then we build the DMK with `.build()`.
7065

71-
**The returned object will be the entrypoint for all your interactions with the SDK.**
66+
**The returned object will be the entrypoint for all your interactions with the DMK.**
7267

73-
The SDK should be built only once in your application runtime so keep a reference of this object somewhere.
68+
The DMK should be built only once in your application runtime so keep a reference of this object somewhere.
7469

7570
```ts
7671
import {
7772
ConsoleLogger,
78-
DeviceSdk,
79-
DeviceSdkBuilder,
73+
DeviceManagementKitBuilder,
8074
} from "@ledgerhq/device-management-kit";
75+
import { webHidTransportFactory } from "@ledgerhq/device-transport-kit-web-hid";
8176

82-
export const sdk = new DeviceSdkBuilder()
77+
export const sdk = new DeviceManagementKitBuilder()
8378
.addLogger(new ConsoleLogger())
79+
.addTransport(webHidTransportFactory)
8480
.build();
8581
```
8682

8783
### Connecting to a Device
8884

8985
There are two steps to connecting to a device:
9086

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

10096
```ts
101-
sdk.startDiscovering().subscribe({
97+
dmk.startDiscovering().subscribe({
10298
next: (device) => {
103-
sdk.connect({ deviceId: device.id }).then((sessionId) => {
104-
const connectedDevice = sdk.getConnectedDevice({ sessionId });
99+
dmk.connect({ deviceId: device.id }).then((sessionId) => {
100+
const connectedDevice = dmk.getConnectedDevice({ sessionId });
105101
});
106102
},
107103
error: (error) => {
@@ -112,8 +108,8 @@ sdk.startDiscovering().subscribe({
112108

113109
Then once a device is connected:
114110

115-
- **Disconnection**: `sdk.disconnect({ sessionId })`
116-
- **Observe the device session state**: `sdk.getDeviceSessionState({ sessionId })`
111+
- **Disconnection**: `dmk.disconnect({ sessionId })`
112+
- **Observe the device session state**: `dmk.getDeviceSessionState({ sessionId })`
117113
- This will return an `Observable<DeviceSessionState>` to listen to the known information about the device:
118114
- device status:
119115
- ready to process a command
@@ -154,7 +150,7 @@ const apdu = new ApduBuilder(openAppApduArgs)
154150

155151
// ### 2. Sending the APDU
156152

157-
const apduResponse = await sdk.sendApdu({ sessionId, apdu });
153+
const apduResponse = await dmk.sendApdu({ sessionId, apdu });
158154

159155
// ### 3. Parsing the result
160156

@@ -178,7 +174,7 @@ The `sendCommand` method will take care of building the APDU, sending it to the
178174
> ### ❗️ Error Responses
179175
>
180176
> Most of the commands will reject with an error if the device is locked.
181-
> 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.
177+
> 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.
182178
>
183179
> Most of the commands will reject with an error if the response status word is not `0x9000` (success response from the device).
184180
@@ -191,7 +187,7 @@ import { OpenAppCommand } from "@ledgerhq/device-management-kit";
191187

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

194-
await sdk.sendCommand({ sessionId, command });
190+
await dmk.sendCommand({ sessionId, command });
195191
```
196192

197193
#### Close App
@@ -203,36 +199,36 @@ import { CloseAppCommand } from "@ledgerhq/device-management-kit";
203199

204200
const command = new CloseAppCommand();
205201

206-
await sdk.sendCommand({ sessionId, command });
202+
await dmk.sendCommand({ sessionId, command });
207203
```
208204

209205
#### Get OS Version
210206

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

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

218214
const command = new GetOsVersionCommand();
219215

220216
const { seVersion, mcuSephVersion, mcuBootloaderVersion } =
221-
await sdk.sendCommand({ sessionId, command });
217+
await dmk.sendCommand({ sessionId, command });
222218
```
223219

224220
#### Get App and Version
225221

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

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

233229
const command = new GetAppAndVersionCommand();
234230

235-
const { name, version } = await sdk.sendCommand({ sessionId, command });
231+
const { name, version } = await dmk.sendCommand({ sessionId, command });
236232
```
237233

238234
### Building a Custom Command
@@ -264,7 +260,7 @@ import {
264260

265261
const openAppDeviceAction = new OpenAppDeviceAction({ appName: "Bitcoin" });
266262

267-
const { observable, cancel } = await sdk.executeDeviceAction({
263+
const { observable, cancel } = await dmk.executeDeviceAction({
268264
deviceAction: openAppDeviceAction,
269265
command,
270266
});

packages/transport/web-ble/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Transport Device Kit Web BLE
2+
3+
> [!CAUTION]
4+
> This is still under development and we are free to make new interfaces which may lead to breaking changes.
5+
6+
- [Transport Device Kit Web HID Documentation](#transport-device-kit-web-ble)
7+
- [Description](#description)
8+
- [Installation](#installation)
9+
- [Usage](#usage)
10+
- [Compatibility](#compatibility)
11+
- [Pre-requisites](#pre-requisites)
12+
- [Main Features](#main-features)
13+
- [How To](#how-to)
14+
15+
## Description
16+
17+
This transport is used to interact with a Ledger device through the Web BLE (Bluetooth) implementation.
18+
19+
## Installation
20+
21+
To install the core package, run the following command:
22+
23+
```sh
24+
npm install @ledgerhq/device-transport-kit-web-ble
25+
```
26+
27+
## Usage
28+
29+
### Compatibility
30+
31+
This library works in [any browser supporting the Web Bluetooth API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API#browser_compatibility).
32+
33+
### Pre-requisites
34+
35+
To use this transport, you need to have the DMK installed on your project as well.
36+
37+
### Main Features
38+
39+
- Exposing a transport factory to be injected into the DeviceManagementKit
40+
- Exposing the transport directly for a custom configuration
41+
42+
### How To
43+
44+
To use the transport, you need to inject it in the DeviceManagementKitBuilder before the build. This will allow the DMK to find and interact with devices on the Web BLE protocol.
45+
46+
```typescript
47+
import { DeviceManagementKitBuilder } from "@ledgerhq/device-management-kit"
48+
import { webBleTransportFactory, WebBleTransport } from "@ledgerhq/device-transport-kit-web-ble"
49+
50+
// Easy setup with the factory
51+
const dmk = new DeviceManagementKitBuilder()
52+
.addTransport(webBleTransportFactory)
53+
.build();
54+
55+
56+
// With custom config
57+
const dmk = new DeviceManagementKitBuilder()
58+
.addTransport(({
59+
deviceModelDataSource: DeviceModelDataSource;
60+
loggerServiceFactory: (tag: string) => LoggerPublisherService;
61+
config: DmkConfig;
62+
apduSenderServiceFactory: ApduSenderServiceFactory;
63+
apduReceiverServiceFactory: ApduReceiverServiceFactory;
64+
}) => {
65+
// custom code
66+
return new WebBleTransport(
67+
deviceModelDataSource,
68+
loggerServiceFactory,
69+
config,
70+
apduSenderServiceFactory,
71+
apduReceiverServiceFactory,
72+
);
73+
})
74+
.build();
75+
76+
// Youn can then make use of the DMK
77+
```

0 commit comments

Comments
 (0)