@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,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/model/UserInteractionRequired.ts"],
4
- "sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n}\n"],
5
- "mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,gBAAkB,qBAVRA,OAAA",
4
+ "sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n}\n"],
5
+ "mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAXRA,OAAA",
6
6
  "names": ["UserInteractionRequired"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as p,Right as o}from"purify-ts";import{assign as t,fromPromise as i,setup as l}from"xstate";import{isSuccessCommandResult as c}from"../../../command/model/CommandResult";import{UserInteractionRequired as s}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as u}from"../../../device-action/os/Errors";import{OpenAppDeviceAction as k}from"../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{XStateDeviceAction as A}from"../../../device-action/xstate-utils/XStateDeviceAction";class R extends A{makeStateMachine(a){const{callTask:r}=this.extractDependencies(a);return l({types:{input:{},context:{},output:{}},actors:{callTask:i(r),openAppStateMachine:new k({input:{appName:this.input.appName,compatibleAppNames:this.input.compatibleAppNames}}).makeStateMachine(a)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:t({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:s.None},_internalState:{taskResponse:null,error:null}}),states:{InitialState:{always:[{target:"CallTask",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName,compatibleAppNames:this.input.compatibleAppNames},src:"openAppStateMachine",onSnapshot:{actions:t({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:t({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:n=>({...e.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:t({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:t({intermediateValue:{requiredUserInteraction:s.None}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[t({_internalState:({event:e,context:n})=>c(e.output)?{...n._internalState,taskResponse:e.output.data}:{...n._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.taskResponse?o(e._internalState.taskResponse):p(e._internalState.error||new u("No error in final state"))})}extractDependencies(a){return{callTask:r=>r.input(a)}}}export{R as CallTaskInAppDeviceAction};
1
+ import{Left as p,Right as o}from"purify-ts";import{assign as t,fromPromise as i,setup as l}from"xstate";import{isSuccessCommandResult as c}from"../../../command/model/CommandResult";import{UserInteractionRequired as s}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as u}from"../../../device-action/os/Errors";import{OpenAppDeviceAction as k}from"../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{XStateDeviceAction as A}from"../../../device-action/xstate-utils/XStateDeviceAction";class R extends A{makeStateMachine(a){const{callTask:r}=this.extractDependencies(a);return l({types:{input:{},context:{},output:{}},actors:{callTask:i(r),openAppStateMachine:new k({input:{appName:this.input.appName}}).makeStateMachine(a)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:t({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:s.None},_internalState:{taskResponse:null,error:null}}),states:{InitialState:{always:[{target:"CallTask",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:t({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:t({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:n=>({...e.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:t({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:t({intermediateValue:{requiredUserInteraction:s.None}}),invoke:{id:"callTask",src:"callTask",input:e=>e.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[t({_internalState:({event:e,context:n})=>c(e.output)?{...n._internalState,taskResponse:e.output.data}:{...n._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.taskResponse?o(e._internalState.taskResponse):p(e._internalState.error||new u("No error in final state"))})}extractDependencies(a){return{callTask:r=>r.input(a)}}}export{R as CallTaskInAppDeviceAction};
2
2
  //# sourceMappingURL=CallTaskInAppDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAInput,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAInternalState,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, calls a task\n * in the app.\n * The output will be the result of the task.\n *\n * ```ts\n * input: {\n * appName: string;\n * task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new CallTaskInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * task: async (internalApi: InternalApi) => internalApi.sendCommand(new MyAppSpecificCommand()),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class CallTaskInAppDeviceAction<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n > {\n type types = StateMachineTypes<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >;\n\n const { callTask } = this.extractDependencies(internalAPI);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n callTask: fromPromise(callTask),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n compatibleAppNames: this.input.compatibleAppNames,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n skipOpenApp: () => this.input.skipOpenApp,\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"CallTaskInAppDeviceAction\",\n initial: \"InitialState\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n taskResponse: null,\n error: null,\n },\n };\n },\n states: {\n InitialState: {\n always: [\n {\n target: \"CallTask\",\n guard: \"skipOpenApp\",\n },\n \"OpenAppDeviceAction\",\n ],\n },\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n compatibleAppNames: this.input.compatibleAppNames,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"CallTask\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n CallTask: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"callTask\",\n src: \"callTask\",\n input: (_: { context: types[\"context\"] }) => _.context.input.task,\n onDone: {\n target: \"CallTaskResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n taskResponse: event.output.data,\n };\n }\n return {\n ...context._internalState,\n error: event.output.error,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CallTaskResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.taskResponse\n ? Right(context._internalState.taskResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n callTask: (_: {\n input: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n }): Promise<CommandResult<TaskResponse, TaskErrorCodes>> =>\n _.input(internalApi),\n };\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAEE,0BAAAC,MACK,mCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,uBAAAC,MAA2B,gEAEpC,OAEE,sBAAAC,MACK,qDAoCA,MAAMC,UAIHD,CAMR,CACA,iBACEE,EAOA,CASA,KAAM,CAAE,SAAAC,CAAS,EAAI,KAAK,oBAAoBD,CAAW,EAEzD,OAAOP,EAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,SAAUD,EAAYS,CAAQ,EAC9B,oBAAqB,IAAIJ,EAAoB,CAC3C,MAAO,CACL,QAAS,KAAK,MAAM,QACpB,mBAAoB,KAAK,MAAM,kBACjC,CACF,CAAC,EAAE,iBAAiBG,CAAW,CACjC,EACA,OAAQ,CACN,YAAa,IAAM,KAAK,MAAM,YAC9B,gBAAiB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IACrE,EACA,QAAS,CACP,qBAAsBX,EAAO,CAC3B,eAAiBY,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,KACjB,EACF,CAAC,CACH,CACF,CAAC,EAAE,cAA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AAO,KACtB,CAEJ,CAAC,CACH,CACF,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,oBAAqB,CACnB,OAAQ,CACN,CACE,OAAQ,UACR,MAAO,iBACT,EACA,OACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAJ,CAAQ,IACjBA,EAAQ,eAAe,aACnBZ,EAAMY,EAAQ,eAAe,YAAY,EACzCb,EACEa,EAAQ,eAAe,OACrB,IAAIN,EAAe,yBAAyB,CAChD,CACR,CAAC,CACH,CAEA,oBAAoBW,EAA0B,CAC5C,MAAO,CACL,SAAWJ,GAKTA,EAAE,MAAMI,CAAW,CACvB,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type CallTaskInAppDAError,\n type CallTaskInAppDAInput,\n type CallTaskInAppDAIntermediateValue,\n type CallTaskInAppDAInternalState,\n type CallTaskInAppDAOutput,\n} from \"./CallTaskInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, calls a task\n * in the app.\n * The output will be the result of the task.\n *\n * ```ts\n * input: {\n * appName: string;\n * task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new CallTaskInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * task: async (internalApi: InternalApi) => internalApi.sendCommand(new MyAppSpecificCommand()),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class CallTaskInAppDeviceAction<\n TaskResponse,\n TaskErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n > {\n type types = StateMachineTypes<\n CallTaskInAppDAOutput<TaskResponse>,\n CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>,\n CallTaskInAppDAError<TaskErrorCodes>,\n CallTaskInAppDAIntermediateValue<UserInteraction>,\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >;\n\n const { callTask } = this.extractDependencies(internalAPI);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n callTask: fromPromise(callTask),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n skipOpenApp: () => this.input.skipOpenApp,\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"CallTaskInAppDeviceAction\",\n initial: \"InitialState\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n taskResponse: null,\n error: null,\n },\n };\n },\n states: {\n InitialState: {\n always: [\n {\n target: \"CallTask\",\n guard: \"skipOpenApp\",\n },\n \"OpenAppDeviceAction\",\n ],\n },\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes>\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"CallTask\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n CallTask: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"callTask\",\n src: \"callTask\",\n input: (_: { context: types[\"context\"] }) => _.context.input.task,\n onDone: {\n target: \"CallTaskResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n taskResponse: event.output.data,\n };\n }\n return {\n ...context._internalState,\n error: event.output.error,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n CallTaskResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.taskResponse\n ? Right(context._internalState.taskResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n callTask: (_: {\n input: (\n internalApi: InternalApi,\n ) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;\n }): Promise<CommandResult<TaskResponse, TaskErrorCodes>> =>\n _.input(internalApi),\n };\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAEE,0BAAAC,MACK,mCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,uBAAAC,MAA2B,gEAEpC,OAEE,sBAAAC,MACK,qDAoCA,MAAMC,UAIHD,CAMR,CACA,iBACEE,EAOA,CASA,KAAM,CAAE,SAAAC,CAAS,EAAI,KAAK,oBAAoBD,CAAW,EAEzD,OAAOP,EAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,SAAUD,EAAYS,CAAQ,EAC9B,oBAAqB,IAAIJ,EAAoB,CAC3C,MAAO,CACL,QAAS,KAAK,MAAM,OACtB,CACF,CAAC,EAAE,iBAAiBG,CAAW,CACjC,EACA,OAAQ,CACN,YAAa,IAAM,KAAK,MAAM,YAC9B,gBAAiB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IACrE,EACA,QAAS,CACP,qBAAsBX,EAAO,CAC3B,eAAiBY,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE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,eACX,MAAOI,EAAM,OAAO,KACtB,CAEJ,CAAC,CACH,CACF,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,oBAAqB,CACnB,OAAQ,CACN,CACE,OAAQ,UACR,MAAO,iBACT,EACA,OACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAJ,CAAQ,IACjBA,EAAQ,eAAe,aACnBZ,EAAMY,EAAQ,eAAe,YAAY,EACzCb,EACEa,EAAQ,eAAe,OACrB,IAAIN,EAAe,yBAAyB,CAChD,CACR,CAAC,CACH,CAEA,oBAAoBW,EAA0B,CAC5C,MAAO,CACL,SAAWJ,GAKTA,EAAE,MAAMI,CAAW,CACvB,CACF,CACF",
6
6
  "names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "UserInteractionRequired", "UnknownDAError", "OpenAppDeviceAction", "XStateDeviceAction", "CallTaskInAppDeviceAction", "internalAPI", "callTask", "context", "_", "input", "error", "event", "internalApi"]
7
7
  }
