@ledgerhq/device-management-kit 0.0.0-develop-20250106155719 → 0.0.0-rnble-transport-20250219100517

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 (521) hide show
  1. package/README.md +27 -31
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/package.json +12 -8
  4. package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
  5. package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
  6. package/lib/cjs/src/api/DeviceManagementKitBuilder.js +1 -1
  7. package/lib/cjs/src/api/DeviceManagementKitBuilder.js.map +2 -2
  8. package/lib/cjs/src/api/DeviceManagementKitBuilder.test.js +1 -1
  9. package/lib/cjs/src/api/DeviceManagementKitBuilder.test.js.map +2 -2
  10. package/lib/cjs/src/api/DmkConfig.js +1 -1
  11. package/lib/cjs/src/api/DmkConfig.js.map +1 -1
  12. package/lib/cjs/src/api/apdu/utils/ByteArrayParser.test.js +1 -1
  13. package/lib/cjs/src/api/apdu/utils/ByteArrayParser.test.js.map +2 -2
  14. package/lib/cjs/src/api/command/model/CommandResult.js.map +1 -1
  15. package/lib/cjs/src/api/command/os/LoadCertificateCommand.js +2 -0
  16. package/lib/cjs/src/api/command/os/LoadCertificateCommand.js.map +7 -0
  17. package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js +2 -0
  18. package/lib/cjs/src/api/command/os/LoadCertificateCommand.test.js.map +7 -0
  19. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  20. package/lib/cjs/src/api/command/use-case/SendCommandUseCase.test.js.map +3 -3
  21. package/lib/cjs/src/api/command/utils/CommandUtils.js +1 -1
  22. package/lib/cjs/src/api/command/utils/CommandUtils.js.map +3 -3
  23. package/lib/cjs/src/api/command/utils/CommandUtils.test.js +1 -1
  24. package/lib/cjs/src/api/command/utils/CommandUtils.test.js.map +3 -3
  25. package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
  26. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  27. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  28. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  29. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  30. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +2 -2
  31. package/lib/cjs/src/api/device-action/__test-utils__/testDeviceActionStates.js +1 -1
  32. package/lib/cjs/src/api/device-action/__test-utils__/testDeviceActionStates.js.map +3 -3
  33. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +2 -0
  34. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +7 -0
  35. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +2 -0
  36. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +7 -0
  37. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +2 -0
  38. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +7 -0
  39. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  40. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  41. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  42. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  43. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
  44. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
  45. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  46. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +2 -2
  47. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  48. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  49. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  50. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
  51. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  52. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  53. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
  54. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
  55. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  56. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  57. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  58. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
  59. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
  60. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +1 -1
  61. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  62. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  63. package/lib/cjs/src/api/device-session/DeviceSessionState.js +1 -1
  64. package/lib/cjs/src/api/device-session/DeviceSessionState.js.map +2 -2
  65. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +1 -1
  66. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +3 -3
  67. package/lib/cjs/src/api/index.js +1 -1
  68. package/lib/cjs/src/api/index.js.map +3 -3
  69. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
  70. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
  71. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  72. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
  73. package/lib/cjs/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js +1 -1
  74. package/lib/cjs/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js.map +2 -2
  75. package/lib/cjs/src/api/transport/model/DeviceApduSender.js +2 -0
  76. package/lib/cjs/src/api/transport/model/DeviceApduSender.js.map +7 -0
  77. package/lib/cjs/src/api/transport/model/DeviceConnectionFactory.stub.js +1 -1
  78. package/lib/cjs/src/api/transport/model/DeviceConnectionFactory.stub.js.map +2 -2
  79. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +2 -0
  80. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +7 -0
  81. package/lib/cjs/src/api/transport/model/DiscoveredDevice.js +1 -1
  82. package/lib/cjs/src/api/transport/model/DiscoveredDevice.js.map +1 -1
  83. package/lib/cjs/src/api/transport/model/Errors.js +1 -1
  84. package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
  85. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.stub.js +1 -1
  86. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.stub.js.map +2 -2
  87. package/lib/cjs/src/api/transport/model/TransportDiscoveredDevice.js +1 -1
  88. package/lib/cjs/src/api/transport/model/TransportDiscoveredDevice.js.map +1 -1
  89. package/lib/cjs/src/api/transport/model/__mocks__/TransportMock.js +1 -1
  90. package/lib/cjs/src/api/transport/model/__mocks__/TransportMock.js.map +2 -2
  91. package/lib/cjs/src/api/types.js.map +1 -1
  92. package/lib/cjs/src/api/utils/Base64String.test.js +1 -1
  93. package/lib/cjs/src/api/utils/Base64String.test.js.map +2 -2
  94. package/lib/cjs/src/api/utils/HexaString.js +1 -1
  95. package/lib/cjs/src/api/utils/HexaString.js.map +2 -2
  96. package/lib/cjs/src/api/utils/HexaString.test.js +1 -1
  97. package/lib/cjs/src/api/utils/HexaString.test.js.map +2 -2
  98. package/lib/cjs/src/di.js +1 -1
  99. package/lib/cjs/src/di.js.map +3 -3
  100. package/lib/cjs/src/di.stub.js +1 -1
  101. package/lib/cjs/src/di.stub.js.map +2 -2
  102. package/lib/cjs/src/internal/config/data/LocalConfigDataSource.test.js +1 -1
  103. package/lib/cjs/src/internal/config/data/LocalConfigDataSource.test.js.map +3 -3
  104. package/lib/cjs/src/internal/config/data/RemoteConfigDataSource.test.js +1 -1
  105. package/lib/cjs/src/internal/config/data/RemoteConfigDataSource.test.js.map +2 -2
  106. package/lib/cjs/src/internal/config/data/__mocks__/LocalConfigDataSource.js +1 -1
  107. package/lib/cjs/src/internal/config/data/__mocks__/LocalConfigDataSource.js.map +2 -2
  108. package/lib/cjs/src/internal/config/data/__mocks__/RemoteConfigDataSource.js +1 -1
  109. package/lib/cjs/src/internal/config/data/__mocks__/RemoteConfigDataSource.js.map +2 -2
  110. package/lib/cjs/src/internal/config/service/DefaultConfigService.test.js +1 -1
  111. package/lib/cjs/src/internal/config/service/DefaultConfigService.test.js.map +2 -2
  112. package/lib/cjs/src/internal/config/use-case/GetDmkVersionUseCase.test.js +1 -1
  113. package/lib/cjs/src/internal/config/use-case/GetDmkVersionUseCase.test.js.map +2 -2
  114. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  115. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  116. package/lib/cjs/src/internal/device-session/model/DeviceSession.stub.js +1 -1
  117. package/lib/cjs/src/internal/device-session/model/DeviceSession.stub.js.map +3 -3
  118. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  119. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  120. package/lib/cjs/src/internal/device-session/service/DefaultApduReceiverService.test.js +1 -1
  121. package/lib/cjs/src/internal/device-session/service/DefaultApduReceiverService.test.js.map +2 -2
  122. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
  123. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
  124. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  125. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  126. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.js +1 -1
  127. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.js.map +3 -3
  128. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
  129. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +3 -3
  130. package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
  131. package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +3 -3
  132. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
  133. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  134. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  135. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  136. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  137. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  138. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
  139. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +3 -3
  140. package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
  141. package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +3 -3
  142. package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
  143. package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +3 -3
  144. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
  145. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +3 -3
  146. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js +1 -1
  147. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js.map +3 -3
  148. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js +1 -1
  149. package/lib/cjs/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js.map +3 -3
  150. package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.js +1 -1
  151. package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.js.map +2 -2
  152. package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js +1 -1
  153. package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js.map +3 -3
  154. package/lib/cjs/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js +1 -1
  155. package/lib/cjs/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js.map +2 -2
  156. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js +1 -1
  157. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js.map +2 -2
  158. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
  159. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +2 -2
  160. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
  161. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
  162. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
  163. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
  164. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
  165. package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
  166. package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
  167. package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js +1 -1
  168. package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
  169. package/lib/cjs/src/internal/manager-api/model/Firmware.js +1 -1
  170. package/lib/cjs/src/internal/manager-api/model/Firmware.js.map +1 -1
  171. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
  172. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js.map +2 -2
  173. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  174. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  175. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +2 -0
  176. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +7 -0
  177. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js +2 -0
  178. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js.map +7 -0
  179. package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js +2 -0
  180. package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js.map +7 -0
  181. package/lib/cjs/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js +2 -0
  182. package/lib/cjs/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js.map +7 -0
  183. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js +2 -0
  184. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js.map +7 -0
  185. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js +2 -0
  186. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js.map +7 -0
  187. package/lib/cjs/src/internal/secure-channel/di/secureChannelTypes.js +2 -0
  188. package/lib/cjs/src/internal/secure-channel/di/secureChannelTypes.js.map +7 -0
  189. package/lib/cjs/src/internal/secure-channel/model/Const.js +2 -0
  190. package/lib/cjs/src/internal/secure-channel/model/Const.js.map +7 -0
  191. package/lib/cjs/src/internal/secure-channel/model/Errors.js +2 -0
  192. package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +7 -0
  193. package/lib/cjs/src/internal/secure-channel/model/Params.js +2 -0
  194. package/lib/cjs/src/internal/secure-channel/model/Params.js.map +7 -0
  195. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js +2 -0
  196. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +7 -0
  197. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.test.js +2 -0
  198. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.test.js.map +7 -0
  199. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js +2 -0
  200. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js.map +7 -0
  201. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  202. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  203. package/lib/cjs/src/internal/transport/di/transportModule.test.js +1 -1
  204. package/lib/cjs/src/internal/transport/di/transportModule.test.js.map +2 -2
  205. package/lib/cjs/src/internal/transport/service/DefaultTransportService.js +1 -1
  206. package/lib/cjs/src/internal/transport/service/DefaultTransportService.js.map +3 -3
  207. package/lib/cjs/src/internal/transport/service/DefaultTransportService.test.js +1 -1
  208. package/lib/cjs/src/internal/transport/service/DefaultTransportService.test.js.map +2 -2
  209. package/lib/cjs/src/internal/transport/service/TransportService.js +1 -1
  210. package/lib/cjs/src/internal/transport/service/TransportService.js.map +1 -1
  211. package/lib/cjs/src/internal/transport/service/__mocks__/DefaultTransportService.js +1 -1
  212. package/lib/cjs/src/internal/transport/service/__mocks__/DefaultTransportService.js.map +2 -2
  213. package/lib/esm/package.json +12 -8
  214. package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
  215. package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
  216. package/lib/esm/src/api/DeviceManagementKitBuilder.js +1 -1
  217. package/lib/esm/src/api/DeviceManagementKitBuilder.js.map +3 -3
  218. package/lib/esm/src/api/DeviceManagementKitBuilder.test.js +1 -1
  219. package/lib/esm/src/api/DeviceManagementKitBuilder.test.js.map +2 -2
  220. package/lib/esm/src/api/apdu/utils/ByteArrayParser.test.js +1 -1
  221. package/lib/esm/src/api/apdu/utils/ByteArrayParser.test.js.map +2 -2
  222. package/lib/esm/src/api/command/model/CommandResult.js.map +1 -1
  223. package/lib/esm/src/api/command/os/LoadCertificateCommand.js +2 -0
  224. package/lib/esm/src/api/command/os/LoadCertificateCommand.js.map +7 -0
  225. package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js +2 -0
  226. package/lib/esm/src/api/command/os/LoadCertificateCommand.test.js.map +7 -0
  227. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  228. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +3 -3
  229. package/lib/esm/src/api/command/utils/CommandUtils.js +1 -1
  230. package/lib/esm/src/api/command/utils/CommandUtils.js.map +3 -3
  231. package/lib/esm/src/api/command/utils/CommandUtils.test.js +1 -1
  232. package/lib/esm/src/api/command/utils/CommandUtils.test.js.map +3 -3
  233. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  234. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  235. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  236. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +2 -2
  237. package/lib/esm/src/api/device-action/__test-utils__/testDeviceActionStates.js +1 -1
  238. package/lib/esm/src/api/device-action/__test-utils__/testDeviceActionStates.js.map +3 -3
  239. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +2 -0
  240. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +7 -0
  241. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +2 -0
  242. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +7 -0
  243. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -0
  244. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +7 -0
  245. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  246. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  247. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  248. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  249. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
  250. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
  251. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  252. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +2 -2
  253. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  254. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  255. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  256. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +2 -2
  257. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  258. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  259. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  260. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  261. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  262. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
  263. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  264. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  265. package/lib/esm/src/api/device-session/DeviceSessionState.js.map +2 -2
  266. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +1 -1
  267. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +3 -3
  268. package/lib/esm/src/api/index.js +1 -1
  269. package/lib/esm/src/api/index.js.map +3 -3
  270. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
  271. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
  272. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  273. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
  274. package/lib/esm/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js +1 -1
  275. package/lib/esm/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.js.map +2 -2
  276. package/lib/esm/src/api/transport/model/DeviceApduSender.js +1 -0
  277. package/lib/esm/src/api/transport/model/DeviceApduSender.js.map +7 -0
  278. package/lib/esm/src/api/transport/model/DeviceConnectionFactory.stub.js +1 -1
  279. package/lib/esm/src/api/transport/model/DeviceConnectionFactory.stub.js.map +2 -2
  280. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +2 -0
  281. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +7 -0
  282. package/lib/esm/src/api/transport/model/Errors.js +1 -1
  283. package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
  284. package/lib/esm/src/api/transport/model/TransportConnectedDevice.stub.js +1 -1
  285. package/lib/esm/src/api/transport/model/TransportConnectedDevice.stub.js.map +2 -2
  286. package/lib/esm/src/api/transport/model/__mocks__/TransportMock.js +1 -1
  287. package/lib/esm/src/api/transport/model/__mocks__/TransportMock.js.map +2 -2
  288. package/lib/esm/src/api/utils/Base64String.test.js +1 -1
  289. package/lib/esm/src/api/utils/Base64String.test.js.map +2 -2
  290. package/lib/esm/src/api/utils/HexaString.js +1 -1
  291. package/lib/esm/src/api/utils/HexaString.js.map +2 -2
  292. package/lib/esm/src/api/utils/HexaString.test.js +1 -1
  293. package/lib/esm/src/api/utils/HexaString.test.js.map +2 -2
  294. package/lib/esm/src/di.js +1 -1
  295. package/lib/esm/src/di.js.map +3 -3
  296. package/lib/esm/src/di.stub.js +1 -1
  297. package/lib/esm/src/di.stub.js.map +2 -2
  298. package/lib/esm/src/internal/config/data/LocalConfigDataSource.test.js +1 -1
  299. package/lib/esm/src/internal/config/data/LocalConfigDataSource.test.js.map +3 -3
  300. package/lib/esm/src/internal/config/data/RemoteConfigDataSource.test.js +1 -1
  301. package/lib/esm/src/internal/config/data/RemoteConfigDataSource.test.js.map +2 -2
  302. package/lib/esm/src/internal/config/data/__mocks__/LocalConfigDataSource.js +1 -1
  303. package/lib/esm/src/internal/config/data/__mocks__/LocalConfigDataSource.js.map +2 -2
  304. package/lib/esm/src/internal/config/data/__mocks__/RemoteConfigDataSource.js +1 -1
  305. package/lib/esm/src/internal/config/data/__mocks__/RemoteConfigDataSource.js.map +2 -2
  306. package/lib/esm/src/internal/config/service/DefaultConfigService.test.js +1 -1
  307. package/lib/esm/src/internal/config/service/DefaultConfigService.test.js.map +2 -2
  308. package/lib/esm/src/internal/config/use-case/GetDmkVersionUseCase.test.js +1 -1
  309. package/lib/esm/src/internal/config/use-case/GetDmkVersionUseCase.test.js.map +2 -2
  310. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  311. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  312. package/lib/esm/src/internal/device-session/model/DeviceSession.stub.js +1 -1
  313. package/lib/esm/src/internal/device-session/model/DeviceSession.stub.js.map +3 -3
  314. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  315. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  316. package/lib/esm/src/internal/device-session/service/DefaultApduReceiverService.test.js +1 -1
  317. package/lib/esm/src/internal/device-session/service/DefaultApduReceiverService.test.js.map +2 -2
  318. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
  319. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
  320. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  321. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  322. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.js +1 -1
  323. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.js.map +3 -3
  324. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
  325. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +3 -3
  326. package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
  327. package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +3 -3
  328. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
  329. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +3 -3
  330. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  331. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  332. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  333. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  334. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
  335. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +3 -3
  336. package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
  337. package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +3 -3
  338. package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
  339. package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +3 -3
  340. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
  341. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +3 -3
  342. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js +1 -1
  343. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.js.map +3 -3
  344. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js +1 -1
  345. package/lib/esm/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.test.js.map +3 -3
  346. package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.js +1 -1
  347. package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.js.map +2 -2
  348. package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js +1 -1
  349. package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.test.js.map +3 -3
  350. package/lib/esm/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js +1 -1
  351. package/lib/esm/src/internal/discovery/use-case/StopDiscoveringUseCase.test.js.map +2 -2
  352. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js +1 -1
  353. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.js.map +2 -2
  354. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
  355. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +2 -2
  356. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
  357. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
  358. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
  359. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
  360. package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
  361. package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
  362. package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js +1 -1
  363. package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
  364. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
  365. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js.map +2 -2
  366. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  367. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  368. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +2 -0
  369. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +7 -0
  370. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js +2 -0
  371. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js.map +7 -0
  372. package/lib/esm/src/internal/secure-channel/data/SecureChannelDataSource.js +1 -0
  373. package/lib/esm/src/internal/secure-channel/data/SecureChannelDataSource.js.map +7 -0
  374. package/lib/esm/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js +2 -0
  375. package/lib/esm/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.js.map +7 -0
  376. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js +2 -0
  377. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js.map +7 -0
  378. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js +2 -0
  379. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js.map +7 -0
  380. package/lib/esm/src/internal/secure-channel/di/secureChannelTypes.js +2 -0
  381. package/lib/esm/src/internal/secure-channel/di/secureChannelTypes.js.map +7 -0
  382. package/lib/esm/src/internal/secure-channel/model/Const.js +2 -0
  383. package/lib/esm/src/internal/secure-channel/model/Const.js.map +7 -0
  384. package/lib/esm/src/internal/secure-channel/model/Errors.js +2 -0
  385. package/lib/esm/src/internal/secure-channel/model/Errors.js.map +7 -0
  386. package/lib/esm/src/internal/secure-channel/model/Params.js +1 -0
  387. package/lib/esm/src/internal/secure-channel/model/Params.js.map +7 -0
  388. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js +2 -0
  389. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +7 -0
  390. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.test.js +2 -0
  391. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.test.js.map +7 -0
  392. package/lib/esm/src/internal/secure-channel/service/SecureChannelService.js +1 -0
  393. package/lib/esm/src/internal/secure-channel/service/SecureChannelService.js.map +7 -0
  394. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  395. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  396. package/lib/esm/src/internal/transport/di/transportModule.test.js +1 -1
  397. package/lib/esm/src/internal/transport/di/transportModule.test.js.map +2 -2
  398. package/lib/esm/src/internal/transport/service/DefaultTransportService.js +1 -1
  399. package/lib/esm/src/internal/transport/service/DefaultTransportService.js.map +3 -3
  400. package/lib/esm/src/internal/transport/service/DefaultTransportService.test.js +1 -1
  401. package/lib/esm/src/internal/transport/service/DefaultTransportService.test.js.map +2 -2
  402. package/lib/esm/src/internal/transport/service/__mocks__/DefaultTransportService.js +1 -1
  403. package/lib/esm/src/internal/transport/service/__mocks__/DefaultTransportService.js.map +2 -2
  404. package/lib/types/src/api/DeviceManagementKit.d.ts +1 -1
  405. package/lib/types/src/api/DeviceManagementKitBuilder.d.ts.map +1 -1
  406. package/lib/types/src/api/DmkConfig.d.ts +1 -0
  407. package/lib/types/src/api/DmkConfig.d.ts.map +1 -1
  408. package/lib/types/src/api/command/model/CommandResult.d.ts +1 -2
  409. package/lib/types/src/api/command/model/CommandResult.d.ts.map +1 -1
  410. package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts +25 -0
  411. package/lib/types/src/api/command/os/LoadCertificateCommand.d.ts.map +1 -0
  412. package/lib/types/src/api/command/os/LoadCertificateCommand.test.d.ts +2 -0
  413. package/lib/types/src/api/command/os/LoadCertificateCommand.test.d.ts.map +1 -0
  414. package/lib/types/src/api/command/utils/CommandUtils.d.ts +1 -0
  415. package/lib/types/src/api/command/utils/CommandUtils.d.ts.map +1 -1
  416. package/lib/types/src/api/device-action/DeviceAction.d.ts +6 -1
  417. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  418. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts +2 -1
  419. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  420. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
  421. package/lib/types/src/api/device-action/__test-utils__/testDeviceActionStates.d.ts +5 -2
  422. package/lib/types/src/api/device-action/__test-utils__/testDeviceActionStates.d.ts.map +1 -1
  423. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts +40 -0
  424. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -0
  425. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.d.ts +2 -0
  426. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.d.ts.map +1 -0
  427. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +19 -0
  428. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -0
  429. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
  430. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
  431. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +1 -0
  432. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
  433. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
  434. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +1 -0
  435. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
  436. package/lib/types/src/api/device-session/DeviceSessionState.d.ts +5 -0
  437. package/lib/types/src/api/device-session/DeviceSessionState.d.ts.map +1 -1
  438. package/lib/types/src/api/index.d.ts +3 -0
  439. package/lib/types/src/api/index.d.ts.map +1 -1
  440. package/lib/types/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.d.ts +1 -1
  441. package/lib/types/src/api/logger-subscriber/service/__mocks__/ConsoleLogger.d.ts.map +1 -1
  442. package/lib/types/src/api/transport/model/DeviceApduSender.d.ts +17 -0
  443. package/lib/types/src/api/transport/model/DeviceApduSender.d.ts.map +1 -0
  444. package/lib/types/src/api/transport/model/DeviceConnectionFactory.stub.d.ts +1 -1
  445. package/lib/types/src/api/transport/model/DeviceConnectionFactory.stub.d.ts.map +1 -1
  446. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +60 -0
  447. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -0
  448. package/lib/types/src/api/transport/model/DiscoveredDevice.d.ts +2 -0
  449. package/lib/types/src/api/transport/model/DiscoveredDevice.d.ts.map +1 -1
  450. package/lib/types/src/api/transport/model/Errors.d.ts +41 -26
  451. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  452. package/lib/types/src/api/transport/model/TransportDiscoveredDevice.d.ts +2 -0
  453. package/lib/types/src/api/transport/model/TransportDiscoveredDevice.d.ts.map +1 -1
  454. package/lib/types/src/api/transport/model/__mocks__/TransportMock.d.ts +7 -7
  455. package/lib/types/src/api/transport/model/__mocks__/TransportMock.d.ts.map +1 -1
  456. package/lib/types/src/api/types.d.ts +2 -1
  457. package/lib/types/src/api/types.d.ts.map +1 -1
  458. package/lib/types/src/api/utils/HexaString.d.ts +1 -1
  459. package/lib/types/src/api/utils/HexaString.d.ts.map +1 -1
  460. package/lib/types/src/di.d.ts.map +1 -1
  461. package/lib/types/src/di.stub.d.ts +1 -1
  462. package/lib/types/src/di.stub.d.ts.map +1 -1
  463. package/lib/types/src/internal/config/data/__mocks__/LocalConfigDataSource.d.ts +1 -1
  464. package/lib/types/src/internal/config/data/__mocks__/LocalConfigDataSource.d.ts.map +1 -1
  465. package/lib/types/src/internal/config/data/__mocks__/RemoteConfigDataSource.d.ts +3 -3
  466. package/lib/types/src/internal/config/data/__mocks__/RemoteConfigDataSource.d.ts.map +1 -1
  467. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +10 -5
  468. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  469. package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts +2 -1
  470. package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts.map +1 -1
  471. package/lib/types/src/internal/device-session/use-case/CloseSessionsUseCase.d.ts +4 -2
  472. package/lib/types/src/internal/device-session/use-case/CloseSessionsUseCase.d.ts.map +1 -1
  473. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +3 -1
  474. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
  475. package/lib/types/src/internal/discovery/use-case/ListenToKnownDevicesUseCase.d.ts.map +1 -1
  476. package/lib/types/src/internal/discovery/use-case/StartDiscoveringUseCase.d.ts.map +1 -1
  477. package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.d.ts +5 -5
  478. package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.stub.d.ts.map +1 -1
  479. package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts +4 -3
  480. package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts.map +1 -1
  481. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +24 -0
  482. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts.map +1 -1
  483. package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts +3 -3
  484. package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts.map +1 -1
  485. package/lib/types/src/internal/manager-api/model/Firmware.d.ts +4 -0
  486. package/lib/types/src/internal/manager-api/model/Firmware.d.ts.map +1 -1
  487. package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts.map +1 -1
  488. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts +18 -0
  489. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts.map +1 -0
  490. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.d.ts +2 -0
  491. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.d.ts.map +1 -0
  492. package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts +52 -0
  493. package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts.map +1 -0
  494. package/lib/types/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.d.ts +10 -0
  495. package/lib/types/src/internal/secure-channel/data/__mocks__/DefaultSecureChannelDataSource.d.ts.map +1 -0
  496. package/lib/types/src/internal/secure-channel/di/secureChannelModule.d.ts +9 -0
  497. package/lib/types/src/internal/secure-channel/di/secureChannelModule.d.ts.map +1 -0
  498. package/lib/types/src/internal/secure-channel/di/secureChannelModule.test.d.ts +2 -0
  499. package/lib/types/src/internal/secure-channel/di/secureChannelModule.test.d.ts.map +1 -0
  500. package/lib/types/src/internal/secure-channel/di/secureChannelTypes.d.ts +6 -0
  501. package/lib/types/src/internal/secure-channel/di/secureChannelTypes.d.ts.map +1 -0
  502. package/lib/types/src/internal/secure-channel/model/Const.d.ts +2 -0
  503. package/lib/types/src/internal/secure-channel/model/Const.d.ts.map +1 -0
  504. package/lib/types/src/internal/secure-channel/model/Errors.d.ts +8 -0
  505. package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -0
  506. package/lib/types/src/internal/secure-channel/model/Params.d.ts +86 -0
  507. package/lib/types/src/internal/secure-channel/model/Params.d.ts.map +1 -0
  508. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts +21 -0
  509. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts.map +1 -0
  510. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.test.d.ts +2 -0
  511. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.test.d.ts.map +1 -0
  512. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts +21 -0
  513. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts.map +1 -0
  514. package/lib/types/src/internal/transport/service/DefaultTransportService.d.ts +2 -0
  515. package/lib/types/src/internal/transport/service/DefaultTransportService.d.ts.map +1 -1
  516. package/lib/types/src/internal/transport/service/TransportService.d.ts +2 -0
  517. package/lib/types/src/internal/transport/service/TransportService.d.ts.map +1 -1
  518. package/lib/types/src/internal/transport/service/__mocks__/DefaultTransportService.d.ts +7 -6
  519. package/lib/types/src/internal/transport/service/__mocks__/DefaultTransportService.d.ts.map +1 -1
  520. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  521. package/package.json +13 -9
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/model/CommandResult.ts"],
4
- "sourcesContent": ["import {\n type InvalidBatteryDataError,\n type InvalidBatteryStatusTypeError,\n type InvalidResponseFormatError,\n type InvalidStatusWordError,\n} from \"@api/command/Errors\";\nimport { type GlobalCommandErrorStatusCode } from \"@api/command/utils/GlobalCommandError\";\nimport {\n type DeviceExchangeError,\n type UnknownDeviceExchangeError,\n} from \"@api/Error\";\n\nexport enum CommandResultStatus {\n Error = \"ERROR\",\n Success = \"SUCCESS\",\n}\ntype CommandSuccessResult<Data> = {\n status: CommandResultStatus.Success;\n data: Data;\n};\nexport type CommandErrorResult<SpecificErrorCodes = void> = {\n error:\n | DeviceExchangeError<SpecificErrorCodes | GlobalCommandErrorStatusCode>\n | InvalidBatteryDataError\n | InvalidBatteryStatusTypeError\n | InvalidResponseFormatError\n | InvalidStatusWordError\n | UnknownDeviceExchangeError;\n status: CommandResultStatus.Error;\n};\nexport type CommandResult<Data, SpecificErrorCodes = void> =\n | CommandSuccessResult<Data>\n | CommandErrorResult<SpecificErrorCodes>;\n\nexport function CommandResultFactory<Data, SpecificErrorCodes = void>({\n data,\n error,\n}:\n | { data: Data; error?: undefined }\n | {\n data?: undefined;\n error:\n | DeviceExchangeError<SpecificErrorCodes>\n | InvalidBatteryDataError\n | InvalidBatteryStatusTypeError\n | InvalidResponseFormatError\n | InvalidStatusWordError\n | UnknownDeviceExchangeError;\n }): CommandResult<Data, SpecificErrorCodes> {\n if (error) {\n return {\n status: CommandResultStatus.Error,\n error,\n };\n }\n return {\n status: CommandResultStatus.Success,\n data,\n };\n}\n\nexport function isSuccessCommandResult<Data, StatusCode>(\n result: CommandResult<Data, StatusCode>,\n): result is CommandSuccessResult<Data> {\n return result.status === CommandResultStatus.Success;\n}\n"],
4
+ "sourcesContent": ["import {\n type InvalidBatteryDataError,\n type InvalidBatteryStatusTypeError,\n type InvalidResponseFormatError,\n type InvalidStatusWordError,\n} from \"@api/command/Errors\";\nimport { type GlobalCommandErrorStatusCode } from \"@api/command/utils/GlobalCommandError\";\nimport {\n type DeviceExchangeError,\n type UnknownDeviceExchangeError,\n} from \"@api/Error\";\n\nexport enum CommandResultStatus {\n Error = \"ERROR\",\n Success = \"SUCCESS\",\n}\nexport type CommandSuccessResult<Data> = {\n status: CommandResultStatus.Success;\n data: Data;\n};\nexport type CommandErrorResult<SpecificErrorCodes = void> = {\n error:\n | DeviceExchangeError<SpecificErrorCodes | GlobalCommandErrorStatusCode>\n | InvalidBatteryDataError\n | InvalidBatteryStatusTypeError\n | InvalidResponseFormatError\n | InvalidStatusWordError\n | UnknownDeviceExchangeError;\n status: CommandResultStatus.Error;\n};\nexport type CommandResult<Data, SpecificErrorCodes = void> =\n | CommandSuccessResult<Data>\n | CommandErrorResult<SpecificErrorCodes>;\n\nexport function CommandResultFactory<Data, SpecificErrorCodes = void>({\n data,\n error,\n}:\n | { data: Data; error?: undefined }\n | {\n data?: undefined;\n error:\n | DeviceExchangeError<SpecificErrorCodes>\n | InvalidBatteryDataError\n | InvalidBatteryStatusTypeError\n | InvalidResponseFormatError\n | InvalidStatusWordError\n | UnknownDeviceExchangeError;\n }): CommandResult<Data, SpecificErrorCodes> {\n if (error) {\n return {\n status: CommandResultStatus.Error,\n error,\n };\n }\n return {\n status: CommandResultStatus.Success,\n data,\n };\n}\n\nexport function isSuccessCommandResult<Data, StatusCode>(\n result: CommandResult<Data, StatusCode>,\n): result is CommandSuccessResult<Data> {\n return result.status === CommandResultStatus.Success;\n}\n"],
5
5
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,wBAAAC,EAAA,2BAAAC,IAAA,eAAAC,EAAAL,GAYO,IAAKG,OACVA,EAAA,MAAQ,QACRA,EAAA,QAAU,UAFAA,OAAA,IAsBL,SAASD,EAAsD,CACpE,KAAAI,EACA,MAAAC,CACF,EAWgD,CAC9C,OAAIA,EACK,CACL,OAAQ,QACR,MAAAA,CACF,EAEK,CACL,OAAQ,UACR,KAAAD,CACF,CACF,CAEO,SAASF,EACdI,EACsC,CACtC,OAAOA,EAAO,SAAW,SAC3B",
6
6
  "names": ["CommandResult_exports", "__export", "CommandResultFactory", "CommandResultStatus", "isSuccessCommandResult", "__toCommonJS", "data", "error", "result"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var A=(r,e)=>{for(var t in e)i(r,t,{get:e[t],enumerable:!0})},E=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of l(e))!y.call(r,a)&&a!==t&&i(r,a,{get:()=>e[a],enumerable:!(o=u(e,a))||o.enumerable});return r};var k=r=>E(i({},"__esModule",{value:!0}),r);var h={};A(h,{LoadCertificateCommand:()=>L,LoadCertificateCommandError:()=>C});module.exports=k(h);var d=require("../../apdu/utils/ApduBuilder"),m=require("../../apdu/utils/ApduParser"),s=require("../../command/model/CommandResult"),c=require("../../command/utils/CommandErrors"),f=require("../../command/utils/CommandUtils"),g=require("../../command/utils/GlobalCommandError"),p=require("../../Error");const n={"422f":{message:"Incorrect structure type"},4230:{message:"Incorrect certificate version"},4231:{message:"Incorrect certificate validity"},4232:{message:"Incorrect certificate validity index"},4233:{message:"Unknown signer key ID"},4234:{message:"Unknown signature algorithm"},4235:{message:"Unknown public key ID"},4236:{message:"Unknown public key usage"},4237:{message:"Incorrect elliptic curve ID"},4238:{message:"Incorrect signature algorithm associated to the public key"},4239:{message:"Unknown target device"},"422d":{message:"Unknown certificate tag"},3301:{message:"Failed to hash data"},"422e":{message:"expected_key_usage doesn't match certificate key usage"},5720:{message:"Failed to verify signature"},4118:{message:"trusted_name buffer is too small to contain the trusted name"},ffff:{message:"Cryptography-related error"}};class C extends p.DeviceExchangeError{constructor({message:e,errorCode:t}){super({tag:"ProvidePkiCertificateCommandError",message:e,errorCode:t})}}class L{args;triggersDisconnection=!1;constructor(e){this.args=e}getApdu(){const e={cla:176,ins:6,p1:this.args.keyUsage,p2:0};return new d.ApduBuilder(e).addBufferToData(this.args.certificate).build()}parseResponse(e){if(f.CommandUtils.isSuccessResponse(e))return(0,s.CommandResultFactory)({data:void 0});const o=new m.ApduParser(e).encodeToHexaString(e.statusCode);return(0,c.isCommandErrorCode)(o,n)?(0,s.CommandResultFactory)({error:new C({...n[o],errorCode:o})}):(0,s.CommandResultFactory)({error:g.GlobalCommandErrorHandler.handle(e)})}}0&&(module.exports={LoadCertificateCommand,LoadCertificateCommandError});
