@ledgerhq/device-management-kit 0.0.0-rn-hid-improvements-20250523090318 → 0.0.0-rn-ble-pairing-removed-while-reconnecting-20250731133348

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 (240) hide show
  1. package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
  2. package/lib/cjs/src/api/DeviceManagementKit.js.map +3 -3
  3. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
  4. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.js.map +3 -3
  5. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
  6. package/lib/cjs/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
  7. package/lib/cjs/src/api/command/utils/CommandUtils.js +1 -1
  8. package/lib/cjs/src/api/command/utils/CommandUtils.js.map +2 -2
  9. package/lib/cjs/src/api/command/utils/CommandUtils.test.js +1 -1
  10. package/lib/cjs/src/api/command/utils/CommandUtils.test.js.map +2 -2
  11. package/lib/cjs/src/api/command/utils/GlobalCommandError.js +1 -1
  12. package/lib/cjs/src/api/command/utils/GlobalCommandError.js.map +2 -2
  13. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
  14. package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  15. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  16. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +2 -2
  17. package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +1 -1
  18. package/lib/cjs/src/api/device-action/os/Errors.js +1 -1
  19. package/lib/cjs/src/api/device-action/os/Errors.js.map +3 -3
  20. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  21. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  22. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +1 -1
  23. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  24. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
  25. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  26. package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  27. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  28. package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  29. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  30. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  31. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
  32. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +1 -1
  33. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  34. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  35. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  36. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +2 -2
  37. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
  38. package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +1 -1
  39. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  40. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
  41. package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +1 -1
  42. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  43. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  44. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
  45. package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +1 -1
  46. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  47. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +2 -2
  48. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  49. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +2 -2
  50. package/lib/cjs/src/api/index.js +1 -1
  51. package/lib/cjs/src/api/index.js.map +2 -2
  52. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
  53. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
  54. package/lib/cjs/src/api/secure-channel/device-action/GenuineCheck/types.js.map +1 -1
  55. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
  56. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
  57. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js +1 -1
  58. package/lib/cjs/src/api/secure-channel/device-action/InstallApp/types.js.map +1 -1
  59. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
  60. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
  61. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js +1 -1
  62. package/lib/cjs/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
  63. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
  64. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
  65. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js +1 -1
  66. package/lib/cjs/src/api/secure-channel/device-action/UninstallApp/types.js.map +1 -1
  67. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  68. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  69. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
  70. package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
  71. package/lib/cjs/src/api/secure-channel/task/types.js +1 -1
  72. package/lib/cjs/src/api/secure-channel/task/types.js.map +2 -2
  73. package/lib/cjs/src/api/secure-channel/utils.js +1 -1
  74. package/lib/cjs/src/api/secure-channel/utils.js.map +3 -3
  75. package/lib/cjs/src/api/secure-channel/utils.test.js +1 -1
  76. package/lib/cjs/src/api/secure-channel/utils.test.js.map +3 -3
  77. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  78. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  79. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js +2 -0
  80. package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +7 -0
  81. package/lib/cjs/src/api/transport/model/Errors.js +1 -1
  82. package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
  83. package/lib/cjs/src/api/utils/AppName.js +2 -0
  84. package/lib/cjs/src/api/utils/AppName.js.map +7 -0
  85. package/lib/cjs/src/api/utils/AppName.test.js +2 -0
  86. package/lib/cjs/src/api/utils/AppName.test.js.map +7 -0
  87. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  88. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +2 -2
  89. package/lib/cjs/src/internal/secure-channel/model/Errors.js +1 -1
  90. package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +3 -3
  91. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js +1 -1
  92. package/lib/cjs/src/internal/send/use-case/SendApduUseCase.js.map +3 -3
  93. package/lib/esm/src/api/DeviceManagementKit.js +1 -1
  94. package/lib/esm/src/api/DeviceManagementKit.js.map +3 -3
  95. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js +1 -1
  96. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.js.map +3 -3
  97. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js +1 -1
  98. package/lib/esm/src/api/apdu/utils/ByteArrayBuilder.test.js.map +2 -2
  99. package/lib/esm/src/api/command/utils/CommandUtils.js +1 -1
  100. package/lib/esm/src/api/command/utils/CommandUtils.js.map +3 -3
  101. package/lib/esm/src/api/command/utils/CommandUtils.test.js +1 -1
  102. package/lib/esm/src/api/command/utils/CommandUtils.test.js.map +2 -2
  103. package/lib/esm/src/api/command/utils/GlobalCommandError.js +1 -1
  104. package/lib/esm/src/api/command/utils/GlobalCommandError.js.map +2 -2
  105. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
  106. package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
  107. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
  108. package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +2 -2
  109. package/lib/esm/src/api/device-action/os/Errors.js +1 -1
  110. package/lib/esm/src/api/device-action/os/Errors.js.map +3 -3
  111. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  112. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  113. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
  114. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +2 -2
  115. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
  116. package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +2 -2
  117. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
  118. package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
  119. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  120. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  121. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
  122. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
  123. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
  124. package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
  125. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
  126. package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +2 -2
  127. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
  128. package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +2 -2
  129. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  130. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +3 -3
  131. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  132. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +3 -3
  133. package/lib/esm/src/api/index.js +1 -1
  134. package/lib/esm/src/api/index.js.map +3 -3
  135. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js +1 -1
  136. package/lib/esm/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.js.map +2 -2
  137. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js +1 -1
  138. package/lib/esm/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.js.map +2 -2
  139. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js +1 -1
  140. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.js.map +2 -2
  141. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js +1 -1
  142. package/lib/esm/src/api/secure-channel/device-action/ListInstalledApps/types.js.map +2 -2
  143. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js +1 -1
  144. package/lib/esm/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.js.map +2 -2
  145. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
  146. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
  147. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js +1 -1
  148. package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.test.js.map +3 -3
  149. package/lib/esm/src/api/secure-channel/task/types.js +1 -1
  150. package/lib/esm/src/api/secure-channel/task/types.js.map +2 -2
  151. package/lib/esm/src/api/secure-channel/utils.js +1 -1
  152. package/lib/esm/src/api/secure-channel/utils.js.map +3 -3
  153. package/lib/esm/src/api/secure-channel/utils.test.js +1 -1
  154. package/lib/esm/src/api/secure-channel/utils.test.js.map +3 -3
  155. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
  156. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
  157. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js +2 -0
  158. package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +7 -0
  159. package/lib/esm/src/api/transport/model/Errors.js +1 -1
  160. package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
  161. package/lib/esm/src/api/utils/AppName.js +2 -0
  162. package/lib/esm/src/api/utils/AppName.js.map +7 -0
  163. package/lib/esm/src/api/utils/AppName.test.js +2 -0
  164. package/lib/esm/src/api/utils/AppName.test.js.map +7 -0
  165. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  166. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +2 -2
  167. package/lib/esm/src/internal/secure-channel/model/Errors.js +1 -1
  168. package/lib/esm/src/internal/secure-channel/model/Errors.js.map +3 -3
  169. package/lib/esm/src/internal/send/use-case/SendApduUseCase.js +1 -1
  170. package/lib/esm/src/internal/send/use-case/SendApduUseCase.js.map +3 -3
  171. package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
  172. package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts +28 -0
  173. package/lib/types/src/api/apdu/utils/ByteArrayBuilder.d.ts.map +1 -1
  174. package/lib/types/src/api/command/utils/CommandUtils.d.ts +3 -0
  175. package/lib/types/src/api/command/utils/CommandUtils.d.ts.map +1 -1
  176. package/lib/types/src/api/command/utils/GlobalCommandError.d.ts +1 -1
  177. package/lib/types/src/api/command/utils/GlobalCommandError.d.ts.map +1 -1
  178. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +1 -0
  179. package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
  180. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
  181. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +0 -1
  182. package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
  183. package/lib/types/src/api/device-action/os/Errors.d.ts +10 -0
  184. package/lib/types/src/api/device-action/os/Errors.d.ts.map +1 -1
  185. package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
  186. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +2 -1
  187. package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
  188. package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
  189. package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
  190. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
  191. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +3 -2
  192. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
  193. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
  194. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +0 -1
  195. package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
  196. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
  197. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +0 -1
  198. package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
  199. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
  200. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +0 -1
  201. package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
  202. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts +2 -2
  203. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts.map +1 -1
  204. package/lib/types/src/api/index.d.ts +1 -1
  205. package/lib/types/src/api/index.d.ts.map +1 -1
  206. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction.d.ts.map +1 -1
  207. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts +2 -1
  208. package/lib/types/src/api/secure-channel/device-action/GenuineCheck/types.d.ts.map +1 -1
  209. package/lib/types/src/api/secure-channel/device-action/InstallApp/InstallAppDeviceAction.d.ts.map +1 -1
  210. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts +2 -1
  211. package/lib/types/src/api/secure-channel/device-action/InstallApp/types.d.ts.map +1 -1
  212. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction.d.ts.map +1 -1
  213. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts +2 -1
  214. package/lib/types/src/api/secure-channel/device-action/ListInstalledApps/types.d.ts.map +1 -1
  215. package/lib/types/src/api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction.d.ts.map +1 -1
  216. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts +2 -1
  217. package/lib/types/src/api/secure-channel/device-action/UninstallApp/types.d.ts.map +1 -1
  218. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts +5 -2
  219. package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
  220. package/lib/types/src/api/secure-channel/task/types.d.ts +6 -1
  221. package/lib/types/src/api/secure-channel/task/types.d.ts.map +1 -1
  222. package/lib/types/src/api/secure-channel/utils.d.ts +0 -11
  223. package/lib/types/src/api/secure-channel/utils.d.ts.map +1 -1
  224. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +8 -7
  225. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
  226. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.test.d.ts +2 -0
  227. package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.test.d.ts.map +1 -0
  228. package/lib/types/src/api/transport/model/Errors.d.ts +0 -5
  229. package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
  230. package/lib/types/src/api/utils/AppName.d.ts +2 -0
  231. package/lib/types/src/api/utils/AppName.d.ts.map +1 -0
  232. package/lib/types/src/api/utils/AppName.test.d.ts +2 -0
  233. package/lib/types/src/api/utils/AppName.test.d.ts.map +1 -0
  234. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  235. package/lib/types/src/internal/secure-channel/model/Errors.d.ts +22 -2
  236. package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -1
  237. package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts +5 -1
  238. package/lib/types/src/internal/send/use-case/SendApduUseCase.d.ts.map +1 -1
  239. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  240. package/package.json +1 -1
