@ledgerhq/device-management-kit 0.0.0-rn-hid-20250221115747 → 0.0.0-rn-ble-logs-20250416162013

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 (589) hide show
  1. package/README.md +58 -8
  2. package/lib/cjs/package.json +4 -4
  3. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  4. package/lib/cjs/src/api/DeviceManagementKit.js.map +3 -3
  5. package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
  6. package/lib/cjs/src/api/DeviceManagementKit.test.js.map +3 -3
  7. package/lib/cjs/src/api/DeviceManagementKitBuilder.js +1 -1
  8. package/lib/cjs/src/api/DeviceManagementKitBuilder.js.map +2 -2
  9. package/lib/cjs/src/api/DmkConfig.js +1 -1
  10. package/lib/cjs/src/api/DmkConfig.js.map +1 -1
  11. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js +1 -1
  12. package/lib/cjs/src/api/command/os/GetOsVersionCommand.js.map +3 -3
  13. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js +2 -0
  14. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.js.map +7 -0
  15. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js +2 -0
  16. package/lib/cjs/src/api/command/os/SecureElementFlagsParser.test.js.map +7 -0
  17. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  18. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
  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/device/SecureElementFlags.js +2 -0
  22. package/lib/cjs/src/api/device/SecureElementFlags.js.map +7 -0
  23. package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
  24. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  25. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  26. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  27. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  28. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  29. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  30. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  31. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  32. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
  33. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  34. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  35. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  36. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +2 -2
  37. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  38. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  39. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  40. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  41. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  42. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
  43. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js.map +1 -1
  44. package/lib/cjs/src/api/device-session/DeviceSessionState.js +1 -1
  45. package/lib/cjs/src/api/device-session/DeviceSessionState.js.map +1 -1
  46. package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.js +2 -0
  47. package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.js.map +7 -0
  48. package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js +2 -0
  49. package/lib/cjs/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js.map +7 -0
  50. package/lib/cjs/src/api/index.js +1 -1
  51. package/lib/cjs/src/api/index.js.map +3 -3
  52. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  53. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +3 -3
  54. package/lib/cjs/src/api/secure-channel/constants.js +2 -0
  55. package/lib/cjs/src/api/secure-channel/constants.js.map +7 -0
  56. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +2 -0
  57. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +7 -0
  58. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js +2 -0
  59. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js.map +7 -0
  60. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js +2 -0
  61. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +7 -0
  62. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +2 -0
  63. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +7 -0
  64. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.test.js +2 -0
  65. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.test.js.map +7 -0
  66. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js +2 -0
  67. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js.map +7 -0
  68. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +2 -0
  69. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +7 -0
  70. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.test.js +2 -0
  71. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.test.js.map +7 -0
  72. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js +2 -0
  73. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +7 -0
  74. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +2 -0
  75. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +7 -0
  76. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.test.js +2 -0
  77. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.test.js.map +7 -0
  78. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js +2 -0
  79. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js.map +7 -0
  80. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +2 -0
  81. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +7 -0
  82. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +2 -0
  83. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +7 -0
  84. package/lib/cjs/src/api/secure-channel/task/types.js +2 -0
  85. package/lib/cjs/src/api/secure-channel/task/types.js.map +7 -0
  86. package/lib/cjs/src/api/secure-channel/types.js +2 -0
  87. package/lib/cjs/src/api/secure-channel/types.js.map +7 -0
  88. package/lib/cjs/src/api/secure-channel/utils.js +2 -0
  89. package/lib/cjs/src/api/secure-channel/utils.js.map +7 -0
  90. package/lib/cjs/src/api/secure-channel/utils.test.js +2 -0
  91. package/lib/cjs/src/api/secure-channel/utils.test.js.map +7 -0
  92. package/lib/cjs/src/api/transport/model/DeviceConnection.js +1 -1
  93. package/lib/cjs/src/api/transport/model/DeviceConnection.js.map +1 -1
  94. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  95. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  96. package/lib/cjs/src/api/transport/model/Errors.js +1 -1
  97. package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
  98. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.test.js +1 -1
  99. package/lib/cjs/src/api/transport/model/TransportConnectedDevice.test.js.map +3 -3
  100. package/lib/cjs/src/api/types.js +1 -1
  101. package/lib/cjs/src/api/types.js.map +1 -1
  102. package/lib/cjs/src/di.js +1 -1
  103. package/lib/cjs/src/di.js.map +2 -2
  104. package/lib/cjs/src/internal/device-session/data/DeviceSessionRefresherConst.js +1 -1
  105. package/lib/cjs/src/internal/device-session/data/DeviceSessionRefresherConst.js.map +3 -3
  106. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
  107. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  108. package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js +1 -1
  109. package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
  110. package/lib/cjs/src/internal/device-session/model/DevicePinger.js +2 -0
  111. package/lib/cjs/src/internal/device-session/model/DevicePinger.js.map +7 -0
  112. package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js +2 -0
  113. package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js.map +7 -0
  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/DeviceSessionEventDispatcher.js +2 -0
  119. package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +7 -0
  120. package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.test.js +2 -0
  121. package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.test.js.map +7 -0
  122. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  123. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
  124. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  125. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +3 -3
  126. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js +2 -0
  127. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js.map +7 -0
  128. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js +2 -0
  129. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +7 -0
  130. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
  131. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
  132. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  133. package/lib/cjs/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  134. package/lib/cjs/src/internal/device-session/service/MutexService.js +2 -0
  135. package/lib/cjs/src/internal/device-session/service/MutexService.js.map +7 -0
  136. package/lib/cjs/src/internal/device-session/service/MutexService.test.js +2 -0
  137. package/lib/cjs/src/internal/device-session/service/MutexService.test.js.map +7 -0
  138. package/lib/cjs/src/internal/device-session/service/RefresherService.js +2 -0
  139. package/lib/cjs/src/internal/device-session/service/RefresherService.js.map +7 -0
  140. package/lib/cjs/src/internal/device-session/service/RefresherService.test.js +2 -0
  141. package/lib/cjs/src/internal/device-session/service/RefresherService.test.js.map +7 -0
  142. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
  143. package/lib/cjs/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +3 -3
  144. package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
  145. package/lib/cjs/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +3 -3
  146. package/lib/cjs/src/internal/device-session/utils/deviceSessionUtils.js +2 -0
  147. package/lib/cjs/src/internal/device-session/utils/deviceSessionUtils.js.map +7 -0
  148. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  149. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  150. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  151. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  152. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
  153. package/lib/cjs/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +3 -3
  154. package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
  155. package/lib/cjs/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +3 -3
  156. package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
  157. package/lib/cjs/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +3 -3
  158. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js +1 -1
  159. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js.map +3 -3
  160. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js +1 -1
  161. package/lib/cjs/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js.map +3 -3
  162. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.js +1 -1
  163. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.js.map +3 -3
  164. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
  165. package/lib/cjs/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +3 -3
  166. package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.js +1 -1
  167. package/lib/cjs/src/internal/discovery/use-case/StartDiscoveringUseCase.js.map +2 -2
  168. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
  169. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
  170. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
  171. package/lib/cjs/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
  172. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js +1 -1
  173. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
  174. package/lib/cjs/src/internal/manager-api/data/ManagerApiDto.js +1 -1
  175. package/lib/cjs/src/internal/manager-api/data/ManagerApiDto.js.map +1 -1
  176. package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
  177. package/lib/cjs/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
  178. package/lib/cjs/src/internal/manager-api/di/managerApiModule.js +1 -1
  179. package/lib/cjs/src/internal/manager-api/di/managerApiModule.js.map +3 -3
  180. package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js +1 -1
  181. package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
  182. package/lib/cjs/src/internal/manager-api/di/managerApiTypes.js +1 -1
  183. package/lib/cjs/src/internal/manager-api/di/managerApiTypes.js.map +2 -2
  184. package/lib/cjs/src/internal/manager-api/model/Application.js +1 -1
  185. package/lib/cjs/src/internal/manager-api/model/Application.js.map +1 -1
  186. package/lib/cjs/src/internal/manager-api/model/Const.js +1 -1
  187. package/lib/cjs/src/internal/manager-api/model/Const.js.map +3 -3
  188. package/lib/cjs/src/internal/manager-api/model/Params.js +2 -0
  189. package/lib/cjs/src/internal/manager-api/model/Params.js.map +7 -0
  190. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
  191. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js.map +3 -3
  192. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  193. package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  194. package/lib/cjs/src/internal/manager-api/service/ManagerApiService.js +1 -1
  195. package/lib/cjs/src/internal/manager-api/service/ManagerApiService.js.map +1 -1
  196. package/lib/cjs/src/internal/manager-api/use-case/SetProviderUseCase.js +2 -0
  197. package/lib/cjs/src/internal/manager-api/use-case/SetProviderUseCase.js.map +7 -0
  198. package/lib/cjs/src/internal/manager-api/use-case/SetProviderUseCase.test.js +2 -0
  199. package/lib/cjs/src/internal/manager-api/use-case/SetProviderUseCase.test.js.map +7 -0
  200. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +1 -1
  201. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +2 -2
  202. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js +1 -1
  203. package/lib/cjs/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js.map +2 -2
  204. package/lib/cjs/src/internal/secure-channel/data/SecureChannelDataSource.js.map +1 -1
  205. package/lib/cjs/src/internal/secure-channel/model/Errors.js +1 -1
  206. package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +3 -3
  207. package/lib/cjs/src/internal/secure-channel/model/Params.js +1 -1
  208. package/lib/cjs/src/internal/secure-channel/model/Params.js.map +1 -1
  209. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
  210. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
  211. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.test.js +1 -1
  212. package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.test.js.map +3 -3
  213. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js +1 -1
  214. package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js.map +1 -1
  215. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js +1 -1
  216. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js.map +3 -3
  217. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  218. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  219. package/lib/cjs/src/internal/transport/di/transportModule.test.js +1 -1
  220. package/lib/cjs/src/internal/transport/di/transportModule.test.js.map +2 -2
  221. package/lib/esm/package.json +4 -4
  222. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  223. package/lib/esm/src/api/DeviceManagementKit.js.map +3 -3
  224. package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
  225. package/lib/esm/src/api/DeviceManagementKit.test.js.map +3 -3
  226. package/lib/esm/src/api/DeviceManagementKitBuilder.js +1 -1
  227. package/lib/esm/src/api/DeviceManagementKitBuilder.js.map +3 -3
  228. package/lib/esm/src/api/command/os/GetOsVersionCommand.js +1 -1
  229. package/lib/esm/src/api/command/os/GetOsVersionCommand.js.map +3 -3
  230. package/lib/esm/src/api/command/os/SecureElementFlagsParser.js +2 -0
  231. package/lib/esm/src/api/command/os/SecureElementFlagsParser.js.map +7 -0
  232. package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js +2 -0
  233. package/lib/esm/src/api/command/os/SecureElementFlagsParser.test.js.map +7 -0
  234. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  235. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
  236. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js +1 -1
  237. package/lib/esm/src/api/command/use-case/SendCommandUseCase.test.js.map +3 -3
  238. package/lib/esm/src/api/device/SecureElementFlags.js +1 -0
  239. package/lib/esm/src/api/device/SecureElementFlags.js.map +7 -0
  240. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  241. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  242. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  243. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  244. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  245. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  246. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  247. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
  248. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  249. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  250. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  251. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +2 -2
  252. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  253. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  254. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  255. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  256. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  257. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
  258. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js.map +1 -1
  259. package/lib/esm/src/api/device-session/DeviceSessionState.js.map +1 -1
  260. package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.js +2 -0
  261. package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.js.map +7 -0
  262. package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js +2 -0
  263. package/lib/esm/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.js.map +7 -0
  264. package/lib/esm/src/api/index.js +1 -1
  265. package/lib/esm/src/api/index.js.map +3 -3
  266. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  267. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +3 -3
  268. package/lib/esm/src/api/secure-channel/constants.js +2 -0
  269. package/lib/esm/src/api/secure-channel/constants.js.map +7 -0
  270. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +2 -0
  271. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +7 -0
  272. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js +2 -0
  273. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.js.map +7 -0
  274. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/types.js +1 -0
  275. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/types.js.map +7 -0
  276. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +2 -0
  277. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +7 -0
  278. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.test.js +2 -0
  279. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.test.js.map +7 -0
  280. package/lib/esm/src/api/secure-channel/device-action/InstallApp/types.js +1 -0
  281. package/lib/esm/src/api/secure-channel/device-action/InstallApp/types.js.map +7 -0
  282. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +2 -0
  283. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +7 -0
  284. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.test.js +2 -0
  285. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.test.js.map +7 -0
  286. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js +2 -0
  287. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +7 -0
  288. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +2 -0
  289. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +7 -0
  290. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.test.js +2 -0
  291. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.test.js.map +7 -0
  292. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/types.js +1 -0
  293. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/types.js.map +7 -0
  294. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +2 -0
  295. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +7 -0
  296. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +2 -0
  297. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +7 -0
  298. package/lib/esm/src/api/secure-channel/task/types.js +2 -0
  299. package/lib/esm/src/api/secure-channel/task/types.js.map +7 -0
  300. package/lib/esm/src/api/secure-channel/types.js +1 -0
  301. package/lib/esm/src/api/secure-channel/types.js.map +7 -0
  302. package/lib/esm/src/api/secure-channel/utils.js +2 -0
  303. package/lib/esm/src/api/secure-channel/utils.js.map +7 -0
  304. package/lib/esm/src/api/secure-channel/utils.test.js +2 -0
  305. package/lib/esm/src/api/secure-channel/utils.test.js.map +7 -0
  306. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  307. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  308. package/lib/esm/src/api/transport/model/Errors.js +1 -1
  309. package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
  310. package/lib/esm/src/api/transport/model/TransportConnectedDevice.test.js +1 -1
  311. package/lib/esm/src/api/transport/model/TransportConnectedDevice.test.js.map +3 -3
  312. package/lib/esm/src/di.js +1 -1
  313. package/lib/esm/src/di.js.map +3 -3
  314. package/lib/esm/src/internal/device-session/data/DeviceSessionRefresherConst.js +1 -1
  315. package/lib/esm/src/internal/device-session/data/DeviceSessionRefresherConst.js.map +3 -3
  316. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
  317. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  318. package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js +1 -1
  319. package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
  320. package/lib/esm/src/internal/device-session/model/DevicePinger.js +2 -0
  321. package/lib/esm/src/internal/device-session/model/DevicePinger.js.map +7 -0
  322. package/lib/esm/src/internal/device-session/model/DevicePinger.test.js +2 -0
  323. package/lib/esm/src/internal/device-session/model/DevicePinger.test.js.map +7 -0
  324. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  325. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  326. package/lib/esm/src/internal/device-session/model/DeviceSession.stub.js +1 -1
  327. package/lib/esm/src/internal/device-session/model/DeviceSession.stub.js.map +3 -3
  328. package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js +2 -0
  329. package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +7 -0
  330. package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.test.js +2 -0
  331. package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.test.js.map +7 -0
  332. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  333. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
  334. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  335. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +3 -3
  336. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js +2 -0
  337. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js.map +7 -0
  338. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js +2 -0
  339. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +7 -0
  340. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
  341. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
  342. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js +1 -1
  343. package/lib/esm/src/internal/device-session/service/DefaultDeviceSessionService.test.js.map +3 -3
  344. package/lib/esm/src/internal/device-session/service/MutexService.js +2 -0
  345. package/lib/esm/src/internal/device-session/service/MutexService.js.map +7 -0
  346. package/lib/esm/src/internal/device-session/service/MutexService.test.js +2 -0
  347. package/lib/esm/src/internal/device-session/service/MutexService.test.js.map +7 -0
  348. package/lib/esm/src/internal/device-session/service/RefresherService.js +2 -0
  349. package/lib/esm/src/internal/device-session/service/RefresherService.js.map +7 -0
  350. package/lib/esm/src/internal/device-session/service/RefresherService.test.js +2 -0
  351. package/lib/esm/src/internal/device-session/service/RefresherService.test.js.map +7 -0
  352. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js +1 -1
  353. package/lib/esm/src/internal/device-session/use-case/CloseSessionsUseCase.test.js.map +3 -3
  354. package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js +1 -1
  355. package/lib/esm/src/internal/device-session/use-case/GetDeviceSessionStateUseCase.test.js.map +3 -3
  356. package/lib/esm/src/internal/device-session/utils/deviceSessionUtils.js +2 -0
  357. package/lib/esm/src/internal/device-session/utils/deviceSessionUtils.js.map +7 -0
  358. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  359. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  360. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  361. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  362. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js +1 -1
  363. package/lib/esm/src/internal/discovery/use-case/DisconnectUseCase.test.js.map +3 -3
  364. package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js +1 -1
  365. package/lib/esm/src/internal/discovery/use-case/GetConnectedDeviceUseCase.test.js.map +3 -3
  366. package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js +1 -1
  367. package/lib/esm/src/internal/discovery/use-case/ListConnectedDevicesUseCase.test.js.map +3 -3
  368. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js +1 -1
  369. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.js.map +3 -3
  370. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js +1 -1
  371. package/lib/esm/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.test.js.map +3 -3
  372. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.js +1 -1
  373. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.js.map +3 -3
  374. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js +1 -1
  375. package/lib/esm/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.test.js.map +3 -3
  376. package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.js +1 -1
  377. package/lib/esm/src/internal/discovery/use-case/StartDiscoveringUseCase.js.map +2 -2
  378. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js +1 -1
  379. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.js.map +3 -3
  380. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js +1 -1
  381. package/lib/esm/src/internal/manager-api/data/AxiosManagerApiDataSource.test.js.map +3 -3
  382. package/lib/esm/src/internal/manager-api/data/ManagerApiDto.js.map +1 -1
  383. package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js +1 -1
  384. package/lib/esm/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.js.map +2 -2
  385. package/lib/esm/src/internal/manager-api/di/managerApiModule.js +1 -1
  386. package/lib/esm/src/internal/manager-api/di/managerApiModule.js.map +3 -3
  387. package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js +1 -1
  388. package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
  389. package/lib/esm/src/internal/manager-api/di/managerApiTypes.js +1 -1
  390. package/lib/esm/src/internal/manager-api/di/managerApiTypes.js.map +2 -2
  391. package/lib/esm/src/internal/manager-api/model/Application.js.map +1 -1
  392. package/lib/esm/src/internal/manager-api/model/Const.js +1 -1
  393. package/lib/esm/src/internal/manager-api/model/Const.js.map +3 -3
  394. package/lib/esm/src/internal/manager-api/model/Params.js +1 -0
  395. package/lib/esm/src/internal/manager-api/model/Params.js.map +7 -0
  396. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
  397. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js.map +3 -3
  398. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
  399. package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
  400. package/lib/esm/src/internal/manager-api/use-case/SetProviderUseCase.js +2 -0
  401. package/lib/esm/src/internal/manager-api/use-case/SetProviderUseCase.js.map +7 -0
  402. package/lib/esm/src/internal/manager-api/use-case/SetProviderUseCase.test.js +2 -0
  403. package/lib/esm/src/internal/manager-api/use-case/SetProviderUseCase.test.js.map +7 -0
  404. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js +1 -1
  405. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.js.map +2 -2
  406. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js +1 -1
  407. package/lib/esm/src/internal/secure-channel/data/DefaultSecureChannelDataSource.test.js.map +2 -2
  408. package/lib/esm/src/internal/secure-channel/model/Errors.js +1 -1
  409. package/lib/esm/src/internal/secure-channel/model/Errors.js.map +3 -3
  410. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
  411. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
  412. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.test.js +1 -1
  413. package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.test.js.map +3 -3
  414. package/lib/esm/src/internal/send/use-case/SendApduUseCase.js +1 -1
  415. package/lib/esm/src/internal/send/use-case/SendApduUseCase.js.map +3 -3
  416. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  417. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  418. package/lib/esm/src/internal/transport/di/transportModule.test.js +1 -1
  419. package/lib/esm/src/internal/transport/di/transportModule.test.js.map +2 -2
  420. package/lib/types/src/api/DeviceManagementKit.d.ts +25 -9
  421. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  422. package/lib/types/src/api/DeviceManagementKitBuilder.d.ts.map +1 -1
  423. package/lib/types/src/api/DmkConfig.d.ts +1 -0
  424. package/lib/types/src/api/DmkConfig.d.ts.map +1 -1
  425. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts +8 -2
  426. package/lib/types/src/api/command/os/GetOsVersionCommand.d.ts.map +1 -1
  427. package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts +43 -0
  428. package/lib/types/src/api/command/os/SecureElementFlagsParser.d.ts.map +1 -0
  429. package/lib/types/src/api/command/os/SecureElementFlagsParser.test.d.ts +2 -0
  430. package/lib/types/src/api/command/os/SecureElementFlagsParser.test.d.ts.map +1 -0
  431. package/lib/types/src/api/command/os/__mocks__/GetOsVersionCommand.d.ts.map +1 -1
  432. package/lib/types/src/api/device/SecureElementFlags.d.ts +41 -0
  433. package/lib/types/src/api/device/SecureElementFlags.d.ts.map +1 -0
  434. package/lib/types/src/api/device-action/DeviceAction.d.ts +1 -0
  435. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  436. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  437. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts +4 -0
  438. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
  439. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +3 -2
  440. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  441. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  442. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts +1 -1
  443. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
  444. package/lib/types/src/api/device-session/DeviceSessionState.d.ts +4 -0
  445. package/lib/types/src/api/device-session/DeviceSessionState.d.ts.map +1 -1
  446. package/lib/types/src/api/device-session/use-case/{ToggleDeviceSessionRefresher.d.ts → DisableDeviceSessionRefresher.d.ts} +6 -6
  447. package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.d.ts.map +1 -0
  448. package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.d.ts +2 -0
  449. package/lib/types/src/api/device-session/use-case/DisableDeviceSessionRefresher.test.d.ts.map +1 -0
  450. package/lib/types/src/api/index.d.ts +5 -1
  451. package/lib/types/src/api/index.d.ts.map +1 -1
  452. package/lib/types/src/api/secure-channel/constants.d.ts +2 -0
  453. package/lib/types/src/api/secure-channel/constants.d.ts.map +1 -0
  454. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts +8 -0
  455. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -0
  456. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.d.ts +2 -0
  457. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.test.d.ts.map +1 -0
  458. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +48 -0
  459. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -0
  460. package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.d.ts +8 -0
  461. package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.d.ts.map +1 -0
  462. package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.test.d.ts +2 -0
  463. package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.test.d.ts.map +1 -0
  464. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts +44 -0
  465. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts.map +1 -0
  466. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.d.ts +8 -0
  467. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.d.ts.map +1 -0
  468. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.test.d.ts +2 -0
  469. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.test.d.ts.map +1 -0
  470. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts +57 -0
  471. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts.map +1 -0
  472. package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.d.ts +8 -0
  473. package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.d.ts.map +1 -0
  474. package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.test.d.ts +2 -0
  475. package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.test.d.ts.map +1 -0
  476. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts +41 -0
  477. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts.map +1 -0
  478. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +23 -0
  479. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -0
  480. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.test.d.ts +2 -0
  481. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.test.d.ts.map +1 -0
  482. package/lib/types/src/api/secure-channel/task/types.d.ts +105 -0
  483. package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -0
  484. package/lib/types/src/api/secure-channel/types.d.ts +4 -0
  485. package/lib/types/src/api/secure-channel/types.d.ts.map +1 -0
  486. package/lib/types/src/api/secure-channel/utils.d.ts +30 -0
  487. package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -0
  488. package/lib/types/src/api/secure-channel/utils.test.d.ts +2 -0
  489. package/lib/types/src/api/secure-channel/utils.test.d.ts.map +1 -0
  490. package/lib/types/src/api/transport/model/DeviceConnection.d.ts +1 -1
  491. package/lib/types/src/api/transport/model/DeviceConnection.d.ts.map +1 -1
  492. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +9 -7
  493. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
  494. package/lib/types/src/api/transport/model/Errors.d.ts +5 -0
  495. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  496. package/lib/types/src/api/types.d.ts +4 -0
  497. package/lib/types/src/api/types.d.ts.map +1 -1
  498. package/lib/types/src/di.d.ts.map +1 -1
  499. package/lib/types/src/internal/device-session/data/DeviceSessionRefresherConst.d.ts +6 -1
  500. package/lib/types/src/internal/device-session/data/DeviceSessionRefresherConst.d.ts.map +1 -1
  501. package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts +1 -1
  502. package/lib/types/src/internal/device-session/model/DevicePinger.d.ts +18 -0
  503. package/lib/types/src/internal/device-session/model/DevicePinger.d.ts.map +1 -0
  504. package/lib/types/src/internal/device-session/model/DevicePinger.test.d.ts +2 -0
  505. package/lib/types/src/internal/device-session/model/DevicePinger.test.d.ts.map +1 -0
  506. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +20 -8
  507. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  508. package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts +2 -2
  509. package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts.map +1 -1
  510. package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts +35 -0
  511. package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts.map +1 -0
  512. package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.test.d.ts +2 -0
  513. package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.test.d.ts.map +1 -0
  514. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts +17 -79
  515. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
  516. package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts +20 -0
  517. package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts.map +1 -0
  518. package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.test.d.ts +2 -0
  519. package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.test.d.ts.map +1 -0
  520. package/lib/types/src/internal/device-session/service/MutexService.d.ts +6 -0
  521. package/lib/types/src/internal/device-session/service/MutexService.d.ts.map +1 -0
  522. package/lib/types/src/internal/device-session/service/MutexService.test.d.ts +2 -0
  523. package/lib/types/src/internal/device-session/service/MutexService.test.d.ts.map +1 -0
  524. package/lib/types/src/internal/device-session/service/RefresherService.d.ts +15 -0
  525. package/lib/types/src/internal/device-session/service/RefresherService.d.ts.map +1 -0
  526. package/lib/types/src/internal/device-session/service/RefresherService.test.d.ts +2 -0
  527. package/lib/types/src/internal/device-session/service/RefresherService.test.d.ts.map +1 -0
  528. package/lib/types/src/internal/device-session/utils/deviceSessionUtils.d.ts +3 -0
  529. package/lib/types/src/internal/device-session/utils/deviceSessionUtils.d.ts.map +1 -0
  530. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts +8 -1
  531. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
  532. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.d.ts +14 -3
  533. package/lib/types/src/internal/discovery/use-case/ListenToAvailableDevicesUseCase.d.ts.map +1 -1
  534. package/lib/types/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.d.ts +1 -1
  535. package/lib/types/src/internal/discovery/use-case/ListenToConnectedDeviceUseCase.d.ts.map +1 -1
  536. package/lib/types/src/internal/discovery/use-case/StartDiscoveringUseCase.d.ts +1 -1
  537. package/lib/types/src/internal/discovery/use-case/StartDiscoveringUseCase.d.ts.map +1 -1
  538. package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts +10 -6
  539. package/lib/types/src/internal/manager-api/data/AxiosManagerApiDataSource.d.ts.map +1 -1
  540. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +24 -9
  541. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts.map +1 -1
  542. package/lib/types/src/internal/manager-api/data/ManagerApiDto.d.ts +4 -1
  543. package/lib/types/src/internal/manager-api/data/ManagerApiDto.d.ts.map +1 -1
  544. package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts +3 -0
  545. package/lib/types/src/internal/manager-api/data/__mocks__/AxiosManagerApiDataSource.d.ts.map +1 -1
  546. package/lib/types/src/internal/manager-api/di/managerApiModule.d.ts.map +1 -1
  547. package/lib/types/src/internal/manager-api/di/managerApiTypes.d.ts +1 -0
  548. package/lib/types/src/internal/manager-api/di/managerApiTypes.d.ts.map +1 -1
  549. package/lib/types/src/internal/manager-api/model/Application.d.ts +4 -1
  550. package/lib/types/src/internal/manager-api/model/Application.d.ts.map +1 -1
  551. package/lib/types/src/internal/manager-api/model/Const.d.ts +1 -0
  552. package/lib/types/src/internal/manager-api/model/Const.d.ts.map +1 -1
  553. package/lib/types/src/internal/manager-api/model/Params.d.ts +37 -0
  554. package/lib/types/src/internal/manager-api/model/Params.d.ts.map +1 -0
  555. package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts +7 -7
  556. package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts.map +1 -1
  557. package/lib/types/src/internal/manager-api/service/ManagerApiService.d.ts +32 -4
  558. package/lib/types/src/internal/manager-api/service/ManagerApiService.d.ts.map +1 -1
  559. package/lib/types/src/internal/manager-api/use-case/SetProviderUseCase.d.ts +11 -0
  560. package/lib/types/src/internal/manager-api/use-case/SetProviderUseCase.d.ts.map +1 -0
  561. package/lib/types/src/internal/manager-api/use-case/SetProviderUseCase.test.d.ts +2 -0
  562. package/lib/types/src/internal/manager-api/use-case/SetProviderUseCase.test.d.ts.map +1 -0
  563. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts +3 -3
  564. package/lib/types/src/internal/secure-channel/data/DefaultSecureChannelDataSource.d.ts.map +1 -1
  565. package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts +13 -13
  566. package/lib/types/src/internal/secure-channel/data/SecureChannelDataSource.d.ts.map +1 -1
  567. package/lib/types/src/internal/secure-channel/model/Errors.d.ts +6 -0
  568. package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -1
  569. package/lib/types/src/internal/secure-channel/model/Params.d.ts +3 -5
  570. package/lib/types/src/internal/secure-channel/model/Params.d.ts.map +1 -1
  571. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts +7 -7
  572. package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts.map +1 -1
  573. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts +39 -4
  574. package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts.map +1 -1
  575. package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts +5 -1
  576. package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts.map +1 -1
  577. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  578. package/package.json +4 -4
  579. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js +0 -2
  580. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js.map +0 -7
  581. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +0 -2
  582. package/lib/cjs/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +0 -7
  583. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js +0 -2
  584. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.js.map +0 -7
  585. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js +0 -2
  586. package/lib/esm/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.js.map +0 -7
  587. package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.d.ts.map +0 -1
  588. package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.d.ts +0 -2
  589. package/lib/types/src/api/device-session/use-case/ToggleDeviceSessionRefresher.test.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/api/device-action/DeviceAction.ts"],