2
+ //# sourceMappingURL=LoadCertificateCommand.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/api/command/os/LoadCertificateCommand.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 {\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 { DeviceExchangeError } from \"@api/Error\";\nimport { type Command, type CommandErrorArgs } from \"@api/types\";\n\nexport type LoadCertificateArgs = {\n readonly keyUsage: number;\n readonly certificate: Uint8Array;\n};\n\nexport type LoadCertificateErrorCodes =\n | \"422f\"\n | \"4230\"\n | \"4231\"\n | \"4232\"\n | \"4233\"\n | \"4234\"\n | \"4235\"\n | \"4236\"\n | \"4237\"\n | \"4238\"\n | \"4239\"\n | \"422d\"\n | \"3301\"\n | \"422e\"\n | \"5720\"\n | \"4118\"\n | \"ffff\";\n\nconst LOAD_CERTIFICATE_ERRORS: CommandErrors<LoadCertificateErrorCodes> = {\n \"422f\": { message: \"Incorrect structure type\" },\n \"4230\": { message: \"Incorrect certificate version\" },\n \"4231\": { message: \"Incorrect certificate validity\" },\n \"4232\": { message: \"Incorrect certificate validity index\" },\n \"4233\": { message: \"Unknown signer key ID\" },\n \"4234\": { message: \"Unknown signature algorithm\" },\n \"4235\": { message: \"Unknown public key ID\" },\n \"4236\": { message: \"Unknown public key usage\" },\n \"4237\": { message: \"Incorrect elliptic curve ID\" },\n \"4238\": {\n message: \"Incorrect signature algorithm associated to the public key\",\n },\n \"4239\": { message: \"Unknown target device\" },\n \"422d\": { message: \"Unknown certificate tag\" },\n \"3301\": { message: \"Failed to hash data\" },\n \"422e\": {\n message: \"expected_key_usage doesn't match certificate key usage\",\n },\n \"5720\": { message: \"Failed to verify signature\" },\n \"4118\": {\n message: \"trusted_name buffer is too small to contain the trusted name\",\n },\n ffff: { message: \"Cryptography-related error\" },\n};\n\nexport class LoadCertificateCommandError extends DeviceExchangeError<LoadCertificateErrorCodes> {\n constructor({\n message,\n errorCode,\n }: CommandErrorArgs<LoadCertificateErrorCodes>) {\n super({ tag: \"ProvidePkiCertificateCommandError\", message, errorCode });\n }\n}\n\nexport type LoadCertificateCommandResult = CommandResult<\n void,\n LoadCertificateErrorCodes\n>;\n\n/**\n * The command to load a certificate on the device.\n */\nexport class LoadCertificateCommand\n implements Command<void, LoadCertificateArgs, LoadCertificateErrorCodes>\n{\n readonly args: LoadCertificateArgs;\n readonly triggersDisconnection = false;\n\n constructor(args: LoadCertificateArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const providePkiApduArgs: ApduBuilderArgs = {\n cla: 0xb0,\n ins: 0x06,\n p1: this.args.keyUsage,\n p2: 0x00,\n };\n return new ApduBuilder(providePkiApduArgs)\n .addBufferToData(this.args.certificate)\n .build();\n }\n\n parseResponse(apduResponse: ApduResponse): LoadCertificateCommandResult {\n if (CommandUtils.isSuccessResponse(apduResponse)) {\n return CommandResultFactory({\n data: undefined,\n });\n }\n const parser = new ApduParser(apduResponse);\n const errorCode = parser.encodeToHexaString(apduResponse.statusCode);\n if (isCommandErrorCode(errorCode, LOAD_CERTIFICATE_ERRORS)) {\n return CommandResultFactory({\n error: new LoadCertificateCommandError({\n ...LOAD_CERTIFICATE_ERRORS[errorCode],\n errorCode,\n }),\n });\n }\n return CommandResultFactory({\n error: GlobalCommandErrorHandler.handle(apduResponse),\n });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,gCAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAkD,uCAClDC,EAA2B,sCAC3BC,EAGO,4CACPC,EAGO,4CACPC,EAA6B,2CAC7BC,EAA0C,iDAE1CC,EAAoC,sBA2BpC,MAAMC,EAAoE,CACxE,OAAQ,CAAE,QAAS,0BAA2B,EAC9C,KAAQ,CAAE,QAAS,+BAAgC,EACnD,KAAQ,CAAE,QAAS,gCAAiC,EACpD,KAAQ,CAAE,QAAS,sCAAuC,EAC1D,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,KAAQ,CAAE,QAAS,6BAA8B,EACjD,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,KAAQ,CAAE,QAAS,0BAA2B,EAC9C,KAAQ,CAAE,QAAS,6BAA8B,EACjD,KAAQ,CACN,QAAS,4DACX,EACA,KAAQ,CAAE,QAAS,uBAAwB,EAC3C,OAAQ,CAAE,QAAS,yBAA0B,EAC7C,KAAQ,CAAE,QAAS,qBAAsB,EACzC,OAAQ,CACN,QAAS,wDACX,EACA,KAAQ,CAAE,QAAS,4BAA6B,EAChD,KAAQ,CACN,QAAS,8DACX,EACA,KAAM,CAAE,QAAS,4BAA6B,CAChD,EAEO,MAAMT,UAAoC,qBAA+C,CAC9F,YAAY,CACV,QAAAU,EACA,UAAAC,CACF,EAAgD,CAC9C,MAAM,CAAE,IAAK,oCAAqC,QAAAD,EAAS,UAAAC,CAAU,CAAC,CACxE,CACF,CAUO,MAAMZ,CAEb,CACW,KACA,sBAAwB,GAEjC,YAAYa,EAA2B,CACrC,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,MAAMC,EAAsC,CAC1C,IAAK,IACL,IAAK,EACL,GAAI,KAAK,KAAK,SACd,GAAI,CACN,EACA,OAAO,IAAI,cAAYA,CAAkB,EACtC,gBAAgB,KAAK,KAAK,WAAW,EACrC,MAAM,CACX,CAEA,cAAcC,EAA0D,CACtE,GAAI,eAAa,kBAAkBA,CAAY,EAC7C,SAAO,wBAAqB,CAC1B,KAAM,MACR,CAAC,EAGH,MAAMH,EADS,IAAI,aAAWG,CAAY,EACjB,mBAAmBA,EAAa,UAAU,EACnE,SAAI,sBAAmBH,EAAWF,CAAuB,KAChD,wBAAqB,CAC1B,MAAO,IAAIT,EAA4B,CACrC,GAAGS,EAAwBE,CAAS,EACpC,UAAAA,CACF,CAAC,CACH,CAAC,KAEI,wBAAqB,CAC1B,MAAO,4BAA0B,OAAOG,CAAY,CACtD,CAAC,CACH,CACF",
6
+ "names": ["LoadCertificateCommand_exports", "__export", "LoadCertificateCommand", "LoadCertificateCommandError", "__toCommonJS", "import_ApduBuilder", "import_ApduParser", "import_CommandResult", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_Error", "LOAD_CERTIFICATE_ERRORS", "message", "errorCode", "args", "providePkiApduArgs", "apduResponse"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=require("../../command/model/CommandResult"),o=require("../../command/os/LoadCertificateCommand"),n=require("../../command/utils/GlobalCommandError"),c=require("../../utils/HexaString");describe("LoadCertificateCommand",()=>{describe("getApdu",()=>{it("should return the APDU with key equal to 1",()=>{const r={keyUsage:66,certificate:new Uint8Array([1,2,3])},e=new o.LoadCertificateCommand(r).getApdu();expect(e.cla).toBe(176),expect(e.ins).toBe(6),expect(e.p1).toBe(66),expect(e.p2).toBe(0),expect(e.data).toStrictEqual(new Uint8Array([1,2,3]))})}),describe("parseResponse",()=>{let r;beforeEach(()=>{r=new o.LoadCertificateCommand({keyUsage:1,certificate:new Uint8Array})}),it("should return success if the response status code is success",()=>{const t={statusCode:new Uint8Array([144,0]),data:new Uint8Array},e=r.parseResponse(t);expect(e).toStrictEqual((0,s.CommandResultFactory)({data:void 0}))}),describe("errors",()=>{it("should return error command result if the device is locked",()=>{const t={statusCode:new Uint8Array([85,21]),data:new Uint8Array},e=r.parseResponse(t);(0,s.isSuccessCommandResult)(e)?assert.fail("Expected error command result"):expect(e.error).toBeInstanceOf(n.GlobalCommandError)}),it.each(["422f","4230","4231","4232","4233","4234","4235","4236","4237","4238","4239","422d","3301","422e","5720","4118","ffff"])("should return a ProvidePkiCertificateCommandError if the response is a %s specific error code",t=>{const e={statusCode:(0,c.hexaStringToBuffer)(t),data:new Uint8Array},a=r.parseResponse(e);(0,s.isSuccessCommandResult)(a)?assert.fail("Expected error command result"):(expect(a.error).toBeInstanceOf(o.LoadCertificateCommandError),expect(a.error.errorCode).toBe(t))})})})});
2
+ //# sourceMappingURL=LoadCertificateCommand.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/api/command/os/LoadCertificateCommand.test.ts"],
4
+ "sourcesContent": ["import {\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport {\n LoadCertificateCommand,\n LoadCertificateCommandError,\n} from \"@api/command/os/LoadCertificateCommand\";\nimport { GlobalCommandError } from \"@api/command/utils/GlobalCommandError\";\nimport { hexaStringToBuffer } from \"@api/utils/HexaString\";\n\ndescribe(\"LoadCertificateCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the APDU with key equal to 1\", () => {\n // GIVEN\n const args = {\n keyUsage: 0x42,\n certificate: new Uint8Array([0x01, 0x02, 0x03]),\n };\n const command = new LoadCertificateCommand(args);\n\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.cla).toBe(0xb0);\n expect(apdu.ins).toBe(0x06);\n expect(apdu.p1).toBe(0x42);\n expect(apdu.p2).toBe(0x00);\n expect(apdu.data).toStrictEqual(new Uint8Array([0x01, 0x02, 0x03]));\n });\n });\n\n describe(\"parseResponse\", () => {\n let command: LoadCertificateCommand;\n\n beforeEach(() => {\n command = new LoadCertificateCommand({\n keyUsage: 0x01,\n certificate: new Uint8Array(),\n });\n });\n\n it(\"should return success if the response status code is success\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(CommandResultFactory({ data: undefined }));\n });\n\n describe(\"errors\", () => {\n it(\"should return error command result if the device is locked\", () => {\n // GIVEN\n const response = {\n statusCode: new Uint8Array([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(GlobalCommandError);\n }\n });\n\n it.each([\n \"422f\",\n \"4230\",\n \"4231\",\n \"4232\",\n \"4233\",\n \"4234\",\n \"4235\",\n \"4236\",\n \"4237\",\n \"4238\",\n \"4239\",\n \"422d\",\n \"3301\",\n \"422e\",\n \"5720\",\n \"4118\",\n \"ffff\",\n ])(\n \"should return a ProvidePkiCertificateCommandError if the response is a %s specific error code\",\n (errorCode) => {\n // GIVEN\n const response = {\n statusCode: hexaStringToBuffer(errorCode)!,\n data: new Uint8Array(),\n };\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n assert.fail(\"Expected error command result\");\n } else {\n expect(result.error).toBeInstanceOf(LoadCertificateCommandError);\n // @ts-expect-error intended\n expect(result.error.errorCode).toBe(errorCode);\n }\n },\n );\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAGO,4CACPC,EAGO,kDACPC,EAAmC,iDACnCC,EAAmC,iCAEnC,SAAS,yBAA0B,IAAM,CACvC,SAAS,UAAW,IAAM,CACxB,GAAG,6CAA8C,IAAM,CAErD,MAAMC,EAAO,CACX,SAAU,GACV,YAAa,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAChD,EAIMC,EAHU,IAAI,yBAAuBD,CAAI,EAG1B,QAAQ,EAG7B,OAAOC,EAAK,GAAG,EAAE,KAAK,GAAI,EAC1B,OAAOA,EAAK,GAAG,EAAE,KAAK,CAAI,EAC1B,OAAOA,EAAK,EAAE,EAAE,KAAK,EAAI,EACzB,OAAOA,EAAK,EAAE,EAAE,KAAK,CAAI,EACzB,OAAOA,EAAK,IAAI,EAAE,cAAc,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAAC,CACpE,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAI,yBAAuB,CACnC,SAAU,EACV,YAAa,IAAI,UACnB,CAAC,CACH,CAAC,EAED,GAAG,+DAAgE,IAAM,CAEvE,MAAMC,EAAW,CACf,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,UACZ,EAGMC,EAASF,EAAQ,cAAcC,CAAQ,EAG7C,OAAOC,CAAM,EAAE,iBAAc,wBAAqB,CAAE,KAAM,MAAU,CAAC,CAAC,CACxE,CAAC,EAED,SAAS,SAAU,IAAM,CACvB,GAAG,6DAA8D,IAAM,CAErE,MAAMD,EAAW,CACf,WAAY,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,EACvC,KAAM,IAAI,UACZ,EAGMC,EAASF,EAAQ,cAAcC,CAAQ,KAGzC,0BAAuBC,CAAM,EAC/B,OAAO,KAAK,+BAA+B,EAE3C,OAAOA,EAAO,KAAK,EAAE,eAAe,oBAAkB,CAE1D,CAAC,EAED,GAAG,KAAK,CACN,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,MACF,CAAC,EACC,gGACCC,GAAc,CAEb,MAAMF,EAAW,CACf,cAAY,sBAAmBE,CAAS,EACxC,KAAM,IAAI,UACZ,EAGMD,EAASF,EAAQ,cAAcC,CAAQ,KAGzC,0BAAuBC,CAAM,EAC/B,OAAO,KAAK,+BAA+B,GAE3C,OAAOA,EAAO,KAAK,EAAE,eAAe,6BAA2B,EAE/D,OAAOA,EAAO,MAAM,SAAS,EAAE,KAAKC,CAAS,EAEjD,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_CommandResult", "import_LoadCertificateCommand", "import_GlobalCommandError", "import_HexaString", "args", "apdu", "command", "response", "result", "errorCode"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var d=require("purify-ts"),r=require("../../command/model/CommandResult"),u=require("../../../internal/device-session/model/DeviceSession.stub"),p=require("../../../internal/device-session/service/DefaultDeviceSessionService"),S=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService"),f=require("../../../internal/manager-api/data/AxiosManagerApiDataSource"),l=require("../../../internal/manager-api/service/DefaultManagerApiService"),a=require("./SendCommandUseCase");let s,o,n,c;const m="fakeSessionId";let i;describe("SendCommandUseCase",()=>{beforeEach(()=>{s=new S.DefaultLoggerPublisherService([],"send-command-use-case"),o=new p.DefaultDeviceSessionService(()=>s),c=new f.AxiosManagerApiDataSource({managerApiUrl:"http://fake.url",mockUrl:"http://fake-mock.url"}),n=new l.DefaultManagerApiService(c),i={getApdu:jest.fn(),parseResponse:jest.fn()}}),afterEach(()=>{jest.restoreAllMocks()}),it("should send a command to a connected device",async()=>{const e=(0,u.deviceSessionStubBuilder)({},()=>s,n);o.addDeviceSession(e);const t=new a.SendCommandUseCase(o,()=>s);jest.spyOn(e,"sendCommand").mockResolvedValue({status:r.CommandResultStatus.Success,data:void 0});const v=await t.execute({sessionId:m,command:i});e.close(),expect(v).toStrictEqual({status:r.CommandResultStatus.Success,data:void 0})}),it("should throw an error if the session is not found",async()=>{const e=new a.SendCommandUseCase(o,()=>s);jest.spyOn(o,"getDeviceSessionById").mockReturnValue((0,d.Left)({_tag:"DeviceSessionNotFound"}));const t=e.execute({sessionId:m,command:i});await expect(t).rejects.toMatchObject({_tag:"DeviceSessionNotFound"})})});
1
+ "use strict";var d=require("purify-ts"),i=require("../../command/model/CommandResult"),p=require("../../../internal/device-session/model/DeviceSession.stub"),f=require("../../../internal/device-session/service/DefaultDeviceSessionService"),l=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService"),v=require("../../../internal/manager-api/data/AxiosManagerApiDataSource"),g=require("../../../internal/manager-api/service/DefaultManagerApiService"),D=require("../../../internal/secure-channel/data/DefaultSecureChannelDataSource"),C=require("../../../internal/secure-channel/service/DefaultSecureChannelService"),a=require("./SendCommandUseCase");let o,t,n,c,m,u;const S="fakeSessionId";let s;describe("SendCommandUseCase",()=>{beforeEach(()=>{o=new l.DefaultLoggerPublisherService([],"send-command-use-case"),t=new f.DefaultDeviceSessionService(()=>o),c=new v.AxiosManagerApiDataSource({}),n=new g.DefaultManagerApiService(c),u=new D.DefaultSecureChannelDataSource({}),m=new C.DefaultSecureChannelService(u),s={getApdu:vi.fn(),parseResponse:vi.fn()}}),afterEach(()=>{vi.restoreAllMocks()}),it("should send a command to a connected device",async()=>{const e=(0,p.deviceSessionStubBuilder)({},()=>o,n,m);t.addDeviceSession(e);const r=new a.SendCommandUseCase(t,()=>o);vi.spyOn(e,"sendCommand").mockResolvedValue({status:i.CommandResultStatus.Success,data:void 0});const h=await r.execute({sessionId:S,command:s});e.close(),expect(h).toStrictEqual({status:i.CommandResultStatus.Success,data:void 0})}),it("should throw an error if the session is not found",async()=>{const e=new a.SendCommandUseCase(t,()=>o);vi.spyOn(t,"getDeviceSessionById").mockReturnValue((0,d.Left)({_tag:"DeviceSessionNotFound"}));const r=e.execute({sessionId:S,command:s});await expect(r).rejects.toMatchObject({_tag:"DeviceSessionNotFound"})})});
2
2
  //# sourceMappingURL=SendCommandUseCase.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/use-case/SendCommandUseCase.test.ts"],
4
- "sourcesContent": ["import { Left } from \"purify-ts\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { CommandResultStatus } from \"@api/command/model/CommandResult\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { SendCommandUseCase } from \"./SendCommandUseCase\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet managerApi: ManagerApiService;\nlet managerApiDataSource: ManagerApiDataSource;\nconst fakeSessionId = \"fakeSessionId\";\nlet command: Command<{ status: string }>;\n\ndescribe(\"SendCommandUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService([], \"send-command-use-case\");\n sessionService = new DefaultDeviceSessionService(() => logger);\n managerApiDataSource = new AxiosManagerApiDataSource({\n managerApiUrl: \"http://fake.url\",\n mockUrl: \"http://fake-mock.url\",\n });\n managerApi = new DefaultManagerApiService(managerApiDataSource);\n command = {\n getApdu: jest.fn(),\n parseResponse: jest.fn(),\n };\n });\n\n afterEach(() => {\n jest.restoreAllMocks();\n });\n\n it(\"should send a command to a connected device\", async () => {\n const deviceSession = deviceSessionStubBuilder(\n {},\n () => logger,\n managerApi,\n );\n sessionService.addDeviceSession(deviceSession);\n const useCase = new SendCommandUseCase(sessionService, () => logger);\n\n jest.spyOn(deviceSession, \"sendCommand\").mockResolvedValue({\n status: CommandResultStatus.Success,\n data: undefined,\n });\n\n const response = await useCase.execute<{ status: string }, void, void>({\n sessionId: fakeSessionId,\n command,\n });\n\n deviceSession.close();\n\n expect(response).toStrictEqual({\n status: CommandResultStatus.Success,\n data: undefined,\n });\n });\n\n it(\"should throw an error if the session is not found\", async () => {\n const useCase = new SendCommandUseCase(sessionService, () => logger);\n jest\n .spyOn(sessionService, \"getDeviceSessionById\")\n .mockReturnValue(Left({ _tag: \"DeviceSessionNotFound\" }));\n\n const res = useCase.execute<{ status: string }, void, void>({\n sessionId: fakeSessionId,\n command,\n });\n\n await expect(res).rejects.toMatchObject({ _tag: \"DeviceSessionNotFound\" });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAAqB,qBAGrBC,EAAoC,4CAEpCC,EAAyC,6DACzCC,EAA4C,wEAE5CC,EAA8C,4EAC9CC,EAA0C,gEAE1CC,EAAyC,kEAGzCC,EAAmC,gCAEnC,IAAIC,EACAC,EACAC,EACAC,EACJ,MAAMC,EAAgB,gBACtB,IAAIC,EAEJ,SAAS,qBAAsB,IAAM,CACnC,WAAW,IAAM,CACfL,EAAS,IAAI,gCAA8B,CAAC,EAAG,uBAAuB,EACtEC,EAAiB,IAAI,8BAA4B,IAAMD,CAAM,EAC7DG,EAAuB,IAAI,4BAA0B,CACnD,cAAe,kBACf,QAAS,sBACX,CAAC,EACDD,EAAa,IAAI,2BAAyBC,CAAoB,EAC9DE,EAAU,CACR,QAAS,KAAK,GAAG,EACjB,cAAe,KAAK,GAAG,CACzB,CACF,CAAC,EAED,UAAU,IAAM,CACd,KAAK,gBAAgB,CACvB,CAAC,EAED,GAAG,8CAA+C,SAAY,CAC5D,MAAMC,KAAgB,4BACpB,CAAC,EACD,IAAMN,EACNE,CACF,EACAD,EAAe,iBAAiBK,CAAa,EAC7C,MAAMC,EAAU,IAAI,qBAAmBN,EAAgB,IAAMD,CAAM,EAEnE,KAAK,MAAMM,EAAe,aAAa,EAAE,kBAAkB,CACzD,OAAQ,sBAAoB,QAC5B,KAAM,MACR,CAAC,EAED,MAAME,EAAW,MAAMD,EAAQ,QAAwC,CACrE,UAAWH,EACX,QAAAC,CACF,CAAC,EAEDC,EAAc,MAAM,EAEpB,OAAOE,CAAQ,EAAE,cAAc,CAC7B,OAAQ,sBAAoB,QAC5B,KAAM,MACR,CAAC,CACH,CAAC,EAED,GAAG,oDAAqD,SAAY,CAClE,MAAMD,EAAU,IAAI,qBAAmBN,EAAgB,IAAMD,CAAM,EACnE,KACG,MAAMC,EAAgB,sBAAsB,EAC5C,mBAAgB,QAAK,CAAE,KAAM,uBAAwB,CAAC,CAAC,EAE1D,MAAMQ,EAAMF,EAAQ,QAAwC,CAC1D,UAAWH,EACX,QAAAC,CACF,CAAC,EAED,MAAM,OAAOI,CAAG,EAAE,QAAQ,cAAc,CAAE,KAAM,uBAAwB,CAAC,CAC3E,CAAC,CACH,CAAC",
6
- "names": ["import_purify_ts", "import_CommandResult", "import_DeviceSession", "import_DefaultDeviceSessionService", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_SendCommandUseCase", "logger", "sessionService", "managerApi", "managerApiDataSource", "fakeSessionId", "command", "deviceSession", "useCase", "response", "res"]
4
+ "sourcesContent": ["import { Left } from \"purify-ts\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { CommandResultStatus } from \"@api/command/model/CommandResult\";\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { deviceSessionStubBuilder } from \"@internal/device-session/model/DeviceSession.stub\";\nimport { DefaultDeviceSessionService } from \"@internal/device-session/service/DefaultDeviceSessionService\";\nimport { type DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { DefaultSecureChannelDataSource } from \"@internal/secure-channel/data/DefaultSecureChannelDataSource\";\nimport { type SecureChannelDataSource } from \"@internal/secure-channel/data/SecureChannelDataSource\";\nimport { DefaultSecureChannelService } from \"@internal/secure-channel/service/DefaultSecureChannelService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { SendCommandUseCase } from \"./SendCommandUseCase\";\n\nlet logger: LoggerPublisherService;\nlet sessionService: DeviceSessionService;\nlet managerApi: ManagerApiService;\nlet managerApiDataSource: ManagerApiDataSource;\nlet secureChannel: SecureChannelService;\nlet secureChannelDataSource: SecureChannelDataSource;\nconst fakeSessionId = \"fakeSessionId\";\nlet command: Command<{ status: string }>;\n\ndescribe(\"SendCommandUseCase\", () => {\n beforeEach(() => {\n logger = new DefaultLoggerPublisherService([], \"send-command-use-case\");\n sessionService = new DefaultDeviceSessionService(() => logger);\n managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n managerApi = new DefaultManagerApiService(managerApiDataSource);\n secureChannelDataSource = new DefaultSecureChannelDataSource(\n {} as DmkConfig,\n );\n secureChannel = new DefaultSecureChannelService(secureChannelDataSource);\n command = {\n getApdu: vi.fn(),\n parseResponse: vi.fn(),\n };\n });\n\n afterEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should send a command to a connected device\", async () => {\n const deviceSession = deviceSessionStubBuilder(\n {},\n () => logger,\n managerApi,\n secureChannel,\n );\n sessionService.addDeviceSession(deviceSession);\n const useCase = new SendCommandUseCase(sessionService, () => logger);\n\n vi.spyOn(deviceSession, \"sendCommand\").mockResolvedValue({\n status: CommandResultStatus.Success,\n data: undefined,\n });\n\n const response = await useCase.execute<{ status: string }, void, void>({\n sessionId: fakeSessionId,\n command,\n });\n\n deviceSession.close();\n\n expect(response).toStrictEqual({\n status: CommandResultStatus.Success,\n data: undefined,\n });\n });\n\n it(\"should throw an error if the session is not found\", async () => {\n const useCase = new SendCommandUseCase(sessionService, () => logger);\n vi.spyOn(sessionService, \"getDeviceSessionById\").mockReturnValue(\n Left({ _tag: \"DeviceSessionNotFound\" }),\n );\n\n const res = useCase.execute<{ status: string }, void, void>({\n sessionId: fakeSessionId,\n command,\n });\n\n await expect(res).rejects.toMatchObject({ _tag: \"DeviceSessionNotFound\" });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAqB,qBAGrBC,EAAoC,4CAGpCC,EAAyC,6DACzCC,EAA4C,wEAE5CC,EAA8C,4EAC9CC,EAA0C,gEAE1CC,EAAyC,kEAEzCC,EAA+C,wEAE/CC,EAA4C,wEAG5CC,EAAmC,gCAEnC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACJ,MAAMC,EAAgB,gBACtB,IAAIC,EAEJ,SAAS,qBAAsB,IAAM,CACnC,WAAW,IAAM,CACfP,EAAS,IAAI,gCAA8B,CAAC,EAAG,uBAAuB,EACtEC,EAAiB,IAAI,8BAA4B,IAAMD,CAAM,EAC7DG,EAAuB,IAAI,4BAA0B,CAAC,CAAc,EACpED,EAAa,IAAI,2BAAyBC,CAAoB,EAC9DE,EAA0B,IAAI,iCAC5B,CAAC,CACH,EACAD,EAAgB,IAAI,8BAA4BC,CAAuB,EACvEE,EAAU,CACR,QAAS,GAAG,GAAG,EACf,cAAe,GAAG,GAAG,CACvB,CACF,CAAC,EAED,UAAU,IAAM,CACd,GAAG,gBAAgB,CACrB,CAAC,EAED,GAAG,8CAA+C,SAAY,CAC5D,MAAMC,KAAgB,4BACpB,CAAC,EACD,IAAMR,EACNE,EACAE,CACF,EACAH,EAAe,iBAAiBO,CAAa,EAC7C,MAAMC,EAAU,IAAI,qBAAmBR,EAAgB,IAAMD,CAAM,EAEnE,GAAG,MAAMQ,EAAe,aAAa,EAAE,kBAAkB,CACvD,OAAQ,sBAAoB,QAC5B,KAAM,MACR,CAAC,EAED,MAAME,EAAW,MAAMD,EAAQ,QAAwC,CACrE,UAAWH,EACX,QAAAC,CACF,CAAC,EAEDC,EAAc,MAAM,EAEpB,OAAOE,CAAQ,EAAE,cAAc,CAC7B,OAAQ,sBAAoB,QAC5B,KAAM,MACR,CAAC,CACH,CAAC,EAED,GAAG,oDAAqD,SAAY,CAClE,MAAMD,EAAU,IAAI,qBAAmBR,EAAgB,IAAMD,CAAM,EACnE,GAAG,MAAMC,EAAgB,sBAAsB,EAAE,mBAC/C,QAAK,CAAE,KAAM,uBAAwB,CAAC,CACxC,EAEA,MAAMU,EAAMF,EAAQ,QAAwC,CAC1D,UAAWH,EACX,QAAAC,CACF,CAAC,EAED,MAAM,OAAOI,CAAG,EAAE,QAAQ,cAAc,CAAE,KAAM,uBAAwB,CAAC,CAC3E,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_CommandResult", "import_DeviceSession", "import_DefaultDeviceSessionService", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_DefaultSecureChannelDataSource", "import_DefaultSecureChannelService", "import_SendCommandUseCase", "logger", "sessionService", "managerApi", "managerApiDataSource", "secureChannel", "secureChannelDataSource", "fakeSessionId", "command", "deviceSession", "useCase", "response", "res"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var c=(s,e)=>{for(var t in e)r(s,t,{get:e[t],enumerable:!0})},l=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of a(e))!o.call(s,i)&&i!==t&&r(s,i,{get:()=>e[i],enumerable:!(n=p(e,i))||n.enumerable});return s};var u=s=>l(r({},"__esModule",{value:!0}),s);var f={};c(f,{CommandUtils:()=>d});module.exports=u(f);class d{static isValidStatusCode(e){return e.length===2}static isSuccessResponse({statusCode:e}){return this.isValidStatusCode(e)?e[0]===144&&e[1]===0:!1}static isLockedDeviceResponse({statusCode:e}){return this.isValidStatusCode(e)?e[0]===85&&e[1]===21:!1}}0&&(module.exports={CommandUtils});
1
+ "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var s in e)a(t,s,{get:e[s],enumerable:!0})},x=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of o(e))!u.call(t,r)&&r!==s&&a(t,r,{get:()=>e[r],enumerable:!(i=p(e,r))||i.enumerable});return t};var A=t=>x(a({},"__esModule",{value:!0}),t);var l={};c(l,{CommandUtils:()=>n});module.exports=A(l);class n{static isValidStatusCode(e){return e.length===2}static isSuccessResponse({statusCode:e}){return n.isValidStatusCode(e)?e[0]===144&&e[1]===0:!1}static isLockedDeviceResponse({statusCode:e}){return n.isValidStatusCode(e)?e[0]===85&&e[1]===21:!1}static isApduThatTriggersDisconnection(e){const s=new Map;return s.set("openApp",new Uint8Array([224,216,0,0])),s.set("closeApp",new Uint8Array([176,167,0,0])),Array.from(s.values()).some(i=>{for(let r=0;r<4;r++)if(i[r]!==e[r])return!1;return!0})}}0&&(module.exports={CommandUtils});
2
2
  //# sourceMappingURL=CommandUtils.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/utils/CommandUtils.ts"],
4
- "sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nexport class CommandUtils {\n static isValidStatusCode(statusCode: Uint8Array) {\n return statusCode.length === 2;\n }\n\n static isSuccessResponse({ statusCode }: ApduResponse) {\n if (!this.isValidStatusCode(statusCode)) {\n return false;\n }\n\n return statusCode[0] === 0x90 && statusCode[1] === 0x00;\n }\n\n static isLockedDeviceResponse({ statusCode }: ApduResponse) {\n if (!this.isValidStatusCode(statusCode)) {\n return false;\n }\n\n return statusCode[0] === 0x55 && statusCode[1] === 0x15;\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAEO,MAAME,CAAa,CACxB,OAAO,kBAAkBE,EAAwB,CAC/C,OAAOA,EAAW,SAAW,CAC/B,CAEA,OAAO,kBAAkB,CAAE,WAAAA,CAAW,EAAiB,CACrD,OAAK,KAAK,kBAAkBA,CAAU,EAI/BA,EAAW,CAAC,IAAM,KAAQA,EAAW,CAAC,IAAM,EAH1C,EAIX,CAEA,OAAO,uBAAuB,CAAE,WAAAA,CAAW,EAAiB,CAC1D,OAAK,KAAK,kBAAkBA,CAAU,EAI/BA,EAAW,CAAC,IAAM,IAAQA,EAAW,CAAC,IAAM,GAH1C,EAIX,CACF",
6
- "names": ["CommandUtils_exports", "__export", "CommandUtils", "__toCommonJS", "statusCode"]
4
+ "sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nexport class CommandUtils {\n static isValidStatusCode(statusCode: Uint8Array) {\n return statusCode.length === 2;\n }\n\n static isSuccessResponse({ statusCode }: ApduResponse) {\n if (!CommandUtils.isValidStatusCode(statusCode)) {\n return false;\n }\n\n return statusCode[0] === 0x90 && statusCode[1] === 0x00;\n }\n\n static isLockedDeviceResponse({ statusCode }: ApduResponse) {\n if (!CommandUtils.isValidStatusCode(statusCode)) {\n return false;\n }\n\n return statusCode[0] === 0x55 && statusCode[1] === 0x15;\n }\n\n static isApduThatTriggersDisconnection(apdu: Uint8Array) {\n /**\n * Map of known APDUs that trigger a disconnection.\n */\n const apduMap = new Map();\n apduMap.set(\"openApp\", new Uint8Array([0xe0, 0xd8, 0x00, 0x00]));\n apduMap.set(\"closeApp\", new Uint8Array([0xb0, 0xa7, 0x00, 0x00]));\n // TODO: add more APDUs that trigger a disconnection (e.g firmware flashing ?)\n\n // check if apdu first 4 UintArray is included in apduMap\n return Array.from(apduMap.values()).some((value: Uint8Array) => {\n for (let i = 0; i < 4; i++) {\n if (value[i] !== apdu[i]) {\n return false;\n }\n }\n return true;\n });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAEO,MAAME,CAAa,CACxB,OAAO,kBAAkBE,EAAwB,CAC/C,OAAOA,EAAW,SAAW,CAC/B,CAEA,OAAO,kBAAkB,CAAE,WAAAA,CAAW,EAAiB,CACrD,OAAKF,EAAa,kBAAkBE,CAAU,EAIvCA,EAAW,CAAC,IAAM,KAAQA,EAAW,CAAC,IAAM,EAH1C,EAIX,CAEA,OAAO,uBAAuB,CAAE,WAAAA,CAAW,EAAiB,CAC1D,OAAKF,EAAa,kBAAkBE,CAAU,EAIvCA,EAAW,CAAC,IAAM,IAAQA,EAAW,CAAC,IAAM,GAH1C,EAIX,CAEA,OAAO,gCAAgCC,EAAkB,CAIvD,MAAMC,EAAU,IAAI,IACpB,OAAAA,EAAQ,IAAI,UAAW,IAAI,WAAW,CAAC,IAAM,IAAM,EAAM,CAAI,CAAC,CAAC,EAC/DA,EAAQ,IAAI,WAAY,IAAI,WAAW,CAAC,IAAM,IAAM,EAAM,CAAI,CAAC,CAAC,EAIzD,MAAM,KAAKA,EAAQ,OAAO,CAAC,EAAE,KAAMC,GAAsB,CAC9D,QAASC,EAAI,EAAGA,EAAI,EAAGA,IACrB,GAAID,EAAMC,CAAC,IAAMH,EAAKG,CAAC,EACrB,MAAO,GAGX,MAAO,EACT,CAAC,CACH,CACF",
6
+ "names": ["CommandUtils_exports", "__export", "CommandUtils", "__toCommonJS", "statusCode", "apdu", "apduMap", "value", "i"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("../../device-session/ApduResponse"),s=require("./CommandUtils");describe("CommandUtils",()=>{describe("static isSuccessResponse",()=>{it("should return true if the status code is 0x9000",()=>{const e=new t.ApduResponse({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([])});expect(s.CommandUtils.isSuccessResponse(e)).toBe(!0)}),it("should return false if the status code is not 0x9000",()=>{const e=new t.ApduResponse({statusCode:Uint8Array.from([110,128]),data:Uint8Array.from([])});expect(s.CommandUtils.isSuccessResponse(e)).toBe(!1)}),it("should return false if the status code is not 2 bytes long",()=>{const e=new t.ApduResponse({statusCode:Uint8Array.from([85]),data:Uint8Array.from([])});expect(s.CommandUtils.isSuccessResponse(e)).toBe(!1)})}),describe("static isValidStatusCode",()=>{it("should return true if the status code is 2 bytes long",()=>{const e=Uint8Array.from([144,0]);expect(s.CommandUtils.isValidStatusCode(e)).toBe(!0)}),it("should return false if the status code is not 2 bytes long",()=>{const e=Uint8Array.from([144]);expect(s.CommandUtils.isValidStatusCode(e)).toBe(!1)})}),describe("static isLockedDeviceResponse",()=>{it("should return true if the status code is 0x5515",()=>{const e=new t.ApduResponse({statusCode:Uint8Array.from([85,21]),data:Uint8Array.from([])});expect(s.CommandUtils.isLockedDeviceResponse(e)).toBe(!0)}),it("should return false if the status code is not 0x5515",()=>{const e=new t.ApduResponse({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([])});expect(s.CommandUtils.isLockedDeviceResponse(e)).toBe(!1)}),it("should return false if the status code is not 2 bytes long",()=>{const e=new t.ApduResponse({statusCode:Uint8Array.from([144]),data:Uint8Array.from([])});expect(s.CommandUtils.isLockedDeviceResponse(e)).toBe(!1)})})});
1
+ "use strict";var o=require("../../command/os/CloseAppCommand"),r=require("../../command/os/GetAppAndVersionCommand"),i=require("../../command/os/OpenAppCommand"),s=require("../../device-session/ApduResponse"),t=require("./CommandUtils");describe("CommandUtils",()=>{describe("static isSuccessResponse",()=>{it("should return true if the status code is 0x9000",()=>{const e=new s.ApduResponse({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([])});expect(t.CommandUtils.isSuccessResponse(e)).toBe(!0)}),it("should return false if the status code is not 0x9000",()=>{const e=new s.ApduResponse({statusCode:Uint8Array.from([110,128]),data:Uint8Array.from([])});expect(t.CommandUtils.isSuccessResponse(e)).toBe(!1)}),it("should return false if the status code is not 2 bytes long",()=>{const e=new s.ApduResponse({statusCode:Uint8Array.from([85]),data:Uint8Array.from([])});expect(t.CommandUtils.isSuccessResponse(e)).toBe(!1)})}),describe("static isValidStatusCode",()=>{it("should return true if the status code is 2 bytes long",()=>{const e=Uint8Array.from([144,0]);expect(t.CommandUtils.isValidStatusCode(e)).toBe(!0)}),it("should return false if the status code is not 2 bytes long",()=>{const e=Uint8Array.from([144]);expect(t.CommandUtils.isValidStatusCode(e)).toBe(!1)})}),describe("static isLockedDeviceResponse",()=>{it("should return true if the status code is 0x5515",()=>{const e=new s.ApduResponse({statusCode:Uint8Array.from([85,21]),data:Uint8Array.from([])});expect(t.CommandUtils.isLockedDeviceResponse(e)).toBe(!0)}),it("should return false if the status code is not 0x5515",()=>{const e=new s.ApduResponse({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([])});expect(t.CommandUtils.isLockedDeviceResponse(e)).toBe(!1)}),it("should return false if the status code is not 2 bytes long",()=>{const e=new s.ApduResponse({statusCode:Uint8Array.from([144]),data:Uint8Array.from([])});expect(t.CommandUtils.isLockedDeviceResponse(e)).toBe(!1)})}),describe("static isApduThatTriggersDisconnection",()=>{it("should return true if the APDU is openApp",()=>{const e=new i.OpenAppCommand({appName:"test"}).getApdu().getRawApdu();expect(t.CommandUtils.isApduThatTriggersDisconnection(e)).toBe(!0)}),it("should return true if the APDU is closeApp",()=>{const e=new o.CloseAppCommand().getApdu().getRawApdu();expect(t.CommandUtils.isApduThatTriggersDisconnection(e)).toBe(!0)}),it("should return false if the APDU is not a known one",()=>{const e=new r.GetAppAndVersionCommand().getApdu().getRawApdu();expect(t.CommandUtils.isApduThatTriggersDisconnection(e)).toBe(!1)})})});
2
2
  //# sourceMappingURL=CommandUtils.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/command/utils/CommandUtils.test.ts"],
4
- "sourcesContent": ["import { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { CommandUtils } from \"./CommandUtils\";\n\ndescribe(\"CommandUtils\", () => {\n describe(\"static isSuccessResponse\", () => {\n it(\"should return true if the status code is 0x9000\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(true);\n });\n\n it(\"should return false if the status code is not 0x9000\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(false);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(false);\n });\n });\n\n describe(\"static isValidStatusCode\", () => {\n it(\"should return true if the status code is 2 bytes long\", () => {\n const statusCode = Uint8Array.from([0x90, 0x00]);\n\n expect(CommandUtils.isValidStatusCode(statusCode)).toBe(true);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const statusCode = Uint8Array.from([0x90]);\n\n expect(CommandUtils.isValidStatusCode(statusCode)).toBe(false);\n });\n });\n\n describe(\"static isLockedDeviceResponse\", () => {\n it(\"should return true if the status code is 0x5515\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(true);\n });\n\n it(\"should return false if the status code is not 0x5515\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(false);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(false);\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA6B,4CAE7BC,EAA6B,0BAE7B,SAAS,eAAgB,IAAM,CAC7B,SAAS,2BAA4B,IAAM,CACzC,GAAG,kDAAmD,IAAM,CAC1D,MAAMC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,kBAAkBA,CAAQ,CAAC,EAAE,KAAK,EAAI,CAC5D,CAAC,EAED,GAAG,uDAAwD,IAAM,CAC/D,MAAMA,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,kBAAkBA,CAAQ,CAAC,EAAE,KAAK,EAAK,CAC7D,CAAC,EAED,GAAG,6DAA8D,IAAM,CACrE,MAAMA,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,EAAI,CAAC,EAClC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,kBAAkBA,CAAQ,CAAC,EAAE,KAAK,EAAK,CAC7D,CAAC,CACH,CAAC,EAED,SAAS,2BAA4B,IAAM,CACzC,GAAG,wDAAyD,IAAM,CAChE,MAAMC,EAAa,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EAE/C,OAAO,eAAa,kBAAkBA,CAAU,CAAC,EAAE,KAAK,EAAI,CAC9D,CAAC,EAED,GAAG,6DAA8D,IAAM,CACrE,MAAMA,EAAa,WAAW,KAAK,CAAC,GAAI,CAAC,EAEzC,OAAO,eAAa,kBAAkBA,CAAU,CAAC,EAAE,KAAK,EAAK,CAC/D,CAAC,CACH,CAAC,EAED,SAAS,gCAAiC,IAAM,CAC9C,GAAG,kDAAmD,IAAM,CAC1D,MAAMD,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,GAAM,EAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,uBAAuBA,CAAQ,CAAC,EAAE,KAAK,EAAI,CACjE,CAAC,EAED,GAAG,uDAAwD,IAAM,CAC/D,MAAMA,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,uBAAuBA,CAAQ,CAAC,EAAE,KAAK,EAAK,CAClE,CAAC,EAED,GAAG,6DAA8D,IAAM,CACrE,MAAMA,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,GAAI,CAAC,EAClC,KAAM,WAAW,KAAK,CAAC,CAAC,CAC1B,CAAC,EAED,OAAO,eAAa,uBAAuBA,CAAQ,CAAC,EAAE,KAAK,EAAK,CAClE,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_ApduResponse", "import_CommandUtils", "response", "statusCode"]
4
+ "sourcesContent": ["import { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nimport { GetAppAndVersionCommand } from \"@api/command/os/GetAppAndVersionCommand\";\nimport { OpenAppCommand } from \"@api/command/os/OpenAppCommand\";\nimport { ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { CommandUtils } from \"./CommandUtils\";\n\ndescribe(\"CommandUtils\", () => {\n describe(\"static isSuccessResponse\", () => {\n it(\"should return true if the status code is 0x9000\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(true);\n });\n\n it(\"should return false if the status code is not 0x9000\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6e, 0x80]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(false);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isSuccessResponse(response)).toBe(false);\n });\n });\n\n describe(\"static isValidStatusCode\", () => {\n it(\"should return true if the status code is 2 bytes long\", () => {\n const statusCode = Uint8Array.from([0x90, 0x00]);\n\n expect(CommandUtils.isValidStatusCode(statusCode)).toBe(true);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const statusCode = Uint8Array.from([0x90]);\n\n expect(CommandUtils.isValidStatusCode(statusCode)).toBe(false);\n });\n });\n\n describe(\"static isLockedDeviceResponse\", () => {\n it(\"should return true if the status code is 0x5515\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(true);\n });\n\n it(\"should return false if the status code is not 0x5515\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(false);\n });\n\n it(\"should return false if the status code is not 2 bytes long\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90]),\n data: Uint8Array.from([]),\n });\n\n expect(CommandUtils.isLockedDeviceResponse(response)).toBe(false);\n });\n });\n\n describe(\"static isApduThatTriggersDisconnection\", () => {\n it(\"should return true if the APDU is openApp\", () => {\n const apdu = new OpenAppCommand({ appName: \"test\" })\n .getApdu()\n .getRawApdu();\n\n expect(CommandUtils.isApduThatTriggersDisconnection(apdu)).toBe(true);\n });\n\n it(\"should return true if the APDU is closeApp\", () => {\n const apdu = new CloseAppCommand().getApdu().getRawApdu();\n\n expect(CommandUtils.isApduThatTriggersDisconnection(apdu)).toBe(true);\n });\n\n it(\"should return false if the APDU is not a known one\", () => {\n const apdu = new GetAppAndVersionCommand().getApdu().getRawApdu();\n\n expect(CommandUtils.isApduThatTriggersDisconnection(apdu)).toBe(false);\n });\n });\n});\n"],
5
+ "mappings": "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",
6
+ "names": ["import_CloseAppCommand", "import_GetAppAndVersionCommand", "import_OpenAppCommand", "import_ApduResponse", "import_CommandUtils", "response", "statusCode", "apdu"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var m=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!p.call(t,r)&&r!==i&&a(t,r,{get:()=>e[r],enumerable:!(o=n(e,r))||o.enumerable});return t};var c=t=>m(a({},"__esModule",{value:!0}),t);var d={};module.exports=c(d);
1
+ "use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var m=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!p.call(t,r)&&r!==i&&n(t,r,{get:()=>e[r],enumerable:!(o=a(e,r))||o.enumerable});return t};var c=t=>m(n({},"__esModule",{value:!0}),t);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 Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n getMetadataForAppHashes: ManagerApiService[\"getAppsByHash\"];\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 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 ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\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};\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 o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var r=(t,e)=>{for(var n in e)o(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of i(e))!p.call(t,s)&&s!==n&&o(t,s,{get:()=>e[s],enumerable:!(a=c(e,s))||a.enumerable});return t};var v=t=>S(o({},"__esModule",{value:!0}),t);var j={};r(j,{makeDeviceActionInternalApiMock:()=>D});module.exports=v(j);const M=jest.fn(),k=jest.fn(),d=jest.fn(),f=jest.fn(),m=jest.fn();function D(){return{sendCommand:M,getDeviceSessionState:k,getDeviceSessionStateObservable:d,setDeviceSessionState:f,getMetadataForAppHashes:m}}0&&(module.exports={makeDeviceActionInternalApiMock});
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 p=n=>S(c({},"__esModule",{value:!0}),n);var D={};v(D,{makeDeviceActionInternalApiMock:()=>l});module.exports=p(D);const M=vi.fn(),k=vi.fn(),d=vi.fn(),f=vi.fn(),m=vi.fn(),g=vi.fn(),A=vi.fn();function l(){return{sendApdu:M,sendCommand:k,getDeviceSessionState:d,getDeviceSessionStateObservable:f,setDeviceSessionState:m,getManagerApiService:g,getSecureChannelService: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 InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendCommandMock = jest.fn();\nconst apiGetDeviceSessionStateMock = jest.fn();\nconst apiGetDeviceSessionStateObservableMock = jest.fn();\nconst setDeviceSessionStateMock = jest.fn();\nconst getMetadataForAppHashesMock = jest.fn();\n\nexport function makeDeviceActionInternalApiMock(): jest.Mocked<InternalApi> {\n return {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getMetadataForAppHashes: getMetadataForAppHashesMock,\n };\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAEA,MAAMI,EAAkB,KAAK,GAAG,EAC1BC,EAA+B,KAAK,GAAG,EACvCC,EAAyC,KAAK,GAAG,EACjDC,EAA4B,KAAK,GAAG,EACpCC,EAA8B,KAAK,GAAG,EAErC,SAASN,GAA4D,CAC1E,MAAO,CACL,YAAaE,EACb,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,wBAAyBC,CAC3B,CACF",
6
- "names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getMetadataForAppHashesMock"]
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 apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\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,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EAEnC,SAASR,GAAuD,CACrE,MAAO,CACL,SAAUE,EACV,YAAaC,EACb,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,CAC3B,CACF",
6
+ "names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendApduMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var k=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!A.call(t,i)&&i!==o&&p(t,i,{get:()=>e[i],enumerable:!(c=f(e,i))||c.enumerable});return t};var D=t=>y(p({},"__esModule",{value:!0}),t);var v={};k(v,{setupGetDeviceStatusMock:()=>h,setupGoToDashboardMock:()=>I,setupListAppsMock:()=>M});module.exports=D(v);var r=require("purify-ts"),n=require("xstate"),a=require("../../device-action/model/UserInteractionRequired"),s=require("../../device-action/os/Errors"),m=require("../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),d=require("../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),u=require("../../device-action/os/ListApps/ListAppsDeviceAction");const M=(t,e=!1)=>{u.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:jest.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.AllowListApps})})},done:{type:"final"}},output:()=>e?(0,r.Left)(new s.UnknownDAError("ListApps failed")):(0,r.Right)(t)}))}))},I=(t=!1)=>{d.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:jest.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:()=>t?(0,r.Left)(new s.UnknownDAError("GoToDashboard failed")):(0,r.Right)(void 0)}))}))},h=(t=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const e=jest.fn();for(const o of t)e.mockImplementationOnce(()=>"currentApp"in o?(0,r.Right)(o):(0,r.Left)(o));m.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:jest.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:e}))}))};0&&(module.exports={setupGetDeviceStatusMock,setupGoToDashboardMock,setupListAppsMock});
1
+ "use strict";var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!k.call(t,i)&&i!==o&&p(t,i,{get:()=>e[i],enumerable:!(m=f(e,i))||m.enumerable});return t};var D=t=>y(p({},"__esModule",{value:!0}),t);var h={};A(h,{setupGetDeviceStatusMock:()=>I,setupGoToDashboardMock:()=>v,setupListAppsMock:()=>M});module.exports=D(h);var r=require("purify-ts"),n=require("xstate"),a=require("../../device-action/model/UserInteractionRequired"),c=require("../../device-action/os/Errors"),s=require("../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),d=require("../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),u=require("../../device-action/os/ListApps/ListAppsDeviceAction");const M=(t,e=!1)=>{u.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.AllowListApps})})},done:{type:"final"}},output:()=>e?(0,r.Left)(new c.UnknownDAError("ListApps failed")):(0,r.Right)(t)}))}))},v=(t=!1)=>{d.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:()=>t?(0,r.Left)(new c.UnknownDAError("GoToDashboard failed")):(0,r.Right)(void 0)}))}))},I=(t=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const e=vi.fn();for(const o of t)e.mockImplementationOnce(()=>"currentApp"in o?(0,r.Right)(o):(0,r.Left)(o));s.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,n.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:e}))}))};0&&(module.exports={setupGetDeviceStatusMock,setupGoToDashboardMock,setupListAppsMock});
2
2
  //# sourceMappingURL=setupTestMachine.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/__test-utils__/setupTestMachine.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { type DmkError } from \"@api/Error\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as jest.Mock).mockImplementation(() => ({\n makeStateMachine: jest.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"ListApps failed\"))\n : Right(apps);\n },\n }),\n ),\n }));\n};\n\nexport const setupGoToDashboardMock = (error: boolean = false) => {\n (GoToDashboardDeviceAction as jest.Mock).mockImplementation(() => ({\n makeStateMachine: jest.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGoToDashboardDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GoToDashboard failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceStatusMock = (\n outputs: ReadonlyArray<\n { currentApp: string; currentAppVersion: string } | DmkError\n > = [\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n ],\n) => {\n const outputFn = jest.fn();\n\n for (const output of outputs) {\n outputFn.mockImplementationOnce(() =>\n \"currentApp\" in output ? Right(output) : Left(output),\n );\n }\n (GetDeviceStatusDeviceAction as jest.Mock).mockImplementation(() => ({\n makeStateMachine: jest.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceStatusDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,2BAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAA4B,qBAC5BC,EAAsC,kBAEtCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAA4C,6EAC5CC,EAA0C,yEAC1CC,EAAqC,+DAO9B,MAAMR,EAAoB,CAACS,EAAaC,EAAQ,KAAU,CAC9D,uBAAmC,mBAAmB,KAAO,CAC5D,iBAAkB,KAAK,GAAG,EAAE,mBAAmB,OAC7C,iBAAc,CACZ,GAAI,2BACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,aACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,iBAAiB,CAAC,KAC1C,SAAMD,CAAI,CAElB,CAAC,CACH,CACF,EAAE,CACJ,EAEaV,EAAyB,CAACW,EAAiB,KAAU,CAC/D,4BAAwC,mBAAmB,KAAO,CACjE,iBAAkB,KAAK,GAAG,EAAE,mBAAmB,OAC7C,iBAAc,CACZ,GAAI,gCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,IACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,sBAAsB,CAAC,KAC/C,SAAM,MAAS,CAEvB,CAAC,CACH,CACF,EAAE,CACJ,EAEaZ,EAA2B,CACtCa,EAEI,CACF,CACE,WAAY,QACZ,kBAAmB,OACrB,CACF,IACG,CACH,MAAMC,EAAW,KAAK,GAAG,EAEzB,UAAWC,KAAUF,EACnBC,EAAS,uBAAuB,IAC9B,eAAgBC,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACtD,EAED,8BAA0C,mBAAmB,KAAO,CACnE,iBAAkB,KAAK,GAAG,EAAE,mBAAmB,OAC7C,iBAAc,CACZ,GAAI,kCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,IACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQD,CACV,CAAC,CACH,CACF,EAAE,CACJ",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport { type DmkError } from \"@api/Error\";\n\nimport { type BTC_APP } from \"./data\";\n\ntype App = typeof BTC_APP;\n\nexport const setupListAppsMock = (apps: App[], error = false) => {\n (ListAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListAppsDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"ListApps failed\"))\n : Right(apps);\n },\n }),\n ),\n }));\n};\n\nexport const setupGoToDashboardMock = (error: boolean = false) => {\n (GoToDashboardDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGoToDashboardDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: () => {\n return error\n ? Left(new UnknownDAError(\"GoToDashboard failed\"))\n : Right(undefined);\n },\n }),\n ),\n }));\n};\n\nexport const setupGetDeviceStatusMock = (\n outputs: ReadonlyArray<\n { currentApp: string; currentAppVersion: string } | DmkError\n > = [\n {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n ],\n) => {\n const outputFn = vi.fn();\n\n for (const output of outputs) {\n outputFn.mockImplementationOnce(() =>\n \"currentApp\" in output ? Right(output) : Left(output),\n );\n }\n (GetDeviceStatusDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockGetDeviceStatusDeviceAction\",\n initial: \"ready\",\n states: {\n ready: {\n after: {\n 0: \"done\",\n },\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n },\n done: {\n type: \"final\",\n },\n },\n output: outputFn,\n }),\n ),\n }));\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,2BAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAA4B,qBAE5BC,EAAsC,kBAEtCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAA4C,6EAC5CC,EAA0C,yEAC1CC,EAAqC,+DAO9B,MAAMR,EAAoB,CAACS,EAAaC,EAAQ,KAAU,CAC9D,uBAA8B,mBAAmB,KAAO,CACvD,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,2BACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,aACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,iBAAiB,CAAC,KAC1C,SAAMD,CAAI,CAElB,CAAC,CACH,CACF,EAAE,CACJ,EAEaV,EAAyB,CAACW,EAAiB,KAAU,CAC/D,4BAAmC,mBAAmB,KAAO,CAC5D,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,gCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,IACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IACCA,KACH,QAAK,IAAI,iBAAe,sBAAsB,CAAC,KAC/C,SAAM,MAAS,CAEvB,CAAC,CACH,CACF,EAAE,CACJ,EAEaZ,EAA2B,CACtCa,EAEI,CACF,CACE,WAAY,QACZ,kBAAmB,OACrB,CACF,IACG,CACH,MAAMC,EAAW,GAAG,GAAG,EAEvB,UAAWC,KAAUF,EACnBC,EAAS,uBAAuB,IAC9B,eAAgBC,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACtD,EAED,8BAAqC,mBAAmB,KAAO,CAC9D,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,OAC3C,iBAAc,CACZ,GAAI,kCACJ,QAAS,QACT,OAAQ,CACN,MAAO,CACL,MAAO,CACL,EAAG,MACL,EACA,SAAO,UAAO,CACZ,kBAAmB,KAAO,CACxB,wBAAyB,0BAAwB,IACnD,EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQD,CACV,CAAC,CACH,CACF,EAAE,CACJ",
