@ledgerhq/device-management-kit-devtools-core 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/LICENSE.MD +202 -0
  2. package/README.md +193 -0
  3. package/lib/cjs/index.js +2 -0
  4. package/lib/cjs/index.js.map +7 -0
  5. package/lib/cjs/package.json +56 -0
  6. package/lib/cjs/src/index.js +2 -0
  7. package/lib/cjs/src/index.js.map +7 -0
  8. package/lib/cjs/src/inspector/DevToolsDmkInspector.js +2 -0
  9. package/lib/cjs/src/inspector/DevToolsDmkInspector.js.map +7 -0
  10. package/lib/cjs/src/inspector/DiscoveryHandler.js +2 -0
  11. package/lib/cjs/src/inspector/DiscoveryHandler.js.map +7 -0
  12. package/lib/cjs/src/inspector/commandHandlers.js +2 -0
  13. package/lib/cjs/src/inspector/commandHandlers.js.map +7 -0
  14. package/lib/cjs/src/inspector/constants.js +2 -0
  15. package/lib/cjs/src/inspector/constants.js.map +7 -0
  16. package/lib/cjs/src/inspector/deviceObserver.js +2 -0
  17. package/lib/cjs/src/inspector/deviceObserver.js.map +7 -0
  18. package/lib/cjs/src/inspector/discoveryObserver.js +2 -0
  19. package/lib/cjs/src/inspector/discoveryObserver.js.map +7 -0
  20. package/lib/cjs/src/inspector/serialization.js +2 -0
  21. package/lib/cjs/src/inspector/serialization.js.map +7 -0
  22. package/lib/cjs/src/logger/DevToolsLog.js +2 -0
  23. package/lib/cjs/src/logger/DevToolsLog.js.map +7 -0
  24. package/lib/cjs/src/logger/DevToolsLogger.js +2 -0
  25. package/lib/cjs/src/logger/DevToolsLogger.js.map +7 -0
  26. package/lib/cjs/src/logger/constants.js +2 -0
  27. package/lib/cjs/src/logger/constants.js.map +7 -0
  28. package/lib/cjs/src/logger/mapDmkLogToDevToolsLog.js +2 -0
  29. package/lib/cjs/src/logger/mapDmkLogToDevToolsLog.js.map +7 -0
  30. package/lib/cjs/src/modules.js +2 -0
  31. package/lib/cjs/src/modules.js.map +7 -0
  32. package/lib/cjs/src/types.js +2 -0
  33. package/lib/cjs/src/types.js.map +7 -0
  34. package/lib/esm/index.js +2 -0
  35. package/lib/esm/index.js.map +7 -0
  36. package/lib/esm/package.json +56 -0
  37. package/lib/esm/src/index.js +2 -0
  38. package/lib/esm/src/index.js.map +7 -0
  39. package/lib/esm/src/inspector/DevToolsDmkInspector.js +2 -0
  40. package/lib/esm/src/inspector/DevToolsDmkInspector.js.map +7 -0
  41. package/lib/esm/src/inspector/DiscoveryHandler.js +2 -0
  42. package/lib/esm/src/inspector/DiscoveryHandler.js.map +7 -0
  43. package/lib/esm/src/inspector/commandHandlers.js +2 -0
  44. package/lib/esm/src/inspector/commandHandlers.js.map +7 -0
  45. package/lib/esm/src/inspector/constants.js +2 -0
  46. package/lib/esm/src/inspector/constants.js.map +7 -0
  47. package/lib/esm/src/inspector/deviceObserver.js +2 -0
  48. package/lib/esm/src/inspector/deviceObserver.js.map +7 -0
  49. package/lib/esm/src/inspector/discoveryObserver.js +2 -0
  50. package/lib/esm/src/inspector/discoveryObserver.js.map +7 -0
  51. package/lib/esm/src/inspector/serialization.js +2 -0
  52. package/lib/esm/src/inspector/serialization.js.map +7 -0
  53. package/lib/esm/src/logger/DevToolsLog.js +1 -0
  54. package/lib/esm/src/logger/DevToolsLog.js.map +7 -0
  55. package/lib/esm/src/logger/DevToolsLogger.js +2 -0
  56. package/lib/esm/src/logger/DevToolsLogger.js.map +7 -0
  57. package/lib/esm/src/logger/constants.js +2 -0
  58. package/lib/esm/src/logger/constants.js.map +7 -0
  59. package/lib/esm/src/logger/mapDmkLogToDevToolsLog.js +2 -0
  60. package/lib/esm/src/logger/mapDmkLogToDevToolsLog.js.map +7 -0
  61. package/lib/esm/src/modules.js +2 -0
  62. package/lib/esm/src/modules.js.map +7 -0
  63. package/lib/esm/src/types.js +1 -0
  64. package/lib/esm/src/types.js.map +7 -0
  65. package/lib/types/index.d.ts +2 -0
  66. package/lib/types/index.d.ts.map +1 -0
  67. package/lib/types/src/index.d.ts +10 -0
  68. package/lib/types/src/index.d.ts.map +1 -0
  69. package/lib/types/src/inspector/DevToolsDmkInspector.d.ts +39 -0
  70. package/lib/types/src/inspector/DevToolsDmkInspector.d.ts.map +1 -0
  71. package/lib/types/src/inspector/DiscoveryHandler.d.ts +67 -0
  72. package/lib/types/src/inspector/DiscoveryHandler.d.ts.map +1 -0
  73. package/lib/types/src/inspector/commandHandlers.d.ts +34 -0
  74. package/lib/types/src/inspector/commandHandlers.d.ts.map +1 -0
  75. package/lib/types/src/inspector/constants.d.ts +39 -0
  76. package/lib/types/src/inspector/constants.d.ts.map +1 -0
  77. package/lib/types/src/inspector/deviceObserver.d.ts +16 -0
  78. package/lib/types/src/inspector/deviceObserver.d.ts.map +1 -0
  79. package/lib/types/src/inspector/discoveryObserver.d.ts +34 -0
  80. package/lib/types/src/inspector/discoveryObserver.d.ts.map +1 -0
  81. package/lib/types/src/inspector/serialization.d.ts +15 -0
  82. package/lib/types/src/inspector/serialization.d.ts.map +1 -0
  83. package/lib/types/src/logger/DevToolsLog.d.ts +9 -0
  84. package/lib/types/src/logger/DevToolsLog.d.ts.map +1 -0
  85. package/lib/types/src/logger/DevToolsLogger.d.ts +8 -0
  86. package/lib/types/src/logger/DevToolsLogger.d.ts.map +1 -0
  87. package/lib/types/src/logger/constants.d.ts +8 -0
  88. package/lib/types/src/logger/constants.d.ts.map +1 -0
  89. package/lib/types/src/logger/mapDmkLogToDevToolsLog.d.ts +4 -0
  90. package/lib/types/src/logger/mapDmkLogToDevToolsLog.d.ts.map +1 -0
  91. package/lib/types/src/modules.d.ts +14 -0
  92. package/lib/types/src/modules.d.ts.map +1 -0
  93. package/lib/types/src/types.d.ts +7 -0
  94. package/lib/types/src/types.d.ts.map +1 -0
  95. package/lib/types/tsconfig.prod.tsbuildinfo +1 -0
  96. package/package.json +56 -0