4
- "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type 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"],
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 disableRefresher: (blockerId: string) => () => void;\n readonly getManagerApiService: () => ManagerApiService;\n readonly getSecureChannelService: () => SecureChannelService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["DeviceAction_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var i in e)c(n,i,{get:e[i],enumerable:!0})},S=(n,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of a(e))!r.call(n,t)&&t!==i&&c(n,t,{get:()=>e[t],enumerable:!(o=s(e,t))||o.enumerable});return n};var 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});
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 b={};v(b,{makeDeviceActionInternalApiMock:()=>D});module.exports=p(b);const f=vi.fn(),M=vi.fn(),d=vi.fn(),k=vi.fn(),l=vi.fn(),m=vi.fn(),g=vi.fn(),A=vi.fn();function D(){return{sendApdu:f,sendCommand:M,getDeviceSessionState:d,getDeviceSessionStateObservable:k,setDeviceSessionState:l,getManagerApiService:m,getSecureChannelService:g,disableRefresher:A}}0&&(module.exports={makeDeviceActionInternalApiMock});
2
2
  //# sourceMappingURL=makeInternalApi.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/__test-utils__/makeInternalApi.ts"],
4
- "sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst 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"]
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();\nconst disableRefresherMock = 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 disableRefresher: disableRefresherMock,\n };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAIA,MAAMI,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EACpCC,EAAuB,GAAG,GAAG,EAE5B,SAAST,GAAuD,CACrE,MAAO,CACL,SAAUE,EACV,YAAaC,EACb,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,EACzB,iBAAkBC,CACpB,CACF",
6
+ "names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendApduMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "disableRefresherMock"]
7
7
  }