@@ -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,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,wBAAqB,CACnB,KAAM,CACJ,KAAM,QACN,QAAS,OACX,CACF,CAAC,CACH,EAEA,MAAMM,EAAgD,CACpD,CACE,kBAAmB,CACjB,wBAAyB,0BAAwB,I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pD,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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ACE,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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\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 { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n} from \"./types\";\n\ntype GoToDashboardMachineInternalState = {\n readonly currentApp: string | null;\n readonly error: GoToDashboardDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GoToDashboardDeviceAction extends XStateDeviceAction<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n > {\n type types = StateMachineTypes<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n >;\n\n const {\n getDeviceSessionState,\n setDeviceSessionState,\n closeApp,\n getAppAndVersion,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n 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 closeApp: fromPromise(closeApp),\n getDeviceStatus: getDeviceStatusMachine,\n },\n guards: {\n hasError: ({ context }: { context: types[\"context\"] }) => {\n return context._internalState.error !== null;\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) =>\n context._internalState.currentApp === \"BOLOS\",\n },\n actions: {\n // assignGetDeviceStatusUnknownError: assign({\n // _internalState: (_) => ({\n // ..._.context._internalState,\n // error: new UnknownDAError(\"GetDeviceUnknownStatusError\"),\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 },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHED2AVVARAhrAFgEao4BOEWYAbgJYDGYAgnQC42oB2AdJbQwEpgcEAJ4BiANoAGALqJQAB1SwabTvJAAPRAHYAjFwDMATikA2MwA5DOnQBYArGeOGANCBGI9VrlcvmpRyknQwcAXzD3NExcAmIyCmp6JlZ2bmQwFl5kgGUWHBYAV1gxCE4wLhoOKlQAawqIJIY8guLpOSQQJRU1Dg1tBAAmOy49QYcpHQdBvR0pMcszO3dPBEM7My4HYz1pqWNLPRsdJYiojGw8IhJybIZmXq4AYXwwOlq7sBaikvaNbtUaX6iDsgy2g3Wdksjn8JlBDhWiAchk2OkMgysB2RzlBZxA0UucRuiT4KUeLzeHyaX3yP0keg6imUgPUnQGgxmo3hdkcemMwwcG0RCGxXDRGMsWJRxlxkXxF1i1wSnweaR4V3i5Ap70ksn+zN6wIQfMsYsG0LMg2MZlm60mwucDi4HMli0GgX0zjxBMVmpJyVVnH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iWBumEIAA */\n id: \"GoToDashboardDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n currentApp:\n \"currentApp\" in sessionState\n ? sessionState.currentApp.name\n : null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"GetDeviceStatus\",\n },\n },\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<GoToDashboardMachineInternalState>(\n {\n Right: (output) => ({\n ..._.context._internalState,\n currentApp: output.currentApp,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n );\n },\n }),\n },\n // NOTE: The way we handle our DeviceActions means that we should never as we return an Either\n // onError: {\n // target: \"Error\",\n // actions: \"assignGetDeviceStatusUnknownError\",\n // },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n DashboardCheck: {\n // We check if the dashboard is open\n always: [\n {\n target: \"Success\",\n guard: \"isDashboardOpen\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: (_) => {\n return _.context._internalState.currentApp === null;\n },\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\"currentApp === null\"),\n }),\n }),\n },\n {\n target: \"CloseApp\",\n },\n ],\n },\n CloseApp: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseAppCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return _.context._internalState;\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 CloseAppCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetAppAndVersion\",\n reenter: true,\n },\n ],\n },\n GetAppAndVersion: {\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"DashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n // Narrow the type to ReadyWithoutSecureChannelState or ReadyWithSecureChannelState\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n }\n return {\n ..._.context._internalState,\n currentApp: _.event.output.data.name,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (_) => {\n if (_.context._internalState.error) {\n return Left(_.context._internalState.error);\n }\n\n return Right(undefined);\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const getAppAndVersion = async () =>\n internalApi.sendCommand(new GetAppAndVersionCommand());\n\n return {\n closeApp,\n getAppAndVersion,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAAuC,4CACvCC,EAGO,2CACPC,EAG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AO,CACd,eAAiBA,GAAM,CACrB,MAAI,0BAAuBA,EAAE,MAAM,MAAM,EAAG,CAC1C,MAAMI,EAA4BX,EAAsB,EAExD,OACEW,EAAM,mBACN,yBAAuB,WAEvBV,EAAsB,CACpB,GAAGU,EACH,WAAYJ,EAAE,MAAM,OAAO,IAC7B,CAAC,EAEI,CACL,GAAGA,EAAE,QAAQ,eACb,WAAYA,EAAE,MAAM,OAAO,KAAK,IAClC,CACF,CACA,MAAO,CACL,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,OAAO,KACxB,CACF,CACF,CAAC,CACH,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASA,GACHA,EAAE,QAAQ,eAAe,SACpB,QAAKA,EAAE,QAAQ,eAAe,KAAK,KAGrC,SAAM,MAAS,CAE1B,CAAC,CACH,CAEA,oBAAoBR,EAA+C,CAKjE,MAAO,CACL,SALe,SAAYA,EAAY,YAAY,IAAI,iBAAiB,EAMxE,iBALuB,SACvBA,EAAY,YAAY,IAAI,yBAAyB,EAKrD,sBAAuB,IAAMA,EAAY,sBAAsB,EAC/D,sBAAwBY,GACtBZ,EAAY,sBAAsBY,CAAK,CAC3C,CACF,CACF",
6
- "names": ["GoToDashboardDeviceAction_exports", "__export", "GoToDashboardDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_CloseAppCommand", "import_GetAppAndVersionCommand", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_GetDeviceStatusDeviceAction", "import_XStateDeviceAction", "import_DeviceSessionState", "internalApi", "getDeviceSessionState", "setDeviceSessionState", "closeApp", "getAppAndVersion", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "sessionState", "output", "error", "state"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n CloseAppCommand,\n type CloseAppCommandResult,\n} from \"@api/command/os/CloseAppCommand\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\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 { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { isDashboardName } from \"@api/utils/AppName\";\n\nimport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n} from \"./types\";\n\ntype GoToDashboardMachineInternalState = {\n readonly currentApp: string | null;\n readonly error: GoToDashboardDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly closeApp: () => Promise<CloseAppCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GoToDashboardDeviceAction extends XStateDeviceAction<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n > {\n type types = StateMachineTypes<\n GoToDashboardDAOutput,\n GoToDashboardDAInput,\n GoToDashboardDAError,\n GoToDashboardDAIntermediateValue,\n GoToDashboardMachineInternalState\n >;\n\n const {\n getDeviceSessionState,\n setDeviceSessionState,\n closeApp,\n getAppAndVersion,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getDeviceStatusMachine = new GetDeviceStatusDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n 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 closeApp: fromPromise(closeApp),\n getDeviceStatus: getDeviceStatusMachine,\n },\n guards: {\n hasError: ({ context }: { context: types[\"context\"] }) => {\n return context._internalState.error !== null;\n },\n isDashboardOpen: ({ context }: { context: types[\"context\"] }) =>\n context._internalState.currentApp !== null &&\n isDashboardName(context._internalState.currentApp),\n },\n actions: {\n // assignGetDeviceStatusUnknownError: assign({\n // _internalState: (_) => ({\n // ..._.context._internalState,\n // error: new UnknownDAError(\"GetDeviceUnknownStatusError\"),\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 },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHED2AVVARAhrAFgEao4BOEWYAbgJYDGYAgnQC42oB2AdJbQwEpgcEAJ4BiANoAGALqJQAB1SwabTvJAAPRAHYAjFwDMATikA2MwA5DOnQBYArGeOGANCBGI9VrlcvmpRyknQwcAXzD3NExcAmIyCmp6JlZ2bmQwFl5kgGUWHBYAV1gxCE4wLhoOKlQAawqIJIY8guLpOSQQJRU1Dg1tBAAmOy49QYcpHQdBv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yZgOvsWvqd4EI67bU7AeJtlJc7zkbnyYrBORxGaVCDh6PhhtGAcJjjPye3EWHolxUGCV2YrMcfWhFi5TyjgUYb9h+2TFG+GMIUhRyUy7IXjV0RNH5tZ13VvUpRpjOYYpBWZCxzOnZNHQZGweSR7qhDLcMTqN9vcDkhR0AwsCq1Gq1GhyIxWvsSYWMZ-I9mTJGEbXsx7Av4Qb7ecsR48ACirHsRXmMBjIi2JaRwEIDzeWtsDMmgUdCthwjadSaJFiWBumEIAA */\n id: \"GoToDashboardDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n currentApp:\n \"currentApp\" in sessionState\n ? sessionState.currentApp.name\n : null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"GetDeviceStatus\",\n },\n },\n GetDeviceStatus: {\n // We run the GetDeviceStatus flow to get information about the device state\n invoke: {\n id: \"deviceStatus\",\n src: \"getDeviceStatus\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckDeviceStatus\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<GoToDashboardMachineInternalState>(\n {\n Right: (output) => ({\n ..._.context._internalState,\n currentApp: output.currentApp,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n );\n },\n }),\n },\n // NOTE: The way we handle our DeviceActions means that we should never as we return an Either\n // onError: {\n // target: \"Error\",\n // actions: \"assignGetDeviceStatusUnknownError\",\n // },\n },\n },\n CheckDeviceStatus: {\n // We check the device status to see if we can have an error\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"DashboardCheck\",\n },\n ],\n },\n DashboardCheck: {\n // We check if the dashboard is open\n always: [\n {\n target: \"Success\",\n guard: \"isDashboardOpen\",\n },\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Error\",\n guard: (_) => {\n return _.context._internalState.currentApp === null;\n },\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\"currentApp === null\"),\n }),\n }),\n },\n {\n target: \"CloseApp\",\n },\n ],\n },\n CloseApp: {\n invoke: {\n src: \"closeApp\",\n onDone: {\n target: \"CloseAppCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n return _.context._internalState;\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 CloseAppCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetAppAndVersion\",\n reenter: true,\n },\n ],\n },\n GetAppAndVersion: {\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"DashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n // Narrow the type to ReadyWithoutSecureChannelState or ReadyWithSecureChannelState\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n }\n return {\n ..._.context._internalState,\n currentApp: _.event.output.data.name,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n },\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (_) => {\n if (_.context._internalState.error) {\n return Left(_.context._internalState.error);\n }\n\n return Right(undefined);\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const closeApp = async () => internalApi.sendCommand(new CloseAppCommand());\n const getAppAndVersion = async () =>\n internalApi.sendCommand(new GetAppAndVersionCommand());\n\n return {\n closeApp,\n getAppAndVersion,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAC5BC,EAA2C,kBAE3CC,EAAuC,4CACvCC,EAGO,2CACPC,EAGO,mDAEPC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAA+B,wCAC/BC,EAA4C,6EAE5CC,EAGO,8DACPC,EAGO,kDACPC,EAAgC,8BA2BzB,MAAMb,UAAkC,oBAM7C,CACA,iBACEc,EAOA,CASA,KAAM,CACJ,sBAAAC,EACA,sBAAAC,EACA,SAAAC,EACA,iBAAAC,CACF,EAAI,KAAK,oBAAoBJ,CAAW,EAElCK,EAAgB,KAAK,MAAM,eAAiB,4BAE5CC,EAAyB,IAAI,8BAA4B,CAC7D,MAAO,CACL,cAAAD,CACF,CACF,CAAC,EAAE,iBAAiBL,CAAW,EAC/B,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAK,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,oBAAkB,eAAYD,CAAgB,EAC9C,YAAU,eAAYD,CAAQ,EAC9B,gBAAiBG,CACnB,EACA,OAAQ,CACN,SAAU,CAAC,CAAE,QAAAC,CAAQ,IACZA,EAAQ,eAAe,QAAU,KAE1C,gBAAiB,CAAC,CAAE,QAAAA,CAAQ,IAC1BA,EAAQ,eAAe,aAAe,SACtC,mBAAgBA,EAAQ,eAAe,UAAU,CACrD,EACA,QAAS,CAOP,wBAAsB,UAAO,CAC3B,eAAiBC,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,KACjB,EACF,CAAC,CACH,CACF,CAAC,EAAE,cAAc,CAEf,GAAI,4BACJ,QAAS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AAE,MAAM,MAAM,EAChCA,EAAE,QAAQ,eAEZ,CACL,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,OAAO,KACxB,CAEJ,CAAC,CACH,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,cAAe,CACb,OAAQ,CACN,CACE,OAAQ,QACR,MAAO,UACT,EACA,CACE,OAAQ,mBACR,QAAS,EACX,CACF,CACF,EACA,iBAAkB,CAChB,OAAQ,CACN,IAAK,mBACL,OAAQ,CACN,OAAQ,iBACR,WAAS,UAAO,CACd,eAAiBA,GAAM,CACrB,MAAI,0BAAuBA,EAAE,MAAM,MAAM,EAAG,CAC1C,MAAMI,EAA4BX,EAAsB,EAExD,OACEW,EAAM,mBACN,yBAAuB,WAEvBV,EAAsB,CACpB,GAAGU,EACH,WAAYJ,EAAE,MAAM,OAAO,IAC7B,CAAC,EAEI,CACL,GAAGA,EAAE,QAAQ,eACb,WAAYA,EAAE,MAAM,OAAO,KAAK,IAClC,CACF,CACA,MAAO,CACL,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,OAAO,KACxB,CACF,CACF,CAAC,CACH,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASA,GACHA,EAAE,QAAQ,eAAe,SACpB,QAAKA,EAAE,QAAQ,eAAe,KAAK,KAGrC,SAAM,MAAS,CAE1B,CAAC,CACH,CAEA,oBAAoBR,EAA+C,CAKjE,MAAO,CACL,SALe,SAAYA,EAAY,YAAY,IAAI,iBAAiB,EAMxE,iBALuB,SACvBA,EAAY,YAAY,IAAI,yBAAyB,EAKrD,sBAAuB,IAAMA,EAAY,sBAAsB,EAC/D,sBAAwBY,GACtBZ,EAAY,sBAAsBY,CAAK,CAC3C,CACF,CACF",
6
+ "names": ["GoToDashboardDeviceAction_exports", "__export", "GoToDashboardDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_CommandResult", "import_CloseAppCommand", "import_GetAppAndVersionCommand", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_GetDeviceStatusDeviceAction", "import_XStateDeviceAction", "import_DeviceSessionState", "import_AppName", "internalApi", "getDeviceSessionState", "setDeviceSessionState", "closeApp", "getAppAndVersion", "unlockTimeout", "getDeviceStatusMachine", "context", "_", "sessionState", "output", "error", "state"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var I=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var V=(i,t)=>{for(var l in t)I(i,l,{get:t[l],enumerable:!0})},T=(i,t,l,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of E(t))!U.call(i,o)&&o!==l&&I(i,o,{get:()=>t[o],enumerable:!(p=P(t,o))||p.enumerable});return i};var k=i=>T(I({},"__esModule",{value:!0}),i);var w={};V(w,{InstallOrUpdateAppsDeviceAction:()=>b});module.exports=k(w);var u=require("purify-ts"),n=require("xstate"),s=require("../../../device-action/model/UserInteractionRequired"),S=require("../../../device-action/os/Const"),g=require("../../../device-action/os/Errors"),O=require("../../../device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),x=require("../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),D=require("../../../device-action/task/BuildAppsInstallPlanTask"),f=require("../../../device-action/task/PredictOutOfMemoryTask"),M=require("../../../device-action/xstate-utils/XStateDeviceAction"),h=require("../../../device-session/DeviceSessionState"),v=require("../../../secure-channel/task/ConnectToSecureChannelTask"),c=require("../../../secure-channel/task/types");class b extends M.XStateDeviceAction{makeStateMachine(t){const{buildInstallPlan:l,predictOutOfMemory:p,installApp:o}=this.extractDependencies(t),r=this.input.unlockTimeout??S.DEFAULT_UNLOCK_TIMEOUT_MS,d=new O.GetDeviceMetadataDeviceAction({input:{unlockTimeout:r,useSecureChannel:!0,forceUpdate:!1}}).makeStateMachine(t),m=new x.GoToDashboardDeviceAction({input:{unlockTimeout:r}}).makeStateMachine(t);return(0,n.setup)({types:{input:{unlockTimeout:r},context:{},output:{}},actors:{updateMetadata:d,buildInstallPlan:(0,n.fromPromise)(l),predictOutOfMemory:(0,n.fromPromise)(p),goToDashboard:m,installApp:(0,n.fromObservable)(o)},guards:{hasError:({context:e})=>e._internalState.error!==null,hasInstallPlan:e=>e.context.intermediateValue.installPlan!==null,hasMoreApps:e=>e.context._internalState.currentIndex<e.context.intermediateValue.installPlan.installPlan.length},actions:{assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:e.event.error})}),nextAppIndex:(0,n.assign)({_internalState:e=>({...e.context._internalState,currentIndex:e.context._internalState.currentIndex+1})}),cleanupDeviceState:()=>{const e=t.getDeviceSessionState();e.sessionStateType!==h.DeviceSessionStateType.Connected&&t.setDeviceSessionState({...e,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"InstallOrUpdateAppsDeviceAction",initial:"DeviceReady",context:e=>({input:{applications:e.input.applications,allowMissingApplication:e.input.allowMissingApplication,unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:s.UserInteractionRequired.None,installPlan:null},_internalState:{error:null,osVersion:null,currentIndex:0}}),states:{DeviceReady:{always:[{target:"UpdateDeviceMetadata"}]},UpdateDeviceMetadata:{exit:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:s.UserInteractionRequired.None})}),invoke:{id:"updateMetadata",src:"updateMetadata",input:e=>({unlockTimeout:e.context.input.unlockTimeout,useSecureChannel:!0,forceUpdate:!1}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:e.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"UpdateDeviceMetadataCheck",actions:(0,n.assign)({_internalState:e=>e.event.output.caseOf({Right:a=>({...e.context._internalState,osVersion:a.firmwareVersion.metadata}),Left:a=>({...e.context._internalState,error:a})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},UpdateDeviceMetadataCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"hasInstallPlan"},{target:"BuildInstallPlan"}]},BuildInstallPlan:{invoke:{src:"buildInstallPlan",input:e=>({applications:e.context.input.applications,allowMissingApplication:e.context.input.allowMissingApplication}),onDone:{target:"BuildInstallPlanCheck",actions:(0,n.assign)({_internalState:e=>"error"in e.event.output?{...e.context._internalState,error:e.event.output.error}:e.context._internalState,intermediateValue:e=>"error"in e.event.output?e.context.intermediateValue:{...e.context.intermediateValue,installPlan:{installPlan:e.event.output.installPlan,alreadyInstalled:e.event.output.alreadyInstalled,missingApplications:e.event.output.missingApplications,currentIndex:0,currentProgress:0}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},BuildInstallPlanCheck:{always:[{guard:"hasError",target:"Error"},{target:"PredictOutOfMemory",guard:"hasMoreApps"},{target:"Success"}]},PredictOutOfMemory:{invoke:{src:"predictOutOfMemory",input:e=>({installPlan:e.context.intermediateValue.installPlan.installPlan}),onDone:{target:"PredictOutOfMemoryCheck",actions:(0,n.assign)({_internalState:e=>"error"in e.event.output?{...e.context._internalState,error:e.event.output.error}:e.event.output.outOfMemory?{...e.context._internalState,error:new g.OutOfMemoryDAError("Not enough memory for those applications")}:e.context._internalState})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},PredictOutOfMemoryCheck:{always:[{guard:"hasError",target:"Error"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:e.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:(0,n.assign)({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:a=>({...e.context._internalState,error:a})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"InstallApp",actions:"cleanupDeviceState"}]},InstallApp:{exit:(0,n.assign)({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:s.UserInteractionRequired.None})}),invoke:{id:"installApp",src:"installApp",input:e=>({osVersion:e.context._internalState.osVersion,application:e.context.intermediateValue.installPlan.installPlan[e.context._internalState.currentIndex]}),onSnapshot:{actions:(0,n.assign)({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case c.SecureChannelEventType.PermissionRequested:return{...e.context.intermediateValue,requiredUserInteraction:s.UserInteractionRequired.AllowSecureConnection};case c.SecureChannelEventType.PermissionGranted:{const a=t.getDeviceSessionState();return a.sessionStateType!==h.DeviceSessionStateType.Connected&&t.setDeviceSessionState({...a,isSecureConnectionAllowed:!0}),{...e.context.intermediateValue,requiredUserInteraction:s.UserInteractionRequired.None}}case c.SecureChannelEventType.Progress:return{...e.context.intermediateValue,installPlan:{...e.context.intermediateValue.installPlan,currentIndex:e.context._internalState.currentIndex,currentProgress:e.event.snapshot.context.payload.progress}};default:return e.context.intermediateValue}}})},onDone:{target:"InstallAppCheck",actions:"nextAppIndex"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},InstallAppCheck:{always:[{target:"Error",guard:"hasError"},{target:"InstallApp",guard:"hasMoreApps"},{target:"UpdateDeviceMetadata"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:a}=e,{error:y}=a._internalState,{installPlan:A}=a.intermediateValue;return y?(0,u.Left)(y):(0,u.Right)({successfullyInstalled:A.installPlan,alreadyInstalled:A.alreadyInstalled,missingApplications:A.missingApplications})}})}extractDependencies(t){return{buildInstallPlan:async r=>new D.BuildAppsInstallPlanTask(t,{applications:r.input.applications,allowMissingApplication:r.input.allowMissingApplication}).run(),predictOutOfMemory:async r=>new f.PredictOutOfMemoryTask(t,{installPlan:r.input.installPlan}).run(),installApp:r=>{const{osVersion:d,application:m}=r.input,e=t.getSecureChannelService().installApp(d,m);return new v.ConnectToSecureChannelTask(t,{connection:e}).run()}}}}0&&(module.exports={InstallOrUpdateAppsDeviceAction});
1
+ "use strict";var I=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var V=(i,e)=>{for(var l in e)I(i,l,{get:e[l],enumerable:!0})},T=(i,e,l,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!U.call(i,o)&&o!==l&&I(i,o,{get:()=>e[o],enumerable:!(p=P(e,o))||p.enumerable});return i};var k=i=>T(I({},"__esModule",{value:!0}),i);var w={};V(w,{InstallOrUpdateAppsDeviceAction:()=>b});module.exports=k(w);var u=require("purify-ts"),n=require("xstate"),s=require("../../../device-action/model/UserInteractionRequired"),S=require("../../../device-action/os/Const"),g=require("../../../device-action/os/Errors"),x=require("../../../device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),O=require("../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction"),D=require("../../../device-action/task/BuildAppsInstallPlanTask"),f=require("../../../device-action/task/PredictOutOfMemoryTask"),v=require("../../../device-action/xstate-utils/XStateDeviceAction"),h=require("../../../device-session/DeviceSessionState"),M=require("../../../secure-channel/task/ConnectToSecureChannelTask"),c=require("../../../secure-channel/task/types");class b extends v.XStateDeviceAction{makeStateMachine(e){const{buildInstallPlan:l,predictOutOfMemory:p,installApp:o}=this.extractDependencies(e),r=this.input.unlockTimeout??S.DEFAULT_UNLOCK_TIMEOUT_MS,d=new x.GetDeviceMetadataDeviceAction({input:{unlockTimeout:r,useSecureChannel:!0,forceUpdate:!1}}).makeStateMachine(e),m=new O.GoToDashboardDeviceAction({input:{unlockTimeout:r}}).makeStateMachine(e);return(0,n.setup)({types:{input:{unlockTimeout:r},context:{},output:{}},actors:{updateMetadata:d,buildInstallPlan:(0,n.fromPromise)(l),predictOutOfMemory:(0,n.fromPromise)(p),goToDashboard:m,installApp:(0,n.fromObservable)(o)},guards:{hasError:({context:t})=>t._internalState.error!==null,hasInstallPlan:t=>t.context.intermediateValue.installPlan!==null,hasMoreApps:t=>t.context._internalState.currentIndex<t.context.intermediateValue.installPlan.installPlan.length},actions:{assignErrorFromEvent:(0,n.assign)({_internalState:t=>({...t.context._internalState,error:t.event.error})}),nextAppIndex:(0,n.assign)({_internalState:t=>({...t.context._internalState,currentIndex:t.context._internalState.currentIndex+1})}),cleanupDeviceState:()=>{const t=e.getDeviceSessionState();t.sessionStateType!==h.DeviceSessionStateType.Connected&&e.setDeviceSessionState({...t,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"InstallOrUpdateAppsDeviceAction",initial:"DeviceReady",context:t=>({input:{applications:t.input.applications,allowMissingApplication:t.input.allowMissingApplication,unlockTimeout:t.input.unlockTimeout},intermediateValue:{requiredUserInteraction:s.UserInteractionRequired.None,installPlan:null},_internalState:{error:null,osVersion:null,currentIndex:0}}),states:{DeviceReady:{always:[{target:"UpdateDeviceMetadata"}]},UpdateDeviceMetadata:{exit:(0,n.assign)({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:s.UserInteractionRequired.None})}),invoke:{id:"updateMetadata",src:"updateMetadata",input:t=>({unlockTimeout:t.context.input.unlockTimeout,useSecureChannel:!0,forceUpdate:!1}),onSnapshot:{actions:(0,n.assign)({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"UpdateDeviceMetadataCheck",actions:(0,n.assign)({_internalState:t=>t.event.output.caseOf({Right:a=>({...t.context._internalState,osVersion:a.firmwareVersion.metadata}),Left:a=>({...t.context._internalState,error:a})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},UpdateDeviceMetadataCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"hasInstallPlan"},{target:"BuildInstallPlan"}]},BuildInstallPlan:{invoke:{src:"buildInstallPlan",input:t=>({applications:t.context.input.applications,allowMissingApplication:t.context.input.allowMissingApplication}),onDone:{target:"BuildInstallPlanCheck",actions:(0,n.assign)({_internalState:t=>"error"in t.event.output?{...t.context._internalState,error:t.event.output.error}:t.context._internalState,intermediateValue:t=>"error"in t.event.output?t.context.intermediateValue:{...t.context.intermediateValue,installPlan:{installPlan:t.event.output.installPlan,alreadyInstalled:t.event.output.alreadyInstalled,missingApplications:t.event.output.missingApplications,currentIndex:0,currentProgress:0}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},BuildInstallPlanCheck:{always:[{guard:"hasError",target:"Error"},{target:"PredictOutOfMemory",guard:"hasMoreApps"},{target:"Success"}]},PredictOutOfMemory:{invoke:{src:"predictOutOfMemory",input:t=>({installPlan:t.context.intermediateValue.installPlan.installPlan}),onDone:{target:"PredictOutOfMemoryCheck",actions:(0,n.assign)({_internalState:t=>"error"in t.event.output?{...t.context._internalState,error:t.event.output.error}:t.event.output.outOfMemory?{...t.context._internalState,error:new g.OutOfMemoryDAError("Not enough memory for those applications")}:t.context._internalState})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},PredictOutOfMemoryCheck:{always:[{guard:"hasError",target:"Error"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:t=>({unlockTimeout:t.context.input.unlockTimeout}),onSnapshot:{actions:(0,n.assign)({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:t.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:(0,n.assign)({_internalState:t=>t.event.output.caseOf({Right:()=>t.context._internalState,Left:a=>({...t.context._internalState,error:a})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"InstallApp",actions:"cleanupDeviceState"}]},InstallApp:{exit:(0,n.assign)({intermediateValue:t=>({...t.context.intermediateValue,requiredUserInteraction:s.UserInteractionRequired.None})}),invoke:{id:"installApp",src:"installApp",input:t=>({osVersion:t.context._internalState.osVersion,application:t.context.intermediateValue.installPlan.installPlan[t.context._internalState.currentIndex]}),onSnapshot:{actions:(0,n.assign)({intermediateValue:t=>{switch(t.event.snapshot.context?.type){case c.SecureChannelEventType.PermissionRequested:return{...t.context.intermediateValue,requiredUserInteraction:s.UserInteractionRequired.AllowSecureConnection};case c.SecureChannelEventType.PermissionGranted:{const a=e.getDeviceSessionState();return a.sessionStateType!==h.DeviceSessionStateType.Connected&&e.setDeviceSessionState({...a,isSecureConnectionAllowed:!0}),{...t.context.intermediateValue,requiredUserInteraction:s.UserInteractionRequired.None}}case c.SecureChannelEventType.Progress:return{...t.context.intermediateValue,installPlan:{...t.context.intermediateValue.installPlan,currentIndex:t.context._internalState.currentIndex,currentProgress:t.event.snapshot.context.payload.progress}};default:return t.context.intermediateValue}},_internalState:t=>t.event.snapshot.context?.type===c.SecureChannelEventType.Error?{...t.context._internalState,error:t.event.snapshot.context.error.mapInstallDAErrors()}:t.context._internalState})},onDone:{target:"InstallAppCheck",actions:"nextAppIndex"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},InstallAppCheck:{always:[{target:"Error",guard:"hasError"},{target:"InstallApp",guard:"hasMoreApps"},{target:"UpdateDeviceMetadata"}]},Success:{type:"final"},Error:{type:"final"}},output:t=>{const{context:a}=t,{error:y}=a._internalState,{installPlan:A}=a.intermediateValue;return y?(0,u.Left)(y):(0,u.Right)({successfullyInstalled:A.installPlan,alreadyInstalled:A.alreadyInstalled,missingApplications:A.missingApplications})}})}extractDependencies(e){return{buildInstallPlan:async r=>new D.BuildAppsInstallPlanTask(e,{applications:r.input.applications,allowMissingApplication:r.input.allowMissingApplication}).run(),predictOutOfMemory:async r=>new f.PredictOutOfMemoryTask(e,{installPlan:r.input.installPlan}).run(),installApp:r=>{const{osVersion:d,application:m}=r.input,t=e.getSecureChannelService().installApp(d,m);return new M.ConnectToSecureChannelTask(e,{connection:t}).run()}}}}0&&(module.exports={InstallOrUpdateAppsDeviceAction});
2
2
  //# sourceMappingURL=InstallOrUpdateAppsDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\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 { OutOfMemoryDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport {\n BuildAppsInstallPlanTask,\n type BuildAppsInstallPlanTaskResult,\n} from \"@api/device-action/task/BuildAppsInstallPlanTask\";\nimport {\n PredictOutOfMemoryTask,\n type PredictOutOfMemoryTaskResult,\n} from \"@api/device-action/task/PredictOutOfMemoryTask\";\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 { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport { type GetOsVersionResponse } from \"@api/index\";\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\";\n\nimport {\n type ApplicationDependency,\n type InstallOrUpdateAppsDAError,\n type InstallOrUpdateAppsDAInput,\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n} from \"./types\";\n\ntype InstallOrUpdateAppsMachineInternalState = {\n readonly error: InstallOrUpdateAppsDAError | null;\n readonly osVersion: GetOsVersionResponse | null;\n readonly currentIndex: number;\n};\n\nexport type MachineDependencies = {\n readonly buildInstallPlan: (arg0: {\n input: {\n applications: ApplicationDependency[];\n allowMissingApplication: boolean;\n };\n }) => Promise<BuildAppsInstallPlanTaskResult>;\n readonly predictOutOfMemory: (arg0: {\n input: {\n installPlan: Application[];\n };\n }) => Promise<PredictOutOfMemoryTaskResult>;\n readonly installApp: (arg0: {\n input: {\n osVersion: GetOsVersionResponse;\n application: Application;\n };\n }) => Observable<SecureChannelEvent>;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class InstallOrUpdateAppsDeviceAction extends XStateDeviceAction<\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDAInput,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAIntermediateValue,\n InstallOrUpdateAppsMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDAInput,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAIntermediateValue,\n InstallOrUpdateAppsMachineInternalState\n > {\n type types = StateMachineTypes<\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDAInput,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAIntermediateValue,\n InstallOrUpdateAppsMachineInternalState\n >;\n\n const { buildInstallPlan, predictOutOfMemory, installApp } =\n this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const updateMetadataMachine = new GetDeviceMetadataDeviceAction({\n input: {\n unlockTimeout,\n useSecureChannel: true,\n forceUpdate: false,\n },\n }).makeStateMachine(internalApi);\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\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 updateMetadata: updateMetadataMachine,\n buildInstallPlan: fromPromise(buildInstallPlan),\n predictOutOfMemory: fromPromise(predictOutOfMemory),\n goToDashboard: goToDashboardMachine,\n installApp: fromObservable(installApp),\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n hasInstallPlan: (_) => _.context.intermediateValue.installPlan !== null,\n hasMoreApps: (_) =>\n _.context._internalState.currentIndex <\n _.context.intermediateValue.installPlan!.installPlan.length,\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 nextAppIndex: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n currentIndex: _.context._internalState.currentIndex + 1,\n }),\n }),\n cleanupDeviceState: () => {\n // After app successful installation, cleanup the device session state\n // to force fetching the new device state when required\n const state = internalApi.getDeviceSessionState();\n if (state.sessionStateType !== DeviceSessionStateType.Connected) {\n internalApi.setDeviceSessionState({\n ...state,\n installedApps: [],\n appsUpdates: undefined,\n });\n }\n },\n },\n }).createMachine({\n id: \"InstallOrUpdateAppsDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n applications: _.input.applications,\n allowMissingApplication: _.input.allowMissingApplication,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n _internalState: {\n error: null,\n osVersion: null,\n currentIndex: 0,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"UpdateDeviceMetadata\",\n },\n ],\n },\n UpdateDeviceMetadata: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n id: \"updateMetadata\",\n src: \"updateMetadata\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n useSecureChannel: true,\n forceUpdate: false,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"UpdateDeviceMetadataCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallOrUpdateAppsMachineInternalState>(\n {\n Right: (data) => ({\n ..._.context._internalState,\n osVersion: data.firmwareVersion.metadata!,\n }),\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 UpdateDeviceMetadataCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Success\",\n guard: \"hasInstallPlan\",\n },\n {\n target: \"BuildInstallPlan\",\n },\n ],\n },\n BuildInstallPlan: {\n invoke: {\n src: \"buildInstallPlan\",\n input: (_) => ({\n applications: _.context.input.applications,\n allowMissingApplication: _.context.input.allowMissingApplication,\n }),\n onDone: {\n target: \"BuildInstallPlanCheck\",\n actions: assign({\n _internalState: (_) => {\n if (\"error\" in _.event.output) {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n } else {\n return _.context._internalState;\n }\n },\n intermediateValue: (_) => {\n if (\"error\" in _.event.output) {\n return _.context.intermediateValue;\n } else {\n return {\n ..._.context.intermediateValue,\n installPlan: {\n installPlan: _.event.output.installPlan,\n alreadyInstalled: _.event.output.alreadyInstalled,\n missingApplications: _.event.output.missingApplications,\n currentIndex: 0,\n currentProgress: 0,\n },\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n BuildInstallPlanCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"PredictOutOfMemory\",\n guard: \"hasMoreApps\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n PredictOutOfMemory: {\n invoke: {\n src: \"predictOutOfMemory\",\n input: (_) => ({\n installPlan: _.context.intermediateValue.installPlan!.installPlan,\n }),\n onDone: {\n target: \"PredictOutOfMemoryCheck\",\n actions: assign({\n _internalState: (_) => {\n if (\"error\" in _.event.output) {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n } else if (_.event.output.outOfMemory) {\n return {\n ..._.context._internalState,\n error: new OutOfMemoryDAError(\n \"Not enough memory for those applications\",\n ),\n };\n } else {\n return _.context._internalState;\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n PredictOutOfMemoryCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n invoke: {\n id: \"goToDashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallOrUpdateAppsMachineInternalState>(\n {\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: \"InstallApp\",\n actions: \"cleanupDeviceState\",\n },\n ],\n },\n InstallApp: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n id: \"installApp\",\n src: \"installApp\",\n input: (_) => ({\n osVersion: _.context._internalState.osVersion!,\n application:\n _.context.intermediateValue.installPlan!.installPlan[\n _.context._internalState.currentIndex\n ]!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n switch (_.event.snapshot.context?.type) {\n case SecureChannelEventType.PermissionRequested: {\n return {\n ..._.context.intermediateValue,\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 ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n case SecureChannelEventType.Progress: {\n return {\n ..._.context.intermediateValue,\n installPlan: {\n ..._.context.intermediateValue.installPlan!,\n currentIndex: _.context._internalState.currentIndex,\n currentProgress:\n _.event.snapshot.context.payload.progress,\n },\n };\n }\n default:\n return _.context.intermediateValue;\n }\n },\n }),\n },\n onDone: {\n target: \"InstallAppCheck\",\n actions: \"nextAppIndex\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n InstallAppCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"InstallApp\",\n guard: \"hasMoreApps\",\n },\n {\n target: \"UpdateDeviceMetadata\",\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 { error } = context._internalState;\n const { installPlan } = context.intermediateValue;\n if (error) {\n return Left(error);\n }\n return Right({\n successfullyInstalled: installPlan!.installPlan,\n alreadyInstalled: installPlan!.alreadyInstalled,\n missingApplications: installPlan!.missingApplications,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const buildInstallPlan = async (arg0: {\n input: {\n applications: ApplicationDependency[];\n allowMissingApplication: boolean;\n };\n }) =>\n new BuildAppsInstallPlanTask(internalApi, {\n applications: arg0.input.applications,\n allowMissingApplication: arg0.input.allowMissingApplication,\n }).run();\n\n const predictOutOfMemory = async (arg0: {\n input: {\n installPlan: Application[];\n };\n }) =>\n new PredictOutOfMemoryTask(internalApi, {\n installPlan: arg0.input.installPlan,\n }).run();\n\n const installApp = (arg0: {\n input: {\n osVersion: GetOsVersionResponse;\n application: Application;\n };\n }) => {\n const { osVersion, application } = arg0.input;\n const connection = internalApi\n .getSecureChannelService()\n .installApp(osVersion, application);\n return new ConnectToSecureChannelTask(internalApi, {\n connection,\n }).run();\n };\n\n return {\n buildInstallPlan,\n predictOutOfMemory,\n installApp,\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,qBAE5BC,EAA2D,kBAG3DC,EAAwC,4DACxCC,EAA0C,uCAC1CC,EAAmC,wCACnCC,EAA8C,iFAC9CC,EAA0C,yEAC1CC,EAGO,4DACPC,EAGO,0DAEPC,EAGO,8DACPC,EAAuC,kDAEvCC,EAA2C,+DAC3CC,EAAuC,0CA0ChC,MAAMd,UAAwC,oBAMnD,CACA,iBACEe,EAOA,CASA,KAAM,CAAE,iBAAAC,EAAkB,mBAAAC,EAAoB,WAAAC,CAAW,EACvD,KAAK,oBAAoBH,CAAW,EAEhCI,EAAgB,KAAK,MAAM,eAAiB,4BAE5CC,EAAwB,IAAI,gCAA8B,CAC9D,MAAO,CACL,cAAAD,EACA,iBAAkB,GAClB,YAAa,EACf,CACF,CAAC,EAAE,iBAAiBJ,CAAW,EAEzBM,EAAuB,IAAI,4BAA0B,CACzD,MAAO,CACL,cAAAF,CACF,CACF,CAAC,EAAE,iBAAiBJ,CAAW,EAE/B,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAI,CACF,EACA,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,eAAgBC,EAChB,oBAAkB,eAAYJ,CAAgB,EAC9C,sBAAoB,eAAYC,CAA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,CAAE,MAAAF,CAAM,EAAIJ,EAAQ,eACpB,CAAE,YAAAO,CAAY,EAAIP,EAAQ,kBAChC,OAAII,KACK,QAAKA,CAAK,KAEZ,SAAM,CACX,sBAAuBG,EAAa,YACpC,iBAAkBA,EAAa,iBAC/B,oBAAqBA,EAAa,mBACpC,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBd,EAA+C,CAoCjE,MAAO,CACL,iBApCuB,MAAOe,GAM9B,IAAI,2BAAyBf,EAAa,CACxC,aAAce,EAAK,MAAM,aACzB,wBAAyBA,EAAK,MAAM,uBACtC,CAAC,EAAE,IAAI,EA4BP,mBA1ByB,MAAOA,GAKhC,IAAI,yBAAuBf,EAAa,CACtC,YAAae,EAAK,MAAM,WAC1B,CAAC,EAAE,IAAI,EAoBP,WAlBkBA,GAKd,CACJ,KAAM,CAAE,UAAAC,EAAW,YAAAC,CAAY,EAAIF,EAAK,MAClCG,EAAalB,EAChB,wBAAwB,EACxB,WAAWgB,EAAWC,CAAW,EACpC,OAAO,IAAI,6BAA2BjB,EAAa,CACjD,WAAAkB,CACF,CAAC,EAAE,IAAI,CACT,CAMA,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\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 { OutOfMemoryDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport {\n BuildAppsInstallPlanTask,\n type BuildAppsInstallPlanTaskResult,\n} from \"@api/device-action/task/BuildAppsInstallPlanTask\";\nimport {\n PredictOutOfMemoryTask,\n type PredictOutOfMemoryTaskResult,\n} from \"@api/device-action/task/PredictOutOfMemoryTask\";\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 { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport { type GetOsVersionResponse } from \"@api/index\";\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\";\n\nimport {\n type ApplicationDependency,\n type InstallOrUpdateAppsDAError,\n type InstallOrUpdateAppsDAInput,\n type InstallOrUpdateAppsDAIntermediateValue,\n type InstallOrUpdateAppsDAOutput,\n} from \"./types\";\n\ntype InstallOrUpdateAppsMachineInternalState = {\n readonly error: InstallOrUpdateAppsDAError | null;\n readonly osVersion: GetOsVersionResponse | null;\n readonly currentIndex: number;\n};\n\nexport type MachineDependencies = {\n readonly buildInstallPlan: (arg0: {\n input: {\n applications: ApplicationDependency[];\n allowMissingApplication: boolean;\n };\n }) => Promise<BuildAppsInstallPlanTaskResult>;\n readonly predictOutOfMemory: (arg0: {\n input: {\n installPlan: Application[];\n };\n }) => Promise<PredictOutOfMemoryTaskResult>;\n readonly installApp: (arg0: {\n input: {\n osVersion: GetOsVersionResponse;\n application: Application;\n };\n }) => Observable<SecureChannelEvent>;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class InstallOrUpdateAppsDeviceAction extends XStateDeviceAction<\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDAInput,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAIntermediateValue,\n InstallOrUpdateAppsMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDAInput,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAIntermediateValue,\n InstallOrUpdateAppsMachineInternalState\n > {\n type types = StateMachineTypes<\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDAInput,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAIntermediateValue,\n InstallOrUpdateAppsMachineInternalState\n >;\n\n const { buildInstallPlan, predictOutOfMemory, installApp } =\n this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const updateMetadataMachine = new GetDeviceMetadataDeviceAction({\n input: {\n unlockTimeout,\n useSecureChannel: true,\n forceUpdate: false,\n },\n }).makeStateMachine(internalApi);\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\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 updateMetadata: updateMetadataMachine,\n buildInstallPlan: fromPromise(buildInstallPlan),\n predictOutOfMemory: fromPromise(predictOutOfMemory),\n goToDashboard: goToDashboardMachine,\n installApp: fromObservable(installApp),\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n hasInstallPlan: (_) => _.context.intermediateValue.installPlan !== null,\n hasMoreApps: (_) =>\n _.context._internalState.currentIndex <\n _.context.intermediateValue.installPlan!.installPlan.length,\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 nextAppIndex: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n currentIndex: _.context._internalState.currentIndex + 1,\n }),\n }),\n cleanupDeviceState: () => {\n // After app successful installation, cleanup the device session state\n // to force fetching the new device state when required\n const state = internalApi.getDeviceSessionState();\n if (state.sessionStateType !== DeviceSessionStateType.Connected) {\n internalApi.setDeviceSessionState({\n ...state,\n installedApps: [],\n appsUpdates: undefined,\n });\n }\n },\n },\n }).createMachine({\n id: \"InstallOrUpdateAppsDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n applications: _.input.applications,\n allowMissingApplication: _.input.allowMissingApplication,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n _internalState: {\n error: null,\n osVersion: null,\n currentIndex: 0,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"UpdateDeviceMetadata\",\n },\n ],\n },\n UpdateDeviceMetadata: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n id: \"updateMetadata\",\n src: \"updateMetadata\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n useSecureChannel: true,\n forceUpdate: false,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"UpdateDeviceMetadataCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallOrUpdateAppsMachineInternalState>(\n {\n Right: (data) => ({\n ..._.context._internalState,\n osVersion: data.firmwareVersion.metadata!,\n }),\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 UpdateDeviceMetadataCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"Success\",\n guard: \"hasInstallPlan\",\n },\n {\n target: \"BuildInstallPlan\",\n },\n ],\n },\n BuildInstallPlan: {\n invoke: {\n src: \"buildInstallPlan\",\n input: (_) => ({\n applications: _.context.input.applications,\n allowMissingApplication: _.context.input.allowMissingApplication,\n }),\n onDone: {\n target: \"BuildInstallPlanCheck\",\n actions: assign({\n _internalState: (_) => {\n if (\"error\" in _.event.output) {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n } else {\n return _.context._internalState;\n }\n },\n intermediateValue: (_) => {\n if (\"error\" in _.event.output) {\n return _.context.intermediateValue;\n } else {\n return {\n ..._.context.intermediateValue,\n installPlan: {\n installPlan: _.event.output.installPlan,\n alreadyInstalled: _.event.output.alreadyInstalled,\n missingApplications: _.event.output.missingApplications,\n currentIndex: 0,\n currentProgress: 0,\n },\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n BuildInstallPlanCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"PredictOutOfMemory\",\n guard: \"hasMoreApps\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n PredictOutOfMemory: {\n invoke: {\n src: \"predictOutOfMemory\",\n input: (_) => ({\n installPlan: _.context.intermediateValue.installPlan!.installPlan,\n }),\n onDone: {\n target: \"PredictOutOfMemoryCheck\",\n actions: assign({\n _internalState: (_) => {\n if (\"error\" in _.event.output) {\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n } else if (_.event.output.outOfMemory) {\n return {\n ..._.context._internalState,\n error: new OutOfMemoryDAError(\n \"Not enough memory for those applications\",\n ),\n };\n } else {\n return _.context._internalState;\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n PredictOutOfMemoryCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n invoke: {\n id: \"goToDashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n }),\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<InstallOrUpdateAppsMachineInternalState>(\n {\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: \"InstallApp\",\n actions: \"cleanupDeviceState\",\n },\n ],\n },\n InstallApp: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n id: \"installApp\",\n src: \"installApp\",\n input: (_) => ({\n osVersion: _.context._internalState.osVersion!,\n application:\n _.context.intermediateValue.installPlan!.installPlan[\n _.context._internalState.currentIndex\n ]!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n switch (_.event.snapshot.context?.type) {\n case SecureChannelEventType.PermissionRequested: {\n return {\n ..._.context.intermediateValue,\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 ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n case SecureChannelEventType.Progress: {\n return {\n ..._.context.intermediateValue,\n installPlan: {\n ..._.context.intermediateValue.installPlan!,\n currentIndex: _.context._internalState.currentIndex,\n currentProgress:\n _.event.snapshot.context.payload.progress,\n },\n };\n }\n default:\n return _.context.intermediateValue;\n }\n },\n _internalState: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Error\n ) {\n return {\n ..._.context._internalState,\n error:\n _.event.snapshot.context.error.mapInstallDAErrors(),\n };\n }\n return _.context._internalState;\n },\n }),\n },\n onDone: {\n target: \"InstallAppCheck\",\n actions: \"nextAppIndex\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n InstallAppCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"InstallApp\",\n guard: \"hasMoreApps\",\n },\n {\n target: \"UpdateDeviceMetadata\",\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 { error } = context._internalState;\n const { installPlan } = context.intermediateValue;\n if (error) {\n return Left(error);\n }\n return Right({\n successfullyInstalled: installPlan!.installPlan,\n alreadyInstalled: installPlan!.alreadyInstalled,\n missingApplications: installPlan!.missingApplications,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const buildInstallPlan = async (arg0: {\n input: {\n applications: ApplicationDependency[];\n allowMissingApplication: boolean;\n };\n }) =>\n new BuildAppsInstallPlanTask(internalApi, {\n applications: arg0.input.applications,\n allowMissingApplication: arg0.input.allowMissingApplication,\n }).run();\n\n const predictOutOfMemory = async (arg0: {\n input: {\n installPlan: Application[];\n };\n }) =>\n new PredictOutOfMemoryTask(internalApi, {\n installPlan: arg0.input.installPlan,\n }).run();\n\n const installApp = (arg0: {\n input: {\n osVersion: GetOsVersionResponse;\n application: Application;\n };\n }) => {\n const { osVersion, application } = arg0.input;\n const connection = internalApi\n .getSecureChannelService()\n .installApp(osVersion, application);\n return new ConnectToSecureChannelTask(internalApi, {\n connection,\n }).run();\n };\n\n return {\n buildInstallPlan,\n predictOutOfMemory,\n installApp,\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,I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ApCuB,MAAOe,GAM9B,IAAI,2BAAyBf,EAAa,CACxC,aAAce,EAAK,MAAM,aACzB,wBAAyBA,EAAK,MAAM,uBACtC,CAAC,EAAE,IAAI,EA4BP,mBA1ByB,MAAOA,GAKhC,IAAI,yBAAuBf,EAAa,CACtC,YAAae,EAAK,MAAM,WAC1B,CAAC,EAAE,IAAI,EAoBP,WAlBkBA,GAKd,CACJ,KAAM,CAAE,UAAAC,EAAW,YAAAC,CAAY,EAAIF,EAAK,MAClCG,EAAalB,EAChB,wBAAwB,EACxB,WAAWgB,EAAWC,CAAW,EACpC,OAAO,IAAI,6BAA2BjB,EAAa,CACjD,WAAAkB,CACF,CAAC,EAAE,IAAI,CACT,CAMA,CACF,CACF",
6
6
  "names": ["InstallOrUpdateAppsDeviceAction_exports", "__export", "InstallOrUpdateAppsDeviceAction", "__toCommonJS", "import_purify_ts", "import_xstate", "import_UserInteractionRequired", "import_Const", "import_Errors", "import_GetDeviceMetadataDeviceAction", "import_GoToDashboardDeviceAction", "import_BuildAppsInstallPlanTask", "import_PredictOutOfMemoryTask", "import_XStateDeviceAction", "import_DeviceSessionState", "import_ConnectToSecureChannelTask", "import_types", "internalApi", "buildInstallPlan", "predictOutOfMemory", "installApp", "unlockTimeout", "updateMetadataMachine", "goToDashboardMachine", "context", "_", "state", "data", "error", "deviceState", "args", "installPlan", "arg0", "osVersion", "application", "connection"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var s=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of i(e))!l.call(t,r)&&r!==o&&n(t,r,{get:()=>e[r],enumerable:!(a=p(e,r))||a.enumerable});return t};var d=t=>s(n({},"__esModule",{value:!0}),t);var c={};module.exports=d(c);
1
+ "use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var s=(r,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of i(e))!l.call(r,t)&&t!==o&&n(r,t,{get:()=>e[t],enumerable:!(a=p(e,t))||a.enumerable});return r};var d=r=>s(n({},"__esModule",{value:!0}),r);var c={};module.exports=d(c);
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/InstallOrUpdateApps/types.ts"],
4
- "sourcesContent": ["import type { CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport type { DeviceModelId } from \"@api/device/DeviceModel\";\nimport type { DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport type { OutOfMemoryDAError } from \"@api/device-action/os/Errors\";\nimport type {\n GetDeviceMetadataDAError,\n GetDeviceMetadataDARequiredInteraction,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport type { GoToDashboardDARequiredInteraction } from \"@api/device-action/os/GoToDashboard/types\";\nimport type { GoToDashboardDAInput } from \"@api/device-action/os/GoToDashboard/types\";\nimport type { InstallAppDAError } from \"@api/secure-channel/device-action/InstallApp/types\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\n\n/**\n * An application version used as application constraint should either be a valid semantic versioning formatted\n * string, or \"latest\" to ensure the app is always up-to-date.\n */\nexport type ApplicationVersionConstraint =\n | `${number}.${number}.${number}`\n | `${number}.${number}.${number}-${string}`\n | `${number}.${number}.${number}+${string}`\n | `${number}.${number}.${number}-${string}+${string}`\n | \"latest\";\n\nexport type ApplicationConstraint = {\n /**\n * Required minimal version of the application, if already installed on the device.\n */\n readonly minVersion: ApplicationVersionConstraint;\n\n /**\n * List of device models that require the minVersion.\n */\n readonly applicableModels?: DeviceModelId[];\n\n /**\n * List of device models that do not require the minVersion.\n */\n readonly exemptModels?: DeviceModelId[];\n};\n\nexport type ApplicationDependency = {\n /**\n * Name of the application to install.\n */\n readonly name: string;\n\n /**\n * List of constraints for the application.\n * If no constraints are provided, no version checks are performed.\n * If the current device model is not concerned by any listed contraints, no version checks are performed.\n */\n readonly constraints?: ApplicationConstraint[];\n};\n\nexport type InstallPlan = {\n readonly installPlan: Application[];\n readonly alreadyInstalled: string[];\n readonly missingApplications: string[];\n readonly currentIndex: number;\n readonly currentProgress: number;\n};\n\nexport type InstallOrUpdateAppsDAOutput = {\n readonly successfullyInstalled: Application[];\n readonly alreadyInstalled: string[];\n readonly missingApplications: string[];\n};\n\nexport type InstallOrUpdateAppsDAInput = GoToDashboardDAInput & {\n readonly applications: ApplicationDependency[];\n readonly allowMissingApplication: boolean;\n};\n\nexport type InstallOrUpdateAppsDAError =\n | GetDeviceMetadataDAError\n | InstallAppDAError\n | OutOfMemoryDAError\n | CommandErrorResult[\"error\"];\n\nexport type InstallOrUpdateAppsDARequiredInteraction =\n | GoToDashboardDARequiredInteraction\n | GetDeviceMetadataDARequiredInteraction;\n\nexport type InstallOrUpdateAppsDAIntermediateValue = {\n requiredUserInteraction: InstallOrUpdateAppsDARequiredInteraction;\n installPlan: InstallPlan | null;\n};\n\nexport type InstallOrUpdateAppsDAState = DeviceActionState<\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAIntermediateValue\n>;\n"],
4
+ "sourcesContent": ["import type { CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport type { DeviceModelId } from \"@api/device/DeviceModel\";\nimport type { DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport type {\n OutOfMemoryDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nimport type {\n GetDeviceMetadataDAError,\n GetDeviceMetadataDARequiredInteraction,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport type { GoToDashboardDARequiredInteraction } from \"@api/device-action/os/GoToDashboard/types\";\nimport type { GoToDashboardDAInput } from \"@api/device-action/os/GoToDashboard/types\";\nimport type { InstallAppDAError } from \"@api/secure-channel/device-action/InstallApp/types\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\nimport type { SecureChannelInstallDAErrors } from \"@internal/secure-channel/model/Errors\";\n\n/**\n * An application version used as application constraint should either be a valid semantic versioning formatted\n * string, or \"latest\" to ensure the app is always up-to-date.\n */\nexport type ApplicationVersionConstraint =\n | `${number}.${number}.${number}`\n | `${number}.${number}.${number}-${string}`\n | `${number}.${number}.${number}+${string}`\n | `${number}.${number}.${number}-${string}+${string}`\n | \"latest\";\n\nexport type ApplicationConstraint = {\n /**\n * Required minimal version of the application, if already installed on the device.\n */\n readonly minVersion: ApplicationVersionConstraint;\n\n /**\n * List of device models that require the minVersion.\n */\n readonly applicableModels?: DeviceModelId[];\n\n /**\n * List of device models that do not require the minVersion.\n */\n readonly exemptModels?: DeviceModelId[];\n};\n\nexport type ApplicationDependency = {\n /**\n * Name of the application to install.\n */\n readonly name: string;\n\n /**\n * List of constraints for the application.\n * If no constraints are provided, no version checks are performed.\n * If the current device model is not concerned by any listed contraints, no version checks are performed.\n */\n readonly constraints?: ApplicationConstraint[];\n};\n\nexport type InstallPlan = {\n readonly installPlan: Application[];\n readonly alreadyInstalled: string[];\n readonly missingApplications: string[];\n readonly currentIndex: number;\n readonly currentProgress: number;\n};\n\nexport type InstallOrUpdateAppsDAOutput = {\n readonly successfullyInstalled: Application[];\n readonly alreadyInstalled: string[];\n readonly missingApplications: string[];\n};\n\nexport type InstallOrUpdateAppsDAInput = GoToDashboardDAInput & {\n readonly applications: ApplicationDependency[];\n readonly allowMissingApplication: boolean;\n};\n\nexport type InstallOrUpdateAppsDAError =\n | GetDeviceMetadataDAError\n | InstallAppDAError\n | OutOfMemoryDAError\n | UnsupportedFirmwareDAError\n | SecureChannelInstallDAErrors\n | CommandErrorResult[\"error\"];\n\nexport type InstallOrUpdateAppsDARequiredInteraction =\n | GoToDashboardDARequiredInteraction\n | GetDeviceMetadataDARequiredInteraction;\n\nexport type InstallOrUpdateAppsDAIntermediateValue = {\n requiredUserInteraction: InstallOrUpdateAppsDARequiredInteraction;\n installPlan: InstallPlan | null;\n};\n\nexport type InstallOrUpdateAppsDAState = DeviceActionState<\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAIntermediateValue\n>;\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["types_exports", "__toCommonJS"]
7
7
  }