@ledgerhq/device-management-kit 1.0.1 → 1.1.0

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 (196) hide show
  1. package/README.md +63 -28
  2. package/lib/cjs/package.json +1 -1
  3. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  4. package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
  5. package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
  6. package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
  7. package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
  8. package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
  9. package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
  10. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  11. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  12. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  13. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  14. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  15. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  16. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
  17. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  18. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  19. package/lib/cjs/src/api/index.js +1 -1
  20. package/lib/cjs/src/api/index.js.map +3 -3
  21. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
  22. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
  23. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
  24. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
  25. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  26. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
  27. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  28. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  29. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  30. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  31. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
  32. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
  33. package/lib/cjs/src/api/transport/model/Errors.js +1 -1
  34. package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
  35. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
  36. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  37. package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js +1 -1
  38. package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
  39. package/lib/cjs/src/internal/device-session/model/DevicePinger.js +1 -1
  40. package/lib/cjs/src/internal/device-session/model/DevicePinger.js.map +2 -2
  41. package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js +1 -1
  42. package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
  43. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  44. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  45. package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js +1 -1
  46. package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
  47. package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
  48. package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
  49. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  50. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
  51. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  52. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  53. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
  54. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
  55. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
  56. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
  57. package/lib/cjs/src/internal/device-session/service/IntentQueueService.js +2 -0
  58. package/lib/cjs/src/internal/device-session/service/IntentQueueService.js.map +7 -0
  59. package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js +2 -0
  60. package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
  61. package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
  62. package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
  63. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  64. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  65. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  66. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  67. package/lib/esm/package.json +1 -1
  68. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  69. package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
  70. package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
  71. package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
  72. package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
  73. package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
  74. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  75. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  76. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  77. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  78. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  79. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
  80. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  81. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  82. package/lib/esm/src/api/index.js +1 -1
  83. package/lib/esm/src/api/index.js.map +3 -3
  84. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
  85. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
  86. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
  87. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
  88. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  89. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +3 -3
  90. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  91. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  92. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  93. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  94. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
  95. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
  96. package/lib/esm/src/api/transport/model/Errors.js +1 -1
  97. package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
  98. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
  99. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  100. package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js +1 -1
  101. package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
  102. package/lib/esm/src/internal/device-session/model/DevicePinger.js +1 -1
  103. package/lib/esm/src/internal/device-session/model/DevicePinger.js.map +2 -2
  104. package/lib/esm/src/internal/device-session/model/DevicePinger.test.js +1 -1
  105. package/lib/esm/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
  106. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  107. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  108. package/lib/esm/src/internal/device-session/model/DeviceSession.test.js +1 -1
  109. package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
  110. package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
  111. package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
  112. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  113. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
  114. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  115. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  116. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
  117. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
  118. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
  119. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
  120. package/lib/esm/src/internal/device-session/service/IntentQueueService.js +2 -0
  121. package/lib/esm/src/internal/device-session/service/IntentQueueService.js.map +7 -0
  122. package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js +2 -0
  123. package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
  124. package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
  125. package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
  126. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  127. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  128. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  129. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  130. package/lib/types/src/api/DeviceManagementKit.d.ts +10 -0
  131. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  132. package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts +17 -0
  133. package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts.map +1 -0
  134. package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts +2 -0
  135. package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts.map +1 -0
  136. package/lib/types/src/api/device-action/DeviceAction.d.ts +2 -1
  137. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  138. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  139. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +4 -1
  140. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  141. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +10 -1
  142. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
  143. package/lib/types/src/api/index.d.ts +7 -2
  144. package/lib/types/src/api/index.d.ts.map +1 -1
  145. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts +12 -0
  146. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts.map +1 -0
  147. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts +2 -0
  148. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts.map +1 -0
  149. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
  150. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +1 -0
  151. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
  152. package/lib/types/src/api/transport/model/Errors.d.ts +5 -0
  153. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  154. package/lib/types/src/internal/device-session/di/deviceSessionModule.d.ts.map +1 -1
  155. package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts +1 -0
  156. package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts.map +1 -1
  157. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +13 -2
  158. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  159. package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts +3 -1
  160. package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts.map +1 -1
  161. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts +0 -1
  162. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
  163. package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts +1 -0
  164. package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts.map +1 -1
  165. package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts +101 -0
  166. package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts.map +1 -0
  167. package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts +2 -0
  168. package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts.map +1 -0
  169. package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts +19 -0
  170. package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts.map +1 -0
  171. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  172. package/package.json +4 -4
  173. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
  174. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
  175. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
  176. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
  177. package/lib/cjs/src/internal/device-session/service/MutexService.js +0 -2
  178. package/lib/cjs/src/internal/device-session/service/MutexService.js.map +0 -7
  179. package/lib/cjs/src/internal/device-session/service/MutexService.test.js +0 -2
  180. package/lib/cjs/src/internal/device-session/service/MutexService.test.js.map +0 -7
  181. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
  182. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
  183. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
  184. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
  185. package/lib/esm/src/internal/device-session/service/MutexService.js +0 -2
  186. package/lib/esm/src/internal/device-session/service/MutexService.js.map +0 -7
  187. package/lib/esm/src/internal/device-session/service/MutexService.test.js +0 -2
  188. package/lib/esm/src/internal/device-session/service/MutexService.test.js.map +0 -7
  189. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +0 -17
  190. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +0 -1
  191. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts +0 -2
  192. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts.map +0 -1
  193. package/lib/types/src/internal/device-session/service/MutexService.d.ts +0 -6
  194. package/lib/types/src/internal/device-session/service/MutexService.d.ts.map +0 -1
  195. package/lib/types/src/internal/device-session/service/MutexService.test.d.ts +0 -2
  196. package/lib/types/src/internal/device-session/service/MutexService.test.d.ts.map +0 -1