@@ -1,2 +1,2 @@
1
- class n{_tag="DeviceNotOnboardedError";originalError;constructor(r){this.originalError=new Error(r??"Device not onboarded.")}}class e{_tag="DeviceLockedError";originalError;constructor(r){this.originalError=new Error(r??"Device locked.")}}class i{_tag="UnsupportedFirmwareDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class t{_tag="OutOfMemoryDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class E{_tag="UnknownDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}export{e as DeviceLockedError,n as DeviceNotOnboardedError,t as OutOfMemoryDAError,E as UnknownDAError,i as UnsupportedFirmwareDAError};
1
+ class n{_tag="DeviceNotOnboardedError";originalError;constructor(r){this.originalError=new Error(r??"Device not onboarded.")}}class e{_tag="DeviceLockedError";originalError;constructor(r){this.originalError=new Error(r??"Device locked.")}}class t{_tag="UnsupportedFirmwareDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class i{_tag="RefusedByUserDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class a{_tag="AppAlreadyInstalledDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class s{_tag="OutOfMemoryDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class E{_tag="UnknownDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}export{a as AppAlreadyInstalledDAError,e as DeviceLockedError,n as DeviceNotOnboardedError,s as OutOfMemoryDAError,i as RefusedByUserDAError,E as UnknownDAError,t as UnsupportedFirmwareDAError};
2
2
  //# sourceMappingURL=Errors.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/os/Errors.ts"],
4
- "sourcesContent": ["import { type DmkError } from \"@api/Error\";\n\nexport class DeviceNotOnboardedError implements DmkError {\n readonly _tag = \"DeviceNotOnboardedError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Device not onboarded.\");\n }\n}\n\nexport class DeviceLockedError implements DmkError {\n readonly _tag = \"DeviceLockedError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Device locked.\");\n }\n}\n\nexport class UnsupportedFirmwareDAError implements DmkError {\n readonly _tag = \"UnsupportedFirmwareDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class OutOfMemoryDAError implements DmkError {\n readonly _tag = \"OutOfMemoryDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class UnknownDAError implements DmkError {\n readonly _tag = \"UnknownDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n"],
5
- "mappings": "AAEO,MAAMA,CAA4C,CAC9C,KAAO,0BACP,cAET,YAAYC,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,uBAAuB,CACnE,CACF,CAEO,MAAMC,CAAsC,CACxC,KAAO,oBACP,cAET,YAAYD,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAME,CAA+C,CACjD,KAAO,6BACP,cAET,YAAYF,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMG,CAAuC,CACzC,KAAO,qBACP,cAET,YAAYH,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMI,CAAmC,CACrC,KAAO,iBACP,cAET,YAAYJ,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF",
6
- "names": ["DeviceNotOnboardedError", "message", "DeviceLockedError", "UnsupportedFirmwareDAError", "OutOfMemoryDAError", "UnknownDAError"]
4
+ "sourcesContent": ["import { type DmkError } from \"@api/Error\";\n\nexport class DeviceNotOnboardedError implements DmkError {\n readonly _tag = \"DeviceNotOnboardedError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Device not onboarded.\");\n }\n}\n\nexport class DeviceLockedError implements DmkError {\n readonly _tag = \"DeviceLockedError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Device locked.\");\n }\n}\n\nexport class UnsupportedFirmwareDAError implements DmkError {\n readonly _tag = \"UnsupportedFirmwareDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class RefusedByUserDAError implements DmkError {\n readonly _tag = \"RefusedByUserDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class AppAlreadyInstalledDAError implements DmkError {\n readonly _tag = \"AppAlreadyInstalledDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class OutOfMemoryDAError implements DmkError {\n readonly _tag = \"OutOfMemoryDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class UnknownDAError implements DmkError {\n readonly _tag = \"UnknownDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n"],
5
+ "mappings": "AAEO,MAAMA,CAA4C,CAC9C,KAAO,0BACP,cAET,YAAYC,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,uBAAuB,CACnE,CACF,CAEO,MAAMC,CAAsC,CACxC,KAAO,oBACP,cAET,YAAYD,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAME,CAA+C,CACjD,KAAO,6BACP,cAET,YAAYF,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMG,CAAyC,CAC3C,KAAO,uBACP,cAET,YAAYH,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMI,CAA+C,CACjD,KAAO,6BACP,cAET,YAAYJ,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMK,CAAuC,CACzC,KAAO,qBACP,cAET,YAAYL,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMM,CAAmC,CACrC,KAAO,iBACP,cAET,YAAYN,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF",
6
+ "names": ["DeviceNotOnboardedError", "message", "DeviceLockedError", "UnsupportedFirmwareDAError", "RefusedByUserDAError", "AppAlreadyInstalledDAError", "OutOfMemoryDAError", "UnknownDAError"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as C,Right as x}from"purify-ts";import{assign as r,fromObservable as V,fromPromise as p,setup as G}from"xstate";import{isSuccessCommandResult as f}from"../../../command/model/CommandResult";import{UserInteractionRequired as i}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as I}from"../../../device-action/os/Const";import{GoToDashboardDeviceAction as F}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{ListAppsDeviceAction as E}from"../../../device-action/os/ListApps/ListAppsDeviceAction";import{GetApplicationsMetadataTask as U}from"../../../device-action/task/GetApplicationsMetadataTask";import{GetFirmwareMetadataTask as k}from"../../../device-action/task/GetFirmwareMetadataTask";import{XStateDeviceAction as T}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as o}from"../../../device-session/DeviceSessionState";import{installedAppResultGuard as L}from"../../../secure-channel/device-action/ListInstalledApps/types";import{ConnectToSecureChannelTask as R}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as c}from"../../../secure-channel/task/types";class Y extends T{makeStateMachine(n){const{getDeviceMetadata:u,getFirmwareMetadata:d,getApplicationsMetadata:m,listAppsSecureChannel:g}=this.extractDependencies(n),t=this.input.unlockTimeout??I,s=new F({input:{unlockTimeout:t}}).makeStateMachine(n),l=new E({input:{unlockTimeout:t}}).makeStateMachine(n);return G({types:{input:{unlockTimeout:t},context:{},output:{}},actors:{goToDashboard:s,getDeviceMetadata:p(u),getFirmwareMetadata:p(d),getApplicationsMetadata:p(m),listApps:l,listAppsSecureChannel:V(g)},guards:{hasError:({context:e})=>e._internalState.error!==null,hasMetadata:({context:e})=>e._internalState.firmwareVersion!==null&&e._internalState.firmwareUpdateContext!==null&&e._internalState.customImage!==null&&e._internalState.applications!==null&&e._internalState.applicationsUpdates!==null&&e._internalState.installedLanguages!==null&&e._internalState.catalog!==null,forceUpdate:({context:e})=>!!e.input.forceUpdate,useSecureChannel:({context:e})=>!!e.input.useSecureChannel},actions:{assignErrorFromEvent:r({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetDeviceMetadataDeviceAction",initial:"DeviceReady",context:e=>({input:{useSecureChannel:e.input.useSecureChannel,forceUpdate:e.input.forceUpdate,unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:i.None},_internalState:{error:null,deviceVersion:null,firmware:null,firmwareVersion:null,firmwareUpdateContext:null,customImage:null,installedApps:null,applications:null,applicationsUpdates:null,installedLanguages:null,catalog:null}}),states:{DeviceReady:{always:[{target:"GoToDashboard",guard:"forceUpdate"},{target:"GetDeviceMetadataFromContext"}]},GetDeviceMetadataFromContext:{invoke:{src:"getDeviceMetadata",onDone:{target:"GetDeviceMetadataFromContextResultCheck",actions:r({_internalState:e=>e.event.output===null?e.context._internalState:{...e.context._internalState,firmwareVersion:e.event.output.firmwareVersion,firmwareUpdateContext:e.event.output.firmwareUpdateContext,customImage:e.event.output.customImage,applications:e.event.output.applications,applicationsUpdates:e.event.output.applicationsUpdates,installedLanguages:e.event.output.installedLanguages,catalog:e.event.output.catalog}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceMetadataFromContextResultCheck:{always:[{target:"Success",guard:"hasMetadata"},{target:"GoToDashboard"}]},GoToDashboard:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"dashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"GoToDashboardCheck",actions:r({_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:"GetFirmwareMetadata"}]},GetFirmwareMetadata:{invoke:{src:"getFirmwareMetadata",onDone:{target:"GetFirmwareMetadataResultCheck",actions:r({_internalState:e=>{if(f(e.event.output)){const a=n.getDeviceSessionState();return a.sessionStateType!==o.Connected&&n.setDeviceSessionState({...a,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}),{...e.context._internalState,deviceVersion:e.event.output.data.deviceVersion,firmware:e.event.output.data.firmware,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"useSecureChannel",target:"ListAppsSecureChannel"},{target:"ListApps"}]},ListAppsSecureChannel:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"listAppsSecureChannel",src:"listAppsSecureChannel",input:e=>({firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion}),onSnapshot:{actions:r({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case c.PermissionRequested:return{requiredUserInteraction:i.AllowSecureConnection};case c.PermissionGranted:{const a=n.getDeviceSessionState();return a.sessionStateType!==o.Connected&&n.setDeviceSessionState({...a,isSecureConnectionAllowed:!0}),{requiredUserInteraction:i.None}}default:return{...e.context.intermediateValue}}},_internalState:e=>{if(e.event.snapshot.context?.type===c.Result){if(L(e.event.snapshot.context.payload))return{...e.context._internalState,installedApps:e.event.snapshot.context.payload.map(a=>({name:a.name,hash:a.hash,hashCode:a.hash_code_data}))};throw new Error(`Invalid result ${JSON.stringify(e.event.snapshot.context.payload)}`)}return{...e.context._internalState}}})},onDone:{target:"ListAppsCheck"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListApps:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"listApps",src:"listApps",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"ListAppsCheck",actions:r({_internalState:e=>e.event.output.isLeft()?{...e.context._internalState,error:e.event.output.extract()}:{...e.context._internalState,installedApps:e.event.output.unsafeCoerce().map(a=>({name:a.appName,hash:a.appFullHash,hashCode:a.appCodeHash}))}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetApplicationsMetadata"}]},GetApplicationsMetadata:{invoke:{src:"getApplicationsMetadata",input:e=>({deviceVersion:e.context._internalState.deviceVersion,firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion,installedApps:e.context._internalState.installedApps}),onDone:{target:"GetApplicationsMetadataResultCheck",actions:r({_internalState:e=>{if(f(e.event.output)){const a=n.getDeviceSessionState();return a.sessionStateType!==o.Connected&&n.setDeviceSessionState({...a,installedApps:e.event.output.data.applications,appsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}),{...e.context._internalState,applications:e.event.output.data.applications,applicationsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetApplicationsMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:a}=e,{error:v,firmwareVersion:S,firmwareUpdateContext:w,customImage:h,applications:D,applicationsUpdates:M,installedLanguages:y,catalog:A}=a._internalState;return v?C(v):x({firmwareVersion:S,firmwareUpdateContext:w,customImage:h,applications:D,applicationsUpdates:M,installedLanguages:y,catalog:A})}})}extractDependencies(n){return{getDeviceMetadata:async()=>{const t=n.getDeviceSessionState();return t.sessionStateType===o.Connected||t.firmwareVersion?.metadata===void 0||t.firmwareUpdateContext===void 0||t.customImage===void 0||t.installedApps.length===0||t.appsUpdates===void 0||t.installedLanguages===void 0||t.catalog===void 0?null:{firmwareVersion:t.firmwareVersion,firmwareUpdateContext:t.firmwareUpdateContext,customImage:t.customImage,applications:t.installedApps,applicationsUpdates:t.appsUpdates,installedLanguages:t.installedLanguages,catalog:t.catalog}},getFirmwareMetadata:async()=>new k(n).run(),getApplicationsMetadata:async t=>new U(n,{deviceVersion:t.input.deviceVersion,firmware:t.input.firmware,firmwareVersion:t.input.firmwareVersion,installedApps:t.input.installedApps}).run(),listAppsSecureChannel:t=>{const{firmware:s,firmwareVersion:l}=t.input,e=n.getSecureChannelService().listInstalledApps(l.metadata,s);return new R(n,{connection:e}).run()}}}}export{Y as GetDeviceMetadataDeviceAction};
1
+ import{Left as C,Right as x}from"purify-ts";import{assign as r,fromObservable as V,fromPromise as c,setup as G}from"xstate";import{isSuccessCommandResult as f}from"../../../command/model/CommandResult";import{UserInteractionRequired as i}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as I}from"../../../device-action/os/Const";import{GoToDashboardDeviceAction as E}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{ListAppsDeviceAction as F}from"../../../device-action/os/ListApps/ListAppsDeviceAction";import{GetApplicationsMetadataTask as U}from"../../../device-action/task/GetApplicationsMetadataTask";import{GetFirmwareMetadataTask as k}from"../../../device-action/task/GetFirmwareMetadataTask";import{XStateDeviceAction as T}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as o}from"../../../device-session/DeviceSessionState";import{installedAppResultGuard as L}from"../../../secure-channel/device-action/ListInstalledApps/types";import{ConnectToSecureChannelTask as R}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as s}from"../../../secure-channel/task/types";class Y extends T{makeStateMachine(n){const{getDeviceMetadata:u,getFirmwareMetadata:d,getApplicationsMetadata:m,listAppsSecureChannel:g}=this.extractDependencies(n),t=this.input.unlockTimeout??I,l=new E({input:{unlockTimeout:t}}).makeStateMachine(n),p=new F({input:{unlockTimeout:t}}).makeStateMachine(n);return G({types:{input:{unlockTimeout:t},context:{},output:{}},actors:{goToDashboard:l,getDeviceMetadata:c(u),getFirmwareMetadata:c(d),getApplicationsMetadata:c(m),listApps:p,listAppsSecureChannel:V(g)},guards:{hasError:({context:e})=>e._internalState.error!==null,hasMetadata:({context:e})=>e._internalState.firmwareVersion!==null&&e._internalState.firmwareUpdateContext!==null&&e._internalState.customImage!==null&&e._internalState.applications!==null&&e._internalState.applicationsUpdates!==null&&e._internalState.installedLanguages!==null&&e._internalState.catalog!==null,forceUpdate:({context:e})=>!!e.input.forceUpdate,useSecureChannel:({context:e})=>!!e.input.useSecureChannel},actions:{assignErrorFromEvent:r({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetDeviceMetadataDeviceAction",initial:"DeviceReady",context:e=>({input:{useSecureChannel:e.input.useSecureChannel,forceUpdate:e.input.forceUpdate,unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:i.None},_internalState:{error:null,deviceVersion:null,firmware:null,firmwareVersion:null,firmwareUpdateContext:null,customImage:null,installedApps:null,applications:null,applicationsUpdates:null,installedLanguages:null,catalog:null}}),states:{DeviceReady:{always:[{target:"GoToDashboard",guard:"forceUpdate"},{target:"GetDeviceMetadataFromContext"}]},GetDeviceMetadataFromContext:{invoke:{src:"getDeviceMetadata",onDone:{target:"GetDeviceMetadataFromContextResultCheck",actions:r({_internalState:e=>e.event.output===null?e.context._internalState:{...e.context._internalState,firmwareVersion:e.event.output.firmwareVersion,firmwareUpdateContext:e.event.output.firmwareUpdateContext,customImage:e.event.output.customImage,applications:e.event.output.applications,applicationsUpdates:e.event.output.applicationsUpdates,installedLanguages:e.event.output.installedLanguages,catalog:e.event.output.catalog}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceMetadataFromContextResultCheck:{always:[{target:"Success",guard:"hasMetadata"},{target:"GoToDashboard"}]},GoToDashboard:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"dashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"GoToDashboardCheck",actions:r({_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:"GetFirmwareMetadata"}]},GetFirmwareMetadata:{invoke:{src:"getFirmwareMetadata",onDone:{target:"GetFirmwareMetadataResultCheck",actions:r({_internalState:e=>{if(f(e.event.output)){const a=n.getDeviceSessionState();return a.sessionStateType!==o.Connected&&n.setDeviceSessionState({...a,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}),{...e.context._internalState,deviceVersion:e.event.output.data.deviceVersion,firmware:e.event.output.data.firmware,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"useSecureChannel",target:"ListAppsSecureChannel"},{target:"ListApps"}]},ListAppsSecureChannel:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"listAppsSecureChannel",src:"listAppsSecureChannel",input:e=>({firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion}),onSnapshot:{actions:r({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case s.PermissionRequested:return{requiredUserInteraction:i.AllowSecureConnection};case s.PermissionGranted:{const a=n.getDeviceSessionState();return a.sessionStateType!==o.Connected&&n.setDeviceSessionState({...a,isSecureConnectionAllowed:!0}),{requiredUserInteraction:i.None}}default:return{...e.context.intermediateValue}}},_internalState:e=>{if(e.event.snapshot.context?.type===s.Error)return{...e.context._internalState,error:e.event.snapshot.context.error.mapDAErrors()};if(e.event.snapshot.context?.type===s.Result){if(L(e.event.snapshot.context.payload))return{...e.context._internalState,installedApps:e.event.snapshot.context.payload.map(a=>({name:a.name,hash:a.hash,hashCode:a.hash_code_data}))};throw new Error(`Invalid result ${JSON.stringify(e.event.snapshot.context.payload)}`)}return{...e.context._internalState}}})},onDone:{target:"ListAppsCheck"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListApps:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"listApps",src:"listApps",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"ListAppsCheck",actions:r({_internalState:e=>e.event.output.isLeft()?{...e.context._internalState,error:e.event.output.extract()}:{...e.context._internalState,installedApps:e.event.output.unsafeCoerce().map(a=>({name:a.appName,hash:a.appFullHash,hashCode:a.appCodeHash}))}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetApplicationsMetadata"}]},GetApplicationsMetadata:{invoke:{src:"getApplicationsMetadata",input:e=>({deviceVersion:e.context._internalState.deviceVersion,firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion,installedApps:e.context._internalState.installedApps}),onDone:{target:"GetApplicationsMetadataResultCheck",actions:r({_internalState:e=>{if(f(e.event.output)){const a=n.getDeviceSessionState();return a.sessionStateType!==o.Connected&&n.setDeviceSessionState({...a,installedApps:e.event.output.data.applications,appsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}),{...e.context._internalState,applications:e.event.output.data.applications,applicationsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetApplicationsMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:a}=e,{error:v,firmwareVersion:S,firmwareUpdateContext:w,customImage:h,applications:D,applicationsUpdates:M,installedLanguages:y,catalog:A}=a._internalState;return v?C(v):x({firmwareVersion:S,firmwareUpdateContext:w,customImage:h,applications:D,applicationsUpdates:M,installedLanguages:y,catalog:A})}})}extractDependencies(n){return{getDeviceMetadata:async()=>{const t=n.getDeviceSessionState();return t.sessionStateType===o.Connected||t.firmwareVersion?.metadata===void 0||t.firmwareUpdateContext===void 0||t.customImage===void 0||t.installedApps.length===0||t.appsUpdates===void 0||t.installedLanguages===void 0||t.catalog===void 0?null:{firmwareVersion:t.firmwareVersion,firmwareUpdateContext:t.firmwareUpdateContext,customImage:t.customImage,applications:t.installedApps,applicationsUpdates:t.appsUpdates,installedLanguages:t.installedLanguages,catalog:t.catalog}},getFirmwareMetadata:async()=>new k(n).run(),getApplicationsMetadata:async t=>new U(n,{deviceVersion:t.input.deviceVersion,firmware:t.input.firmware,firmwareVersion:t.input.firmwareVersion,installedApps:t.input.installedApps}).run(),listAppsSecureChannel:t=>{const{firmware:l,firmwareVersion:p}=t.input,e=n.getSecureChannelService().listInstalledApps(p.metadata,l);return new R(n,{connection:e}).run()}}}}export{Y as GetDeviceMetadataDeviceAction};
2
2
  //# sourceMappingURL=GetDeviceMetadataDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport {\n GetApplicationsMetadataTask,\n type GetApplicationsMetadataTaskResult,\n type InstalledApp,\n} from \"@api/device-action/task/GetApplicationsMetadataTask\";\nimport {\n GetFirmwareMetadataTask,\n type GetFirmwareMetadataTaskResult,\n} from \"@api/device-action/task/GetFirmwareMetadataTask\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type Catalog,\n type CustomImage,\n DeviceSessionStateType,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport { installedAppResultGuard } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type SecureChannelEvent } from \"@api/secure-channel/task/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport {\n type GetDeviceMetadataDAError,\n type GetDeviceMetadataDAInput,\n type GetDeviceMetadataDAIntermediateValue,\n type GetDeviceMetadataDAOutput,\n} from \"./types\";\n\ntype GetDeviceMetadataMachineInternalState = {\n readonly error: GetDeviceMetadataDAError | null;\n readonly deviceVersion: DeviceVersion | null;\n readonly firmware: FinalFirmware | null;\n readonly firmwareVersion: FirmwareVersion | null;\n readonly firmwareUpdateContext: FirmwareUpdateContext | null;\n readonly customImage: CustomImage | null;\n readonly installedApps: InstalledApp[] | null;\n readonly applications: Application[] | null;\n readonly applicationsUpdates: Application[] | null;\n readonly installedLanguages: InstalledLanguagePackage[] | null;\n readonly catalog: Catalog | null;\n};\n\nexport type GetDeviceMetadataFromContextTaskResult = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly customImage: CustomImage;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n} | null;\n\nexport type MachineDependencies = {\n readonly getDeviceMetadata: () => Promise<GetDeviceMetadataFromContextTaskResult>;\n readonly getFirmwareMetadata: () => Promise<GetFirmwareMetadataTaskResult>;\n readonly getApplicationsMetadata: (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) => Promise<GetApplicationsMetadataTaskResult>;\n readonly listAppsSecureChannel: (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => Observable<SecureChannelEvent>;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceMetadataDeviceAction extends XStateDeviceAction<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n >;\n\n const {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n const listAppsMachine = new ListAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n goToDashboard: goToDashboardMachine,\n getDeviceMetadata: fromPromise(getDeviceMetadata),\n getFirmwareMetadata: fromPromise(getFirmwareMetadata),\n getApplicationsMetadata: fromPromise(getApplicationsMetadata),\n listApps: listAppsMachine,\n listAppsSecureChannel: fromObservable(listAppsSecureChannel),\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n hasMetadata: ({ context }) =>\n context._internalState.firmwareVersion !== null &&\n context._internalState.firmwareUpdateContext !== null &&\n context._internalState.customImage !== null &&\n context._internalState.applications !== null &&\n context._internalState.applicationsUpdates !== null &&\n context._internalState.installedLanguages !== null &&\n context._internalState.catalog !== null,\n forceUpdate: ({ context }) => Boolean(context.input.forceUpdate),\n useSecureChannel: ({ context }) =>\n Boolean(context.input.useSecureChannel),\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"GetDeviceMetadataDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n useSecureChannel: _.input.useSecureChannel,\n forceUpdate: _.input.forceUpdate,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n deviceVersion: null,\n firmware: null,\n firmwareVersion: null,\n firmwareUpdateContext: null,\n customImage: null,\n installedApps: null,\n applications: null,\n applicationsUpdates: null,\n installedLanguages: null,\n catalog: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"GoToDashboard\",\n guard: \"forceUpdate\",\n },\n {\n target: \"GetDeviceMetadataFromContext\",\n },\n ],\n },\n GetDeviceMetadataFromContext: {\n invoke: {\n src: \"getDeviceMetadata\",\n onDone: {\n target: \"GetDeviceMetadataFromContextResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output === null) {\n return _.context._internalState;\n } else {\n return {\n ..._.context._internalState,\n firmwareVersion: _.event.output.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.firmwareUpdateContext,\n customImage: _.event.output.customImage,\n applications: _.event.output.applications,\n applicationsUpdates: _.event.output.applicationsUpdates,\n installedLanguages: _.event.output.installedLanguages,\n catalog: _.event.output.catalog,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceMetadataFromContextResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"hasMetadata\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"dashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GoToDashboardCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetFirmwareMetadata\",\n },\n ],\n },\n GetFirmwareMetadata: {\n invoke: {\n src: \"getFirmwareMetadata\",\n onDone: {\n target: \"GetFirmwareMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n });\n }\n return {\n ..._.context._internalState,\n deviceVersion: _.event.output.data.deviceVersion,\n firmware: _.event.output.data.firmware,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetFirmwareMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n guard: \"useSecureChannel\",\n target: \"ListAppsSecureChannel\",\n },\n {\n target: \"ListApps\",\n },\n ],\n },\n ListAppsSecureChannel: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listAppsSecureChannel\",\n src: \"listAppsSecureChannel\",\n input: (_) => ({\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n switch (_.event.snapshot.context?.type) {\n case SecureChannelEventType.PermissionRequested: {\n return {\n requiredUserInteraction:\n UserInteractionRequired.AllowSecureConnection,\n };\n }\n case SecureChannelEventType.PermissionGranted: {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n isSecureConnectionAllowed: true,\n });\n }\n return {\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n default:\n return {\n ..._.context.intermediateValue,\n };\n }\n },\n _internalState: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Result\n ) {\n if (\n installedAppResultGuard(_.event.snapshot.context.payload)\n ) {\n return {\n ..._.context._internalState,\n installedApps: _.event.snapshot.context.payload.map(\n (app) => ({\n name: app.name,\n hash: app.hash,\n hashCode: app.hash_code_data,\n }),\n ),\n };\n }\n throw new Error(\n `Invalid result ${JSON.stringify(_.event.snapshot.context.payload)}`,\n );\n }\n return { ..._.context._internalState };\n },\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListApps: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listApps\",\n src: \"listApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output.isLeft()) {\n return {\n ..._.context._internalState,\n error: _.event.output.extract(),\n };\n } else {\n return {\n ..._.context._internalState,\n installedApps: _.event.output\n .unsafeCoerce()\n .map((app) => ({\n name: app.appName,\n hash: app.appFullHash,\n hashCode: app.appCodeHash,\n })),\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetApplicationsMetadata\",\n },\n ],\n },\n GetApplicationsMetadata: {\n invoke: {\n src: \"getApplicationsMetadata\",\n input: (_) => ({\n deviceVersion: _.context._internalState.deviceVersion!,\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n installedApps: _.context._internalState.installedApps!,\n }),\n onDone: {\n target: \"GetApplicationsMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n installedApps: _.event.output.data.applications,\n appsUpdates: _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n });\n }\n return {\n ..._.context._internalState,\n applications: _.event.output.data.applications,\n applicationsUpdates:\n _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetApplicationsMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n const { context } = args;\n const {\n error,\n firmwareVersion,\n firmwareUpdateContext,\n customImage,\n applications,\n applicationsUpdates,\n installedLanguages,\n catalog,\n } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right({\n firmwareVersion: firmwareVersion!,\n firmwareUpdateContext: firmwareUpdateContext!,\n customImage: customImage!,\n applications: applications!,\n applicationsUpdates: applicationsUpdates!,\n installedLanguages: installedLanguages!,\n catalog: catalog!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getDeviceMetadata = async () => {\n const deviceState = internalApi.getDeviceSessionState();\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n return null;\n }\n if (\n deviceState.firmwareVersion?.metadata === undefined ||\n deviceState.firmwareUpdateContext === undefined ||\n deviceState.customImage === undefined ||\n deviceState.installedApps.length === 0 ||\n deviceState.appsUpdates === undefined ||\n deviceState.installedLanguages === undefined ||\n deviceState.catalog === undefined\n ) {\n return null;\n }\n return {\n firmwareVersion: deviceState.firmwareVersion,\n firmwareUpdateContext: deviceState.firmwareUpdateContext,\n customImage: deviceState.customImage,\n applications: deviceState.installedApps,\n applicationsUpdates: deviceState.appsUpdates,\n installedLanguages: deviceState.installedLanguages,\n catalog: deviceState.catalog,\n };\n };\n\n const getFirmwareMetadata = async () =>\n new GetFirmwareMetadataTask(internalApi).run();\n\n const getApplicationsMetadata = async (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) =>\n new GetApplicationsMetadataTask(internalApi, {\n deviceVersion: arg0.input.deviceVersion,\n firmware: arg0.input.firmware,\n firmwareVersion: arg0.input.firmwareVersion,\n installedApps: arg0.input.installedApps,\n }).run();\n\n const listAppsSecureChannel = (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => {\n const { firmware, firmwareVersion } = arg0.input;\n const connection = internalApi\n .getSecureChannelService()\n .listInstalledApps(firmwareVersion.metadata!, firmware);\n return new ConnectToSecureChannelTask(internalApi, {\n connection,\n }).run();\n };\n\n return {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n };\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA8B,mCAEvC,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAA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,SAAY,CACpC,MAAMW,EAAcX,EAAY,sBAAsB,EAItD,OAHIW,EAAY,mBAAqBhB,EAAuB,WAI1DgB,EAAY,iBAAiB,WAAa,QAC1CA,EAAY,wBAA0B,QACtCA,EAAY,cAAgB,QAC5BA,EAAY,cAAc,SAAW,GACrCA,EAAY,cAAgB,QAC5BA,EAAY,qBAAuB,QACnCA,EAAY,UAAY,OAEjB,KAEF,CACL,gBAAiBA,EAAY,gBAC7B,sBAAuBA,EAAY,sBACnC,YAAaA,EAAY,YACzB,aAAcA,EAAY,cAC1B,oBAAqBA,EAAY,YACjC,mBAAoBA,EAAY,mBAChC,QAASA,EAAY,OACvB,CACF,EAqCE,oBAnC0B,SAC1B,IAAIlB,EAAwBO,CAAW,EAAE,IAAI,EAmC7C,wBAjC8B,MAAOqB,GAQrC,IAAI7B,EAA4BQ,EAAa,CAC3C,cAAeqB,EAAK,MAAM,cAC1B,SAAUA,EAAK,MAAM,SACrB,gBAAiBA,EAAK,MAAM,gBAC5B,cAAeA,EAAK,MAAM,aAC5B,CAAC,EAAE,IAAI,EAqBP,sBAnB6BA,GAKzB,CACJ,KAAM,CAAE,SAAAC,EAAU,gBAAAR,CAAgB,EAAIO,EAAK,MACrCE,EAAavB,EAChB,wBAAwB,EACxB,kBAAkBc,EAAgB,SAAWQ,CAAQ,EACxD,OAAO,IAAIzB,EAA2BG,EAAa,CACjD,WAAAuB,CACF,CAAC,EAAE,IAAI,CACT,CAOA,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nimport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nimport {\n GetApplicationsMetadataTask,\n type GetApplicationsMetadataTaskResult,\n type InstalledApp,\n} from \"@api/device-action/task/GetApplicationsMetadataTask\";\nimport {\n GetFirmwareMetadataTask,\n type GetFirmwareMetadataTaskResult,\n} from \"@api/device-action/task/GetFirmwareMetadataTask\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type Catalog,\n type CustomImage,\n DeviceSessionStateType,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n type InstalledLanguagePackage,\n} from \"@api/device-session/DeviceSessionState\";\nimport { installedAppResultGuard } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nimport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nimport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nimport { type SecureChannelEvent } from \"@api/secure-channel/task/types\";\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport {\n type GetDeviceMetadataDAError,\n type GetDeviceMetadataDAInput,\n type GetDeviceMetadataDAIntermediateValue,\n type GetDeviceMetadataDAOutput,\n} from \"./types\";\n\ntype GetDeviceMetadataMachineInternalState = {\n readonly error: GetDeviceMetadataDAError | null;\n readonly deviceVersion: DeviceVersion | null;\n readonly firmware: FinalFirmware | null;\n readonly firmwareVersion: FirmwareVersion | null;\n readonly firmwareUpdateContext: FirmwareUpdateContext | null;\n readonly customImage: CustomImage | null;\n readonly installedApps: InstalledApp[] | null;\n readonly applications: Application[] | null;\n readonly applicationsUpdates: Application[] | null;\n readonly installedLanguages: InstalledLanguagePackage[] | null;\n readonly catalog: Catalog | null;\n};\n\nexport type GetDeviceMetadataFromContextTaskResult = {\n readonly firmwareVersion: FirmwareVersion;\n readonly firmwareUpdateContext: FirmwareUpdateContext;\n readonly customImage: CustomImage;\n readonly applications: Application[];\n readonly applicationsUpdates: Application[];\n readonly installedLanguages: InstalledLanguagePackage[];\n readonly catalog: Catalog;\n} | null;\n\nexport type MachineDependencies = {\n readonly getDeviceMetadata: () => Promise<GetDeviceMetadataFromContextTaskResult>;\n readonly getFirmwareMetadata: () => Promise<GetFirmwareMetadataTaskResult>;\n readonly getApplicationsMetadata: (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) => Promise<GetApplicationsMetadataTaskResult>;\n readonly listAppsSecureChannel: (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => Observable<SecureChannelEvent>;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceMetadataDeviceAction extends XStateDeviceAction<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDAInput,\n GetDeviceMetadataDAError,\n GetDeviceMetadataDAIntermediateValue,\n GetDeviceMetadataMachineInternalState\n >;\n\n const {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const goToDashboardMachine = new GoToDashboardDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n const listAppsMachine = new ListAppsDeviceAction({\n input: {\n unlockTimeout,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n goToDashboard: goToDashboardMachine,\n getDeviceMetadata: fromPromise(getDeviceMetadata),\n getFirmwareMetadata: fromPromise(getFirmwareMetadata),\n getApplicationsMetadata: fromPromise(getApplicationsMetadata),\n listApps: listAppsMachine,\n listAppsSecureChannel: fromObservable(listAppsSecureChannel),\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n hasMetadata: ({ context }) =>\n context._internalState.firmwareVersion !== null &&\n context._internalState.firmwareUpdateContext !== null &&\n context._internalState.customImage !== null &&\n context._internalState.applications !== null &&\n context._internalState.applicationsUpdates !== null &&\n context._internalState.installedLanguages !== null &&\n context._internalState.catalog !== null,\n forceUpdate: ({ context }) => Boolean(context.input.forceUpdate),\n useSecureChannel: ({ context }) =>\n Boolean(context.input.useSecureChannel),\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"GetDeviceMetadataDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n useSecureChannel: _.input.useSecureChannel,\n forceUpdate: _.input.forceUpdate,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n error: null,\n deviceVersion: null,\n firmware: null,\n firmwareVersion: null,\n firmwareUpdateContext: null,\n customImage: null,\n installedApps: null,\n applications: null,\n applicationsUpdates: null,\n installedLanguages: null,\n catalog: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"GoToDashboard\",\n guard: \"forceUpdate\",\n },\n {\n target: \"GetDeviceMetadataFromContext\",\n },\n ],\n },\n GetDeviceMetadataFromContext: {\n invoke: {\n src: \"getDeviceMetadata\",\n onDone: {\n target: \"GetDeviceMetadataFromContextResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output === null) {\n return _.context._internalState;\n } else {\n return {\n ..._.context._internalState,\n firmwareVersion: _.event.output.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.firmwareUpdateContext,\n customImage: _.event.output.customImage,\n applications: _.event.output.applications,\n applicationsUpdates: _.event.output.applicationsUpdates,\n installedLanguages: _.event.output.installedLanguages,\n catalog: _.event.output.catalog,\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceMetadataFromContextResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"hasMetadata\",\n },\n {\n target: \"GoToDashboard\",\n },\n ],\n },\n GoToDashboard: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"dashboard\",\n src: \"goToDashboard\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"GoToDashboardCheck\",\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GoToDashboardCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetFirmwareMetadata\",\n },\n ],\n },\n GetFirmwareMetadata: {\n invoke: {\n src: \"getFirmwareMetadata\",\n onDone: {\n target: \"GetFirmwareMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n });\n }\n return {\n ..._.context._internalState,\n deviceVersion: _.event.output.data.deviceVersion,\n firmware: _.event.output.data.firmware,\n firmwareVersion: _.event.output.data.firmwareVersion,\n firmwareUpdateContext:\n _.event.output.data.firmwareUpdateContext,\n customImage: _.event.output.data.customImage,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetFirmwareMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n guard: \"useSecureChannel\",\n target: \"ListAppsSecureChannel\",\n },\n {\n target: \"ListApps\",\n },\n ],\n },\n ListAppsSecureChannel: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listAppsSecureChannel\",\n src: \"listAppsSecureChannel\",\n input: (_) => ({\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => {\n switch (_.event.snapshot.context?.type) {\n case SecureChannelEventType.PermissionRequested: {\n return {\n requiredUserInteraction:\n UserInteractionRequired.AllowSecureConnection,\n };\n }\n case SecureChannelEventType.PermissionGranted: {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n isSecureConnectionAllowed: true,\n });\n }\n return {\n requiredUserInteraction: UserInteractionRequired.None,\n };\n }\n default:\n return {\n ..._.context.intermediateValue,\n };\n }\n },\n _internalState: (_) => {\n if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Error\n ) {\n return {\n ..._.context._internalState,\n error: _.event.snapshot.context.error.mapDAErrors(),\n };\n } else if (\n _.event.snapshot.context?.type ===\n SecureChannelEventType.Result\n ) {\n if (\n installedAppResultGuard(_.event.snapshot.context.payload)\n ) {\n return {\n ..._.context._internalState,\n installedApps: _.event.snapshot.context.payload.map(\n (app) => ({\n name: app.name,\n hash: app.hash,\n hashCode: app.hash_code_data,\n }),\n ),\n };\n }\n throw new Error(\n `Invalid result ${JSON.stringify(_.event.snapshot.context.payload)}`,\n );\n }\n return { ..._.context._internalState };\n },\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListApps: {\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"listApps\",\n src: \"listApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"ListAppsCheck\",\n actions: assign({\n _internalState: (_) => {\n if (_.event.output.isLeft()) {\n return {\n ..._.context._internalState,\n error: _.event.output.extract(),\n };\n } else {\n return {\n ..._.context._internalState,\n installedApps: _.event.output\n .unsafeCoerce()\n .map((app) => ({\n name: app.appName,\n hash: app.appFullHash,\n hashCode: app.appCodeHash,\n })),\n };\n }\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ListAppsCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"GetApplicationsMetadata\",\n },\n ],\n },\n GetApplicationsMetadata: {\n invoke: {\n src: \"getApplicationsMetadata\",\n input: (_) => ({\n deviceVersion: _.context._internalState.deviceVersion!,\n firmware: _.context._internalState.firmware!,\n firmwareVersion: _.context._internalState.firmwareVersion!,\n installedApps: _.context._internalState.installedApps!,\n }),\n onDone: {\n target: \"GetApplicationsMetadataResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const deviceState = internalApi.getDeviceSessionState();\n if (\n deviceState.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n internalApi.setDeviceSessionState({\n ...deviceState,\n installedApps: _.event.output.data.applications,\n appsUpdates: _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n });\n }\n return {\n ..._.context._internalState,\n applications: _.event.output.data.applications,\n applicationsUpdates:\n _.event.output.data.applicationsUpdates,\n installedLanguages:\n _.event.output.data.installedLanguages,\n catalog: _.event.output.data.catalog,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetApplicationsMetadataResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n const { context } = args;\n const {\n error,\n firmwareVersion,\n firmwareUpdateContext,\n customImage,\n applications,\n applicationsUpdates,\n installedLanguages,\n catalog,\n } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right({\n firmwareVersion: firmwareVersion!,\n firmwareUpdateContext: firmwareUpdateContext!,\n customImage: customImage!,\n applications: applications!,\n applicationsUpdates: applicationsUpdates!,\n installedLanguages: installedLanguages!,\n catalog: catalog!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getDeviceMetadata = async () => {\n const deviceState = internalApi.getDeviceSessionState();\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n return null;\n }\n if (\n deviceState.firmwareVersion?.metadata === undefined ||\n deviceState.firmwareUpdateContext === undefined ||\n deviceState.customImage === undefined ||\n deviceState.installedApps.length === 0 ||\n deviceState.appsUpdates === undefined ||\n deviceState.installedLanguages === undefined ||\n deviceState.catalog === undefined\n ) {\n return null;\n }\n return {\n firmwareVersion: deviceState.firmwareVersion,\n firmwareUpdateContext: deviceState.firmwareUpdateContext,\n customImage: deviceState.customImage,\n applications: deviceState.installedApps,\n applicationsUpdates: deviceState.appsUpdates,\n installedLanguages: deviceState.installedLanguages,\n catalog: deviceState.catalog,\n };\n };\n\n const getFirmwareMetadata = async () =>\n new GetFirmwareMetadataTask(internalApi).run();\n\n const getApplicationsMetadata = async (arg0: {\n input: {\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n installedApps: InstalledApp[];\n };\n }) =>\n new GetApplicationsMetadataTask(internalApi, {\n deviceVersion: arg0.input.deviceVersion,\n firmware: arg0.input.firmware,\n firmwareVersion: arg0.input.firmwareVersion,\n installedApps: arg0.input.installedApps,\n }).run();\n\n const listAppsSecureChannel = (arg0: {\n input: {\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n };\n }) => {\n const { firmware, firmwareVersion } = arg0.input;\n const connection = internalApi\n .getSecureChannelService()\n .listInstalledApps(firmwareVersion.metadata!, firmware);\n return new ConnectToSecureChannelTask(internalApi, {\n connection,\n }).run();\n };\n\n return {\n getDeviceMetadata,\n getFirmwareMetadata,\n getApplicationsMetadata,\n listAppsSecureChannel,\n };\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA8B,mCAEvC,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,6BAAAC,MAAiC,gEAC1C,OAAS,wBAAAC,MAA4B,sDACrC,OACE,+BAAAC,MAGK,sDACP,OACE,2BAAAC,MAEK,k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AAoBpB,EAA+C,CA6DjE,MAAO,CACL,kBA7DwB,SAAY,CACpC,MAAMW,EAAcX,EAAY,sBAAsB,EAItD,OAHIW,EAAY,mBAAqBhB,EAAuB,WAI1DgB,EAAY,iBAAiB,WAAa,QAC1CA,EAAY,wBAA0B,QACtCA,EAAY,cAAgB,QAC5BA,EAAY,cAAc,SAAW,GACrCA,EAAY,cAAgB,QAC5BA,EAAY,qBAAuB,QACnCA,EAAY,UAAY,OAEjB,KAEF,CACL,gBAAiBA,EAAY,gBAC7B,sBAAuBA,EAAY,sBACnC,YAAaA,EAAY,YACzB,aAAcA,EAAY,cAC1B,oBAAqBA,EAAY,YACjC,mBAAoBA,EAAY,mBAChC,QAASA,EAAY,OACvB,CACF,EAqCE,oBAnC0B,SAC1B,IAAIlB,EAAwBO,CAAW,EAAE,IAAI,EAmC7C,wBAjC8B,MAAOqB,GAQrC,IAAI7B,EAA4BQ,EAAa,CAC3C,cAAeqB,EAAK,MAAM,cAC1B,SAAUA,EAAK,MAAM,SACrB,gBAAiBA,EAAK,MAAM,gBAC5B,cAAeA,EAAK,MAAM,aAC5B,CAAC,EAAE,IAAI,EAqBP,sBAnB6BA,GAKzB,CACJ,KAAM,CAAE,SAAAC,EAAU,gBAAAR,CAAgB,EAAIO,EAAK,MACrCE,EAAavB,EAChB,wBAAwB,EACxB,kBAAkBc,EAAgB,SAAWQ,CAAQ,EACxD,OAAO,IAAIzB,EAA2BG,EAAa,CACjD,WAAAuB,CACF,CAAC,EAAE,IAAI,CACT,CAOA,CACF,CACF",
6
6
  "names": ["Left", "Right", "assign", "fromObservable", "fromPromise", "setup", "isSuccessCommandResult", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "GoToDashboardDeviceAction", "ListAppsDeviceAction", "GetApplicationsMetadataTask", "GetFirmwareMetadataTask", "XStateDeviceAction", "DeviceSessionStateType", "installedAppResultGuard", "ConnectToSecureChannelTask", "SecureChannelEventType", "GetDeviceMetadataDeviceAction", "internalApi", "getDeviceMetadata", "getFirmwareMetadata", "getApplicationsMetadata", "listAppsSecureChannel", "unlockTimeout", "goToDashboardMachine", "listAppsMachine", "context", "_", "error", "deviceState", "app", "args", "firmwareVersion", "firmwareUpdateContext", "customImage", "applications", "applicationsUpdates", "installedLanguages", "catalog", "arg0", "firmware", "connection"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as A,Right as m}from"purify-ts";import{Observable as y}from"rxjs";import{tap as g,timeout as k}from"rxjs/operators";import{assign as n,fromObservable as b,fromPromise as f,setup as E}from"xstate";import{isSuccessCommandResult as h}from"../../../command/model/CommandResult";import{GetAppAndVersionCommand as V}from"../../../command/os/GetAppAndVersionCommand";import{DeviceStatus as D}from"../../../device/DeviceStatus";import{UserInteractionRequired as c}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as U}from"../../../device-action/os/Const";import{DeviceLockedError as G,DeviceNotOnboardedError as x}from"../../../device-action/os/Errors";import{XStateDeviceAction as I}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as l}from"../../../device-session/DeviceSessionState";class K extends I{makeStateMachine(r){const{getAppAndVersion:d,getDeviceSessionState:u,setDeviceSessionState:i,waitForDeviceUnlock:p,isDeviceOnboarded:o}=this.extractDependencies(r),a=this.input.unlockTimeout??U;return E({types:{input:{unlockTimeout:a},context:{},output:{}},actors:{getAppAndVersion:f(d),waitForDeviceUnlock:b(p)},guards:{isDeviceOnboarded:()=>o(),isDeviceLocked:({context:e})=>e._internalState.locked,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:n({_internalState:e=>({...e.context._internalState,error:new x})}),assignErrorDeviceLocked:n({_internalState:e=>({...e.context._internalState,error:new G}),intermediateValue:{requiredUserInteraction:c.UnlockDevice}}),assignErrorFromEvent:n({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:n({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.None})}),assignUserActionUnlockNeeded:n({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const t=u(),{sessionStateType:s}=t;return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:c.None},_internalState:{onboarded:!1,locked:!1,currentApp:s===l.ReadyWithoutSecureChannel?t.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"AppAndVersionCheck",actions:n({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:a}),onDone:{target:"AppAndVersionCheck",actions:n({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:n({_internalState:e=>{if(h(e.event.output)){const t=u();return t.sessionStateType!==l.Connected?i({...t,currentApp:e.event.output.data}):i({deviceModelId:t.deviceModelId,sessionStateType:l.ReadyWithoutSecureChannel,deviceStatus:D.CONNECTED,currentApp:e.event.output.data,installedApps:[],isSecureConnectionAllowed:!1}),{...e.context._internalState,locked:!1,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}return"errorCode"in e.event.output.error&&e.event.output.error.errorCode==="5515"?{...e.context._internalState,locked:!0}:{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:t}=e,{error:s,currentApp:v,currentAppVersion:S}=t._internalState;return s?A(s):m({currentApp:v,currentAppVersion:S})}})}extractDependencies(r){return{getAppAndVersion:()=>r.sendCommand(new V),waitForDeviceUnlock:({input:i})=>new y(p=>{const o=r.getDeviceSessionStateObservable().pipe(g(a=>{a.deviceStatus===D.CONNECTED&&(p.complete(),o.unsubscribe())})).subscribe();return()=>{o.unsubscribe()}}).pipe(k(i.unlockTimeout)),getDeviceSessionState:()=>r.getDeviceSessionState(),setDeviceSessionState:i=>r.setDeviceSessionState(i),isDeviceOnboarded:()=>!0}}}export{K as GetDeviceStatusDeviceAction};
1
+ import{Left as A,Right as m}from"purify-ts";import{Observable as y}from"rxjs";import{tap as g,timeout as k}from"rxjs/operators";import{assign as n,fromObservable as f,fromPromise as b,setup as E}from"xstate";import{isSuccessCommandResult as h}from"../../../command/model/CommandResult";import{GetAppAndVersionCommand as V}from"../../../command/os/GetAppAndVersionCommand";import{DeviceStatus as D}from"../../../device/DeviceStatus";import{UserInteractionRequired as c}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as U}from"../../../device-action/os/Const";import{DeviceLockedError as G,DeviceNotOnboardedError as x}from"../../../device-action/os/Errors";import{XStateDeviceAction as O}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as l}from"../../../device-session/DeviceSessionState";class B extends O{makeStateMachine(r){const{getAppAndVersion:d,getDeviceSessionState:u,setDeviceSessionState:i,waitForDeviceUnlock:p,isDeviceOnboarded:o}=this.extractDependencies(r),a=this.input.unlockTimeout??U;return E({types:{input:{unlockTimeout:a},context:{},output:{}},actors:{getAppAndVersion:b(d),waitForDeviceUnlock:f(p)},guards:{isDeviceOnboarded:()=>o(),isDeviceLocked:({context:e})=>e._internalState.locked,hasError:({context:e})=>e._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:n({_internalState:e=>({...e.context._internalState,error:new x})}),assignErrorDeviceLocked:n({_internalState:e=>({...e.context._internalState,error:new G}),intermediateValue:{requiredUserInteraction:c.UnlockDevice}}),assignErrorFromEvent:n({_internalState:e=>({...e.context._internalState,error:e.event.error})}),assignNoUserActionNeeded:n({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.None})}),assignUserActionUnlockNeeded:n({intermediateValue:e=>({...e.context.intermediateValue,requiredUserInteraction:c.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:e=>{const t=u(),{sessionStateType:s}=t;return{input:{unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:c.None},_internalState:{onboarded:!1,locked:!1,currentApp:s===l.ReadyWithoutSecureChannel?t.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"AppAndVersionCheck",actions:n({_internalState:e=>({...e.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:e=>({unlockTimeout:a}),onDone:{target:"AppAndVersionCheck",actions:n({_internalState:e=>({...e.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:n({_internalState:e=>{if(h(e.event.output)){const t=u();return t.sessionStateType!==l.Connected?i({...t,currentApp:e.event.output.data}):i({deviceModelId:t.deviceModelId,sessionStateType:l.ReadyWithoutSecureChannel,deviceStatus:D.CONNECTED,currentApp:e.event.output.data,installedApps:[],isSecureConnectionAllowed:!1}),{...e.context._internalState,locked:!1,currentApp:e.event.output.data.name,currentAppVersion:e.event.output.data.version}}if("errorCode"in e.event.output.error){if(e.event.output.error.errorCode==="5515")return{...e.context._internalState,locked:!0};if(e.event.output.error.errorCode==="6e00")return{...e.context._internalState,locked:!1,currentApp:"BOLOS",currentAppVersion:"0.0.0"}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:t}=e,{error:s,currentApp:S,currentAppVersion:v}=t._internalState;return s?A(s):m({currentApp:S,currentAppVersion:v})}})}extractDependencies(r){return{getAppAndVersion:()=>r.sendCommand(new V),waitForDeviceUnlock:({input:i})=>new y(p=>{const o=r.getDeviceSessionStateObservable().pipe(g(a=>{a.deviceStatus===D.CONNECTED&&(p.complete(),o.unsubscribe())})).subscribe();return()=>{o.unsubscribe()}}).pipe(k(i.unlockTimeout)),getDeviceSessionState:()=>r.getDeviceSessionState(),setDeviceSessionState:i=>r.setDeviceSessionState(i),isDeviceOnboarded:()=>!0}}}export{B as GetDeviceStatusDeviceAction};
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\nimport { tap, timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n isDeviceOnboarded,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isDeviceLocked: ({ context }) => context._internalState.locked,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI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YIKY3a2NvnxsrVITCrE8RoMdDucxWgx1jpZCELDHDgKTC9jg6mNXKLDSHPcbV3O7LG3bNH2SYioLB3EmCI1-HuVL6Cj4hU6eNjsIVD3UrWfKXVCj5cV5Wvtr5n6CShaFE-1JMkWzPgXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n onboarded: false, // we don't know how to check yet\n locked: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"OnboardingCheck\",\n },\n },\n OnboardingCheck: {\n // TODO: we don't have this info for now\n always: [\n {\n guard: {\n type: \"isDeviceOnboarded\",\n },\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion command\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n // Update the current app\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n } else {\n // The device can be set to Ready if GetAppAndVersionCommand was successful\n setDeviceSessionState({\n deviceModelId: state.deviceModelId,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: _.event.output.data,\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n }\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n if (\n \"errorCode\" in _.event.output.error &&\n _.event.output.error.errorCode === \"5515\"\n ) {\n return {\n ..._.context._internalState,\n locked: true,\n };\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"UserActionUnlockDevice\",\n guard: \"isDeviceLocked\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n new Observable<void>((subscriber) => {\n const inner = internalApi\n .getDeviceSessionStateObservable()\n .pipe(\n tap((state) => {\n if (state.deviceStatus === DeviceStatus.CONNECTED) {\n subscriber.complete();\n inner.unsubscribe();\n }\n }),\n )\n .subscribe();\n\n return () => {\n inner.unsubscribe();\n };\n }).pipe(timeout(input.unlockTimeout));\n\n return {\n getAppAndVersion,\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now\n };\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,cAAAC,MAAkB,OAC3B,OAAS,OAAAC,EAAK,WAAAC,MAAe,iBAC7B,OAAS,UAAAC,EAAQ,kBAAAC,EAAgB,eAAAC,EAAa,SAAAC,MAAa,SAE3D,OAAS,0BAAAC,MAA8B,mCACvC,OACE,2BAAAC,MAEK,0CACP,OAAS,gBAAAC,MAAoB,2BAE7B,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OACE,qBAAAC,EACA,2BAAAC,MACK,+BAEP,OAEE,sBAAAC,MACK,qDACP,OAEE,0BAAAC,MACK,yCAiCA,MAAMC,UAAoCF,CAM/C,CACA,iBACEG,EAOA,CASA,KAAM,CACJ,iBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,kBAAAC,CACF,EAAI,KAAK,oBAAoBL,CAAW,EAElCM,EAAgB,KAAK,MAAM,eAAiBZ,EAElD,OAAOL,EAAM,CACX,MAAO,CACL,MAAO,CACL,cAAAiB,CACF,EACA,QAAS,CAA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OAAQ,EACV,EAEK,CACL,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,OAAO,KACxB,CACF,CACF,CAAC,CACH,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,gCAAiC,CAC/B,OAAQ,CACN,CACE,MAAO,WACP,OAAQ,OACV,EACA,CACE,OAAQ,yBACR,MAAO,gBACT,EACA,CACE,OAAQ,SACV,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASI,GAAS,CAEhB,KAAM,CAAE,QAAAL,CAAQ,EAAIK,EACd,CAAE,MAAAC,EAAO,WAAAC,EAAY,kBAAAC,CAAkB,EAAIR,EAAQ,eACzD,OAAIM,EACKhC,EAAKgC,CAAK,EAEZ/B,EAA+B,CACpC,WAAYgC,EACZ,kBAAmBC,CACrB,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBf,EAA+C,CA4BjE,MAAO,CACL,iBA5BuB,IAChBA,EAAY,YAAY,IAAIT,CAAyB,EA4B5D,oBAzB0B,CAAC,CAC3B,MAAAyB,CACF,IAGE,IAAIjC,EAAkBkC,GAAe,CACnC,MAAMC,EAAQlB,EACX,gCAAgC,EAChC,KACChB,EAAK2B,GAAU,CACTA,EAAM,eAAiBnB,EAAa,YACtCyB,EAAW,SAAS,EACpBC,EAAM,YAAY,EAEtB,CAAC,CACH,EACC,UAAU,EAEb,MAAO,IAAM,CACXA,EAAM,YAAY,CACpB,CACF,CAAC,EAAE,KAAKjC,EAAQ+B,EAAM,aAAa,CAAC,EAKpC,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\nimport { tap, timeout } from \"rxjs/operators\";\nimport { assign, fromObservable, fromPromise, setup } from \"xstate\";\n\nimport { isSuccessCommandResult } from \"@api/command/model/CommandResult\";\nimport {\n GetAppAndVersionCommand,\n type GetAppAndVersionCommandResult,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport {\n DeviceLockedError,\n DeviceNotOnboardedError,\n} from \"@api/device-action/os/Errors\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\n\nimport {\n type GetDeviceStatusDAError,\n type GetDeviceStatusDAInput,\n type GetDeviceStatusDAIntermediateValue,\n type GetDeviceStatusDAOutput,\n} from \"./types\";\n\ntype GetDeviceStatusMachineInternalState = {\n readonly onboarded: boolean;\n readonly locked: boolean;\n readonly currentApp: string | null;\n readonly currentAppVersion: string | null;\n readonly error: GetDeviceStatusDAError | null;\n};\n\nexport type MachineDependencies = {\n readonly getAppAndVersion: () => Promise<GetAppAndVersionCommandResult>;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly waitForDeviceUnlock: (args: {\n input: { unlockTimeout: number };\n }) => Observable<void>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly isDeviceOnboarded: () => boolean;\n};\n\nexport type ExtractMachineDependencies = (\n internalApi: InternalApi,\n) => MachineDependencies;\n\nexport class GetDeviceStatusDeviceAction extends XStateDeviceAction<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n > {\n type types = StateMachineTypes<\n GetDeviceStatusDAOutput,\n GetDeviceStatusDAInput,\n GetDeviceStatusDAError,\n GetDeviceStatusDAIntermediateValue,\n GetDeviceStatusMachineInternalState\n >;\n\n const {\n getAppAndVersion,\n getDeviceSessionState,\n setDeviceSessionState,\n waitForDeviceUnlock,\n isDeviceOnboarded,\n } = this.extractDependencies(internalApi);\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getAppAndVersion: fromPromise(getAppAndVersion),\n waitForDeviceUnlock: fromObservable(waitForDeviceUnlock),\n },\n guards: {\n isDeviceOnboarded: () => isDeviceOnboarded(), // TODO: we don't have this info for now, this can be derived from the \"flags\" obtained in the getVersion command\n isDeviceLocked: ({ context }) => context._internalState.locked,\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorDeviceNotOnboarded: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceNotOnboardedError(),\n }),\n }),\n assignErrorDeviceLocked: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new DeviceLockedError(),\n }),\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n },\n }),\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n assignNoUserActionNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n assignUserActionUnlockNeeded: assign({\n intermediateValue: (_) =>\n ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.UnlockDevice,\n }) satisfies types[\"context\"][\"intermediateValue\"],\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QHEwBcAiYBuBLAxmAMpoCGaArrFnoQIL5q4D2AdgHQ0FgBKYpEAJ4BiANoAGALqJQAB2axcTNjJAAPRAFoArAHZx7AIwAmQ7oCcugMyHzANmMAWYwBoQgxI8vsAHOJM+VuLmVj5e2gC+EW6omDjcJORUXPSMLBwA8qwARsykAE4QuKxQAMIAFmD4ANZiUqryisqsqhoImo4O7OGhPj4h5n6Obh4IunZ2RoZ+ena6nYaGUTHoKcRklNTxqc3sWbkFRSUVVbWihtJIII1K6a1aVtoGTxOOjtbv84YjiObik7ofPM7GFDP9jNofMsQLE1olNmsGLsADLMGrFMqVGp1S5yBS3FRXNqaOzadjiHx2KyORbzcRBczmH4IbTOdjaabaKmdGy6XSRaIw1bbdZJLa0MBI9LsVHo45Ys4XBr45r3dps-n0ubaGxgx6PZlWULkkLBGmDCzGYzQ2Ei+HJEVStjsACqsDA+SdrBdrAANmjqmthBA2GB2MVsMxqmG3R6vT7-TU1hJcdcVXciYgglZycYQiYqRTQoZtMynDmbM4aW8rHYzD4BSs4hL7eLuF7Xe7PWk2AmA0GPflmPl2LJfeQAGbDgC2nbjPe9fv7IpTyqaGdAbXmxnZPkMNNM820VuZ+8M7Dsb3MznpwW31sFtpbGwdEo7dFksjorAgADUPYobAnNiIasGGEZRmGT4JC+bY7NKH5fj+-75IBrDAdUCAQfg5DpCmq5XDcqqZmMjgGDY-yGJeejjFRzJ2P47DZoEJb+Hyx42sKz5ioiC7sIh35-gB6QYcIg7DqO45oFO+SztBhCtrxuwCchwlAQqWGsJGOHNPh9SEemhKbogdLsIMTjmPuNF1nYZaOBW+5OPu9l1oCjZCs2ME8Y6fGIb6BC4WwdDYKQuDjtkvq8HAFC+mgokEXi65GeoiBguYZJOPSJa6Hm1hGsyuglkxxiUjYVjXlq7nyaKCI+cpn7+Tp6TBaF4WRXwsAxXFCpiEqBlJS0JFAo4vg+BCe55e8-QFUVVglVShjlWRtZ2FEgqsMwEBwKo1WKXVG5pgNaokmRZmQg4fyLHR7ieCNpjGPyx7aNo6UNo4nGeQpsFKdKax8AIoyJQSg3Ge0L07q9F3+Istk3Qg1IjUaZ7GNS-LlU4H1wt9+3OvseSFBiGFrsDx01mZ15mHooReFaVj0fZ5Jci5zissYIKY3a2NvnxsrVITCrE8RoMdDucxWgx1jpZCELDHDgKTC9jg6mNXKLDSHPcbV3O7LG3bNH2SYioLB3EmCI1-HuVL6Cj4hU6eNjsIVD3UrWfKXVCj5cV5Wvtr5n6CShaFE-1JMkWzPgXpCjh+Faw3Mjq5jdOlJhGvo-RzRr3uvr79VjgFzQtWFpARVFnWxcHQNCylCBm+eKPjJL4jWMEdNww4O46vSFVsfyD5Nlj3na9KRAUPghCwPAIdV20QIR7e-RzOYbNK98cN7ndgR-BSzgo+YmdfYPOfSgAovkQ75MbyVtItehmSrJgcijz2uHD+pmXyQSQnyVLs2tQA */\n id: \"GetDeviceStatusDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n const sessionState = getDeviceSessionState();\n const { sessionStateType } = sessionState;\n return {\n input: {\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n onboarded: false, // we don't know how to check yet\n locked: false,\n currentApp:\n sessionStateType ===\n DeviceSessionStateType.ReadyWithoutSecureChannel\n ? sessionState.currentApp.name\n : null,\n currentAppVersion: null,\n error: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: {\n target: \"OnboardingCheck\",\n },\n },\n OnboardingCheck: {\n // TODO: we don't have this info for now\n always: [\n {\n guard: {\n type: \"isDeviceOnboarded\",\n },\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n onboarded: true,\n }),\n }),\n },\n {\n target: \"Error\",\n actions: \"assignErrorDeviceNotOnboarded\",\n },\n ],\n },\n UserActionUnlockDevice: {\n // we wait for the device to be unlocked (default timeout is 15s)\n entry: \"assignUserActionUnlockNeeded\",\n exit: \"assignNoUserActionNeeded\",\n invoke: {\n id: \"UserActionUnlockDevice\",\n src: \"waitForDeviceUnlock\",\n input: (_) => ({\n unlockTimeout,\n }),\n onDone: {\n target: \"AppAndVersionCheck\",\n actions: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n locked: false,\n }),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorDeviceLocked\",\n },\n },\n },\n AppAndVersionCheck: {\n // We check the current app and version using the getAppAndVersion command\n invoke: {\n src: \"getAppAndVersion\",\n onDone: {\n target: \"ApplicationAvailableResultCheck\",\n actions: assign({\n _internalState: (_) => {\n if (isSuccessCommandResult(_.event.output)) {\n const state: DeviceSessionState = getDeviceSessionState();\n if (\n state.sessionStateType !==\n DeviceSessionStateType.Connected\n ) {\n // Update the current app\n setDeviceSessionState({\n ...state,\n currentApp: _.event.output.data,\n });\n } else {\n // The device can be set to Ready if GetAppAndVersionCommand was successful\n setDeviceSessionState({\n deviceModelId: state.deviceModelId,\n sessionStateType:\n DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n currentApp: _.event.output.data,\n installedApps: [],\n isSecureConnectionAllowed: false,\n });\n }\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: _.event.output.data.name,\n currentAppVersion: _.event.output.data.version,\n };\n }\n if (\"errorCode\" in _.event.output.error) {\n if (_.event.output.error.errorCode === \"5515\") {\n // Locked device error\n return {\n ..._.context._internalState,\n locked: true,\n };\n } else if (_.event.output.error.errorCode === \"6e00\") {\n // CLA not supported\n // GetAppAndVersion should always be supported by the firmware or any app.\n // But on old firmware versions, that APDU was not supported in the dashboard.\n // On those firmwares, it fails with CLA_NOT_SUPPORTED in BOLOS, and INS_NOT_SUPPORTED\n // in applications. Therefore if CLA is not supported, we can consider we're on the\n // dashboard on an old firmware. We should therefore return that information to\n // ensure the user can still update his firmware and is not blocked at this step.\n return {\n ..._.context._internalState,\n locked: false,\n currentApp: \"BOLOS\",\n currentAppVersion: \"0.0.0\",\n };\n }\n }\n return {\n ..._.context._internalState,\n error: _.event.output.error,\n };\n },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n ApplicationAvailableResultCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"UserActionUnlockDevice\",\n guard: \"isDeviceLocked\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n // TODO: instead we should rely on the current state (\"Success\" or \"Error\")\n const { context } = args;\n const { error, currentApp, currentAppVersion } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right<GetDeviceStatusDAOutput>({\n currentApp: currentApp!,\n currentAppVersion: currentAppVersion!,\n });\n },\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const getAppAndVersion = () => {\n return internalApi.sendCommand(new GetAppAndVersionCommand());\n };\n\n const waitForDeviceUnlock = ({\n input,\n }: {\n input: { unlockTimeout: number };\n }) =>\n new Observable<void>((subscriber) => {\n const inner = internalApi\n .getDeviceSessionStateObservable()\n .pipe(\n tap((state) => {\n if (state.deviceStatus === DeviceStatus.CONNECTED) {\n subscriber.complete();\n inner.unsubscribe();\n }\n }),\n )\n .subscribe();\n\n return () => {\n inner.unsubscribe();\n };\n }).pipe(timeout(input.unlockTimeout));\n\n return {\n getAppAndVersion,\n waitForDeviceUnlock,\n getDeviceSessionState: () => internalApi.getDeviceSessionState(),\n setDeviceSessionState: (state: DeviceSessionState) =>\n internalApi.setDeviceSessionState(state),\n isDeviceOnboarded: () => true, // TODO: we don't have this info for now\n };\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MA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AC,CAAkB,EAAIR,EAAQ,eACzD,OAAIM,EACKhC,EAAKgC,CAAK,EAEZ/B,EAA+B,CACpC,WAAYgC,EACZ,kBAAmBC,CACrB,CAAC,CACH,CACF,CAAC,CACH,CAEA,oBAAoBf,EAA+C,CA4BjE,MAAO,CACL,iBA5BuB,IAChBA,EAAY,YAAY,IAAIT,CAAyB,EA4B5D,oBAzB0B,CAAC,CAC3B,MAAAyB,CACF,IAGE,IAAIjC,EAAkBkC,GAAe,CACnC,MAAMC,EAAQlB,EACX,gCAAgC,EAChC,KACChB,EAAK2B,GAAU,CACTA,EAAM,eAAiBnB,EAAa,YACtCyB,EAAW,SAAS,EACpBC,EAAM,YAAY,EAEtB,CAAC,CACH,EACC,UAAU,EAEb,MAAO,IAAM,CACXA,EAAM,YAAY,CACpB,CACF,CAAC,EAAE,KAAKjC,EAAQ+B,EAAM,aAAa,CAAC,EAKpC,sBAAuB,IAAMhB,EAAY,sBAAsB,EAC/D,sBAAwBW,GACtBX,EAAY,sBAAsBW,CAAK,EACzC,kBAAmB,IAAM,EAC3B,CACF,CACF",
6
6
  "names": ["Left", "Right", "Observable", "tap", "timeout", "assign", "fromObservable", "fromPromise", "setup", "isSuccessCommandResult", "GetAppAndVersionCommand", "DeviceStatus", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "DeviceLockedError", "DeviceNotOnboardedError", "XStateDeviceAction", "DeviceSessionStateType", "GetDeviceStatusDeviceAction", "internalApi", "getAppAndVersion", "getDeviceSessionState", "setDeviceSessionState", "waitForDeviceUnlock", "isDeviceOnboarded", "unlockTimeout", "context", "_", "sessionState", "sessionStateType", "state", "args", "error", "currentApp", "currentAppVersion", "input", "subscriber", "inner"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{interval as h,Observable as C}from"rxjs";import{CommandResultFactory as d}from"../../../command/model/CommandResult";import{GLOBAL_ERRORS as y,GlobalCommandError as V}from"../../../command/utils/GlobalCommandError";import{DeviceModelId as A}from"../../../device/DeviceModel";import{DeviceStatus as i}from"../../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as u}from"../../../device-action/__test-utils__/makeInternalApi";import{testDeviceActionStates as p}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as t}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as a}from"../../../device-action/model/UserInteractionRequired";import{DeviceLockedError as g,DeviceNotOnboardedError as x,UnknownDAError as T}from"../../../device-action/os/Errors";import{DeviceSessionStateType as s}from"../../../device-session/DeviceSessionState";import{GetDeviceStatusDeviceAction as l}from"./GetDeviceStatusDeviceAction";describe("GetDeviceStatusDeviceAction",()=>{const S=vi.fn(),v=vi.fn(),O=vi.fn(),R=vi.fn(),E=vi.fn();function D(){return{getAppAndVersion:S,getDeviceSessionState:v,waitForDeviceUnlock:O,setDeviceSessionState:R,isDeviceOnboarded:E}}const{sendCommand:w,getDeviceSessionState:N,getDeviceSessionStateObservable:f}=u();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({input:{unlockTimeout:500}});N.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED,deviceModelId:A.NANO_X}),w.mockResolvedValue(d({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.Completed}];p(e,n,u(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new l({input:{unlockTimeout:500}});N.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.NANO_X,isSecureConnectionAllowed:!1}),f.mockImplementation(()=>new C(c=>{const m=h(50).subscribe({next:k=>{k>2?(c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.NANO_X,isSecureConnectionAllowed:!1}),c.complete()):c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{m.unsubscribe()}})),w.mockResolvedValueOnce(d({error:new V({...y[5515],errorCode:"5515"})})).mockResolvedValueOnce(d({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.UnlockDevice},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.Completed}];p(e,n,u(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValue(d({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,u(),{onDone:()=>{expect(R).toHaveBeenCalledWith({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.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)=>{v.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED}),S.mockResolvedValue(d({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,u(),{onDone:()=>{expect(R).toHaveBeenCalledWith({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.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)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValueOnce(d({error:new V({...y[5515],errorCode:"5515"})})).mockResolvedValueOnce(d({data:{name:"BOLOS",version:"1.0.0"}})),O.mockImplementation(()=>new C(c=>{const m=h(50).subscribe({next:k=>{k>2?(c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),c.complete()):c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{m.unsubscribe()}}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.UnlockDevice},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,u(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),E.mockReturnValue(!1);const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{error:new x,status:t.Error}];p(e,n,u(),{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)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValue(d({error:new V({...y[5515],errorCode:"5515"})})),f.mockImplementation(()=>new C(c=>{const m=h(200).subscribe({next:()=>{c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{m.unsubscribe()}}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.UnlockDevice},status:t.Pending},{error:new g("Device locked."),status:t.Error}];p(e,n,u(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new V({...y[5501],errorCode:"5501"});S.mockResolvedValue(d({error:e})),O.mockImplementation(()=>new C(m=>{const k=h(50).subscribe({next:b=>{b>2?(m.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),m.complete()):m.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{k.unsubscribe()}}));const n=new l({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(D());const c=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{error:e,status:t.Error}];p(n,c,u(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockImplementation(()=>{throw new T("error")}),O.mockImplementation(()=>new C(c=>{c.complete()}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(D());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{error:new T("error"),status:t.Error}];p(e,n,u(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{N.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:A.NANO_X,isSecureConnectionAllowed:!1}),w.mockResolvedValue(d({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:500}}),n=[{status:t.Pending,intermediateValue:{requiredUserInteraction:a.None}},{status:t.Stopped}],{cancel:c}=p(e,n,u(),{onDone:r,onError:o});c()}))});
1
+ import{interval as w,Observable as C}from"rxjs";import{CommandResultFactory as d}from"../../../command/model/CommandResult";import{GLOBAL_ERRORS as O,GlobalCommandError as h}from"../../../command/utils/GlobalCommandError";import{DeviceModelId as D}from"../../../device/DeviceModel";import{DeviceStatus as i}from"../../../device/DeviceStatus";import{makeDeviceActionInternalApiMock as u}from"../../../device-action/__test-utils__/makeInternalApi";import{testDeviceActionStates as p}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as t}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as a}from"../../../device-action/model/UserInteractionRequired";import{DeviceLockedError as x,DeviceNotOnboardedError as b,UnknownDAError as T}from"../../../device-action/os/Errors";import{DeviceSessionStateType as s}from"../../../device-session/DeviceSessionState";import{GetDeviceStatusDeviceAction as l}from"./GetDeviceStatusDeviceAction";describe("GetDeviceStatusDeviceAction",()=>{const S=vi.fn(),v=vi.fn(),y=vi.fn(),E=vi.fn(),N=vi.fn();function A(){return{getAppAndVersion:S,getDeviceSessionState:v,waitForDeviceUnlock:y,setDeviceSessionState:E,isDeviceOnboarded:N}}const{sendCommand:V,getDeviceSessionState:R,getDeviceSessionStateObservable:f}=u();beforeEach(()=>{vi.resetAllMocks(),N.mockReturnValue(!0)}),describe("without overriding `extractDependencies`",()=>{it("should run the device action with an unlocked device",()=>new Promise((r,o)=>{const e=new l({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED,deviceModelId:D.NANO_X}),V.mockResolvedValue(d({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.Completed}];p(e,n,u(),{onDone:r,onError:o})})),it("should run the device action with a locked device",()=>new Promise((r,o)=>{const e=new l({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.NANO_X,isSecureConnectionAllowed:!1}),f.mockImplementation(()=>new C(c=>{const m=w(50).subscribe({next:k=>{k>2?(c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.NANO_X,isSecureConnectionAllowed:!1}),c.complete()):c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{m.unsubscribe()}})),V.mockResolvedValueOnce(d({error:new h({...O[5515],errorCode:"5515"})})).mockResolvedValueOnce(d({data:{name:"BOLOS",version:"1.0.0"}}));const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.UnlockDevice},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"},status:t.Completed}];p(e,n,u(),{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({input:{unlockTimeout:500}});R.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED,deviceModelId:D.NANO_X}),V.mockResolvedValue(d({error:new h({...O["6e00"],errorCode:"6e00"})}));const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{output:{currentApp:"BOLOS",currentAppVersion:"0.0.0"},status:t.Completed}];p(e,n,u(),{onDone:r,onError:o})}))}),describe("success cases",()=>{it("should return the device status if the device is unlocked",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValue(d({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,u(),{onDone:()=>{expect(E).toHaveBeenCalledWith({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.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)=>{v.mockReturnValue({sessionStateType:s.Connected,deviceStatus:i.CONNECTED}),S.mockResolvedValue(d({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:void 0}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,u(),{onDone:()=>{expect(E).toHaveBeenCalledWith({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.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)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValueOnce(d({error:new h({...O[5515],errorCode:"5515"})})).mockResolvedValueOnce(d({data:{name:"BOLOS",version:"1.0.0"}})),y.mockImplementation(()=>new C(c=>{const m=w(50).subscribe({next:k=>{k>2?(c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),c.complete()):c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{m.unsubscribe()}}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.UnlockDevice},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{status:t.Completed,output:{currentApp:"BOLOS",currentAppVersion:"1.0.0"}}];p(e,n,u(),{onDone:r,onError:o})}))}),describe("errors cases",()=>{it("should end in an error if the device is not onboarded",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),N.mockReturnValue(!1);const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{error:new b,status:t.Error}];p(e,n,u(),{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)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockResolvedValue(d({error:new h({...O[5515],errorCode:"5515"})})),f.mockImplementation(()=>new C(c=>{const m=w(200).subscribe({next:()=>{c.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.NANO_X,isSecureConnectionAllowed:!1})}});return()=>{m.unsubscribe()}}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{intermediateValue:{requiredUserInteraction:a.UnlockDevice},status:t.Pending},{error:new x("Device locked."),status:t.Error}];p(e,n,u(),{onDone:r,onError:o})})),it("should end in an error if the GetAppAndVersion command fails",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}});const e=new h({...O[5501],errorCode:"5501"});S.mockResolvedValue(d({error:e})),y.mockImplementation(()=>new C(m=>{const k=w(50).subscribe({next:g=>{g>2?(m.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),m.complete()):m.next({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}})}});return()=>{k.unsubscribe()}}));const n=new l({input:{unlockTimeout:500}});vi.spyOn(n,"extractDependencies").mockReturnValue(A());const c=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{error:e,status:t.Error}];p(n,c,u(),{onDone:r,onError:o})})),it("should end in an error if getAppAndVersion actor throws an error",()=>new Promise((r,o)=>{v.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.LOCKED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"}}),S.mockImplementation(()=>{throw new T("error")}),y.mockImplementation(()=>new C(c=>{c.complete()}));const e=new l({input:{unlockTimeout:500}});vi.spyOn(e,"extractDependencies").mockReturnValue(A());const n=[{intermediateValue:{requiredUserInteraction:a.None},status:t.Pending},{error:new T("error"),status:t.Error}];p(e,n,u(),{onDone:r,onError:o})}))}),it("should emit a stopped state if the action is cancelled",()=>new Promise((r,o)=>{R.mockReturnValue({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:i.CONNECTED,currentApp:{name:"mockedCurrentApp",version:"1.0.0"},installedApps:[],deviceModelId:D.NANO_X,isSecureConnectionAllowed:!1}),V.mockResolvedValue(d({data:{name:"BOLOS",version:"1.0.0"}}));const e=new l({input:{unlockTimeout:500}}),n=[{status:t.Pending,intermediateValue:{requiredUserInteraction:a.None}},{status:t.Stopped}],{cancel:c}=p(e,n,u(),{onDone:r,onError:o});c()}))});
2
2
  //# sourceMappingURL=GetDeviceStatusDeviceAction.test.js.map