6
6
  "names": ["setupTestMachine_exports", "__export", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupListAppsMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_ListAppsDeviceAction", "apps", "error", "outputs", "outputFn", "output"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var s=(t,e)=>{for(var i in e)o(t,i,{get:e[i],enumerable:!0})},A=(t,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!l.call(t,r)&&r!==i&&o(t,r,{get:()=>e[r],enumerable:!(c=p(e,r))||c.enumerable});return t};var D=t=>A(o({},"__esModule",{value:!0}),t);var I={};s(I,{testDeviceActionStates:()=>v});module.exports=D(I);function v(t,e,i,c){const r=[],{observable:a,cancel:u}=t._execute(i);return a.subscribe({next:n=>{r.push(n)},error:n=>{c(n)},complete:()=>{try{expect(r).toEqual(e),c()}catch(n){c(n)}}}),{observable:a,cancel:u}}0&&(module.exports={testDeviceActionStates});
1
+ "use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},A=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!l.call(t,r)&&r!==o&&c(t,r,{get:()=>e[r],enumerable:!(n=m(e,r))||n.enumerable});return t};var d=t=>A(c({},"__esModule",{value:!0}),t);var I={};v(I,{testDeviceActionStates:()=>D});module.exports=d(I);function D(t,e,o,{onDone:n,onError:r}){const a=[],{observable:u,cancel:p}=t._execute(o);return u.subscribe({next:i=>{a.push(i)},error:i=>{r(i)},complete:()=>{try{expect(a).toEqual(e),n()}catch(i){r(i)}}}),{observable:u,cancel:p}}0&&(module.exports={testDeviceActionStates});
2
2
  //# sourceMappingURL=testDeviceActionStates.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/__test-utils__/testDeviceActionStates.ts"],
4
- "sourcesContent": ["import {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\n\n/**\n * Test that the states emitted by a device action match the expected states.\n * @param deviceAction The device action to test.\n * @param expectedStates The expected states.\n * @param internalApi\n * @param done The Jest done callback.\n */\nexport function testDeviceActionStates<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n>(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n expectedStates: Array<DeviceActionState<Output, Error, IntermediateValue>>,\n internalApi: InternalApi,\n done: jest.DoneCallback,\n) {\n const observedStates: Array<\n DeviceActionState<Output, Error, IntermediateValue>\n > = [];\n\n const { observable, cancel } = deviceAction._execute(internalApi);\n observable.subscribe({\n next: (state) => {\n observedStates.push(state);\n },\n error: (error) => {\n done(error);\n },\n complete: () => {\n try {\n expect(observedStates).toEqual(expectedStates);\n done();\n } catch (e) {\n done(e);\n }\n },\n });\n return { observable, cancel };\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAeO,SAASE,EAMdE,EACAC,EACAC,EACAC,EACA,CACA,MAAMC,EAEF,CAAC,EAEC,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAIN,EAAa,SAASE,CAAW,EAChE,OAAAG,EAAW,UAAU,CACnB,KAAOE,GAAU,CACfH,EAAe,KAAKG,CAAK,CAC3B,EACA,MAAQC,GAAU,CAChBL,EAAKK,CAAK,CACZ,EACA,SAAU,IAAM,CACd,GAAI,CACF,OAAOJ,CAAc,EAAE,QAAQH,CAAc,EAC7CE,EAAK,CACP,OAASM,EAAG,CACVN,EAAKM,CAAC,CACR,CACF,CACF,CAAC,EACM,CAAE,WAAAJ,EAAY,OAAAC,CAAO,CAC9B",
6
- "names": ["testDeviceActionStates_exports", "__export", "testDeviceActionStates", "__toCommonJS", "deviceAction", "expectedStates", "internalApi", "done", "observedStates", "observable", "cancel", "state", "error", "e"]
4
+ "sourcesContent": ["import {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\n\n/**\n * Test that the states emitted by a device action match the expected states.\n * @param deviceAction The device action to test.\n * @param expectedStates The expected states.\n * @param internalApi\n * @param callbacks { onDone, onError } The callbacks to call when the test is done or an error occurs.\n */\nexport function testDeviceActionStates<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n>(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n expectedStates: Array<DeviceActionState<Output, Error, IntermediateValue>>,\n internalApi: InternalApi,\n {\n onDone,\n onError,\n }: {\n onDone: () => void;\n onError: (error: Error) => void;\n },\n) {\n const observedStates: Array<\n DeviceActionState<Output, Error, IntermediateValue>\n > = [];\n\n const { observable, cancel } = deviceAction._execute(internalApi);\n\n observable.subscribe({\n next: (state) => {\n observedStates.push(state);\n },\n error: (error) => {\n onError(error);\n },\n complete: () => {\n try {\n expect(observedStates).toEqual(expectedStates);\n onDone();\n } catch (e) {\n onError(e as Error);\n }\n },\n });\n\n return { observable, cancel };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAeO,SAASE,EAMdE,EACAC,EACAC,EACA,CACE,OAAAC,EACA,QAAAC,CACF,EAIA,CACA,MAAMC,EAEF,CAAC,EAEC,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAIP,EAAa,SAASE,CAAW,EAEhE,OAAAI,EAAW,UAAU,CACnB,KAAOE,GAAU,CACfH,EAAe,KAAKG,CAAK,CAC3B,EACA,MAAQC,GAAU,CAChBL,EAAQK,CAAK,CACf,EACA,SAAU,IAAM,CACd,GAAI,CACF,OAAOJ,CAAc,EAAE,QAAQJ,CAAc,EAC7CE,EAAO,CACT,OAASO,EAAG,CACVN,EAAQM,CAAU,CACpB,CACF,CACF,CAAC,EAEM,CAAE,WAAAJ,EAAY,OAAAC,CAAO,CAC9B",
6
+ "names": ["testDeviceActionStates_exports", "__export", "testDeviceActionStates", "__toCommonJS", "deviceAction", "expectedStates", "internalApi", "onDone", "onError", "observedStates", "observable", "cancel", "state", "error", "e"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var I=(r,t)=>{for(var s in t)o(r,s,{get:t[s],enumerable:!0})},C=(r,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!m.call(r,n)&&n!==s&&o(r,n,{get:()=>t[n],enumerable:!(e=A(t,n))||e.enumerable});return r};var d=r=>C(o({},"__esModule",{value:!0}),r);var S={};I(S,{CallTaskInAppDeviceAction:()=>D});module.exports=d(S);var p=require("purify-ts"),a=require("xstate"),l=require("../../../command/model/CommandResult"),i=require("../../../device-action/model/UserInteractionRequired"),c=require("../../../device-action/os/Errors"),u=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),k=require("../../../device-action/xstate-utils/XStateDeviceAction");class D extends k.XStateDeviceAction{makeStateMachine(t){const{callTask:s}=this.extractDependencies(t);return(0,a.setup)({types:{input:{},context:{},output:{}},actors:{callTask:(0,a.fromPromise)(s),openAppStateMachine:new u.OpenAppDeviceAction({input:{appName:this.input.appName,compatibleAppNames:this.input.compatibleAppNames}}).makeStateMachine(t)},guards:{noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:(0,a.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"OpenAppDeviceAction",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.None},_internalState:{taskResponse:null,error:null}}),states:{OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName,compatibleAppNames:this.input.compatibleAppNames},src:"openAppStateMachine",onSnapshot:{actions:(0,a.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:(0,a.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:n=>({...e.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:(0,a.assign)({intermediateValue:{requiredUserInteraction:i.UserInteractionRequired.None}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[(0,a.assign)({_internalState:({event:e,context:n})=>(0,l.isSuccessCommandResult)(e.output)?{...n._internalState,taskResponse:e.output.data}:{...n._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.taskResponse?(0,p.Right)(e._internalState.taskResponse):(0,p.Left)(e._internalState.error||new c.UnknownDAError("No error in final state"))})}extractDependencies(t){return{callTask:s=>s.input(t)}}}0&&(module.exports={CallTaskInAppDeviceAction});
2
+ //# sourceMappingURL=CallTaskInAppDeviceAction.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.ts"],
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAInput,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAInternalState,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, calls a task\n * in the app.\n * The output will be the result of the task.\n *\n * ```ts\n * input: {\n * appName: string;\n * task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new CallTaskInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * task: async (internalApi: InternalApi) => internalApi.sendCommand(new MyAppSpecificCommand()),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class CallTaskInAppDeviceAction<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n > {\n type types = StateMachineTypes<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >;\n\n const { callTask } = this.extractDependencies(internalAPI);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n callTask: fromPromise(callTask),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n compatibleAppNames: this.input.compatibleAppNames,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"CallTaskInAppDeviceAction\",\n initial: \"OpenAppDeviceAction\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n taskResponse: null,\n error: null,\n },\n };\n },\n states: {\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n compatibleAppNames: this.input.compatibleAppNames,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"CallTask\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n CallTask: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"callTask\",\n src: \"callTask\",\n input: (_: { context: types[\"context\"] }) => _.context.input.task,\n onDone: {\n target: \"CallTaskResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n taskResponse: event.output.data,\n };\n }\n return {\n ...context._internalState,\n error: event.output.error,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CallTaskResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.taskResponse\n ? Right(context._internalState.taskResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n callTask: (_: {\n input: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n }): Promise<CommandResult<TaskResponse, TaskErrorCodes>> =>\n _.input(internalApi),\n };\n }\n}\n"],
5
+ "mappings": "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",
6
+ "names": ["CallTaskInAppDeviceAction_exports", "__export", "CallTaskInAppDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_XStateDeviceAction", "internalAPI", "callTask", "context", "_", "input", "error", "event", "internalApi"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var k=require("purify-ts"),y=require("xstate"),w=require("../../../apdu/utils/ApduBuilder"),u=require("../../../command/model/CommandResult"),s=require("../../../device-action/__test-utils__/makeInternalApi"),A=require("../../../device-action/__test-utils__/testDeviceActionStates"),n=require("../../../device-action/model/DeviceActionState"),e=require("../../../device-action/model/UserInteractionRequired"),C=require("../../../device-action/os/Errors"),M=require("../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),v=require("../../../../../src"),d=require("./CallTaskInAppDeviceAction");vi.mock("@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction",async t=>{const o=await t();return{...o,OpenAppDeviceAction:vi.fn(()=>({...o.OpenAppDeviceAction,makeStateMachine:vi.fn()}))}});const l=t=>{M.OpenAppDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,y.createMachine)({initial:"pending",states:{pending:{entry:(0,y.assign)({intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}}),after:{0:"done"}},done:{type:"final"}},output:()=>t?(0,k.Left)(t):(0,k.Right)(void 0)}))}))};describe("CallTaskInAppDeviceAction",()=>{const t=vi.fn(),o=()=>({callTask:t}),{sendCommand:D}=(0,s.makeDeviceActionInternalApiMock)(),p={paramString:"aParameter",paramNumber:1234},I={aNumber:5678,aString:"mockedResponseString"};beforeEach(()=>{vi.resetAllMocks()}),describe("without mocking extractDependencies",()=>{it("should call sendCommand on internalApi with the correct parameters",async()=>{l(),D.mockResolvedValue((0,u.CommandResultFactory)({data:void 0}));const i=new d.CallTaskInAppDeviceAction({input:{task:async r=>await r.sendCommand(new c(p)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}});await new Promise((r,a)=>{i._execute((0,s.makeDeviceActionInternalApiMock)()).observable.subscribe({error:()=>a(),complete:()=>r(),next:()=>{}})}),expect(D).toHaveBeenCalledWith(new c(p))})}),describe("error cases",()=>{it("should error and output the error if the open app fails",()=>new Promise((i,r)=>{l(new C.UnknownDAError("Mocked error"));const a=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Error,error:new C.UnknownDAError("Mocked error")}];(0,A.testDeviceActionStates)(new d.CallTaskInAppDeviceAction({input:{task:async m=>await m.sendCommand(new c(p)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}}),a,(0,s.makeDeviceActionInternalApiMock)(),{onDone:i,onError:r})})),it("should error and output an error if the call task fails",()=>new Promise((i,r)=>{l(),t.mockResolvedValue((0,u.CommandResultFactory)({error:new v.UnknownDeviceExchangeError("Mocked error")}));const a=new d.CallTaskInAppDeviceAction({input:{task:async f=>await f.sendCommand(new c(p)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}});vi.spyOn(a,"extractDependencies").mockImplementation(o);const m=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}},{status:n.DeviceActionStatus.Error,error:new v.UnknownDeviceExchangeError("Mocked error")}];(0,A.testDeviceActionStates)(a,m,(0,s.makeDeviceActionInternalApiMock)(),{onDone:i,onError:r})}))}),describe("success cases",()=>{it("should succeed and output the command result if the send command succeeds",()=>new Promise((i,r)=>{l(),t.mockResolvedValue((0,u.CommandResultFactory)({data:I}));const a=new d.CallTaskInAppDeviceAction({input:{task:async f=>await f.sendCommand(new c(p)),appName:"MyApp",requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}});vi.spyOn(a,"extractDependencies").mockImplementation(o);const m=[{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.None}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.ConfirmOpenApp}},{status:n.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:e.UserInteractionRequired.VerifyAddress}},{status:n.DeviceActionStatus.Completed,output:I}];(0,A.testDeviceActionStates)(a,m,(0,s.makeDeviceActionInternalApiMock)(),{onDone:i,onError:r})}))})});class c{params;constructor(o){this.params=o}getApdu(){return new w.ApduBuilder({cla:0,ins:1,p1:2,p2:3}).add32BitUIntToData(this.params.paramNumber).addAsciiStringToData(this.params.paramString).build()}parseResponse(){return(0,u.CommandResultFactory)({data:{aNumber:1,aString:"aString"}})}}
2
+ //# sourceMappingURL=CallTaskInAppDeviceAction.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.ts"],
4
+ "sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports:0 */\nimport { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type Command } from \"@api/types\";\nimport { UnknownDeviceExchangeError } from \"@root/src\";\n\nimport { CallTaskInAppDeviceAction } from \"./CallTaskInAppDeviceAction\";\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\nvi.mock(\n \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\",\n async (importOriginal) => {\n const original =\n await importOriginal<\n typeof import(\"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\")\n >();\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n ...original.OpenAppDeviceAction,\n makeStateMachine: vi.fn(),\n })),\n };\n },\n);\n\nconst setupOpenAppDAMock = (error?: unknown) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"pending\",\n states: {\n pending: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => (error ? Left(error) : Right(undefined)),\n }),\n ),\n }));\n};\n\ndescribe(\"CallTaskInAppDeviceAction\", () => {\n const callMyTask = vi.fn();\n\n const extractDependenciesMock = () => ({\n callTask: callMyTask,\n });\n\n const { sendCommand: apiSendCommandMock } = makeDeviceActionInternalApiMock();\n\n const commandParams = {\n paramString: \"aParameter\",\n paramNumber: 1234,\n };\n const mockedCommandResponse = {\n aNumber: 5678,\n aString: \"mockedResponseString\",\n };\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"without mocking extractDependencies\", () => {\n it(\"should call sendCommand on internalApi with the correct parameters\", async () => {\n setupOpenAppDAMock();\n apiSendCommandMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n });\n await new Promise<void>((resolve, reject) => {\n deviceAction\n ._execute(makeDeviceActionInternalApiMock())\n .observable.subscribe({\n error: () => reject(),\n complete: () => resolve(),\n next: () => {},\n });\n });\n\n expect(apiSendCommandMock).toHaveBeenCalledWith(\n new TestCommand(commandParams),\n );\n });\n });\n\n describe(\"error cases\", () => {\n it(\"should error and output the error if the open app fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock(new UnknownDAError(\"Mocked error\"));\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n }),\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error and output an error if the call task fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should succeed and output the command result if the send command succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n callMyTask.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n await internalApi.sendCommand(new TestCommand(commandParams)),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandCallTaskDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n\ntype MyCommandResponse = {\n aNumber: number;\n aString: string;\n};\n\ntype MyCommandParams = {\n paramString: string;\n paramNumber: number;\n};\n\nclass TestCommand implements Command<MyCommandResponse, MyCommandParams> {\n params: MyCommandParams;\n constructor(params: MyCommandParams) {\n this.params = params;\n }\n getApdu(): Apdu {\n return new ApduBuilder({ cla: 0x00, ins: 0x01, p1: 0x02, p2: 0x03 })\n .add32BitUIntToData(this.params.paramNumber)\n .addAsciiStringToData(this.params.paramString)\n .build();\n }\n parseResponse() {\n return CommandResultFactory({ data: { aNumber: 1, aString: \"aString\" } });\n }\n}\n\ntype MyCommandCallTaskDAState = DeviceActionState<\n CallTaskInAppDAOutput<MyCommandResponse>,\n CallTaskInAppDAError<UnknownDAError>,\n CallTaskInAppDAIntermediateValue<\n UserInteractionRequired.None | UserInteractionRequired.VerifyAddress\n >\n>;\n"],
5
+ "mappings": "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",
6
+ "names": ["import_purify_ts", "import_xstate", "import_ApduBuilder", "import_CommandResult", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_OpenAppDeviceAction", "import_src", "import_CallTaskInAppDeviceAction", "importOriginal", "original", "setupOpenAppDAMock", "error", "callMyTask", "extractDependenciesMock", "apiSendCommandMock", "commandParams", "mockedCommandResponse", "deviceAction", "internalApi", "TestCommand", "resolve", "reject", "expectedStates", "params"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of t(e))!l.call(r,p)&&p!==n&&o(r,p,{get:()=>e[p],enumerable:!(a=s(e,p))||a.enumerable});return r};var d=r=>A(o({},"__esModule",{value:!0}),r);var i={};module.exports=d(i);
2
+ //# sourceMappingURL=CallTaskInAppDeviceActionTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.ts"],
4
+ "sourcesContent": ["import {\n type CommandErrorResult,\n type CommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport {\n type OpenAppDAError,\n type OpenAppDAIntermediateValue,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\n\nexport type CallTaskInAppDAOutput<TaskResponse> = TaskResponse;\n\nexport type CallTaskInAppDAInput<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction,\n> = {\n readonly task: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n readonly appName: string;\n readonly requiredUserInteraction: UserInteraction;\n readonly compatibleAppNames?: string[];\n};\n\nexport type CallTaskInAppDAError<TaskErrorCodes = void> =\n | OpenAppDAError\n | CommandErrorResult<TaskErrorCodes>[\"error\"];\n\nexport type CallTaskInAppDAIntermediateValue<UserInteraction> =\n | { readonly requiredUserInteraction: UserInteraction }\n | OpenAppDAIntermediateValue;\n\nexport type CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes> = {\n readonly taskResponse: TaskResponse | null;\n readonly error: CallTaskInAppDAError<TaskErrorCodes> | null;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["CallTaskInAppDeviceActionTypes_exports", "__toCommonJS"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var u=require("rxjs"),S=require("../../../command/model/CommandResult"),h=require("../../../command/utils/GlobalCommandError"),i=require("../../../device/DeviceStatus"),a=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),c=require("../../../device-action/model/UserInteractionRequired"),v=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),p=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const A=jest.fn(),l=jest.fn(),C=jest.fn(),b=jest.fn(),y=jest.fn();function D(){return{getAppAndVersion:A,getDeviceSessionState:l,waitForDeviceUnlock:C,setDeviceSessionState:b,isDeviceOnboarded:y}}const{sendCommand:O,getDeviceSessionState:R,getDeviceSessionStateObservable:V}=(0,a.makeDeviceActionInternalApiMock)();beforeEach(()=>{jest.resetAllMocks(),y.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",r=>{const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED}),O.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should run the device action with a locked device",r=>{const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[]}),V.mockImplementation(()=>new u.Observable(o=>{const m=(0,u.interval)(50).subscribe({next:k=>{k>2?(o.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[]}),o.complete()):o.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[]})}});return()=>{m.unsubscribe()}})),O.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),describe("success cases",()=>{it("should return the device status if the device is unlocked",r=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});jest.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should return the device status if the device is locked and the user unlocks the device",r=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),C.mockImplementation(()=>new u.Observable(o=>{const m=(0,u.interval)(50).subscribe({next:k=>{k>2?(o.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),o.complete()):o.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{m.unsubscribe()}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",r=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),y.mockReturnValue(!1);const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{error:new v.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the device is locked and the user does not unlock",r=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),V.mockImplementation(()=>new u.Observable(o=>{const m=(0,u.interval)(200).subscribe({next:()=>{o.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[]})}});return()=>{m.unsubscribe()}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new v.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if the GetAppAndVersion command fails",r=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new h.GlobalCommandError({...h.GLOBAL_ERRORS[5501],errorCode:"5501"});A.mockResolvedValue((0,S.CommandResultFactory)({error:e})),C.mockImplementation(()=>new u.Observable(m=>{const k=(0,u.interval)(50).subscribe({next:f=>{f>2?(m.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),m.complete()):m.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{k.unsubscribe()}}));const n=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(n,"extractDependencies").mockReturnValue(D());const o=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(n,o,(0,a.makeDeviceActionInternalApiMock)(),r)}),it("should end in an error if getAppAndVersion actor throws an error",r=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockImplementation(()=>{throw new v.UnknownDAError("error")}),C.mockImplementation(()=>new u.Observable(o=>{o.complete()}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});jest.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new v.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r)})}),it("should emit a stopped state if the action is cancelled",r=>{R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[]}),O.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new p.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:o}=(0,d.testDeviceActionStates)(e,n,(0,a.makeDeviceActionInternalApiMock)(),r);o()})});
1
+ "use strict";var d=require("rxjs"),S=require("../../../command/model/CommandResult"),y=require("../../../command/utils/GlobalCommandError"),D=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),u=require("../../../device-action/__test-utils__/makeInternalApi"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),a=require("../../../device-action/model/UserInteractionRequired"),A=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),m=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const C=vi.fn(),l=vi.fn(),O=vi.fn(),f=vi.fn(),R=vi.fn();function k(){return{getAppAndVersion:C,getDeviceSessionState:l,waitForDeviceUnlock:O,setDeviceSessionState:f,isDeviceOnboarded:R}}const{sendCommand:V,getDeviceSessionState:E,getDeviceSessionStateObservable:w}=(0,u.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),R.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((r,o)=>{const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});E.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:D.DeviceModelId.NANO_X}),V.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});E.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X}),w.mockImplementation(()=>new d.Observable(c=>{const v=(0,d.interval)(50).subscribe({next:h=>{h>2?(c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X}),c.complete()):c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X})}});return()=>{v.unsubscribe()}})),V.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),O.mockImplementation(()=>new d.Observable(c=>{const v=(0,d.interval)(50).subscribe({next:h=>{h>2?(c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),c.complete()):c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{v.unsubscribe()}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),R.mockReturnValue(!1);const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{error:new A.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),w.mockImplementation(()=>new d.Observable(c=>{const v=(0,d.interval)(200).subscribe({next:()=>{c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X})}});return()=>{v.unsubscribe()}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new A.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new y.GlobalCommandError({...y.GLOBAL_ERRORS[5501],errorCode:"5501"});C.mockResolvedValue((0,S.CommandResultFactory)({error:e})),O.mockImplementation(()=>new d.Observable(v=>{const h=(0,d.interval)(50).subscribe({next:b=>{b>2?(v.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),v.complete()):v.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{h.unsubscribe()}}));const n=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(k());const c=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(n,c,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{l.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockImplementation(()=>{throw new A.UnknownDAError("error")}),O.mockImplementation(()=>new d.Observable(c=>{c.complete()}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new A.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{E.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X}),V.mockResolvedValue((0,S.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:c}=(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});c()}))});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map