package/README.md CHANGED
@@ -21,6 +21,9 @@
21
21
  - [Executing a device action](#executing-a-device-action)
22
22
  - [Open App Device Action](#open-app-device-action)
23
23
  - [Example in React](#example-in-react)
24
+ - [Developer tools](#developer-tools)
25
+ - [Web, Node.js or Electron app](#web-nodejs-or-electron-app)
26
+ - [React Native app (with Rozenite)](#react-native-app-with-rozenite)
24
27
 
25
28
  ## Description
26
29
 
@@ -372,12 +375,19 @@ Check [the sample app](https://github.com/LedgerHQ/device-sdk-ts/tree/develop/ap
372
375
 
373
376
  ## Developer tools
374
377
 
375
- Some basic developer tools are available.
376
- For now they allow to view logs from the Device Management Kit. They will have more advanced features soon.
378
+ Developer tools are available to help debug your DMK integration:
377
379
 
378
- ### JavaScript app
380
+ - **Real-time logging** — View DMK logs with filtering by level and tag
381
+ - **Device session inspector** — Monitor connected devices and their states
382
+ - **Device discovery** — Discover and connect to devices from the dashboard
383
+ - **APDU sender** — Send raw APDU commands to devices
384
+ - **DMK configuration** — View and modify settings like the My Ledger API provider
379
385
 
380
- The devtools can be set up in any JavaScript runtime with WebSocket support. (e.g. web apps, React Native apps etc.)
386
+ ### Web, Node.js or Electron app
387
+
388
+ For web apps, Node.js apps, Electron apps, or any JavaScript runtime with WebSocket support (including React Native), use the WebSocket-based devtools with the Electron dashboard app.
389
+
390
+ > **React Native users:** This setup also works for React Native apps. However, if you have [Rozenite](https://www.rozenite.dev/) set up in your app, we recommend the [Rozenite-based devtools](#react-native-app-with-rozenite) instead — it provides a more integrated experience directly within the React Native DevTools, with less setup required.
381
391
 
382
392
  #### Set up
383
393
 
@@ -388,24 +398,33 @@ Install those packages:
388
398
  - `@ledgerhq/device-management-kit-devtools-websocket-connector`
389
399
 
390
400
  ```ts
391
- import { DevToolsLogger } from "@ledgerhq/device-management-kit-devtools-core";
401
+ import {
402
+ DevToolsLogger,
403
+ DevToolsDmkInspector,
404
+ } from "@ledgerhq/device-management-kit-devtools-core";
392
405
  import { DEFAULT_CLIENT_WS_URL } from "@ledgerhq/device-management-kit-devtools-websocket-common";
393
- import { DevtoolsWebSocketConnector } from "@ledgerhq/device-management-kit-devtools-websocket-connector";
406
+ import { DevToolsWebSocketConnector } from "@ledgerhq/device-management-kit-devtools-websocket-connector";
394
407
 
395
- // Build the dev tools logger
396
- function buildDevToolsLogger() {
397
- const devToolsWebSocketConnector =
398
- DevtoolsWebSocketConnector.getInstance().connect({
399
- url: DEFAULT_CLIENT_WS_URL,
400
- });
401
- return new DevToolsLogger(devToolsWebSocketConnector);
402
- }
408
+ // Create the connector (shared between logger and inspector)
409
+ const connector = DevToolsWebSocketConnector.getInstance().connect({
410
+ url: DEFAULT_CLIENT_WS_URL,
411
+ });
403
412
 
404
- // Pass the logger to your DMK builder
405
- new DeviceManagementKitBuilder()
413
+ // Create the logger (before DMK is built)
414
+ const devToolsLogger = new DevToolsLogger(connector);
415
+
416
+ // Build the DMK with the logger
417
+ const dmk = new DeviceManagementKitBuilder()
406
418
  //...
407
- .addLogger(buildDevToolsLogger())
419
+ .addLogger(devToolsLogger)
408
420
  .build();
421
+
422
+ // Optional: Enable inspector for device sessions and DMK interaction
423
+ // This must be done AFTER the DMK is built
424
+ const inspector = new DevToolsDmkInspector(connector, dmk);
425
+
426
+ // Clean up when done (e.g., on app unmount)
427
+ // inspector.destroy();
409
428
  ```
410
429
 
411
430
  #### Usage
@@ -427,24 +446,40 @@ Install those packages:
427
446
  - `@ledgerhq/device-management-kit-devtools-rozenite`
428
447
 
429
448
  ```ts
430
- import { DevToolsLogger } from "@ledgerhq/device-management-kit-devtools-core";
431
- import { RozeniteConnector } from "@ledgerhq/device-management-kit-devtools-rozenite";
449
+ import {
450
+ DevToolsLogger,
451
+ DevToolsDmkInspector,
452
+ } from "@ledgerhq/device-management-kit-devtools-core";
453
+ import {
454
+ RozeniteConnector,
455
+ useRozeniteConnector,
456
+ } from "@ledgerhq/device-management-kit-devtools-rozenite";
432
457
 
433
- // Build the dev tools logger
434
- function buildDevToolsLogger() {
435
- const connector = RozeniteConnector.getInstance();
436
- return new DevToolsLogger(connector);
437
- }
458
+ // Create the connector (shared between logger and inspector)
459
+ const connector = RozeniteConnector.getInstance();
438
460
 
439
- // Pass the logger to your DMK builder
440
- new DeviceManagementKitBuilder()
461
+ // Create the logger (before DMK is built)
462
+ const devToolsLogger = new DevToolsLogger(connector);
463
+
464
+ // Build the DMK with the logger
465
+ const dmk = new DeviceManagementKitBuilder()
441
466
  //...
442
- .addLogger(buildDevToolsLogger())
467
+ .addLogger(devToolsLogger)
443
468
  .build();
469
+
470
+ // Optional: Enable inspector for device sessions and DMK interaction
471
+ // This must be done AFTER the DMK is built
472
+ const inspector = new DevToolsDmkInspector(connector, dmk);
473
+
474
+ // Clean up when done (e.g., on app unmount)
475
+ // inspector.destroy();
476
+
477
+ // At the root of your React app, call this hook to initialise the connection
478
+ useRozeniteConnector();
444
479
  ```
445
480
 
446
481
  #### Usage
447
482
 
448
483
  1. Run your React Native app
449
484
  2. [Open the React Native DevTools](https://reactnative.dev/docs/react-native-devtools)
450
- 3. Navigate to the DMK Devtools tab
485
+ 3. Navigate to the DMK DevTools tab
@@ -64,5 +64,5 @@
64
64
  "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
65
65
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
66
66
  },
67
- "version": "1.0.1"
67
+ "version": "1.1.0"
68
68
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},A=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!y.call(t,r)&&r!==o&&c(t,r,{get:()=>e[r],enumerable:!(i=g(e,r))||i.enumerable});return t};var l=t=>A(c({},"__esModule",{value:!0}),t);var h={};S(h,{DeviceManagementKit:()=>f});module.exports=l(h);var p=require("./command/di/commandTypes"),m=require("../internal/config/di/configTypes"),n=require("../internal/device-session/di/deviceSessionTypes"),s=require("../internal/discovery/di/discoveryTypes"),C=require("../internal/logger-publisher/di/loggerTypes"),a=require("../internal/manager-api/di/managerApiTypes"),v=require("../internal/send/di/sendTypes"),d=require("../internal/transport/di/transportDiTypes"),D=require("../../src/di"),u=require("./device-action/di/deviceActionTypes");class f{container;constructor({stub:e,transports:o,loggers:i,config:r}={}){this.container=(0,D.makeContainer)({stub:e,transports:o,loggers:i,config:r})}getVersion(){return this.container.get(m.configTypes.GetDmkVersionUseCase).getDmkVersion()}startDiscovering(e){return this.container.get(s.discoveryTypes.StartDiscoveringUseCase).execute(e)}stopDiscovering(){return this.container.get(s.discoveryTypes.StopDiscoveringUseCase).execute()}listenToAvailableDevices(e){return this.container.get(s.discoveryTypes.ListenToAvailableDevicesUseCase).execute(e)}async reconnect(e){return this.container.get(s.discoveryTypes.ReconnectUseCase).execute(e)}connect(e){return this.container.get(s.discoveryTypes.ConnectUseCase).execute(e)}disconnect(e){return this.container.get(s.discoveryTypes.DisconnectUseCase).execute(e)}sendApdu(e){return this.container.get(v.sendTypes.SendApduUseCase).execute(e)}sendCommand(e){return this.container.get(p.commandTypes.SendCommandUseCase).execute(e)}executeDeviceAction(e){return this.container.get(u.deviceActionTypes.ExecuteDeviceActionUseCase).execute(e)}getConnectedDevice(e){return this.container.get(s.discoveryTypes.GetConnectedDeviceUseCase).execute(e)}getDeviceSessionState(e){return this.container.get(n.deviceSessionTypes.GetDeviceSessionStateUseCase).execute(e)}close(){return this.container.get(n.deviceSessionTypes.CloseSessionsUseCase).execute()}listConnectedDevices(){return this.container.get(s.discoveryTypes.ListConnectedDevicesUseCase).execute()}listenToConnectedDevice(){return this.container.get(s.discoveryTypes.ListenToConnectedDeviceUseCase).execute()}disableDeviceSessionRefresher(e){return this.container.get(n.deviceSessionTypes.DisableDeviceSessionRefresherUseCase).execute(e)}setProvider(e){return this.container.get(a.managerApiTypes.SetProviderUseCase).execute(e)}getProvider(){return this.container.get(a.managerApiTypes.ManagerApiDataSource).getProvider()}isEnvironmentSupported(){return this.container.get(d.transportDiTypes.TransportService).getAllTransports().some(e=>e.isSupported())}getLoggerFactory(){return this.container.get(C.loggerTypes.LoggerPublisherServiceFactory)}}0&&(module.exports={DeviceManagementKit});
1
+ "use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var n in e)a(t,n,{get:e[n],enumerable:!0})},A=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!y.call(t,r)&&r!==n&&a(t,r,{get:()=>e[r],enumerable:!(i=g(e,r))||i.enumerable});return t};var f=t=>A(a({},"__esModule",{value:!0}),t);var h={};S(h,{DeviceManagementKit:()=>l});module.exports=f(h);var p=require("./command/di/commandTypes"),m=require("../internal/config/di/configTypes"),o=require("../internal/device-session/di/deviceSessionTypes"),s=require("../internal/discovery/di/discoveryTypes"),C=require("../internal/logger-publisher/di/loggerTypes"),c=require("../internal/manager-api/di/managerApiTypes"),v=require("../internal/send/di/sendTypes"),u=require("../internal/transport/di/transportDiTypes"),d=require("../../src/di"),D=require("./device-action/di/deviceActionTypes");class l{container;constructor({stub:e,transports:n,loggers:i,config:r}={}){this.container=(0,d.makeContainer)({stub:e,transports:n,loggers:i,config:r})}getVersion(){return this.container.get(m.configTypes.GetDmkVersionUseCase).getDmkVersion()}startDiscovering(e){return this.container.get(s.discoveryTypes.StartDiscoveringUseCase).execute(e)}stopDiscovering(){return this.container.get(s.discoveryTypes.StopDiscoveringUseCase).execute()}listenToAvailableDevices(e){return this.container.get(s.discoveryTypes.ListenToAvailableDevicesUseCase).execute(e)}async reconnect(e){return this.container.get(s.discoveryTypes.ReconnectUseCase).execute(e)}connect(e){return this.container.get(s.discoveryTypes.ConnectUseCase).execute(e)}disconnect(e){return this.container.get(s.discoveryTypes.DisconnectUseCase).execute(e)}sendApdu(e){return this.container.get(v.sendTypes.SendApduUseCase).execute(e)}sendCommand(e){return this.container.get(p.commandTypes.SendCommandUseCase).execute(e)}executeDeviceAction(e){return this.container.get(D.deviceActionTypes.ExecuteDeviceActionUseCase).execute(e)}getConnectedDevice(e){return this.container.get(s.discoveryTypes.GetConnectedDeviceUseCase).execute(e)}getDeviceSessionState(e){return this.container.get(o.deviceSessionTypes.GetDeviceSessionStateUseCase).execute(e)}close(){return this.container.get(o.deviceSessionTypes.CloseSessionsUseCase).execute()}listConnectedDevices(){return this.container.get(s.discoveryTypes.ListConnectedDevicesUseCase).execute()}listenToConnectedDevice(){return this.container.get(s.discoveryTypes.ListenToConnectedDeviceUseCase).execute()}disableDeviceSessionRefresher(e){return this.container.get(o.deviceSessionTypes.DisableDeviceSessionRefresherUseCase).execute(e)}_unsafeBypassIntentQueue(e){return this.container.get(o.deviceSessionTypes.UnsafeBypassIntentQueueUseCase).execute(e)}setProvider(e){return this.container.get(c.managerApiTypes.SetProviderUseCase).execute(e)}getProvider(){return this.container.get(c.managerApiTypes.ManagerApiDataSource).getProvider()}isEnvironmentSupported(){return this.container.get(u.transportDiTypes.TransportService).getAllTransports().some(e=>e.isSupported())}getLoggerFactory(){return this.container.get(C.loggerTypes.LoggerPublisherServiceFactory)}}0&&(module.exports={DeviceManagementKit});
2
2
  //# sourceMappingURL=DeviceManagementKit.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/DeviceManagementKit.ts"],
4
- "sourcesContent": ["import { type Container, type Factory } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type LoggerPublisherService,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n\n /**\n * Returns the DMK logger factory with configured logger subscribers.\n */\n getLoggerFactory(): Factory<LoggerPublisherService> {\n return this.container.get(loggerTypes.LoggerPublisherServiceFactory);\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAA6B,wCAuB7BC,EAA4B,2CAE5BC,EAAmC,0DAGnCC,EAA+B,iDAgB/BC,EAA4B,qDAE5BC,EAAgC,oDAEhCC,EAA0B,uCAE1BC,EAAiC,mDAEjCC,EAAuD,wBAMvDC,EAAkC,gDAS3B,MAAMX,CAAoB,CACtB,UAET,YAAY,CACV,KAAAY,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,EAAiC,CAAC,EAAG,CAInC,KAAK,aAAY,iBAAc,CAC7B,KAAAH,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,CAAC,CACH,CAKA,YAA8B,CAC5B,OAAO,KAAK,UACT,IAA0B,cAAY,oBAAoB,EAC1D,cAAc,CACnB,CAWA,iBACEC,EAC8B,CAC9B,OAAO,KAAK,UACT,IAA6B,iBAAe,uBAAuB,EACnE,QAAQA,CAAI,CACjB,CAKA,iBAAkB,CAChB,OAAO,KAAK,UACT,IAA4B,iBAAe,sBAAsB,EACjE,QAAQ,CACb,CAOA,yBACEA,EACgC,CAChC,OAAO,KAAK,UACT,IACC,iBAAe,+BACjB,EACC,QAAQA,CAAI,CACjB,CAYA,MAAM,UAAUA,EAAsD,CACpE,OAAO,KAAK,UACT,IAAsB,iBAAe,gBAAgB,EACrD,QAAQA,CAAI,CACjB,CAiBA,QAAQA,EAAoD,CAC1D,OAAO,KAAK,UACT,IAAoB,iBAAe,cAAc,EACjD,QAAQA,CAAI,CACjB,CAOA,WAAWA,EAA4C,CACrD,OAAO,KAAK,UACT,IAAuB,iBAAe,iBAAiB,EACvD,QAAQA,CAAI,CACjB,CAOA,SAASA,EAAkD,CACzD,OAAO,KAAK,UACT,IAAqB,YAAU,eAAe,EAC9C,QAAQA,CAAI,CACjB,CAQA,YACEA,EAC8C,CAC9C,OAAO,KAAK,UACT,IAAwB,eAAa,kBAAkB,EACvD,QAAQA,CAAI,CACjB,CAEA,oBAMEA,EAMiE,CACjE,OAAO,KAAK,UACT,IACC,oBAAkB,0BACpB,EACC,QAAQA,CAAI,CACjB,CAQA,mBAAmBA,EAAsD,CACvE,OAAO,KAAK,UACT,IAA+B,iBAAe,yBAAyB,EACvE,QAAQA,CAAI,CACjB,CAQA,sBAAsBA,EAEa,CACjC,OAAO,KAAK,UACT,IACC,qBAAmB,4BACrB,EACC,QAAQA,CAAI,CACjB,CAMA,OAAQ,CACN,OAAO,KAAK,UACT,IAA0B,qBAAmB,oBAAoB,EACjE,QAAQ,CACb,CAOA,sBAA0C,CACxC,OAAO,KAAK,UACT,IACC,iBAAe,2BACjB,EACC,QAAQ,CACb,CAOA,yBAAuD,CACrD,OAAO,KAAK,UACT,IACC,iBAAe,8BACjB,EACC,QAAQ,CACb,CAQA,8BAA8BA,EAGf,CACb,OAAO,KAAK,UACT,IACC,qBAAmB,oCACrB,EACC,QAAQA,CAAI,CACjB,CAMA,YAAYC,EAAwB,CAClC,OAAO,KAAK,UACT,IAAwB,kBAAgB,kBAAkB,EAC1D,QAAQA,CAAQ,CACrB,CAKA,aAAsB,CACpB,OAAO,KAAK,UACT,IAA0B,kBAAgB,oBAAoB,EAC9D,YAAY,CACjB,CAKA,wBAAkC,CAChC,OAAO,KAAK,UACT,IAAsB,mBAAiB,gBAAgB,EACvD,iBAAiB,EACjB,KAAMC,GAAcA,EAAU,YAAY,CAAC,CAChD,CAKA,kBAAoD,CAClD,OAAO,KAAK,UAAU,IAAI,cAAY,6BAA6B,CACrE,CACF",
4
+ "sourcesContent": ["import { type Container, type Factory } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type LoggerPublisherService,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport {\n type UnsafeBypassIntentQueueUseCase,\n type UnsafeBypassIntentQueueUseCaseArgs,\n} from \"@internal/device-session/use-case/UnsafeBypassIntentQueueUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n\n /**\n * UNSAFE: Bypasses the intent queue for a device session.\n * This allows all intents (sendApdu, sendCommand, executeDeviceAction) to execute\n * directly without being queued. Use with extreme caution as this can lead to\n * race conditions and concurrent execution issues.\n *\n * @param {UnsafeBypassIntentQueueUseCaseArgs} args - The device session ID and bypass flag.\n */\n _unsafeBypassIntentQueue(args: UnsafeBypassIntentQueueUseCaseArgs): void {\n return this.container\n .get<UnsafeBypassIntentQueueUseCase>(\n deviceSessionTypes.UnsafeBypassIntentQueueUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n\n /**\n * Returns the DMK logger factory with configured logger subscribers.\n */\n getLoggerFactory(): Factory<LoggerPublisherService> {\n return this.container.get(loggerTypes.LoggerPublisherServiceFactory);\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAA6B,wCAuB7BC,EAA4B,2CAE5BC,EAAmC,0DAOnCC,EAA+B,iDAgB/BC,EAA4B,qDAE5BC,EAAgC,oDAEhCC,EAA0B,uCAE1BC,EAAiC,mDAEjCC,EAAuD,wBAMvDC,EAAkC,gDAS3B,MAAMX,CAAoB,CACtB,UAET,YAAY,CACV,KAAAY,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,EAAiC,CAAC,EAAG,CAInC,KAAK,aAAY,iBAAc,CAC7B,KAAAH,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,CAAC,CACH,CAKA,YAA8B,CAC5B,OAAO,KAAK,UACT,IAA0B,cAAY,oBAAoB,EAC1D,cAAc,CACnB,CAWA,iBACEC,EAC8B,CAC9B,OAAO,KAAK,UACT,IAA6B,iBAAe,uBAAuB,EACnE,QAAQA,CAAI,CACjB,CAKA,iBAAkB,CAChB,OAAO,KAAK,UACT,IAA4B,iBAAe,sBAAsB,EACjE,QAAQ,CACb,CAOA,yBACEA,EACgC,CAChC,OAAO,KAAK,UACT,IACC,iBAAe,+BACjB,EACC,QAAQA,CAAI,CACjB,CAYA,MAAM,UAAUA,EAAsD,CACpE,OAAO,KAAK,UACT,IAAsB,iBAAe,gBAAgB,EACrD,QAAQA,CAAI,CACjB,CAiBA,QAAQA,EAAoD,CAC1D,OAAO,KAAK,UACT,IAAoB,iBAAe,cAAc,EACjD,QAAQA,CAAI,CACjB,CAOA,WAAWA,EAA4C,CACrD,OAAO,KAAK,UACT,IAAuB,iBAAe,iBAAiB,EACvD,QAAQA,CAAI,CACjB,CAOA,SAASA,EAAkD,CACzD,OAAO,KAAK,UACT,IAAqB,YAAU,eAAe,EAC9C,QAAQA,CAAI,CACjB,CAQA,YACEA,EAC8C,CAC9C,OAAO,KAAK,UACT,IAAwB,eAAa,kBAAkB,EACvD,QAAQA,CAAI,CACjB,CAEA,oBAMEA,EAMiE,CACjE,OAAO,KAAK,UACT,IACC,oBAAkB,0BACpB,EACC,QAAQA,CAAI,CACjB,CAQA,mBAAmBA,EAAsD,CACvE,OAAO,KAAK,UACT,IAA+B,iBAAe,yBAAyB,EACvE,QAAQA,CAAI,CACjB,CAQA,sBAAsBA,EAEa,CACjC,OAAO,KAAK,UACT,IACC,qBAAmB,4BACrB,EACC,QAAQA,CAAI,CACjB,CAMA,OAAQ,CACN,OAAO,KAAK,UACT,IAA0B,qBAAmB,oBAAoB,EACjE,QAAQ,CACb,CAOA,sBAA0C,CACxC,OAAO,KAAK,UACT,IACC,iBAAe,2BACjB,EACC,QAAQ,CACb,CAOA,yBAAuD,CACrD,OAAO,KAAK,UACT,IACC,iBAAe,8BACjB,EACC,QAAQ,CACb,CAQA,8BAA8BA,EAGf,CACb,OAAO,KAAK,UACT,IACC,qBAAmB,oCACrB,EACC,QAAQA,CAAI,CACjB,CAUA,yBAAyBA,EAAgD,CACvE,OAAO,KAAK,UACT,IACC,qBAAmB,8BACrB,EACC,QAAQA,CAAI,CACjB,CAMA,YAAYC,EAAwB,CAClC,OAAO,KAAK,UACT,IAAwB,kBAAgB,kBAAkB,EAC1D,QAAQA,CAAQ,CACrB,CAKA,aAAsB,CACpB,OAAO,KAAK,UACT,IAA0B,kBAAgB,oBAAoB,EAC9D,YAAY,CACjB,CAKA,wBAAkC,CAChC,OAAO,KAAK,UACT,IAAsB,mBAAiB,gBAAgB,EACvD,iBAAiB,EACjB,KAAMC,GAAcA,EAAU,YAAY,CAAC,CAChD,CAKA,kBAAoD,CAClD,OAAO,KAAK,UAAU,IAAI,cAAY,6BAA6B,CACrE,CACF",
6
6
  "names": ["DeviceManagementKit_exports", "__export", "DeviceManagementKit", "__toCommonJS", "import_commandTypes", "import_configTypes", "import_deviceSessionTypes", "import_discoveryTypes", "import_loggerTypes", "import_managerApiTypes", "import_sendTypes", "import_transportDiTypes", "import_di", "import_deviceActionTypes", "stub", "transports", "loggers", "config", "args", "provider", "transport"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var B=(r,e)=>{for(var o in e)n(r,o,{get:e[o],enumerable:!0})},f=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of E(e))!S.call(r,m)&&m!==o&&n(r,m,{get:()=>e[m],enumerable:!(t=I(e,m))||t.enumerable});return r};var z=r=>f(n({},"__esModule",{value:!0}),r);var G={};B(G,{GetBackgroundImageSizeCommand:()=>k,GetBackgroundImageSizeCommandError:()=>l});module.exports=z(G);var s=require("../../apdu/utils/ApduBuilder"),i=require("../../apdu/utils/ApduParser"),g=require("../../command/Errors"),a=require("../../command/model/CommandResult"),u=require("../../command/utils/CommandErrors"),p=require("../../command/utils/CommandUtils"),c=require("../../command/utils/GlobalCommandError"),C=require("../../Error");const d={"662e":{message:"Invalid state, no background image loaded."},"662f":{message:"Invalid state, device is in recovery mode."}};class l extends C.DeviceExchangeError{constructor({message:e,errorCode:o}){super({message:e,errorCode:o,tag:"GetBackgroundImageSizeCommandError"})}}class k{name="getBackgroundImageSize";getApdu(){const e={cla:224,ins:100,p1:0,p2:0};return new s.ApduBuilder(e).build()}parseResponse(e){const o=new i.ApduParser(e);if(!p.CommandUtils.isSuccessResponse(e)){const m=o.encodeToHexaString(e.statusCode);return(0,u.isCommandErrorCode)(m,d)?(0,a.CommandResultFactory)({error:new l({...d[m],errorCode:m})}):(0,a.CommandResultFactory)({error:c.GlobalCommandErrorHandler.handle(e)})}const t=o.extract32BitUInt();return t===void 0?(0,a.CommandResultFactory)({error:new g.InvalidStatusWordError("Didn't receive any size")}):(0,a.CommandResultFactory)({data:t})}}0&&(module.exports={GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError});
2
+ //# sourceMappingURL=GetBackgroundImageSizeCommand.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/api/command/os/GetBackgroundImageSizeCommand.ts"],
4
+ "sourcesContent": ["import { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder, type ApduBuilderArgs } from \"@api/apdu/utils/ApduBuilder\";\nimport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nimport { type Command } from \"@api/command/Command\";\nimport { InvalidStatusWordError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n} from \"@api/command/model/CommandResult\";\nimport {\n type CommandErrors,\n isCommandErrorCode,\n} from \"@api/command/utils/CommandErrors\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { GlobalCommandErrorHandler } from \"@api/command/utils/GlobalCommandError\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type CommandErrorArgs, DeviceExchangeError } from \"@api/Error\";\n\nexport type GetBackgroundImageSizeResponse = number;\n\nexport type GetBackgroundImageSizeErrorCodes = \"662e\" | \"662f\";\n\nconst IMAGE_SIZE_ERRORS: CommandErrors<GetBackgroundImageSizeErrorCodes> = {\n \"662e\": { message: \"Invalid state, no background image loaded.\" },\n \"662f\": { message: \"Invalid state, device is in recovery mode.\" },\n};\n\nexport type GetBackgroundImageSizeCommandResult = CommandResult<\n GetBackgroundImageSizeResponse,\n GetBackgroundImageSizeErrorCodes\n>;\n\nexport class GetBackgroundImageSizeCommandError extends DeviceExchangeError<GetBackgroundImageSizeErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<GetBackgroundImageSizeErrorCodes>) {\n super({ message, errorCode, tag: \"GetBackgroundImageSizeCommandError\" });\n }\n}\n\nexport class GetBackgroundImageSizeCommand\n implements\n Command<\n GetBackgroundImageSizeResponse,\n void,\n GetBackgroundImageSizeErrorCodes\n >\n{\n readonly name = \"getBackgroundImageSize\";\n\n getApdu(): Apdu {\n const apduArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x64,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(apduArgs).build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): GetBackgroundImageSizeCommandResult {\n const parser = new ApduParser(apduResponse);\n\n if (!CommandUtils.isSuccessResponse(apduResponse)) {\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, IMAGE_SIZE_ERRORS)) {\n return CommandResultFactory({\n error: new GetBackgroundImageSizeCommandError({\n ...IMAGE_SIZE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n\n const size = parser.extract32BitUInt();\n if (size === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n });\n }\n\n return CommandResultFactory({\n data: size,\n });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,uCAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkD,uCAClDC,EAA2B,sCAE3BC,EAAuC,+BACvCC,EAGO,4CACPC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAE1CC,EAA2D,sBAM3D,MAAMC,EAAqE,CACzE,OAAQ,CAAE,QAAS,4CAA6C,EAChE,OAAQ,CAAE,QAAS,4CAA6C,CAClE,EAOO,MAAMV,UAA2C,qBAAsD,CAC5G,YAAY,CACV,QAAAW,EACA,UAAAC,CACF,EAAuD,CACrD,MAAM,CAAE,QAAAD,EAAS,UAAAC,EAAW,IAAK,oCAAqC,CAAC,CACzE,CACF,CAEO,MAAMb,CAOb,CACW,KAAO,yBAEhB,SAAgB,CACd,MAAMc,EAA4B,CAChC,IAAK,IACL,IAAK,IACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAI,cAAYA,CAAQ,EAAE,MAAM,CACzC,CAEA,cACEC,EACqC,CACrC,MAAMC,EAAS,IAAI,aAAWD,CAAY,EAE1C,GAAI,CAAC,eAAa,kBAAkBA,CAAY,EAAG,CACjD,MAAMF,EAAYG,EAAO,mBAAmBD,EAAa,UAAU,EACnE,SAAI,sBAAmBF,EAAWF,CAAiB,KAC1C,wBAAqB,CAC1B,MAAO,IAAIV,EAAmC,CAC5C,GAAGU,EAAkBE,CAAS,EAC9B,UAAAA,CACF,CAAC,CACH,CAAC,KAEI,wBAAqB,CAC1B,MAAO,4BAA0B,OAAOE,CAAY,CACtD,CAAC,CACH,CAEA,MAAME,EAAOD,EAAO,iBAAiB,EACrC,OAAIC,IAAS,UACJ,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,yBAAyB,CAC7D,CAAC,KAGI,wBAAqB,CAC1B,KAAMA,CACR,CAAC,CACH,CACF",
6
+ "names": ["GetBackgroundImageSizeCommand_exports", "__export", "GetBackgroundImageSizeCommand", "GetBackgroundImageSizeCommandError", "__toCommonJS", "import_ApduBuilder", "import_ApduParser", "import_Errors", "import_CommandResult", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_Error", "IMAGE_SIZE_ERRORS", "message", "errorCode", "apduArgs", "apduResponse", "parser", "size"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var d=require("../../command/Errors"),a=require("../../command/model/CommandResult"),o=require("../../command/model/CommandResult"),n=require("../../command/os/GetBackgroundImageSizeCommand"),s=require("../../device-session/ApduResponse");const i=new Uint8Array([224,100,0,0,0]);describe("GetBackgroundImageSizeCommand",()=>{let t;beforeEach(()=>{t=new n.GetBackgroundImageSizeCommand}),describe("name",()=>{it("should be 'getBackgroundImageSize'",()=>{expect(t.name).toBe("getBackgroundImageSize")})}),it("should return the correct APDU",()=>{const r=t.getApdu();expect(r.getRawApdu()).toStrictEqual(i)}),it("should parse result successfully",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([0,0,137,233])}),e=t.parseResponse(r);expect(e).toStrictEqual((0,a.CommandResultFactory)({data:35305}))}),it("should fail on invalid size",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([144,0]),data:new Uint8Array([233])}),e=t.parseResponse(r);expect(e).toStrictEqual((0,a.CommandResultFactory)({error:new d.InvalidStatusWordError("Didn't receive any size")}))}),it("should return error on no image loaded (662e)",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([102,46]),data:new Uint8Array([])}),e=t.parseResponse(r);expect((0,o.isSuccessCommandResult)(e)).toBe(!1),(0,o.isSuccessCommandResult)(e)||(expect(e.error).toBeInstanceOf(n.GetBackgroundImageSizeCommandError),expect(e.error.message).toBe("Invalid state, no background image loaded."))}),it("should return error on recovery mode (662f)",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([102,47]),data:new Uint8Array([])}),e=t.parseResponse(r);expect((0,o.isSuccessCommandResult)(e)).toBe(!1),(0,o.isSuccessCommandResult)(e)||(expect(e.error).toBeInstanceOf(n.GetBackgroundImageSizeCommandError),expect(e.error.message).toBe("Invalid state, device is in recovery mode."))}),it("should return global error on unknown status code",()=>{const r=new s.ApduResponse({statusCode:new Uint8Array([110,0]),data:new Uint8Array([])}),e=t.parseResponse(r);expect((0,o.isSuccessCommandResult)(e)).toBe(!1)})});
2
+ //# sourceMappingURL=GetBackgroundImageSizeCommand.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/api/command/os/GetBackgroundImageSizeCommand.test.ts"],
4
+ "sourcesContent": ["import { InvalidStatusWordError } from \"@api/command/Errors\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nconst IMAGE_SIZE_APDU = new Uint8Array([0xe0, 0x64, 0x00, 0x00, 0x00]);\n\ndescribe(\"GetBackgroundImageSizeCommand\", () => {\n let command: GetBackgroundImageSizeCommand;\n\n beforeEach(() => {\n command = new GetBackgroundImageSizeCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getBackgroundImageSize'\", () => {\n expect(command.name).toBe(\"getBackgroundImageSize\");\n });\n });\n\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(IMAGE_SIZE_APDU);\n });\n\n it(\"should parse result successfully\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x00, 0x00, 0x89, 0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: 35305,\n }),\n );\n });\n\n it(\"should fail on invalid size\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0xe9]),\n });\n const result = command.parseResponse(response);\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Didn't receive any size\"),\n }),\n );\n });\n\n it(\"should return error on no image loaded (662e)\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2e]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(GetBackgroundImageSizeCommandError);\n expect((result.error as GetBackgroundImageSizeCommandError).message).toBe(\n \"Invalid state, no background image loaded.\",\n );\n }\n });\n\n it(\"should return error on recovery mode (662f)\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x66, 0x2f]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toBeInstanceOf(GetBackgroundImageSizeCommandError);\n expect((result.error as GetBackgroundImageSizeCommandError).message).toBe(\n \"Invalid state, device is in recovery mode.\",\n );\n }\n });\n\n it(\"should return global error on unknown status code\", () => {\n const response: ApduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x6e, 0x00]),\n data: new Uint8Array([]),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAuC,+BACvCC,EAAqC,4CACrCA,EAAuC,4CACvCC,EAGO,yDACPC,EAA6B,4CAE7B,MAAMC,EAAkB,IAAI,WAAW,CAAC,IAAM,IAAM,EAAM,EAAM,CAAI,CAAC,EAErE,SAAS,gCAAiC,IAAM,CAC9C,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAI,+BAChB,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,qCAAsC,IAAM,CAC7C,OAAOA,EAAQ,IAAI,EAAE,KAAK,wBAAwB,CACpD,CAAC,CACH,CAAC,EAED,GAAG,iCAAkC,IAAM,CACzC,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cAAcF,CAAe,CACzD,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,EAAM,EAAM,IAAM,GAAI,CAAC,CAC/C,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,iBACb,wBAAqB,CACnB,KAAM,KACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,8BAA+B,IAAM,CACtC,MAAMD,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,GAAI,CAAC,CAC7B,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,OAAOC,CAAM,EAAE,iBACb,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,yBAAyB,CAC7D,CAAC,CACH,CACF,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,MAAMD,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,IAChC,OAAOA,EAAO,KAAK,EAAE,eAAe,oCAAkC,EACtE,OAAQA,EAAO,MAA6C,OAAO,EAAE,KACnE,4CACF,EAEJ,CAAC,EAED,GAAG,8CAA+C,IAAM,CACtD,MAAMD,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,EAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,IAChC,OAAOA,EAAO,KAAK,EAAE,eAAe,oCAAkC,EACtE,OAAQA,EAAO,MAA6C,OAAO,EAAE,KACnE,4CACF,EAEJ,CAAC,EAED,GAAG,oDAAqD,IAAM,CAC5D,MAAMD,EAAyB,IAAI,eAAa,CAC9C,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EACKC,EAASH,EAAQ,cAAcE,CAAQ,EAC7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,CACH,CAAC",
6
+ "names": ["import_Errors", "import_CommandResult", "import_GetBackgroundImageSizeCommand", "import_ApduResponse", "IMAGE_SIZE_APDU", "command", "apdu", "response", "result"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var m=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of s(e))!p.call(r,t)&&t!==n&&i(r,t,{get:()=>e[t],enumerable:!(o=a(e,t))||o.enumerable});return r};var c=r=>m(i({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
1
+ "use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var m=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!s.call(r,t)&&t!==n&&i(r,t,{get:()=>e[t],enumerable:!(o=a(e,t))||o.enumerable});return r};var c=r=>m(i({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
2
2
  //# sourceMappingURL=DeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/api/device-action/DeviceAction.ts"],
4
- "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendApdu: (\n apdu: Uint8Array,\n ) => Promise<Either<DmkError, ApduResponse>>;\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceModel: () => TransportDeviceModel;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly disableRefresher: (blockerId: string) => () => void;\n readonly getManagerApiService: () => ManagerApiService;\n readonly getSecureChannelService: () => SecureChannelService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendApdu: (\n apdu: Uint8Array,\n ) => Promise<Either<DmkError, ApduResponse>>;\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceModel: () => TransportDeviceModel;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly getManagerApiService: () => ManagerApiService;\n readonly getSecureChannelService: () => SecureChannelService;\n readonly loggerFactory?: (tag: string) => LoggerPublisherService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["DeviceAction_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var i in e)c(n,i,{get:e[i],enumerable:!0})},S=(n,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of a(e))!r.call(n,t)&&t!==i&&c(n,t,{get:()=>e[t],enumerable:!(o=s(e,t))||o.enumerable});return n};var M=n=>S(c({},"__esModule",{value:!0}),n);var u={};v(u,{makeDeviceActionInternalApiMock:()=>b});module.exports=M(u);const p=vi.fn(),d=vi.fn(),f=vi.fn(),k=vi.fn(),l=vi.fn(),g=vi.fn(),m=vi.fn(),D=vi.fn(),A=vi.fn();function b(){return{sendApdu:p,sendCommand:d,getDeviceModel:f,getDeviceSessionState:k,getDeviceSessionStateObservable:l,setDeviceSessionState:g,getManagerApiService:m,getSecureChannelService:D,disableRefresher:A}}0&&(module.exports={makeDeviceActionInternalApiMock});
1
+ "use strict";var i=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},p=(e,t,o,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of a(t))!v.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(c=r(t,n))||c.enumerable});return e};var M=e=>p(i({},"__esModule",{value:!0}),e);var y={};S(y,{makeDeviceActionInternalApiMock:()=>b});module.exports=M(y);var s=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService");const g=vi.fn(),f=vi.fn(),k=vi.fn(),l=vi.fn(),d=vi.fn(),m=vi.fn(),D=vi.fn(),u=vi.fn(),A=vi.fn(e=>new s.DefaultLoggerPublisherService([],e));function b(){return{sendApdu:g,sendCommand:f,getDeviceModel:k,getDeviceSessionState:l,getDeviceSessionStateObservable:d,setDeviceSessionState:m,getManagerApiService:D,getSecureChannelService:u,loggerFactory:A}}0&&(module.exports={makeDeviceActionInternalApiMock});
2
2
  //# sourceMappingURL=makeInternalApi.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/__test-utils__/makeInternalApi.ts"],
4
- "sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\nconst disableRefresherMock = vi.fn();\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceModel: apiGetDeviceModelMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\n disableRefresher: disableRefresherMock,\n };\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAIA,MAAMI,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAAwB,GAAG,GAAG,EAC9BC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EACpCC,EAAuB,GAAG,GAAG,EAE5B,SAASV,GAAuD,CACrE,MAAO,CACL,SAAUE,EACV,YAAaC,EACb,eAAgBC,EAChB,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,EACzB,iBAAkBC,CACpB,CACF",
6
- "names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "disableRefresherMock"]
4
+ "sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\nconst loggerFactoryMock = vi.fn(\n (tag) => new DefaultLoggerPublisherService([], tag),\n);\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceModel: apiGetDeviceModelMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\n loggerFactory: loggerFactoryMock,\n };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAA8C,4EAE9C,MAAMC,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAAwB,GAAG,GAAG,EAC9BC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EACpCC,EAAoB,GAAG,GAC1BC,GAAQ,IAAI,gCAA8B,CAAC,EAAGA,CAAG,CACpD,EAEO,SAASZ,GAAuD,CACrE,MAAO,CACL,SAAUG,EACV,YAAaC,EACb,eAAgBC,EAChB,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,EACzB,cAAeC,CACjB,CACF",
6
+ "names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "import_DefaultLoggerPublisherService", "sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "loggerFactoryMock", "tag"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var S=(p,s)=>{for(var g in s)o(p,g,{get:s[g],enumerable:!0})},i=(p,s,g,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of w(s))!y.call(p,a)&&a!==g&&o(p,a,{get:()=>s[a],enumerable:!(n=A(s,a))||n.enumerable});return p};var h=p=>i(o({},"__esModule",{value:!0}),p);var k={};S(k,{UserInteractionRequired:()=>f});module.exports=h(k);var f=(l=>(l.None="none",l.UnlockDevice="unlock-device",l.AllowSecureConnection="allow-secure-connection",l.ConfirmOpenApp="confirm-open-app",l.SignTransaction="sign-transaction",l.SignTypedData="sign-typed-data",l.AllowListApps="allow-list-apps",l.VerifyAddress="verify-address",l.SignPersonalMessage="sign-personal-message",l.SignDelegationAuthorization="sign-delegation-authorization",l.Web3ChecksOptIn="web3-checks-opt-in",l.VerifySafeAddress="verify-safe-address",l.RegisterWallet="register-wallet",l))(f||{});0&&(module.exports={UserInteractionRequired});
1
+ "use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(g,m)=>{for(var a in m)p(g,a,{get:m[a],enumerable:!0})},v=(g,m,a,f)=>{if(m&&typeof m=="object"||typeof m=="function")for(let l of n(m))!A.call(g,l)&&l!==a&&p(g,l,{get:()=>m[l],enumerable:!(f=i(m,l))||f.enumerable});return g};var w=g=>v(p({},"__esModule",{value:!0}),g);var y={};C(y,{UserInteractionRequired:()=>s});module.exports=w(y);var s=(o=>(o.None="none",o.UnlockDevice="unlock-device",o.AllowSecureConnection="allow-secure-connection",o.ConfirmOpenApp="confirm-open-app",o.SignTransaction="sign-transaction",o.SignTypedData="sign-typed-data",o.AllowListApps="allow-list-apps",o.VerifyAddress="verify-address",o.SignPersonalMessage="sign-personal-message",o.SignDelegationAuthorization="sign-delegation-authorization",o.Web3ChecksOptIn="web3-checks-opt-in",o.VerifySafeAddress="verify-safe-address",o.RegisterWallet="register-wallet",o.ConfirmLoadImage="confirm-load-image",o.ConfirmCommitImage="confirm-commit-image",o.ConfirmRemoveImage="confirm-remove-image",o))(s||{});0&&(module.exports={UserInteractionRequired});
2
2
  //# sourceMappingURL=UserInteractionRequired.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/model/UserInteractionRequired.ts"],
4
- "sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n RegisterWallet = \"register-wallet\",\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,kBAbPA,OAAA",
4
+ "sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n RegisterWallet = \"register-wallet\",\n ConfirmLoadImage = \"confirm-load-image\",\n ConfirmCommitImage = \"confirm-commit-image\",\n ConfirmRemoveImage = \"confirm-remove-image\",\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,kBACjBA,EAAA,iBAAmB,qBACnBA,EAAA,mBAAqB,uBACrBA,EAAA,mBAAqB,uBAhBXA,OAAA",
6
6
  "names": ["UserInteractionRequired_exports", "__export", "UserInteractionRequired", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var U=(a,e)=>{for(var o in e)p(a,o,{get:e[o],enumerable:!0})},h=(a,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!I.call(a,r)&&r!==o&&p(a,r,{get:()=>e[r],enumerable:!(t=y(e,r))||t.enumerable});return a};var R=a=>h(p({},"__esModule",{value:!0}),a);var G={};U(G,{GetFirmwareMetadataTask:()=>x});module.exports=R(G);var f=require("../../command/Errors"),n=require("../../command/model/CommandResult"),l=require("../../command/os/GetCustomImageSizeCommand"),F=require("../../command/os/GetOsVersionCommand");class x{constructor(e){this.api=e}async run(){const e=await this.api.sendCommand(new F.GetOsVersionCommand);if(!(0,n.isSuccessCommandResult)(e))return e;const o={mcu:e.data.mcuSephVersion,bootloader:e.data.mcuBootloaderVersion,os:e.data.seVersion,metadata:e.data},t=this.api.getManagerApiService(),r=await t.getDeviceVersion(e.data).chain(i=>t.getFirmwareVersion(e.data,i).map(s=>({deviceVersion:i,currentFirmware:s})));if(r.isLeft())return(0,n.CommandResultFactory)({error:new f.InvalidGetFirmwareMetadataResponseError});const{deviceVersion:c,currentFirmware:d}=r.unsafeCoerce(),V=(await t.getLatestFirmwareVersion(d,c).chain(i=>t.getNextFirmwareVersion(i).chain(s=>t.getMcuList().map(m=>m.find(g=>g.name===o.mcu)).map(m=>m===void 0||!s.mcuVersions.includes(m.id)).map(m=>({osuFirmware:i,finalFirmware:s,mcuUpdateRequired:m}))))).caseOf({Right:i=>i,Left:i=>{}}),C={currentFirmware:d,availableUpdate:V};let u={};const w=await this.api.sendCommand(new l.GetCustomImageSizeCommand);return(0,n.isSuccessCommandResult)(w)&&(u={size:w.data}),(0,n.CommandResultFactory)({data:{deviceVersion:c,firmware:d,firmwareVersion:o,firmwareUpdateContext:C,customImage:u}})}}0&&(module.exports={GetFirmwareMetadataTask});
1
+ "use strict";var p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var U=(a,e)=>{for(var o in e)p(a,o,{get:e[o],enumerable:!0})},h=(a,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!I.call(a,r)&&r!==o&&p(a,r,{get:()=>e[r],enumerable:!(t=y(e,r))||t.enumerable});return a};var R=a=>h(p({},"__esModule",{value:!0}),a);var G={};U(G,{GetFirmwareMetadataTask:()=>x});module.exports=R(G);var f=require("../../command/Errors"),n=require("../../command/model/CommandResult"),l=require("../../command/os/GetBackgroundImageSizeCommand"),F=require("../../command/os/GetOsVersionCommand");class x{constructor(e){this.api=e}async run(){const e=await this.api.sendCommand(new F.GetOsVersionCommand);if(!(0,n.isSuccessCommandResult)(e))return e;const o={mcu:e.data.mcuSephVersion,bootloader:e.data.mcuBootloaderVersion,os:e.data.seVersion,metadata:e.data},t=this.api.getManagerApiService(),r=await t.getDeviceVersion(e.data).chain(i=>t.getFirmwareVersion(e.data,i).map(s=>({deviceVersion:i,currentFirmware:s})));if(r.isLeft())return(0,n.CommandResultFactory)({error:new f.InvalidGetFirmwareMetadataResponseError});const{deviceVersion:c,currentFirmware:d}=r.unsafeCoerce(),V=(await t.getLatestFirmwareVersion(d,c).chain(i=>t.getNextFirmwareVersion(i).chain(s=>t.getMcuList().map(m=>m.find(C=>C.name===o.mcu)).map(m=>m===void 0||!s.mcuVersions.includes(m.id)).map(m=>({osuFirmware:i,finalFirmware:s,mcuUpdateRequired:m}))))).caseOf({Right:i=>i,Left:i=>{}}),g={currentFirmware:d,availableUpdate:V};let u={};const w=await this.api.sendCommand(new l.GetBackgroundImageSizeCommand);return(0,n.isSuccessCommandResult)(w)&&(u={size:w.data}),(0,n.CommandResultFactory)({data:{deviceVersion:c,firmware:d,firmwareVersion:o,firmwareUpdateContext:g,customImage:u}})}}0&&(module.exports={GetFirmwareMetadataTask});
2
2
  //# sourceMappingURL=GetFirmwareMetadataTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/task/GetFirmwareMetadataTask.ts"],
4
- "sourcesContent": ["import { InvalidGetFirmwareMetadataResponseError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { GetCustomImageSizeCommand } from \"@api/command/os/GetCustomImageSizeCommand\";\nimport { GetOsVersionCommand } from \"@api/command/os/GetOsVersionCommand\";\nimport type { InternalApi } from \"@api/device-action/DeviceAction\";\nimport {\n type CustomImage,\n type FirmwareUpdate,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nexport type GetFirmwareMetadataTaskResult = CommandResult<{\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n firmwareUpdateContext: FirmwareUpdateContext;\n customImage: CustomImage;\n}>;\n\nexport class GetFirmwareMetadataTask {\n constructor(private readonly api: InternalApi) {}\n\n async run(): Promise<GetFirmwareMetadataTaskResult> {\n // Get installed firmware metadata\n const osVersion = await this.api.sendCommand(new GetOsVersionCommand());\n if (!isSuccessCommandResult(osVersion)) {\n return osVersion;\n }\n const firmwareVersion: FirmwareVersion = {\n mcu: osVersion.data.mcuSephVersion,\n bootloader: osVersion.data.mcuBootloaderVersion,\n os: osVersion.data.seVersion,\n metadata: osVersion.data,\n };\n\n // Fetch current firmware metadata from app store\n const manager = this.api.getManagerApiService();\n const result = await manager\n .getDeviceVersion(osVersion.data)\n .chain((deviceVersion) =>\n manager\n .getFirmwareVersion(osVersion.data, deviceVersion)\n .map((currentFirmware) => ({ deviceVersion, currentFirmware })),\n );\n if (result.isLeft()) {\n return CommandResultFactory({\n error: new InvalidGetFirmwareMetadataResponseError(),\n });\n }\n const { deviceVersion, currentFirmware } = result.unsafeCoerce();\n\n // Fetch latest firmware available, if any\n const maybeUpdate = await manager\n .getLatestFirmwareVersion(currentFirmware, deviceVersion)\n .chain((osuFirmware) =>\n manager.getNextFirmwareVersion(osuFirmware).chain((finalFirmware) =>\n manager\n .getMcuList()\n .map((mcus) => mcus.find((mcu) => mcu.name === firmwareVersion.mcu))\n .map(\n (mcu) =>\n mcu === undefined ||\n !finalFirmware.mcuVersions.includes(mcu.id),\n )\n .map((mcuUpdateRequired) => ({\n osuFirmware,\n finalFirmware,\n mcuUpdateRequired,\n })),\n ),\n );\n const availableUpdate: FirmwareUpdate | undefined = maybeUpdate.caseOf({\n Right: (data) => data,\n Left: (_error) => undefined,\n });\n const firmwareUpdateContext = {\n currentFirmware,\n availableUpdate,\n };\n\n // Get custom image metadata\n let customImage: CustomImage = {};\n const imageSize = await this.api.sendCommand(\n new GetCustomImageSizeCommand(),\n );\n if (isSuccessCommandResult(imageSize)) {\n customImage = { size: imageSize.data };\n }\n\n // Return firmware metadata\n return CommandResultFactory({\n data: {\n deviceVersion,\n firmware: currentFirmware,\n firmwareVersion,\n firmwareUpdateContext,\n customImage,\n },\n });\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwD,+BACxDC,EAIO,4CACPC,EAA0C,qDAC1CC,EAAoC,+CAmB7B,MAAML,CAAwB,CACnC,YAA6BM,EAAkB,CAAlB,SAAAA,CAAmB,CAEhD,MAAM,KAA8C,CAElD,MAAMC,EAAY,MAAM,KAAK,IAAI,YAAY,IAAI,qBAAqB,EACtE,GAAI,IAAC,0BAAuBA,CAAS,EACnC,OAAOA,EAET,MAAMC,EAAmC,CACvC,IAAKD,EAAU,KAAK,eACpB,WAAYA,EAAU,KAAK,qBAC3B,GAAIA,EAAU,KAAK,UACnB,SAAUA,EAAU,IACtB,EAGME,EAAU,KAAK,IAAI,qBAAqB,EACxCC,EAAS,MAAMD,EAClB,iBAAiBF,EAAU,IAAI,EAC/B,MAAOI,GACNF,EACG,mBAAmBF,EAAU,KAAMI,CAAa,EAChD,IAAKC,IAAqB,CAAE,cAAAD,EAAe,gBAAAC,CAAgB,EAAE,CAClE,EACF,GAAIF,EAAO,OAAO,EAChB,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yCACb,CAAC,EAEH,KAAM,CAAE,cAAAC,EAAe,gBAAAC,CAAgB,EAAIF,EAAO,aAAa,EAsBzDG,GAnBc,MAAMJ,EACvB,yBAAyBG,EAAiBD,CAAa,EACvD,MAAOG,GACNL,EAAQ,uBAAuBK,CAAW,EAAE,MAAOC,GACjDN,EACG,WAAW,EACX,IAAKO,GAASA,EAAK,KAAMC,GAAQA,EAAI,OAAST,EAAgB,GAAG,CAAC,EAClE,IACES,GACCA,IAAQ,QACR,CAACF,EAAc,YAAY,SAASE,EAAI,EAAE,CAC9C,EACC,IAAKC,IAAuB,CAC3B,YAAAJ,EACA,cAAAC,EACA,kBAAAG,CACF,EAAE,CACN,CACF,GAC8D,OAAO,CACrE,MAAQC,GAASA,EACjB,KAAOC,GAAQ,EACjB,CAAC,EACKC,EAAwB,CAC5B,gBAAAT,EACA,gBAAAC,CACF,EAGA,IAAIS,EAA2B,CAAC,EAChC,MAAMC,EAAY,MAAM,KAAK,IAAI,YAC/B,IAAI,2BACN,EACA,SAAI,0BAAuBA,CAAS,IAClCD,EAAc,CAAE,KAAMC,EAAU,IAAK,MAIhC,wBAAqB,CAC1B,KAAM,CACJ,cAAAZ,EACA,SAAUC,EACV,gBAAAJ,EACA,sBAAAa,EACA,YAAAC,CACF,CACF,CAAC,CACH,CACF",
6
- "names": ["GetFirmwareMetadataTask_exports", "__export", "GetFirmwareMetadataTask", "__toCommonJS", "import_Errors", "import_CommandResult", "import_GetCustomImageSizeCommand", "import_GetOsVersionCommand", "api", "osVersion", "firmwareVersion", "manager", "result", "deviceVersion", "currentFirmware", "availableUpdate", "osuFirmware", "finalFirmware", "mcus", "mcu", "mcuUpdateRequired", "data", "_error", "firmwareUpdateContext", "customImage", "imageSize"]
4
+ "sourcesContent": ["import { InvalidGetFirmwareMetadataResponseError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { GetBackgroundImageSizeCommand } from \"@api/command/os/GetBackgroundImageSizeCommand\";\nimport { GetOsVersionCommand } from \"@api/command/os/GetOsVersionCommand\";\nimport type { InternalApi } from \"@api/device-action/DeviceAction\";\nimport {\n type CustomImage,\n type FirmwareUpdate,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nexport type GetFirmwareMetadataTaskResult = CommandResult<{\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n firmwareUpdateContext: FirmwareUpdateContext;\n customImage: CustomImage;\n}>;\n\nexport class GetFirmwareMetadataTask {\n constructor(private readonly api: InternalApi) {}\n\n async run(): Promise<GetFirmwareMetadataTaskResult> {\n // Get installed firmware metadata\n const osVersion = await this.api.sendCommand(new GetOsVersionCommand());\n if (!isSuccessCommandResult(osVersion)) {\n return osVersion;\n }\n const firmwareVersion: FirmwareVersion = {\n mcu: osVersion.data.mcuSephVersion,\n bootloader: osVersion.data.mcuBootloaderVersion,\n os: osVersion.data.seVersion,\n metadata: osVersion.data,\n };\n\n // Fetch current firmware metadata from app store\n const manager = this.api.getManagerApiService();\n const result = await manager\n .getDeviceVersion(osVersion.data)\n .chain((deviceVersion) =>\n manager\n .getFirmwareVersion(osVersion.data, deviceVersion)\n .map((currentFirmware) => ({ deviceVersion, currentFirmware })),\n );\n if (result.isLeft()) {\n return CommandResultFactory({\n error: new InvalidGetFirmwareMetadataResponseError(),\n });\n }\n const { deviceVersion, currentFirmware } = result.unsafeCoerce();\n\n // Fetch latest firmware available, if any\n const maybeUpdate = await manager\n .getLatestFirmwareVersion(currentFirmware, deviceVersion)\n .chain((osuFirmware) =>\n manager.getNextFirmwareVersion(osuFirmware).chain((finalFirmware) =>\n manager\n .getMcuList()\n .map((mcus) => mcus.find((mcu) => mcu.name === firmwareVersion.mcu))\n .map(\n (mcu) =>\n mcu === undefined ||\n !finalFirmware.mcuVersions.includes(mcu.id),\n )\n .map((mcuUpdateRequired) => ({\n osuFirmware,\n finalFirmware,\n mcuUpdateRequired,\n })),\n ),\n );\n const availableUpdate: FirmwareUpdate | undefined = maybeUpdate.caseOf({\n Right: (data) => data,\n Left: (_error) => undefined,\n });\n const firmwareUpdateContext = {\n currentFirmware,\n availableUpdate,\n };\n\n // Get custom image metadata\n let customImage: CustomImage = {};\n const imageSize = await this.api.sendCommand(\n new GetBackgroundImageSizeCommand(),\n );\n if (isSuccessCommandResult(imageSize)) {\n customImage = { size: imageSize.data };\n }\n\n // Return firmware metadata\n return CommandResultFactory({\n data: {\n deviceVersion,\n firmware: currentFirmware,\n firmwareVersion,\n firmwareUpdateContext,\n customImage,\n },\n });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwD,+BACxDC,EAIO,4CACPC,EAA8C,yDAC9CC,EAAoC,+CAmB7B,MAAML,CAAwB,CACnC,YAA6BM,EAAkB,CAAlB,SAAAA,CAAmB,CAEhD,MAAM,KAA8C,CAElD,MAAMC,EAAY,MAAM,KAAK,IAAI,YAAY,IAAI,qBAAqB,EACtE,GAAI,IAAC,0BAAuBA,CAAS,EACnC,OAAOA,EAET,MAAMC,EAAmC,CACvC,IAAKD,EAAU,KAAK,eACpB,WAAYA,EAAU,KAAK,qBAC3B,GAAIA,EAAU,KAAK,UACnB,SAAUA,EAAU,IACtB,EAGME,EAAU,KAAK,IAAI,qBAAqB,EACxCC,EAAS,MAAMD,EAClB,iBAAiBF,EAAU,IAAI,EAC/B,MAAOI,GACNF,EACG,mBAAmBF,EAAU,KAAMI,CAAa,EAChD,IAAKC,IAAqB,CAAE,cAAAD,EAAe,gBAAAC,CAAgB,EAAE,CAClE,EACF,GAAIF,EAAO,OAAO,EAChB,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yCACb,CAAC,EAEH,KAAM,CAAE,cAAAC,EAAe,gBAAAC,CAAgB,EAAIF,EAAO,aAAa,EAsBzDG,GAnBc,MAAMJ,EACvB,yBAAyBG,EAAiBD,CAAa,EACvD,MAAOG,GACNL,EAAQ,uBAAuBK,CAAW,EAAE,MAAOC,GACjDN,EACG,WAAW,EACX,IAAKO,GAASA,EAAK,KAAMC,GAAQA,EAAI,OAAST,EAAgB,GAAG,CAAC,EAClE,IACES,GACCA,IAAQ,QACR,CAACF,EAAc,YAAY,SAASE,EAAI,EAAE,CAC9C,EACC,IAAKC,IAAuB,CAC3B,YAAAJ,EACA,cAAAC,EACA,kBAAAG,CACF,EAAE,CACN,CACF,GAC8D,OAAO,CACrE,MAAQC,GAASA,EACjB,KAAOC,GAAQ,EACjB,CAAC,EACKC,EAAwB,CAC5B,gBAAAT,EACA,gBAAAC,CACF,EAGA,IAAIS,EAA2B,CAAC,EAChC,MAAMC,EAAY,MAAM,KAAK,IAAI,YAC/B,IAAI,+BACN,EACA,SAAI,0BAAuBA,CAAS,IAClCD,EAAc,CAAE,KAAMC,EAAU,IAAK,MAIhC,wBAAqB,CAC1B,KAAM,CACJ,cAAAZ,EACA,SAAUC,EACV,gBAAAJ,EACA,sBAAAa,EACA,YAAAC,CACF,CACF,CAAC,CACH,CACF",
6
+ "names": ["GetFirmwareMetadataTask_exports", "__export", "GetFirmwareMetadataTask", "__toCommonJS", "import_Errors", "import_CommandResult", "import_GetBackgroundImageSizeCommand", "import_GetOsVersionCommand", "api", "osVersion", "firmwareVersion", "manager", "result", "deviceVersion", "currentFirmware", "availableUpdate", "osuFirmware", "finalFirmware", "mcus", "mcu", "mcuUpdateRequired", "data", "_error", "firmwareUpdateContext", "customImage", "imageSize"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var A=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},D=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of v(e))!g.call(a,n)&&n!==t&&l(a,n,{get:()=>e[n],enumerable:!(r=y(e,n))||r.enumerable});return a};var E=a=>D(l({},"__esModule",{value:!0}),a);var M={};A(M,{XStateDeviceAction:()=>x});module.exports=E(M);var o=require("rxjs"),h=require("xstate"),p=require("../../device-action/model/DeviceActionState");class x{input;inspect=!1;logger;constructor(e){this.input=e.input,this.inspect=!!e.inspect,this.logger=e.logger}_execute(e){const t=this.makeStateMachine(e);return this._subscribeToStateMachine(t)}_subscribeToStateMachine(e){const t=(0,h.createActor)(e,{input:this.input}),r=new o.ReplaySubject;let n=!1;const m=i=>{const{context:u,status:s,output:b,error:I}=i;if(this.logger&&!n&&(n=!0,this.logger.debug("[XStateDeviceAction] Input",{data:{input:u.input}})),this.logger&&s==="active"){const c=typeof i.value=="string"?i.value:JSON.stringify(i.value);this.logger.debug(`[XStateDeviceAction] State: ${c}`,{data:{internalState:u._internalState}})}switch(s){case"active":r.next({status:p.DeviceActionStatus.Pending,intermediateValue:u.intermediateValue});break;case"done":b.caseOf({Left:c=>{r.next({status:p.DeviceActionStatus.Error,error:c})},Right:c=>{r.next({status:p.DeviceActionStatus.Completed,output:c})}}),r.complete();break;case"error":r.error(I),r.complete();break;case"stopped":r.next({status:p.DeviceActionStatus.Stopped}),r.complete();break;default:this._exhaustiveMatchingGuard(s)}},d=new o.Observable(i=>{const u=r.subscribe(i);return()=>{S.unsubscribe(),u.unsubscribe(),t.stop()}}),S=t.subscribe(m);return t.start(),{observable:d.pipe((0,o.share)()),cancel:()=>{t.stop(),S.unsubscribe(),m(t.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}0&&(module.exports={XStateDeviceAction});
1
+ "use strict";var l=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var D=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},E=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of v(e))!A.call(a,n)&&n!==t&&l(a,n,{get:()=>e[n],enumerable:!(r=I(e,n))||r.enumerable});return a};var f=a=>E(l({},"__esModule",{value:!0}),a);var M={};D(M,{XStateDeviceAction:()=>x});module.exports=f(M);var o=require("rxjs"),S=require("xstate"),s=require("../../device-action/model/DeviceActionState"),m=require("../../logger-publisher/utils/noopLoggerFactory");class x{input;inspect=!1;logger;loggerFactory;constructor(e){this.input=e.input,this.inspect=!!e.inspect,this.logger=e.logger,this.loggerFactory=e.loggerFactory}getLoggerFactory(e){return this.loggerFactory??e.loggerFactory??m.noopLoggerFactory}_execute(e){const t=this.makeStateMachine(e);return!this.logger&&t.id&&(this.logger=this.getLoggerFactory(e)(t.id)),this._subscribeToStateMachine(t)}_subscribeToStateMachine(e){const t=(0,S.createActor)(e,{input:this.input}),r=new o.ReplaySubject;let n=!1;const g=i=>{const{context:c,status:p,output:y,error:b}=i;if(this.logger&&!n&&(n=!0,this.logger.debug("[XStateDeviceAction] Input",{data:{input:c.input}})),this.logger&&p==="active"){const u=typeof i.value=="string"?i.value:JSON.stringify(i.value);this.logger.debug(`[XStateDeviceAction] State: ${u}`,{data:{internalState:c._internalState}})}switch(p){case"active":r.next({status:s.DeviceActionStatus.Pending,intermediateValue:c.intermediateValue});break;case"done":y.caseOf({Left:u=>{r.next({status:s.DeviceActionStatus.Error,error:u})},Right:u=>{r.next({status:s.DeviceActionStatus.Completed,output:u})}}),r.complete();break;case"error":r.error(b),r.complete();break;case"stopped":r.next({status:s.DeviceActionStatus.Stopped}),r.complete();break;default:this._exhaustiveMatchingGuard(p)}},d=new o.Observable(i=>{const c=r.subscribe(i);return()=>{h.unsubscribe(),c.unsubscribe(),t.stop()}}),h=t.subscribe(g);return t.start(),{observable:d.pipe((0,o.share)()),cancel:()=>{t.stop(),h.unsubscribe(),g(t.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}0&&(module.exports={XStateDeviceAction});
2
2
  //# sourceMappingURL=XStateDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/xstate-utils/XStateDeviceAction.ts"],
4
- "sourcesContent": ["// import { createBrowserInspector } from \"@statelyai/inspect\";\nimport { Observable, ReplaySubject, share } from \"rxjs\";\nimport {\n createActor,\n type SnapshotFrom,\n type StateMachine,\n type StateSchema,\n} from \"xstate\";\n\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\n\nimport { type StateMachineTypes } from \"./StateMachineTypes\";\n\nexport type DeviceActionStateMachine<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> = StateMachine<\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"context\"], // context\n /**\n * The following usages `any` are OK because this is just a wrapper around the\n * state machine and we are not directly going to use these types.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any, // event\n any, // children\n any, // actor\n any, // action\n any, // guard\n any, // delay\n any, // state value\n any, // tag\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"input\"],\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"output\"],\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any,\n any,\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateSchema\n>;\n\n/**\n * A DeviceAction that uses an XState state machine to execute.\n * It maps the state machine snapshots to the DeviceActionState.\n * This class is abstract and should be extended to implement the state machine.\n */\nexport abstract class XStateDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> implements DeviceAction<Output, Input, Error, IntermediateValue>\n{\n readonly input: Input;\n readonly inspect: boolean = false;\n protected readonly logger?: LoggerPublisherService;\n\n /**\n *\n * @param input The input for the DeviceAction\n * @param inspect If true, the state machine will be inspected in the browser\n * @param logger Optional logger for debugging. If provided, input and internal state will be logged on state transitions.\n */\n constructor(args: {\n input: Input;\n inspect?: boolean;\n logger?: LoggerPublisherService;\n }) {\n this.input = args.input;\n this.inspect = Boolean(args.inspect);\n this.logger = args.logger;\n }\n\n protected abstract makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >;\n\n _execute(\n internalApi: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const stateMachine = this.makeStateMachine(internalApi);\n return this._subscribeToStateMachine(stateMachine);\n }\n\n protected _subscribeToStateMachine(\n stateMachine: DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const actor = createActor(stateMachine, {\n input: this.input,\n // optional inspector for debugging\n // inspect: this.inspect ? createBrowserInspector().inspect : undefined,\n });\n\n /**\n * Using a ReplaySubject is important because the first snapshots might be\n * emitted before the observable is subscribed (if the machine goes through\n * those states fully synchronously).\n * This way, we ensure that the subscriber always receives the latest snapshot.\n * */\n const subject = new ReplaySubject<\n DeviceActionState<Output, Error, IntermediateValue>\n >();\n\n let hasLoggedInput = false;\n\n const handleActorSnapshot = (\n snapshot: SnapshotFrom<typeof stateMachine>,\n ) => {\n const { context, status, output, error } = snapshot;\n\n // Log input once at the beginning\n if (this.logger && !hasLoggedInput) {\n hasLoggedInput = true;\n this.logger.debug(\"[XStateDeviceAction] Input\", {\n data: { input: context.input },\n });\n }\n\n // Log internal state on each state transition\n if (this.logger && status === \"active\") {\n const stateValue =\n typeof snapshot.value === \"string\"\n ? snapshot.value\n : JSON.stringify(snapshot.value);\n this.logger.debug(`[XStateDeviceAction] State: ${stateValue}`, {\n data: { internalState: context._internalState },\n });\n }\n\n switch (status) {\n case \"active\":\n subject.next({\n status: DeviceActionStatus.Pending,\n intermediateValue: context.intermediateValue,\n });\n break;\n case \"done\":\n output.caseOf({\n Left: (err) => {\n subject.next({\n status: DeviceActionStatus.Error,\n error: err,\n });\n },\n Right: (result) => {\n subject.next({\n status: DeviceActionStatus.Completed,\n output: result,\n });\n },\n });\n subject.complete();\n break;\n case \"error\":\n // this is an error in the execution of the state machine, it should not happen\n subject.error(error);\n subject.complete();\n break;\n case \"stopped\":\n subject.next({\n status: DeviceActionStatus.Stopped,\n });\n subject.complete();\n break;\n default:\n this._exhaustiveMatchingGuard(status);\n }\n };\n\n const observable = new Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >((subscriber) => {\n const subjectSubscription = subject.subscribe(subscriber);\n return () => {\n actorSubscription.unsubscribe();\n subjectSubscription.unsubscribe();\n actor.stop(); // stop the actor when the observable is unsubscribed\n };\n });\n\n const actorSubscription = actor.subscribe(handleActorSnapshot);\n actor.start();\n\n return {\n observable: observable.pipe(share()), // share to garantee that once there is no more observer, the actor is stopped\n cancel: () => {\n actor.stop();\n actorSubscription.unsubscribe();\n handleActorSnapshot(actor.getSnapshot());\n },\n };\n }\n\n private _exhaustiveMatchingGuard(status: never): never {\n console.log(\"_exhaustiveMatchingGuard status\", status);\n throw new Error(`Unhandled status: ${status}`);\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAKO,kBAQPC,EAGO,sDA4DA,MAAeJ,CAOtB,CACW,MACA,QAAmB,GACT,OAQnB,YAAYK,EAIT,CACD,KAAK,MAAQA,EAAK,MAClB,KAAK,QAAU,EAAQA,EAAK,QAC5B,KAAK,OAASA,EAAK,MACrB,CAYA,SACEC,EACiE,CACjE,MAAMC,EAAe,KAAK,iBAAiBD,CAAW,EACtD,OAAO,KAAK,yBAAyBC,CAAY,CACnD,CAEU,yBACRA,EAOiE,CACjE,MAAMC,KAAQ,eAAYD,EAAc,CACtC,MAAO,KAAK,KAGd,CAAC,EAQKE,EAAU,IAAI,gBAIpB,IAAIC,EAAiB,GAErB,MAAMC,EACJC,GACG,CACH,KAAM,CAAE,QAAAC,EAAS,OAAAC,EAAQ,OAAAC,EAAQ,MAAAC,CAAM,EAAIJ,EAW3C,GARI,KAAK,QAAU,CAACF,IAClBA,EAAiB,GACjB,KAAK,OAAO,MAAM,6BAA8B,CAC9C,KAAM,CAAE,MAAOG,EAAQ,KAAM,CAC/B,CAAC,GAIC,KAAK,QAAUC,IAAW,SAAU,CACtC,MAAMG,EACJ,OAAOL,EAAS,OAAU,SACtBA,EAAS,MACT,KAAK,UAAUA,EAAS,KAAK,EACnC,KAAK,OAAO,MAAM,+BAA+BK,CAAU,GAAI,CAC7D,KAAM,CAAE,cAAeJ,EAAQ,cAAe,CAChD,CAAC,CACH,CAEA,OAAQC,EAAQ,CACd,IAAK,SACHL,EAAQ,KAAK,CACX,OAAQ,qBAAmB,QAC3B,kBAAmBI,EAAQ,iBAC7B,CAAC,EACD,MACF,IAAK,OACHE,EAAO,OAAO,CACZ,KAAOG,GAAQ,CACbT,EAAQ,KAAK,CACX,OAAQ,qBAAmB,MAC3B,MAAOS,CACT,CAAC,CACH,EACA,MAAQC,GAAW,CACjBV,EAAQ,KAAK,CACX,OAAQ,qBAAmB,UAC3B,OAAQU,CACV,CAAC,CACH,CACF,CAAC,EACDV,EAAQ,SAAS,EACjB,MACF,IAAK,QAEHA,EAAQ,MAAMO,CAAK,EACnBP,EAAQ,SAAS,EACjB,MACF,IAAK,UACHA,EAAQ,KAAK,CACX,OAAQ,qBAAmB,OAC7B,CAAC,EACDA,EAAQ,SAAS,EACjB,MACF,QACE,KAAK,yBAAyBK,CAAM,CACxC,CACF,EAEMM,EAAa,IAAI,aAEpBC,GAAe,CAChB,MAAMC,EAAsBb,EAAQ,UAAUY,CAAU,EACxD,MAAO,IAAM,CACXE,EAAkB,YAAY,EAC9BD,EAAoB,YAAY,EAChCd,EAAM,KAAK,CACb,CACF,CAAC,EAEKe,EAAoBf,EAAM,UAAUG,CAAmB,EAC7D,OAAAH,EAAM,MAAM,EAEL,CACL,WAAYY,EAAW,QAAK,SAAM,CAAC,EACnC,OAAQ,IAAM,CACZZ,EAAM,KAAK,EACXe,EAAkB,YAAY,EAC9BZ,EAAoBH,EAAM,YAAY,CAAC,CACzC,CACF,CACF,CAEQ,yBAAyBM,EAAsB,CACrD,cAAQ,IAAI,kCAAmCA,CAAM,EAC/C,IAAI,MAAM,qBAAqBA,CAAM,EAAE,CAC/C,CACF",
6
- "names": ["XStateDeviceAction_exports", "__export", "XStateDeviceAction", "__toCommonJS", "import_rxjs", "import_xstate", "import_DeviceActionState", "args", "internalApi", "stateMachine", "actor", "subject", "hasLoggedInput", "handleActorSnapshot", "snapshot", "context", "status", "output", "error", "stateValue", "err", "result", "observable", "subscriber", "subjectSubscription", "actorSubscription"]
4
+ "sourcesContent": ["// import { createBrowserInspector } from \"@statelyai/inspect\";\nimport { Observable, ReplaySubject, share } from \"rxjs\";\nimport {\n createActor,\n type SnapshotFrom,\n type StateMachine,\n type StateSchema,\n} from \"xstate\";\n\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { noopLoggerFactory } from \"@api/logger-publisher/utils/noopLoggerFactory\";\n\nimport { type StateMachineTypes } from \"./StateMachineTypes\";\n\nexport type DeviceActionStateMachine<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> = StateMachine<\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"context\"], // context\n /**\n * The following usages `any` are OK because this is just a wrapper around the\n * state machine and we are not directly going to use these types.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any, // event\n any, // children\n any, // actor\n any, // action\n any, // guard\n any, // delay\n any, // state value\n any, // tag\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"input\"],\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"output\"],\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any,\n any,\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateSchema\n>;\n\n/**\n * A DeviceAction that uses an XState state machine to execute.\n * It maps the state machine snapshots to the DeviceActionState.\n * This class is abstract and should be extended to implement the state machine.\n */\nexport abstract class XStateDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> implements DeviceAction<Output, Input, Error, IntermediateValue>\n{\n readonly input: Input;\n readonly inspect: boolean = false;\n protected logger?: LoggerPublisherService;\n protected loggerFactory?: (tag: string) => LoggerPublisherService;\n\n /**\n *\n * @param input The input for the DeviceAction\n * @param inspect If true, the state machine will be inspected in the browser\n * @param logger Optional logger for debugging. If provided, input and internal state will be logged on state transitions.\n * @param loggerFactory Optional logger factory for creating loggers with prefixed tags. Takes precedence over logger.\n */\n constructor(args: {\n input: Input;\n inspect?: boolean;\n logger?: LoggerPublisherService;\n loggerFactory?: (tag: string) => LoggerPublisherService;\n }) {\n this.input = args.input;\n this.inspect = Boolean(args.inspect);\n this.logger = args.logger;\n this.loggerFactory = args.loggerFactory;\n }\n\n /**\n * Returns the logger factory to use for creating loggers.\n * Prefers the instance loggerFactory, then internalApi.loggerFactory,\n * and falls back to a no-op logger factory if neither is available.\n */\n protected getLoggerFactory(\n internalApi: InternalApi,\n ): (tag: string) => LoggerPublisherService {\n return this.loggerFactory ?? internalApi.loggerFactory ?? noopLoggerFactory;\n }\n\n protected abstract makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >;\n\n _execute(\n internalApi: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const stateMachine = this.makeStateMachine(internalApi);\n\n // Create logger from machine ID if not explicitly provided\n // Prefer loggerFactory (prefixed) over internalApi.loggerFactory (unprefixed)\n if (!this.logger && stateMachine.id) {\n this.logger = this.getLoggerFactory(internalApi)(stateMachine.id);\n }\n\n return this._subscribeToStateMachine(stateMachine);\n }\n\n protected _subscribeToStateMachine(\n stateMachine: DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const actor = createActor(stateMachine, {\n input: this.input,\n // optional inspector for debugging\n // inspect: this.inspect ? createBrowserInspector().inspect : undefined,\n });\n\n /**\n * Using a ReplaySubject is important because the first snapshots might be\n * emitted before the observable is subscribed (if the machine goes through\n * those states fully synchronously).\n * This way, we ensure that the subscriber always receives the latest snapshot.\n * */\n const subject = new ReplaySubject<\n DeviceActionState<Output, Error, IntermediateValue>\n >();\n\n let hasLoggedInput = false;\n\n const handleActorSnapshot = (\n snapshot: SnapshotFrom<typeof stateMachine>,\n ) => {\n const { context, status, output, error } = snapshot;\n\n // Log input once at the beginning\n if (this.logger && !hasLoggedInput) {\n hasLoggedInput = true;\n this.logger.debug(\"[XStateDeviceAction] Input\", {\n data: { input: context.input },\n });\n }\n\n // Log internal state on each state transition\n if (this.logger && status === \"active\") {\n const stateValue =\n typeof snapshot.value === \"string\"\n ? snapshot.value\n : JSON.stringify(snapshot.value);\n this.logger.debug(`[XStateDeviceAction] State: ${stateValue}`, {\n data: { internalState: context._internalState },\n });\n }\n\n switch (status) {\n case \"active\":\n subject.next({\n status: DeviceActionStatus.Pending,\n intermediateValue: context.intermediateValue,\n });\n break;\n case \"done\":\n output.caseOf({\n Left: (err) => {\n subject.next({\n status: DeviceActionStatus.Error,\n error: err,\n });\n },\n Right: (result) => {\n subject.next({\n status: DeviceActionStatus.Completed,\n output: result,\n });\n },\n });\n subject.complete();\n break;\n case \"error\":\n // this is an error in the execution of the state machine, it should not happen\n subject.error(error);\n subject.complete();\n break;\n case \"stopped\":\n subject.next({\n status: DeviceActionStatus.Stopped,\n });\n subject.complete();\n break;\n default:\n this._exhaustiveMatchingGuard(status);\n }\n };\n\n const observable = new Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >((subscriber) => {\n const subjectSubscription = subject.subscribe(subscriber);\n return () => {\n actorSubscription.unsubscribe();\n subjectSubscription.unsubscribe();\n actor.stop(); // stop the actor when the observable is unsubscribed\n };\n });\n\n const actorSubscription = actor.subscribe(handleActorSnapshot);\n actor.start();\n\n return {\n observable: observable.pipe(share()), // share to garantee that once there is no more observer, the actor is stopped\n cancel: () => {\n actor.stop();\n actorSubscription.unsubscribe();\n handleActorSnapshot(actor.getSnapshot());\n },\n };\n }\n\n private _exhaustiveMatchingGuard(status: never): never {\n console.log(\"_exhaustiveMatchingGuard status\", status);\n throw new Error(`Unhandled status: ${status}`);\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAKO,kBAQPC,EAGO,sDAGPC,EAAkC,yDA0D3B,MAAeL,CAOtB,CACW,MACA,QAAmB,GAClB,OACA,cASV,YAAYM,EAKT,CACD,KAAK,MAAQA,EAAK,MAClB,KAAK,QAAU,EAAQA,EAAK,QAC5B,KAAK,OAASA,EAAK,OACnB,KAAK,cAAgBA,EAAK,aAC5B,CAOU,iBACRC,EACyC,CACzC,OAAO,KAAK,eAAiBA,EAAY,eAAiB,mBAC5D,CAYA,SACEA,EACiE,CACjE,MAAMC,EAAe,KAAK,iBAAiBD,CAAW,EAItD,MAAI,CAAC,KAAK,QAAUC,EAAa,KAC/B,KAAK,OAAS,KAAK,iBAAiBD,CAAW,EAAEC,EAAa,EAAE,GAG3D,KAAK,yBAAyBA,CAAY,CACnD,CAEU,yBACRA,EAOiE,CACjE,MAAMC,KAAQ,eAAYD,EAAc,CACtC,MAAO,KAAK,KAGd,CAAC,EAQKE,EAAU,IAAI,gBAIpB,IAAIC,EAAiB,GAErB,MAAMC,EACJC,GACG,CACH,KAAM,CAAE,QAAAC,EAAS,OAAAC,EAAQ,OAAAC,EAAQ,MAAAC,CAAM,EAAIJ,EAW3C,GARI,KAAK,QAAU,CAACF,IAClBA,EAAiB,GACjB,KAAK,OAAO,MAAM,6BAA8B,CAC9C,KAAM,CAAE,MAAOG,EAAQ,KAAM,CAC/B,CAAC,GAIC,KAAK,QAAUC,IAAW,SAAU,CACtC,MAAMG,EACJ,OAAOL,EAAS,OAAU,SACtBA,EAAS,MACT,KAAK,UAAUA,EAAS,KAAK,EACnC,KAAK,OAAO,MAAM,+BAA+BK,CAAU,GAAI,CAC7D,KAAM,CAAE,cAAeJ,EAAQ,cAAe,CAChD,CAAC,CACH,CAEA,OAAQC,EAAQ,CACd,IAAK,SACHL,EAAQ,KAAK,CACX,OAAQ,qBAAmB,QAC3B,kBAAmBI,EAAQ,iBAC7B,CAAC,EACD,MACF,IAAK,OACHE,EAAO,OAAO,CACZ,KAAOG,GAAQ,CACbT,EAAQ,KAAK,CACX,OAAQ,qBAAmB,MAC3B,MAAOS,CACT,CAAC,CACH,EACA,MAAQC,GAAW,CACjBV,EAAQ,KAAK,CACX,OAAQ,qBAAmB,UAC3B,OAAQU,CACV,CAAC,CACH,CACF,CAAC,EACDV,EAAQ,SAAS,EACjB,MACF,IAAK,QAEHA,EAAQ,MAAMO,CAAK,EACnBP,EAAQ,SAAS,EACjB,MACF,IAAK,UACHA,EAAQ,KAAK,CACX,OAAQ,qBAAmB,OAC7B,CAAC,EACDA,EAAQ,SAAS,EACjB,MACF,QACE,KAAK,yBAAyBK,CAAM,CACxC,CACF,EAEMM,EAAa,IAAI,aAEpBC,GAAe,CAChB,MAAMC,EAAsBb,EAAQ,UAAUY,CAAU,EACxD,MAAO,IAAM,CACXE,EAAkB,YAAY,EAC9BD,EAAoB,YAAY,EAChCd,EAAM,KAAK,CACb,CACF,CAAC,EAEKe,EAAoBf,EAAM,UAAUG,CAAmB,EAC7D,OAAAH,EAAM,MAAM,EAEL,CACL,WAAYY,EAAW,QAAK,SAAM,CAAC,EACnC,OAAQ,IAAM,CACZZ,EAAM,KAAK,EACXe,EAAkB,YAAY,EAC9BZ,EAAoBH,EAAM,YAAY,CAAC,CACzC,CACF,CACF,CAEQ,yBAAyBM,EAAsB,CACrD,cAAQ,IAAI,kCAAmCA,CAAM,EAC/C,IAAI,MAAM,qBAAqBA,CAAM,EAAE,CAC/C,CACF",
6
+ "names": ["XStateDeviceAction_exports", "__export", "XStateDeviceAction", "__toCommonJS", "import_rxjs", "import_xstate", "import_DeviceActionState", "import_noopLoggerFactory", "args", "internalApi", "stateMachine", "actor", "subject", "hasLoggedInput", "handleActorSnapshot", "snapshot", "context", "status", "output", "error", "stateValue", "err", "result", "observable", "subscriber", "subjectSubscription", "actorSubscription"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var u=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var le=Object.prototype.hasOwnProperty;var ue=(p,o)=>{for(var i in o)u(p,i,{get:o[i],enumerable:!0})},l=(p,o,i,v)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of De(o))!le.call(p,s)&&s!==i&&u(p,s,{get:()=>o[s],enumerable:!(v=Ae(o,s))||v.enumerable});return p},r=(p,o,i)=>(l(p,o,"default"),i&&l(i,o,"default"));var ve=p=>l(u({},"__esModule",{value:!0}),p);var e={};ue(e,{APDU_MAX_PAYLOAD:()=>f.APDU_MAX_PAYLOAD,Apdu:()=>S.Apdu,ApduBuilder:()=>f.ApduBuilder,ApduParser:()=>y.ApduParser,ApduResponse:()=>j.ApduResponse,AppAlreadyInstalledDAError:()=>t.AppAlreadyInstalledDAError,BatteryStatusType:()=>x.BatteryStatusType,BleDeviceInfos:()=>N.BleDeviceInfos,ByteArrayBuilder:()=>C.ByteArrayBuilder,ByteArrayParser:()=>g.ByteArrayParser,CallTaskInAppDeviceAction:()=>U.CallTaskInAppDeviceAction,CloseAppCommand:()=>L.CloseAppCommand,CommandResultFactory:()=>m.CommandResultFactory,CommandResultStatus:()=>m.CommandResultStatus,CommandUtils:()=>O.CommandUtils,ConnectedDevice:()=>fe.ConnectedDevice,ConsoleLogger:()=>ne.ConsoleLogger,DefaultLogTagFormatter:()=>ae.DefaultLogTagFormatter,DeviceActionStatus:()=>b.DeviceActionStatus,DeviceConnectionStateMachine:()=>ce.DeviceConnectionStateMachine,DeviceLockedError:()=>t.DeviceLockedError,DeviceManagementKit:()=>pe.DeviceManagementKit,DeviceManagementKitBuilder:()=>ie.DeviceManagementKitBuilder,DeviceModel:()=>n.DeviceModel,DeviceModelId:()=>n.DeviceModelId,DeviceSessionStateType:()=>z.DeviceSessionStateType,DeviceStatus:()=>T.DeviceStatus,FramerUtils:()=>te.FramerUtils,GenuineCheckDeviceAction:()=>J.GenuineCheckDeviceAction,GetAppAndVersionCommand:()=>E.GetAppAndVersionCommand,GetBatteryStatusCommand:()=>x.GetBatteryStatusCommand,GetDeviceMetadataDeviceAction:()=>F.GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction:()=>P.GetDeviceStatusDeviceAction,GetOsVersionCommand:()=>B.GetOsVersionCommand,GlobalCommandError:()=>d.GlobalCommandError,GlobalCommandErrorHandler:()=>d.GlobalCommandErrorHandler,GoToDashboardDeviceAction:()=>V.GoToDashboardDeviceAction,InstallAppDeviceAction:()=>Q.InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction:()=>k.InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError:()=>c.InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError:()=>c.InvalidStatusWordError,LEDGER_VENDOR_ID:()=>n.LEDGER_VENDOR_ID,ListAppsCommand:()=>G.ListAppsCommand,ListAppsDeviceAction:()=>W.ListAppsDeviceAction,ListAppsWithMetadataDeviceAction:()=>_.ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction:()=>Z.ListInstalledAppsDeviceAction,LoadCertificateCommand:()=>R.LoadCertificateCommand,LogLevel:()=>me.LogLevel,OpenAppCommand:()=>M.OpenAppCommand,OpenAppDeviceAction:()=>w.OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction:()=>H.OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError:()=>t.OutOfMemoryDAError,RefusedByUserDAError:()=>t.RefusedByUserDAError,SecureChannelError:()=>ee.SecureChannelError,SendCommandInAppDeviceAction:()=>K.SendCommandInAppDeviceAction,StaticDeviceModelDataSource:()=>q.StaticDeviceModelDataSource,TransportConnectedDevice:()=>xe.TransportConnectedDevice,TransportDeviceModel:()=>Y.TransportDeviceModel,UninstallAppDeviceAction:()=>$.UninstallAppDeviceAction,UnknownDAError:()=>t.UnknownDAError,UnsupportedFirmwareDAError:()=>t.UnsupportedFirmwareDAError,UserInteractionRequired:()=>h.UserInteractionRequired,WebLogsExporterLogger:()=>se.WebLogsExporterLogger,XStateDeviceAction:()=>X.XStateDeviceAction,base64StringToBuffer:()=>D.base64StringToBuffer,bufferToHexaString:()=>a.bufferToHexaString,connectedDeviceStubBuilder:()=>de.connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder:()=>re.defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder:()=>oe.defaultApduSenderServiceStubBuilder,formatApduReceivedLog:()=>A.formatApduReceivedLog,formatApduSentLog:()=>A.formatApduSentLog,hexaStringToBuffer:()=>a.hexaStringToBuffer,isBase64String:()=>D.isBase64String,isCommandErrorCode:()=>I.isCommandErrorCode,isHexaString:()=>a.isHexaString,isSuccessCommandResult:()=>m.isSuccessCommandResult});module.exports=ve(e);var S=require("./apdu/model/Apdu"),f=require("./apdu/utils/ApduBuilder"),y=require("./apdu/utils/ApduParser");r(e,require("./apdu/utils/AppBuilderError"),module.exports);var C=require("./apdu/utils/ByteArrayBuilder"),g=require("./apdu/utils/ByteArrayParser"),c=require("./command/Errors"),m=require("./command/model/CommandResult"),L=require("./command/os/CloseAppCommand"),E=require("./command/os/GetAppAndVersionCommand"),x=require("./command/os/GetBatteryStatusCommand"),B=require("./command/os/GetOsVersionCommand"),G=require("./command/os/ListAppsCommand"),R=require("./command/os/LoadCertificateCommand"),M=require("./command/os/OpenAppCommand"),I=require("./command/utils/CommandErrors"),O=require("./command/utils/CommandUtils"),d=require("./command/utils/GlobalCommandError"),n=require("./device/DeviceModel"),T=require("./device/DeviceStatus"),b=require("./device-action/model/DeviceActionState"),h=require("./device-action/model/UserInteractionRequired"),U=require("./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction"),t=require("./device-action/os/Errors"),F=require("./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),P=require("./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),V=require("./device-action/os/GoToDashboard/GoToDashboardDeviceAction"),k=require("./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),W=require("./device-action/os/ListApps/ListAppsDeviceAction"),_=require("./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction"),w=require("./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),H=require("./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction"),K=require("./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction"),X=require("./device-action/xstate-utils/XStateDeviceAction"),q=require("./device-model/data/StaticDeviceModelDataSource"),N=require("./device-model/model/BleDeviceInfos"),Y=require("./device-model/model/DeviceModel"),j=require("./device-session/ApduResponse");r(e,require("./device-session/data/FramerConst"),module.exports);var z=require("./device-session/DeviceSessionState"),J=require("./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction"),Q=require("./secure-channel/device-action/InstallApp/InstallAppDeviceAction"),Z=require("./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction"),$=require("./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction"),ee=require("../internal/secure-channel/model/Errors"),re=require("./device-session/service/DefaultApduReceiverService.stub"),oe=require("./device-session/service/DefaultApduSenderService.stub"),te=require("./device-session/utils/FramerUtils"),pe=require("./DeviceManagementKit"),ie=require("./DeviceManagementKitBuilder");r(e,require("./Error"),module.exports);var me=require("./logger-subscriber/model/LogLevel"),ne=require("./logger-subscriber/service/ConsoleLogger"),ae=require("./logger-subscriber/service/DefaultLogTagFormatter"),se=require("./logger-subscriber/service/WebLogsExporterLogger"),fe=require("./transport/model/ConnectedDevice"),ce=require("./transport/model/DeviceConnectionStateMachine");r(e,require("./transport/model/Errors"),module.exports);var xe=require("./transport/model/TransportConnectedDevice"),de=require("./transport/model/TransportConnectedDevice.stub");r(e,require("./types"),module.exports);var A=require("./utils/apduLogs"),D=require("./utils/Base64String"),a=require("./utils/HexaString");0&&(module.exports={APDU_MAX_PAYLOAD,Apdu,ApduBuilder,ApduParser,ApduResponse,AppAlreadyInstalledDAError,BatteryStatusType,BleDeviceInfos,ByteArrayBuilder,ByteArrayParser,CallTaskInAppDeviceAction,CloseAppCommand,CommandResultFactory,CommandResultStatus,CommandUtils,ConnectedDevice,ConsoleLogger,DefaultLogTagFormatter,DeviceActionStatus,DeviceConnectionStateMachine,DeviceLockedError,DeviceManagementKit,DeviceManagementKitBuilder,DeviceModel,DeviceModelId,DeviceSessionStateType,DeviceStatus,FramerUtils,GenuineCheckDeviceAction,GetAppAndVersionCommand,GetBatteryStatusCommand,GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction,GetOsVersionCommand,GlobalCommandError,GlobalCommandErrorHandler,GoToDashboardDeviceAction,InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError,LEDGER_VENDOR_ID,ListAppsCommand,ListAppsDeviceAction,ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction,LoadCertificateCommand,LogLevel,OpenAppCommand,OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError,RefusedByUserDAError,SecureChannelError,SendCommandInAppDeviceAction,StaticDeviceModelDataSource,TransportConnectedDevice,TransportDeviceModel,UninstallAppDeviceAction,UnknownDAError,UnsupportedFirmwareDAError,UserInteractionRequired,WebLogsExporterLogger,XStateDeviceAction,base64StringToBuffer,bufferToHexaString,connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder,formatApduReceivedLog,formatApduSentLog,hexaStringToBuffer,isBase64String,isCommandErrorCode,isHexaString,isSuccessCommandResult,...require("./apdu/utils/AppBuilderError"),...require("./device-session/data/FramerConst"),...require("./Error"),...require("./transport/model/Errors"),...require("./types")});
1
+ "use strict";var S=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var ge=(p,t)=>{for(var a in t)S(p,a,{get:t[a],enumerable:!0})},v=(p,t,a,g)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of ve(t))!Se.call(p,c)&&c!==a&&S(p,c,{get:()=>t[c],enumerable:!(g=le(t,c))||g.enumerable});return p},o=(p,t,a)=>(v(p,t,"default"),a&&v(a,t,"default"));var ye=p=>v(S({},"__esModule",{value:!0}),p);var e={};ge(e,{APDU_MAX_PAYLOAD:()=>d.APDU_MAX_PAYLOAD,Apdu:()=>y.Apdu,ApduBuilder:()=>d.ApduBuilder,ApduParser:()=>C.ApduParser,ApduResponse:()=>Q.ApduResponse,AppAlreadyInstalledDAError:()=>r.AppAlreadyInstalledDAError,BatteryStatusType:()=>A.BatteryStatusType,BleDeviceInfos:()=>j.BleDeviceInfos,ByteArrayBuilder:()=>G.ByteArrayBuilder,ByteArrayParser:()=>L.ByteArrayParser,CallTaskInAppDeviceAction:()=>F.CallTaskInAppDeviceAction,CloseAppCommand:()=>E.CloseAppCommand,CommandResultFactory:()=>i.CommandResultFactory,CommandResultStatus:()=>i.CommandResultStatus,CommandUtils:()=>h.CommandUtils,ConnectedDevice:()=>xe.ConnectedDevice,ConsoleLogger:()=>ce.ConsoleLogger,DEFAULT_UNLOCK_TIMEOUT_MS:()=>_.DEFAULT_UNLOCK_TIMEOUT_MS,DefaultLogTagFormatter:()=>de.DefaultLogTagFormatter,DeviceActionStatus:()=>U.DeviceActionStatus,DeviceConnectionStateMachine:()=>Ae.DeviceConnectionStateMachine,DeviceLockedError:()=>r.DeviceLockedError,DeviceManagementKit:()=>me.DeviceManagementKit,DeviceManagementKitBuilder:()=>ne.DeviceManagementKitBuilder,DeviceModel:()=>n.DeviceModel,DeviceModelId:()=>n.DeviceModelId,DeviceNotOnboardedError:()=>r.DeviceNotOnboardedError,DeviceSessionStateType:()=>Z.DeviceSessionStateType,DeviceStatus:()=>M.DeviceStatus,FramerUtils:()=>ie.FramerUtils,GLOBAL_ERRORS:()=>m.GLOBAL_ERRORS,GenuineCheckDeviceAction:()=>$.GenuineCheckDeviceAction,GetAppAndVersionCommand:()=>B.GetAppAndVersionCommand,GetBackgroundImageSizeCommand:()=>x.GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError:()=>x.GetBackgroundImageSizeCommandError,GetBatteryStatusCommand:()=>A.GetBatteryStatusCommand,GetDeviceMetadataDeviceAction:()=>V.GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction:()=>z.GetDeviceStatusDeviceAction,GetOsVersionCommand:()=>I.GetOsVersionCommand,GlobalCommandError:()=>m.GlobalCommandError,GlobalCommandErrorHandler:()=>m.GlobalCommandErrorHandler,GoToDashboardDeviceAction:()=>P.GoToDashboardDeviceAction,InstallAppDeviceAction:()=>ee.InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction:()=>W.InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError:()=>f.InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError:()=>f.InvalidStatusWordError,LEDGER_VENDOR_ID:()=>n.LEDGER_VENDOR_ID,ListAppsCommand:()=>R.ListAppsCommand,ListAppsDeviceAction:()=>w.ListAppsDeviceAction,ListAppsWithMetadataDeviceAction:()=>H.ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction:()=>oe.ListInstalledAppsDeviceAction,LoadCertificateCommand:()=>T.LoadCertificateCommand,LogLevel:()=>se.LogLevel,OpenAppCommand:()=>b.OpenAppCommand,OpenAppDeviceAction:()=>K.OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction:()=>N.OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError:()=>r.OutOfMemoryDAError,RefusedByUserDAError:()=>r.RefusedByUserDAError,SecureChannelError:()=>te.SecureChannelError,SendCommandInAppDeviceAction:()=>q.SendCommandInAppDeviceAction,StaticDeviceModelDataSource:()=>Y.StaticDeviceModelDataSource,TransportConnectedDevice:()=>De.TransportConnectedDevice,TransportDeviceModel:()=>J.TransportDeviceModel,UninstallAppDeviceAction:()=>re.UninstallAppDeviceAction,UnknownDAError:()=>r.UnknownDAError,UnsupportedFirmwareDAError:()=>r.UnsupportedFirmwareDAError,UserInteractionRequired:()=>k.UserInteractionRequired,WebLogsExporterLogger:()=>fe.WebLogsExporterLogger,XStateDeviceAction:()=>X.XStateDeviceAction,base64StringToBuffer:()=>l.base64StringToBuffer,bufferToHexaString:()=>s.bufferToHexaString,connectedDeviceStubBuilder:()=>ue.connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder:()=>pe.defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder:()=>ae.defaultApduSenderServiceStubBuilder,formatApduReceivedLog:()=>u.formatApduReceivedLog,formatApduSentLog:()=>u.formatApduSentLog,hexaStringToBuffer:()=>s.hexaStringToBuffer,isBase64String:()=>l.isBase64String,isCommandErrorCode:()=>O.isCommandErrorCode,isHexaString:()=>s.isHexaString,isSuccessCommandResult:()=>i.isSuccessCommandResult,noopLogger:()=>D.noopLogger,noopLoggerFactory:()=>D.noopLoggerFactory});module.exports=ye(e);var y=require("./apdu/model/Apdu"),d=require("./apdu/utils/ApduBuilder"),C=require("./apdu/utils/ApduParser");o(e,require("./apdu/utils/AppBuilderError"),module.exports);var G=require("./apdu/utils/ByteArrayBuilder"),L=require("./apdu/utils/ByteArrayParser"),f=require("./command/Errors"),i=require("./command/model/CommandResult"),E=require("./command/os/CloseAppCommand"),B=require("./command/os/GetAppAndVersionCommand"),x=require("./command/os/GetBackgroundImageSizeCommand"),A=require("./command/os/GetBatteryStatusCommand"),I=require("./command/os/GetOsVersionCommand"),R=require("./command/os/ListAppsCommand"),T=require("./command/os/LoadCertificateCommand"),b=require("./command/os/OpenAppCommand"),O=require("./command/utils/CommandErrors"),h=require("./command/utils/CommandUtils"),m=require("./command/utils/GlobalCommandError"),n=require("./device/DeviceModel"),M=require("./device/DeviceStatus"),U=require("./device-action/model/DeviceActionState"),k=require("./device-action/model/UserInteractionRequired"),F=require("./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction"),_=require("./device-action/os/Const"),r=require("./device-action/os/Errors"),V=require("./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),z=require("./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),P=require("./device-action/os/GoToDashboard/GoToDashboardDeviceAction"),W=require("./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),w=require("./device-action/os/ListApps/ListAppsDeviceAction"),H=require("./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction"),K=require("./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),N=require("./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction"),q=require("./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction"),X=require("./device-action/xstate-utils/XStateDeviceAction"),Y=require("./device-model/data/StaticDeviceModelDataSource"),j=require("./device-model/model/BleDeviceInfos"),J=require("./device-model/model/DeviceModel"),Q=require("./device-session/ApduResponse");o(e,require("./device-session/data/FramerConst"),module.exports);var Z=require("./device-session/DeviceSessionState"),$=require("./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction"),ee=require("./secure-channel/device-action/InstallApp/InstallAppDeviceAction"),oe=require("./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction"),re=require("./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction"),te=require("../internal/secure-channel/model/Errors"),pe=require("./device-session/service/DefaultApduReceiverService.stub"),ae=require("./device-session/service/DefaultApduSenderService.stub"),ie=require("./device-session/utils/FramerUtils"),me=require("./DeviceManagementKit"),ne=require("./DeviceManagementKitBuilder");o(e,require("./Error"),module.exports);var D=require("./logger-publisher/utils/noopLoggerFactory"),se=require("./logger-subscriber/model/LogLevel"),ce=require("./logger-subscriber/service/ConsoleLogger"),de=require("./logger-subscriber/service/DefaultLogTagFormatter"),fe=require("./logger-subscriber/service/WebLogsExporterLogger"),xe=require("./transport/model/ConnectedDevice"),Ae=require("./transport/model/DeviceConnectionStateMachine");o(e,require("./transport/model/Errors"),module.exports);var De=require("./transport/model/TransportConnectedDevice"),ue=require("./transport/model/TransportConnectedDevice.stub");o(e,require("./types"),module.exports);var u=require("./utils/apduLogs"),l=require("./utils/Base64String"),s=require("./utils/HexaString");0&&(module.exports={APDU_MAX_PAYLOAD,Apdu,ApduBuilder,ApduParser,ApduResponse,AppAlreadyInstalledDAError,BatteryStatusType,BleDeviceInfos,ByteArrayBuilder,ByteArrayParser,CallTaskInAppDeviceAction,CloseAppCommand,CommandResultFactory,CommandResultStatus,CommandUtils,ConnectedDevice,ConsoleLogger,DEFAULT_UNLOCK_TIMEOUT_MS,DefaultLogTagFormatter,DeviceActionStatus,DeviceConnectionStateMachine,DeviceLockedError,DeviceManagementKit,DeviceManagementKitBuilder,DeviceModel,DeviceModelId,DeviceNotOnboardedError,DeviceSessionStateType,DeviceStatus,FramerUtils,GLOBAL_ERRORS,GenuineCheckDeviceAction,GetAppAndVersionCommand,GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError,GetBatteryStatusCommand,GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction,GetOsVersionCommand,GlobalCommandError,GlobalCommandErrorHandler,GoToDashboardDeviceAction,InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError,LEDGER_VENDOR_ID,ListAppsCommand,ListAppsDeviceAction,ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction,LoadCertificateCommand,LogLevel,OpenAppCommand,OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError,RefusedByUserDAError,SecureChannelError,SendCommandInAppDeviceAction,StaticDeviceModelDataSource,TransportConnectedDevice,TransportDeviceModel,UninstallAppDeviceAction,UnknownDAError,UnsupportedFirmwareDAError,UserInteractionRequired,WebLogsExporterLogger,XStateDeviceAction,base64StringToBuffer,bufferToHexaString,connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder,formatApduReceivedLog,formatApduSentLog,hexaStringToBuffer,isBase64String,isCommandErrorCode,isHexaString,isSuccessCommandResult,noopLogger,noopLoggerFactory,...require("./apdu/utils/AppBuilderError"),...require("./device-session/data/FramerConst"),...require("./Error"),...require("./transport/model/Errors"),...require("./types")});
2
2
  //# sourceMappingURL=index.js.map