You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library works in [any browser supporting the WebHID API](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API#browser_compatibility).
43
-
44
39
### Pre-requisites
45
40
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.
47
42
48
43
### Main Features
49
44
@@ -60,48 +55,51 @@ Some of the APIs exposed return objects of type `Observable` from RxJS. Ensure y
60
55
> [!NOTE]
61
56
> 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.
62
57
63
-
### Setting up the SDK
58
+
### Setting up the DMK
64
59
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.
66
61
67
62
For now it allows you to add one or more custom loggers.
68
63
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()`.
70
65
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.**
72
67
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.
74
69
75
70
```ts
76
71
import {
77
72
ConsoleLogger,
78
-
DeviceSdk,
79
-
DeviceSdkBuilder,
73
+
DeviceManagementKitBuilder,
80
74
} from"@ledgerhq/device-management-kit";
75
+
import {
76
+
webHidTransportFactory
77
+
} from"@ledgerhq/device-transport-kit-web-hid"
81
78
82
-
exportconst sdk =newDeviceSdkBuilder()
79
+
exportconst sdk =newDeviceManagementKitBuilder()
83
80
.addLogger(newConsoleLogger())
81
+
.addTransport(webHidTransportFactory)
84
82
.build();
85
83
```
86
84
87
85
### Connecting to a Device
88
86
89
87
There are two steps to connecting to a device:
90
88
91
-
-**Discovery**: `sdk.startDiscovering()`
89
+
-**Discovery**: `dmk.startDiscovering()`
92
90
- Returns an observable which will emit a new `DiscoveredDevice` for every scanned device.
93
91
- The `DiscoveredDevice` objects contain information about the device model.
94
92
- Use one of these values to connect to a given discovered device.
@@ -178,7 +176,7 @@ The `sendCommand` method will take care of building the APDU, sending it to the
178
176
> ### ❗️ Error Responses
179
177
>
180
178
> 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.
179
+
> 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.
182
180
>
183
181
> Most of the commands will reject with an error if the response status word is not `0x9000` (success response from the device).
184
182
@@ -191,7 +189,7 @@ import { OpenAppCommand } from "@ledgerhq/device-management-kit";
191
189
192
190
const command =newOpenAppCommand("Bitcoin"); // Open the Bitcoin app
193
191
194
-
awaitsdk.sendCommand({ sessionId, command });
192
+
awaitdmk.sendCommand({ sessionId, command });
195
193
```
196
194
197
195
#### Close App
@@ -203,36 +201,36 @@ import { CloseAppCommand } from "@ledgerhq/device-management-kit";
203
201
204
202
const command =newCloseAppCommand();
205
203
206
-
awaitsdk.sendCommand({ sessionId, command });
204
+
awaitdmk.sendCommand({ sessionId, command });
207
205
```
208
206
209
207
#### Get OS Version
210
208
211
209
This command will return information about the currently installed OS on the device.
212
210
213
-
> ℹ️ If you want this information you can simply get it from the device session state by observing it with `sdk.getDeviceSessionState({ sessionId })`.
211
+
> ℹ️ If you want this information you can simply get it from the device session state by observing it with `dmk.getDeviceSessionState({ sessionId })`.
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.
This library works in [any browser supporting the WebHID API](https://developer.mozilla.org/en-US/docs/Web/API/WebHID_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 HID protocol.
0 commit comments