@ledgerhq/device-management-kit 0.7.0 → 0.8.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 (388) hide show
  1. package/lib/cjs/package.json +1 -2
  2. package/lib/cjs/src/api/DeviceManagementKit.test.js +1 -1
  3. package/lib/cjs/src/api/DeviceManagementKit.test.js.map +2 -2
  4. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
  5. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.js.map +3 -3
  6. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
  7. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
  8. package/lib/cjs/src/api/apdu/utils/ByteArrayParser.js +1 -1
  9. package/lib/cjs/src/api/apdu/utils/ByteArrayParser.js.map +3 -3
  10. package/lib/cjs/src/api/command/di/commandModule.js +1 -1
  11. package/lib/cjs/src/api/command/di/commandModule.js.map +3 -3
  12. package/lib/cjs/src/api/command/di/commandModule.test.js +1 -1
  13. package/lib/cjs/src/api/command/di/commandModule.test.js.map +2 -2
  14. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  15. package/lib/cjs/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
  16. package/lib/cjs/src/api/command/utils/CommandUtils.js +1 -1
  17. package/lib/cjs/src/api/command/utils/CommandUtils.js.map +2 -2
  18. package/lib/cjs/src/api/command/utils/CommandUtils.test.js +1 -1
  19. package/lib/cjs/src/api/command/utils/CommandUtils.test.js.map +2 -2
  20. package/lib/cjs/src/api/command/utils/GlobalCommandError.js +1 -1
  21. package/lib/cjs/src/api/command/utils/GlobalCommandError.js.map +2 -2
  22. package/lib/cjs/src/api/device/DeviceModel.js +1 -1
  23. package/lib/cjs/src/api/device/DeviceModel.js.map +2 -2
  24. package/lib/cjs/src/api/device-action/di/deviceActionModule.js +1 -1
  25. package/lib/cjs/src/api/device-action/di/deviceActionModule.js.map +3 -3
  26. package/lib/cjs/src/api/device-action/di/deviceActionModule.test.js +1 -1
  27. package/lib/cjs/src/api/device-action/di/deviceActionModule.test.js.map +2 -2
  28. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  29. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  30. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  31. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +2 -2
  32. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +1 -1
  33. package/lib/cjs/src/api/device-action/os/Errors.js +1 -1
  34. package/lib/cjs/src/api/device-action/os/Errors.js.map +3 -3
  35. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  36. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  37. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +1 -1
  38. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  39. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
  40. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  41. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  42. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  43. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  44. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  45. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  46. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
  47. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +1 -1
  48. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  49. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  50. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  51. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
  52. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
  53. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
  54. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  55. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
  56. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +1 -1
  57. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  58. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  59. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
  60. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +1 -1
  61. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  62. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +2 -2
  63. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  64. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +2 -2
  65. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
  66. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
  67. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
  68. package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +2 -2
  69. package/lib/cjs/src/api/device-model/model/DeviceModel.js +1 -1
  70. package/lib/cjs/src/api/device-model/model/DeviceModel.js.map +2 -2
  71. package/lib/cjs/src/api/index.js +1 -1
  72. package/lib/cjs/src/api/index.js.map +2 -2
  73. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
  74. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
  75. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +1 -1
  76. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
  77. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
  78. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js +1 -1
  79. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js.map +1 -1
  80. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
  81. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
  82. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js +1 -1
  83. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
  84. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
  85. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
  86. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js +1 -1
  87. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js.map +1 -1
  88. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  89. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  90. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
  91. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
  92. package/lib/cjs/src/api/secure-channel/task/types.js +1 -1
  93. package/lib/cjs/src/api/secure-channel/task/types.js.map +2 -2
  94. package/lib/cjs/src/api/secure-channel/utils.js +1 -1
  95. package/lib/cjs/src/api/secure-channel/utils.js.map +3 -3
  96. package/lib/cjs/src/api/secure-channel/utils.test.js +1 -1
  97. package/lib/cjs/src/api/secure-channel/utils.test.js.map +3 -3
  98. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  99. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  100. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js +2 -0
  101. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +7 -0
  102. package/lib/cjs/src/api/transport/model/Errors.js +1 -1
  103. package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
  104. package/lib/cjs/src/api/utils/AppName.js +2 -0
  105. package/lib/cjs/src/api/utils/AppName.js.map +7 -0
  106. package/lib/cjs/src/api/utils/AppName.test.js +2 -0
  107. package/lib/cjs/src/api/utils/AppName.test.js.map +7 -0
  108. package/lib/cjs/src/di.js +1 -1
  109. package/lib/cjs/src/di.js.map +2 -2
  110. package/lib/cjs/src/internal/config/di/configModule.js +1 -1
  111. package/lib/cjs/src/internal/config/di/configModule.js.map +3 -3
  112. package/lib/cjs/src/internal/config/di/configModule.test.js +1 -1
  113. package/lib/cjs/src/internal/config/di/configModule.test.js.map +2 -2
  114. package/lib/cjs/src/internal/device-model/di/deviceModelModule.js +1 -1
  115. package/lib/cjs/src/internal/device-model/di/deviceModelModule.js.map +3 -3
  116. package/lib/cjs/src/internal/device-model/di/deviceModelModule.test.js +1 -1
  117. package/lib/cjs/src/internal/device-model/di/deviceModelModule.test.js.map +2 -2
  118. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
  119. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  120. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.test.js +1 -1
  121. package/lib/cjs/src/internal/device-session/di/deviceSessionModule.test.js.map +2 -2
  122. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
  123. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
  124. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
  125. package/lib/cjs/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
  126. package/lib/cjs/src/internal/discovery/di/discoveryModule.js +1 -1
  127. package/lib/cjs/src/internal/discovery/di/discoveryModule.js.map +3 -3
  128. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js +1 -1
  129. package/lib/cjs/src/internal/discovery/di/discoveryModule.test.js.map +2 -2
  130. package/lib/cjs/src/internal/logger-publisher/di/loggerModule.js +1 -1
  131. package/lib/cjs/src/internal/logger-publisher/di/loggerModule.js.map +3 -3
  132. package/lib/cjs/src/internal/logger-publisher/di/loggerModule.test.js +1 -1
  133. package/lib/cjs/src/internal/logger-publisher/di/loggerModule.test.js.map +2 -2
  134. package/lib/cjs/src/internal/manager-api/di/managerApiModule.js +1 -1
  135. package/lib/cjs/src/internal/manager-api/di/managerApiModule.js.map +3 -3
  136. package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js +1 -1
  137. package/lib/cjs/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
  138. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js +1 -1
  139. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.js.map +3 -3
  140. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js +1 -1
  141. package/lib/cjs/src/internal/secure-channel/di/secureChannelModule.test.js.map +2 -2
  142. package/lib/cjs/src/internal/secure-channel/model/Errors.js +1 -1
  143. package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +3 -3
  144. package/lib/cjs/src/internal/send/di/sendModule.js +1 -1
  145. package/lib/cjs/src/internal/send/di/sendModule.js.map +3 -3
  146. package/lib/cjs/src/internal/send/di/sendModule.test.js +1 -1
  147. package/lib/cjs/src/internal/send/di/sendModule.test.js.map +2 -2
  148. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js +1 -1
  149. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js.map +3 -3
  150. package/lib/cjs/src/internal/transport/di/transportModule.js +1 -1
  151. package/lib/cjs/src/internal/transport/di/transportModule.js.map +3 -3
  152. package/lib/cjs/src/internal/transport/di/transportModule.test.js +1 -1
  153. package/lib/cjs/src/internal/transport/di/transportModule.test.js.map +2 -2
  154. package/lib/esm/package.json +1 -2
  155. package/lib/esm/src/api/DeviceManagementKit.test.js +1 -1
  156. package/lib/esm/src/api/DeviceManagementKit.test.js.map +2 -2
  157. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
  158. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js.map +3 -3
  159. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
  160. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
  161. package/lib/esm/src/api/apdu/utils/ByteArrayParser.js +1 -1
  162. package/lib/esm/src/api/apdu/utils/ByteArrayParser.js.map +3 -3
  163. package/lib/esm/src/api/command/di/commandModule.js +1 -1
  164. package/lib/esm/src/api/command/di/commandModule.js.map +3 -3
  165. package/lib/esm/src/api/command/di/commandModule.test.js +1 -1
  166. package/lib/esm/src/api/command/di/commandModule.test.js.map +2 -2
  167. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js +1 -1
  168. package/lib/esm/src/api/command/os/__mocks__/GetOsVersionCommand.js.map +2 -2
  169. package/lib/esm/src/api/command/utils/CommandUtils.js +1 -1
  170. package/lib/esm/src/api/command/utils/CommandUtils.js.map +3 -3
  171. package/lib/esm/src/api/command/utils/CommandUtils.test.js +1 -1
  172. package/lib/esm/src/api/command/utils/CommandUtils.test.js.map +2 -2
  173. package/lib/esm/src/api/command/utils/GlobalCommandError.js +1 -1
  174. package/lib/esm/src/api/command/utils/GlobalCommandError.js.map +2 -2
  175. package/lib/esm/src/api/device/DeviceModel.js +1 -1
  176. package/lib/esm/src/api/device/DeviceModel.js.map +2 -2
  177. package/lib/esm/src/api/device-action/di/deviceActionModule.js +1 -1
  178. package/lib/esm/src/api/device-action/di/deviceActionModule.js.map +3 -3
  179. package/lib/esm/src/api/device-action/di/deviceActionModule.test.js +1 -1
  180. package/lib/esm/src/api/device-action/di/deviceActionModule.test.js.map +2 -2
  181. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  182. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  183. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  184. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +2 -2
  185. package/lib/esm/src/api/device-action/os/Errors.js +1 -1
  186. package/lib/esm/src/api/device-action/os/Errors.js.map +3 -3
  187. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  188. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  189. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  190. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
  191. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  192. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  193. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  194. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  195. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  196. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  197. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  198. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  199. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  200. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  201. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  202. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
  203. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  204. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  205. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  206. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +3 -3
  207. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  208. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +3 -3
  209. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
  210. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
  211. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
  212. package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +2 -2
  213. package/lib/esm/src/api/device-model/model/DeviceModel.js +1 -1
  214. package/lib/esm/src/api/device-model/model/DeviceModel.js.map +2 -2
  215. package/lib/esm/src/api/index.js +1 -1
  216. package/lib/esm/src/api/index.js.map +3 -3
  217. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
  218. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
  219. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
  220. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
  221. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
  222. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
  223. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js +1 -1
  224. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
  225. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
  226. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
  227. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  228. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  229. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
  230. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
  231. package/lib/esm/src/api/secure-channel/task/types.js +1 -1
  232. package/lib/esm/src/api/secure-channel/task/types.js.map +2 -2
  233. package/lib/esm/src/api/secure-channel/utils.js +1 -1
  234. package/lib/esm/src/api/secure-channel/utils.js.map +3 -3
  235. package/lib/esm/src/api/secure-channel/utils.test.js +1 -1
  236. package/lib/esm/src/api/secure-channel/utils.test.js.map +3 -3
  237. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  238. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  239. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js +2 -0
  240. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +7 -0
  241. package/lib/esm/src/api/transport/model/Errors.js +1 -1
  242. package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
  243. package/lib/esm/src/api/utils/AppName.js +2 -0
  244. package/lib/esm/src/api/utils/AppName.js.map +7 -0
  245. package/lib/esm/src/api/utils/AppName.test.js +2 -0
  246. package/lib/esm/src/api/utils/AppName.test.js.map +7 -0
  247. package/lib/esm/src/di.js +1 -1
  248. package/lib/esm/src/di.js.map +2 -2
  249. package/lib/esm/src/internal/config/di/configModule.js +1 -1
  250. package/lib/esm/src/internal/config/di/configModule.js.map +3 -3
  251. package/lib/esm/src/internal/config/di/configModule.test.js +1 -1
  252. package/lib/esm/src/internal/config/di/configModule.test.js.map +2 -2
  253. package/lib/esm/src/internal/device-model/di/deviceModelModule.js +1 -1
  254. package/lib/esm/src/internal/device-model/di/deviceModelModule.js.map +3 -3
  255. package/lib/esm/src/internal/device-model/di/deviceModelModule.test.js +1 -1
  256. package/lib/esm/src/internal/device-model/di/deviceModelModule.test.js.map +2 -2
  257. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
  258. package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
  259. package/lib/esm/src/internal/device-session/di/deviceSessionModule.test.js +1 -1
  260. package/lib/esm/src/internal/device-session/di/deviceSessionModule.test.js.map +2 -2
  261. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js +1 -1
  262. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.js.map +2 -2
  263. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js +1 -1
  264. package/lib/esm/src/internal/device-session/service/DefaultApduSenderService.test.js.map +2 -2
  265. package/lib/esm/src/internal/discovery/di/discoveryModule.js +1 -1
  266. package/lib/esm/src/internal/discovery/di/discoveryModule.js.map +3 -3
  267. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js +1 -1
  268. package/lib/esm/src/internal/discovery/di/discoveryModule.test.js.map +2 -2
  269. package/lib/esm/src/internal/logger-publisher/di/loggerModule.js +1 -1
  270. package/lib/esm/src/internal/logger-publisher/di/loggerModule.js.map +3 -3
  271. package/lib/esm/src/internal/logger-publisher/di/loggerModule.test.js +1 -1
  272. package/lib/esm/src/internal/logger-publisher/di/loggerModule.test.js.map +2 -2
  273. package/lib/esm/src/internal/manager-api/di/managerApiModule.js +1 -1
  274. package/lib/esm/src/internal/manager-api/di/managerApiModule.js.map +3 -3
  275. package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js +1 -1
  276. package/lib/esm/src/internal/manager-api/di/managerApiModule.test.js.map +2 -2
  277. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js +1 -1
  278. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.js.map +3 -3
  279. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js +1 -1
  280. package/lib/esm/src/internal/secure-channel/di/secureChannelModule.test.js.map +2 -2
  281. package/lib/esm/src/internal/secure-channel/model/Errors.js +1 -1
  282. package/lib/esm/src/internal/secure-channel/model/Errors.js.map +3 -3
  283. package/lib/esm/src/internal/send/di/sendModule.js +1 -1
  284. package/lib/esm/src/internal/send/di/sendModule.js.map +3 -3
  285. package/lib/esm/src/internal/send/di/sendModule.test.js +1 -1
  286. package/lib/esm/src/internal/send/di/sendModule.test.js.map +2 -2
  287. package/lib/esm/src/internal/send/use-case/SendApduUseCase.js +1 -1
  288. package/lib/esm/src/internal/send/use-case/SendApduUseCase.js.map +3 -3
  289. package/lib/esm/src/internal/transport/di/transportModule.js +1 -1
  290. package/lib/esm/src/internal/transport/di/transportModule.js.map +3 -3
  291. package/lib/esm/src/internal/transport/di/transportModule.test.js +1 -1
  292. package/lib/esm/src/internal/transport/di/transportModule.test.js.map +2 -2
  293. package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts.map +1 -1
  294. package/lib/types/src/api/apdu/utils/ApduParser.d.ts.map +1 -1
  295. package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts +28 -0
  296. package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts.map +1 -1
  297. package/lib/types/src/api/apdu/utils/ByteArrayParser.d.ts +1 -0
  298. package/lib/types/src/api/apdu/utils/ByteArrayParser.d.ts.map +1 -1
  299. package/lib/types/src/api/command/di/commandModule.d.ts.map +1 -1
  300. package/lib/types/src/api/command/os/__mocks__/GetOsVersionCommand.d.ts.map +1 -1
  301. package/lib/types/src/api/command/utils/CommandErrors.d.ts.map +1 -1
  302. package/lib/types/src/api/command/utils/CommandUtils.d.ts +3 -0
  303. package/lib/types/src/api/command/utils/CommandUtils.d.ts.map +1 -1
  304. package/lib/types/src/api/command/utils/GlobalCommandError.d.ts +1 -1
  305. package/lib/types/src/api/command/utils/GlobalCommandError.d.ts.map +1 -1
  306. package/lib/types/src/api/device/DeviceModel.d.ts +2 -1
  307. package/lib/types/src/api/device/DeviceModel.d.ts.map +1 -1
  308. package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
  309. package/lib/types/src/api/device-action/di/deviceActionModule.d.ts.map +1 -1
  310. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +1 -0
  311. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  312. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
  313. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +0 -1
  314. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
  315. package/lib/types/src/api/device-action/os/Errors.d.ts +10 -0
  316. package/lib/types/src/api/device-action/os/Errors.d.ts.map +1 -1
  317. package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
  318. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +2 -1
  319. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
  320. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  321. package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
  322. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
  323. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +3 -2
  324. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
  325. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
  326. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +0 -1
  327. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
  328. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
  329. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +0 -1
  330. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
  331. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
  332. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +0 -1
  333. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
  334. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts +2 -2
  335. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts.map +1 -1
  336. package/lib/types/src/api/device-model/data/StaticDeviceModelDataSource.d.ts.map +1 -1
  337. package/lib/types/src/api/device-model/model/DeviceModel.d.ts.map +1 -1
  338. package/lib/types/src/api/device-session/service/DefaultApduReceiverService.stub.d.ts.map +1 -1
  339. package/lib/types/src/api/device-session/service/DefaultApduSenderService.stub.d.ts.map +1 -1
  340. package/lib/types/src/api/index.d.ts +1 -1
  341. package/lib/types/src/api/index.d.ts.map +1 -1
  342. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -1
  343. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +2 -1
  344. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -1
  345. package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.d.ts.map +1 -1
  346. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts +2 -1
  347. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts.map +1 -1
  348. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.d.ts.map +1 -1
  349. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts +2 -1
  350. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts.map +1 -1
  351. package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.d.ts.map +1 -1
  352. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts +2 -1
  353. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts.map +1 -1
  354. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +5 -2
  355. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
  356. package/lib/types/src/api/secure-channel/task/types.d.ts +6 -1
  357. package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -1
  358. package/lib/types/src/api/secure-channel/utils.d.ts +0 -11
  359. package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -1
  360. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +8 -7
  361. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
  362. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.test.d.ts +2 -0
  363. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.test.d.ts.map +1 -0
  364. package/lib/types/src/api/transport/model/Errors.d.ts +5 -0
  365. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  366. package/lib/types/src/api/utils/AppName.d.ts +2 -0
  367. package/lib/types/src/api/utils/AppName.d.ts.map +1 -0
  368. package/lib/types/src/api/utils/AppName.test.d.ts +2 -0
  369. package/lib/types/src/api/utils/AppName.test.d.ts.map +1 -0
  370. package/lib/types/src/api/utils/HexaString.d.ts.map +1 -1
  371. package/lib/types/src/di.d.ts.map +1 -1
  372. package/lib/types/src/internal/config/di/configModule.d.ts.map +1 -1
  373. package/lib/types/src/internal/device-model/di/deviceModelModule.d.ts.map +1 -1
  374. package/lib/types/src/internal/device-session/di/deviceSessionModule.d.ts.map +1 -1
  375. package/lib/types/src/internal/device-session/model/DeviceSession.stub.d.ts.map +1 -1
  376. package/lib/types/src/internal/device-session/utils/deviceSessionUtils.d.ts.map +1 -1
  377. package/lib/types/src/internal/discovery/di/discoveryModule.d.ts.map +1 -1
  378. package/lib/types/src/internal/logger-publisher/di/loggerModule.d.ts.map +1 -1
  379. package/lib/types/src/internal/manager-api/di/managerApiModule.d.ts.map +1 -1
  380. package/lib/types/src/internal/secure-channel/di/secureChannelModule.d.ts.map +1 -1
  381. package/lib/types/src/internal/secure-channel/model/Errors.d.ts +22 -2
  382. package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -1
  383. package/lib/types/src/internal/send/di/sendModule.d.ts.map +1 -1
  384. package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts +5 -1
  385. package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts.map +1 -1
  386. package/lib/types/src/internal/transport/di/transportModule.d.ts.map +1 -1
  387. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  388. package/package.json +2 -3
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\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 { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport {\n GetApplicationsMetadataTask,\n type GetApplicationsMetadataTaskResult,\n type InstalledApp,\n} from \"@api/device-action/task/GetApplicationsMetadataTask\";\nimport {\n GetFirmwareMetadataTask,\n type GetFirmwareMetadataTaskResult,\n} from \"@api/device-action/task/GetFirmwareMetadataTask\";\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 Catalog,\n type CustomImage,\n DeviceSessionStateType,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport { installedAppResultGuard } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type SecureChannelEvent } from \"@api/secure-channel/task/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport {\n type GetDeviceMetadataDAError,\n type GetDeviceMetadataDAInput,\n type GetDeviceMetadataDAIntermediateValue,\n type GetDeviceMetadataDAOutput,\n} from \"./types\";\n\ntype GetDeviceMetadataMachineInternalState = {\n readonly error: GetDeviceMetadataDAError | null;\n readonly deviceVersion: DeviceVersion | null;\n readonly firmware: FinalFirmware | null;\n readonly firmwareVersion: FirmwareVersion | null;\n readonly firmwareUpdateContext: FirmwareUpdateContext | null;\n readonly customImage: CustomImage | null;\n readonly installedApps: InstalledApp[] | null;\n readonly applications: Application[] | null;\n readonly applicationsUpdates: Application[] | null;\n readonly installedLanguages: InstalledLanguagePackage[] | null;\n readonly catalog: Catalog | null;\n};\n\nexport type GetDeviceMetadataFromContextTaskResult = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly customImage: CustomImage;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n} | null;\n\nexport type MachineDependencies = {\n readonly getDeviceMetadata: () => Promise<GetDeviceMetadataFromContextTaskResult>;\n readonly getFirmwareMetadata: () => Promise<GetFirmwareMetadataTaskResult>;\n readonly getApplicationsMetadata: (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) => Promise<GetApplicationsMetadataTaskResult>;\n readonly listAppsSecureChannel: (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => Observable<SecureChannelEvent>;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceMetadataDeviceAction extends XStateDeviceAction<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n >;\n\n const {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n const listAppsMachine = new ListAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n goToDashboard: goToDashboardMachine,\n getDeviceMetadata: fromPromise(getDeviceMetadata),\n getFirmwareMetadata: fromPromise(getFirmwareMetadata),\n getApplicationsMetadata: fromPromise(getApplicationsMetadata),\n listApps: listAppsMachine,\n listAppsSecureChannel: fromObservable(listAppsSecureChannel),\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n hasMetadata: ({ context }) =>\n context._internalState.firmwareVersion !== null &&\n context._internalState.firmwareUpdateContext !== null &&\n context._internalState.customImage !== null &&\n context._internalState.applications !== null &&\n context._internalState.applicationsUpdates !== null &&\n context._internalState.installedLanguages !== null &&\n context._internalState.catalog !== null,\n forceUpdate: ({ context }) => Boolean(context.input.forceUpdate),\n useSecureChannel: ({ context }) =>\n Boolean(context.input.useSecureChannel),\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"GetDeviceMetadataDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n useSecureChannel: _.input.useSecureChannel,\n forceUpdate: _.input.forceUpdate,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n deviceVersion: null,\n firmware: null,\n firmwareVersion: null,\n firmwareUpdateContext: null,\n customImage: null,\n installedApps: null,\n applications: null,\n applicationsUpdates: null,\n installedLanguages: null,\n catalog: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"GoToDashboard\",\n guard: \"forceUpdate\",\n },\n {\n target: \"GetDeviceMetadataFromContext\",\n },\n ],\n },\n GetDeviceMetadataFromContext: {\n invoke: {\n src: \"getDeviceMetadata\",\n onDone: {\n target: \"GetDeviceMetadataFromContextResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output === null) {\n return _.context._internalState;\n } else {\n return {\n ..._.context._internalState,\n firmwareVersion: _.event.output.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.firmwareUpdateContext,\n customImage: _.event.output.customImage,\n applications: _.event.output.applications,\n applicationsUpdates: _.event.output.applicationsUpdates,\n installedLanguages: _.event.output.installedLanguages,\n catalog: _.event.output.catalog,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceMetadataFromContextResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"hasMetadata\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"dashboard\",\n src: \"goToDashboard\",\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: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GoToDashboardCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetFirmwareMetadata\",\n },\n ],\n },\n GetFirmwareMetadata: {\n invoke: {\n src: \"getFirmwareMetadata\",\n onDone: {\n target: \"GetFirmwareMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n });\n }\n return {\n ..._.context._internalState,\n deviceVersion: _.event.output.data.deviceVersion,\n firmware: _.event.output.data.firmware,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetFirmwareMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n guard: \"useSecureChannel\",\n target: \"ListAppsSecureChannel\",\n },\n {\n target: \"ListApps\",\n },\n ],\n },\n ListAppsSecureChannel: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listAppsSecureChannel\",\n src: \"listAppsSecureChannel\",\n input: (_) => ({\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n switch (_.event.snapshot.context?.type) {\n case SecureChannelEventType.PermissionRequested: {\n return {\n requiredUserInteraction:\n UserInteractionRequired.AllowSecureConnection,\n };\n }\n case SecureChannelEventType.PermissionGranted: {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n isSecureConnectionAllowed: true,\n });\n }\n return {\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n default:\n return {\n ..._.context.intermediateValue,\n };\n }\n },\n _internalState: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Result\n ) {\n if (\n installedAppResultGuard(_.event.snapshot.context.payload)\n ) {\n return {\n ..._.context._internalState,\n installedApps: _.event.snapshot.context.payload.map(\n (app) => ({\n name: app.name,\n hash: app.hash,\n hashCode: app.hash_code_data,\n }),\n ),\n };\n }\n throw new Error(\n `Invalid result ${JSON.stringify(_.event.snapshot.context.payload)}`,\n );\n }\n return { ..._.context._internalState };\n },\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListApps: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listApps\",\n src: \"listApps\",\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: \"ListAppsCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output.isLeft()) {\n return {\n ..._.context._internalState,\n error: _.event.output.extract(),\n };\n } else {\n return {\n ..._.context._internalState,\n installedApps: _.event.output\n .unsafeCoerce()\n .map((app) => ({\n name: app.appName,\n hash: app.appFullHash,\n hashCode: app.appCodeHash,\n })),\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetApplicationsMetadata\",\n },\n ],\n },\n GetApplicationsMetadata: {\n invoke: {\n src: \"getApplicationsMetadata\",\n input: (_) => ({\n deviceVersion: _.context._internalState.deviceVersion!,\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n installedApps: _.context._internalState.installedApps!,\n }),\n onDone: {\n target: \"GetApplicationsMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n installedApps: _.event.output.data.applications,\n appsUpdates: _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n });\n }\n return {\n ..._.context._internalState,\n applications: _.event.output.data.applications,\n applicationsUpdates:\n _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetApplicationsMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n const { context } = args;\n const {\n error,\n firmwareVersion,\n firmwareUpdateContext,\n customImage,\n applications,\n applicationsUpdates,\n installedLanguages,\n catalog,\n } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right({\n firmwareVersion: firmwareVersion!,\n firmwareUpdateContext: firmwareUpdateContext!,\n customImage: customImage!,\n applications: applications!,\n applicationsUpdates: applicationsUpdates!,\n installedLanguages: installedLanguages!,\n catalog: catalog!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getDeviceMetadata = async () => {\n const deviceState = internalApi.getDeviceSessionState();\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n return null;\n }\n if (\n deviceState.firmwareVersion?.metadata === undefined ||\n deviceState.firmwareUpdateContext === undefined ||\n deviceState.customImage === undefined ||\n deviceState.installedApps.length === 0 ||\n deviceState.appsUpdates === undefined ||\n deviceState.installedLanguages === undefined ||\n deviceState.catalog === undefined\n ) {\n return null;\n }\n return {\n firmwareVersion: deviceState.firmwareVersion,\n firmwareUpdateContext: deviceState.firmwareUpdateContext,\n customImage: deviceState.customImage,\n applications: deviceState.installedApps,\n applicationsUpdates: deviceState.appsUpdates,\n installedLanguages: deviceState.installedLanguages,\n catalog: deviceState.catalog,\n };\n };\n\n const getFirmwareMetadata = async () =>\n new GetFirmwareMetadataTask(internalApi).run();\n\n const getApplicationsMetadata = async (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) =>\n new GetApplicationsMetadataTask(internalApi, {\n deviceVersion: arg0.input.deviceVersion,\n firmware: arg0.input.firmware,\n firmwareVersion: arg0.input.firmwareVersion,\n installedApps: arg0.input.installedApps,\n }).run();\n\n const listAppsSecureChannel = (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => {\n const { firmware, firmwareVersion } = arg0.input;\n const connection = internalApi\n .getSecureChannelService()\n .listInstalledApps(firmwareVersion.metadata!, firmware);\n return new ConnectToSecureChannelTask(internalApi, {\n connection,\n }).run();\n };\n\n return {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAE5BC,EAA2D,kBAE3DC,EAAuC,4CAEvCC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAA0C,yEAC1CC,EAAqC,+DACrCC,EAIO,+DACPC,EAGO,2DAEPC,EAGO,8DACPC,EAOO,kDACPC,EAAwC,qEACxCC,EAA2C,+DAC3CD,EAAuC,0CA4DhC,MAAMb,UAAsC,oBAMjD,CACA,iBACEe,EAOA,CASA,KAAM,CACJ,kBAAAC,EACA,oBAAAC,EACA,wBAAAC,EACA,sBAAAC,CACF,EAAI,KAAK,oBAAoBJ,CAAW,EAElCK,EAAgB,KAAK,MAAM,eAAiB,4BAE5CC,EAAuB,IAAI,4BAA0B,CACzD,MAAO,CACL,cAAAD,CACF,CACF,CAAC,EAAE,iBAAiBL,CAAW,EACzBO,EAAkB,IAAI,uBAAqB,CAC/C,MAAO,CACL,cAAAF,CACF,CACF,CAAC,EAAE,iBAAiBL,CAAW,EAE/B,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAK,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,cAAeC,EACf,qBAAmB,eAAYL,CAAiB,EAChD,uBAAqB,eAAYC,CAAmB,EACpD,2BAAyB,eAAYC,CAAuB,EAC5D,SAAUI,EACV,yBAAuB,kBAAeH,CAAqB,CAC7D,EACA,OAAQ,CACN,SAAU,CAAC,CAAE,QAAAI,CAAQ,IAAMA,EAAQ,eAAe,QAAU,KAC5D,YAAa,CAAC,CAAE,QAAAA,CAAQ,IACtBA,EAAQ,e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,sBAAuBC,EACvB,YAAaC,EACb,aAAcC,EACd,oBAAqBC,EACrB,mBAAoBC,EACpB,QAASC,CACX,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBpB,EAA+C,CA6DjE,MAAO,CACL,kBA7DwB,SAAY,CACpC,MAAMW,EAAcX,EAAY,sBAAsB,EAItD,OAHIW,EAAY,mBAAqB,yBAAuB,WAI1DA,EAAY,iBAAiB,WAAa,QAC1CA,EAAY,wBAA0B,QACtCA,EAAY,cAAgB,QAC5BA,EAAY,cAAc,SAAW,GACrCA,EAAY,cAAgB,QAC5BA,EAAY,qBAAuB,QACnCA,EAAY,UAAY,OAEjB,KAEF,CACL,gBAAiBA,EAAY,gBAC7B,sBAAuBA,EAAY,sBACnC,YAAaA,EAAY,YACzB,aAAcA,EAAY,cAC1B,oBAAqBA,EAAY,YACjC,mBAAoBA,EAAY,mBAChC,QAASA,EAAY,OACvB,CACF,EAqCE,oBAnC0B,SAC1B,IAAI,0BAAwBX,CAAW,EAAE,IAAI,EAmC7C,wBAjC8B,MAAOqB,GAQrC,IAAI,8BAA4BrB,EAAa,CAC3C,cAAeqB,EAAK,MAAM,cAC1B,SAAUA,EAAK,MAAM,SACrB,gBAAiBA,EAAK,MAAM,gBAC5B,cAAeA,EAAK,MAAM,aAC5B,CAAC,EAAE,IAAI,EAqBP,sBAnB6BA,GAKzB,CACJ,KAAM,CAAE,SAAAC,EAAU,gBAAAR,CAAgB,EAAIO,EAAK,MACrCE,EAAavB,EAChB,wBAAwB,EACxB,kBAAkBc,EAAgB,SAAWQ,CAAQ,EACxD,OAAO,IAAI,6BAA2BtB,EAAa,CACjD,WAAAuB,CACF,CAAC,EAAE,IAAI,CACT,CAOA,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\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 { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport {\n GetApplicationsMetadataTask,\n type GetApplicationsMetadataTaskResult,\n type InstalledApp,\n} from \"@api/device-action/task/GetApplicationsMetadataTask\";\nimport {\n GetFirmwareMetadataTask,\n type GetFirmwareMetadataTaskResult,\n} from \"@api/device-action/task/GetFirmwareMetadataTask\";\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 Catalog,\n type CustomImage,\n DeviceSessionStateType,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport { installedAppResultGuard } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type SecureChannelEvent } from \"@api/secure-channel/task/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport {\n type GetDeviceMetadataDAError,\n type GetDeviceMetadataDAInput,\n type GetDeviceMetadataDAIntermediateValue,\n type GetDeviceMetadataDAOutput,\n} from \"./types\";\n\ntype GetDeviceMetadataMachineInternalState = {\n readonly error: GetDeviceMetadataDAError | null;\n readonly deviceVersion: DeviceVersion | null;\n readonly firmware: FinalFirmware | null;\n readonly firmwareVersion: FirmwareVersion | null;\n readonly firmwareUpdateContext: FirmwareUpdateContext | null;\n readonly customImage: CustomImage | null;\n readonly installedApps: InstalledApp[] | null;\n readonly applications: Application[] | null;\n readonly applicationsUpdates: Application[] | null;\n readonly installedLanguages: InstalledLanguagePackage[] | null;\n readonly catalog: Catalog | null;\n};\n\nexport type GetDeviceMetadataFromContextTaskResult = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly customImage: CustomImage;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n} | null;\n\nexport type MachineDependencies = {\n readonly getDeviceMetadata: () => Promise<GetDeviceMetadataFromContextTaskResult>;\n readonly getFirmwareMetadata: () => Promise<GetFirmwareMetadataTaskResult>;\n readonly getApplicationsMetadata: (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) => Promise<GetApplicationsMetadataTaskResult>;\n readonly listAppsSecureChannel: (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => Observable<SecureChannelEvent>;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceMetadataDeviceAction extends XStateDeviceAction<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n >;\n\n const {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n const listAppsMachine = new ListAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n goToDashboard: goToDashboardMachine,\n getDeviceMetadata: fromPromise(getDeviceMetadata),\n getFirmwareMetadata: fromPromise(getFirmwareMetadata),\n getApplicationsMetadata: fromPromise(getApplicationsMetadata),\n listApps: listAppsMachine,\n listAppsSecureChannel: fromObservable(listAppsSecureChannel),\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n hasMetadata: ({ context }) =>\n context._internalState.firmwareVersion !== null &&\n context._internalState.firmwareUpdateContext !== null &&\n context._internalState.customImage !== null &&\n context._internalState.applications !== null &&\n context._internalState.applicationsUpdates !== null &&\n context._internalState.installedLanguages !== null &&\n context._internalState.catalog !== null,\n forceUpdate: ({ context }) => Boolean(context.input.forceUpdate),\n useSecureChannel: ({ context }) =>\n Boolean(context.input.useSecureChannel),\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"GetDeviceMetadataDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n useSecureChannel: _.input.useSecureChannel,\n forceUpdate: _.input.forceUpdate,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n deviceVersion: null,\n firmware: null,\n firmwareVersion: null,\n firmwareUpdateContext: null,\n customImage: null,\n installedApps: null,\n applications: null,\n applicationsUpdates: null,\n installedLanguages: null,\n catalog: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"GoToDashboard\",\n guard: \"forceUpdate\",\n },\n {\n target: \"GetDeviceMetadataFromContext\",\n },\n ],\n },\n GetDeviceMetadataFromContext: {\n invoke: {\n src: \"getDeviceMetadata\",\n onDone: {\n target: \"GetDeviceMetadataFromContextResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output === null) {\n return _.context._internalState;\n } else {\n return {\n ..._.context._internalState,\n firmwareVersion: _.event.output.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.firmwareUpdateContext,\n customImage: _.event.output.customImage,\n applications: _.event.output.applications,\n applicationsUpdates: _.event.output.applicationsUpdates,\n installedLanguages: _.event.output.installedLanguages,\n catalog: _.event.output.catalog,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceMetadataFromContextResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"hasMetadata\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"dashboard\",\n src: \"goToDashboard\",\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: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GoToDashboardCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetFirmwareMetadata\",\n },\n ],\n },\n GetFirmwareMetadata: {\n invoke: {\n src: \"getFirmwareMetadata\",\n onDone: {\n target: \"GetFirmwareMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n });\n }\n return {\n ..._.context._internalState,\n deviceVersion: _.event.output.data.deviceVersion,\n firmware: _.event.output.data.firmware,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetFirmwareMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n guard: \"useSecureChannel\",\n target: \"ListAppsSecureChannel\",\n },\n {\n target: \"ListApps\",\n },\n ],\n },\n ListAppsSecureChannel: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listAppsSecureChannel\",\n src: \"listAppsSecureChannel\",\n input: (_) => ({\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n switch (_.event.snapshot.context?.type) {\n case SecureChannelEventType.PermissionRequested: {\n return {\n requiredUserInteraction:\n UserInteractionRequired.AllowSecureConnection,\n };\n }\n case SecureChannelEventType.PermissionGranted: {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n isSecureConnectionAllowed: true,\n });\n }\n return {\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n default:\n return {\n ..._.context.intermediateValue,\n };\n }\n },\n _internalState: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Error\n ) {\n return {\n ..._.context._internalState,\n error: _.event.snapshot.context.error.mapDAErrors(),\n };\n } else if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Result\n ) {\n if (\n installedAppResultGuard(_.event.snapshot.context.payload)\n ) {\n return {\n ..._.context._internalState,\n installedApps: _.event.snapshot.context.payload.map(\n (app) => ({\n name: app.name,\n hash: app.hash,\n hashCode: app.hash_code_data,\n }),\n ),\n };\n }\n throw new Error(\n `Invalid result ${JSON.stringify(_.event.snapshot.context.payload)}`,\n );\n }\n return { ..._.context._internalState };\n },\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListApps: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listApps\",\n src: \"listApps\",\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: \"ListAppsCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output.isLeft()) {\n return {\n ..._.context._internalState,\n error: _.event.output.extract(),\n };\n } else {\n return {\n ..._.context._internalState,\n installedApps: _.event.output\n .unsafeCoerce()\n .map((app) => ({\n name: app.appName,\n hash: app.appFullHash,\n hashCode: app.appCodeHash,\n })),\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetApplicationsMetadata\",\n },\n ],\n },\n GetApplicationsMetadata: {\n invoke: {\n src: \"getApplicationsMetadata\",\n input: (_) => ({\n deviceVersion: _.context._internalState.deviceVersion!,\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n installedApps: _.context._internalState.installedApps!,\n }),\n onDone: {\n target: \"GetApplicationsMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n installedApps: _.event.output.data.applications,\n appsUpdates: _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n });\n }\n return {\n ..._.context._internalState,\n applications: _.event.output.data.applications,\n applicationsUpdates:\n _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetApplicationsMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n const { context } = args;\n const {\n error,\n firmwareVersion,\n firmwareUpdateContext,\n customImage,\n applications,\n applicationsUpdates,\n installedLanguages,\n catalog,\n } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right({\n firmwareVersion: firmwareVersion!,\n firmwareUpdateContext: firmwareUpdateContext!,\n customImage: customImage!,\n applications: applications!,\n applicationsUpdates: applicationsUpdates!,\n installedLanguages: installedLanguages!,\n catalog: catalog!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getDeviceMetadata = async () => {\n const deviceState = internalApi.getDeviceSessionState();\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n return null;\n }\n if (\n deviceState.firmwareVersion?.metadata === undefined ||\n deviceState.firmwareUpdateContext === undefined ||\n deviceState.customImage === undefined ||\n deviceState.installedApps.length === 0 ||\n deviceState.appsUpdates === undefined ||\n deviceState.installedLanguages === undefined ||\n deviceState.catalog === undefined\n ) {\n return null;\n }\n return {\n firmwareVersion: deviceState.firmwareVersion,\n firmwareUpdateContext: deviceState.firmwareUpdateContext,\n customImage: deviceState.customImage,\n applications: deviceState.installedApps,\n applicationsUpdates: deviceState.appsUpdates,\n installedLanguages: deviceState.installedLanguages,\n catalog: deviceState.catalog,\n };\n };\n\n const getFirmwareMetadata = async () =>\n new GetFirmwareMetadataTask(internalApi).run();\n\n const getApplicationsMetadata = async (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) =>\n new GetApplicationsMetadataTask(internalApi, {\n deviceVersion: arg0.input.deviceVersion,\n firmware: arg0.input.firmware,\n firmwareVersion: arg0.input.firmwareVersion,\n installedApps: arg0.input.installedApps,\n }).run();\n\n const listAppsSecureChannel = (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => {\n const { firmware, firmwareVersion } = arg0.input;\n const connection = internalApi\n .getSecureChannelService()\n .listInstalledApps(firmwareVersion.metadata!, firmware);\n return new ConnectToSecureChannelTask(internalApi, {\n connection,\n }).run();\n };\n\n return {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAE5BC,EAA2D,kBAE3DC,EAAuC,4CAEvCC,EAAwC,4DACxCC,EAA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Y,sBAAsB,EAItD,OAHIW,EAAY,mBAAqB,yBAAuB,WAI1DA,EAAY,iBAAiB,WAAa,QAC1CA,EAAY,wBAA0B,QACtCA,EAAY,cAAgB,QAC5BA,EAAY,cAAc,SAAW,GACrCA,EAAY,cAAgB,QAC5BA,EAAY,qBAAuB,QACnCA,EAAY,UAAY,OAEjB,KAEF,CACL,gBAAiBA,EAAY,gBAC7B,sBAAuBA,EAAY,sBACnC,YAAaA,EAAY,YACzB,aAAcA,EAAY,cAC1B,oBAAqBA,EAAY,YACjC,mBAAoBA,EAAY,mBAChC,QAASA,EAAY,OACvB,CACF,EAqCE,oBAnC0B,SAC1B,IAAI,0BAAwBX,CAAW,EAAE,IAAI,EAmC7C,wBAjC8B,MAAOqB,GAQrC,IAAI,8BAA4BrB,EAAa,CAC3C,cAAeqB,EAAK,MAAM,cAC1B,SAAUA,EAAK,MAAM,SACrB,gBAAiBA,EAAK,MAAM,gBAC5B,cAAeA,EAAK,MAAM,aAC5B,CAAC,EAAE,IAAI,EAqBP,sBAnB6BA,GAKzB,CACJ,KAAM,CAAE,SAAAC,EAAU,gBAAAR,CAAgB,EAAIO,EAAK,MACrCE,EAAavB,EAChB,wBAAwB,EACxB,kBAAkBc,EAAgB,SAAWQ,CAAQ,EACxD,OAAO,IAAI,6BAA2BtB,EAAa,CACjD,WAAAuB,CACF,CAAC,EAAE,IAAI,CACT,CAOA,CACF,CACF",
6
6
  "names": ["GetDeviceMetadataDeviceAction_exports", "__export", "GetDeviceMetadataDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_UserInteractionRequired", "import_Const", "import_GoToDashboardDeviceAction", "import_ListAppsDeviceAction", "import_GetApplicationsMetadataTask", "import_GetFirmwareMetadataTask", "import_XStateDeviceAction", "import_DeviceSessionState", "import_types", "import_ConnectToSecureChannelTask", "internalApi", "getDeviceMetadata", "getFirmwareMetadata", "getApplicationsMetadata", "listAppsSecureChannel", "unlockTimeout", "goToDashboardMachine", "listAppsMachine", "context", "_", "error", "deviceState", "app", "args", "firmwareVersion", "firmwareUpdateContext", "customImage", "applications", "applicationsUpdates", "installedLanguages", "catalog", "arg0", "firmware", "connection"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceMetadata/types.ts"],
4
- "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDARequiredInteraction,\n} from \"@api/device-action/os/GoToDashboard/types\";\nimport {\n type ListAppsDAError,\n type ListAppsDARequiredInteraction,\n} from \"@api/device-action/os/ListApps/types\";\nimport {\n type Catalog,\n type CustomImage,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport {\n type ListInstalledAppsDAError,\n type ListInstalledAppsDARequiredInteraction,\n} from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\n\nexport type GetDeviceMetadataDAOutput = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n readonly customImage: CustomImage;\n};\n\nexport type GetDeviceMetadataDAInput = GoToDashboardDAInput & {\n readonly useSecureChannel?: boolean;\n readonly forceUpdate?: boolean;\n};\n\nexport type GetDeviceMetadataDAError =\n | GoToDashboardDAError\n | ListAppsDAError\n | ListInstalledAppsDAError\n | CommandErrorResult[\"error\"];\n\nexport type GetDeviceMetadataDARequiredInteraction =\n | GoToDashboardDARequiredInteraction\n | ListAppsDARequiredInteraction\n | ListInstalledAppsDARequiredInteraction;\n\nexport type GetDeviceMetadataDAIntermediateValue = {\n requiredUserInteraction: GetDeviceMetadataDARequiredInteraction;\n};\n\nexport type GetDeviceMetadataDAState = DeviceActionState<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue\n>;\n"],
4
+ "sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport {\n type GoToDashboardDAError,\n type GoToDashboardDAInput,\n type GoToDashboardDARequiredInteraction,\n} from \"@api/device-action/os/GoToDashboard/types\";\nimport {\n type ListAppsDAError,\n type ListAppsDARequiredInteraction,\n} from \"@api/device-action/os/ListApps/types\";\nimport {\n type Catalog,\n type CustomImage,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport {\n type ListInstalledAppsDAError,\n type ListInstalledAppsDARequiredInteraction,\n} from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type SecureChannelDAErrors } from \"@internal/secure-channel/model/Errors\";\n\nexport type GetDeviceMetadataDAOutput = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n readonly customImage: CustomImage;\n};\n\nexport type GetDeviceMetadataDAInput = GoToDashboardDAInput & {\n readonly useSecureChannel?: boolean;\n readonly forceUpdate?: boolean;\n};\n\nexport type GetDeviceMetadataDAError =\n | GoToDashboardDAError\n | ListAppsDAError\n | ListInstalledAppsDAError\n | SecureChannelDAErrors\n | CommandErrorResult[\"error\"];\n\nexport type GetDeviceMetadataDARequiredInteraction =\n | GoToDashboardDARequiredInteraction\n | ListAppsDARequiredInteraction\n | ListInstalledAppsDARequiredInteraction;\n\nexport type GetDeviceMetadataDAIntermediateValue = {\n requiredUserInteraction: GetDeviceMetadataDARequiredInteraction;\n};\n\nexport type GetDeviceMetadataDAState = DeviceActionState<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue\n>;\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["types_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var I=(i,t)=>{for(var a in t)m(i,a,{get:t[a],enumerable:!0})},C=(i,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!x.call(i,r)&&r!==a&&m(i,r,{get:()=>t[r],enumerable:!(s=U(t,r))||s.enumerable});return i};var O=i=>C(m({},"__esModule",{value:!0}),i);var T={};I(T,{GetDeviceStatusDeviceAction:()=>M});module.exports=O(T);var D=require("purify-ts"),g=require("rxjs"),v=require("rxjs/operators"),n=require("xstate"),k=require("../../../command/model/CommandResult"),b=require("../../../command/os/GetAppAndVersionCommand"),y=require("../../../device/DeviceStatus"),c=require("../../../device-action/model/UserInteractionRequired"),f=require("../../../device-action/os/Const"),S=require("../../../device-action/os/Errors"),E=require("../../../device-action/xstate-utils/XStateDeviceAction"),d=require("../../../device-session/DeviceSessionState");class M extends E.XStateDeviceAction{makeStateMachine(t){const{getAppAndVersion:a,getDeviceSessionState:s,setDeviceSessionState:r,waitForDeviceUnlock:A,isDeviceOnboarded:u}=this.extractDependencies(t),p=this.input.unlockTimeout??f.DEFAULT_UNLOCK_TIMEOUT_MS;return(0,n.setup)({types:{input:{unlockTimeout:p},context:{},output:{}},actors:{getAppAndVersion:(0,n.fromPromise)(a),waitForDeviceUnlock:(0,n.fromObservable)(A)},guards:{isDeviceOnboarded:()=>u(),isDeviceLocked:({context:e})=>e._internalState.locked,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new S.DeviceNotOnboardedError})}),assignErrorDeviceLocked:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new S.DeviceLockedError}),intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice}}),assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.None})}),assignUserActionUnlockNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const o=s(),{sessionStateType:l}=o;return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},_internalState:{onboarded:!1,locked:!1,currentApp:l===d.DeviceSessionStateType.ReadyWithoutSecureChannel?o.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:p}),onDone:{target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,k.isSuccessCommandResult)(e.event.output)){const o=s();return o.sessionStateType!==d.DeviceSessionStateType.Connected?r({...o,currentApp:e.event.output.data}):r({deviceModelId:o.deviceModelId,sessionStateType:d.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:y.DeviceStatus.CONNECTED,currentApp:e.event.output.data,installedApps:[],isSecureConnectionAllowed:!1}),{...e.context._internalState,locked:!1,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}return"errorCode"in e.event.output.error&&e.event.output.error.errorCode==="5515"?{...e.context._internalState,locked:!0}:{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:o}=e,{error:l,currentApp:h,currentAppVersion:V}=o._internalState;return l?(0,D.Left)(l):(0,D.Right)({currentApp:h,currentAppVersion:V})}})}extractDependencies(t){return{getAppAndVersion:()=>t.sendCommand(new b.GetAppAndVersionCommand),waitForDeviceUnlock:({input:r})=>new g.Observable(A=>{const u=t.getDeviceSessionStateObservable().pipe((0,v.tap)(p=>{p.deviceStatus===y.DeviceStatus.CONNECTED&&(A.complete(),u.unsubscribe())})).subscribe();return()=>{u.unsubscribe()}}).pipe((0,v.timeout)(r.unlockTimeout)),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:r=>t.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}0&&(module.exports={GetDeviceStatusDeviceAction});
1
+ "use strict";var m=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var O=(i,t)=>{for(var a in t)m(i,a,{get:t[a],enumerable:!0})},C=(i,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!x.call(i,r)&&r!==a&&m(i,r,{get:()=>t[r],enumerable:!(s=U(t,r))||s.enumerable});return i};var I=i=>C(m({},"__esModule",{value:!0}),i);var T={};O(T,{GetDeviceStatusDeviceAction:()=>M});module.exports=I(T);var D=require("purify-ts"),g=require("rxjs"),S=require("rxjs/operators"),n=require("xstate"),k=require("../../../command/model/CommandResult"),f=require("../../../command/os/GetAppAndVersionCommand"),y=require("../../../device/DeviceStatus"),c=require("../../../device-action/model/UserInteractionRequired"),b=require("../../../device-action/os/Const"),v=require("../../../device-action/os/Errors"),E=require("../../../device-action/xstate-utils/XStateDeviceAction"),d=require("../../../device-session/DeviceSessionState");class M extends E.XStateDeviceAction{makeStateMachine(t){const{getAppAndVersion:a,getDeviceSessionState:s,setDeviceSessionState:r,waitForDeviceUnlock:A,isDeviceOnboarded:u}=this.extractDependencies(t),p=this.input.unlockTimeout??b.DEFAULT_UNLOCK_TIMEOUT_MS;return(0,n.setup)({types:{input:{unlockTimeout:p},context:{},output:{}},actors:{getAppAndVersion:(0,n.fromPromise)(a),waitForDeviceUnlock:(0,n.fromObservable)(A)},guards:{isDeviceOnboarded:()=>u(),isDeviceLocked:({context:e})=>e._internalState.locked,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceNotOnboardedError})}),assignErrorDeviceLocked:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new v.DeviceLockedError}),intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice}}),assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.None})}),assignUserActionUnlockNeeded:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UserInteractionRequired.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const o=s(),{sessionStateType:l}=o;return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},_internalState:{onboarded:!1,locked:!1,currentApp:l===d.DeviceSessionStateType.ReadyWithoutSecureChannel?o.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:p}),onDone:{target:"AppAndVersionCheck",actions:(0,n.assign)({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:(0,n.assign)({_internalState:e=>{if((0,k.isSuccessCommandResult)(e.event.output)){const o=s();return o.sessionStateType!==d.DeviceSessionStateType.Connected?r({...o,currentApp:e.event.output.data}):r({deviceModelId:o.deviceModelId,sessionStateType:d.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:y.DeviceStatus.CONNECTED,currentApp:e.event.output.data,installedApps:[],isSecureConnectionAllowed:!1}),{...e.context._internalState,locked:!1,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}if("errorCode"in e.event.output.error){if(e.event.output.error.errorCode==="5515")return{...e.context._internalState,locked:!0};if(e.event.output.error.errorCode==="6e00")return{...e.context._internalState,locked:!1,currentApp:"BOLOS",currentAppVersion:"0.0.0"}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:o}=e,{error:l,currentApp:h,currentAppVersion:V}=o._internalState;return l?(0,D.Left)(l):(0,D.Right)({currentApp:h,currentAppVersion:V})}})}extractDependencies(t){return{getAppAndVersion:()=>t.sendCommand(new f.GetAppAndVersionCommand),waitForDeviceUnlock:({input:r})=>new g.Observable(A=>{const u=t.getDeviceSessionStateObservable().pipe((0,S.tap)(p=>{p.deviceStatus===y.DeviceStatus.CONNECTED&&(A.complete(),u.unsubscribe())})).subscribe();return()=>{u.unsubscribe()}}).pipe((0,S.timeout)(r.unlockTimeout)),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:r=>t.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}0&&(module.exports={GetDeviceStatusDeviceAction});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\nimport { tap, timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n isDeviceOnboarded,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isDeviceLocked: ({ context }) => context._internalState.locked,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI8vsAHOJM+VuLmVj5e2gC+EW6omDjcJORUXPSMLBwA8qwARsykAE4QuKxQAMIAFmD4ANZiUqryisqsqhoImo4O7OGhPj4h5n6Obh4IunZ2RoZ+ena6nYaGUTHoKcRklNTxqc3sWbkFRSUVVbWihtJIII1K6a1aVtoGTxOOjtbv84YjiObik7ofPM7GFDP9jNofMsQLE1olNmsGLsADLMGrFMqVGp1S5yBS3FRX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SFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n onboarded: false, // we don't know how to check yet\n locked: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"OnboardingCheck\",\n },\n },\n OnboardingCheck: {\n // TODO: we don't have this info for now\n always: [\n {\n guard: {\n type: \"isDeviceOnboarded\",\n },\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion command\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n // Update the current app\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n } else {\n // The device can be set to Ready if GetAppAndVersionCommand was successful\n setDeviceSessionState({\n deviceModelId: state.deviceModelId,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: _.event.output.data,\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n }\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n if (\n \"errorCode\" in _.event.output.error &&\n _.event.output.error.errorCode === \"5515\"\n ) {\n return {\n ..._.context._internalState,\n locked: true,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"UserActionUnlockDevice\",\n guard: \"isDeviceLocked\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n new Observable<void>((subscriber) => {\n const inner = internalApi\n .getDeviceSessionStateObservable()\n .pipe(\n tap((state) => {\n if (state.deviceStatus === DeviceStatus.CONNECTED) {\n subscriber.complete();\n inner.unsubscribe();\n }\n }),\n )\n .subscribe();\n\n return () => {\n inner.unsubscribe();\n };\n }).pipe(timeout(input.unlockTimeout));\n\n return {\n getAppAndVersion,\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2B,gBAC3BC,EAA6B,0BAC7BC,EAA2D,kBAE3DC,EAAuC,4CACvCC,EAGO,mDACPC,EAA6B,oCAE7BC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAGO,wCAEPC,EAGO,8DACPC,EAGO,kDAiCA,MAAMb,UAAoC,oBAM/C,CACA,iBACEc,EAOA,CASA,KAAM,CACJ,iBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,kBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiB,4BAElD,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAA,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,oBAAkB,eAAYL,CAAgB,EAC9C,uBAAqB,kBAAeG,CAAmB,CACzD,EACA,OAAQ,CACN,kBAAmB,IAAMC,EAAkB,EAC3C,eAAgB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,OACxD,SAAU,CAAC,CAAE,QAAAA,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IAC9D,EACA,QAAS,CACP,iCAA+B,UAAO,CACpC,eAAiBC,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,MAAO,IAAI,yBACb,EACF,CAAC,EACD,2BAAyB,UAAO,CA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B,EAAIR,EAAQ,eACzD,OAAIM,KACK,QAAKA,CAAK,KAEZ,SAA+B,CACpC,WAAYC,EACZ,kBAAmBC,CACrB,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBf,EAA+C,CA4BjE,MAAO,CACL,iBA5BuB,IAChBA,EAAY,YAAY,IAAI,yBAAyB,EA4B5D,oBAzB0B,CAAC,CAC3B,MAAAgB,CACF,IAGE,IAAI,aAAkBC,GAAe,CACnC,MAAMC,EAAQlB,EACX,gCAAgC,EAChC,QACC,OAAKW,GAAU,CACTA,EAAM,eAAiB,eAAa,YACtCM,EAAW,SAAS,EACpBC,EAAM,YAAY,EAEtB,CAAC,CACH,EACC,UAAU,EAEb,MAAO,IAAM,CACXA,EAAM,YAAY,CACpB,CACF,CAAC,EAAE,QAAK,WAAQF,EAAM,aAAa,CAAC,EAKpC,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\nimport { tap, timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n isDeviceOnboarded,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isDeviceLocked: ({ context }) => context._internalState.locked,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI8vsAHOJM+VuLmVj5e2gC+EW6omDjcJORUXPSMLBwA8qwARsykAE4QuKxQAMIAFmD4ANZiUqryisqsqhoImo4O7OGhPj4h5n6Obh4IunZ2RoZ+ena6nYaGUTHoKcRklNTxqc3sWbkFRSUVV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gXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n onboarded: false, // we don't know how to check yet\n locked: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"OnboardingCheck\",\n },\n },\n OnboardingCheck: {\n // TODO: we don't have this info for now\n always: [\n {\n guard: {\n type: \"isDeviceOnboarded\",\n },\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion command\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n // Update the current app\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n } else {\n // The device can be set to Ready if GetAppAndVersionCommand was successful\n setDeviceSessionState({\n deviceModelId: state.deviceModelId,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: _.event.output.data,\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n }\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n if (\"errorCode\" in _.event.output.error) {\n if (_.event.output.error.errorCode === \"5515\") {\n // Locked device error\n return {\n ..._.context._internalState,\n locked: true,\n };\n } else if (_.event.output.error.errorCode === \"6e00\") {\n // CLA not supported\n // GetAppAndVersion should always be supported by the firmware or any app.\n // But on old firmware versions, that APDU was not supported in the dashboard.\n // On those firmwares, it fails with CLA_NOT_SUPPORTED in BOLOS, and INS_NOT_SUPPORTED\n // in applications. Therefore if CLA is not supported, we can consider we're on the\n // dashboard on an old firmware. We should therefore return that information to\n // ensure the user can still update his firmware and is not blocked at this step.\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n };\n }\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"UserActionUnlockDevice\",\n guard: \"isDeviceLocked\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n new Observable<void>((subscriber) => {\n const inner = internalApi\n .getDeviceSessionStateObservable()\n .pipe(\n tap((state) => {\n if (state.deviceStatus === DeviceStatus.CONNECTED) {\n subscriber.complete();\n inner.unsubscribe();\n }\n }),\n )\n .subscribe();\n\n return () => {\n inner.unsubscribe();\n };\n }).pipe(timeout(input.unlockTimeout));\n\n return {\n getAppAndVersion,\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2B,gBAC3BC,EAA6B,0BAC7BC,EAA2D,kBAE3DC,EAAuC,4CACvCC,EAGO,mDACPC,EAA6B,oCAE7BC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAGO,wCAEPC,EAGO,8DACPC,EAGO,kDAiCA,MAAMb,UAAoC,oBAM/C,CACA,iBACEc,EAOA,CASA,KAAM,CACJ,iBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,kBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiB,4BAElD,SAAO,SAAM,CACX,MAAO,CACL,MAAO,C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ACF",
6
6
  "names": ["GetDeviceStatusDeviceAction_exports", "__export", "GetDeviceStatusDeviceAction", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_operators", "import_xstate", "import_CommandResult", "import_GetAppAndVersionCommand", "import_DeviceStatus", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_XStateDeviceAction", "import_DeviceSessionState", "internalApi", "getAppAndVersion", "getDeviceSessionState", "setDeviceSessionState", "waitForDeviceUnlock", "isDeviceOnboarded", "unlockTimeout", "context", "_", "sessionState", "sessionStateType", "state", "args", "error", "currentApp", "currentAppVersion", "input", "subscriber", "inner"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=require("rxjs"),d=require("../../../command/model/CommandResult"),v=require("../../../command/utils/GlobalCommandError"),C=require("../../../device/DeviceModel"),r=require("../../../device/DeviceStatus"),u=require("../../../device-action/__test-utils__/makeInternalApi"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),a=require("../../../device-action/model/UserInteractionRequired"),O=require("../../../device-action/os/Errors"),o=require("../../../device-session/DeviceSessionState"),l=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const A=vi.fn(),D=vi.fn(),y=vi.fn(),V=vi.fn(),R=vi.fn();function k(){return{getAppAndVersion:A,getDeviceSessionState:D,waitForDeviceUnlock:y,setDeviceSessionState:V,isDeviceOnboarded:R}}const{sendCommand:E,getDeviceSessionState:w,getDeviceSessionStateObservable:N}=(0,u.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),R.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((i,s)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});w.mockReturnValue({sessionStateType:o.DeviceSessionStateType.Connected,deviceStatus:r.DeviceStatus.CONNECTED,deviceModelId:C.DeviceModelId.NANO_X}),E.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:i,onError:s})})),it("should run the device action with a locked device",()=>new Promise((i,s)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});w.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),N.mockImplementation(()=>new m.Observable(c=>{const S=(0,m.interval)(50).subscribe({next:h=>{h>2?(c.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),c.complete()):c.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{S.unsubscribe()}})),E.mockResolvedValueOnce((0,d.CommandResultFactory)({error:new v.GlobalCommandError({...v.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:i,onError:s})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((i,s)=>{D.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(V).toHaveBeenCalledWith({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}}),i()},onError:s})})),it("should return the device status and update session if the device is not ready",()=>new Promise((i,s)=>{D.mockReturnValue({sessionStateType:o.DeviceSessionStateType.Connected,deviceStatus:r.DeviceStatus.CONNECTED}),A.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(V).toHaveBeenCalledWith({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:!1}),i()},onError:s})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((i,s)=>{D.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockResolvedValueOnce((0,d.CommandResultFactory)({error:new v.GlobalCommandError({...v.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),y.mockImplementation(()=>new m.Observable(c=>{const S=(0,m.interval)(50).subscribe({next:h=>{h>2?(c.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),c.complete()):c.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{S.unsubscribe()}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:i,onError:s})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((i,s)=>{D.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),R.mockReturnValue(!1);const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{error:new O.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:i,onError:s})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((i,s)=>{D.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockResolvedValue((0,d.CommandResultFactory)({error:new v.GlobalCommandError({...v.GLOBAL_ERRORS[5515],errorCode:"5515"})})),N.mockImplementation(()=>new m.Observable(c=>{const S=(0,m.interval)(200).subscribe({next:()=>{c.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{S.unsubscribe()}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new O.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:i,onError:s})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((i,s)=>{D.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new v.GlobalCommandError({...v.GLOBAL_ERRORS[5501],errorCode:"5501"});A.mockResolvedValue((0,d.CommandResultFactory)({error:e})),y.mockImplementation(()=>new m.Observable(S=>{const h=(0,m.interval)(50).subscribe({next:f=>{f>2?(S.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.complete()):S.next({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{h.unsubscribe()}}));const n=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(k());const c=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(n,c,(0,u.makeDeviceActionInternalApiMock)(),{onDone:i,onError:s})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((i,s)=>{D.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),A.mockImplementation(()=>{throw new O.UnknownDAError("error")}),y.mockImplementation(()=>new m.Observable(c=>{c.complete()}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(k());const n=[{intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new O.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:i,onError:s})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((i,s)=>{w.mockReturnValue({sessionStateType:o.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:r.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:C.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),E.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:a.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:c}=(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:i,onError:s});c()}))});
1
+ "use strict";var v=require("rxjs"),d=require("../../../command/model/CommandResult"),m=require("../../../command/utils/GlobalCommandError"),D=require("../../../device/DeviceModel"),i=require("../../../device/DeviceStatus"),u=require("../../../device-action/__test-utils__/makeInternalApi"),p=require("../../../device-action/__test-utils__/testDeviceActionStates"),t=require("../../../device-action/model/DeviceActionState"),c=require("../../../device-action/model/UserInteractionRequired"),O=require("../../../device-action/os/Errors"),s=require("../../../device-session/DeviceSessionState"),l=require("./GetDeviceStatusDeviceAction");describe("GetDeviceStatusDeviceAction",()=>{const k=vi.fn(),A=vi.fn(),y=vi.fn(),w=vi.fn(),E=vi.fn();function C(){return{getAppAndVersion:k,getDeviceSessionState:A,waitForDeviceUnlock:y,setDeviceSessionState:w,isDeviceOnboarded:E}}const{sendCommand:V,getDeviceSessionState:R,getDeviceSessionStateObservable:N}=(0,u.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.resetAllMocks(),E.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:D.DeviceModelId.NANO_X}),V.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),N.mockImplementation(()=>new v.Observable(a=>{const S=(0,v.interval)(50).subscribe({next:h=>{h>2?(a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),a.complete()):a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{S.unsubscribe()}})),V.mockResolvedValueOnce((0,d.CommandResultFactory)({error:new m.GlobalCommandError({...m.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should run the device action with an old firmware not supporting GetAppAndVersion",()=>new Promise((r,o)=>{const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:D.DeviceModelId.NANO_X}),V.mockResolvedValue((0,d.CommandResultFactory)({error:new m.GlobalCommandError({...m.GLOBAL_ERRORS["6e00"],errorCode:"6e00"})}));const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"0.0.0"},status:t.DeviceActionStatus.Completed}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(w).toHaveBeenCalledWith({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"}}),r()},onError:o})})),it("should return the device status and update session if the device is not ready",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED}),k.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:()=>{expect(w).toHaveBeenCalledWith({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"BOLOS",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:!1}),r()},onError:o})})),it("should return the device status if the device is locked and the user unlocks the device",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValueOnce((0,d.CommandResultFactory)({error:new m.GlobalCommandError({...m.GLOBAL_ERRORS[5515],errorCode:"5515"})})).mockResolvedValueOnce((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}})),y.mockImplementation(()=>new v.Observable(a=>{const S=(0,v.interval)(50).subscribe({next:h=>{h>2?(a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),a.complete()):a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{S.unsubscribe()}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{status:t.DeviceActionStatus.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),E.mockReturnValue(!1);const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{error:new O.DeviceNotOnboardedError,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the device is locked and the user does not unlock",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockResolvedValue((0,d.CommandResultFactory)({error:new m.GlobalCommandError({...m.GLOBAL_ERRORS[5515],errorCode:"5515"})})),N.mockImplementation(()=>new v.Observable(a=>{const S=(0,v.interval)(200).subscribe({next:()=>{a.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{S.unsubscribe()}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.UnlockDevice},status:t.DeviceActionStatus.Pending},{error:new O.DeviceLockedError("Device locked."),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new m.GlobalCommandError({...m.GLOBAL_ERRORS[5501],errorCode:"5501"});k.mockResolvedValue((0,d.CommandResultFactory)({error:e})),y.mockImplementation(()=>new v.Observable(S=>{const h=(0,v.interval)(50).subscribe({next:f=>{f>2?(S.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.complete()):S.next({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{h.unsubscribe()}}));const n=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(C());const a=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:e,status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(n,a,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{A.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),k.mockImplementation(()=>{throw new O.UnknownDAError("error")}),y.mockImplementation(()=>new v.Observable(a=>{a.complete()}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(C());const n=[{intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None},status:t.DeviceActionStatus.Pending},{error:new O.UnknownDAError("error"),status:t.DeviceActionStatus.Error}];(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{R.mockReturnValue({sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:i.DeviceStatus.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.DeviceModelId.NANO_X,isSecureConnectionAllowed:!1}),V.mockResolvedValue((0,d.CommandResultFactory)({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l.GetDeviceStatusDeviceAction({input:{unlockTimeout:500}}),n=[{status:t.DeviceActionStatus.Pending,intermediateValue:{requiredUserInteraction:c.UserInteractionRequired.None}},{status:t.DeviceActionStatus.Stopped}],{cancel:a}=(0,p.testDeviceActionStates)(e,n,(0,u.makeDeviceActionInternalApiMock)(),{onDone:r,onError:o});a()}))});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.ts"],
4
- "sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const waitForDeviceUnlockMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n sendCommandMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n // Session should be updated with current app\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status and update session if the device is not ready\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n // Session should be set as ready if GetAppAndVersionCommand was successful\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n );\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetAppAndVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAAqC,gBAErCC,EAAqC,4CACrCC,EAGO,iDACPC,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAIO,wCACPC,EAAuC,kDAEvCC,EAA4C,yCAG5C,SAAS,8BAA+B,IAAM,C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AAC,CACL,EAEA,MAAMF,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAED,GAAG,MACDA,EACA,qBACF,EAAE,gBAAgBN,EAAwB,CAAC,EAE3C,MAAMO,EAAgD,CACpD,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,MAAO,IAAI,iBAAe,OAAO,EACjC,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BACED,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,EAED,GAAG,yDAA0D,IAC3D,IAAI,QAAc,CAACD,EAASC,IAAW,CACrCH,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,WAAY,CAAE,KAAM,mBAAoB,QAAS,OAAQ,EACzD,cAAe,CAAC,EAChB,cAAe,gBAAc,OAC7B,0BAA2B,EAC7B,CAAC,EAEDD,EAAgB,qBACd,wBAAqB,CACnB,KAAM,CACJ,KAAM,QACN,QAAS,OACX,CACF,CAAC,CACH,EAEA,MAAMK,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEKC,EAAgD,CACpD,CACE,OAAQ,qBAAmB,QAC3B,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,CACF,EACA,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAAK,CAAO,KAAI,0BACjBN,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,EACAO,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
4
+ "sourcesContent": ["import { interval, Observable } from \"rxjs\";\n\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n} from \"@api/command/utils/GlobalCommandError\";\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n UnknownDAError,\n} from \"@api/device-action/os/Errors\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\n\nimport { GetDeviceStatusDeviceAction } from \"./GetDeviceStatusDeviceAction\";\nimport { type GetDeviceStatusDAState } from \"./types\";\n\ndescribe(\"GetDeviceStatusDeviceAction\", () => {\n const getAppAndVersionMock = vi.fn();\n const getDeviceSessionStateMock = vi.fn();\n const waitForDeviceUnlockMock = vi.fn();\n const setDeviceSessionState = vi.fn();\n const isDeviceOnboardedMock = vi.fn();\n\n function extractDependenciesMock() {\n return {\n getAppAndVersion: getAppAndVersionMock,\n getDeviceSessionState: getDeviceSessionStateMock,\n waitForDeviceUnlock: waitForDeviceUnlockMock,\n setDeviceSessionState: setDeviceSessionState,\n isDeviceOnboarded: isDeviceOnboardedMock,\n };\n }\n\n const {\n sendCommand: sendCommandMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n } = makeDeviceActionInternalApiMock();\n beforeEach(() => {\n vi.resetAllMocks();\n isDeviceOnboardedMock.mockReturnValue(true);\n });\n\n describe(\"without overriding `extractDependencies`\", () => {\n it(\"should run the device action with an unlocked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with a locked device\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n sendCommandMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should run the device action with an old firmware not supporting GetAppAndVersion\", () =>\n new Promise<void>((resolve, reject) => {\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.NANO_X,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"6e00\"],\n errorCode: \"6e00\",\n }),\n }),\n );\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should return the device status if the device is unlocked\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n // Session should be updated with current app\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status and update session if the device is not ready\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: undefined },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: () => {\n // Session should be set as ready if GetAppAndVersionCommand was successful\n expect(setDeviceSessionState).toHaveBeenCalledWith({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n resolve();\n },\n onError: reject,\n },\n );\n }));\n\n it(\"should return the device status if the device is locked and the user unlocks the device\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock\n .mockResolvedValueOnce(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n )\n .mockResolvedValueOnce(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n status: DeviceActionStatus.Completed,\n output: {\n currentApp: \"BOLOS\",\n currentAppVersion: \"1.0.0\",\n },\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"errors cases\", () => {\n it(\"should end in an error if the device is not onboarded\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n isDeviceOnboardedMock.mockReturnValue(false);\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n error: new DeviceNotOnboardedError(),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the device is locked and the user does not unlock\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockResolvedValue(\n CommandResultFactory({\n error: new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5515\"],\n errorCode: \"5515\",\n }),\n }),\n );\n\n apiGetDeviceSessionStateObservableMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(200).subscribe({\n next: () => {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new DeviceLockedError(\"Device locked.\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if the GetAppAndVersion command fails\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n const error = new GlobalCommandError({\n ...GLOBAL_ERRORS[\"5501\"],\n errorCode: \"5501\",\n });\n\n getAppAndVersionMock.mockResolvedValue(CommandResultFactory({ error }));\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n const inner = interval(50).subscribe({\n next: (i) => {\n if (i > 2) {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n o.complete();\n } else {\n o.next({\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: {\n name: \"mockedCurrentApp\",\n version: \"1.0.0\",\n },\n });\n }\n },\n });\n\n return () => {\n inner.unsubscribe();\n };\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error,\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should end in an error if getAppAndVersion actor throws an error\", () =>\n new Promise<void>((resolve, reject) => {\n getDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.LOCKED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n });\n\n getAppAndVersionMock.mockImplementation(() => {\n throw new UnknownDAError(\"error\");\n });\n\n waitForDeviceUnlockMock.mockImplementation(\n () =>\n new Observable((o) => {\n o.complete();\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n vi.spyOn(\n getDeviceStateDeviceAction,\n \"extractDependencies\",\n ).mockReturnValue(extractDependenciesMock());\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n error: new UnknownDAError(\"error\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n it(\"should emit a stopped state if the action is cancelled\", () =>\n new Promise<void>((resolve, reject) => {\n apiGetDeviceSessionStateMock.mockReturnValue({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: { name: \"mockedCurrentApp\", version: \"1.0.0\" },\n installedApps: [],\n deviceModelId: DeviceModelId.NANO_X,\n isSecureConnectionAllowed: false,\n });\n\n sendCommandMock.mockResolvedValue(\n CommandResultFactory({\n data: {\n name: \"BOLOS\",\n version: \"1.0.0\",\n },\n }),\n );\n\n const getDeviceStateDeviceAction = new GetDeviceStatusDeviceAction({\n input: { unlockTimeout: 500 },\n });\n\n const expectedStates: Array<GetDeviceStatusDAState> = [\n {\n status: DeviceActionStatus.Pending, // get app and version\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Stopped,\n },\n ];\n\n const { cancel } = testDeviceActionStates(\n getDeviceStateDeviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n cancel();\n }));\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAqC,gBAErCC,EAAqC,4CACrCC,EAGO,iDACPC,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAAuC,oEACvCC,EAAmC,sDACnCC,EAAwC,4DACxCC,EAIO,wCACPC,EAAuC,kDAEvCC,EAA4C,yCAG5C,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuB,GAAG,GAAG,EAC7BC,EAA4B,GAAG,GAAG,EAClCC,EAA0B,GAAG,GAAG,EAChCC,EAAwB,GAAG,GAAG,EAC9BC,EAAwB,GAAG,GAAG,EAEpC,SAASC,GAA0B,CACjC,MAAO,CACL,iBAAkBL,EAClB,sBAAuBC,EACvB,oBAAqBC,EACrB,sBAAuBC,EACvB,kBAAmBC,CACrB,CACF,CAEA,KAAM,CACJ,YAAaE,EACb,sBAAuBC,EACvB,gCAAiCC,CACnC,KAAI,mCAAgC,EACpC,WAAW,IAAM,CACf,GAAG,cAAc,EACjBJ,EAAsB,gBAAgB,EAAI,CAC5C,CAAC,EAED,SAAS,2CAA4C,IAAM,CACzD,GAAG,uDAAwD,IACzD,IAAI,QAAc,CAACK,EAASC,IAAW,CACrC,MAAMC,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEDJ,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,gBAAc,MAC/B,CAAC,EAEDD,EAAgB,qBACd,wBA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B,CAAC,EAED,GAAG,MACDA,EACA,qBACF,EAAE,gBAAgBN,EAAwB,CAAC,EAE3C,MAAMO,EAAgD,CACpD,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,EACA,OAAQ,qBAAmB,OAC7B,EACA,CACE,MAAO,IAAI,iBAAe,OAAO,EACjC,OAAQ,qBAAmB,KAC7B,CACF,KAEA,0BACED,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,EAED,GAAG,yDAA0D,IAC3D,IAAI,QAAc,CAACD,EAASC,IAAW,CACrCH,EAA6B,gBAAgB,CAC3C,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,WAAY,CAAE,KAAM,mBAAoB,QAAS,OAAQ,EACzD,cAAe,CAAC,EAChB,cAAe,gBAAc,OAC7B,0BAA2B,EAC7B,CAAC,EAEDD,EAAgB,qBACd,wBAAqB,CACnB,KAAM,CACJ,KAAM,QACN,QAAS,OACX,CACF,CAAC,CACH,EAEA,MAAMK,EAA6B,IAAI,8BAA4B,CACjE,MAAO,CAAE,cAAe,GAAI,CAC9B,CAAC,EAEKC,EAAgD,CACpD,CACE,OAAQ,qBAAmB,QAC3B,kBAAmB,CACjB,wBAAyB,0BAAwB,IACnD,CACF,EACA,CACE,OAAQ,qBAAmB,OAC7B,CACF,EAEM,CAAE,OAAAK,CAAO,KAAI,0BACjBN,EACAC,KACA,mCAAgC,EAChC,CACE,OAAQH,EACR,QAASC,CACX,CACF,EACAO,EAAO,CACT,CAAC,CAAC,CACN,CAAC",
6
6
  "names": ["import_rxjs", "import_CommandResult", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_testDeviceActionStates", "import_DeviceActionState", "import_UserInteractionRequired", "import_Errors", "import_DeviceSessionState", "import_GetDeviceStatusDeviceAction", "getAppAndVersionMock", "getDeviceSessionStateMock", "waitForDeviceUnlockMock", "setDeviceSessionState", "isDeviceOnboardedMock", "extractDependenciesMock", "sendCommandMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "resolve", "reject", "getDeviceStateDeviceAction", "expectedStates", "o", "inner", "i", "error", "cancel"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var f=(a,t)=>{for(var s in t)c(a,s,{get:t[s],enumerable:!0})},C=(a,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of b(t))!x.call(a,n)&&n!==s&&c(a,n,{get:()=>t[n],enumerable:!(i=G(t,n))||i.enumerable});return a};var E=a=>C(c({},"__esModule",{value:!0}),a);var k={};f(k,{GoToDashboardDeviceAction:()=>I});module.exports=E(k);var p=require("purify-ts"),r=require("xstate"),u=require("../../../command/model/CommandResult"),D=require("../../../command/os/CloseAppCommand"),l=require("../../../command/os/GetAppAndVersionCommand"),S=require("../../../device-action/model/UserInteractionRequired"),A=require("../../../device-action/os/Const"),m=require("../../../device-action/os/Errors"),h=require("../../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),v=require("../../../device-action/xstate-utils/XStateDeviceAction"),y=require("../../../device-session/DeviceSessionState");class I extends v.XStateDeviceAction{makeStateMachine(t){const{getDeviceSessionState:s,setDeviceSessionState:i,closeApp:n,getAppAndVersion:g}=this.extractDependencies(t),d=this.input.unlockTimeout??A.DEFAULT_UNLOCK_TIMEOUT_MS,T=new h.GetDeviceStatusDeviceAction({input:{unlockTimeout:d}}).makeStateMachine(t);return(0,r.setup)({types:{input:{unlockTimeout:d},context:{},output:{}},actors:{getAppAndVersion:(0,r.fromPromise)(g),closeApp:(0,r.fromPromise)(n),getDeviceStatus:T},guards:{hasError:({context:e})=>e._internalState.error!==null,isDashboardOpen:({context:e})=>e._internalState.currentApp==="BOLOS"},actions:{assignErrorFromEvent:(0,r.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GoToDashboardDeviceAction",initial:"DeviceReady",context:e=>{const o=s();return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:S.UserInteractionRequired.None},_internalState:{currentApp:"currentApp"in o?o.currentApp.name:null,error:null}}},states:{DeviceReady:{always:{target:"GetDeviceStatus"}},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,r.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:(0,r.assign)({_internalState:e=>e.event.output.caseOf({Right:o=>({...e.context._internalState,currentApp:o.currentApp}),Left:o=>({...e.context._internalState,error:o})})})}}},CheckDeviceStatus:{always:[{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"Success",guard:"isDashboardOpen"},{target:"Error",guard:"hasError"},{target:"Error",guard:e=>e.context._internalState.currentApp===null,actions:(0,r.assign)({_internalState:e=>({...e.context._internalState,error:new m.UnknownDAError("currentApp === null")})})},{target:"CloseApp"}]},CloseApp:{invoke:{src:"closeApp",onDone:{target:"CloseAppCheck",actions:(0,r.assign)({_internalState:e=>(0,u.isSuccessCommandResult)(e.event.output)?e.context._internalState:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseAppCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetAppAndVersion",reenter:!0}]},GetAppAndVersion:{invoke:{src:"getAppAndVersion",onDone:{target:"DashboardCheck",actions:(0,r.assign)({_internalState:e=>{if((0,u.isSuccessCommandResult)(e.event.output)){const o=s();return o.sessionStateType!==y.DeviceSessionStateType.Connected&&i({...o,currentApp:e.event.output.data}),{...e.context._internalState,currentApp:e.event.output.data.name}}return{...e.context._internalState,error:e.event.output.error}}})}}},Success:{type:"final"},Error:{type:"final"}},output:e=>e.context._internalState.error?(0,p.Left)(e.context._internalState.error):(0,p.Right)(void 0)})}extractDependencies(t){return{closeApp:async()=>t.sendCommand(new D.CloseAppCommand),getAppAndVersion:async()=>t.sendCommand(new l.GetAppAndVersionCommand),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:n=>t.setDeviceSessionState(n)}}}0&&(module.exports={GoToDashboardDeviceAction});
1
+ "use strict";var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var C=(a,t)=>{for(var s in t)c(a,s,{get:t[s],enumerable:!0})},E=(a,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of f(t))!x.call(a,n)&&n!==s&&c(a,n,{get:()=>t[n],enumerable:!(i=b(t,n))||i.enumerable});return a};var I=a=>E(c({},"__esModule",{value:!0}),a);var M={};C(M,{GoToDashboardDeviceAction:()=>k});module.exports=I(M);var p=require("purify-ts"),r=require("xstate"),u=require("../../../command/model/CommandResult"),D=require("../../../command/os/CloseAppCommand"),l=require("../../../command/os/GetAppAndVersionCommand"),S=require("../../../device-action/model/UserInteractionRequired"),A=require("../../../device-action/os/Const"),m=require("../../../device-action/os/Errors"),h=require("../../../device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),v=require("../../../device-action/xstate-utils/XStateDeviceAction"),y=require("../../../device-session/DeviceSessionState"),g=require("../../../utils/AppName");class k extends v.XStateDeviceAction{makeStateMachine(t){const{getDeviceSessionState:s,setDeviceSessionState:i,closeApp:n,getAppAndVersion:T}=this.extractDependencies(t),d=this.input.unlockTimeout??A.DEFAULT_UNLOCK_TIMEOUT_MS,G=new h.GetDeviceStatusDeviceAction({input:{unlockTimeout:d}}).makeStateMachine(t);return(0,r.setup)({types:{input:{unlockTimeout:d},context:{},output:{}},actors:{getAppAndVersion:(0,r.fromPromise)(T),closeApp:(0,r.fromPromise)(n),getDeviceStatus:G},guards:{hasError:({context:e})=>e._internalState.error!==null,isDashboardOpen:({context:e})=>e._internalState.currentApp!==null&&(0,g.isDashboardName)(e._internalState.currentApp)},actions:{assignErrorFromEvent:(0,r.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GoToDashboardDeviceAction",initial:"DeviceReady",context:e=>{const o=s();return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:S.UserInteractionRequired.None},_internalState:{currentApp:"currentApp"in o?o.currentApp.name:null,error:null}}},states:{DeviceReady:{always:{target:"GetDeviceStatus"}},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,r.assign)({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:(0,r.assign)({_internalState:e=>e.event.output.caseOf({Right:o=>({...e.context._internalState,currentApp:o.currentApp}),Left:o=>({...e.context._internalState,error:o})})})}}},CheckDeviceStatus:{always:[{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"Success",guard:"isDashboardOpen"},{target:"Error",guard:"hasError"},{target:"Error",guard:e=>e.context._internalState.currentApp===null,actions:(0,r.assign)({_internalState:e=>({...e.context._internalState,error:new m.UnknownDAError("currentApp === null")})})},{target:"CloseApp"}]},CloseApp:{invoke:{src:"closeApp",onDone:{target:"CloseAppCheck",actions:(0,r.assign)({_internalState:e=>(0,u.isSuccessCommandResult)(e.event.output)?e.context._internalState:{...e.context._internalState,error:e.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseAppCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetAppAndVersion",reenter:!0}]},GetAppAndVersion:{invoke:{src:"getAppAndVersion",onDone:{target:"DashboardCheck",actions:(0,r.assign)({_internalState:e=>{if((0,u.isSuccessCommandResult)(e.event.output)){const o=s();return o.sessionStateType!==y.DeviceSessionStateType.Connected&&i({...o,currentApp:e.event.output.data}),{...e.context._internalState,currentApp:e.event.output.data.name}}return{...e.context._internalState,error:e.event.output.error}}})}}},Success:{type:"final"},Error:{type:"final"}},output:e=>e.context._internalState.error?(0,p.Left)(e.context._internalState.error):(0,p.Right)(void 0)})}extractDependencies(t){return{closeApp:async()=>t.sendCommand(new D.CloseAppCommand),getAppAndVersion:async()=>t.sendCommand(new l.GetAppAndVersionCommand),getDeviceSessionState:()=>t.getDeviceSessionState(),setDeviceSessionState:n=>t.setDeviceSessionState(n)}}}0&&(module.exports={GoToDashboardDeviceAction});
2
2
  //# sourceMappingURL=GoToDashboardDeviceAction.js.map