@@ -1,2 +1,2 @@
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});
1
+ "use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},I=(t,e,o,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A(e))!k.call(t,r)&&r!==o&&p(t,r,{get:()=>e[r],enumerable:!(m=u(e,r))||m.enumerable});return t};var D=t=>I(p({},"__esModule",{value:!0}),t);var S={};y(S,{setupGetDeviceStatusMock:()=>h,setupGoToDashboardMock:()=>v,setupListAppsMock:()=>M,setupListInstalledAppsMock:()=>L});module.exports=D(S);var n=require("purify-ts"),i=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"),l=require("../../device-action/os/ListApps/ListAppsDeviceAction"),f=require("../../secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction");const M=(t,e=!1)=>{l.ListAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,i.createMachine)({id:"MockListAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,i.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.AllowListApps})})},done:{type:"final"}},output:()=>e?(0,n.Left)(new c.UnknownDAError("ListApps failed")):(0,n.Right)(t)}))}))},v=(t=!1)=>{d.GoToDashboardDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,i.createMachine)({id:"MockGoToDashboardDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,i.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:()=>t?(0,n.Left)(new c.UnknownDAError("GoToDashboard failed")):(0,n.Right)(void 0)}))}))},h=(t=[{currentApp:"BOLOS",currentAppVersion:"1.0.0"}])=>{const e=vi.fn();for(const o of t)e.mockImplementationOnce(()=>"currentApp"in o?(0,n.Right)(o):(0,n.Left)(o));s.GetDeviceStatusDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,i.createMachine)({id:"MockGetDeviceStatusDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,i.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:e}))}))},L=(t=[])=>{f.ListInstalledAppsDeviceAction.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>(0,i.createMachine)({id:"MockListInstalledAppsDeviceAction",initial:"ready",states:{ready:{after:{0:"done"},entry:(0,i.assign)({intermediateValue:()=>({requiredUserInteraction:a.UserInteractionRequired.None})})},done:{type:"final"}},output:t.reduce((e,o)=>e.mockImplementationOnce(()=>"installedApps"in o?(0,n.Right)(o):(0,n.Left)(o)),vi.fn()).mockImplementation(()=>(0,n.Right)([]))}))}))};0&&(module.exports={setupGetDeviceStatusMock,setupGoToDashboardMock,setupListAppsMock,setupListInstalledAppsMock});
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 { 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
- "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"]
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\";\nimport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nimport { type InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\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\nexport const setupListInstalledAppsMock = (\n outputs: Array<{ installedApps: InstalledApp[] } | DmkError> = [],\n) => {\n (ListInstalledAppsDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n id: \"MockListInstalledAppsDeviceAction\",\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: outputs\n .reduce(\n (mockFn, output) =>\n mockFn.mockImplementationOnce(() =>\n \"installedApps\" in output ? Right(output) : Left(output),\n ),\n vi.fn(),\n )\n .mockImplementation(() => Right([])),\n }),\n ),\n }));\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,2BAAAC,EAAA,sBAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAA4B,qBAE5BC,EAAsC,kBAEtCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAA4C,6EAC5CC,EAA0C,yEAC1CC,EAAqC,+DAErCC,EAA8C,6FAOvC,MAAMV,EAAoB,CAACW,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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EACF,CAAC,CACH,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQA,EACL,OACC,CAACG,EAAQD,IACPC,EAAO,uBAAuB,IAC5B,kBAAmBD,KAAS,SAAMA,CAAM,KAAI,QAAKA,CAAM,CACzD,EACF,GAAG,GAAG,CACR,EACC,mBAAmB,OAAM,SAAM,CAAC,CAAC,CAAC,CACvC,CAAC,CACH,CACF,EAAE,CACJ",
6
+ "names": ["setupTestMachine_exports", "__export", "setupGetDeviceStatusMock", "setupGoToDashboardMock", "setupListAppsMock", "setupListInstalledAppsMock", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Errors", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_ListAppsDeviceAction", "import_ListInstalledAppsDeviceAction", "apps", "error", "outputs", "outputFn", "output", "mockFn"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var y=(o,p)=>{for(var n in p)a(o,n,{get:p[n],enumerable:!0})},S=(o,p,n,g)=>{if(p&&typeof p=="object"||typeof p=="function")for(let s of m(p))!w.call(o,s)&&s!==n&&a(o,s,{get:()=>p[s],enumerable:!(g=f(p,s))||g.enumerable});return o};var c=o=>S(a({},"__esModule",{value:!0}),o);var v={};y(v,{UserInteractionRequired:()=>A});module.exports=c(v);var A=(l=>(l.None="none",l.UnlockDevice="unlock-device",l.AllowSecureConnection="allow-secure-connection",l.ConfirmOpenApp="confirm-open-app",l.SignTransaction="sign-transaction",l.SignTypedData="sign-typed-data",l.AllowListApps="allow-list-apps",l.VerifyAddress="verify-address",l.SignPersonalMessage="sign-personal-message",l))(A||{});0&&(module.exports={UserInteractionRequired});
1
+ "use strict";var g=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var k=(s,l)=>{for(var n in l)g(s,n,{get:l[n],enumerable:!0})},m=(s,l,n,a)=>{if(l&&typeof l=="object"||typeof l=="function")for(let o of A(l))!f.call(s,o)&&o!==n&&g(s,o,{get:()=>l[o],enumerable:!(a=w(l,o))||a.enumerable});return s};var y=s=>m(g({},"__esModule",{value:!0}),s);var S={};k(S,{UserInteractionRequired:()=>c});module.exports=y(S);var c=(p=>(p.None="none",p.UnlockDevice="unlock-device",p.AllowSecureConnection="allow-secure-connection",p.ConfirmOpenApp="confirm-open-app",p.SignTransaction="sign-transaction",p.SignTypedData="sign-typed-data",p.AllowListApps="allow-list-apps",p.VerifyAddress="verify-address",p.SignPersonalMessage="sign-personal-message",p.Web3ChecksOptIn="web3-checks-opt-in",p))(c||{});0&&(module.exports={UserInteractionRequired});
2
2
  //# sourceMappingURL=UserInteractionRequired.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/model/UserInteractionRequired.ts"],
4
- "sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the user about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBATZA,OAAA",
4
+ "sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,gBAAkB,qBAVRA,OAAA",
6
6
  "names": ["UserInteractionRequired_exports", "__export", "UserInteractionRequired", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var O=(i,t)=>{for(var a in t)m(i,a,{get:t[a],enumerable:!0})},I=(i,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!x.call(i,r)&&r!==a&&m(i,r,{get:()=>t[r],enumerable:!(s=V(t,r))||s.enumerable});return i};var C=i=>I(m({},"__esModule",{value:!0}),i);var T={};O(T,{GetDeviceStatusDeviceAction:()=>M});module.exports=C(T);var D=require("purify-ts"),g=require("rxjs"),S=require("rxjs/operators"),n=require("xstate"),k=require("../../../command/model/CommandResult"),b=require("../../../command/os/GetAppAndVersionCommand"),d=require("../../../device/DeviceStatus"),c=require("../../../device-action/model/UserInteractionRequired"),E=require("../../../device-action/os/Const"),v=require("../../../device-action/os/Errors"),h=require("../../../device-action/xstate-utils/XStateDeviceAction"),y=require("../../../device-session/DeviceSessionState");class M extends h.XStateDeviceAction{makeStateMachine(t){const{getAppAndVersion:a,getDeviceSessionState:s,setDeviceSessionState:r,waitForDeviceUnlock:A,isDeviceOnboarded:u}=this.extractDependencies(t),p=this.input.unlockTimeout??E.DEFAULT_UNLOCK_TIMEOUT_MS;return(0,n.setup)({types:{input:{unlockTimeout:p},context:{},output:{}},actors:{getAppAndVersion:(0,n.fromPromise)(a),waitForDeviceUnlock:(0,n.fromObservable)(A)},guards:{isDeviceOnboarded:()=>u(),isDeviceUnlocked:()=>s().deviceStatus!==d.DeviceStatus.LOCKED,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceNotOnboardedError})}),assignErrorDeviceLocked:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceLockedError}),intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice}}),assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.None})}),assignUserActionUnlockNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const o=s(),{sessionStateType:l}=o;return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},_internalState:{onboarded:!1,locked:o.deviceStatus===d.DeviceStatus.LOCKED,currentApp:l===y.DeviceSessionStateType.ReadyWithoutSecureChannel?o.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"LockingCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},LockingCheck:{always:[{target:"AppAndVersionCheck",guard:{type:"isDeviceUnlocked"},actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,locked:!1})})},{target:"UserActionUnlockDevice"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:p}),onDone:{target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,k.isSuccessCommandResult)(e.event.output)){const o=s();return o.sessionStateType!==y.DeviceSessionStateType.Connected&&r({...o,currentApp:e.event.output.data}),{...e.context._internalState,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:o}=e,{error:l,currentApp:U,currentAppVersion:f}=o._internalState;return l?(0,D.Left)(l):(0,D.Right)({currentApp:U,currentAppVersion:f})}})}extractDependencies(t){return{getAppAndVersion:()=>t.sendCommand(new b.GetAppAndVersionCommand),waitForDeviceUnlock:({input:r})=>new g.Observable(A=>{const u=t.getDeviceSessionStateObservable().pipe((0,S.tap)(p=>{p.deviceStatus===d.DeviceStatus.CONNECTED&&(A.complete(),u.unsubscribe())})).subscribe();return()=>{u.unsubscribe()}}).pipe((0,S.timeout)(r.unlockTimeout)),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:r=>t.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}0&&(module.exports={GetDeviceStatusDeviceAction});
1
+ "use strict";var A=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var I=(i,t)=>{for(var o in t)A(i,o,{get:t[o],enumerable:!0})},O=(i,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!x.call(i,r)&&r!==o&&A(i,r,{get:()=>t[r],enumerable:!(s=U(t,r))||s.enumerable});return i};var C=i=>O(A({},"__esModule",{value:!0}),i);var T={};I(T,{GetDeviceStatusDeviceAction:()=>M});module.exports=C(T);var d=require("purify-ts"),y=require("rxjs"),D=require("rxjs/operators"),n=require("xstate"),g=require("../../../command/model/CommandResult"),k=require("../../../command/os/GetAppAndVersionCommand"),b=require("../../../device/DeviceStatus"),c=require("../../../device-action/model/UserInteractionRequired"),f=require("../../../device-action/os/Const"),v=require("../../../device-action/os/Errors"),E=require("../../../device-action/xstate-utils/XStateDeviceAction"),m=require("../../../device-session/DeviceSessionState");class M extends E.XStateDeviceAction{makeStateMachine(t){const{getAppAndVersion:o,getDeviceSessionState:s,setDeviceSessionState:r,waitForDeviceUnlock:S,isDeviceOnboarded:u}=this.extractDependencies(t),p=this.input.unlockTimeout??f.DEFAULT_UNLOCK_TIMEOUT_MS;return(0,n.setup)({types:{input:{unlockTimeout:p},context:{},output:{}},actors:{getAppAndVersion:(0,n.fromPromise)(o),waitForDeviceUnlock:(0,n.fromObservable)(S)},guards:{isDeviceOnboarded:()=>u(),isDeviceLocked:({context:e})=>e._internalState.locked,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceNotOnboardedError})}),assignErrorDeviceLocked:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceLockedError}),intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice}}),assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.None})}),assignUserActionUnlockNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const a=s(),{sessionStateType:l}=a;return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},_internalState:{onboarded:!1,locked:!1,currentApp:l===m.DeviceSessionStateType.ReadyWithoutSecureChannel?a.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:p}),onDone:{target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,g.isSuccessCommandResult)(e.event.output)){const a=s();return a.sessionStateType!==m.DeviceSessionStateType.Connected&&r({...a,currentApp:e.event.output.data}),{...e.context._internalState,locked:!1,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}return"errorCode"in e.event.output.error&&e.event.output.error.errorCode==="5515"?{...e.context._internalState,locked:!0}:{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:a}=e,{error:l,currentApp:V,currentAppVersion:h}=a._internalState;return l?(0,d.Left)(l):(0,d.Right)({currentApp:V,currentAppVersion:h})}})}extractDependencies(t){return{getAppAndVersion:()=>t.sendCommand(new k.GetAppAndVersionCommand),waitForDeviceUnlock:({input:r})=>new y.Observable(S=>{const u=t.getDeviceSessionStateObservable().pipe((0,D.tap)(p=>{p.deviceStatus===b.DeviceStatus.CONNECTED&&(S.complete(),u.unsubscribe())})).subscribe();return()=>{u.unsubscribe()}}).pipe((0,D.timeout)(r.unlockTimeout)),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:r=>t.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}0&&(module.exports={GetDeviceStatusDeviceAction});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\nimport { tap, timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n isDeviceOnboarded,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isDeviceUnlocked: () =>\n getDeviceSessionState().deviceStatus !== DeviceStatus.LOCKED,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n }),\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 assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI8vsAHOJM+VuLm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VITCrE8RoMdDucxWgx1jpZCELDHDgKTC9jg6mNXKLDSHPcbV3O7LG3bNH2SYioLB3EmCI1-HuVL6Cj4hU6eNjsIVD3UrWfKXVCj5cV5Wvtr5n6CShaFE-1JMkWzPgXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n onboarded: false, // we don't know how to check yet\n locked: sessionState.deviceStatus === DeviceStatus.LOCKED,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"OnboardingCheck\",\n },\n },\n OnboardingCheck: {\n // TODO: we don't have this info for now\n always: [\n {\n guard: {\n type: \"isDeviceOnboarded\",\n },\n target: \"LockingCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n LockingCheck: {\n // We check if the device is locked in the session state\n always: [\n {\n target: \"AppAndVersionCheck\",\n guard: {\n type: \"isDeviceUnlocked\",\n },\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n {\n target: \"UserActionUnlockDevice\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion command\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n // Narrow the type to ReadyWithoutSecureChannelState or ReadyWithSecureChannelState\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n }\n return {\n ..._.context._internalState,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n new Observable<void>((subscriber) => {\n const inner = internalApi\n .getDeviceSessionStateObservable()\n .pipe(\n tap((state) => {\n if (state.deviceStatus === DeviceStatus.CONNECTED) {\n subscriber.complete();\n inner.unsubscribe();\n }\n }),\n )\n .subscribe();\n\n return () => {\n inner.unsubscribe();\n };\n }).pipe(timeout(input.unlockTimeout));\n\n return {\n getAppAndVersion,\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2B,gBAC3BC,EAA6B,0BAC7BC,EAA2D,kBAE3DC,EAAuC,4CACvCC,EAGO,mDACPC,EAA6B,oCAE7BC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAGO,wCAEPC,EAGO,8DACPC,EAGO,kDAiCA,MAAMb,UAAoC,oBAM/C,CACA,iBACEc,EAOA,CASA,KAAM,CACJ,iBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,kBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiB,4BAElD,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAA,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,oBAAkB,eAAYL,CAAgB,EAC9C,uBAAqB,kBAAeG,CAAmB,CACzD,EACA,OAAQ,CACN,kBAAmB,IAAMC,EAAkB,EAC3C,iBAAkB,IAChBH,EAAsB,EAAE,eAAiB,eAAa,OACxD,SAAU,CAAC,CAAE,QAAAK,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IAC9D,EACA,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WAAAC,EAAY,kBAAAC,CAAkB,EAAIR,EAAQ,eACzD,OAAIM,KACK,QAAKA,CAAK,KAEZ,SAA+B,CACpC,WAAYC,EACZ,kBAAmBC,CACrB,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBf,EAA+C,CA4BjE,MAAO,CACL,iBA5BuB,IAChBA,EAAY,YAAY,IAAI,yBAAyB,EA4B5D,oBAzB0B,CAAC,CAC3B,MAAAgB,CACF,IAGE,IAAI,aAAkBC,GAAe,CACnC,MAAMC,EAAQlB,EACX,gCAAgC,EAChC,QACC,OAAKW,GAAU,CACTA,EAAM,eAAiB,eAAa,YACtCM,EAAW,SAAS,EACpBC,EAAM,YAAY,EAEtB,CAAC,CACH,EACC,UAAU,EAEb,MAAO,IAAM,CACXA,EAAM,YAAY,CACpB,CACF,CAAC,EAAE,QAAK,WAAQF,EAAM,aAAa,CAAC,EAKpC,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\nimport { tap, timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n isDeviceOnboarded,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isDeviceLocked: ({ context }) => context._internalState.locked,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n }),\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 assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI8vsAHOJM+VuLmVj5e2gC+EW6omDjcJORUXPSMLBwA8qwARsykAE4QuKxQAMIAFmD4ANZiUqryisqsqhoImo4O7OGhPj4h5n6Obh4IunZ2RoZ+ena6nYaGUT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5Wvtr5n6CShaFE-1JMkWzPgXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n onboarded: false, // we don't know how to check yet\n locked: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"OnboardingCheck\",\n },\n },\n OnboardingCheck: {\n // TODO: we don't have this info for now\n always: [\n {\n guard: {\n type: \"isDeviceOnboarded\",\n },\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion command\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n // Narrow the type to ReadyWithoutSecureChannelState or ReadyWithSecureChannelState\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n }\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n if (\n \"errorCode\" in _.event.output.error &&\n _.event.output.error.errorCode === \"5515\"\n ) {\n return {\n ..._.context._internalState,\n locked: true,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"UserActionUnlockDevice\",\n guard: \"isDeviceLocked\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n new Observable<void>((subscriber) => {\n const inner = internalApi\n .getDeviceSessionStateObservable()\n .pipe(\n tap((state) => {\n if (state.deviceStatus === DeviceStatus.CONNECTED) {\n subscriber.complete();\n inner.unsubscribe();\n }\n }),\n )\n .subscribe();\n\n return () => {\n inner.unsubscribe();\n };\n }).pipe(timeout(input.unlockTimeout));\n\n return {\n getAppAndVersion,\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2B,gBAC3BC,EAA6B,0BAC7BC,EAA2D,kBAE3DC,EAAuC,4CACvCC,EAGO,mDACPC,EAA6B,oCAE7BC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAGO,wCAEPC,EAGO,8DACPC,EAGO,kDAiCA,MAAMb,UAAoC,oBAM/C,CACA,iBACEc,EAOA,CASA,KAAM,CACJ,iBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,kBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiB,4BAElD,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAA,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,oBAAkB,eAAYL,CAAgB,EAC9C,uBAAqB,kBAAeG,CAAmB,CACzD,EACA,OAAQ,CACN,kBAAmB,IAAMC,EAAkB,EAC3C,eAAgB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,OACxD,SAAU,CAAC,CAAE,QAAAA,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IAC9D,EACA,QAAS,CACP,iCAA+B,UAAO,CACpC,eAAiBC,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,MAAO,IAAI,yBACb,EACF,CAAC,EACD,2BAAyB,UAAO,CAC9B,eAAiBA,IAAO,CACtB,GAAGA,EAAE,QAA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AAI,yBAAyB,EA4B5D,oBAzB0B,CAAC,CAC3B,MAAAgB,CACF,IAGE,IAAI,aAAkBC,GAAe,CACnC,MAAMC,EAAQlB,EACX,gCAAgC,EAChC,QACC,OAAKW,GAAU,CACTA,EAAM,eAAiB,eAAa,YACtCM,EAAW,SAAS,EACpBC,EAAM,YAAY,EAEtB,CAAC,CACH,EACC,UAAU,EAEb,MAAO,IAAM,CACXA,EAAM,YAAY,CACpB,CACF,CAAC,EAAE,QAAK,WAAQF,EAAM,aAAa,CAAC,EAKpC,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
6
6
  "names": ["GetDeviceStatusDeviceAction_exports", "__export", "GetDeviceStatusDeviceAction", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_operators", "import_xstate", "import_CommandResult", "import_GetAppAndVersionCommand", "import_DeviceStatus", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_XStateDeviceAction", "import_DeviceSessionState", "internalApi", "getAppAndVersion", "getDeviceSessionState", "setDeviceSessionState", "waitForDeviceUnlock", "isDeviceOnboarded", "unlockTimeout", "context", "_", "sessionState", "sessionStateType", "state", "args", "error", "currentApp", "currentAppVersion", "input", "subscriber", "inner"]