package/LICENSE.MD ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024-present Ledger
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,193 @@
1
+ # Device Management Kit DevTools Core
2
+
3
+ Core library for DMK developer tools. Contains:
4
+
5
+ - **`DevToolsLogger`** — Relays DMK logs to the devtools dashboard
6
+ - **`DevToolsDmkInspector`** — Enables device session inspection and DMK interaction from the dashboard
7
+
8
+ ## Getting Started
9
+
10
+ Choose the setup that matches your app:
11
+
12
+ - **Web, Node.js, Electron or React Native app** → [WebSocket devtools setup](../device-management-kit/README.md#web-nodejs-or-electron-app)
13
+ - **React Native app with Rozenite** → [Rozenite devtools setup](../device-management-kit/README.md#react-native-app-with-rozenite) _(recommended for RN — better DX, less setup)_
14
+
15
+ ## Architecture
16
+
17
+ The devtools system provides a bi-directional communication bridge between a client app (hosting the DMK) and a "Dashboard" app where the developer tools UI is displayed.
18
+
19
+ ```
20
+ Client App Dashboard
21
+ ┌──────────────────┐ ┌──────────────────┐
22
+ │ DevToolsLogger │────────▶│ Logger Screen │
23
+ │ │ │ │
24
+ │ DevToolsDmkInspector ◀────▶│ Inspector Screen │
25
+ └──────────────────┘ └──────────────────┘
26
+ │ │
27
+ └───────── Connector ────────┘
28
+ (WebSocket/Rozenite)
29
+ ```
30
+
31
+ ![DMK DevTools architecture](https://github.com/user-attachments/assets/2fa7785d-97e7-4f6c-a516-01eab2bccf15)
32
+
33
+ ### Packages
34
+
35
+ | Package | Description |
36
+ | ------------------------------ | ------------------------------------------------------------------------------------------------ |
37
+ | `devtools-core` | Core types, `DevToolsLogger` for logging, and `DevToolsDmkInspector` for session/DMK interaction |
38
+ | `devtools-ui` | React component for the devtools dashboard UI |
39
+ | `devtools-rozenite` | Connector for React Native apps using [Rozenite](https://www.rozenite.dev/) |
40
+ | `devtools-websocket-common` | Common types and constants for the WebSocket layer |
41
+ | `devtools-websocket-connector` | WebSocket connector implementation for client apps |
42
+ | `devtools-websocket-server` | Node WebSocket server that relays messages between client and dashboard |
43
+
44
+ ### Dashboard Implementations
45
+
46
+ There are two dashboard implementations:
47
+
48
+ - **Rozenite** (for React Native apps): The devtools appear directly in the React Native DevTools
49
+ - **Electron** (for all other platforms): A standalone desktop app (`apps/devtools`)
50
+
51
+ ### Module Architecture
52
+
53
+ #### Connector Interface
54
+
55
+ Both `DevToolsLogger` and `DevToolsDmkInspector` communicate with the dashboard through a `Connector` interface:
56
+
57
+ ```ts
58
+ interface Connector {
59
+ sendMessage: (type: string, payload: string) => void;
60
+ listenToMessages: (listener: (type: string, payload: string) => void) => {
61
+ unsubscribe: () => void;
62
+ };
63
+ }
64
+ ```
65
+
66
+ This interface is implemented by:
67
+
68
+ - `DevToolsWebSocketConnector` — for web, Node.js, Electron, and React Native apps
69
+ - `RozeniteConnector` — for React Native apps using Rozenite
70
+
71
+ #### Module Handshake
72
+
73
+ When a module is instantiated, it sends a `moduleConnected` message to identify itself to the dashboard. This allows the dashboard UI to show connection status for each module and conditionally render UI elements.
74
+
75
+ This mechanism helps developers integrating the tools verify that their setup is working as expected. For instance, if someone only sets up `DevToolsLogger` or only `DevToolsDmkInspector` (which is allowed, but could be a user mistake), the Dashboard UI will reflect it with visual indicators.
76
+
77
+ #### DevToolsLogger Protocol
78
+
79
+ `DevToolsLogger` provides **one-way communication** from the client app to the dashboard for log streaming.
80
+
81
+ ```mermaid
82
+ sequenceDiagram
83
+ participant App as Client App
84
+ participant Logger as DevToolsLogger
85
+ participant Dashboard
86
+
87
+ Logger->>Dashboard: moduleConnected (handshake)
88
+ App->>Logger: log()
89
+ Logger->>Dashboard: addLog
90
+ ```
91
+
92
+ | Direction | Message Type | Payload |
93
+ | ------------------ | ----------------- | ---------------------------------------------------------------------- |
94
+ | Client → Dashboard | `moduleConnected` | `{ module: "logger" }` |
95
+ | Client → Dashboard | `addLog` | `DevToolsLog` object (timestamp, tag, verbosity, message, payloadJSON) |
96
+
97
+ #### DevToolsDmkInspector Protocol
98
+
99
+ `DevToolsDmkInspector` provides **bi-directional communication** for device session inspection and DMK interaction.
100
+
101
+ **Session inspection flow:**
102
+
103
+ ```mermaid
104
+ sequenceDiagram
105
+ participant DMK
106
+ participant Inspector as DevToolsDmkInspector
107
+ participant Dashboard
108
+
109
+ Inspector->>Dashboard: moduleConnected (handshake)
110
+ Inspector->>Dashboard: connectedDevicesUpdate
111
+ DMK-->>Inspector: device connected
112
+ Inspector->>Dashboard: connectedDevicesUpdate
113
+ Inspector->>Dashboard: deviceSessionStateUpdate
114
+ Dashboard->>Inspector: disconnect
115
+ Inspector->>DMK: disconnect()
116
+ Dashboard->>Inspector: sendApdu
117
+ Inspector->>DMK: sendApdu()
118
+ Inspector->>Dashboard: apduResponse
119
+ ```
120
+
121
+ **Device discovery flow:**
122
+
123
+ ```mermaid
124
+ sequenceDiagram
125
+ participant DMK
126
+ participant Inspector as DevToolsDmkInspector
127
+ participant Dashboard
128
+
129
+ Dashboard->>Inspector: startListeningDevices
130
+ Inspector->>DMK: listenToAvailableDevices()
131
+ DMK-->>Inspector: DiscoveredDevice[]
132
+ Inspector->>Dashboard: discoveredDevicesUpdate
133
+ Dashboard->>Inspector: connectDevice
134
+ Inspector->>DMK: connect(device)
135
+ DMK-->>Inspector: sessionId
136
+ Inspector->>Dashboard: connectedDevicesUpdate
137
+ Dashboard->>Inspector: stopListeningDevices
138
+ ```
139
+
140
+ **Messages from Inspector to Dashboard:**
141
+
142
+ | Message Type | Payload | Description |
143
+ | -------------------------- | ---------------------------------------------------- | ---------------------------------------- |
144
+ | `moduleConnected` | `{ module: "dmk-inspector" }` | Handshake |
145
+ | `connectedDevicesUpdate` | `ConnectedDevice[]` | List of all connected devices |
146
+ | `deviceSessionStateUpdate` | `{ sessionId, state }` | Session state change |
147
+ | `providerValue` | `{ provider: number }` | Response to getProvider |
148
+ | `apduResponse` | `{ requestId, success, statusCode?, data?, error? }` | Response to sendApdu |
149
+ | `discoveredDevicesUpdate` | `DiscoveredDevice[]` | List of available devices for connection |
150
+
151
+ **Commands from Dashboard to Inspector:**
152
+
153
+ | Command Type | Payload | Description |
154
+ | ----------------------- | -------------------------------- | --------------------------------------------------- |
155
+ | `disconnect` | `{ sessionId }` | Disconnect a device session |
156
+ | `sendApdu` | `{ sessionId, apdu, requestId }` | Send raw APDU to device |
157
+ | `getProvider` | — | Request current provider value |
158
+ | `setProvider` | `{ provider: number }` | Set provider value |
159
+ | `startListeningDevices` | — | Start listening for available devices (passive) |
160
+ | `stopListeningDevices` | — | Stop listening for available devices |
161
+ | `startDiscovering` | — | Start active discovery (triggers permission prompt) |
162
+ | `stopDiscovering` | — | Stop active discovery |
163
+ | `connectDevice` | `{ deviceId }` | Connect to a discovered device |
164
+
165
+ #### Lifecycle
166
+
167
+ - **`DevToolsLogger`** — Instantiated _before_ DMK is built, then passed to `DeviceManagementKitBuilder.addLogger()`
168
+ - **`DevToolsDmkInspector`** — Instantiated _after_ DMK is built, requires the DMK instance
169
+ - Both modules should share the same `Connector` instance
170
+ - Call `DevToolsDmkInspector.destroy()` to clean up subscriptions when done
171
+
172
+ ### Features
173
+
174
+ #### DevToolsLogger
175
+
176
+ - [x] **Real-time log display** — View all DMK logs in real-time with verbosity levels and tags
177
+ - [x] **Filtering** — Filter logs by level and tag
178
+ - [x] **Export** — Export logs to JSON
179
+
180
+ #### DevToolsDmkInspector
181
+
182
+ - [x] **Device sessions inspector** — Display all connected device sessions and their live states
183
+ - List all active device sessions with device info (model, name, connection type)
184
+ - Show live `DeviceSessionState` for each session (status, battery, current app, OS info)
185
+ - [x] **Device session actions** — Interact with device sessions from the dashboard
186
+ - Disconnect a device session
187
+ - Send raw APDU commands to a session
188
+ - [x] **Device discovery** — Discover and connect to devices from the dashboard
189
+ - Start/stop device discovery (passive listening and active discovery)
190
+ - View list of available devices
191
+ - Connect to a discovered device
192
+ - [x] **DMK configuration** — View and modify DMK settings
193
+ - View and set the Manager API provider (`getProvider` / `setProvider`)
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./src"),module.exports);0&&(module.exports={...require("./src")});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../index.ts"],
4
+ "sourcesContent": ["export * from \"./src\";\n"],
5
+ "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,iBAAd",
6
+ "names": ["index_exports", "__toCommonJS", "__reExport"]
7
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "dependencies": {},
3
+ "devDependencies": {
4
+ "@ledgerhq/device-management-kit": "workspace:^",
5
+ "@ledgerhq/eslint-config-dsdk": "workspace:^",
6
+ "@ledgerhq/ldmk-tool": "workspace:^",
7
+ "@ledgerhq/prettier-config-dsdk": "workspace:^",
8
+ "@ledgerhq/tsconfig-dsdk": "workspace:^",
9
+ "@ledgerhq/vitest-config-dmk": "workspace:^",
10
+ "rxjs": "catalog:"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": "./lib/esm/index.js",
15
+ "require": "./lib/cjs/index.js",
16
+ "types": "./lib/types/index.d.ts"
17
+ },
18
+ "./*": {
19
+ "import": "./lib/esm/*",
20
+ "require": "./lib/cjs/*",
21
+ "types": "./lib/types/*"
22
+ }
23
+ },
24
+ "files": [
25
+ "./lib"
26
+ ],
27
+ "license": "Apache-2.0",
28
+ "main": "lib/index.js",
29
+ "name": "@ledgerhq/device-management-kit-devtools-core",
30
+ "peerDependencies": {
31
+ "@ledgerhq/device-management-kit": "^1.2.0",
32
+ "rxjs": "catalog:"
33
+ },
34
+ "private": false,
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/LedgerHQ/device-sdk-ts.git"
38
+ },
39
+ "scripts": {
40
+ "build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
41
+ "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
42
+ "lint": "eslint",
43
+ "lint:fix": "pnpm lint --fix",
44
+ "prebuild": "rimraf lib",
45
+ "prettier": "prettier . --check",
46
+ "prettier:fix": "prettier . --write",
47
+ "test": "vitest run",
48
+ "test:coverage": "vitest run --coverage",
49
+ "test:watch": "vitest",
50
+ "typecheck": "tsc --noEmit",
51
+ "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
52
+ "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
53
+ },
54
+ "types": "lib/index.d.ts",
55
+ "version": "1.1.1"
56
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var D=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var l=(o,e)=>{for(var E in e)D(o,E,{get:e[E],enumerable:!0})},n=(o,e,E,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of _(e))!f.call(o,t)&&t!==E&&D(o,t,{get:()=>e[t],enumerable:!(m=x(e,t))||m.enumerable});return o};var C=o=>n(D({},"__esModule",{value:!0}),o);var O={};l(O,{DEVTOOLS_MODULES:()=>p.DEVTOOLS_MODULES,DevToolsDmkInspector:()=>T.DevToolsDmkInspector,DevToolsLogger:()=>s.DevToolsLogger,INSPECTOR_COMMAND_TYPES:()=>S.INSPECTOR_COMMAND_TYPES,INSPECTOR_MESSAGE_TYPES:()=>S.INSPECTOR_MESSAGE_TYPES,LOGGER_MESSAGE_TYPES:()=>i.LOGGER_MESSAGE_TYPES,MODULE_CONNECTED_MESSAGE_TYPE:()=>p.MODULE_CONNECTED_MESSAGE_TYPE,serializeConnectedDevice:()=>r.serializeConnectedDevice,serializeDeviceSessionState:()=>r.serializeDeviceSessionState,serializeDiscoveredDevice:()=>r.serializeDiscoveredDevice});module.exports=C(O);var S=require("./inspector/constants"),T=require("./inspector/DevToolsDmkInspector"),r=require("./inspector/serialization"),i=require("./logger/constants"),s=require("./logger/DevToolsLogger"),p=require("./modules");0&&(module.exports={DEVTOOLS_MODULES,DevToolsDmkInspector,DevToolsLogger,INSPECTOR_COMMAND_TYPES,INSPECTOR_MESSAGE_TYPES,LOGGER_MESSAGE_TYPES,MODULE_CONNECTED_MESSAGE_TYPE,serializeConnectedDevice,serializeDeviceSessionState,serializeDiscoveredDevice});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/index.ts"],
4
+ "sourcesContent": ["// Inspector module\nexport { type CommandHandlerContext } from \"./inspector/commandHandlers\";\nexport {\n INSPECTOR_COMMAND_TYPES,\n INSPECTOR_MESSAGE_TYPES,\n} from \"./inspector/constants\";\nexport { DevToolsDmkInspector } from \"./inspector/DevToolsDmkInspector\";\nexport {\n serializeConnectedDevice,\n serializeDeviceSessionState,\n serializeDiscoveredDevice,\n} from \"./inspector/serialization\";\n\n// Logger module\nexport { LOGGER_MESSAGE_TYPES } from \"./logger/constants\";\nexport { type DevToolsLog } from \"./logger/DevToolsLog\";\nexport { DevToolsLogger } from \"./logger/DevToolsLogger\";\n\n// Shared\nexport {\n DEVTOOLS_MODULES,\n type DevToolsModule,\n MODULE_CONNECTED_MESSAGE_TYPE,\n} from \"./modules\";\nexport { type Connector } from \"./types\";\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4hBAAAE,EAAAF,GAEA,IAAAG,EAGO,iCACPC,EAAqC,4CACrCC,EAIO,qCAGPF,EAAqC,8BAErCG,EAA+B,mCAG/BC,EAIO",
6
+ "names": ["src_exports", "__export", "__toCommonJS", "import_constants", "import_DevToolsDmkInspector", "import_serialization", "import_DevToolsLogger", "import_modules"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var h=(i,e)=>{for(var r in e)c(i,r,{get:e[r],enumerable:!0})},E=(i,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D(e))!l.call(i,o)&&o!==r&&c(i,o,{get:()=>e[o],enumerable:!(n=m(e,o))||n.enumerable});return i};var b=i=>E(c({},"__esModule",{value:!0}),i);var S={};h(S,{DevToolsDmkInspector:()=>C});module.exports=b(S);var a=require("../modules"),t=require("./commandHandlers"),s=require("./constants"),d=require("./deviceObserver"),v=require("./DiscoveryHandler");class C{ctx;destroyDeviceObserver;discoveryHandler;commandListenerUnsubscribe=null;constructor(e,r){this.ctx={connector:e,dmk:r},e.sendMessage(a.MODULE_CONNECTED_MESSAGE_TYPE,JSON.stringify({module:a.DEVTOOLS_MODULES.DMK_INSPECTOR})),this.destroyDeviceObserver=(0,d.createDeviceObserver)(r,e),this.discoveryHandler=new v.DiscoveryHandler(r,e),this.setupCommandListener()}destroy(){this.destroyDeviceObserver(),this.discoveryHandler.destroy(),this.commandListenerUnsubscribe&&(this.commandListenerUnsubscribe(),this.commandListenerUnsubscribe=null)}setupCommandListener(){const{unsubscribe:e}=this.ctx.connector.listenToMessages(async(r,n)=>{try{switch(r){case s.INSPECTOR_COMMAND_TYPES.DISCONNECT:await(0,t.handleDisconnect)(this.ctx,n);break;case s.INSPECTOR_COMMAND_TYPES.SEND_APDU:await(0,t.handleSendApdu)(this.ctx,n);break;case s.INSPECTOR_COMMAND_TYPES.GET_PROVIDER:(0,t.handleGetProvider)(this.ctx);break;case s.INSPECTOR_COMMAND_TYPES.SET_PROVIDER:(0,t.handleSetProvider)(this.ctx,n);break;case s.INSPECTOR_COMMAND_TYPES.START_LISTENING_DEVICES:this.discoveryHandler.startListening();break;case s.INSPECTOR_COMMAND_TYPES.STOP_LISTENING_DEVICES:this.discoveryHandler.stopListening();break;case s.INSPECTOR_COMMAND_TYPES.START_DISCOVERING:this.discoveryHandler.startDiscovering();break;case s.INSPECTOR_COMMAND_TYPES.STOP_DISCOVERING:this.discoveryHandler.stopDiscovering();break;case s.INSPECTOR_COMMAND_TYPES.CONNECT_DEVICE:await(0,t.handleConnectDevice)(this.ctx,n,this.discoveryHandler.discoveredDevices);break}}catch(o){console.error(`[DevToolsDmkInspector] Error handling command ${r}`,o)}});this.commandListenerUnsubscribe=e}}0&&(module.exports={DevToolsDmkInspector});
2
+ //# sourceMappingURL=DevToolsDmkInspector.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/inspector/DevToolsDmkInspector.ts"],
4
+ "sourcesContent": ["import { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { DEVTOOLS_MODULES, MODULE_CONNECTED_MESSAGE_TYPE } from \"../modules\";\nimport { type Connector } from \"../types\";\nimport {\n type CommandHandlerContext,\n handleConnectDevice,\n handleDisconnect,\n handleGetProvider,\n handleSendApdu,\n handleSetProvider,\n} from \"./commandHandlers\";\nimport { INSPECTOR_COMMAND_TYPES } from \"./constants\";\nimport { createDeviceObserver } from \"./deviceObserver\";\nimport { DiscoveryHandler } from \"./DiscoveryHandler\";\n\n/**\n * DevToolsDmkInspector enables the devtools dashboard to inspect and interact\n * with the Device Management Kit.\n *\n * Features:\n * - Device sessions: list connected devices, observe session states\n * - Actions: disconnect sessions, send APDUs\n * - Configuration: get/set provider\n *\n * @example\n * ```ts\n * const connector = DevToolsWebSocketConnector.getInstance().connect({ url });\n * const dmk = new DeviceManagementKitBuilder().build();\n *\n * // Enable inspector after DMK is built\n * const inspector = new DevToolsDmkInspector(connector, dmk);\n *\n * // Clean up when done\n * inspector.destroy();\n * ```\n */\nexport class DevToolsDmkInspector {\n private readonly ctx: CommandHandlerContext;\n private readonly destroyDeviceObserver: () => void;\n private readonly discoveryHandler: DiscoveryHandler;\n private commandListenerUnsubscribe: (() => void) | null = null;\n\n constructor(connector: Connector, dmk: DeviceManagementKit) {\n this.ctx = { connector, dmk };\n\n // Send handshake\n connector.sendMessage(\n MODULE_CONNECTED_MESSAGE_TYPE,\n JSON.stringify({ module: DEVTOOLS_MODULES.DMK_INSPECTOR }),\n );\n\n // Start observing devices\n this.destroyDeviceObserver = createDeviceObserver(dmk, connector);\n\n // Initialize discovery handler\n this.discoveryHandler = new DiscoveryHandler(dmk, connector);\n\n // Listen for commands from dashboard\n this.setupCommandListener();\n }\n\n /**\n * Clean up subscriptions and listeners.\n */\n destroy(): void {\n this.destroyDeviceObserver();\n this.discoveryHandler.destroy();\n\n if (this.commandListenerUnsubscribe) {\n this.commandListenerUnsubscribe();\n this.commandListenerUnsubscribe = null;\n }\n }\n\n /**\n * Listen for commands from the dashboard.\n */\n private setupCommandListener(): void {\n const { unsubscribe } = this.ctx.connector.listenToMessages(\n async (type, payload) => {\n try {\n switch (type) {\n case INSPECTOR_COMMAND_TYPES.DISCONNECT:\n await handleDisconnect(this.ctx, payload);\n break;\n case INSPECTOR_COMMAND_TYPES.SEND_APDU:\n await handleSendApdu(this.ctx, payload);\n break;\n case INSPECTOR_COMMAND_TYPES.GET_PROVIDER:\n handleGetProvider(this.ctx);\n break;\n case INSPECTOR_COMMAND_TYPES.SET_PROVIDER:\n handleSetProvider(this.ctx, payload);\n break;\n case INSPECTOR_COMMAND_TYPES.START_LISTENING_DEVICES:\n this.discoveryHandler.startListening();\n break;\n case INSPECTOR_COMMAND_TYPES.STOP_LISTENING_DEVICES:\n this.discoveryHandler.stopListening();\n break;\n case INSPECTOR_COMMAND_TYPES.START_DISCOVERING:\n this.discoveryHandler.startDiscovering();\n break;\n case INSPECTOR_COMMAND_TYPES.STOP_DISCOVERING:\n this.discoveryHandler.stopDiscovering();\n break;\n case INSPECTOR_COMMAND_TYPES.CONNECT_DEVICE:\n await handleConnectDevice(\n this.ctx,\n payload,\n this.discoveryHandler.discoveredDevices,\n );\n break;\n }\n } catch (error) {\n console.error(\n `[DevToolsDmkInspector] Error handling command ${type}`,\n error,\n );\n }\n },\n );\n this.commandListenerUnsubscribe = unsubscribe;\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAAgE,sBAEhEC,EAOO,6BACPC,EAAwC,uBACxCC,EAAqC,4BACrCC,EAAiC,8BAuB1B,MAAMN,CAAqB,CACf,IACA,sBACA,iBACT,2BAAkD,KAE1D,YAAYO,EAAsBC,EAA0B,CAC1D,KAAK,IAAM,CAAE,UAAAD,EAAW,IAAAC,CAAI,EAG5BD,EAAU,YACR,gCACA,KAAK,UAAU,CAAE,OAAQ,mBAAiB,aAAc,CAAC,CAC3D,EAGA,KAAK,yBAAwB,wBAAqBC,EAAKD,CAAS,EAGhE,KAAK,iBAAmB,IAAI,mBAAiBC,EAAKD,CAAS,EAG3D,KAAK,qBAAqB,CAC5B,CAKA,SAAgB,CACd,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,QAAQ,EAE1B,KAAK,6BACP,KAAK,2BAA2B,EAChC,KAAK,2BAA6B,KAEtC,CAKQ,sBAA6B,CACnC,KAAM,CAAE,YAAAE,CAAY,EAAI,KAAK,IAAI,UAAU,iBACzC,MAAOC,EAAMC,IAAY,CACvB,GAAI,CACF,OAAQD,EAAM,CACZ,KAAK,0BAAwB,WAC3B,QAAM,oBAAiB,KAAK,IAAKC,CAAO,EACxC,MACF,KAAK,0BAAwB,UAC3B,QAAM,kBAAe,KAAK,IAAKA,CAAO,EACtC,MACF,KAAK,0BAAwB,gBAC3B,qBAAkB,KAAK,GAAG,EAC1B,MACF,KAAK,0BAAwB,gBAC3B,qBAAkB,KAAK,IAAKA,CAAO,EACnC,MACF,KAAK,0BAAwB,wBAC3B,KAAK,iBAAiB,eAAe,EACrC,MACF,KAAK,0BAAwB,uBAC3B,KAAK,iBAAiB,cAAc,EACpC,MACF,KAAK,0BAAwB,kBAC3B,KAAK,iBAAiB,iBAAiB,EACvC,MACF,KAAK,0BAAwB,iBAC3B,KAAK,iBAAiB,gBAAgB,EACtC,MACF,KAAK,0BAAwB,eAC3B,QAAM,uBACJ,KAAK,IACLA,EACA,KAAK,iBAAiB,iBACxB,EACA,KACJ,CACF,OAASC,EAAO,CACd,QAAQ,MACN,iDAAiDF,CAAI,GACrDE,CACF,CACF,CACF,CACF,EACA,KAAK,2BAA6BH,CACpC,CACF",
6
+ "names": ["DevToolsDmkInspector_exports", "__export", "DevToolsDmkInspector", "__toCommonJS", "import_modules", "import_commandHandlers", "import_constants", "import_deviceObserver", "import_DiscoveryHandler", "connector", "dmk", "unsubscribe", "type", "payload", "error"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=(e,i)=>{for(var t in i)o(e,t,{get:i[t],enumerable:!0})},p=(e,i,t,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of v(i))!d.call(e,s)&&s!==t&&o(e,s,{get:()=>i[s],enumerable:!(r=c(i,s))||r.enumerable});return e};var D=e=>p(o({},"__esModule",{value:!0}),e);var l={};g(l,{DiscoveryHandler:()=>h});module.exports=D(l);var n=require("./discoveryObserver");class h{dmk;connector;stopListeningFn=null;stopDiscoveringFn=null;_discoveredDevices=[];constructor(i,t){this.dmk=i,this.connector=t}get discoveredDevices(){return this._discoveredDevices}get isListening(){return this.stopListeningFn!==null}get isDiscovering(){return this.stopDiscoveringFn!==null}startListening(){this.stopListeningFn||(this.stopListeningFn=(0,n.startListeningObserver)(this.dmk,this.connector,i=>{this._discoveredDevices=i}))}stopListening(){this.stopListeningFn&&(this.stopListeningFn(),this.stopListeningFn=null,this._discoveredDevices=[])}startDiscovering(){this.stopDiscoveringFn||(this.stopDiscoveringFn=(0,n.startDiscoveringObserver)(this.dmk,this.connector,i=>{this._discoveredDevices=i}))}stopDiscovering(){this.stopDiscoveringFn&&(this.stopDiscoveringFn(),this.stopDiscoveringFn=null,this._discoveredDevices=[])}destroy(){this.stopListening(),this.stopDiscovering()}}0&&(module.exports={DiscoveryHandler});
2
+ //# sourceMappingURL=DiscoveryHandler.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/inspector/DiscoveryHandler.ts"],
4
+ "sourcesContent": ["import {\n type DeviceManagementKit,\n type DiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type Connector } from \"../types\";\nimport {\n startDiscoveringObserver,\n startListeningObserver,\n} from \"./discoveryObserver\";\n\n/**\n * Handles device discovery operations for the devtools inspector.\n * Encapsulates both passive listening and active discovery modes.\n *\n * @example\n * ```ts\n * const handler = new DiscoveryHandler(dmk, connector);\n *\n * // Start passive listening (no user gesture required)\n * handler.startListening();\n *\n * // Or start active discovery (triggers permission prompt in web)\n * handler.startDiscovering();\n *\n * // Get current discovered devices\n * const devices = handler.discoveredDevices;\n *\n * // Clean up\n * handler.destroy();\n * ```\n */\nexport class DiscoveryHandler {\n private readonly dmk: DeviceManagementKit;\n private readonly connector: Connector;\n\n private stopListeningFn: (() => void) | null = null;\n private stopDiscoveringFn: (() => void) | null = null;\n private _discoveredDevices: DiscoveredDevice[] = [];\n\n constructor(dmk: DeviceManagementKit, connector: Connector) {\n this.dmk = dmk;\n this.connector = connector;\n }\n\n /**\n * Get the current list of discovered devices.\n */\n get discoveredDevices(): DiscoveredDevice[] {\n return this._discoveredDevices;\n }\n\n /**\n * Whether passive listening is currently active.\n */\n get isListening(): boolean {\n return this.stopListeningFn !== null;\n }\n\n /**\n * Whether active discovery is currently active.\n */\n get isDiscovering(): boolean {\n return this.stopDiscoveringFn !== null;\n }\n\n /**\n * Start passive listening for available devices.\n * Does NOT trigger permission prompts - works with already-paired devices.\n */\n startListening(): void {\n if (this.stopListeningFn) {\n return; // Already listening\n }\n\n this.stopListeningFn = startListeningObserver(\n this.dmk,\n this.connector,\n (devices) => {\n this._discoveredDevices = devices;\n },\n );\n }\n\n /**\n * Stop passive listening for available devices.\n */\n stopListening(): void {\n if (this.stopListeningFn) {\n this.stopListeningFn();\n this.stopListeningFn = null;\n this._discoveredDevices = [];\n }\n }\n\n /**\n * Start active device discovery.\n * NOTE: In web apps (WebHID/WebBLE), this requires a user gesture in the app context.\n * Calling this from the dashboard will NOT work for web apps.\n */\n startDiscovering(): void {\n if (this.stopDiscoveringFn) {\n return; // Already discovering\n }\n\n this.stopDiscoveringFn = startDiscoveringObserver(\n this.dmk,\n this.connector,\n (devices) => {\n this._discoveredDevices = devices;\n },\n );\n }\n\n /**\n * Stop active device discovery.\n */\n stopDiscovering(): void {\n if (this.stopDiscoveringFn) {\n this.stopDiscoveringFn();\n this.stopDiscoveringFn = null;\n this._discoveredDevices = [];\n }\n }\n\n /**\n * Clean up all discovery operations.\n */\n destroy(): void {\n this.stopListening();\n this.stopDiscovering();\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAMA,IAAAI,EAGO,+BAuBA,MAAMF,CAAiB,CACX,IACA,UAET,gBAAuC,KACvC,kBAAyC,KACzC,mBAAyC,CAAC,EAElD,YAAYG,EAA0BC,EAAsB,CAC1D,KAAK,IAAMD,EACX,KAAK,UAAYC,CACnB,CAKA,IAAI,mBAAwC,CAC1C,OAAO,KAAK,kBACd,CAKA,IAAI,aAAuB,CACzB,OAAO,KAAK,kBAAoB,IAClC,CAKA,IAAI,eAAyB,CAC3B,OAAO,KAAK,oBAAsB,IACpC,CAMA,gBAAuB,CACjB,KAAK,kBAIT,KAAK,mBAAkB,0BACrB,KAAK,IACL,KAAK,UACJC,GAAY,CACX,KAAK,mBAAqBA,CAC5B,CACF,EACF,CAKA,eAAsB,CAChB,KAAK,kBACP,KAAK,gBAAgB,EACrB,KAAK,gBAAkB,KACvB,KAAK,mBAAqB,CAAC,EAE/B,CAOA,kBAAyB,CACnB,KAAK,oBAIT,KAAK,qBAAoB,4BACvB,KAAK,IACL,KAAK,UACJA,GAAY,CACX,KAAK,mBAAqBA,CAC5B,CACF,EACF,CAKA,iBAAwB,CAClB,KAAK,oBACP,KAAK,kBAAkB,EACvB,KAAK,kBAAoB,KACzB,KAAK,mBAAqB,CAAC,EAE/B,CAKA,SAAgB,CACd,KAAK,cAAc,EACnB,KAAK,gBAAgB,CACvB,CACF",
6
+ "names": ["DiscoveryHandler_exports", "__export", "DiscoveryHandler", "__toCommonJS", "import_discoveryObserver", "dmk", "connector", "devices"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var u=(e,n)=>{for(var o in n)c(e,o,{get:n[o],enumerable:!0})},f=(e,n,o,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of p(n))!v.call(e,r)&&r!==o&&c(e,r,{get:()=>n[r],enumerable:!(s=m(n,r))||s.enumerable});return e};var D=e=>f(c({},"__esModule",{value:!0}),e);var C={};u(C,{handleConnectDevice:()=>y,handleDisconnect:()=>l,handleGetProvider:()=>a,handleSendApdu:()=>S,handleSetProvider:()=>g});module.exports=D(C);var d=require("./constants");async function l(e,n){const{sessionId:o}=JSON.parse(n);await e.dmk.disconnect({sessionId:o})}async function S(e,n){const{sessionId:o,apdu:s,requestId:r}=JSON.parse(n);try{const t=new Uint8Array(s),i=await e.dmk.sendApdu({sessionId:o,apdu:t});e.connector.sendMessage(d.INSPECTOR_MESSAGE_TYPES.APDU_RESPONSE,JSON.stringify({requestId:r,success:!0,statusCode:Array.from(i.statusCode),data:Array.from(i.data)}))}catch(t){e.connector.sendMessage(d.INSPECTOR_MESSAGE_TYPES.APDU_RESPONSE,JSON.stringify({requestId:r,success:!1,error:t instanceof Error?t.message:String(t)}))}}function a(e){const n=e.dmk.getProvider();e.connector.sendMessage(d.INSPECTOR_MESSAGE_TYPES.PROVIDER_VALUE,JSON.stringify({provider:n}))}function g(e,n){const{provider:o}=JSON.parse(n);e.dmk.setProvider(o),a(e)}async function y(e,n,o){const{deviceId:s,sessionRefresherOptions:r}=JSON.parse(n),t=o.find(i=>i.id===s);if(!t){console.error(`[DevToolsDmkInspector] Device not found for connect: ${s}`);return}try{await e.dmk.connect({device:t,sessionRefresherOptions:r})}catch(i){console.error(`[DevToolsDmkInspector] Error connecting to device ${s}`,i)}}0&&(module.exports={handleConnectDevice,handleDisconnect,handleGetProvider,handleSendApdu,handleSetProvider});
2
+ //# sourceMappingURL=commandHandlers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/inspector/commandHandlers.ts"],
4
+ "sourcesContent": ["import {\n type DeviceId,\n type DeviceManagementKit,\n type DeviceSessionId,\n type DiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type Connector } from \"../types\";\nimport { INSPECTOR_MESSAGE_TYPES } from \"./constants\";\n\n/**\n * Context passed to command handlers.\n */\nexport type CommandHandlerContext = {\n dmk: DeviceManagementKit;\n connector: Connector;\n};\n\n/**\n * Handle disconnect command - disconnects a device session.\n */\nexport async function handleDisconnect(\n ctx: CommandHandlerContext,\n payload: string,\n): Promise<void> {\n const { sessionId } = JSON.parse(payload) as { sessionId: DeviceSessionId };\n await ctx.dmk.disconnect({ sessionId });\n // Device list update will be sent via the observer\n}\n\n/**\n * Handle sendApdu command - sends a raw APDU to a device.\n */\nexport async function handleSendApdu(\n ctx: CommandHandlerContext,\n payload: string,\n): Promise<void> {\n const { sessionId, apdu, requestId } = JSON.parse(payload) as {\n sessionId: DeviceSessionId;\n apdu: number[];\n requestId: string;\n };\n try {\n // Convert array to Uint8Array for DMK\n const apduBytes = new Uint8Array(apdu);\n const response = await ctx.dmk.sendApdu({ sessionId, apdu: apduBytes });\n ctx.connector.sendMessage(\n INSPECTOR_MESSAGE_TYPES.APDU_RESPONSE,\n JSON.stringify({\n requestId,\n success: true,\n statusCode: Array.from(response.statusCode),\n data: Array.from(response.data),\n }),\n );\n } catch (error) {\n ctx.connector.sendMessage(\n INSPECTOR_MESSAGE_TYPES.APDU_RESPONSE,\n JSON.stringify({\n requestId,\n success: false,\n error: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n}\n\n/**\n * Handle getProvider command - returns the current provider value.\n */\nexport function handleGetProvider(ctx: CommandHandlerContext): void {\n const provider = ctx.dmk.getProvider();\n ctx.connector.sendMessage(\n INSPECTOR_MESSAGE_TYPES.PROVIDER_VALUE,\n JSON.stringify({ provider }),\n );\n}\n\n/**\n * Handle setProvider command - sets the provider value and confirms.\n */\nexport function handleSetProvider(\n ctx: CommandHandlerContext,\n payload: string,\n): void {\n const { provider } = JSON.parse(payload) as { provider: number };\n ctx.dmk.setProvider(provider);\n // Send back the new value to confirm\n handleGetProvider(ctx);\n}\n\n/**\n * Handle connectDevice command - connects to a discovered device.\n *\n * @param ctx - Command handler context\n * @param payload - JSON payload containing deviceId and optional sessionRefresherOptions\n * @param discoveredDevices - Current list of discovered devices to find the device\n */\nexport async function handleConnectDevice(\n ctx: CommandHandlerContext,\n payload: string,\n discoveredDevices: DiscoveredDevice[],\n): Promise<void> {\n const { deviceId, sessionRefresherOptions } = JSON.parse(payload) as {\n deviceId: DeviceId;\n sessionRefresherOptions?: {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n };\n };\n\n const device = discoveredDevices.find((d) => d.id === deviceId);\n if (!device) {\n console.error(\n `[DevToolsDmkInspector] Device not found for connect: ${deviceId}`,\n );\n return;\n }\n\n try {\n await ctx.dmk.connect({ device, sessionRefresherOptions });\n // The connected device will be picked up by the deviceObserver\n } catch (error) {\n console.error(\n `[DevToolsDmkInspector] Error connecting to device ${deviceId}`,\n error,\n );\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,qBAAAC,EAAA,sBAAAC,EAAA,mBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAP,GAQA,IAAAQ,EAAwC,uBAaxC,eAAsBL,EACpBM,EACAC,EACe,CACf,KAAM,CAAE,UAAAC,CAAU,EAAI,KAAK,MAAMD,CAAO,EACxC,MAAMD,EAAI,IAAI,WAAW,CAAE,UAAAE,CAAU,CAAC,CAExC,CAKA,eAAsBN,EACpBI,EACAC,EACe,CACf,KAAM,CAAE,UAAAC,EAAW,KAAAC,EAAM,UAAAC,CAAU,EAAI,KAAK,MAAMH,CAAO,EAKzD,GAAI,CAEF,MAAMI,EAAY,IAAI,WAAWF,CAAI,EAC/BG,EAAW,MAAMN,EAAI,IAAI,SAAS,CAAE,UAAAE,EAAW,KAAMG,CAAU,CAAC,EACtEL,EAAI,UAAU,YACZ,0BAAwB,cACxB,KAAK,UAAU,CACb,UAAAI,EACA,QAAS,GACT,WAAY,MAAM,KAAKE,EAAS,UAAU,EAC1C,KAAM,MAAM,KAAKA,EAAS,IAAI,CAChC,CAAC,CACH,CACF,OAASC,EAAO,CACdP,EAAI,UAAU,YACZ,0BAAwB,cACxB,KAAK,UAAU,CACb,UAAAI,EACA,QAAS,GACT,MAAOG,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAC9D,CAAC,CACH,CACF,CACF,CAKO,SAASZ,EAAkBK,EAAkC,CAClE,MAAMQ,EAAWR,EAAI,IAAI,YAAY,EACrCA,EAAI,UAAU,YACZ,0BAAwB,eACxB,KAAK,UAAU,CAAE,SAAAQ,CAAS,CAAC,CAC7B,CACF,CAKO,SAASX,EACdG,EACAC,EACM,CACN,KAAM,CAAE,SAAAO,CAAS,EAAI,KAAK,MAAMP,CAAO,EACvCD,EAAI,IAAI,YAAYQ,CAAQ,EAE5Bb,EAAkBK,CAAG,CACvB,CASA,eAAsBP,EACpBO,EACAC,EACAQ,EACe,CACf,KAAM,CAAE,SAAAC,EAAU,wBAAAC,CAAwB,EAAI,KAAK,MAAMV,CAAO,EAQ1DW,EAASH,EAAkB,KAAMI,GAAMA,EAAE,KAAOH,CAAQ,EAC9D,GAAI,CAACE,EAAQ,CACX,QAAQ,MACN,wDAAwDF,CAAQ,EAClE,EACA,MACF,CAEA,GAAI,CACF,MAAMV,EAAI,IAAI,QAAQ,CAAE,OAAAY,EAAQ,wBAAAD,CAAwB,CAAC,CAE3D,OAASJ,EAAO,CACd,QAAQ,MACN,qDAAqDG,CAAQ,GAC7DH,CACF,CACF,CACF",
6
+ "names": ["commandHandlers_exports", "__export", "handleConnectDevice", "handleDisconnect", "handleGetProvider", "handleSendApdu", "handleSetProvider", "__toCommonJS", "import_constants", "ctx", "payload", "sessionId", "apdu", "requestId", "apduBytes", "response", "error", "provider", "discoveredDevices", "deviceId", "sessionRefresherOptions", "device", "d"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var i=(e,E)=>{for(var D in E)s(e,D,{get:E[D],enumerable:!0})},c=(e,E,D,t)=>{if(E&&typeof E=="object"||typeof E=="function")for(let S of I(E))!T.call(e,S)&&S!==D&&s(e,S,{get:()=>E[S],enumerable:!(t=_(E,S))||t.enumerable});return e};var n=e=>c(s({},"__esModule",{value:!0}),e);var N={};i(N,{INSPECTOR_COMMAND_TYPES:()=>C,INSPECTOR_MESSAGE_TYPES:()=>o});module.exports=n(N);const o={CONNECTED_DEVICES_UPDATE:"connectedDevicesUpdate",DEVICE_SESSION_STATE_UPDATE:"deviceSessionStateUpdate",PROVIDER_VALUE:"providerValue",APDU_RESPONSE:"apduResponse",DISCOVERED_DEVICES_UPDATE:"discoveredDevicesUpdate"},C={DISCONNECT:"disconnect",SEND_APDU:"sendApdu",GET_PROVIDER:"getProvider",SET_PROVIDER:"setProvider",START_LISTENING_DEVICES:"startListeningDevices",STOP_LISTENING_DEVICES:"stopListeningDevices",START_DISCOVERING:"startDiscovering",STOP_DISCOVERING:"stopDiscovering",CONNECT_DEVICE:"connectDevice"};0&&(module.exports={INSPECTOR_COMMAND_TYPES,INSPECTOR_MESSAGE_TYPES});
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/inspector/constants.ts"],
4
+ "sourcesContent": ["/**\n * Message types sent from inspector to dashboard\n */\nexport const INSPECTOR_MESSAGE_TYPES = {\n /** List of all connected devices updated */\n CONNECTED_DEVICES_UPDATE: \"connectedDevicesUpdate\",\n /** A device session state updated */\n DEVICE_SESSION_STATE_UPDATE: \"deviceSessionStateUpdate\",\n /** Response to a getProvider request */\n PROVIDER_VALUE: \"providerValue\",\n /** Response to a sendApdu request */\n APDU_RESPONSE: \"apduResponse\",\n /** List of discovered (available) devices updated */\n DISCOVERED_DEVICES_UPDATE: \"discoveredDevicesUpdate\",\n} as const;\n\n/**\n * Message types sent from dashboard to inspector (commands)\n */\nexport const INSPECTOR_COMMAND_TYPES = {\n /** Request to disconnect a session */\n DISCONNECT: \"disconnect\",\n /** Request to send an APDU */\n SEND_APDU: \"sendApdu\",\n /** Request to get current provider */\n GET_PROVIDER: \"getProvider\",\n /** Request to set provider */\n SET_PROVIDER: \"setProvider\",\n /** Request to start listening for available devices (passive, no user gesture required) */\n START_LISTENING_DEVICES: \"startListeningDevices\",\n /** Request to stop listening for available devices */\n STOP_LISTENING_DEVICES: \"stopListeningDevices\",\n /** Request to start discovering devices (triggers permission prompt, requires user gesture in web apps) */\n START_DISCOVERING: \"startDiscovering\",\n /** Request to stop discovering devices */\n STOP_DISCOVERING: \"stopDiscovering\",\n /** Request to connect to a discovered device */\n CONNECT_DEVICE: \"connectDevice\",\n} as const;\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,4BAAAC,IAAA,eAAAC,EAAAJ,GAGO,MAAMG,EAA0B,CAErC,yBAA0B,yBAE1B,4BAA6B,2BAE7B,eAAgB,gBAEhB,cAAe,eAEf,0BAA2B,yBAC7B,EAKaD,EAA0B,CAErC,WAAY,aAEZ,UAAW,WAEX,aAAc,cAEd,aAAc,cAEd,wBAAyB,wBAEzB,uBAAwB,uBAExB,kBAAmB,mBAEnB,iBAAkB,kBAElB,eAAgB,eAClB",
6
+ "names": ["constants_exports", "__export", "INSPECTOR_COMMAND_TYPES", "INSPECTOR_MESSAGE_TYPES", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var v=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var l=(e,t)=>{for(var i in t)v(e,i,{get:t[i],enumerable:!0})},C=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of f(t))!d.call(e,n)&&n!==i&&v(e,n,{get:()=>t[n],enumerable:!(o=b(t,n))||o.enumerable});return e};var E=e=>C(v({},"__esModule",{value:!0}),e);var T={};l(T,{createDeviceObserver:()=>m,sendConnectedDevicesUpdate:()=>r,sendSessionStateUpdate:()=>a});module.exports=E(T);var D=require("./constants"),c=require("./serialization");function r(e,t){const i=e.listConnectedDevices();t.sendMessage(D.INSPECTOR_MESSAGE_TYPES.CONNECTED_DEVICES_UPDATE,JSON.stringify(i.map(c.serializeConnectedDevice)))}function a(e,t,i){e.sendMessage(D.INSPECTOR_MESSAGE_TYPES.DEVICE_SESSION_STATE_UPDATE,JSON.stringify({sessionId:t,state:(0,c.serializeDeviceSessionState)(i)}))}function m(e,t){const i=[],o=new Map,n=s=>{if(o.has(s))return;const u=e.getDeviceSessionState({sessionId:s}).subscribe({next:S=>{a(t,s,S)},error:S=>{console.error(`[DevToolsDmkInspector] getDeviceSessionState error for ${s}`,S),o.delete(s)},complete:()=>{o.delete(s),r(e,t)}});o.set(s,u)};r(e,t);const p=e.listenToConnectedDevice().subscribe({next:s=>{r(e,t),n(s.sessionId)},error:s=>{console.error("[DevToolsDmkInspector] listenToConnectedDevice error",s)}});return i.push(p),e.listConnectedDevices().forEach(s=>{n(s.sessionId)}),()=>{for(const s of i)s.unsubscribe();for(const s of o.values())s.unsubscribe();o.clear()}}0&&(module.exports={createDeviceObserver,sendConnectedDevicesUpdate,sendSessionStateUpdate});
2
+ //# sourceMappingURL=deviceObserver.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/inspector/deviceObserver.ts"],
4
+ "sourcesContent": ["import {\n type DeviceManagementKit,\n type DeviceSessionId,\n type DeviceSessionState,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Subscription } from \"rxjs\";\n\nimport { type Connector } from \"../types\";\nimport { INSPECTOR_MESSAGE_TYPES } from \"./constants\";\nimport {\n serializeConnectedDevice,\n serializeDeviceSessionState,\n} from \"./serialization\";\n\n/**\n * Sends the current list of connected devices to the dashboard.\n */\nexport function sendConnectedDevicesUpdate(\n dmk: DeviceManagementKit,\n connector: Connector,\n): void {\n const devices = dmk.listConnectedDevices();\n connector.sendMessage(\n INSPECTOR_MESSAGE_TYPES.CONNECTED_DEVICES_UPDATE,\n JSON.stringify(devices.map(serializeConnectedDevice)),\n );\n}\n\n/**\n * Sends a device session state update to the dashboard.\n */\nexport function sendSessionStateUpdate(\n connector: Connector,\n sessionId: DeviceSessionId,\n state: DeviceSessionState,\n): void {\n connector.sendMessage(\n INSPECTOR_MESSAGE_TYPES.DEVICE_SESSION_STATE_UPDATE,\n JSON.stringify({\n sessionId,\n state: serializeDeviceSessionState(state),\n }),\n );\n}\n\n/**\n * Creates a device observer that tracks connected devices and their session states.\n * Returns a cleanup function to unsubscribe from all observations.\n */\nexport function createDeviceObserver(\n dmk: DeviceManagementKit,\n connector: Connector,\n): () => void {\n const subscriptions: Subscription[] = [];\n const sessionStateSubscriptions = new Map<DeviceSessionId, Subscription>();\n\n const subscribeToSessionState = (sessionId: DeviceSessionId): void => {\n // Don't double-subscribe\n if (sessionStateSubscriptions.has(sessionId)) {\n return;\n }\n\n const sub = dmk.getDeviceSessionState({ sessionId }).subscribe({\n next: (state: DeviceSessionState) => {\n sendSessionStateUpdate(connector, sessionId, state);\n },\n error: (err) => {\n console.error(\n `[DevToolsDmkInspector] getDeviceSessionState error for ${sessionId}`,\n err,\n );\n sessionStateSubscriptions.delete(sessionId);\n },\n complete: () => {\n // Session ended, clean up and send updated device list\n sessionStateSubscriptions.delete(sessionId);\n sendConnectedDevicesUpdate(dmk, connector);\n },\n });\n\n sessionStateSubscriptions.set(sessionId, sub);\n };\n\n // Send initial list of connected devices\n sendConnectedDevicesUpdate(dmk, connector);\n\n // Subscribe to new device connections\n const deviceSub = dmk.listenToConnectedDevice().subscribe({\n next: (device) => {\n sendConnectedDevicesUpdate(dmk, connector);\n subscribeToSessionState(device.sessionId);\n },\n error: (err) => {\n console.error(\n \"[DevToolsDmkInspector] listenToConnectedDevice error\",\n err,\n );\n },\n });\n subscriptions.push(deviceSub);\n\n // Subscribe to existing devices' session states\n const existingDevices = dmk.listConnectedDevices();\n existingDevices.forEach((device) => {\n subscribeToSessionState(device.sessionId);\n });\n\n // Return cleanup function\n return () => {\n for (const sub of subscriptions) {\n sub.unsubscribe();\n }\n for (const sub of sessionStateSubscriptions.values()) {\n sub.unsubscribe();\n }\n sessionStateSubscriptions.clear();\n };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,+BAAAC,EAAA,2BAAAC,IAAA,eAAAC,EAAAL,GAQA,IAAAM,EAAwC,uBACxCC,EAGO,2BAKA,SAASJ,EACdK,EACAC,EACM,CACN,MAAMC,EAAUF,EAAI,qBAAqB,EACzCC,EAAU,YACR,0BAAwB,yBACxB,KAAK,UAAUC,EAAQ,IAAI,0BAAwB,CAAC,CACtD,CACF,CAKO,SAASN,EACdK,EACAE,EACAC,EACM,CACNH,EAAU,YACR,0BAAwB,4BACxB,KAAK,UAAU,CACb,UAAAE,EACA,SAAO,+BAA4BC,CAAK,CAC1C,CAAC,CACH,CACF,CAMO,SAASV,EACdM,EACAC,EACY,CACZ,MAAMI,EAAgC,CAAC,EACjCC,EAA4B,IAAI,IAEhCC,EAA2BJ,GAAqC,CAEpE,GAAIG,EAA0B,IAAIH,CAAS,EACzC,OAGF,MAAMK,EAAMR,EAAI,sBAAsB,CAAE,UAAAG,CAAU,CAAC,EAAE,UAAU,CAC7D,KAAOC,GAA8B,CACnCR,EAAuBK,EAAWE,EAAWC,CAAK,CACpD,EACA,MAAQK,GAAQ,CACd,QAAQ,MACN,0DAA0DN,CAAS,GACnEM,CACF,EACAH,EAA0B,OAAOH,CAAS,CAC5C,EACA,SAAU,IAAM,CAEdG,EAA0B,OAAOH,CAAS,EAC1CR,EAA2BK,EAAKC,CAAS,CAC3C,CACF,CAAC,EAEDK,EAA0B,IAAIH,EAAWK,CAAG,CAC9C,EAGAb,EAA2BK,EAAKC,CAAS,EAGzC,MAAMS,EAAYV,EAAI,wBAAwB,EAAE,UAAU,CACxD,KAAOW,GAAW,CAChBhB,EAA2BK,EAAKC,CAAS,EACzCM,EAAwBI,EAAO,SAAS,CAC1C,EACA,MAAQF,GAAQ,CACd,QAAQ,MACN,uDACAA,CACF,CACF,CACF,CAAC,EACD,OAAAJ,EAAc,KAAKK,CAAS,EAGJV,EAAI,qBAAqB,EACjC,QAASW,GAAW,CAClCJ,EAAwBI,EAAO,SAAS,CAC1C,CAAC,EAGM,IAAM,CACX,UAAWH,KAAOH,EAChBG,EAAI,YAAY,EAElB,UAAWA,KAAOF,EAA0B,OAAO,EACjDE,EAAI,YAAY,EAElBF,EAA0B,MAAM,CAClC,CACF",
6
+ "names": ["deviceObserver_exports", "__export", "createDeviceObserver", "sendConnectedDevicesUpdate", "sendSessionStateUpdate", "__toCommonJS", "import_constants", "import_serialization", "dmk", "connector", "devices", "sessionId", "state", "subscriptions", "sessionStateSubscriptions", "subscribeToSessionState", "sub", "err", "deviceSub", "device"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var t=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,i)=>{for(var s in i)t(r,s,{get:i[s],enumerable:!0})},m=(r,i,s,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of u(i))!a.call(r,e)&&e!==s&&t(r,e,{get:()=>i[e],enumerable:!(o=d(i,e))||o.enumerable});return r};var f=r=>m(t({},"__esModule",{value:!0}),r);var x={};b(x,{sendDiscoveredDevicesUpdate:()=>c,startDiscoveringObserver:()=>S,startListeningObserver:()=>g});module.exports=f(x);var D=require("./constants"),p=require("./serialization");function c(r,i){i.sendMessage(D.INSPECTOR_MESSAGE_TYPES.DISCOVERED_DEVICES_UPDATE,JSON.stringify(r.map(p.serializeDiscoveredDevice)))}function g(r,i,s){let o=null;return o=r.listenToAvailableDevices({}).subscribe({next:e=>{c(e,i),s?.(e)},error:e=>{console.error("[DevToolsDmkInspector] listenToAvailableDevices error",e)}}),()=>{o&&(o.unsubscribe(),o=null)}}function S(r,i,s){let o=null;const e=[];return o=r.startDiscovering({}).subscribe({next:n=>{const v=e.findIndex(l=>l.id===n.id);v>=0?e[v]=n:e.push(n),c([...e],i),s?.([...e])},error:n=>{console.error("[DevToolsDmkInspector] startDiscovering error",n)},complete:()=>{}}),()=>{o&&(o.unsubscribe(),o=null),r.stopDiscovering()}}0&&(module.exports={sendDiscoveredDevicesUpdate,startDiscoveringObserver,startListeningObserver});
2
+ //# sourceMappingURL=discoveryObserver.js.map