@ledgerhq/device-management-kit 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/README.md +63 -28
  2. package/lib/cjs/package.json +1 -1
  3. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  4. package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
  5. package/lib/cjs/src/api/apdu/utils/ApduBuilder.js +1 -1
  6. package/lib/cjs/src/api/apdu/utils/ApduBuilder.js.map +3 -3
  7. package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
  8. package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
  9. package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
  10. package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
  11. package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
  12. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  13. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  14. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  15. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  16. package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  17. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  18. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  19. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  20. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
  21. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
  22. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
  23. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -1
  24. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +3 -3
  25. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  26. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  27. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
  28. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
  29. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js +1 -1
  30. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +3 -3
  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 +3 -3
  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 +3 -3
  35. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
  36. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js.map +3 -3
  37. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  38. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  39. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  40. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  41. package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js +1 -1
  42. package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js.map +3 -3
  43. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  44. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  45. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
  46. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +2 -2
  47. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
  48. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +3 -3
  49. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
  50. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
  51. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
  52. package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
  53. package/lib/cjs/src/api/device-action/os/ListApps/types.js +1 -1
  54. package/lib/cjs/src/api/device-action/os/ListApps/types.js.map +3 -3
  55. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  56. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  57. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  58. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  59. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -1
  60. package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js.map +3 -3
  61. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  62. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  63. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  64. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  65. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
  66. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +3 -3
  67. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  68. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
  69. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
  70. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
  71. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -1
  72. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +3 -3
  73. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  74. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
  75. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  76. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
  77. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
  78. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +3 -3
  79. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  80. package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
  81. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  82. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  83. package/lib/cjs/src/api/index.js +1 -1
  84. package/lib/cjs/src/api/index.js.map +3 -3
  85. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
  86. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
  87. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
  88. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
  89. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  90. package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
  91. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  92. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  93. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  94. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  95. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
  96. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
  97. package/lib/cjs/src/api/transport/model/Errors.js +1 -1
  98. package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
  99. package/lib/cjs/src/api/types.js +1 -1
  100. package/lib/cjs/src/api/types.js.map +1 -1
  101. package/lib/cjs/src/api/utils/ApplicationChecker.js +2 -0
  102. package/lib/cjs/src/api/utils/ApplicationChecker.js.map +7 -0
  103. package/lib/cjs/src/api/utils/ApplicationChecker.test.js +2 -0
  104. package/lib/cjs/src/api/utils/ApplicationChecker.test.js.map +7 -0
  105. package/lib/cjs/src/api/utils/ApplicationResolver.js +2 -0
  106. package/lib/cjs/src/api/utils/ApplicationResolver.js.map +7 -0
  107. package/lib/cjs/src/api/utils/Base64String.js +1 -1
  108. package/lib/cjs/src/api/utils/Base64String.js.map +3 -3
  109. package/lib/cjs/src/api/utils/Base64String.test.js +1 -1
  110. package/lib/cjs/src/api/utils/Base64String.test.js.map +3 -3
  111. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
  112. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  113. package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js +1 -1
  114. package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
  115. package/lib/cjs/src/internal/device-session/model/DevicePinger.js +1 -1
  116. package/lib/cjs/src/internal/device-session/model/DevicePinger.js.map +2 -2
  117. package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js +1 -1
  118. package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
  119. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  120. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
  121. package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js +1 -1
  122. package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
  123. package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
  124. package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
  125. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  126. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
  127. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  128. package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  129. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
  130. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
  131. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
  132. package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
  133. package/lib/cjs/src/internal/device-session/service/IntentQueueService.js +2 -0
  134. package/lib/cjs/src/internal/device-session/service/IntentQueueService.js.map +7 -0
  135. package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js +2 -0
  136. package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
  137. package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
  138. package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
  139. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  140. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  141. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  142. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  143. package/lib/esm/package.json +1 -1
  144. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  145. package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
  146. package/lib/esm/src/api/apdu/utils/ApduBuilder.js +1 -1
  147. package/lib/esm/src/api/apdu/utils/ApduBuilder.js.map +3 -3
  148. package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
  149. package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
  150. package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
  151. package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
  152. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  153. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  154. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
  155. package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
  156. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  157. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  158. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  159. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
  160. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
  161. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
  162. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -0
  163. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +4 -4
  164. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  165. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +3 -3
  166. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
  167. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
  168. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js +1 -0
  169. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js.map +4 -4
  170. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  171. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
  172. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  173. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
  174. package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js +1 -0
  175. package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js.map +4 -4
  176. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  177. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  178. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
  179. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
  180. package/lib/esm/src/api/device-action/os/GoToDashboard/types.js +1 -0
  181. package/lib/esm/src/api/device-action/os/GoToDashboard/types.js.map +4 -4
  182. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  183. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +3 -3
  184. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
  185. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +3 -3
  186. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -0
  187. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js.map +4 -4
  188. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
  189. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
  190. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
  191. package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
  192. package/lib/esm/src/api/device-action/os/ListApps/types.js +1 -0
  193. package/lib/esm/src/api/device-action/os/ListApps/types.js.map +4 -4
  194. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
  195. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
  196. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
  197. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
  198. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -0
  199. package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js.map +4 -4
  200. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  201. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  202. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  203. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  204. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -0
  205. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js.map +4 -4
  206. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  207. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
  208. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
  209. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
  210. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -0
  211. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js.map +4 -4
  212. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  213. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
  214. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
  215. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
  216. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -0
  217. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +4 -4
  218. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
  219. package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
  220. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  221. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  222. package/lib/esm/src/api/index.js +1 -1
  223. package/lib/esm/src/api/index.js.map +3 -3
  224. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
  225. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
  226. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
  227. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
  228. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
  229. package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +3 -3
  230. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  231. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  232. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  233. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  234. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
  235. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
  236. package/lib/esm/src/api/transport/model/Errors.js +1 -1
  237. package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
  238. package/lib/esm/src/api/utils/ApplicationChecker.js +2 -0
  239. package/lib/esm/src/api/utils/ApplicationChecker.js.map +7 -0
  240. package/lib/esm/src/api/utils/ApplicationChecker.test.js +2 -0
  241. package/lib/esm/src/api/utils/ApplicationChecker.test.js.map +7 -0
  242. package/lib/esm/src/api/utils/ApplicationResolver.js +1 -0
  243. package/lib/esm/src/api/utils/ApplicationResolver.js.map +7 -0
  244. package/lib/esm/src/api/utils/Base64String.js +1 -1
  245. package/lib/esm/src/api/utils/Base64String.js.map +3 -3
  246. package/lib/esm/src/api/utils/Base64String.test.js +1 -1
  247. package/lib/esm/src/api/utils/Base64String.test.js.map +3 -3
  248. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
  249. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  250. package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js +1 -1
  251. package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
  252. package/lib/esm/src/internal/device-session/model/DevicePinger.js +1 -1
  253. package/lib/esm/src/internal/device-session/model/DevicePinger.js.map +2 -2
  254. package/lib/esm/src/internal/device-session/model/DevicePinger.test.js +1 -1
  255. package/lib/esm/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
  256. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  257. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
  258. package/lib/esm/src/internal/device-session/model/DeviceSession.test.js +1 -1
  259. package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
  260. package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
  261. package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
  262. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
  263. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
  264. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
  265. package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
  266. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
  267. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
  268. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
  269. package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
  270. package/lib/esm/src/internal/device-session/service/IntentQueueService.js +2 -0
  271. package/lib/esm/src/internal/device-session/service/IntentQueueService.js.map +7 -0
  272. package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js +2 -0
  273. package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
  274. package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
  275. package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
  276. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
  277. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
  278. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
  279. package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
  280. package/lib/types/src/api/DeviceManagementKit.d.ts +10 -0
  281. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  282. package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts +7 -0
  283. package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts.map +1 -1
  284. package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts +17 -0
  285. package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts.map +1 -0
  286. package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts +2 -0
  287. package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts.map +1 -0
  288. package/lib/types/src/api/device-action/DeviceAction.d.ts +2 -1
  289. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  290. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  291. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
  292. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +4 -1
  293. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  294. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
  295. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +9 -1
  296. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
  297. package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
  298. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +13 -2
  299. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
  300. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  301. package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts +6 -0
  302. package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts.map +1 -1
  303. package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts +1 -1
  304. package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
  305. package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts +9 -1
  306. package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts.map +1 -1
  307. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
  308. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +9 -1
  309. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
  310. package/lib/types/src/api/device-action/os/ListApps/ListAppsDeviceAction.d.ts.map +1 -1
  311. package/lib/types/src/api/device-action/os/ListApps/types.d.ts +6 -0
  312. package/lib/types/src/api/device-action/os/ListApps/types.d.ts.map +1 -1
  313. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
  314. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts +8 -1
  315. package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts.map +1 -1
  316. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
  317. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +12 -2
  318. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
  319. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
  320. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +8 -0
  321. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
  322. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
  323. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +9 -1
  324. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
  325. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +10 -1
  326. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
  327. package/lib/types/src/api/index.d.ts +11 -4
  328. package/lib/types/src/api/index.d.ts.map +1 -1
  329. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts +12 -0
  330. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts.map +1 -0
  331. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts +2 -0
  332. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts.map +1 -0
  333. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
  334. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +1 -0
  335. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
  336. package/lib/types/src/api/transport/model/Errors.d.ts +5 -0
  337. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  338. package/lib/types/src/api/types.d.ts +1 -0
  339. package/lib/types/src/api/types.d.ts.map +1 -1
  340. package/lib/types/src/api/utils/ApplicationChecker.d.ts +14 -0
  341. package/lib/types/src/api/utils/ApplicationChecker.d.ts.map +1 -0
  342. package/lib/types/src/api/utils/ApplicationChecker.test.d.ts +2 -0
  343. package/lib/types/src/api/utils/ApplicationChecker.test.d.ts.map +1 -0
  344. package/lib/types/src/api/utils/ApplicationResolver.d.ts +12 -0
  345. package/lib/types/src/api/utils/ApplicationResolver.d.ts.map +1 -0
  346. package/lib/types/src/api/utils/Base64String.d.ts +1 -0
  347. package/lib/types/src/api/utils/Base64String.d.ts.map +1 -1
  348. package/lib/types/src/internal/device-session/di/deviceSessionModule.d.ts.map +1 -1
  349. package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts +1 -0
  350. package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts.map +1 -1
  351. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +13 -2
  352. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  353. package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts +3 -1
  354. package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts.map +1 -1
  355. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts +0 -1
  356. package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
  357. package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts +1 -0
  358. package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts.map +1 -1
  359. package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts +101 -0
  360. package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts.map +1 -0
  361. package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts +2 -0
  362. package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts.map +1 -0
  363. package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts +19 -0
  364. package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts.map +1 -0
  365. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  366. package/package.json +4 -4
  367. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
  368. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
  369. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
  370. package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
  371. package/lib/cjs/src/internal/device-session/service/MutexService.js +0 -2
  372. package/lib/cjs/src/internal/device-session/service/MutexService.js.map +0 -7
  373. package/lib/cjs/src/internal/device-session/service/MutexService.test.js +0 -2
  374. package/lib/cjs/src/internal/device-session/service/MutexService.test.js.map +0 -7
  375. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
  376. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
  377. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
  378. package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
  379. package/lib/esm/src/internal/device-session/service/MutexService.js +0 -2
  380. package/lib/esm/src/internal/device-session/service/MutexService.js.map +0 -7
  381. package/lib/esm/src/internal/device-session/service/MutexService.test.js +0 -2
  382. package/lib/esm/src/internal/device-session/service/MutexService.test.js.map +0 -7
  383. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +0 -17
  384. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +0 -1
  385. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts +0 -2
  386. package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts.map +0 -1
  387. package/lib/types/src/internal/device-session/service/MutexService.d.ts +0 -6
  388. package/lib/types/src/internal/device-session/service/MutexService.d.ts.map +0 -1
  389. package/lib/types/src/internal/device-session/service/MutexService.test.d.ts +0 -2
  390. package/lib/types/src/internal/device-session/service/MutexService.test.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n BTC_APP,\n BTC_APP_METADATA,\n CUSTOM_LOCK_SCREEN_APP,\n CUSTOM_LOCK_SCREEN_APP_METADATA,\n ETH_APP,\n ETH_APP_METADATA,\n} from \"@api/device-action/__test-utils__/data\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { setupListAppsMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\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 { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport { HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { ListAppsWithMetadataDeviceAction } from \"./ListAppsWithMetadataDeviceAction\";\nimport { type ListAppsWithMetadataDAState } from \"./types\";\n\nvi.mock(\"@api/device-action/os/ListApps/ListAppsDeviceAction\");\n\ndescribe(\"ListAppsWithMetadataDeviceAction\", () => {\n const { getManagerApiService: getManagerApiServiceMock } =\n makeDeviceActionInternalApiMock();\n\n const setDeviceSessionStateMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const getAppsByHashMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppsByHash: getAppsByHashMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"success case\", () => {\n it(\"should run the device actions with no apps installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Right([])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n status: DeviceActionStatus.Completed,\n output: [],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 1 app installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Right([BTC_APP_METADATA])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 2 apps installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP, ETH_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockResolvedValue(Right([BTC_APP_METADATA, ETH_APP_METADATA])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA, ETH_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 1 app installed and a custom lock screen\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP, CUSTOM_LOCK_SCREEN_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockResolvedValue(\n Right([BTC_APP_METADATA, CUSTOM_LOCK_SCREEN_APP_METADATA]),\n ),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA, CUSTOM_LOCK_SCREEN_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"error case\", () => {\n it(\"should error when ListApps fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([], true);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"ListApps failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when getAppsByHash rejects\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockRejectedValue(new UnknownDAError(\"getAppsByHash failed\")),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"getAppsByHash failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when getAppsByHash fails but error is known\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n const error = new HttpFetchApiError(new Error(\"Failed to fetch data\"));\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Left(error)),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n status: DeviceActionStatus.Error,\n error,\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when SaveSession fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getAppsByHashMock.mockImplementation(async () =>\n Promise.resolve(Right([BTC_APP_METADATA])),\n );\n\n vi.spyOn(\n listAppsWithMetadataDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: \"BOLOS\",\n installedApps: [],\n });\n\n setDeviceSessionStateMock.mockImplementation(() => {\n throw new UnknownDAError(\"SaveSession failed\");\n });\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"SaveSession failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAA6B,oCAC7BC,EAOO,kDACPC,EAAgD,6DAChDC,EAAkC,8DAClCC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAA+B,wCAC/BC,EAAuC,kDACvCD,EAAkC,8CAGlCE,EAAiD,8CAGjD,GAAG,KAAK,qDAAqD,EAE7D,SAAS,mCAAoC,IAAM,CACjD,KAAM,CAAE,qBAAsBC,CAAyB,KACrD,mCAAgC,EAE5BC,EAA4B,GAAG,GAAG,EAClCC,EAA4B,GAAG,GAAG,EAClCC,EAAoB,GAAG,GAAG,EAEhC,SAASC,GAA0B,CACjC,MAAO,CACL,cAAeD,EACf,sBAAuBD,EACvB,sBAAuBD,CACzB,CACF,CAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,eAAgB,IAAM,CAC7B,GAAG,uDAAwD,IACzD,IAAI,QAAc,CAACI,EAASC,IAAW,IACrC,qBAAkB,CAAC,CAAC,EACpB,MAAMC,EACJ,IAAI,mCAAiC,CACnC,MAAO,CAAC,CACV,CAAC,EAEHP,EAAyB,gBAAgB,CACvC,cAAe,GAAG,GAAG,EAAE,qBAAkB,SAAM,CAAC,CAAC,CAAC,CACpD,CAAiC,EAEjC,MAAMQ,EAAqD,CACzD,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,aACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,OAAQ,qBAAmB,UAC3B,OAAQ,CAAC,CACX,CACF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,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,OAAQ,qBAAmB,MAC3B,MAAO,IAAI,iBAAe,oBAAoB,CAChD,CACF,KAEA,0BACED,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,CACH,CAAC",
6
- "names": ["import_purify_ts", "import_DeviceStatus", "import_data", "import_makeInternalApi", "import_setupTestMachine", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_ListAppsWithMetadataDeviceAction", "getManagerApiServiceMock", "setDeviceSessionStateMock", "getDeviceSessionStateMock", "getAppsByHashMock", "extractDependenciesMock", "resolve", "reject", "listAppsWithMetadataDeviceAction", "expectedStates", "error"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n BTC_APP,\n BTC_APP_METADATA,\n CUSTOM_LOCK_SCREEN_APP,\n CUSTOM_LOCK_SCREEN_APP_METADATA,\n ETH_APP,\n ETH_APP_METADATA,\n} from \"@api/device-action/__test-utils__/data\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { setupListAppsMock } from \"@api/device-action/__test-utils__/setupTestMachine\";\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 { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { listAppsDAStateStep } from \"@api/device-action/os/ListApps/types\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport { HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { ListAppsWithMetadataDeviceAction } from \"./ListAppsWithMetadataDeviceAction\";\nimport {\n type ListAppsWithMetadataDAState,\n listAppsWithMetadataDAStateStep,\n} from \"./types\";\n\nvi.mock(\"@api/device-action/os/ListApps/ListAppsDeviceAction\");\n\ndescribe(\"ListAppsWithMetadataDeviceAction\", () => {\n const { getManagerApiService: getManagerApiServiceMock } =\n makeDeviceActionInternalApiMock();\n\n const setDeviceSessionStateMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const getAppsByHashMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppsByHash: getAppsByHashMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"success case\", () => {\n it(\"should run the device actions with no apps installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Right([])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n status: DeviceActionStatus.Completed,\n output: [],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 1 app installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Right([BTC_APP_METADATA])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 2 apps installed\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP, ETH_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockResolvedValue(Right([BTC_APP_METADATA, ETH_APP_METADATA])),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA, ETH_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device actions with 1 app installed and a custom lock screen\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP, CUSTOM_LOCK_SCREEN_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockResolvedValue(\n Right([BTC_APP_METADATA, CUSTOM_LOCK_SCREEN_APP_METADATA]),\n ),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Completed,\n output: [BTC_APP_METADATA, CUSTOM_LOCK_SCREEN_APP_METADATA],\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"error case\", () => {\n it(\"should error when ListApps fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([], true);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"ListApps failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when getAppsByHash rejects\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi\n .fn()\n .mockRejectedValue(new UnknownDAError(\"getAppsByHash failed\")),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"getAppsByHash failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when getAppsByHash fails but error is known\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n const error = new HttpFetchApiError(new Error(\"Failed to fetch data\"));\n\n getManagerApiServiceMock.mockReturnValue({\n getAppsByHash: vi.fn().mockResolvedValue(Left(error)),\n } as unknown as ManagerApiService);\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n status: DeviceActionStatus.Error,\n error,\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error when SaveSession fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupListAppsMock([BTC_APP]);\n const listAppsWithMetadataDeviceAction =\n new ListAppsWithMetadataDeviceAction({\n input: {},\n });\n\n getAppsByHashMock.mockImplementation(async () =>\n Promise.resolve(Right([BTC_APP_METADATA])),\n );\n\n vi.spyOn(\n listAppsWithMetadataDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: \"BOLOS\",\n installedApps: [],\n });\n\n setDeviceSessionStateMock.mockImplementation(() => {\n throw new UnknownDAError(\"SaveSession failed\");\n });\n\n const expectedStates: Array<ListAppsWithMetadataDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // Ready\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.AllowListApps,\n step: listAppsDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // ListAppsDeviceAction\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // FetchMetadata\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: listAppsWithMetadataDAStateStep.LIST_APPS,\n },\n status: DeviceActionStatus.Pending, // SaveSession\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"SaveSession failed\"),\n },\n ];\n\n testDeviceActionStates(\n listAppsWithMetadataDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B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AED,MAAMO,EAAqD,CACzD,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,KACjD,KAAM,kCAAgC,SACxC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,cACjD,KAAM,sBAAoB,SAC5B,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,KACjD,KAAM,kCAAgC,SACxC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,KACjD,KAAM,kCAAgC,SACxC,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,OAAQ,qBAAmB,MAC3B,MAAO,IAAI,iBAAe,oBAAoB,CAChD,CACF,KAEA,0BACED,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_DeviceStatus", "import_data", "import_makeInternalApi", "import_setupTestMachine", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_types", "import_DeviceSessionState", "import_ListAppsWithMetadataDeviceAction", "getManagerApiServiceMock", "setDeviceSessionStateMock", "getDeviceSessionStateMock", "getAppsByHashMock", "extractDependenciesMock", "resolve", "reject", "listAppsWithMetadataDeviceAction", "expectedStates", "error"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var n=(e,t,a,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of s(t))!A.call(e,r)&&r!==a&&i(e,r,{get:()=>t[r],enumerable:!(p=o(t,r))||p.enumerable});return e};var m=e=>n(i({},"__esModule",{value:!0}),e);var d={};module.exports=m(d);
1
+ "use strict";var r=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var n=(e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})},d=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of o(t))!A.call(e,p)&&p!==a&&r(e,p,{get:()=>t[p],enumerable:!(i=s(t,p))||i.enumerable});return e};var D=e=>d(r({},"__esModule",{value:!0}),e);var y={};n(y,{listAppsWithMetadataDAStateStep:()=>m});module.exports=D(y);const m=Object.freeze({LIST_APPS:"os.listAppsWithMetadata.steps.listApps",FETCH_METADATA:"os.listAppsWithMetadata.steps.fetchMetadata",SAVE_SESSION:"os.listAppsWithMetadata.steps.saveSession"});0&&(module.exports={listAppsWithMetadataDAStateStep});
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/ListAppsWithMetadata/types.ts"],
4
- "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type ListAppsErrorCodes } from \"@api/command/os/ListAppsCommand\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { type UnknownDAError } from \"@api/device-action/os/Errors\";\nimport {\n type ListAppsDAError,\n type ListAppsDAInput,\n type ListAppsDAIntermediateValue,\n} from \"@api/device-action/os/ListApps/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\n\nexport type ListAppsWithMetadataDAOutput = Array<Application | null>;\nexport type ListAppsWithMetadataDAInput = ListAppsDAInput;\n\nexport type ListAppsWithMetadataDAError =\n | ListAppsDAError\n | UnknownDAError\n | HttpFetchApiError\n | CommandErrorResult<ListAppsErrorCodes>[\"error\"];\n\nexport type ListAppsWithMetadataDARequiredInteraction =\n UserInteractionRequired.None;\n\nexport type ListAppsWithMetadataDAIntermediateValue =\n | ListAppsDAIntermediateValue\n | {\n requiredUserInteraction: ListAppsWithMetadataDARequiredInteraction;\n };\n\nexport type ListAppsWithMetadataDAState = DeviceActionState<\n ListAppsWithMetadataDAOutput,\n ListAppsWithMetadataDAError,\n ListAppsWithMetadataDAIntermediateValue\n>;\n"],
5
- "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
- "names": ["types_exports", "__toCommonJS"]
4
+ "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type ListAppsErrorCodes } from \"@api/command/os/ListAppsCommand\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { type UnknownDAError } from \"@api/device-action/os/Errors\";\nimport {\n type ListAppsDAError,\n type ListAppsDAInput,\n type ListAppsDAIntermediateValue,\n} from \"@api/device-action/os/ListApps/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\n\nexport const listAppsWithMetadataDAStateStep = Object.freeze({\n LIST_APPS: \"os.listAppsWithMetadata.steps.listApps\",\n FETCH_METADATA: \"os.listAppsWithMetadata.steps.fetchMetadata\",\n SAVE_SESSION: \"os.listAppsWithMetadata.steps.saveSession\",\n} as const);\n\nexport type ListAppsWithMetadataDAStateStep =\n (typeof listAppsWithMetadataDAStateStep)[keyof typeof listAppsWithMetadataDAStateStep];\n\nexport type ListAppsWithMetadataDAOutput = Array<Application | null>;\nexport type ListAppsWithMetadataDAInput = ListAppsDAInput;\n\nexport type ListAppsWithMetadataDAError =\n | ListAppsDAError\n | UnknownDAError\n | HttpFetchApiError\n | CommandErrorResult<ListAppsErrorCodes>[\"error\"];\n\nexport type ListAppsWithMetadataDARequiredInteraction =\n UserInteractionRequired.None;\n\nexport type ListAppsWithMetadataDAIntermediateValue =\n | ListAppsDAIntermediateValue\n | {\n readonly requiredUserInteraction: ListAppsWithMetadataDARequiredInteraction;\n readonly step: ListAppsWithMetadataDAStateStep;\n };\n\nexport type ListAppsWithMetadataDAState = DeviceActionState<\n ListAppsWithMetadataDAOutput,\n ListAppsWithMetadataDAError,\n ListAppsWithMetadataDAIntermediateValue\n>;\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAaO,MAAME,EAAkC,OAAO,OAAO,CAC3D,UAAW,yCACX,eAAgB,8CAChB,aAAc,2CAChB,CAAU",
6
+ "names": ["types_exports", "__export", "listAppsWithMetadataDAStateStep", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var k=(a,t)=>{for(var i in t)l(a,i,{get:t[i],enumerable:!0})},_=(a,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of N(t))!I.call(a,r)&&r!==i&&l(a,r,{get:()=>t[r],enumerable:!(o=x(t,r))||o.enumerable});return a};var M=a=>_(l({},"__esModule",{value:!0}),a);var V={};k(V,{OpenAppDeviceAction:()=>b});module.exports=M(V);var u=require("purify-ts"),n=require("xstate"),A=require("../../../command/model/CommandResult"),S=require("../../../command/os/CloseAppCommand"),m=require("../../../command/os/OpenAppCommand"),c=require("../../../device-action/model/UserInteractionRequired"),D=require("../../../device-action/os/Const"),g=require("../../../device-action/os/Errors"),y=require("../../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),O=require("../../../device-action/xstate-utils/XStateDeviceAction"),d=require("../../../device-session/DeviceSessionState"),v=require("../../../transport/model/Errors"),h=require("../../../utils/AppName");class b extends O.XStateDeviceAction{makeStateMachine(t){const{closeApp:i,openApp:o,getDeviceSessionState:r,isDeviceOnboarded:E,setDeviceSessionState:f}=this.extractDependencies(t),R=this.input.unlockTimeout??D.DEFAULT_UNLOCK_TIMEOUT_MS,C=new y.GetDeviceStatusDeviceAction({input:{unlockTimeout:R}}).makeStateMachine(t);return(0,n.setup)({types:{input:{},context:{},output:{}},actors:{closeApp:(0,n.fromPromise)(i),openApp:(0,n.fromPromise)(o),getDeviceStatus:C},guards:{isDeviceOnboarded:()=>E(),isRequestedAppOpen:({context:e})=>e._internalState.currentlyRunningApp===null?!1:e._internalState.currentlyRunningApp===e.input.appName,isDashboardOpen:({context:e})=>{if(e._internalState.currentlyRunningApp===null)throw new Error("context.currentlyRunningApp === null");return(0,h.isDashboardName)(e._internalState.currentlyRunningApp)},hasDisconnectedWhileSending:({context:e})=>e._internalState.error!==null&&e._internalState.error instanceof v.DeviceDisconnectedWhileSendingError,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new g.DeviceNotOnboardedError})}),assignUserActionNeededOpenApp:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.ConfirmOpenApp})}),assignNoUserActionNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.None})}),assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoError:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:null})})}}).createMachine({id:"OpenAppDeviceAction",initial:"DeviceReady",context:({input:e})=>{const p=r(),{sessionStateType:s}=p;return{input:e,intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},_internalState:{error:null,currentlyRunningApp:s===d.DeviceSessionStateType.ReadyWithoutSecureChannel?p.currentApp.name:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{target:"GetDeviceStatus",guard:{type:"isDeviceOnboarded"}},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:(0,n.assign)({_internalState:e=>e.event.output.caseOf({Right:p=>{const s=r();return s.sessionStateType!==d.DeviceSessionStateType.Connected&&f({...s,currentApp:{name:p.currentApp,version:p.currentAppVersion}}),{...e.context._internalState,currentlyRunningApp:p.currentApp}},Left:p=>({...e.context._internalState,currentlyRunningApp:null,error:p})})})},onError:{target:"Error",actions:[(0,n.assign)({_internalState:e=>({...e.context._internalState,currentlyRunningApp:null})}),"assignErrorFromEvent"]}}},CheckDeviceStatus:{always:[{target:"ApplicationReady",guard:"isRequestedAppOpen",actions:"assignNoError"},{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"OpenApplication",guard:"isDashboardOpen"},"CloseApplication"]},OpenApplication:{entry:"assignUserActionNeededOpenApp",exit:"assignNoUserActionNeeded",invoke:{src:"openApp",input:({context:e})=>({appName:e.input.appName}),onDone:{target:"OpenApplicationResultCheck",actions:(0,n.assign)({_internalState:e=>(0,A.isSuccessCommandResult)(e.event.output)?{...e.context._internalState,currentlyRunningApp:e.context.input.appName}:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"OpenApplicationResultCheck",actions:"assignErrorFromEvent"}}},OpenApplicationResultCheck:{always:[{target:"GetDeviceStatus",guard:"hasDisconnectedWhileSending"},{target:"Error",guard:"hasError"},{target:"GetDeviceStatus"}]},CloseApplication:{invoke:{src:"closeApp",onDone:{target:"CloseApplicationResultCheck",actions:(0,n.assign)({_internalState:e=>(0,A.isSuccessCommandResult)(e.event.output)?{...e.context._internalState,currentlyRunningApp:"BOLOS"}:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseApplicationResultCheck:{always:[{target:"Error",guard:"hasError"},{target:"OpenApplication"}]},ApplicationReady:{always:"Success"},Success:{type:"final",actions:"assignNoError"},Error:{type:"final"}},output:({context:e})=>e._internalState.error?(0,u.Left)(e._internalState.error):(0,u.Right)(void 0)})}extractDependencies(t){return{closeApp:async()=>t.sendCommand(new S.CloseAppCommand),openApp:async r=>t.sendCommand(new m.OpenAppCommand({appName:r.input.appName})),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:r=>t.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}0&&(module.exports={OpenAppDeviceAction});
1
+ "use strict";var l=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var k=(a,t)=>{for(var i in t)l(a,i,{get:t[i],enumerable:!0})},M=(a,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!_.call(a,r)&&r!==i&&l(a,r,{get:()=>t[r],enumerable:!(o=N(t,r))||o.enumerable});return a};var b=a=>M(l({},"__esModule",{value:!0}),a);var V={};k(V,{OpenAppDeviceAction:()=>T});module.exports=b(V);var u=require("purify-ts"),n=require("xstate"),A=require("../../../command/model/CommandResult"),S=require("../../../command/os/CloseAppCommand"),m=require("../../../command/os/OpenAppCommand"),c=require("../../../device-action/model/UserInteractionRequired"),D=require("../../../device-action/os/Const"),g=require("../../../device-action/os/Errors"),y=require("../../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),O=require("../../../device-action/xstate-utils/XStateDeviceAction"),d=require("../../../device-session/DeviceSessionState"),v=require("../../../transport/model/Errors"),h=require("../../../utils/AppName"),E=require("./types");class T extends O.XStateDeviceAction{makeStateMachine(t){const{closeApp:i,openApp:o,getDeviceSessionState:r,isDeviceOnboarded:f,setDeviceSessionState:C}=this.extractDependencies(t),R=this.input.unlockTimeout??D.DEFAULT_UNLOCK_TIMEOUT_MS,x=new y.GetDeviceStatusDeviceAction({input:{unlockTimeout:R}}).makeStateMachine(t);return(0,n.setup)({types:{input:{},context:{},output:{}},actors:{closeApp:(0,n.fromPromise)(i),openApp:(0,n.fromPromise)(o),getDeviceStatus:x},guards:{isDeviceOnboarded:()=>f(),isRequestedAppOpen:({context:e})=>e._internalState.currentlyRunningApp===null?!1:e._internalState.currentlyRunningApp===e.input.appName,isDashboardOpen:({context:e})=>{if(e._internalState.currentlyRunningApp===null)throw new Error("context.currentlyRunningApp === null");return(0,h.isDashboardName)(e._internalState.currentlyRunningApp)},hasDisconnectedWhileSending:({context:e})=>e._internalState.error!==null&&e._internalState.error instanceof v.DeviceDisconnectedWhileSendingError,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new g.DeviceNotOnboardedError})}),assignUserActionNeededOpenApp:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.ConfirmOpenApp})}),assignNoUserActionNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.None})}),assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoError:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:null})})}}).createMachine({id:"OpenAppDeviceAction",initial:"DeviceReady",context:({input:e})=>{const p=r(),{sessionStateType:s}=p;return{input:e,intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None,step:E.openAppDAStateStep.GET_DEVICE_STATUS},_internalState:{error:null,currentlyRunningApp:s===d.DeviceSessionStateType.ReadyWithoutSecureChannel?p.currentApp.name:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{target:"GetDeviceStatus",guard:{type:"isDeviceOnboarded"}},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:(0,n.assign)({_internalState:e=>e.event.output.caseOf({Right:p=>{const s=r();return s.sessionStateType!==d.DeviceSessionStateType.Connected&&C({...s,currentApp:{name:p.currentApp,version:p.currentAppVersion}}),{...e.context._internalState,currentlyRunningApp:p.currentApp}},Left:p=>({...e.context._internalState,currentlyRunningApp:null,error:p})})})},onError:{target:"Error",actions:[(0,n.assign)({_internalState:e=>({...e.context._internalState,currentlyRunningApp:null})}),"assignErrorFromEvent"]}}},CheckDeviceStatus:{always:[{target:"ApplicationReady",guard:"isRequestedAppOpen",actions:"assignNoError"},{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"OpenApplication",guard:"isDashboardOpen"},"CloseApplication"]},OpenApplication:{entry:"assignUserActionNeededOpenApp",exit:"assignNoUserActionNeeded",invoke:{src:"openApp",input:({context:e})=>({appName:e.input.appName}),onDone:{target:"OpenApplicationResultCheck",actions:(0,n.assign)({_internalState:e=>(0,A.isSuccessCommandResult)(e.event.output)?{...e.context._internalState,currentlyRunningApp:e.context.input.appName}:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"OpenApplicationResultCheck",actions:"assignErrorFromEvent"}}},OpenApplicationResultCheck:{always:[{target:"GetDeviceStatus",guard:"hasDisconnectedWhileSending"},{target:"Error",guard:"hasError"},{target:"GetDeviceStatus"}]},CloseApplication:{invoke:{src:"closeApp",onDone:{target:"CloseApplicationResultCheck",actions:(0,n.assign)({_internalState:e=>(0,A.isSuccessCommandResult)(e.event.output)?{...e.context._internalState,currentlyRunningApp:"BOLOS"}:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseApplicationResultCheck:{always:[{target:"Error",guard:"hasError"},{target:"OpenApplication"}]},ApplicationReady:{always:"Success"},Success:{type:"final",actions:"assignNoError"},Error:{type:"final"}},output:({context:e})=>e._internalState.error?(0,u.Left)(e._internalState.error):(0,u.Right)(void 0)})}extractDependencies(t){return{closeApp:async()=>t.sendCommand(new S.CloseAppCommand),openApp:async r=>t.sendCommand(new m.OpenAppCommand({appName:r.input.appName})),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:r=>t.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}0&&(module.exports={OpenAppDeviceAction});
2
2
  //# sourceMappingURL=OpenAppDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n OpenAppCommand,\n type OpenAppCommandResult,\n} from \"@api/command/os/OpenAppCommand\";\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 { DeviceNotOnboardedError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\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\";\nimport { DeviceDisconnectedWhileSendingError } from \"@api/transport/model/Errors\";\nimport { isDashboardName } from \"@api/utils/AppName\";\n\nimport {\n type OpenAppDAError,\n type OpenAppDAInput,\n type OpenAppDAIntermediateValue,\n type OpenAppDAOutput,\n} from \"./types\";\n\ntype OpenAppStateMachineInternalState = {\n readonly currentlyRunningApp: string | null;\n readonly error: OpenAppDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly openApp: (arg0: {\n input: { appName: string };\n }) => Promise<OpenAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (state: DeviceSessionState) => void;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\n/**\n * Opens a given app on the device.\n *\n * It checks if the device is onboarded, unlocked, and which app is currently open.\n * If the current app is the dashboard, it will directly open the requested app.\n * If another app is opened, it will close the current app and open the requested app.\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new OpenAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class OpenAppDeviceAction extends XStateDeviceAction<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n > {\n type types = StateMachineTypes<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n >;\n\n const {\n closeApp,\n openApp,\n getDeviceSessionState,\n isDeviceOnboarded,\n setDeviceSessionState,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n closeApp: fromPromise(closeApp),\n openApp: fromPromise(openApp),\n getDeviceStatus: getDeviceStatusMachine,\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 isRequestedAppOpen: ({ context }: { context: types[\"context\"] }) => {\n if (context._internalState.currentlyRunningApp === null) return false;\n return (\n context._internalState.currentlyRunningApp === context.input.appName\n );\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) => {\n if (context._internalState.currentlyRunningApp === null)\n throw new Error(\"context.currentlyRunningApp === null\");\n return isDashboardName(context._internalState.currentlyRunningApp);\n },\n hasDisconnectedWhileSending: ({ context }) =>\n context._internalState.error !== null &&\n context._internalState.error instanceof\n DeviceDisconnectedWhileSendingError,\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 assignUserActionNeededOpenApp: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // FIXME: add a typeguard\n }),\n }),\n assignNoError: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: null,\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHkAOYB2BBVqAiYAbgJYDGYWpALsQPYYB0BJ5ASmAIYQCeAxANoAGALqJQqWrGI16YkAA9EARhWCGADgAsAZm1b1SwUoDspgDQhuiAEzX1DbQE5tJlQDYlm414CsAXz8LNEwcfCIyCmo6RmQMACNaDgAnCGIMKABhAAswUgBrARE5CSkZDDlFBCUPbQYfZx91H0FtTRNjCysEbWM1bTdHAzcfH2q9awCg9Gxc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W-TGIMfmO6zNmLHVmNlOtGAOiGO0o2ztke5DGDYxd4ZXXzN3uZU1RPBBjTNM7UtdAWxjqQZ6gqv0LyO9oruPkywe49D7adt2vaI8jauB+796e6dC7TvjLnR11d1x955xJ1cKeIAZ6dGEJqJKk4qqq3ttdF-XIc67zrdue3CLVG4gqZyMpbGG4bhBeoq9b-mB7jaTZYT+JU86sX05z5R2wLxlG78oKYpNKW16mx9x6EkhWdGKTSvXgLrFKSENcbsC4Hwa6i9eQHgQgmCkIlBjKmcEFUY24ejaSTMeCkHxPgYFoBAOAcgA5u1um3XkABaHeEoKEEkKvQwQJ4XjKl6ErIBDUmCenATwA2RM7rknUm4FUhV-oiTJFTCUth05j0xJVFUTxt7sIOssRIKRQRyV4bdWOTNkTqDekqAwbxNDIUzFIhwzhZHVHkf0akZ9rKFx1CyPI6j2SaJjsoUsBIBimB8MMeUZJqFdH6PYDwKYBjwQaEYpRtlOYzlfC2NxS8bB6HsM4RUIwiSH0VNxAy6lkL1EEjTYUtisLn1ISAhuDZZxvhvpsRJmVX51FJFlZ4-Qk5wUYcxR2BTTIGUKtEvCoDpwaMUobbqugUzIg8PmEwIiTJ9yqAMaUW90IngCaIgZcUEpJVUa1Vxoy+GVGMbvZiuVf5IM8CoTZOpNZDL4eQjcIlDLIRRH5FhoxDyIGFMiASe8IoFlGNchaS0waxNqfkepG4tACiMGeQw6IiQeBGncMaMycxEl8eoIFu0fiVPbg87qSE3q6MVBpehPQ4K6G+uoZUJIVB7laNiq+2s4DkRGYTLRygs6GSQtmO4iIaWljgvUBgip-K5RErofOdiYocLBZwHhBzOWSkKqKz6Lw3i6U+QgPchlTB7xTPBeCWVHDYoAMqflIOQWA8AlXuO6KMQylImipgMi4BZzhDIKkpM0FEypRimplXNWyABRMuSRIXjNaKvHQ3h0Q0reCYT+3khGNEKgqIRxgAgBCAA */\n id: \"OpenAppDeviceAction\",\n initial: \"DeviceReady\",\n context: ({ input }) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n currentlyRunningApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n },\n };\n },\n states: {\n DeviceReady: {\n // check device capabilities & status known\n always: {\n target: \"OnboardingCheck\",\n },\n },\n\n OnboardingCheck: {\n // check onboarding status provided by device session\n always: [\n {\n target: \"GetDeviceStatus\",\n guard: {\n type: \"isDeviceOnboarded\",\n },\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<OpenAppStateMachineInternalState>(\n {\n Right: (output) => {\n const state: DeviceSessionState =\n getDeviceSessionState();\n\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: {\n name: output.currentApp,\n version: output.currentAppVersion,\n },\n });\n }\n return {\n ..._.context._internalState,\n currentlyRunningApp: output.currentApp,\n };\n },\n Left: (error) => ({\n ..._.context._internalState,\n currentlyRunningApp: null,\n error,\n }),\n },\n );\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: [\n assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n currentlyRunningApp: null,\n }),\n }),\n \"assignErrorFromEvent\",\n ],\n },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"ApplicationReady\",\n guard: \"isRequestedAppOpen\",\n // If target app is currently opened, we can ignore errors\n actions: \"assignNoError\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n\n DashboardCheck: {\n // Is the current application the dashboard\n always: [\n {\n target: \"OpenApplication\",\n guard: \"isDashboardOpen\",\n },\n \"CloseApplication\",\n ],\n },\n\n OpenApplication: {\n // execute openApp command,\n entry: \"assignUserActionNeededOpenApp\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n src: \"openApp\",\n input: ({ context }) => ({ appName: context.input.appName }),\n onDone: {\n target: \"OpenApplicationResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return {\n ..._.context._internalState,\n currentlyRunningApp: _.context.input.appName,\n };\n } else {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n }\n },\n }),\n },\n onError: {\n target: \"OpenApplicationResultCheck\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n\n OpenApplicationResultCheck: {\n always: [\n {\n // When an APDU triggers a disconnection, some transports may possibly\n // be closed on device side before the APDU response could be received,\n // especially on BLE transports.\n // Therefore when a disconnection occurs while sending, we should verify\n // the device status because it may have been successfully executed.\n target: \"GetDeviceStatus\",\n guard: \"hasDisconnectedWhileSending\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"GetDeviceStatus\" },\n ],\n },\n\n CloseApplication: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseApplicationResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return {\n ..._.context._internalState,\n currentlyRunningApp: \"BOLOS\",\n };\n } else {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CloseApplicationResultCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"OpenApplication\" },\n ],\n },\n\n ApplicationReady: {\n // application is ready to be used\n always: \"Success\",\n },\n\n // success state\n Success: {\n type: \"final\",\n actions: \"assignNoError\", // TODO, we should not need this\n },\n\n // error state\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n ? Left(context._internalState.error)\n : Right(undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const openApp = async (arg0: { input: { appName: string } }) =>\n internalApi.sendCommand(\n new OpenAppCommand({ appName: arg0.input.appName }),\n );\n\n return {\n closeApp,\n openApp,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAAuC,4CACvCC,EAGO,2CACPC,EAGO,0CAEPC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAAwC,wCACxCC,EAA4C,6EAE5CC,EAGO,8DACPC,EAGO,kDACPH,EAAoD,uCACpDI,EAAgC,8BA8CzB,MAAMb,UAA4B,oBAMvC,CACA,iBACEc,EAOA,CASA,KAAM,CACJ,SAAAC,EACA,QAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,sBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiB,4BAE5CC,EAAyB,IAAI,8BAA4B,CAC7D,MAAO,CACL,cAAAD,CACF,CACF,CAAC,EAAE,iBAAiBN,CAAW,EAE/B,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,YAAU,e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Q,eAAe,SACnB,QAAKA,EAAQ,eAAe,KAAK,KACjC,SAAM,MAAS,CACvB,CAAC,CACH,CAEA,oBAAoBR,EAA+C,CAOjE,MAAO,CACL,SAPe,SAAYA,EAAY,YAAY,IAAI,iBAAiB,EAQxE,QAPc,MAAOgB,GACrBhB,EAAY,YACV,IAAI,iBAAe,CAAE,QAASgB,EAAK,MAAM,OAAQ,CAAC,CACpD,EAKA,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBc,GACtBd,EAAY,sBAAsBc,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
6
- "names": ["OpenAppDeviceAction_exports", "__export", "OpenAppDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_CloseAppCommand", "import_OpenAppCommand", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_GetDeviceStatusDeviceAction", "import_XStateDeviceAction", "import_DeviceSessionState", "import_AppName", "internalApi", "closeApp", "openApp", "getDeviceSessionState", "isDeviceOnboarded", "setDeviceSessionState", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "input", "sessionState", "sessionStateType", "output", "state", "error", "arg0"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n OpenAppCommand,\n type OpenAppCommandResult,\n} from \"@api/command/os/OpenAppCommand\";\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 { DeviceNotOnboardedError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\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\";\nimport { DeviceDisconnectedWhileSendingError } from \"@api/transport/model/Errors\";\nimport { isDashboardName } from \"@api/utils/AppName\";\n\nimport {\n type OpenAppDAError,\n type OpenAppDAInput,\n type OpenAppDAIntermediateValue,\n type OpenAppDAOutput,\n openAppDAStateStep,\n} from \"./types\";\n\ntype OpenAppStateMachineInternalState = {\n readonly currentlyRunningApp: string | null;\n readonly error: OpenAppDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly openApp: (arg0: {\n input: { appName: string };\n }) => Promise<OpenAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (state: DeviceSessionState) => void;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\n/**\n * Opens a given app on the device.\n *\n * It checks if the device is onboarded, unlocked, and which app is currently open.\n * If the current app is the dashboard, it will directly open the requested app.\n * If another app is opened, it will close the current app and open the requested app.\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new OpenAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class OpenAppDeviceAction extends XStateDeviceAction<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n > {\n type types = StateMachineTypes<\n OpenAppDAOutput,\n OpenAppDAInput,\n OpenAppDAError,\n OpenAppDAIntermediateValue,\n OpenAppStateMachineInternalState\n >;\n\n const {\n closeApp,\n openApp,\n getDeviceSessionState,\n isDeviceOnboarded,\n setDeviceSessionState,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n closeApp: fromPromise(closeApp),\n openApp: fromPromise(openApp),\n getDeviceStatus: getDeviceStatusMachine,\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 isRequestedAppOpen: ({ context }: { context: types[\"context\"] }) => {\n if (context._internalState.currentlyRunningApp === null) return false;\n return (\n context._internalState.currentlyRunningApp === context.input.appName\n );\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) => {\n if (context._internalState.currentlyRunningApp === null)\n throw new Error(\"context.currentlyRunningApp === null\");\n return isDashboardName(context._internalState.currentlyRunningApp);\n },\n hasDisconnectedWhileSending: ({ context }) =>\n context._internalState.error !== null &&\n context._internalState.error instanceof\n DeviceDisconnectedWhileSendingError,\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 assignUserActionNeededOpenApp: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // FIXME: add a typeguard\n }),\n }),\n assignNoError: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: null,\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHkAOYB2BBVqAiYAbgJYDGYWpALsQPYYB0BJ5ASmAIYQCeAxANoAGALqJQqWrGI16YkAA9EARhWCGADgAsAZm1b1SwUoDspgDQhuiAEzX1DbQE5tJlQDYlm414CsAXz8LNEwcfCIyCmo6RmQMACNaDgAnCGIMKABhAAswUgBrARE5CSkZDDlFBCUPbQYfZx91H0FtTRNjCysEbWM1bTdHAzcfH2q9awCg9GxcZgjKMoZYhOTU9Ozcgv4lUSQQEuloiuUauoamlrbzSxtBNTu7pW1BEe1rJUmQYJmwlkjFgAytHyaUyOXyhV24kkh1ke0q7w8DDcxmqjkM1l6Kh8nUQzR8DEEjjcz3UxKUjiMbk+31Cc3IC2iDCBIPW4K2O2KMLKxwQiKUyNRAwxWKUOJu3TaDFsw28bkExmsgnU-Rp0zp4QZUXoDFCABsyBwylhCBxiHqOHE9WBeBB6GAGGlCLQ8g7abNNf8mfrDcbTebLdaEE7gUbokJhBGuaUjvCbCSCdZNI5UQqhg1cQhNOprAxND4XP0xZTHI01SEPX9GTqfaQw-QTWaLVabWAkklaEkGKgLVQAGadgC2S3Vlfm2sYtfr2H9zaDIbrZQjUb2Bx5cb5CelydTxnT2nFXTcmjUBYTzlazkcE0CX1Hv3HiynfqbgbA7FgAFc9VQNhCV9CMZwqAlQuAWZwHiqbStI0mY+PmdRKNYxLZmKgjvDeUwVg+WpPrgBqLtEjYBi2H7fr+7ICJyq7crGIGIK0LwME8dzJuizzNNYmZeLmAysZ4Ph2KYmiaOWPz0l6Nb4b60R-lsRQ0UB5Qbq0pgMM4FJ8dYx4KpomaOJo6k9G4yHvEhBmYmJGpV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UEpJVUa1Vxoy+GVGMbvZiuVf5IM8CoTZOpNZDL4eQjcIlDLIRRH5FhoxDyIGFMiASe8IoFlGNchaS0waxNqfkepG4tACiMGeQw6IiQeBGncMaMycxEl8eoIFu0fiVPbg87qSE3q6MVBpehPQ4K6G+uoZUJIVB7laNiq+2s4DkRGYTLRygs6GSQtmO4iIaWljgvUBgip-K5RErofOdiYocLBZwHhBzOWSkKqKz6Lw3i6U+QgPchlTB7xTPBeCWVHDYoAMqflIOQWA8AlXuO6KMQylImipgMi4BZzhDIKkpM0FEypRimplXNWyABRMuSRIXjNaKvHQ3h0Q0reCYT+3khGNEKgqIRxgAgBCAA */\n id: \"OpenAppDeviceAction\",\n initial: \"DeviceReady\",\n context: ({ input }) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n _internalState: {\n error: null,\n currentlyRunningApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n },\n };\n },\n states: {\n DeviceReady: {\n // check device capabilities & status known\n always: {\n target: \"OnboardingCheck\",\n },\n },\n\n OnboardingCheck: {\n // check onboarding status provided by device session\n always: [\n {\n target: \"GetDeviceStatus\",\n guard: {\n type: \"isDeviceOnboarded\",\n },\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<OpenAppStateMachineInternalState>(\n {\n Right: (output) => {\n const state: DeviceSessionState =\n getDeviceSessionState();\n\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: {\n name: output.currentApp,\n version: output.currentAppVersion,\n },\n });\n }\n return {\n ..._.context._internalState,\n currentlyRunningApp: output.currentApp,\n };\n },\n Left: (error) => ({\n ..._.context._internalState,\n currentlyRunningApp: null,\n error,\n }),\n },\n );\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: [\n assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n currentlyRunningApp: null,\n }),\n }),\n \"assignErrorFromEvent\",\n ],\n },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"ApplicationReady\",\n guard: \"isRequestedAppOpen\",\n // If target app is currently opened, we can ignore errors\n actions: \"assignNoError\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n\n DashboardCheck: {\n // Is the current application the dashboard\n always: [\n {\n target: \"OpenApplication\",\n guard: \"isDashboardOpen\",\n },\n \"CloseApplication\",\n ],\n },\n\n OpenApplication: {\n // execute openApp command,\n entry: \"assignUserActionNeededOpenApp\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n src: \"openApp\",\n input: ({ context }) => ({ appName: context.input.appName }),\n onDone: {\n target: \"OpenApplicationResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return {\n ..._.context._internalState,\n currentlyRunningApp: _.context.input.appName,\n };\n } else {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n }\n },\n }),\n },\n onError: {\n target: \"OpenApplicationResultCheck\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n\n OpenApplicationResultCheck: {\n always: [\n {\n // When an APDU triggers a disconnection, some transports may possibly\n // be closed on device side before the APDU response could be received,\n // especially on BLE transports.\n // Therefore when a disconnection occurs while sending, we should verify\n // the device status because it may have been successfully executed.\n target: \"GetDeviceStatus\",\n guard: \"hasDisconnectedWhileSending\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"GetDeviceStatus\" },\n ],\n },\n\n CloseApplication: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseApplicationResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return {\n ..._.context._internalState,\n currentlyRunningApp: \"BOLOS\",\n };\n } else {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CloseApplicationResultCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n { target: \"OpenApplication\" },\n ],\n },\n\n ApplicationReady: {\n // application is ready to be used\n always: \"Success\",\n },\n\n // success state\n Success: {\n type: \"final\",\n actions: \"assignNoError\", // TODO, we should not need this\n },\n\n // error state\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.error // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n ? Left(context._internalState.error)\n : Right(undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const openApp = async (arg0: { input: { appName: string } }) =>\n internalApi.sendCommand(\n new OpenAppCommand({ appName: arg0.input.appName }),\n );\n\n return {\n closeApp,\n openApp,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAAuC,4CACvCC,EAGO,2CACPC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,EAEA,iBAAkB,CAChB,OAAQ,CACN,IAAK,WACL,OAAQ,CACN,OAAQ,8BACR,WAAS,UAAO,CACd,eAAiBA,MACX,0BAAuBA,EAAE,MAAM,MAAM,EAChC,CACL,GAAGA,EAAE,QAAQ,eACb,oBAAqB,OACvB,EAEO,CACL,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,OAAO,KACxB,CAGN,CAAC,CACH,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,4BAA6B,CAC3B,OAAQ,CACN,CACE,OAAQ,QACR,MAAO,UACT,EACA,CAAE,OAAQ,iBAAkB,CAC9B,CACF,EAEA,iBAAkB,CAEhB,OAAQ,SACV,EAGA,QAAS,CACP,KAAM,QACN,QAAS,eACX,EAGA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAD,CAAQ,IACjBA,EAAQ,eAAe,SACnB,QAAKA,EAAQ,eAAe,KAAK,KACjC,SAAM,MAAS,CACvB,CAAC,CACH,CAEA,oBAAoBR,EAA+C,CAOjE,MAAO,CACL,SAPe,SAAYA,EAAY,YAAY,IAAI,iBAAiB,EAQxE,QAPc,MAAOgB,GACrBhB,EAAY,YACV,IAAI,iBAAe,CAAE,QAASgB,EAAK,MAAM,OAAQ,CAAC,CACpD,EAKA,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBc,GACtBd,EAAY,sBAAsBc,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
6
+ "names": ["OpenAppDeviceAction_exports", "__export", "OpenAppDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_CloseAppCommand", "import_OpenAppCommand", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_GetDeviceStatusDeviceAction", "import_XStateDeviceAction", "import_DeviceSessionState", "import_AppName", "import_types", "internalApi", "closeApp", "openApp", "getDeviceSessionState", "isDeviceOnboarded", "setDeviceSessionState", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "input", "sessionState", "sessionStateType", "output", "state", "error", "arg0"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var C=require("rxjs"),S=require("../../../command/Errors"),m=require("../../../command/model/CommandResult"),E=require("../../../device/DeviceModel"),a=require("../../../device/DeviceStatus"),p=require("../../../device-action/__test-utils__/makeInternalApi"),A=require("../../../device-action/__test-utils__/setupTestMachine"),c=require("../../../device-action/__test-utils__/testDeviceActionStates"),e=require("../../../device-action/model/DeviceActionState"),n=require("../../../device-action/model/UserInteractionRequired"),v=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),h=require("../../../transport/model/Errors"),u=require("./OpenAppDeviceAction");vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("OpenAppDeviceAction",()=>{const O=vi.fn(),D=vi.fn(),V=vi.fn(),d=vi.fn(),k=vi.fn(),y=vi.fn();function l(){return{getDeviceSessionState:d,setDeviceSessionState:k,getAppAndVersion:O,openApp:D,closeApp:V,isDeviceOnboarded:y}}const{getDeviceSessionState:w}=(0,p.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),y.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should end if the required application is opened",()=>new Promise((r,o)=>{w.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:E.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),(0,A.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"0.0.0"}]);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}}),i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should end in a success if the app is already opened",()=>new Promise((r,o)=>{d.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"}}),(0,A.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin",unlockTimeout:void 0}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in a success if the dashboard is open and open app succeeds",()=>new Promise((r,o)=>{d.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}),(0,A.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),D.mockResolvedValue((0,m.CommandResultFactory)({data:void 0}));const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}],{observable:N}=(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});(0,C.lastValueFrom)(N).then(()=>{expect(k).toHaveBeenCalledWith({deviceStatus:a.DeviceStatus.CONNECTED,sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,currentApp:{name:"Bitcoin",version:"1.0.0"}})})})),it("should end in a success if disconnection occurs while open app succeeds",()=>new Promise((r,o)=>{d.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),O.mockResolvedValue((0,m.CommandResultFactory)({data:{name:"BOLOS",version:"0.0.0"}})),(0,A.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"},{currentApp:"Bitcoin",currentAppVersion:"0.0.0"}]),D.mockRejectedValue(new h.DeviceDisconnectedWhileSendingError);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in a success if another app is open, close app succeeds and open app succeeds",()=>new Promise((r,o)=>{d.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,A.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"},{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),V.mockResolvedValue((0,m.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,m.CommandResultFactory)({data:void 0}));const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Completed,output:void 0}],{observable:N}=(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});(0,C.lastValueFrom)(N).then(()=>{expect(k).toHaveBeenCalledWith({currentApp:{name:"Bitcoin",version:"1.0.0"},deviceStatus:a.DeviceStatus.CONNECTED,sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel})})}))}),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:a.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),y.mockReturnValue(!1);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{error:new v.DeviceNotOnboardedError,status:e.DeviceActionStatus.Error}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the device is locked",()=>new Promise((r,o)=>{d.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,A.setupGetDeviceStatusMock)([new v.DeviceLockedError]);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new v.DeviceLockedError}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion returns an error",()=>new Promise((r,o)=>{d.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,A.setupGetDeviceStatusMock)([new S.InvalidStatusWordError("mocked error")]);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the dashboard is open and open app returns an error",()=>new Promise((r,o)=>{d.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),O.mockResolvedValue((0,m.CommandResultFactory)({data:{name:"BOLOS",version:"0.0.0"}})),(0,A.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),D.mockResolvedValue((0,m.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in a success if disconnection occurs while open app failed",()=>new Promise((r,o)=>{d.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),O.mockResolvedValue((0,m.CommandResultFactory)({data:{name:"BOLOS",version:"0.0.0"}})),(0,A.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"},{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),D.mockRejectedValue(new h.DeviceDisconnectedWhileSendingError);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new h.DeviceDisconnectedWhileSendingError}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if another app is open, and close app returns an error",()=>new Promise((r,o)=>{d.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,A.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),V.mockResolvedValue((0,m.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if another app is open, close app succeeds but open app returns an error",()=>new Promise((r,o)=>{d.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,A.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),V.mockResolvedValue((0,m.CommandResultFactory)({data:void 0})),D.mockResolvedValue((0,m.CommandResultFactory)({error:new S.InvalidStatusWordError("mocked error")}));const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new S.InvalidStatusWordError("mocked error")}];(0,c.testDeviceActionStates)(t,i,(0,p.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:a.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,A.setupGetDeviceStatusMock)([new v.UnknownDAError("Unknown error")]);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new v.UnknownDAError("Unknown error")}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if openApp actor throws an error",()=>new Promise((r,o)=>{d.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),(0,A.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),D.mockImplementation(()=>{throw new v.UnknownDAError("Unknown error")});const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp}},{status:e.DeviceActionStatus.Error,error:new v.UnknownDAError("Unknown error")}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if closeApp actor throws an error",()=>new Promise((r,o)=>{d.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),(0,A.setupGetDeviceStatusMock)([{currentApp:"anApp",currentAppVersion:"0.0.0"}]),V.mockImplementation(()=>{throw new v.UnknownDAError("Unknown error")});const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Error,error:new v.UnknownDAError("Unknown error")}];(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{d.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,A.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]);const t=new u.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(l());const i=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None}},{status:e.DeviceActionStatus.Stopped}],{cancel:N}=(0,c.testDeviceActionStates)(t,i,(0,p.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});N()}))})});
1
+ "use strict";var T=require("rxjs"),C=require("../../../command/Errors"),m=require("../../../command/model/CommandResult"),y=require("../../../device/DeviceModel"),a=require("../../../device/DeviceStatus"),c=require("../../../device-action/__test-utils__/makeInternalApi"),l=require("../../../device-action/__test-utils__/setupTestMachine"),u=require("../../../device-action/__test-utils__/testDeviceActionStates"),e=require("../../../device-action/model/DeviceActionState"),n=require("../../../device-action/model/UserInteractionRequired"),O=require("../../../device-action/os/Errors"),r=require("../../../device-action/os/GetDeviceStatus/types"),p=require("../../../device-session/DeviceSessionState"),R=require("../../../transport/model/Errors"),d=require("./OpenAppDeviceAction"),D=require("./types");vi.mock("@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction");describe("OpenAppDeviceAction",()=>{const N=vi.fn(),E=vi.fn(),v=vi.fn(),A=vi.fn(),h=vi.fn(),k=vi.fn();function S(){return{getDeviceSessionState:A,setDeviceSessionState:h,getAppAndVersion:N,openApp:E,closeApp:v,isDeviceOnboarded:k}}const{getDeviceSessionState:B}=(0,c.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),k.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should end if the required application is opened",()=>new Promise((o,i)=>{B.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"},installedApps:[],deviceModelId:y.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),(0,l.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"0.0.0"}]);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}}),s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})}))}),describe("success cases",()=>{it("should end in a success if the app is already opened",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"Bitcoin",version:"1.0.0"}}),(0,l.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin",unlockTimeout:void 0}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in a success if the dashboard is open and open app succeeds",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}),(0,l.setupGetDeviceStatusMock)([{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),E.mockResolvedValue((0,m.CommandResultFactory)({data:void 0}));const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Completed,output:void 0}],{observable:V}=(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i});(0,T.lastValueFrom)(V).then(()=>{expect(h).toHaveBeenCalledWith({deviceStatus:a.DeviceStatus.CONNECTED,sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,currentApp:{name:"Bitcoin",version:"1.0.0"}})})})),it("should end in a success if disconnection occurs while open app succeeds",()=>new Promise((o,i)=>{A.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),N.mockResolvedValue((0,m.CommandResultFactory)({data:{name:"BOLOS",version:"0.0.0"}})),(0,l.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"},{currentApp:"Bitcoin",currentAppVersion:"0.0.0"}]),E.mockRejectedValue(new R.DeviceDisconnectedWhileSendingError);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Completed,output:void 0}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in a success if another app is open, close app succeeds and open app succeeds",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,l.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"},{currentApp:"Bitcoin",currentAppVersion:"1.0.0"}]),v.mockResolvedValue((0,m.CommandResultFactory)({data:void 0})),E.mockResolvedValue((0,m.CommandResultFactory)({data:void 0}));const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Completed,output:void 0}],{observable:V}=(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i});(0,T.lastValueFrom)(V).then(()=>{expect(h).toHaveBeenCalledWith({currentApp:{name:"Bitcoin",version:"1.0.0"},deviceStatus:a.DeviceStatus.CONNECTED,sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel})})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockReturnValue(!1);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{error:new O.DeviceNotOnboardedError,status:e.DeviceActionStatus.Error}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if the device is locked",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,l.setupGetDeviceStatusMock)([new O.DeviceLockedError]);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new O.DeviceLockedError}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if getAppAndVersion returns an error",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,l.setupGetDeviceStatusMock)([new C.InvalidStatusWordError("mocked error")]);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new C.InvalidStatusWordError("mocked error")}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if the dashboard is open and open app returns an error",()=>new Promise((o,i)=>{A.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),N.mockResolvedValue((0,m.CommandResultFactory)({data:{name:"BOLOS",version:"0.0.0"}})),(0,l.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),E.mockResolvedValue((0,m.CommandResultFactory)({error:new C.InvalidStatusWordError("mocked error")}));const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new C.InvalidStatusWordError("mocked error")}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in a success if disconnection occurs while open app failed",()=>new Promise((o,i)=>{A.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),N.mockResolvedValue((0,m.CommandResultFactory)({data:{name:"BOLOS",version:"0.0.0"}})),(0,l.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"},{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),E.mockRejectedValue(new R.DeviceDisconnectedWhileSendingError);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new R.DeviceDisconnectedWhileSendingError}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if another app is open, and close app returns an error",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,l.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),v.mockResolvedValue((0,m.CommandResultFactory)({error:new C.InvalidStatusWordError("mocked error")}));const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new C.InvalidStatusWordError("mocked error")}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if another app is open, close app succeeds but open app returns an error",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,l.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]),v.mockResolvedValue((0,m.CommandResultFactory)({data:void 0})),E.mockResolvedValue((0,m.CommandResultFactory)({error:new C.InvalidStatusWordError("mocked error")}));const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new C.InvalidStatusWordError("mocked error")}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),(0,l.setupGetDeviceStatusMock)([new O.UnknownDAError("Unknown error")]);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new O.UnknownDAError("Unknown error")}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if openApp actor throws an error",()=>new Promise((o,i)=>{A.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),(0,l.setupGetDeviceStatusMock)([{currentApp:"BOLOS",currentAppVersion:"0.0.0"}]),E.mockImplementation(()=>{throw new O.UnknownDAError("Unknown error")});const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.ConfirmOpenApp,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new O.UnknownDAError("Unknown error")}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should end in an error if closeApp actor throws an error",()=>new Promise((o,i)=>{A.mockReturnValue((0,m.CommandResultFactory)({data:{sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"0.0.0"}}})),(0,l.setupGetDeviceStatusMock)([{currentApp:"anApp",currentAppVersion:"0.0.0"}]),v.mockImplementation(()=>{throw new O.UnknownDAError("Unknown error")});const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Error,error:new O.UnknownDAError("Unknown error")}];(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i})})),it("should emit a stopped state if the action is cancelled",()=>new Promise((o,i)=>{A.mockReturnValue({sessionStateType:p.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,currentApp:{name:"AnotherApp",version:"0.0.0"}}),(0,l.setupGetDeviceStatusMock)([{currentApp:"AnotherApp",currentAppVersion:"0.0.0"}]);const t=new d.OpenAppDeviceAction({input:{appName:"Bitcoin"}});vi.spyOn(t,"extractDependencies").mockReturnValue(S());const s=[{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:D.openAppDAStateStep.GET_DEVICE_STATUS}},{status:e.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:n.UserInteractionRequired.None,step:r.getDeviceStatusDAStateStep.ONBOARD_CHECK}},{status:e.DeviceActionStatus.Stopped}],{cancel:V}=(0,u.testDeviceActionStates)(t,s,(0,c.makeDeviceActionInternalApiMock)(),{onDone:o,onError:i});V()}))})});
2
2
  //# sourceMappingURL=OpenAppDeviceAction.test.js.map