7
7
  }
@@ -1,2 +1,2 @@
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()}))});
1
+ "use strict";var d=require("rxjs"),p=require("../../../command/model/CommandResult"),v=require("../../../command/utils/GlobalCommandError"),A=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),u=require("../../../device-action/__test-utils__/makeInternalApi"),l=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),a=require("../../../device-action/model/UserInteractionRequired"),k=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),m=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const C=vi.fn(),D=vi.fn(),y=vi.fn(),f=vi.fn(),V=vi.fn();function h(){return{getAppAndVersion:C,getDeviceSessionState:D,waitForDeviceUnlock:y,setDeviceSessionState:f,isDeviceOnboarded:V}}const{sendCommand:R,getDeviceSessionState:w,getDeviceSessionStateObservable:E}=(0,u.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),V.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}});w.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:A.DeviceModelId.NANO_X}),R.mockResolvedValue((0,p.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,l.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}});w.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),E.mockImplementation(()=>new d.Observable(c=>{const S=(0,d.interval)(50).subscribe({next:O=>{O>2?(c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),c.complete()):c.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{S.unsubscribe()}})),R.mockResolvedValueOnce((0,p.CommandResultFactory)({error:new v.GlobalCommandError({...v.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,p.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{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,l.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)=>{D.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockResolvedValue((0,p.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(h());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,l.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)=>{D.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockResolvedValueOnce((0,p.CommandResultFactory)({error:new v.GlobalCommandError({...v.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,p.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),y.mockImplementation(()=>new d.Observable(c=>{const S=(0,d.interval)(50).subscribe({next:O=>{O>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()=>{S.unsubscribe()}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(h());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{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,l.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)=>{D.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),V.mockReturnValue(!1);const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(h());const n=[{error:new k.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,l.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)=>{D.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockResolvedValue((0,p.CommandResultFactory)({error:new v.GlobalCommandError({...v.GLOBAL_ERRORS[5515],errorCode:"5515"})})),E.mockImplementation(()=>new d.Observable(c=>{const S=(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:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{S.unsubscribe()}}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(h());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new k.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,l.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)=>{D.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new v.GlobalCommandError({...v.GLOBAL_ERRORS[5501],errorCode:"5501"});C.mockResolvedValue((0,p.CommandResultFactory)({error:e})),y.mockImplementation(()=>new d.Observable(S=>{const O=(0,d.interval)(50).subscribe({next:N=>{N>2?(S.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.complete()):S.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{O.unsubscribe()}}));const n=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(h());const c=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,l.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)=>{D.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),C.mockImplementation(()=>{throw new k.UnknownDAError("error")}),y.mockImplementation(()=>new d.Observable(c=>{c.complete()}));const e=new m.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(h());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new k.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,l.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)=>{w.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),R.mockResolvedValue((0,p.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,l.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});c()}))});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.ts"],
4
- "sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const waitForDeviceUnlockMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetAppAndVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAAqC,g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AI,CAC9B,CAAC,EAED,GAAG,MACDA,EACA,qBACF,EAAE,gBAAgBN,EAAwB,CAAC,EAE3C,MAAMO,EAAgD,CACpD,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,YACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,MAAO,IAAI,iBAAe,OAAO,EACjC,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BACED,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,EAED,GAAG,yDAA0D,IAC3D,IAAI,QAAc,CAACD,EAASC,IAAW,CACrCH,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,WAAY,CAAE,KAAM,mBAAoB,QAAS,OAAQ,EACzD,cAAe,CAAC,EAChB,cAAe,gBAAc,MAC/B,CAAC,EAEDD,EAAgB,qBACd,wBAAqB,CACnB,KAAM,CACJ,KAAM,QACN,QAAS,OACX,CACF,CAAC,CACH,EAEA,MAAMK,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEKC,EAAgD,CACpD,CACE,OAAQ,qBAAmB,QAC3B,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,CACF,EACA,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAAK,CAAO,KAAI,0BACjBN,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,EACAO,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
4
+ "sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const waitForDeviceUnlockMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n sendCommandMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n );\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetAppAndVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAqC,gBAErCC,EAAqC,4CACrCC,EAGO,iDACPC,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAIO,wCACPC,EAAuC,kDAEvCC,EAA4C,yCAG5C,SAAS,8BAA+B,IAAM,CAC5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O,KAAI,0BACjBN,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,EACAO,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
6
6
  "names": ["import_rxjs", "import_CommandResult", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_GetDeviceStatusDeviceAction", "getAppAndVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "isDeviceOnboardedMock", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "resolve", "reject", "getDeviceStateDeviceAction", "expectedStates", "o", "inner", "i", "error", "cancel"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=require("../../../command/model/CommandResult"),h=require("../../../command/utils/GlobalCommandError"),S=require("../../../device/DeviceModel"),c=require("../../../device/DeviceStatus"),s=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/setupTestMachine"),u=require("../../../device-action/__test-utils__/testDeviceActionStates"),e=require("../../../device-action/model/DeviceActionState"),t=require("../../../device-action/model/UserInteractionRequired"),V=require("../../../device-action/os/Errors"),p=require("../../../device-session/DeviceSessionState"),N=require("../../../../../src"),m=require("./GoToDashboardDeviceAction");vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("GoToDashboardDeviceAction",()=>{const v=vi.fn(),D=vi.fn(),l=vi.fn(),T=vi.fn();function A(){return{closeApp:v,getAppAndVersion:D,getDeviceSessionState:l,setDeviceSessionState:T}}const{sendCommand:g,getDeviceSessionState:k}=(0,s.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks()}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with device already on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X});const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should run the device action with device not on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X}),g.mockResolvedValueOnce((0,a.CommandResultFactory)({data:void 0})).mockResolvedValueOnce((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))}),describe("success cases",()=>{it("should success if the device is already on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"}}),D.mockReturnValue({app:"BOLOS",version:"1.5.0"}),vi.spyOn(n,"extractDependencies").mockReturnValue(A());const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should success if the device is not on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockReturnValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))}),describe("error cases",()=>{it("should return an error if GetDeviceStatus return an error",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([new V.UnknownDAError("Unknown error")]);const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X});const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new V.UnknownDAError("Unknown error")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),describe("not on dashboard",()=>{it("should return an error if closeApp fails",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new m.GoToDashboardDeviceAction({input:{}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockReturnValue((0,a.CommandResultFactory)({error:new N.UnknownDeviceExchangeError("Close app failed")}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new N.UnknownDeviceExchangeError("Close app failed")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion fails",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}}),o=new h.GlobalCommandError({...h.GLOBAL_ERRORS[5501],errorCode:"5501"});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,a.CommandResultFactory)({error:o}));const f=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:o}];(0,u.testDeviceActionStates)(n,f,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion does not return an app name",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new m.GoToDashboardDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),l.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,a.CommandResultFactory)({data:{name:null,version:"1.0.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new V.UnknownDAError("currentApp === null")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))})})});
1
+ "use strict";var a=require("../../../command/model/CommandResult"),h=require("../../../command/utils/GlobalCommandError"),S=require("../../../device/DeviceModel"),c=require("../../../device/DeviceStatus"),s=require("../../../device-action/__test-utils__/makeInternalApi"),d=require("../../../device-action/__test-utils__/setupTestMachine"),u=require("../../../device-action/__test-utils__/testDeviceActionStates"),e=require("../../../device-action/model/DeviceActionState"),t=require("../../../device-action/model/UserInteractionRequired"),V=require("../../../device-action/os/Errors"),p=require("../../../device-session/DeviceSessionState"),N=require("../../../../../src"),l=require("./GoToDashboardDeviceAction");vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("GoToDashboardDeviceAction",()=>{const v=vi.fn(),D=vi.fn(),m=vi.fn(),T=vi.fn();function A(){return{closeApp:v,getAppAndVersion:D,getDeviceSessionState:m,setDeviceSessionState:T}}const{sendCommand:f,getDeviceSessionState:k}=(0,s.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks()}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with device already on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new l.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1});const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should run the device action with device not on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new l.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),f.mockResolvedValueOnce((0,a.CommandResultFactory)({data:void 0})).mockResolvedValueOnce((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))}),describe("success cases",()=>{it("should success if the device is already on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new l.GoToDashboardDeviceAction({input:{unlockTimeout:500}});m.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"}}),D.mockReturnValue({app:"BOLOS",version:"1.5.0"}),vi.spyOn(n,"extractDependencies").mockReturnValue(A());const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should success if the device is not on dashboard",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)();const n=new l.GoToDashboardDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),m.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockReturnValue((0,a.CommandResultFactory)({data:{name:"BOLOS",version:"1.5.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{output:void 0,status:e.DeviceActionStatus.Completed}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))}),describe("error cases",()=>{it("should return an error if GetDeviceStatus return an error",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([new V.UnknownDAError("Unknown error")]);const n=new l.GoToDashboardDeviceAction({input:{unlockTimeout:500}});k.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.5.0"},installedApps:[],deviceModelId:S.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1});const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new V.UnknownDAError("Unknown error")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),describe("not on dashboard",()=>{it("should return an error if closeApp fails",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new l.GoToDashboardDeviceAction({input:{}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),m.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockReturnValue((0,a.CommandResultFactory)({error:new N.UnknownDeviceExchangeError("Close app failed")}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new N.UnknownDeviceExchangeError("Close app failed")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion fails",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new l.GoToDashboardDeviceAction({input:{unlockTimeout:500}}),o=new h.GlobalCommandError({...h.GLOBAL_ERRORS[5501],errorCode:"5501"});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),m.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,a.CommandResultFactory)({error:o}));const g=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:o}];(0,u.testDeviceActionStates)(n,g,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})})),it("should return an error if getAppAndVersion does not return an app name",()=>new Promise((r,i)=>{(0,d.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const n=new l.GoToDashboardDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A()),m.mockReturnValue({sessionStateType:p.DeviceSessionStateType.Connected,deviceStatus:c.DeviceStatus.CONNECTED,currentApp:"Bitcoin"}),v.mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,a.CommandResultFactory)({data:{name:null,version:"1.0.0"}}));const o=[{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:t.UserInteractionRequired.None},status:e.DeviceActionStatus.Pending},{status:e.DeviceActionStatus.Error,error:new V.UnknownDAError("currentApp === null")}];(0,u.testDeviceActionStates)(n,o,(0,s.makeDeviceActionInternalApiMock)(),{onDone:r,onError:i})}))})})});
2
2
  //# sourceMappingURL=GoToDashboardDeviceAction.test.js.map